feat: finish cdylib ffi and improve ffi C header
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
# 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
|
||||
# include/ - contains wfassoc.h
|
||||
# lib/ - contains wfassoc_cdylib.dll.lib (import library)
|
||||
#
|
||||
# This module defines the following variables:
|
||||
@@ -36,7 +36,7 @@ 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)
|
||||
if(EXISTS ${wfassoc_INCLUDE_DIR}/wfassoc.h)
|
||||
set(wfassoc_INCLUDE_DIRS ${wfassoc_INCLUDE_DIR})
|
||||
else()
|
||||
message(SEND_ERROR "Missing wfassoc header files in ${wfassoc_INCLUDE_DIR}")
|
||||
|
||||
@@ -2,28 +2,50 @@
|
||||
#ifndef __WFASSOC_H__
|
||||
#define __WFASSOC_H__
|
||||
|
||||
#include <stdarg.h>
|
||||
#ifdef __cplusplus
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#else // __cplusplus
|
||||
#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
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
using CStyleString = const char*;
|
||||
using Token = uint64_t;
|
||||
using HICON = void*;
|
||||
#else // __cplusplus
|
||||
typedef const char *CStyleString;
|
||||
typedef uint64_t Token;
|
||||
typedef void *HICON;
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
enum class Scope : uint32_t {
|
||||
User = 0u,
|
||||
System = 1u
|
||||
};
|
||||
enum class View : uint32_t {
|
||||
User = 0u,
|
||||
System = 1u,
|
||||
Hybrid = 2u
|
||||
};
|
||||
#else // __cplusplus
|
||||
typedef uint32_t Scope;
|
||||
static const Scope SCOPE_USER = 0u;
|
||||
static const Scope SCOPE_SYSTEM = 1u;
|
||||
typedef uint32_t View;
|
||||
static const View VIEW_USER = 0u;
|
||||
static const View VIEW_SYSTEM = 1u;
|
||||
static const View VIEW_HYBRID = 2u;
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace wfassoc {
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
@@ -35,6 +57,8 @@ CStyleString WFGetLastError(void);
|
||||
|
||||
bool WFHasPrivilege(void);
|
||||
|
||||
Token WFInvalidToken(void);
|
||||
|
||||
bool WFSchemaCreate(Token *out_schema);
|
||||
|
||||
bool WFSchemaDestroy(Token in_schema);
|
||||
@@ -67,18 +91,27 @@ bool WFProgramCreate(Token in_schema, Token *out_program);
|
||||
|
||||
bool WFProgramDestroy(Token in_program);
|
||||
|
||||
bool WFProgramRegister(Token in_program, uint32_t in_scope);
|
||||
bool WFProgramRegister(Token in_program, Scope in_scope);
|
||||
|
||||
bool WFProgramUnregister(Token in_program, uint32_t in_scope);
|
||||
bool WFProgramUnregister(Token in_program, Scope in_scope);
|
||||
|
||||
bool WFProgramIsRegistered(Token in_program, uint32_t in_scope, bool *out_is_registered);
|
||||
bool WFProgramIsRegistered(Token in_program, Scope in_scope, bool *out_is_registered);
|
||||
|
||||
bool WFProgramLinkExt(Token in_program, uint32_t in_scope, size_t in_index);
|
||||
bool WFProgramLinkExt(Token in_program, Scope in_scope, size_t in_index);
|
||||
|
||||
bool WFProgramUnlinkExt(Token in_program, uint32_t in_scope, size_t in_index);
|
||||
bool WFProgramUnlinkExt(Token in_program, Scope in_scope, size_t in_index);
|
||||
|
||||
bool WFProgramQueryExt(Token in_program, View in_view, size_t in_index, Token *out_ext_status);
|
||||
|
||||
bool WFExtStatusDestroy(Token in_ext_status);
|
||||
|
||||
bool WFExtStatuGetName(Token in_ext_status, CStyleString *out_name);
|
||||
|
||||
bool WFExtStatuGetIcon(Token in_ext_status, HICON *out_icon);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace wfassoc
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __WFASSOC_H__
|
||||
#endif // __WFASSOC_H__
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
#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);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user