diff --git a/core/include/keyman/keyman_core_api.h b/core/include/keyman/keyman_core_api.h index 11affd9296b..3c41182bab2 100644 --- a/core/include/keyman/keyman_core_api.h +++ b/core/include/keyman/keyman_core_api.h @@ -1007,7 +1007,11 @@ Provides read-only information about a keyboard. typedef struct { km_core_cu const * version_string; km_core_cu const * id; + + // TODO-web-core: Deprecate this field (#12497) + // KMN_DEPRECATED km_core_path_name folder_path; + km_core_option_item const * default_options; } km_core_keyboard_attrs; @@ -1022,7 +1026,7 @@ typedef struct { : Keyman keyboard ID string. `folder_path` -: Path to the unpacked folder containing the keyboard and associated resources. +: Path to the unpacked folder containing the keyboard and associated resources (deprecated). `default_options` : Set of default values for any options included in the keyboard. @@ -1096,12 +1100,16 @@ typedef struct { ## Description +DEPRECATED: use [km_core_keyboard_load_from_blob] instead. + Parse and load keyboard from the supplied path and a pointer to the loaded keyboard -into the out paramter. +into the out parameter. ## Specification ```c */ +// TODO-web-core: Deprecate this function (#12497) +// KMN_DEPRECATED_API KMN_API km_core_status km_core_keyboard_load(km_core_path_name kb_path, @@ -1151,7 +1159,9 @@ into the out paramter. ```c */ KMN_API -km_core_status km_core_keyboard_load_from_blob(void* blob, size_t blob_size, +km_core_status km_core_keyboard_load_from_blob(const km_core_path_name kb_name, + const void* blob, + const size_t blob_size, km_core_keyboard** keyboard); /* @@ -1159,11 +1169,14 @@ km_core_status km_core_keyboard_load_from_blob(void* blob, size_t blob_size, ## Parameters +`kb_name` +: a string with the name of the keyboard. + `blob` -: a byte array containing the content of a KMX/KMX+ file +: a byte array containing the content of a KMX/KMX+ file. `blob_size` -: A pointer to a size_t variable with the size of the blob in bytes. +: a size_t variable with the size of the blob in bytes. `keyboard` : A pointer to result variable: A pointer to the opaque keyboard @@ -1179,10 +1192,13 @@ km_core_status km_core_keyboard_load_from_blob(void* blob, size_t blob_size, : In the event an internal memory allocation fails. `KM_CORE_STATUS_IO_ERROR` -: In the event the keyboard blob is unparseable for any reason +: In the event the keyboard file is unparseable for any reason `KM_CORE_STATUS_INVALID_ARGUMENT` -: In the event one of the required parameters is null. +: In the event `keyboard` is null. + +`KM_CORE_STATUS_OS_ERROR` +: Bit 31 (high bit) set, bits 0-30 are an OS-specific error code. ------------------------------------------------------------------------------- diff --git a/core/include/keyman/keyman_core_api_bits.h b/core/include/keyman/keyman_core_api_bits.h index e00f4698a8c..bd1f519bffe 100644 --- a/core/include/keyman/keyman_core_api_bits.h +++ b/core/include/keyman/keyman_core_api_bits.h @@ -23,7 +23,6 @@ #define _kmn_unused(x) UNUSED_ ## x __attribute__((__unused__)) #else #define _kmn_unused(x) UNUSED_ ## x - #endif #if defined _WIN32 || defined __CYGWIN__ @@ -36,7 +35,7 @@ #undef _kmn_static_flag #else // How MSVC sepcifies function level attributes adn deprecation #define _kmn_and - #define _kmn_tag_fn(a) __declspec(a) + #define _kmn_tag_fn(a) __declspec(a) #define _kmn_deprecated_flag deprecated #endif #define _kmn_export_flag dllexport @@ -48,6 +47,8 @@ #define _KM_CORE_EXT_SEPARATOR ('.') #endif +#define KMN_DEPRECATED _kmn_tag_fn(_kmn_deprecated_flag) + #if defined KM_CORE_LIBRARY_STATIC #define KMN_API _kmn_tag_fn(_kmn_static_flag) #define KMN_DEPRECATED_API _kmn_tag_fn(_kmn_deprecated_flag _kmn_and _kmn_static_flag) diff --git a/core/src/keyboard.cpp b/core/src/keyboard.cpp index 2c3a0c11b2c..0f104f9422a 100644 --- a/core/src/keyboard.cpp +++ b/core/src/keyboard.cpp @@ -17,18 +17,16 @@ void keyboard_attributes::render() // Make attributes point to the stored values above. id = _keyboard_id.c_str(); version_string = _version_string.c_str(); - folder_path = _folder_path.c_str(); default_options = _default_opts.data(); } keyboard_attributes::keyboard_attributes(std::u16string const & kbid, std::u16string const & version, - path_type const & path, options_store const &opts) : _keyboard_id(kbid), _version_string(version), - _folder_path(path), + _folder_path(""), _default_opts(opts) { // Ensure that the default_options array will be properly terminated. @@ -40,7 +38,7 @@ keyboard_attributes::keyboard_attributes(std::u16string const & kbid, keyboard_attributes::keyboard_attributes(keyboard_attributes &&rhs) : _keyboard_id(std::move(rhs._keyboard_id)), _version_string(std::move(rhs._version_string)), - _folder_path(std::move(rhs._folder_path)), + _folder_path(""), _default_opts(std::move(rhs._default_opts)) { rhs.id = rhs.version_string = nullptr; @@ -58,7 +56,6 @@ json & km::core::operator << (json & j, km::core::keyboard_attributes const & kb { j << json::object << "id" << kb.id - << "folder" << kb._folder_path << "version" << kb.version_string << "rules" << json::array << json::close; diff --git a/core/src/keyboard.hpp b/core/src/keyboard.hpp index 142bf40e860..2ca7118d870 100644 --- a/core/src/keyboard.hpp +++ b/core/src/keyboard.hpp @@ -26,6 +26,7 @@ namespace core { std::u16string _keyboard_id; std::u16string _version_string; + // unused and deprecated core::path _folder_path; std::vector