Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Config and it's C FFI functions #14

Merged
merged 7 commits into from
Apr 19, 2021
Merged

Introduce Config and it's C FFI functions #14

merged 7 commits into from
Apr 19, 2021

Conversation

mominul
Copy link
Member

@mominul mominul commented Apr 16, 2021

This PR introduces Config to configure RitiContext and replaces the current weird way of configuring through environment variables.

Now to initialize a RitiContext, one has to pass a properly populated Config struct to the constructor function which is analogous to setting the environment variables before initializing a RitiContext.

This PR also introduces the following C APIs:

/*
 Config struct for configuring RitiContext.
 */
struct Config;

/*
 Creates a new instance of Config which is used to initialize
 and to control the configuration of RitiContext.
 This function creates an instance of Config in an initial
 state which can't be used before populating the Config using
 `riti_config_set_*` set of functions.
 */
Config *riti_config_new();

/*
 Free the allocated Config struct.
 */
void riti_config_free(Config *ptr);

void riti_config_set_layout_file(Config *ptr, const char *path);

void riti_config_set_database_dir(Config *ptr, const char *path);

void riti_config_set_phonetic_suggestion(Config *ptr, bool option);

void riti_config_set_phonetic_include_english(Config *ptr, bool option);

void riti_config_set_fixed_suggestion(Config *ptr, bool option);

void riti_config_set_fixed_auto_vowel(Config *ptr, bool option);

void riti_config_set_fixed_auto_chandra(Config *ptr, bool option);

void riti_config_set_fixed_traditional_kar(Config *ptr, bool option);

void riti_config_set_fixed_old_reph(Config *ptr, bool option);

void riti_config_set_fixed_numpad(Config *ptr, bool option);

Closes #12

@mominul
Copy link
Member Author

mominul commented Apr 16, 2021

cc @wengxt can you do a review, please?

@wengxt
Copy link

wengxt commented Apr 18, 2021

I don't use rust so I can't really comment about that, but the C API LGTM.

@mominul mominul merged commit 173517f into master Apr 19, 2021
@mominul
Copy link
Member Author

mominul commented Apr 19, 2021

Thanks!

@mominul mominul deleted the config branch April 19, 2021 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggest to have a riti_context_set_option API
2 participants