feat: remove cbindgen. use manual writing instead (actually AI writing)
This commit is contained in:
@@ -14,6 +14,3 @@ thiserror = { workspace = true }
|
||||
wfassoc = { path="../wfassoc" }
|
||||
slotmap = "1.1.1"
|
||||
num_enum = "0.7.6"
|
||||
|
||||
[build-dependencies]
|
||||
cbindgen = "0.29.0"
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
extern crate cbindgen;
|
||||
|
||||
use std::{env, path::Path};
|
||||
|
||||
fn main() {
|
||||
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||
|
||||
let crate_dir_path = Path::new(&crate_dir);
|
||||
let cbindgen_toml_path = crate_dir_path.join("cbindgen.toml");
|
||||
let cbindgen_config = cbindgen::Config::from_file(cbindgen_toml_path)
|
||||
.expect("Unable to load cbindgen configuration file.");
|
||||
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
let out_dir_path = Path::new(&out_dir);
|
||||
let wfassoc_h_path = out_dir_path.join("wfassoc.h");
|
||||
|
||||
cbindgen::Builder::new()
|
||||
.with_crate(crate_dir)
|
||||
.with_config(cbindgen_config)
|
||||
.generate()
|
||||
.expect("Unable to generate bindings")
|
||||
.write_to_file(wfassoc_h_path);
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
# This is a template cbindgen.toml file with all of the default values.
|
||||
# Some values are commented out because their absence is the real default.
|
||||
#
|
||||
# See https://github.com/mozilla/cbindgen/blob/main/docs.md#cbindgentoml
|
||||
# for detailed documentation of every option here.
|
||||
|
||||
|
||||
|
||||
language = "C"
|
||||
|
||||
|
||||
|
||||
############## Options for Wrapping the Contents of the Header #################
|
||||
|
||||
# header = "/* Text to put at the beginning of the generated file. Probably a license. */"
|
||||
# trailer = "/* Text to put at the end of the generated file */"
|
||||
# include_guard = "my_bindings_h"
|
||||
pragma_once = true
|
||||
# autogen_warning = "/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */"
|
||||
include_version = false
|
||||
# namespace = "my_namespace"
|
||||
namespaces = []
|
||||
using_namespaces = []
|
||||
sys_includes = []
|
||||
includes = []
|
||||
no_includes = false
|
||||
cpp_compat = true
|
||||
after_includes = ""
|
||||
|
||||
|
||||
|
||||
|
||||
############################ Code Style Options ################################
|
||||
|
||||
braces = "SameLine"
|
||||
line_length = 100
|
||||
tab_width = 4
|
||||
documentation = true
|
||||
documentation_style = "auto"
|
||||
documentation_length = "full"
|
||||
line_endings = "Native" # also "LF", "CR", "CRLF", "Native"
|
||||
|
||||
|
||||
|
||||
|
||||
############################# Codegen Options ##################################
|
||||
|
||||
style = "both"
|
||||
sort_by = "Name" # default for `fn.sort_by` and `const.sort_by`
|
||||
usize_is_size_t = true
|
||||
|
||||
|
||||
|
||||
[defines]
|
||||
# "target_os = freebsd" = "DEFINE_FREEBSD"
|
||||
# "feature = serde" = "DEFINE_SERDE"
|
||||
|
||||
|
||||
|
||||
[export]
|
||||
include = []
|
||||
exclude = []
|
||||
# prefix = "CAPI_"
|
||||
item_types = []
|
||||
renaming_overrides_prefixing = false
|
||||
|
||||
|
||||
|
||||
[export.rename]
|
||||
|
||||
|
||||
|
||||
[export.body]
|
||||
|
||||
|
||||
[export.mangle]
|
||||
|
||||
|
||||
[fn]
|
||||
rename_args = "None"
|
||||
# must_use = "MUST_USE_FUNC"
|
||||
# deprecated = "DEPRECATED_FUNC"
|
||||
# deprecated_with_note = "DEPRECATED_FUNC_WITH_NOTE"
|
||||
# no_return = "NO_RETURN"
|
||||
# prefix = "START_FUNC"
|
||||
# postfix = "END_FUNC"
|
||||
args = "auto"
|
||||
sort_by = "None"
|
||||
|
||||
|
||||
|
||||
|
||||
[struct]
|
||||
rename_fields = "None"
|
||||
# must_use = "MUST_USE_STRUCT"
|
||||
# deprecated = "DEPRECATED_STRUCT"
|
||||
# deprecated_with_note = "DEPRECATED_STRUCT_WITH_NOTE"
|
||||
rename_associated_constant = "None"
|
||||
derive_constructor = false
|
||||
derive_eq = false
|
||||
derive_neq = false
|
||||
derive_lt = false
|
||||
derive_lte = false
|
||||
derive_gt = false
|
||||
derive_gte = false
|
||||
|
||||
|
||||
|
||||
|
||||
[enum]
|
||||
rename_variants = "UpperCase"
|
||||
# must_use = "MUST_USE_ENUM"
|
||||
# deprecated = "DEPRECATED_ENUM"
|
||||
# deprecated_with_note = "DEPRECATED_ENUM_WITH_NOTE"
|
||||
add_sentinel = false
|
||||
prefix_with_name = true
|
||||
derive_helper_methods = false
|
||||
derive_const_casts = false
|
||||
derive_mut_casts = false
|
||||
# cast_assert_name = "ASSERT"
|
||||
derive_tagged_enum_destructor = false
|
||||
derive_tagged_enum_copy_constructor = false
|
||||
enum_class = true
|
||||
private_default_tagged_enum_constructor = false
|
||||
|
||||
|
||||
|
||||
|
||||
[const]
|
||||
allow_static_const = true
|
||||
allow_constexpr = false
|
||||
sort_by = "Name"
|
||||
|
||||
|
||||
|
||||
|
||||
[macro_expansion]
|
||||
bitflags = false
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
############## Options for How Your Rust library Should Be Parsed ##############
|
||||
|
||||
[parse]
|
||||
parse_deps = false
|
||||
# include = []
|
||||
exclude = []
|
||||
clean = false
|
||||
extra_bindings = []
|
||||
|
||||
|
||||
|
||||
[parse.expand]
|
||||
crates = ["wfassoc-cdylib"]
|
||||
all_features = false
|
||||
default_features = true
|
||||
features = []
|
||||
101
wfassoc-cdylib/codegen/Findwfassoc.cmake
Normal file
101
wfassoc-cdylib/codegen/Findwfassoc.cmake
Normal 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()
|
||||
84
wfassoc-cdylib/codegen/wfassoc.h
Normal file
84
wfassoc-cdylib/codegen/wfassoc.h
Normal 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__
|
||||
74
wfassoc-cdylib/codegen/wfassoc.hpp
Normal file
74
wfassoc-cdylib/codegen/wfassoc.hpp
Normal 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);
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@ pub enum Error {
|
||||
NoSuchToken,
|
||||
}
|
||||
|
||||
/// The token for fetching obejct in [ObjectPool].
|
||||
/// The token for fetching object in [ObjectPool].
|
||||
pub type Token = u64;
|
||||
|
||||
/// A pool for managing objects with unique tokens.
|
||||
|
||||
Reference in New Issue
Block a user