Skip to content

Commit

Permalink
cbindgen
Browse files Browse the repository at this point in the history
  • Loading branch information
saschanaz committed Aug 24, 2024
1 parent 4fd47d9 commit 3c8955c
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 80 deletions.
77 changes: 39 additions & 38 deletions cpp/SampleIME/cbindgen/composition_processor.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>
#include <minwindef.h>

Expand Down Expand Up @@ -44,74 +45,74 @@ enum class KeystrokeFunction {

extern "C" {

HRESULT compartment_callback(const void *wrapper, const GUID *guid);

bool compositionprocessorengine_add_virtual_key(void *engine, uint16_t wch);

void compositionprocessorengine_compartmentwrapper_conversion_mode_compartment_updated(void *engine,
ITfThreadMgr* thread_mgr);

const void *compositionprocessorengine_compartmentwrapper_raw_ptr(void *engine);

void compositionprocessorengine_disable_language_bar_button(void *engine, bool disable);
void *compositionprocessorengine_new(ITfThreadMgr* thread_mgr, uint32_t tf_client_id);

void compositionprocessorengine_free(void *engine);

uintptr_t compositionprocessorengine_get_candidate_list(const void *engine,
void **keys_buffer,
void **values_buffer,
uintptr_t buffer_length,
bool is_incremental_word_search,
bool is_wildcard_search);
bool compositionprocessorengine_add_virtual_key(void *engine, uint16_t wch);

uintptr_t compositionprocessorengine_get_candidate_string_in_converted(const void *engine,
const void *search_key,
void **keys_buffer,
void **values_buffer,
uintptr_t buffer_length);
void compositionprocessorengine_pop_virtual_key(void *engine);

const void *compositionprocessorengine_get_table_dictionary_engine(const void *engine);
void compositionprocessorengine_purge_virtual_key(void *engine);

bool compositionprocessorengine_has_virtual_key(void *engine);

void compositionprocessorengine_hide_language_bar_button(void *engine, bool hide);

void *compositionprocessorengine_keystroke_buffer_get_reading_string(void *engine);

bool compositionprocessorengine_keystroke_buffer_includes_wildcard(void *engine);

bool compositionprocessorengine_modifiers_is_alt_key_down_only(void *engine);
const void *compositionprocessorengine_get_table_dictionary_engine(const void *engine);

bool compositionprocessorengine_modifiers_is_control_key_down_only(void *engine);
void compositionprocessorengine_modifiers_update(void *engine, WPARAM w, LPARAM l);

bool compositionprocessorengine_modifiers_is_shift_key_down_only(void *engine);

void compositionprocessorengine_modifiers_update(void *engine, WPARAM w, LPARAM l);
bool compositionprocessorengine_modifiers_is_control_key_down_only(void *engine);

void *compositionprocessorengine_new(ITfThreadMgr* thread_mgr, uint32_t tf_client_id);
bool compositionprocessorengine_modifiers_is_alt_key_down_only(void *engine);

bool compositionprocessorengine_punctuations_has_alternative_punctuation(void *engine,
uint16_t wch);

uint16_t compositionprocessorengine_punctuations_get_alternative_punctuation_counted(void *engine,
uint16_t wch);

HRESULT compositionprocessorengine_preserved_keys_init(void *engine,
ITfThreadMgr* thread_mgr,
uint32_t client_id);

HRESULT compositionprocessorengine_on_preserved_key(void *engine,
const GUID *guid,
bool *out_is_eaten,
ITfThreadMgr* thread_mgr,
uint32_t client_id);

void compositionprocessorengine_pop_virtual_key(void *engine);
void compositionprocessorengine_compartmentwrapper_conversion_mode_compartment_updated(void *engine,
ITfThreadMgr* thread_mgr);

HRESULT compositionprocessorengine_preserved_keys_init(void *engine,
const void *compositionprocessorengine_compartmentwrapper_raw_ptr(void *engine);

bool compositionprocessorengine_setup_language_profile(void *engine,
ITfThreadMgr* thread_mgr,
uint32_t client_id);

uint16_t compositionprocessorengine_punctuations_get_alternative_punctuation_counted(void *engine,
uint16_t wch);
void compositionprocessorengine_hide_language_bar_button(void *engine, bool hide);

bool compositionprocessorengine_punctuations_has_alternative_punctuation(void *engine,
uint16_t wch);
void compositionprocessorengine_disable_language_bar_button(void *engine, bool disable);

void compositionprocessorengine_purge_virtual_key(void *engine);
uintptr_t compositionprocessorengine_get_candidate_list(const void *engine,
void **keys_buffer,
void **values_buffer,
uintptr_t buffer_length,
bool is_incremental_word_search,
bool is_wildcard_search);

bool compositionprocessorengine_setup_language_profile(void *engine,
ITfThreadMgr* thread_mgr,
uint32_t client_id);
uintptr_t compositionprocessorengine_get_candidate_string_in_converted(const void *engine,
const void *search_key,
void **keys_buffer,
void **values_buffer,
uintptr_t buffer_length);

HRESULT compartment_callback(const void *wrapper, const GUID *guid);

} // extern "C"
19 changes: 10 additions & 9 deletions cpp/SampleIME/cbindgen/globals.h
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>
#include <guiddef.h>

extern "C" {

extern const GUID SAMPLEIME_CLSID;

extern const GUID SAMPLEIME_GUID_CAND_UIELEMENT;
extern const GUID SAMPLEIME_GUID_PROFILE;

extern const GUID SAMPLEIME_GUID_COMPARTMENT_DOUBLE_SINGLE_BYTE;
extern const GUID SAMPLEIME_GUID_IME_MODE_PRESERVE_KEY;

extern const GUID SAMPLEIME_GUID_COMPARTMENT_PUNCTUATION;
extern const GUID SAMPLEIME_GUID_DOUBLE_SINGLE_BYTE_PRESERVE_KEY;

extern const GUID SAMPLEIME_GUID_DISPLAY_ATTRIBUTE_CONVERTED;
extern const GUID SAMPLEIME_GUID_PUNCTUATION_PRESERVE_KEY;

extern const GUID SAMPLEIME_GUID_DISPLAY_ATTRIBUTE_INPUT;
extern const GUID SAMPLEIME_GUID_COMPARTMENT_DOUBLE_SINGLE_BYTE;

extern const GUID SAMPLEIME_GUID_DOUBLE_SINGLE_BYTE_PRESERVE_KEY;
extern const GUID SAMPLEIME_GUID_COMPARTMENT_PUNCTUATION;

extern const GUID SAMPLEIME_GUID_IME_MODE_PRESERVE_KEY;
extern const GUID SAMPLEIME_GUID_DISPLAY_ATTRIBUTE_INPUT;

extern const GUID SAMPLEIME_GUID_PROFILE;
extern const GUID SAMPLEIME_GUID_DISPLAY_ATTRIBUTE_CONVERTED;

extern const GUID SAMPLEIME_GUID_PUNCTUATION_PRESERVE_KEY;
extern const GUID SAMPLEIME_GUID_CAND_UIELEMENT;

} // extern "C"
9 changes: 5 additions & 4 deletions cpp/SampleIME/cbindgen/ime.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>

static const uint32_t IME_MODE_OFF_ICO_INDEX = 22;
constexpr static const uint32_t IME_MODE_ON_ICO_INDEX = 21;

static const uint32_t IME_MODE_ON_ICO_INDEX = 21;
constexpr static const uint32_t IME_MODE_OFF_ICO_INDEX = 22;

extern "C" {

extern HFONT DEFAULT_FONT_HANDLE;

extern HMODULE DLL_INSTANCE;

extern HFONT DEFAULT_FONT_HANDLE;

} // extern "C"
21 changes: 11 additions & 10 deletions cpp/SampleIME/cbindgen/input_processor.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>
#include <minwindef.h>

extern "C" {

bool key_event_sink_on_key_up(ITfThreadMgr* thread_mgr,
uint32_t tf_client_id,
void *engine,
bool composing,
CandidateMode candidate_mode,
WPARAM wparam,
LPARAM lparam);

bool key_event_sink_init_key_event_sink(ITfThreadMgr* thread_mgr,
uint32_t tf_client_id,
ITfKeyEventSink* sink);

void key_event_sink_uninit_key_event_sink(ITfThreadMgr* thread_mgr, uint32_t tf_client_id);

bool key_event_sink_is_key_eaten(ITfThreadMgr* thread_mgr,
uint32_t tf_client_id,
const void *engine,
Expand All @@ -20,14 +31,4 @@ bool key_event_sink_is_key_eaten(ITfThreadMgr* thread_mgr,
KeystrokeCategory *category,
KeystrokeFunction *function);

bool key_event_sink_on_key_up(ITfThreadMgr* thread_mgr,
uint32_t tf_client_id,
void *engine,
bool composing,
CandidateMode candidate_mode,
WPARAM wparam,
LPARAM lparam);

void key_event_sink_uninit_key_event_sink(ITfThreadMgr* thread_mgr, uint32_t tf_client_id);

} // extern "C"
27 changes: 14 additions & 13 deletions cpp/SampleIME/cbindgen/itf_components.h
Original file line number Diff line number Diff line change
@@ -1,48 +1,49 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>

using CESCALLBACK = HRESULT(*)(const void *pv, const GUID *guid);

extern "C" {

HRESULT compartment_clear(void *compartment);
void *compartment_new(ITfThreadMgr* thread_mgr, uint32_t tf_client_id, const GUID *guid);

void compartment_free(void *compartment);

HRESULT compartment_get_bool(void *compartment, bool *data);

HRESULT compartment_set_bool(void *compartment, bool flag);

HRESULT compartment_get_u32(void *compartment, uint32_t *data);

void compartment_guid(void *compartment, GUID *guid);
HRESULT compartment_set_u32(void *compartment, uint32_t data);

void *compartment_new(ITfThreadMgr* thread_mgr, uint32_t tf_client_id, const GUID *guid);
HRESULT compartment_clear(void *compartment);

HRESULT compartment_set_bool(void *compartment, bool flag);
void compartment_guid(void *compartment, GUID *guid);

HRESULT compartment_set_u32(void *compartment, uint32_t data);
void *compartmenteventsink_new(CESCALLBACK callback, const void *pv);

HRESULT compartmenteventsink_advise(ITfCompartmentEventSink* sink,
IUnknown* punk,
const GUID *guid);

void *compartmenteventsink_new(CESCALLBACK callback, const void *pv);

HRESULT compartmenteventsink_unadvise(ITfCompartmentEventSink* sink);

void langbaritembutton_cleanup(ITfLangBarItemButton* button);
void *langbaritembutton_new(const GUID *item_guid,
void *description,
void *tooltip,
uint32_t on_icon_index,
uint32_t off_icon_index);

HRESULT langbaritembutton_init(ITfLangBarItemButton* button,
ITfThreadMgr* thread_mgr,
uint32_t tf_client_id,
const GUID *compartment_guid);

void *langbaritembutton_new(const GUID *item_guid,
void *description,
void *tooltip,
uint32_t on_icon_index,
uint32_t off_icon_index);
void langbaritembutton_cleanup(ITfLangBarItemButton* button);

HRESULT langbaritembutton_set_status(ITfLangBarItemButton* button, uint32_t status, bool set);

Expand Down
1 change: 1 addition & 0 deletions cpp/SampleIME/cbindgen/numberkey_windows.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>

extern "C" {
Expand Down
13 changes: 7 additions & 6 deletions cpp/SampleIME/cbindgen/ruststringrange.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>

extern "C" {

void *ruststringrange_clone(const void *p);
void *ruststringrange_new(const uint16_t *buffer, uintptr_t buffer_len);

int8_t ruststringrange_compare(void *x_raw, void *y_raw);
void *ruststringrange_new_utf8(const uint8_t *buffer, uintptr_t buffer_len);

void ruststringrange_free(void *p);

uintptr_t ruststringrange_len(const void *p);
const uint8_t *ruststringrange_raw(void *p);

void *ruststringrange_new(const uint16_t *buffer, uintptr_t buffer_len);
uintptr_t ruststringrange_len(const void *p);

void *ruststringrange_new_utf8(const uint8_t *buffer, uintptr_t buffer_len);
int8_t ruststringrange_compare(void *x_raw, void *y_raw);

const uint8_t *ruststringrange_raw(void *p);
void *ruststringrange_clone(const void *p);

} // extern "C"

0 comments on commit 3c8955c

Please sign in to comment.