From 0dd40125c555ccfc6b018eda8107fa1aa101c43e Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sat, 22 Sep 2012 10:58:00 +0300 Subject: API: add _context prefix to log-related functions This is to follow the general scheme set by all of the other API functions. Since no one is using these functions yet, we don't (actually better not) add the old names to xkbcommon-compat.h. Signed-off-by: Ran Benita --- src/context.c | 24 ++++++++++++------------ src/context.h | 4 ++-- src/xkbcomp/compat.c | 4 ++-- src/xkbcomp/keycodes.c | 6 +++--- src/xkbcomp/symbols.c | 4 ++-- src/xkbcomp/types.c | 2 +- test/log.c | 12 ++++++------ test/rules-file.c | 12 ++++++------ test/rulescomp.c | 12 ++++++------ xkbcommon/xkbcommon.h | 21 +++++++++++---------- 10 files changed, 51 insertions(+), 50 deletions(-) diff --git a/src/context.c b/src/context.c index 6710fe2..b3e2f23 100644 --- a/src/context.c +++ b/src/context.c @@ -296,11 +296,11 @@ xkb_context_new(enum xkb_context_flags flags) /* Environment overwrites defaults. */ env = getenv("XKB_LOG"); if (env) - xkb_set_log_level(ctx, log_level(env)); + xkb_context_set_log_level(ctx, log_level(env)); env = getenv("XKB_VERBOSITY"); if (env) - xkb_set_log_verbosity(ctx, log_verbosity(env)); + xkb_context_set_log_verbosity(ctx, log_verbosity(env)); if (!(flags & XKB_CONTEXT_NO_DEFAULT_INCLUDES) && !xkb_context_include_path_append_default(ctx)) { @@ -361,40 +361,40 @@ xkb_log(struct xkb_context *ctx, enum xkb_log_level level, } XKB_EXPORT void -xkb_set_log_fn(struct xkb_context *ctx, - void (*log_fn)(struct xkb_context *ctx, - enum xkb_log_level level, - const char *fmt, va_list args)) +xkb_context_set_log_fn(struct xkb_context *ctx, + void (*log_fn)(struct xkb_context *ctx, + enum xkb_log_level level, + const char *fmt, va_list args)) { ctx->log_fn = (log_fn ? log_fn : default_log_fn); } XKB_EXPORT enum xkb_log_level -xkb_get_log_level(struct xkb_context *ctx) +xkb_context_get_log_level(struct xkb_context *ctx) { return ctx->log_level; } XKB_EXPORT void -xkb_set_log_level(struct xkb_context *ctx, enum xkb_log_level level) +xkb_context_set_log_level(struct xkb_context *ctx, enum xkb_log_level level) { ctx->log_level = level; } XKB_EXPORT int -xkb_get_log_verbosity(struct xkb_context *ctx) +xkb_context_get_log_verbosity(struct xkb_context *ctx) { return ctx->log_verbosity; } XKB_EXPORT void -xkb_set_log_verbosity(struct xkb_context *ctx, int verbosity) +xkb_context_set_log_verbosity(struct xkb_context *ctx, int verbosity) { ctx->log_verbosity = verbosity; } XKB_EXPORT void * -xkb_get_user_data(struct xkb_context *ctx) +xkb_context_get_user_data(struct xkb_context *ctx) { if (ctx) return ctx->user_data; @@ -402,7 +402,7 @@ xkb_get_user_data(struct xkb_context *ctx) } XKB_EXPORT void -xkb_set_user_data(struct xkb_context *ctx, void *user_data) +xkb_context_set_user_data(struct xkb_context *ctx, void *user_data) { ctx->user_data = user_data; } diff --git a/src/context.h b/src/context.h index 1a87815..fb3150a 100644 --- a/src/context.h +++ b/src/context.h @@ -68,12 +68,12 @@ xkb_log(struct xkb_context *ctx, enum xkb_log_level level, const char *fmt, ...); #define xkb_log_cond_level(ctx, level, ...) do { \ - if (xkb_get_log_level(ctx) >= (level)) \ + if (xkb_context_get_log_level(ctx) >= (level)) \ xkb_log((ctx), (level), __VA_ARGS__); \ } while (0) #define xkb_log_cond_verbosity(ctx, level, vrb, ...) do { \ - if (xkb_get_log_verbosity(ctx) >= (vrb)) \ + if (xkb_context_get_log_verbosity(ctx) >= (vrb)) \ xkb_log_cond_level((ctx), (level), __VA_ARGS__); \ } while (0) diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c index 963c938..06cb0a6 100644 --- a/src/xkbcomp/compat.c +++ b/src/xkbcomp/compat.c @@ -311,7 +311,7 @@ AddInterp(CompatInfo *info, SymInterpInfo *new) old = FindMatchingInterp(info, new); if (old) { - int verbosity = xkb_get_log_verbosity(info->keymap->ctx); + int verbosity = xkb_context_get_log_verbosity(info->keymap->ctx); bool report = ((old->file_id == new->file_id && verbosity > 0) || verbosity > 9); @@ -425,7 +425,7 @@ AddIndicatorMap(CompatInfo *info, LEDInfo *new) LEDInfo *old; enum led_field collide; struct xkb_context *ctx = info->keymap->ctx; - int verbosity = xkb_get_log_verbosity(ctx); + int verbosity = xkb_context_get_log_verbosity(ctx); darray_foreach(old, info->leds) { bool report; diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c index cfd8bd9..2c5af55 100644 --- a/src/xkbcomp/keycodes.c +++ b/src/xkbcomp/keycodes.c @@ -177,7 +177,7 @@ AddIndicatorName(KeyNamesInfo *info, enum merge_mode merge, xkb_led_index_t old_idx; IndicatorNameInfo *old; bool replace, report; - int verbosity = xkb_get_log_verbosity(info->ctx); + int verbosity = xkb_context_get_log_verbosity(info->ctx); replace = (merge == MERGE_REPLACE) || (merge == MERGE_OVERRIDE); @@ -279,7 +279,7 @@ AddKeyName(KeyNamesInfo *info, xkb_keycode_t kc, unsigned long name, { KeyNameInfo *namei; xkb_keycode_t old; - int verbosity = xkb_get_log_verbosity(info->ctx); + int verbosity = xkb_context_get_log_verbosity(info->ctx); if (kc >= darray_size(info->key_names)) darray_resize0(info->key_names, kc + 1); @@ -483,7 +483,7 @@ HandleKeycodeDef(KeyNamesInfo *info, KeycodeDef *stmt, enum merge_mode merge) static void HandleAliasCollision(KeyNamesInfo *info, AliasInfo *old, AliasInfo *new) { - int verbosity = xkb_get_log_verbosity(info->ctx); + int verbosity = xkb_context_get_log_verbosity(info->ctx); bool report = ((new->file_id == old->file_id && verbosity > 0) || verbosity > 9); diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c index 793804a..f92f8a6 100644 --- a/src/xkbcomp/symbols.c +++ b/src/xkbcomp/symbols.c @@ -399,7 +399,7 @@ MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from) xkb_layout_index_t groups_in_both; enum key_field collide = 0; bool clobber, report; - int verbosity = xkb_get_log_verbosity(info->keymap->ctx); + int verbosity = xkb_context_get_log_verbosity(info->keymap->ctx); if (from->merge == MERGE_REPLACE) { ClearKeyInfo(into); @@ -1669,7 +1669,7 @@ CopySymbolsToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info) if (!CopySymbolsDef(info, keyi)) info->errorCount++; - if (xkb_get_log_verbosity(keymap->ctx) > 3) { + if (xkb_context_get_log_verbosity(keymap->ctx) > 3) { xkb_foreach_key(key, keymap) { if (key->name[0] == '\0') continue; diff --git a/src/xkbcomp/types.c b/src/xkbcomp/types.c index 12f477f..ada9a1f 100644 --- a/src/xkbcomp/types.c +++ b/src/xkbcomp/types.c @@ -252,7 +252,7 @@ static bool AddKeyType(KeyTypesInfo *info, KeyTypeInfo *new) { KeyTypeInfo *old; - int verbosity = xkb_get_log_verbosity(info->keymap->ctx); + int verbosity = xkb_context_get_log_verbosity(info->keymap->ctx); old = FindMatchingKeyType(info, new->name); if (old) { diff --git a/test/log.c b/test/log.c index cf59045..ac32867 100644 --- a/test/log.c +++ b/test/log.c @@ -51,7 +51,7 @@ log_fn(struct xkb_context *ctx, enum xkb_log_level level, { char *s; int size; - darray_char *ls = xkb_get_user_data(ctx); + darray_char *ls = xkb_context_get_user_data(ctx); assert(ls); size = vasprintf(&s, fmt, args); @@ -78,8 +78,8 @@ main(void) assert(ctx); darray_init(log_string); - xkb_set_user_data(ctx, &log_string); - xkb_set_log_fn(ctx, log_fn); + xkb_context_set_user_data(ctx, &log_string); + xkb_context_set_log_fn(ctx, log_fn); log_warn(ctx, "first warning: %d\n", 87); log_info(ctx, "first info\n"); @@ -87,15 +87,15 @@ main(void) log_err(ctx, "first error: %lu\n", 115415UL); log_vrb(ctx, 5, "first verbose 5\n"); - xkb_set_log_level(ctx, XKB_LOG_LEVEL_DEBUG); + xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_DEBUG); log_warn(ctx, "second warning: %d\n", 87); log_dbg(ctx, "second debug: %s %s\n", "hello", "world"); log_info(ctx, "second info\n"); log_err(ctx, "second error: %lu\n", 115415UL); log_vrb(ctx, 6, "second verbose 6\n"); - xkb_set_log_verbosity(ctx, 0); - xkb_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL); + xkb_context_set_log_verbosity(ctx, 0); + xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL); log_warn(ctx, "third warning: %d\n", 87); log_dbg(ctx, "third debug: %s %s\n", "hello", "world"); log_info(ctx, "third info\n"); diff --git a/test/rules-file.c b/test/rules-file.c index b2091de..b3b3b6c 100644 --- a/test/rules-file.c +++ b/test/rules-file.c @@ -92,16 +92,16 @@ static void benchmark(struct xkb_context *ctx) { struct timespec start, stop, elapsed; - enum xkb_log_level old_level = xkb_get_log_level(ctx); - int old_verb = xkb_get_log_verbosity(ctx); + enum xkb_log_level old_level = xkb_context_get_log_level(ctx); + int old_verb = xkb_context_get_log_verbosity(ctx); int i; struct xkb_rule_names rmlvo = { "evdev", "pc105", "us,il", ",", "ctrl:nocaps,grp:menu_toggle", }; struct xkb_component_names kccgst; - xkb_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL); - xkb_set_log_verbosity(ctx, 0); + xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL); + xkb_context_set_log_verbosity(ctx, 0); clock_gettime(CLOCK_MONOTONIC, &start); for (i = 0; i < BENCHMARK_ITERATIONS; i++) { @@ -113,8 +113,8 @@ benchmark(struct xkb_context *ctx) } clock_gettime(CLOCK_MONOTONIC, &stop); - xkb_set_log_level(ctx, old_level); - xkb_set_log_verbosity(ctx, old_verb); + xkb_context_set_log_level(ctx, old_level); + xkb_context_set_log_verbosity(ctx, old_verb); elapsed.tv_sec = stop.tv_sec - start.tv_sec; elapsed.tv_nsec = stop.tv_nsec - start.tv_nsec; diff --git a/test/rulescomp.c b/test/rulescomp.c index e30f539..7318f75 100644 --- a/test/rulescomp.c +++ b/test/rulescomp.c @@ -65,20 +65,20 @@ static void benchmark(struct xkb_context *context) { struct timespec start, stop, elapsed; - enum xkb_log_level old_level = xkb_get_log_level(context); - int old_verb = xkb_get_log_verbosity(context); + enum xkb_log_level old_level = xkb_context_get_log_level(context); + int old_verb = xkb_context_get_log_verbosity(context); int i; - xkb_set_log_level(context, XKB_LOG_LEVEL_CRITICAL); - xkb_set_log_verbosity(context, 0); + xkb_context_set_log_level(context, XKB_LOG_LEVEL_CRITICAL); + xkb_context_set_log_verbosity(context, 0); clock_gettime(CLOCK_MONOTONIC, &start); for (i = 0; i < BENCHMARK_ITERATIONS; i++) assert(test_rmlvo_silent(context, "evdev", "evdev", "us", "", "")); clock_gettime(CLOCK_MONOTONIC, &stop); - xkb_set_log_level(context, old_level); - xkb_set_log_verbosity(context, old_verb); + xkb_context_set_log_level(context, old_level); + xkb_context_set_log_verbosity(context, old_verb); elapsed.tv_sec = stop.tv_sec - start.tv_sec; elapsed.tv_nsec = stop.tv_nsec - start.tv_nsec; diff --git a/xkbcommon/xkbcommon.h b/xkbcommon/xkbcommon.h index 995771f..43c5220 100644 --- a/xkbcommon/xkbcommon.h +++ b/xkbcommon/xkbcommon.h @@ -279,10 +279,10 @@ enum xkb_log_level { * Passing NULL restores the default function, which logs to stderr. **/ void -xkb_set_log_fn(struct xkb_context *context, - void (*log_fn)(struct xkb_context *context, - enum xkb_log_level level, - const char *format, va_list args)); +xkb_context_set_log_fn(struct xkb_context *context, + void (*log_fn)(struct xkb_context *context, + enum xkb_log_level level, + const char *format, va_list args)); /** * Sets the current logging level. The value controls which messages * are logged. The default level is XKB_LOG_LEVEL_ERROR. @@ -291,13 +291,14 @@ xkb_set_log_fn(struct xkb_context *context, * and may be specified as a level number or name. */ void -xkb_set_log_level(struct xkb_context *context, enum xkb_log_level level); +xkb_context_set_log_level(struct xkb_context *context, + enum xkb_log_level level); /** * Returns the current logging level. */ enum xkb_log_level -xkb_get_log_level(struct xkb_context *context); +xkb_context_get_log_level(struct xkb_context *context); /** * Sets the current logging verbosity, a value from 0 to 10. @@ -312,13 +313,13 @@ xkb_get_log_level(struct xkb_context *context); * or lower. */ void -xkb_set_log_verbosity(struct xkb_context *ctx, int verbosity); +xkb_context_set_log_verbosity(struct xkb_context *ctx, int verbosity); /** * Returns the current logging verbosity. */ int -xkb_get_log_verbosity(struct xkb_context *ctx); +xkb_context_get_log_verbosity(struct xkb_context *ctx); /** * Retrieves stored data pointer from the context. This might be useful @@ -327,13 +328,13 @@ xkb_get_log_verbosity(struct xkb_context *ctx); * If context is NULL, returns NULL. **/ void * -xkb_get_user_data(struct xkb_context *context); +xkb_context_get_user_data(struct xkb_context *context); /** * Store custom user data in the context. */ void -xkb_set_user_data(struct xkb_context *context, void *user_data); +xkb_context_set_user_data(struct xkb_context *context, void *user_data); /** @} */ -- cgit v1.2.1