mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-09 10:25:32 +00:00
Relates to #9999. Fixes #10384. The context API endpoints should no longer be considered as part of the standard Core API. The only consumers that have a need to access these APIs are the IMX integration in Engine for Windows, and the Keyman Developer Debugger. These symbols are currently used by Developer: * `km_core_context` struct * `km_core_context_type` enum * `km_core_context_item` struct * `KM_CORE_CONTEXT_ITEM_END` macro * `km_core_state_context()` * `km_core_context_set()` * `km_core_context_clear()` These symbols are currently used by Windows IMX: * `km_core_context` struct * `km_core_context_type` enum * `km_core_context_item` struct * `KM_CORE_CONTEXT_ITEM_END` macro * `km_core_context_items_dispose()` * `km_core_context_item_list_size()` * `km_core_state_get_intermediate_context()` The following functions and symbols are moving to keyman_core_api_context.h: * `km_core_context` struct * `km_core_context_type` enum * `km_core_context_item` struct * `KM_CORE_CONTEXT_ITEM_END` macro * `km_core_state_context()` function * `km_core_state_get_intermediate_context()` function * `km_core_context_set()` function * `km_core_context_clear()` function * `km_core_context_get()` function * `km_core_context_items_from_utf16()` function * `km_core_context_items_from_utf8()` function * `km_core_context_items_to_utf8()` function * `km_core_context_items_to_utf16()` function * `km_core_context_items_to_utf32()` function * `km_core_context_items_dispose()` function * `km_core_context_length()` function * `km_core_context_append()` function * `km_core_context_shrink()` function * `km_core_context_item_list_size()` function
70 lines
1.7 KiB
C++
70 lines
1.7 KiB
C++
/*
|
|
* Keyman is copyright (C) SIL International. MIT License.
|
|
*
|
|
* Keyman Core - Debug class definition
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <cassert>
|
|
#include <vector>
|
|
|
|
#include "keyman_core.h"
|
|
|
|
namespace km {
|
|
namespace core
|
|
{
|
|
|
|
class debug_items : public std::vector<km_core_state_debug_item>
|
|
{
|
|
private:
|
|
bool _is_enabled;
|
|
public:
|
|
template<typename... Args> debug_items(Args&&... args);
|
|
void push_begin(km_core_state_debug_key_info *key_info, uint32_t flags);
|
|
void push_end(uint16_t first_action, uint32_t flags);
|
|
void assert_push_entry();
|
|
bool is_enabled() const noexcept;
|
|
void set_enabled(bool value) noexcept;
|
|
};
|
|
|
|
template<typename... Args>
|
|
debug_items::debug_items(Args&&... args)
|
|
: std::vector<km_core_state_debug_item>(std::forward<Args>(args)...)
|
|
{
|
|
// Ensure the debug_items list is terminated in case the client calls
|
|
// km_core_state_debug_items before they call process_event.
|
|
_is_enabled = false;
|
|
push_end(0, 0);
|
|
}
|
|
|
|
inline
|
|
void debug_items::assert_push_entry() {
|
|
assert(empty() || (!empty() && back().type != KM_CORE_DEBUG_END));
|
|
}
|
|
|
|
inline
|
|
void debug_items::push_begin(km_core_state_debug_key_info *key_info, uint32_t flags) {
|
|
assert_push_entry();
|
|
emplace_back(km_core_state_debug_item{ KM_CORE_DEBUG_BEGIN, flags, {*key_info, }, { }});
|
|
}
|
|
|
|
inline
|
|
void debug_items::push_end(uint16_t first_action, uint32_t flags) {
|
|
assert_push_entry();
|
|
emplace_back(km_core_state_debug_item{ KM_CORE_DEBUG_END, flags, { }, { u"", nullptr, nullptr, { }, first_action, {} } });
|
|
}
|
|
|
|
inline
|
|
bool debug_items::is_enabled() const noexcept {
|
|
return _is_enabled;
|
|
}
|
|
|
|
inline
|
|
void debug_items::set_enabled(bool value) noexcept {
|
|
_is_enabled = value;
|
|
}
|
|
|
|
} // namespace core
|
|
} // namespace km
|
|
|