Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions core/src/wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,23 @@ km_core_state_get_actions_wasm(km_core_state const *state) {
return actions_wasm;
}

int
km_core_state_options_update_wasm(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this get added to /core/docs/api/state.md?

(I dunno if that's the right doc)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, since it's close enough to km_core_state_options_update. From Javascript/Typescript the function looks identical to what is documented.

Having said that, we will have to add documentation for the API exposed through WASM, but that's a separate task (#13434, #13435).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not currently adding extra docs for _wasm versions of existing functions... but we could

km_core_state const *state,
const std::vector<km_core_option_item_wasm>& new_options
) {
km_core_option_item* options_c = new km_core_option_item[new_options.size() + 1];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be freed at the end of the function

for (size_t i = 0; i < new_options.size(); ++i) {
options_c[i].key = new_options[i].key.c_str();
options_c[i].value = new_options[i].value.c_str();
options_c[i].scope = new_options[i].scope;
}
options_c[new_options.size()] = KM_CORE_OPTIONS_END;
km_core_status status = km_core_state_options_update(const_cast<km_core_state*>(state), options_c);
delete[] options_c;
return status;
}

const CoreReturn<km_core_context_items>*
km_core_context_get_wasm(
km_core_context const* context
Expand Down Expand Up @@ -484,6 +501,8 @@ EMSCRIPTEN_BINDINGS(core_interface) {

em::function("state_get_actions(state)", &km_core_state_get_actions_wasm, em::allow_raw_pointers());

em::function("state_options_update(state, new_options)", &km_core_state_options_update_wasm, em::allow_raw_pointers());

em::function("context_get(context)", &km_core_context_get_wasm, em::allow_raw_pointers());
em::function("context_set(context, context_items)", &km_core_context_set_wasm, em::allow_raw_pointers());
}
Expand Down
4 changes: 2 additions & 2 deletions web/src/engine/src/core-adapter/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { KM_Core, KM_CORE_STATUS, KM_CORE_OPTION_SCOPE, KM_CORE_KMX_ENV, KM_CORE_CT } from './KM_Core.js';
import { type km_core_keyboard, type km_core_state, type km_core_context, type km_core_context_item, type km_core_context_items } from './import/core/keymancore.js';
export { km_core_keyboard, km_core_state, km_core_context, km_core_context_item, km_core_context_items };
import { type km_core_keyboard, type km_core_state, type km_core_context, type km_core_context_item, type km_core_context_items, type km_core_option_item } from './import/core/keymancore.js';
export { km_core_keyboard, km_core_state, km_core_context, km_core_context_item, km_core_context_items, km_core_option_item };