1
0

feat: remove cbindgen. use manual writing instead (actually AI writing)

This commit is contained in:
2026-05-16 13:58:12 +08:00
parent 8d7f96d499
commit 92ec83b8d7
8 changed files with 265 additions and 306 deletions

View File

@@ -0,0 +1,101 @@
# Findwfassoc.cmake
# ----------------
# Find wfassoc library and headers.
#
# This module requires the user to set wfassoc_ROOT to the installation
# directory of wfassoc. The directory structure under wfassoc_ROOT must be:
# bin/ - contains wfassoc_cdylib.dll
# include/ - contains wfassoc.h and wfassoc.hpp
# lib/ - contains wfassoc_cdylib.dll.lib (import library)
#
# This module defines the following variables:
# wfassoc_FOUND - True if wfassoc was found
# wfassoc_INCLUDE_DIRS - Path to wfassoc include directory
# wfassoc_LIBRARIES - Path to wfassoc import library
# wfassoc_DLL - Path to wfassoc DLL
# wfassoc_ROOT - The root directory (user-provided)
#
# This module also creates the following imported targets:
# wfassoc::wfassoc - Main wfassoc library (includes both include and link)
#
set(wfassoc_FOUND FALSE)
# Require user to set wfassoc_ROOT
if(NOT wfassoc_ROOT)
message(FATAL_ERROR "wfassoc_ROOT must be set to the installation directory of wfassoc")
endif()
# Check existence of required subdirectories
if(NOT EXISTS ${wfassoc_ROOT})
message(FATAL_ERROR "wfassoc_ROOT directory does not exist: ${wfassoc_ROOT}")
endif()
set(wfassoc_INCLUDE_DIR ${wfassoc_ROOT}/include)
set(wfassoc_LIB_DIR ${wfassoc_ROOT}/lib)
set(wfassoc_BIN_DIR ${wfassoc_ROOT}/bin)
# Find header files
if(EXISTS ${wfassoc_INCLUDE_DIR}/wfassoc.h AND EXISTS ${wfassoc_INCLUDE_DIR}/wfassoc.hpp)
set(wfassoc_INCLUDE_DIRS ${wfassoc_INCLUDE_DIR})
else()
message(SEND_ERROR "Missing wfassoc header files in ${wfassoc_INCLUDE_DIR}")
return()
endif()
# Find import library (.lib)
find_file(wfassoc_LIBRARIES
NAMES wfassoc_cdylib.dll.lib
PATHS ${wfassoc_LIB_DIR}
NO_DEFAULT_PATH
DOC "wfassoc import library"
)
if(NOT wfassoc_LIBRARIES)
message(SEND_ERROR "Missing wfassoc import library (wfassoc_cdylib.dll.lib) in ${wfassoc_LIB_DIR}")
return()
endif()
# Find DLL file
find_file(wfassoc_DLL
NAMES wfassoc_cdylib.dll
PATHS ${wfassoc_BIN_DIR}
NO_DEFAULT_PATH
DOC "wfassoc dynamic library"
)
if(NOT wfassoc_DLL)
message(SEND_ERROR "Missing wfassoc DLL (wfassoc_cdylib.dll) in ${wfassoc_BIN_DIR}")
return()
endif()
# Everything found
set(wfassoc_FOUND TRUE)
# Mark variables as advanced for ccmake/cmake-gui
mark_as_advanced(wfassoc_INCLUDE_DIRS wfassoc_LIBRARIES wfassoc_DLL)
# Create imported target for wfassoc
if(wfassoc_FOUND AND NOT TARGET wfassoc::wfassoc)
add_library(wfassoc::wfassoc SHARED IMPORTED)
# Set include directories
set_target_properties(wfassoc::wfassoc PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${wfassoc_INCLUDE_DIRS}
)
# Set import library location
set_target_properties(wfassoc::wfassoc PROPERTIES
IMPORTED_IMPLIB "${wfassoc_LIBRARIES}"
IMPORTED_LOCATION "${wfassoc_DLL}"
)
endif()
# Optional: Print status message
if(wfassoc_FOUND)
message(STATUS "Found wfassoc:")
message(STATUS " Root : ${wfassoc_ROOT}")
message(STATUS " Include : ${wfassoc_INCLUDE_DIRS}")
message(STATUS " Library : ${wfassoc_LIBRARIES}")
message(STATUS " DLL : ${wfassoc_DLL}")
endif()

