spiegel-keyman/developer/kmcompx/include/XX/debug.hpp
Sabine 3e58fa76b6 get keymans version
Merge branch 'master' of https://github.com/keymanapp/keyman into refactor/developer/6026-kmcompx-compiler-cross-platform-part-2-NEW_VERSION

# Conflicts:
#	common/core/desktop/src/kmx/kmx_context.h
#	common/core/desktop/src/kmx/kmx_processor.cpp
#	common/windows/cpp/include/keymanversion.h
#	common/windows/cpp/include/kkmnkbd/Compfile.h
#	common/windows/cpp/include/kmtip_guids.h
#	common/windows/cpp/src/kmtip_guids.cpp
#	core/src/kmx/kmx_conversion.cpp
#	core/src/kmx/kmx_conversion.h
#	core/src/kmx/kmx_file.cpp
#	core/src/kmx/kmx_processevent.cpp
#	core/src/kmx/kmx_processor.hpp
#	core/src/kmx/kmx_xstring.cpp
#	developer/js/.gitignore
#	developer/js/package-lock.json
#	developer/js/tests/tsconfig.json
#	developer/src/kmcmpdll/CasedKeys.cpp
#	developer/src/kmcmpdll/CheckFilenameConsistency.cpp
#	developer/src/kmcmpdll/CheckFilenameConsistency.h
#	developer/src/kmcmpdll/CheckForDuplicates.cpp
#	developer/src/kmcmpdll/CheckForDuplicates.h
#	developer/src/kmcmpdll/CheckNCapsConsistency.cpp
#	developer/src/kmcmpdll/CheckNCapsConsistency.h
#	developer/src/kmcmpdll/Compiler.cpp
#	developer/src/kmcmpdll/DeprecationChecks.cpp
#	developer/src/kmcmpdll/NamedCodeConstants.cpp
#	developer/src/kmcmpdll/UnreachableRules.cpp
#	developer/src/kmcmpdll/UnreachableRules.h
#	developer/src/kmcmpdll/compfile.h
#	developer/src/kmcmpdll/kcframe/kcframe.cpp
#	developer/src/kmcmpdll/kcframe/kcframe.vcxproj
#	developer/src/kmcmpdll/kcframe/kcframe.vcxproj.filters
#	developer/src/kmcmpdll/kmcmpdll.vcxproj
#	developer/src/kmcmpdll/kmcmpdll.vcxproj.filters
#	developer/src/kmcmpdll/version.rc
#	developer/src/kmcmpdll/versioning.cpp
#	developer/src/kmlmc/bundle.sh
#	developer/src/kmlmc/tests/test-join-word-breaker.ts
#	developer/src/kmlmc/tests/test-override-script-defaults.ts
#	developer/src/server/tsconfig.json
#	windows/src/developer/kmcmpdll/Makefile
#	windows/src/developer/kmcmpdll/vkeys.h
#	windows/src/engine/keyman32/keymanengine.h
#	windows/src/global/inc/Vkeys.h
#	windows/src/global/inc/rc4.h
#	windows/src/global/vc/rc4.cpp
2022-07-12 10:43:20 +02:00

71 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/keyboardprocessor.h"
#include "../keyman/keyboardprocessor_debug.h"
namespace km {
namespace kbp
{
class debug_items : public std::vector<km_kbp_state_debug_item>
{
private:
bool _is_enabled;
public:
template<typename... Args> debug_items(Args&&... args);
void push_begin(km_kbp_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_kbp_state_debug_item>(std::forward<Args>(args)...)
{
// Ensure the debug_items list is terminated in case the client calls
// km_kbp_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_KBP_DEBUG_END));
}
inline
void debug_items::push_begin(km_kbp_state_debug_key_info *key_info, uint32_t flags) {
assert_push_entry();
emplace_back(km_kbp_state_debug_item{ KM_KBP_DEBUG_BEGIN, flags, {*key_info, } });
}
inline
void debug_items::push_end(uint16_t first_action, uint32_t flags) {
assert_push_entry();
emplace_back(km_kbp_state_debug_item{ KM_KBP_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 kbp
} // namespace km