diff --git a/wfassoc-cdylib/cbindgen/wfassoc++.h b/wfassoc-cdylib/cbindgen/wfassoc++.h index 0caa545..ac468b2 100644 --- a/wfassoc-cdylib/cbindgen/wfassoc++.h +++ b/wfassoc-cdylib/cbindgen/wfassoc++.h @@ -19,13 +19,13 @@ namespace wfassocpp { -using wfassoc::CStyleString; -using wfassoc::Token; -using wfassoc::HICON; -using wfassoc::INVALID_HICON; -using wfassoc::INVALID_INDEX; -using wfassoc::Scope; -using wfassoc::View; +using CString = wfassoc::WFCString; +using Token = wfassoc::WFToken; +using HICON = wfassoc::WFHICON; +using INVALID_HICON = wfassoc::WF_INVALID_HICON; +using INVALID_INDEX = wfassoc::WF_INVALID_INDEX; +using Scope = wfassoc::WFScope; +using View = wfassoc::WFView; /// @private inline void _Check(bool result) { diff --git a/wfassoc-cdylib/cbindgen/wfassoc.h b/wfassoc-cdylib/cbindgen/wfassoc.h index 6bb9d43..ff03d7e 100644 --- a/wfassoc-cdylib/cbindgen/wfassoc.h +++ b/wfassoc-cdylib/cbindgen/wfassoc.h @@ -28,35 +28,35 @@ namespace wfassoc { #ifdef __cplusplus /** Type representing a null-terminated UTF-8 C-style string */ -using CStyleString = const char*; +using WFCString = const char*; /** * @brief Type representing a handle/token for managed objects * * This library use object pool to manage any objects created during calling. * And we expose this type as an opaque handle for visiting your created object. */ -using Token = uint64_t; +using WFToken = uint64_t; /** * @brief Type representing an icon handle (opaque pointer) * * This type is equivalent with Win32 HICON type. */ -using HICON = void*; +using WFHICON = void*; #else // __cplusplus -typedef const char *CStyleString; -typedef uint64_t Token; -typedef void *HICON; +typedef const char *WFCString; +typedef uint64_t WFToken; +typedef void *WFHICON; #endif // __cplusplus #ifdef __cplusplus /** Invalid icon handle value */ -constexpr HICON INVALID_HICON = nullptr; +constexpr WFHICON WF_INVALID_HICON = nullptr; /** Invalid index value used for error conditions */ -constexpr size_t INVALID_INDEX = static_cast(-1); +constexpr size_t WF_INVALID_INDEX = static_cast(-1); #else // __cplusplus -static const HICON INVALID_HICON = NULL; -static const size_t INVALID_INDEX = ((size_t)-1); +static const WFHICON WF_INVALID_HICON = NULL; +static const size_t WF_INVALID_INDEX = ((size_t)-1); #endif // __cplusplus @@ -66,7 +66,7 @@ static const size_t INVALID_INDEX = ((size_t)-1); * * Determines whether a program is registered for the current user or system-wide. */ -enum class Scope : uint32_t { +enum class WFScope : uint32_t { /** Current user scope */ User = 0u, /** System-wide scope */ @@ -77,7 +77,7 @@ enum class Scope : uint32_t { * * Determines how the association status is viewed/queried. */ -enum class View : uint32_t { +enum class WFView : uint32_t { /** User-level view */ User = 0u, /** System-level view */ @@ -86,18 +86,18 @@ enum class View : uint32_t { Hybrid = 2u }; #else // __cplusplus -typedef uint32_t Scope; +typedef uint32_t WFScope; /** Current user scope */ -static const Scope SCOPE_USER = 0u; +static const WFScope WF_SCOPE_USER = 0u; /** System-wide scope */ -static const Scope SCOPE_SYSTEM = 1u; -typedef uint32_t View; +static const WFScope WF_SCOPE_SYSTEM = 1u; +typedef uint32_t WFView; /** User-level view */ -static const View VIEW_USER = 0u; +static const WFView WF_VIEW_USER = 0u; /** System-level view */ -static const View VIEW_SYSTEM = 1u; +static const WFView WF_VIEW_SYSTEM = 1u; /** Combined hybrid view of both user and system */ -static const View VIEW_HYBRID = 2u; +static const WFView WF_VIEW_HYBRID = 2u; #endif // __cplusplus @@ -143,7 +143,7 @@ bool WFShutdown(void); * If no error has occurred, the string is empty. * There is no possibility of a NULL return value. */ -CStyleString WFGetLastError(void); +WFCString WFGetLastError(void); /** * @brief Check if the current process has administrative privileges @@ -170,7 +170,7 @@ bool WFHasPrivilege(void); * * @return An invalid token value */ -Token WFInvalidToken(void); +WFToken WFInvalidWFToken(void); /** * @brief Create a new Schema object @@ -185,7 +185,7 @@ Token WFInvalidToken(void); * or consumed by creating a Program object via WFProgramCreate(). * @return true on success, false on failure */ -bool WFSchemaCreate(Token *out_schema); +bool WFSchemaCreate(WFToken *out_schema); /** * @brief Destroy a Schema object @@ -198,7 +198,7 @@ bool WFSchemaCreate(Token *out_schema); * @param[in] in_schema Schema token to destroy * @return true on success, false on failure */ -bool WFSchemaDestroy(Token in_schema); +bool WFSchemaDestroy(WFToken in_schema); /** * @brief Set the program identifier for a Schema @@ -209,7 +209,7 @@ bool WFSchemaDestroy(Token in_schema); * and follow with alphabet characters, digits, underline, or hyphens. * @return true on success, false on failure */ -bool WFSchemaSetIdentifier(Token in_schema, CStyleString in_value); +bool WFSchemaSetIdentifier(WFToken in_schema, WFCString in_value); /** * @brief Set the program path for a Schema @@ -219,7 +219,7 @@ bool WFSchemaSetIdentifier(Token in_schema, CStyleString in_value); * This path should be the fully qualified path to the application. * @return true on success, false on failure */ -bool WFSchemaSetPath(Token in_schema, CStyleString in_value); +bool WFSchemaSetPath(WFToken in_schema, WFCString in_value); /** * @brief Set the program CLSID for a Schema @@ -230,7 +230,7 @@ bool WFSchemaSetPath(Token in_schema, CStyleString in_value); * Please note that curly braces are required. * @return true on success, false on failure */ -bool WFSchemaSetClsid(Token in_schema, CStyleString in_value); +bool WFSchemaSetClsid(WFToken in_schema, WFCString in_value); /** * @brief Set the program name for a Schema (optional) @@ -239,7 +239,7 @@ bool WFSchemaSetClsid(Token in_schema, CStyleString in_value); * @param[in] in_value Null-terminated UTF-8 string containing the name, or NULL to clear * @return true on success, false on failure */ -bool WFSchemaSetName(Token in_schema, CStyleString in_value); +bool WFSchemaSetName(WFToken in_schema, WFCString in_value); /** * @brief Set the program icon for a Schema (optional) @@ -248,7 +248,7 @@ bool WFSchemaSetName(Token in_schema, CStyleString in_value); * @param[in] in_value Null-terminated UTF-8 string containing the icon path, or NULL to clear * @return true on success, false on failure */ -bool WFSchemaSetIcon(Token in_schema, CStyleString in_value); +bool WFSchemaSetIcon(WFToken in_schema, WFCString in_value); /** * @brief Set the program behavior for a Schema (optional) @@ -257,7 +257,7 @@ bool WFSchemaSetIcon(Token in_schema, CStyleString in_value); * @param[in] in_value Null-terminated UTF-8 string containing the behavior command, or NULL to clear * @return true on success, false on failure */ -bool WFSchemaSetBehavior(Token in_schema, CStyleString in_value); +bool WFSchemaSetBehavior(WFToken in_schema, WFCString in_value); /** * @brief Add a string resource entry to a Schema @@ -268,7 +268,7 @@ bool WFSchemaSetBehavior(Token in_schema, CStyleString in_value); * It can be a plain string or a reference string to resource. * @return true on success, false on failure */ -bool WFSchemaAddStr(Token in_schema, CStyleString in_name, CStyleString in_value); +bool WFSchemaAddStr(WFToken in_schema, WFCString in_name, WFCString in_value); /** * @brief Add an icon registry entry to a Schema @@ -279,7 +279,7 @@ bool WFSchemaAddStr(Token in_schema, CStyleString in_name, CStyleString in_value * It can be a path to icon or a reference string to resource. * @return true on success, false on failure */ -bool WFSchemaAddIcon(Token in_schema, CStyleString in_name, CStyleString in_value); +bool WFSchemaAddIcon(WFToken in_schema, WFCString in_name, WFCString in_value); /** * @brief Add a behavior registry entry to a Schema @@ -290,7 +290,7 @@ bool WFSchemaAddIcon(Token in_schema, CStyleString in_name, CStyleString in_valu * It should be a valid command line string which use \c %1, \c %2, etc. to represent parameters. * @return true on success, false on failure */ -bool WFSchemaAddBehavior(Token in_schema, CStyleString in_name, CStyleString in_value); +bool WFSchemaAddBehavior(WFToken in_schema, WFCString in_name, WFCString in_value); /** * @brief Add a file extension to a Schema @@ -305,11 +305,11 @@ bool WFSchemaAddBehavior(Token in_schema, CStyleString in_name, CStyleString in_ * This name should be registered by calling WFSchemaAddBehavior(). * @return true on success, false on failure */ -bool WFSchemaAddExt(Token in_schema, - CStyleString in_ext, - CStyleString in_ext_name, - CStyleString in_ext_icon, - CStyleString in_ext_behavior); +bool WFSchemaAddExt(WFToken in_schema, + WFCString in_ext, + WFCString in_ext_name, + WFCString in_ext_icon, + WFCString in_ext_behavior); /** * @brief Create a Program object from a Schema @@ -327,7 +327,7 @@ bool WFSchemaAddExt(Token in_schema, * And it should be freed by calling WFProgramDestroy() when it is no longer needed. * @return true on success, false on failure */ -bool WFProgramCreate(Token in_schema, Token *out_program); +bool WFProgramCreate(WFToken in_schema, WFToken *out_program); /** * @brief Destroy a Program object @@ -337,7 +337,7 @@ bool WFProgramCreate(Token in_schema, Token *out_program); * @param[in] in_program Program token to destroy * @return true on success, false on failure */ -bool WFProgramDestroy(Token in_program); +bool WFProgramDestroy(WFToken in_program); /** * @brief Resolve the provided program name of this Program @@ -352,7 +352,7 @@ bool WFProgramDestroy(Token in_program); * This string will be freed at the next API call. Please make a copy immediately if you need to use it longer. * @return true on success, false on failure */ -bool WFProgramResolveName(Token in_program, CStyleString *out_name); +bool WFProgramResolveName(WFToken in_program, WFCString *out_name); /** * @brief Resolve the Program icon resource @@ -367,7 +367,7 @@ bool WFProgramResolveName(Token in_program, CStyleString *out_name); * And it should be freed by calling WFIconRcDestroy() when it is no longer needed. * @return true on success, false on failure */ -bool WFProgramResolveIcon(Token in_program, Token *out_icon_rc); +bool WFProgramResolveIcon(WFToken in_program, WFToken *out_icon_rc); /** * @brief Get the number of file extensions in the Program @@ -376,17 +376,17 @@ bool WFProgramResolveIcon(Token in_program, Token *out_icon_rc); * @param[out] out_len Pointer to receive the number of extensions * @return true on success, false on failure */ -bool WFProgramExtsLen(Token in_program, size_t *out_len); +bool WFProgramExtsLen(WFToken in_program, size_t *out_len); /** * @brief Find a file extension by its body (extension string) * * @param[in] in_program Program token * @param[in] in_body Null-terminated UTF-8 string containing the file extension name (without leading dot) to find. - * @param[out] out_index Pointer to receive the file extension index, or INVALID_INDEX if not found. + * @param[out] out_index Pointer to receive the file extension index, or WF_INVALID_INDEX if not found. * @return true on success, false on failure */ -bool WFProgramFindExt(Token in_program, CStyleString in_body, size_t *out_index); +bool WFProgramFindExt(WFToken in_program, WFCString in_body, size_t *out_index); /** * @brief Resolve this program provided extension's details by index @@ -398,7 +398,7 @@ bool WFProgramFindExt(Token in_program, CStyleString in_body, size_t *out_index) * And it should be freed by calling WFSelfExtStatusDestroy() when it is no longer needed. * @return true on success, false on failure */ -bool WFProgramResolveExt(Token in_program, size_t in_index, Token *out_self_ext_status); +bool WFProgramResolveExt(WFToken in_program, size_t in_index, WFToken *out_self_ext_status); /** * @brief Register the Program in the specified scope @@ -407,7 +407,7 @@ bool WFProgramResolveExt(Token in_program, size_t in_index, Token *out_self_ext_ * @param[in] in_scope Registration scope * @return true on success, false on failure */ -bool WFProgramRegister(Token in_program, Scope in_scope); +bool WFProgramRegister(WFToken in_program, WFScope in_scope); /** * @brief Unregister the Program from the specified scope @@ -416,7 +416,7 @@ bool WFProgramRegister(Token in_program, Scope in_scope); * @param[in] in_scope Registration scope * @return true on success, false on failure */ -bool WFProgramUnregister(Token in_program, Scope in_scope); +bool WFProgramUnregister(WFToken in_program, WFScope in_scope); /** * @brief Check if the Program is registered in the specified scope @@ -427,7 +427,7 @@ bool WFProgramUnregister(Token in_program, Scope in_scope); * True if the Program is registered in the specified scope, false otherwise. * @return true on success, false on failure */ -bool WFProgramIsRegistered(Token in_program, Scope in_scope, bool *out_is_registered); +bool WFProgramIsRegistered(WFToken in_program, WFScope in_scope, bool *out_is_registered); /** * @brief Link a file extension in the specified scope @@ -437,7 +437,7 @@ bool WFProgramIsRegistered(Token in_program, Scope in_scope, bool *out_is_regist * @param[in] in_index Index of the extension to link * @return true on success, false on failure */ -bool WFProgramLinkExt(Token in_program, Scope in_scope, size_t in_index); +bool WFProgramLinkExt(WFToken in_program, WFScope in_scope, size_t in_index); /** * @brief Unlink a file extension in the specified scope @@ -447,7 +447,7 @@ bool WFProgramLinkExt(Token in_program, Scope in_scope, size_t in_index); * @param[in] in_index Index of the extension to unlink * @return true on success, false on failure */ -bool WFProgramUnlinkExt(Token in_program, Scope in_scope, size_t in_index); +bool WFProgramUnlinkExt(WFToken in_program, WFScope in_scope, size_t in_index); /** * @brief Query the status of a file extension @@ -461,7 +461,7 @@ bool WFProgramUnlinkExt(Token in_program, Scope in_scope, size_t in_index); * And it should be freed by calling WFExtStatusDestroy() when it is no longer needed. * @return true on success, false on failure */ -bool WFProgramQueryExt(Token in_program, View in_view, size_t in_index, Token *out_ext_status); +bool WFProgramQueryExt(WFToken in_program, WFView in_view, size_t in_index, WFToken *out_ext_status); /** * @brief Destroy an extension status object @@ -469,7 +469,7 @@ bool WFProgramQueryExt(Token in_program, View in_view, size_t in_index, Token *o * @param[in] in_ext_status Extension status token to destroy * @return true on success, false on failure */ -bool WFExtStatusDestroy(Token in_ext_status); +bool WFExtStatusDestroy(WFToken in_ext_status); /** * @brief Get the display name from an extension status object @@ -484,7 +484,7 @@ bool WFExtStatusDestroy(Token in_ext_status); * This string will be freed at the next API call. Please make a copy immediately if you need to use it longer. * @return true on success, false on failure */ -bool WFExtStatusGetName(Token in_ext_status, CStyleString *out_name); +bool WFExtStatusGetName(WFToken in_ext_status, WFCString *out_name); /** * @brief Get the icon from an extension status object @@ -498,7 +498,7 @@ bool WFExtStatusGetName(Token in_ext_status, CStyleString *out_name); * Please make a copy immediately if you need to use it longer. * @return true on success, false on failure */ -bool WFExtStatusGetIcon(Token in_ext_status, HICON *out_icon); +bool WFExtStatusGetIcon(WFToken in_ext_status, WFHICON *out_icon); /** * @brief Destroy a self extension status object @@ -506,7 +506,7 @@ bool WFExtStatusGetIcon(Token in_ext_status, HICON *out_icon); * @param[in] in_self_ext_status Self extension status token to destroy * @return true on success, false on failure */ -bool WFSelfExtStatusDestroy(Token in_self_ext_status); +bool WFSelfExtStatusDestroy(WFToken in_self_ext_status); /** * @brief Get the display name from a self extension status object @@ -520,7 +520,7 @@ bool WFSelfExtStatusDestroy(Token in_self_ext_status); * This string will be freed at the next API call. Please make a copy immediately if you need to use it longer. * @return true on success, false on failure */ -bool WFSelfExtStatusGetName(Token in_self_ext_status, CStyleString *out_name); +bool WFSelfExtStatusGetName(WFToken in_self_ext_status, WFCString *out_name); /** * @brief Get the icon from a self extension status object @@ -534,7 +534,7 @@ bool WFSelfExtStatusGetName(Token in_self_ext_status, CStyleString *out_name); * Please make a copy immediately if you need to use it longer. * @return true on success, false on failure */ -bool WFSelfExtStatusGetIcon(Token in_self_ext_status, HICON *out_icon); +bool WFSelfExtStatusGetIcon(WFToken in_self_ext_status, WFHICON *out_icon); /** * @brief Get the extension string (without leading dot) from a self extension status object @@ -545,7 +545,7 @@ bool WFSelfExtStatusGetIcon(Token in_self_ext_status, HICON *out_icon); * This string will be freed at the next API call. Please make a copy immediately if you need to use it longer. * @return true on success, false on failure */ -bool WFSelfExtStatusGetExt(Token in_self_ext_status, CStyleString *out_inner); +bool WFSelfExtStatusGetExt(WFToken in_self_ext_status, WFCString *out_inner); /** * @brief Get the dotted extension string (with leading dot) from a self extension status object @@ -556,7 +556,7 @@ bool WFSelfExtStatusGetExt(Token in_self_ext_status, CStyleString *out_inner); * This string will be freed at the next API call. Please make a copy immediately if you need to use it longer. * @return true on success, false on failure */ -bool WFSelfExtStatusGetDottedExt(Token in_self_ext_status, CStyleString *out_inner); +bool WFSelfExtStatusGetDottedExt(WFToken in_self_ext_status, WFCString *out_inner); /** * @brief Destroy an icon resource object @@ -564,19 +564,19 @@ bool WFSelfExtStatusGetDottedExt(Token in_self_ext_status, CStyleString *out_inn * @param[in] in_icon_rc Icon resource token to destroy * @return true on success, false on failure */ -bool WFIconRcDestroy(Token in_icon_rc); +bool WFIconRcDestroy(WFToken in_icon_rc); /** * @brief Get the icon handle from an icon resource object * * @param[in] in_icon_rc Icon resource token * @param[out] out_icon Pointer to receive the icon handle. - * There is no possibility that this value is INVALID_HICON. + * There is no possibility that this value is WF_INVALID_HICON. * This icon handle will be freed once this icon resource object is destroyed. * Please make a copy immediately if you need to use it longer. * @return true on success, false on failure */ -bool WFIconRcGetIcon(Token in_icon_rc, HICON *out_icon); +bool WFIconRcGetIcon(WFToken in_icon_rc, WFHICON *out_icon); #ifdef __cplusplus } // extern "C" diff --git a/wfassoc-cdylib/src/cstr_ffi.rs b/wfassoc-cdylib/src/cstr_ffi.rs index 8ff80be..9f3bd9a 100644 --- a/wfassoc-cdylib/src/cstr_ffi.rs +++ b/wfassoc-cdylib/src/cstr_ffi.rs @@ -9,11 +9,9 @@ //! The only thing that outer programs should note is that this string is volatile, //! once they get it, they must dupliate it immediately before any futher calling to this dynamic library. use std::cell::RefCell; -use std::ffi::{CStr, CString, c_char}; +use std::ffi::{CStr, CString}; use thiserror::Error as TeError; - -/// The type representing the raw pointer to immutable C-style NUL-terminated string. -pub type CStyleString = *const c_char; +use crate::ffi_types::CStyleString; // region: Error diff --git a/wfassoc-cdylib/src/ffi_types.rs b/wfassoc-cdylib/src/ffi_types.rs index df2ebef..a4b34f5 100644 --- a/wfassoc-cdylib/src/ffi_types.rs +++ b/wfassoc-cdylib/src/ffi_types.rs @@ -1,11 +1,15 @@ //! The module including all FFI types used by this crate, except string type. //! For string type, see also [crate::cstr_ffi]. -use std::ffi::c_void; +use std::ffi::{c_void, c_char}; use num_enum::TryFromPrimitive; -// region: File Extension Index +// region: Misc Types and Constants +/// The type representing the raw pointer to immutable C-style NUL-terminated string. +pub type CStyleString = *const c_char; + +/// The invalid value of index. pub const INVALID_INDEX: usize = usize::MAX; // endregion @@ -23,7 +27,7 @@ pub type HICON = *mut c_void; /// The invalid value of Win32 HICON handle. /// -/// The same reason like [HICON] to re-define it in there. +/// The same reason like [WFHICON] to re-define it in there. pub const INVALID_HICON: HICON = std::ptr::null_mut(); // endregion diff --git a/wfassoc-cdylib/src/lib.rs b/wfassoc-cdylib/src/lib.rs index 0073e9c..9baf416 100644 --- a/wfassoc-cdylib/src/lib.rs +++ b/wfassoc-cdylib/src/lib.rs @@ -202,9 +202,11 @@ static ICON_RC_POOL: LazyLock // region: Exposed Types -pub use cstr_ffi::CStyleString; -pub use ffi_types::{HICON, Scope, View}; -pub use object_pool::Token; +pub use ffi_types::{ + CStyleString as WFCString, HICON as WFHICON, Scope as WFScope, View as WFView, +}; +pub use ffi_types::{INVALID_HICON as WF_INVALID_HICON, INVALID_INDEX as WF_INVALID_INDEX}; +pub use object_pool::Token as WFToken; // endregion @@ -244,7 +246,7 @@ pub extern "C" fn WFShutdown() -> bool { } #[unsafe(no_mangle)] -pub extern "C" fn WFGetLastError() -> CStyleString { +pub extern "C" fn WFGetLastError() -> WFCString { last_error::get_last_error() } @@ -254,7 +256,7 @@ pub extern "C" fn WFHasPrivilege() -> bool { } #[unsafe(no_mangle)] -pub extern "C" fn WFInvalidToken() -> Token { +pub extern "C" fn WFInvalidToken() -> WFToken { object_pool::invalid_token() } @@ -263,16 +265,16 @@ pub extern "C" fn WFInvalidToken() -> Token { // region: Schema #[unsafe(no_mangle)] -pub extern "C" fn WFSchemaCreate(out_schema: out_param_ty!(Token)) -> bool { - cffi_wrapper!(|| -> (out_schema: Token) { +pub extern "C" fn WFSchemaCreate(out_schema: out_param_ty!(WFToken)) -> bool { + cffi_wrapper!(|| -> (out_schema: WFToken) { let mut pool = pull_writer!(SCHEMA_POOL)?; Ok(pool.allocate(Schema::new())?) }) } #[unsafe(no_mangle)] -pub extern "C" fn WFSchemaDestroy(in_schema: in_param_ty!(Token)) -> bool { - cffi_wrapper!(|in_schema: Token| { +pub extern "C" fn WFSchemaDestroy(in_schema: in_param_ty!(WFToken)) -> bool { + cffi_wrapper!(|in_schema: WFToken| { let mut pool = pull_writer!(SCHEMA_POOL)?; Ok(pool.free(in_schema)?) }) @@ -280,10 +282,10 @@ pub extern "C" fn WFSchemaDestroy(in_schema: in_param_ty!(Token)) -> bool { #[unsafe(no_mangle)] pub extern "C" fn WFSchemaSetIdentifier( - in_schema: in_param_ty!(Token), - in_value: in_param_ty!(CStyleString), + in_schema: in_param_ty!(WFToken), + in_value: in_param_ty!(WFCString), ) -> bool { - cffi_wrapper!(|in_schema: Token, in_value: CStyleString| { + cffi_wrapper!(|in_schema: WFToken, in_value: WFCString| { let mut pool = pull_writer!(SCHEMA_POOL)?; let schema = pool.get_mut(in_schema)?; schema.set_identifier(cstr_ffi::parse_ffi_string(in_value)?); @@ -293,10 +295,10 @@ pub extern "C" fn WFSchemaSetIdentifier( #[unsafe(no_mangle)] pub extern "C" fn WFSchemaSetPath( - in_schema: in_param_ty!(Token), - in_value: in_param_ty!(CStyleString), + in_schema: in_param_ty!(WFToken), + in_value: in_param_ty!(WFCString), ) -> bool { - cffi_wrapper!(|in_schema: Token, in_value: CStyleString| { + cffi_wrapper!(|in_schema: WFToken, in_value: WFCString| { let mut pool = pull_writer!(SCHEMA_POOL)?; let schema = pool.get_mut(in_schema)?; schema.set_path(cstr_ffi::parse_ffi_string(in_value)?); @@ -306,10 +308,10 @@ pub extern "C" fn WFSchemaSetPath( #[unsafe(no_mangle)] pub extern "C" fn WFSchemaSetClsid( - in_schema: in_param_ty!(Token), - in_value: in_param_ty!(CStyleString), + in_schema: in_param_ty!(WFToken), + in_value: in_param_ty!(WFCString), ) -> bool { - cffi_wrapper!(|in_schema: Token, in_value: CStyleString| { + cffi_wrapper!(|in_schema: WFToken, in_value: WFCString| { let mut pool = pull_writer!(SCHEMA_POOL)?; let schema = pool.get_mut(in_schema)?; schema.set_clsid(cstr_ffi::parse_ffi_string(in_value)?); @@ -319,10 +321,10 @@ pub extern "C" fn WFSchemaSetClsid( #[unsafe(no_mangle)] pub extern "C" fn WFSchemaSetName( - in_schema: in_param_ty!(Token), - in_value: in_param_ty!(CStyleString), + in_schema: in_param_ty!(WFToken), + in_value: in_param_ty!(WFCString), ) -> bool { - cffi_wrapper!(|in_schema: Token, in_value: CStyleString| { + cffi_wrapper!(|in_schema: WFToken, in_value: WFCString| { let mut pool = pull_writer!(SCHEMA_POOL)?; let schema = pool.get_mut(in_schema)?; @@ -338,10 +340,10 @@ pub extern "C" fn WFSchemaSetName( #[unsafe(no_mangle)] pub extern "C" fn WFSchemaSetIcon( - in_schema: in_param_ty!(Token), - in_value: in_param_ty!(CStyleString), + in_schema: in_param_ty!(WFToken), + in_value: in_param_ty!(WFCString), ) -> bool { - cffi_wrapper!(|in_schema: Token, in_value: CStyleString| { + cffi_wrapper!(|in_schema: WFToken, in_value: WFCString| { let mut pool = pull_writer!(SCHEMA_POOL)?; let schema = pool.get_mut(in_schema)?; @@ -357,10 +359,10 @@ pub extern "C" fn WFSchemaSetIcon( #[unsafe(no_mangle)] pub extern "C" fn WFSchemaSetBehavior( - in_schema: in_param_ty!(Token), - in_value: in_param_ty!(CStyleString), + in_schema: in_param_ty!(WFToken), + in_value: in_param_ty!(WFCString), ) -> bool { - cffi_wrapper!(|in_schema: Token, in_value: CStyleString| { + cffi_wrapper!(|in_schema: WFToken, in_value: WFCString| { let mut pool = pull_writer!(SCHEMA_POOL)?; let schema = pool.get_mut(in_schema)?; @@ -376,12 +378,12 @@ pub extern "C" fn WFSchemaSetBehavior( #[unsafe(no_mangle)] pub extern "C" fn WFSchemaAddStr( - in_schema: in_param_ty!(Token), - in_name: in_param_ty!(CStyleString), - in_value: in_param_ty!(CStyleString), + in_schema: in_param_ty!(WFToken), + in_name: in_param_ty!(WFCString), + in_value: in_param_ty!(WFCString), ) -> bool { cffi_wrapper!( - |in_schema: Token, in_name: CStyleString, in_value: CStyleString| { + |in_schema: WFToken, in_name: WFCString, in_value: WFCString| { let mut pool = pull_writer!(SCHEMA_POOL)?; let schema = pool.get_mut(in_schema)?; schema.add_str( @@ -395,12 +397,12 @@ pub extern "C" fn WFSchemaAddStr( #[unsafe(no_mangle)] pub extern "C" fn WFSchemaAddIcon( - in_schema: in_param_ty!(Token), - in_name: in_param_ty!(CStyleString), - in_value: in_param_ty!(CStyleString), + in_schema: in_param_ty!(WFToken), + in_name: in_param_ty!(WFCString), + in_value: in_param_ty!(WFCString), ) -> bool { cffi_wrapper!( - |in_schema: Token, in_name: CStyleString, in_value: CStyleString| { + |in_schema: WFToken, in_name: WFCString, in_value: WFCString| { let mut pool = pull_writer!(SCHEMA_POOL)?; let schema = pool.get_mut(in_schema)?; schema.add_icon( @@ -414,12 +416,12 @@ pub extern "C" fn WFSchemaAddIcon( #[unsafe(no_mangle)] pub extern "C" fn WFSchemaAddBehavior( - in_schema: in_param_ty!(Token), - in_name: in_param_ty!(CStyleString), - in_value: in_param_ty!(CStyleString), + in_schema: in_param_ty!(WFToken), + in_name: in_param_ty!(WFCString), + in_value: in_param_ty!(WFCString), ) -> bool { cffi_wrapper!( - |in_schema: Token, in_name: CStyleString, in_value: CStyleString| { + |in_schema: WFToken, in_name: WFCString, in_value: WFCString| { let mut pool = pull_writer!(SCHEMA_POOL)?; let schema = pool.get_mut(in_schema)?; schema.add_behavior( @@ -433,17 +435,17 @@ pub extern "C" fn WFSchemaAddBehavior( #[unsafe(no_mangle)] pub extern "C" fn WFSchemaAddExt( - in_schema: in_param_ty!(Token), - in_ext: in_param_ty!(CStyleString), - in_ext_name: in_param_ty!(CStyleString), - in_ext_icon: in_param_ty!(CStyleString), - in_ext_behavior: in_param_ty!(CStyleString), + in_schema: in_param_ty!(WFToken), + in_ext: in_param_ty!(WFCString), + in_ext_name: in_param_ty!(WFCString), + in_ext_icon: in_param_ty!(WFCString), + in_ext_behavior: in_param_ty!(WFCString), ) -> bool { - cffi_wrapper!(|in_schema: Token, - in_ext: CStyleString, - in_ext_name: CStyleString, - in_ext_icon: CStyleString, - in_ext_behavior: CStyleString| { + cffi_wrapper!(|in_schema: WFToken, + in_ext: WFCString, + in_ext_name: WFCString, + in_ext_icon: WFCString, + in_ext_behavior: WFCString| { let mut pool = pull_writer!(SCHEMA_POOL)?; let schema = pool.get_mut(in_schema)?; schema.add_ext( @@ -462,10 +464,10 @@ pub extern "C" fn WFSchemaAddExt( #[unsafe(no_mangle)] pub extern "C" fn WFProgramCreate( - in_schema: in_param_ty!(Token), - out_program: out_param_ty!(Token), + in_schema: in_param_ty!(WFToken), + out_program: out_param_ty!(WFToken), ) -> bool { - cffi_wrapper!(|in_schema: Token| -> (out_program: Token) { + cffi_wrapper!(|in_schema: WFToken| -> (out_program: WFToken) { let mut pool = pull_writer!(SCHEMA_POOL)?; let schema = pool.pop(in_schema)?; @@ -476,8 +478,8 @@ pub extern "C" fn WFProgramCreate( } #[unsafe(no_mangle)] -pub extern "C" fn WFProgramDestroy(in_program: in_param_ty!(Token)) -> bool { - cffi_wrapper!(|in_program: Token| { +pub extern "C" fn WFProgramDestroy(in_program: in_param_ty!(WFToken)) -> bool { + cffi_wrapper!(|in_program: WFToken| { let mut pool = pull_writer!(PROGRAM_POOL)?; Ok(pool.free(in_program)?) }) @@ -485,10 +487,10 @@ pub extern "C" fn WFProgramDestroy(in_program: in_param_ty!(Token)) -> bool { #[unsafe(no_mangle)] pub extern "C" fn WFProgramResolveName( - in_program: in_param_ty!(Token), - out_name: out_param_ty!(CStyleString), + in_program: in_param_ty!(WFToken), + out_name: out_param_ty!(WFCString), ) -> bool { - cffi_wrapper!(|in_program: Token| -> (out_name: CStyleString) { + cffi_wrapper!(|in_program: WFToken| -> (out_name: WFCString) { let mut pool = pull_writer!(PROGRAM_POOL)?; let program = pool.get_mut(in_program)?; @@ -500,10 +502,10 @@ pub extern "C" fn WFProgramResolveName( #[unsafe(no_mangle)] pub extern "C" fn WFProgramResolveIcon( - in_program: in_param_ty!(Token), - out_icon_rc: out_param_ty!(Token), + in_program: in_param_ty!(WFToken), + out_icon_rc: out_param_ty!(WFToken), ) -> bool { - cffi_wrapper!(|in_program: Token| -> (out_icon_rc: Token) { + cffi_wrapper!(|in_program: WFToken| -> (out_icon_rc: WFToken) { let mut pool = pull_writer!(PROGRAM_POOL)?; let program = pool.get_mut(in_program)?; @@ -515,10 +517,10 @@ pub extern "C" fn WFProgramResolveIcon( #[unsafe(no_mangle)] pub extern "C" fn WFProgramExtsLen( - in_program: in_param_ty!(Token), + in_program: in_param_ty!(WFToken), out_len: out_param_ty!(usize), ) -> bool { - cffi_wrapper!(|in_program: Token| -> (out_len: usize) { + cffi_wrapper!(|in_program: WFToken| -> (out_len: usize) { let mut pool = pull_writer!(PROGRAM_POOL)?; let program = pool.get_mut(in_program)?; Ok(program.exts_len()) @@ -527,18 +529,18 @@ pub extern "C" fn WFProgramExtsLen( #[unsafe(no_mangle)] pub extern "C" fn WFProgramFindExt( - in_program: in_param_ty!(Token), - in_body: in_param_ty!(CStyleString), + in_program: in_param_ty!(WFToken), + in_body: in_param_ty!(WFCString), out_index: out_param_ty!(usize), ) -> bool { - cffi_wrapper!(|in_program: Token, in_body: CStyleString| -> (out_index: usize) { + cffi_wrapper!(|in_program: WFToken, in_body: WFCString| -> (out_index: usize) { let mut pool = pull_writer!(PROGRAM_POOL)?; let program = pool.get_mut(in_program)?; let body = cstr_ffi::parse_ffi_string(in_body)?; let index = match program.find_ext(body) { Some(index) => index, - None => ffi_types::INVALID_INDEX, + None => WF_INVALID_INDEX, }; Ok(index) }) @@ -546,11 +548,11 @@ pub extern "C" fn WFProgramFindExt( #[unsafe(no_mangle)] pub extern "C" fn WFProgramResolveExt( - in_program: in_param_ty!(Token), + in_program: in_param_ty!(WFToken), in_index: in_param_ty!(usize), - out_self_ext_status: out_param_ty!(Token), + out_self_ext_status: out_param_ty!(WFToken), ) -> bool { - cffi_wrapper!(|in_program: Token, in_index: usize| -> (out_self_ext_status: Token) { + cffi_wrapper!(|in_program: WFToken, in_index: usize| -> (out_self_ext_status: WFToken) { let mut pool = pull_writer!(PROGRAM_POOL)?; let program = pool.get_mut(in_program)?; @@ -563,13 +565,13 @@ pub extern "C" fn WFProgramResolveExt( #[unsafe(no_mangle)] pub extern "C" fn WFProgramRegister( - in_program: in_param_ty!(Token), + in_program: in_param_ty!(WFToken), in_scope: in_param_ty!(u32), ) -> bool { - cffi_wrapper!(|in_program: Token, in_scope: u32| { + cffi_wrapper!(|in_program: WFToken, in_scope: u32| { let mut pool = pull_writer!(PROGRAM_POOL)?; let program = pool.get_mut(in_program)?; - let scope = resolve_enum!(Scope, in_scope)?; + let scope = resolve_enum!(WFScope, in_scope)?; program.register(scope.into())?; Ok(()) }) @@ -577,13 +579,13 @@ pub extern "C" fn WFProgramRegister( #[unsafe(no_mangle)] pub extern "C" fn WFProgramUnregister( - in_program: in_param_ty!(Token), + in_program: in_param_ty!(WFToken), in_scope: in_param_ty!(u32), ) -> bool { - cffi_wrapper!(|in_program: Token, in_scope: u32| { + cffi_wrapper!(|in_program: WFToken, in_scope: u32| { let mut pool = pull_writer!(PROGRAM_POOL)?; let program = pool.get_mut(in_program)?; - let scope = resolve_enum!(Scope, in_scope)?; + let scope = resolve_enum!(WFScope, in_scope)?; program.unregister(scope.into())?; Ok(()) }) @@ -591,28 +593,28 @@ pub extern "C" fn WFProgramUnregister( #[unsafe(no_mangle)] pub extern "C" fn WFProgramIsRegistered( - in_program: in_param_ty!(Token), + in_program: in_param_ty!(WFToken), in_scope: in_param_ty!(u32), out_is_registered: out_param_ty!(bool), ) -> bool { - cffi_wrapper!(|in_program: Token, in_scope: u32| -> (out_is_registered: bool) { + cffi_wrapper!(|in_program: WFToken, in_scope: u32| -> (out_is_registered: bool) { let pool = pull_reader!(PROGRAM_POOL)?; let program = pool.get(in_program)?; - let scope = resolve_enum!(Scope, in_scope)?; + let scope = resolve_enum!(WFScope, in_scope)?; Ok(program.is_registered(scope.into())?) }) } #[unsafe(no_mangle)] pub extern "C" fn WFProgramLinkExt( - in_program: in_param_ty!(Token), + in_program: in_param_ty!(WFToken), in_scope: in_param_ty!(u32), in_index: in_param_ty!(usize), ) -> bool { - cffi_wrapper!(|in_program: Token, in_scope: u32, in_index: usize| { + cffi_wrapper!(|in_program: WFToken, in_scope: u32, in_index: usize| { let mut pool = pull_writer!(PROGRAM_POOL)?; let program = pool.get_mut(in_program)?; - let scope = resolve_enum!(Scope, in_scope)?; + let scope = resolve_enum!(WFScope, in_scope)?; program.link_ext(scope.into(), in_index)?; Ok(()) }) @@ -620,14 +622,14 @@ pub extern "C" fn WFProgramLinkExt( #[unsafe(no_mangle)] pub extern "C" fn WFProgramUnlinkExt( - in_program: in_param_ty!(Token), + in_program: in_param_ty!(WFToken), in_scope: in_param_ty!(u32), in_index: in_param_ty!(usize), ) -> bool { - cffi_wrapper!(|in_program: Token, in_scope: u32, in_index: usize| { + cffi_wrapper!(|in_program: WFToken, in_scope: u32, in_index: usize| { let mut pool = pull_writer!(PROGRAM_POOL)?; let program = pool.get_mut(in_program)?; - let scope = resolve_enum!(Scope, in_scope)?; + let scope = resolve_enum!(WFScope, in_scope)?; program.unlink_ext(scope.into(), in_index)?; Ok(()) }) @@ -635,15 +637,15 @@ pub extern "C" fn WFProgramUnlinkExt( #[unsafe(no_mangle)] pub extern "C" fn WFProgramQueryExt( - in_program: in_param_ty!(Token), + in_program: in_param_ty!(WFToken), in_view: in_param_ty!(u32), in_index: in_param_ty!(usize), - out_ext_status: out_param_ty!(Token), + out_ext_status: out_param_ty!(WFToken), ) -> bool { - cffi_wrapper!(|in_program: Token, in_view: u32, in_index: usize| -> (out_ext_status: Token) { + cffi_wrapper!(|in_program: WFToken, in_view: u32, in_index: usize| -> (out_ext_status: WFToken) { let pool = pull_reader!(PROGRAM_POOL)?; let program = pool.get(in_program)?; - let view = resolve_enum!(View, in_view)?; + let view = resolve_enum!(WFView, in_view)?; let ext_status = program.query_ext(view.into(), in_index)?; let token = match ext_status { @@ -662,8 +664,8 @@ pub extern "C" fn WFProgramQueryExt( // region: Extension Status #[unsafe(no_mangle)] -pub extern "C" fn WFExtStatusDestroy(in_ext_status: in_param_ty!(Token)) -> bool { - cffi_wrapper!(|in_ext_status: Token| { +pub extern "C" fn WFExtStatusDestroy(in_ext_status: in_param_ty!(WFToken)) -> bool { + cffi_wrapper!(|in_ext_status: WFToken| { let mut pool = pull_writer!(EXT_STATUS_POOL)?; Ok(pool.free(in_ext_status)?) }) @@ -671,10 +673,10 @@ pub extern "C" fn WFExtStatusDestroy(in_ext_status: in_param_ty!(Token)) -> bool #[unsafe(no_mangle)] pub extern "C" fn WFExtStatusGetName( - in_ext_status: in_param_ty!(Token), - out_name: out_param_ty!(CStyleString), + in_ext_status: in_param_ty!(WFToken), + out_name: out_param_ty!(WFCString), ) -> bool { - cffi_wrapper!(|in_ext_status: Token| -> (out_name: CStyleString) { + cffi_wrapper!(|in_ext_status: WFToken| -> (out_name: WFCString) { let pool = pull_reader!(EXT_STATUS_POOL)?; let ext_status = pool.get(in_ext_status)?; @@ -685,10 +687,10 @@ pub extern "C" fn WFExtStatusGetName( #[unsafe(no_mangle)] pub extern "C" fn WFExtStatusGetIcon( - in_ext_status: in_param_ty!(Token), - out_icon: out_param_ty!(HICON), + in_ext_status: in_param_ty!(WFToken), + out_icon: out_param_ty!(WFHICON), ) -> bool { - cffi_wrapper!(|in_ext_status: Token| -> (out_icon: HICON) { + cffi_wrapper!(|in_ext_status: WFToken| -> (out_icon: WFHICON) { let pool = pull_reader!(EXT_STATUS_POOL)?; let ext_status = pool.get(in_ext_status)?; @@ -702,8 +704,8 @@ pub extern "C" fn WFExtStatusGetIcon( // region: Self Extension Status #[unsafe(no_mangle)] -pub extern "C" fn WFSelfExtStatusDestroy(in_self_ext_status: in_param_ty!(Token)) -> bool { - cffi_wrapper!(|in_self_ext_status: Token| { +pub extern "C" fn WFSelfExtStatusDestroy(in_self_ext_status: in_param_ty!(WFToken)) -> bool { + cffi_wrapper!(|in_self_ext_status: WFToken| { let mut pool = pull_writer!(SELF_EXT_STATUS_POOL)?; Ok(pool.free(in_self_ext_status)?) }) @@ -711,10 +713,10 @@ pub extern "C" fn WFSelfExtStatusDestroy(in_self_ext_status: in_param_ty!(Token) #[unsafe(no_mangle)] pub extern "C" fn WFSelfExtStatusGetName( - in_self_ext_status: in_param_ty!(Token), - out_name: out_param_ty!(CStyleString), + in_self_ext_status: in_param_ty!(WFToken), + out_name: out_param_ty!(WFCString), ) -> bool { - cffi_wrapper!(|in_self_ext_status: Token| -> (out_name: CStyleString) { + cffi_wrapper!(|in_self_ext_status: WFToken| -> (out_name: WFCString) { let pool = pull_reader!(SELF_EXT_STATUS_POOL)?; let self_ext_status = pool.get(in_self_ext_status)?; @@ -725,10 +727,10 @@ pub extern "C" fn WFSelfExtStatusGetName( #[unsafe(no_mangle)] pub extern "C" fn WFSelfExtStatusGetIcon( - in_self_ext_status: in_param_ty!(Token), - out_icon: out_param_ty!(HICON), + in_self_ext_status: in_param_ty!(WFToken), + out_icon: out_param_ty!(WFHICON), ) -> bool { - cffi_wrapper!(|in_self_ext_status: Token| -> (out_icon: HICON) { + cffi_wrapper!(|in_self_ext_status: WFToken| -> (out_icon: WFHICON) { let pool = pull_reader!(SELF_EXT_STATUS_POOL)?; let self_ext_status = pool.get(in_self_ext_status)?; @@ -739,10 +741,10 @@ pub extern "C" fn WFSelfExtStatusGetIcon( #[unsafe(no_mangle)] pub extern "C" fn WFSelfExtStatusGetExt( - in_self_ext_status: in_param_ty!(Token), - out_inner: out_param_ty!(CStyleString), + in_self_ext_status: in_param_ty!(WFToken), + out_inner: out_param_ty!(WFCString), ) -> bool { - cffi_wrapper!(|in_self_ext_status: Token| -> (out_inner: CStyleString) { + cffi_wrapper!(|in_self_ext_status: WFToken| -> (out_inner: WFCString) { let pool = pull_reader!(SELF_EXT_STATUS_POOL)?; let self_ext_status = pool.get(in_self_ext_status)?; @@ -753,10 +755,10 @@ pub extern "C" fn WFSelfExtStatusGetExt( #[unsafe(no_mangle)] pub extern "C" fn WFSelfExtStatusGetDottedExt( - in_self_ext_status: in_param_ty!(Token), - out_inner: out_param_ty!(CStyleString), + in_self_ext_status: in_param_ty!(WFToken), + out_inner: out_param_ty!(WFCString), ) -> bool { - cffi_wrapper!(|in_self_ext_status: Token| -> (out_inner: CStyleString) { + cffi_wrapper!(|in_self_ext_status: WFToken| -> (out_inner: WFCString) { let pool = pull_reader!(SELF_EXT_STATUS_POOL)?; let self_ext_status = pool.get(in_self_ext_status)?; @@ -770,8 +772,8 @@ pub extern "C" fn WFSelfExtStatusGetDottedExt( // region: Icon Resource #[unsafe(no_mangle)] -pub extern "C" fn WFIconRcDestroy(in_icon_rc: in_param_ty!(Token)) -> bool { - cffi_wrapper!(|in_icon_rc: Token| { +pub extern "C" fn WFIconRcDestroy(in_icon_rc: in_param_ty!(WFToken)) -> bool { + cffi_wrapper!(|in_icon_rc: WFToken| { let mut pool = pull_writer!(ICON_RC_POOL)?; Ok(pool.free(in_icon_rc)?) }) @@ -779,10 +781,10 @@ pub extern "C" fn WFIconRcDestroy(in_icon_rc: in_param_ty!(Token)) -> bool { #[unsafe(no_mangle)] pub extern "C" fn WFIconRcGetIcon( - in_icon_rc: in_param_ty!(Token), - out_icon: out_param_ty!(HICON), + in_icon_rc: in_param_ty!(WFToken), + out_icon: out_param_ty!(WFHICON), ) -> bool { - cffi_wrapper!(|in_icon_rc: Token| -> (out_icon: HICON) { + cffi_wrapper!(|in_icon_rc: WFToken| -> (out_icon: WFHICON) { let pool = pull_reader!(ICON_RC_POOL)?; let icon_rc = pool.get(in_icon_rc)?;