View File

@@ -0,0 +1,84 @@
#pragma once
#ifndef __WFASSOC_H__
#define __WFASSOC_H__
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
typedef const char *CStyleString;
typedef uint64_t Token;
typedef uint32_t Scope;
#define SCOPE_USER 0u
#define SCOPE_SYSTEM 1u
typedef uint32_t View;
#define VIEW_USER 0u
#define VIEW_SYSTEM 1u
#define VIEW_HYBRID 2u
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
bool WFStartup(void);
bool WFShutdown(void);
CStyleString WFGetLastError(void);
bool WFHasPrivilege(void);
bool WFSchemaCreate(Token *out_schema);
bool WFSchemaDestroy(Token in_schema);
bool WFSchemaSetIdentifier(Token in_schema, CStyleString in_value);
bool WFSchemaSetPath(Token in_schema, CStyleString in_value);
bool WFSchemaSetClsid(Token in_schema, CStyleString in_value);
bool WFSchemaSetName(Token in_schema, CStyleString in_value);
bool WFSchemaSetIcon(Token in_schema, CStyleString in_value);
bool WFSchemaSetBehavior(Token in_schema, CStyleString in_value);
bool WFSchemaAddStr(Token in_schema, CStyleString in_name, CStyleString in_value);
bool WFSchemaAddIcon(Token in_schema, CStyleString in_name, CStyleString in_value);
bool WFSchemaAddBehavior(Token in_schema, CStyleString in_name, CStyleString in_value);
bool WFSchemaAddExt(Token in_schema,
CStyleString in_ext,
CStyleString in_ext_name,
CStyleString in_ext_icon,
CStyleString in_ext_behavior);
bool WFProgramCreate(Token in_schema, Token *out_program);
bool WFProgramDestroy(Token in_program);
bool WFProgramRegister(Token in_program, uint32_t in_scope);
bool WFProgramUnregister(Token in_program, uint32_t in_scope);
bool WFProgramIsRegistered(Token in_program, uint32_t in_scope, bool *out_is_registered);
bool WFProgramLinkExt(Token in_program, uint32_t in_scope, size_t in_index);
bool WFProgramUnlinkExt(Token in_program, uint32_t in_scope, size_t in_index);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // __WFASSOC_H__

View File

@@ -0,0 +1,74 @@
#pragma once
#include <cstddef>
#include <cstdint>
#include <string>
enum class Scope : uint32_t {
User = 0u,
System = 1u
};
enum class View : uint32_t {
User = 0u,
System = 1u,
Hybrid = 2u
};
using Token = uint64_t;
using CStyleString = const char*;
extern "C" {
bool WFStartup(void);
bool WFShutdown(void);
CStyleString WFGetLastError(void);
bool WFHasPrivilege(void);
bool WFSchemaCreate(Token *out_schema);
bool WFSchemaDestroy(Token in_schema);
bool WFSchemaSetIdentifier(Token in_schema, CStyleString in_value);
bool WFSchemaSetPath(Token in_schema, CStyleString in_value);
bool WFSchemaSetClsid(Token in_schema, CStyleString in_value);
bool WFSchemaSetName(Token in_schema, CStyleString in_value);
bool WFSchemaSetIcon(Token in_schema, CStyleString in_value);
bool WFSchemaSetBehavior(Token in_schema, CStyleString in_value);
bool WFSchemaAddStr(Token in_schema, CStyleString in_name, CStyleString in_value);
bool WFSchemaAddIcon(Token in_schema, CStyleString in_name, CStyleString in_value);
bool WFSchemaAddBehavior(Token in_schema, CStyleString in_name, CStyleString in_value);
bool WFSchemaAddExt(Token in_schema,
CStyleString in_ext,
CStyleString in_ext_name,
CStyleString in_ext_icon,
CStyleString in_ext_behavior);
bool WFProgramCreate(Token in_schema, Token *out_program);
bool WFProgramDestroy(Token in_program);
bool WFProgramRegister(Token in_program, uint32_t in_scope);
bool WFProgramUnregister(Token in_program, uint32_t in_scope);
bool WFProgramIsRegistered(Token in_program, uint32_t in_scope, bool *out_is_registered);
bool WFProgramLinkExt(Token in_program, uint32_t in_scope, size_t in_index);
bool WFProgramUnlinkExt(Token in_program, uint32_t in_scope, size_t in_index);
}