Shorten context to ctx

(This breaks the API.)

"context" is really annoying to type all the time (and we're going to
type it a lot more :). "ctx" is clear, concise and common in many other
libraries. Use it!

Signed-off-by: Ran Benita <ran234@gmail.com>

[daniels: Fix for xkb -> keymap change.]
master
Ran Benita 2012-05-09 15:03:11 +03:00 committed by Daniel Stone
parent 699a0b841c
commit e7bb1e5fd9
30 changed files with 444 additions and 446 deletions

View File

@ -133,9 +133,9 @@ struct xkb_component_names {
/** /**
* Opaque context object; may only be created, accessed, manipulated and * Opaque context object; may only be created, accessed, manipulated and
* destroyed through the xkb_context_*() API. * destroyed through the xkb_ctx_*() API.
*/ */
struct xkb_context; struct xkb_ctx;
/** /**
* Opaque keymap object; may only be created, accessed, manipulated and * Opaque keymap object; may only be created, accessed, manipulated and
@ -193,7 +193,7 @@ xkb_keysym_from_name(const char *s);
* @{ * @{
*/ */
enum xkb_context_flags { enum xkb_ctx_flags {
/** Create this context with an empty include path. */ /** Create this context with an empty include path. */
XKB_CONTEXT_NO_DEFAULT_INCLUDES = 1, XKB_CONTEXT_NO_DEFAULT_INCLUDES = 1,
}; };
@ -201,10 +201,10 @@ enum xkb_context_flags {
/** /**
* Returns a new XKB context, or NULL on failure. If successful, the caller * Returns a new XKB context, or NULL on failure. If successful, the caller
* holds a reference on the context, and must free it when finished with * holds a reference on the context, and must free it when finished with
* xkb_context_unref(). * xkb_ctx_unref().
*/ */
struct xkb_context * struct xkb_ctx *
xkb_context_new(enum xkb_context_flags flags); xkb_ctx_new(enum xkb_ctx_flags flags);
/** /**
* Appends a new entry to the include path used for keymap compilation. * Appends a new entry to the include path used for keymap compilation.
@ -212,7 +212,7 @@ xkb_context_new(enum xkb_context_flags flags);
* inaccessible. * inaccessible.
*/ */
int int
xkb_context_include_path_append(struct xkb_context *context, const char *path); xkb_ctx_include_path_append(struct xkb_ctx *ctx, const char *path);
/** /**
* Appends the default include paths to the context's current include path. * Appends the default include paths to the context's current include path.
@ -220,7 +220,7 @@ xkb_context_include_path_append(struct xkb_context *context, const char *path);
* added. * added.
*/ */
int int
xkb_context_include_path_append_default(struct xkb_context *context); xkb_ctx_include_path_append_default(struct xkb_ctx *ctx);
/** /**
* Removes all entries from the context's include path, and inserts the * Removes all entries from the context's include path, and inserts the
@ -228,37 +228,37 @@ xkb_context_include_path_append_default(struct xkb_context *context);
* could not be added. * could not be added.
*/ */
int int
xkb_context_include_path_reset_defaults(struct xkb_context *context); xkb_ctx_include_path_reset_defaults(struct xkb_ctx *ctx);
/** /**
* Removes all entries from the context's include path. * Removes all entries from the context's include path.
*/ */
void void
xkb_context_include_path_clear(struct xkb_context *context); xkb_ctx_include_path_clear(struct xkb_ctx *ctx);
/** /**
* Returns the number of include paths currently active in the context. * Returns the number of include paths currently active in the context.
*/ */
unsigned int unsigned int
xkb_context_num_include_paths(struct xkb_context *context); xkb_ctx_num_include_paths(struct xkb_ctx *ctx);
/** /**
* Returns the include path at the specified index within the context. * Returns the include path at the specified index within the context.
*/ */
const char * const char *
xkb_context_include_path_get(struct xkb_context *context, unsigned int index); xkb_ctx_include_path_get(struct xkb_ctx *ctx, unsigned int index);
/** /**
* Takes a new reference on an XKB context. * Takes a new reference on an XKB context.
*/ */
struct xkb_context * struct xkb_ctx *
xkb_context_ref(struct xkb_context *context); xkb_ctx_ref(struct xkb_ctx *ctx);
/** /**
* Releases a reference on an XKB context, and possibly frees it. * Releases a reference on an XKB context, and possibly frees it.
*/ */
void void
xkb_context_unref(struct xkb_context *context); xkb_ctx_unref(struct xkb_ctx *ctx);
/** @} */ /** @} */
@ -282,7 +282,7 @@ enum xkb_map_compile_flags {
* keymaps. * keymaps.
*/ */
struct xkb_keymap * struct xkb_keymap *
xkb_map_new_from_names(struct xkb_context *context, xkb_map_new_from_names(struct xkb_ctx *ctx,
const struct xkb_rule_names *names, const struct xkb_rule_names *names,
enum xkb_map_compile_flags flags); enum xkb_map_compile_flags flags);
@ -297,7 +297,7 @@ xkb_map_new_from_names(struct xkb_context *context,
* Geometry will be ignored since xkbcommon does not support it in any way. * Geometry will be ignored since xkbcommon does not support it in any way.
*/ */
struct xkb_keymap * struct xkb_keymap *
xkb_map_new_from_kccgst(struct xkb_context *context, xkb_map_new_from_kccgst(struct xkb_ctx *ctx,
const struct xkb_component_names *kccgst, const struct xkb_component_names *kccgst,
enum xkb_map_compile_flags flags); enum xkb_map_compile_flags flags);
@ -311,7 +311,7 @@ enum xkb_keymap_format {
* file descriptor. * file descriptor.
*/ */
struct xkb_keymap * struct xkb_keymap *
xkb_map_new_from_fd(struct xkb_context *context, xkb_map_new_from_fd(struct xkb_ctx *ctx,
int fd, enum xkb_keymap_format format, int fd, enum xkb_keymap_format format,
enum xkb_map_compile_flags flags); enum xkb_map_compile_flags flags);
@ -320,7 +320,7 @@ xkb_map_new_from_fd(struct xkb_context *context,
* enormous string. * enormous string.
*/ */
struct xkb_keymap * struct xkb_keymap *
xkb_map_new_from_string(struct xkb_context *context, xkb_map_new_from_string(struct xkb_ctx *ctx,
const char *string, const char *string,
enum xkb_keymap_format format, enum xkb_keymap_format format,
enum xkb_map_compile_flags flags); enum xkb_map_compile_flags flags);

View File

@ -597,7 +597,7 @@ XkbcFreeIndicatorMaps(struct xkb_keymap *keymap)
} }
struct xkb_keymap * struct xkb_keymap *
XkbcAllocKeyboard(struct xkb_context *context) XkbcAllocKeyboard(struct xkb_ctx *ctx)
{ {
struct xkb_keymap *keymap; struct xkb_keymap *keymap;
@ -606,7 +606,7 @@ XkbcAllocKeyboard(struct xkb_context *context)
return NULL; return NULL;
keymap->refcnt = 1; keymap->refcnt = 1;
keymap->context = xkb_context_ref(context); keymap->ctx = xkb_ctx_ref(ctx);
return keymap; return keymap;
} }
@ -623,6 +623,6 @@ XkbcFreeKeyboard(struct xkb_keymap *keymap)
XkbcFreeIndicatorMaps(keymap); XkbcFreeIndicatorMaps(keymap);
XkbcFreeNames(keymap); XkbcFreeNames(keymap);
XkbcFreeControls(keymap); XkbcFreeControls(keymap);
xkb_context_unref(keymap->context); xkb_ctx_unref(keymap->ctx);
free(keymap); free(keymap);
} }

View File

@ -43,7 +43,7 @@ extern int
XkbcAllocIndicatorMaps(struct xkb_keymap *keymap); XkbcAllocIndicatorMaps(struct xkb_keymap *keymap);
extern struct xkb_keymap * extern struct xkb_keymap *
XkbcAllocKeyboard(struct xkb_context *context); XkbcAllocKeyboard(struct xkb_ctx *ctx);
extern void extern void
XkbcFreeKeyboard(struct xkb_keymap *keymap); XkbcFreeKeyboard(struct xkb_keymap *keymap);

View File

@ -31,7 +31,7 @@
#include "xkb-priv.h" #include "xkb-priv.h"
#include "atom.h" #include "atom.h"
struct xkb_context { struct xkb_ctx {
int refcnt; int refcnt;
char **include_paths; char **include_paths;
@ -48,23 +48,23 @@ struct xkb_context {
* Append one directory to the context's include path. * Append one directory to the context's include path.
*/ */
_X_EXPORT int _X_EXPORT int
xkb_context_include_path_append(struct xkb_context *context, const char *path) xkb_ctx_include_path_append(struct xkb_ctx *ctx, const char *path)
{ {
struct stat stat_buf; struct stat stat_buf;
int err; int err;
if (context->size_include_paths <= context->num_include_paths) { if (ctx->size_include_paths <= ctx->num_include_paths) {
int new_size; int new_size;
char **new_paths; char **new_paths;
new_size = context->size_include_paths + 2; new_size = ctx->size_include_paths + 2;
new_paths = uTypedRecalloc(context->include_paths, new_paths = uTypedRecalloc(ctx->include_paths,
context->size_include_paths, ctx->size_include_paths,
new_size, new_size,
char *); char *);
if (!new_paths) if (!new_paths)
return 0; return 0;
context->include_paths = new_paths; ctx->include_paths = new_paths;
context->size_include_paths = new_size; ctx->size_include_paths = new_size;
} }
err = stat(path, &stat_buf); err = stat(path, &stat_buf);
@ -75,10 +75,10 @@ xkb_context_include_path_append(struct xkb_context *context, const char *path)
if (eaccess(path, R_OK | X_OK) != 0) if (eaccess(path, R_OK | X_OK) != 0)
return 0; return 0;
context->include_paths[context->num_include_paths] = strdup(path); ctx->include_paths[ctx->num_include_paths] = strdup(path);
if (!context->include_paths[context->num_include_paths]) if (!ctx->include_paths[ctx->num_include_paths])
return 0; return 0;
context->num_include_paths++; ctx->num_include_paths++;
return 1; return 1;
} }
@ -87,13 +87,13 @@ xkb_context_include_path_append(struct xkb_context *context, const char *path)
* Append the default include directories to the context. * Append the default include directories to the context.
*/ */
_X_EXPORT int _X_EXPORT int
xkb_context_include_path_append_default(struct xkb_context *context) xkb_ctx_include_path_append_default(struct xkb_ctx *ctx)
{ {
const char *home = getenv("HOME"); const char *home = getenv("HOME");
char *user_path; char *user_path;
int err; int err;
(void) xkb_context_include_path_append(context, DFLT_XKB_CONFIG_ROOT); (void) xkb_ctx_include_path_append(ctx, DFLT_XKB_CONFIG_ROOT);
home = getenv("HOME"); home = getenv("HOME");
if (!home) if (!home)
@ -101,7 +101,7 @@ xkb_context_include_path_append_default(struct xkb_context *context)
err = asprintf(&user_path, "%s/.xkb", home); err = asprintf(&user_path, "%s/.xkb", home);
if (err <= 0) if (err <= 0)
return 1; return 1;
(void) xkb_context_include_path_append(context, user_path); (void) xkb_ctx_include_path_append(ctx, user_path);
free(user_path); free(user_path);
return 1; return 1;
@ -111,36 +111,36 @@ xkb_context_include_path_append_default(struct xkb_context *context)
* Remove all entries in the context's include path. * Remove all entries in the context's include path.
*/ */
_X_EXPORT void _X_EXPORT void
xkb_context_include_path_clear(struct xkb_context *context) xkb_ctx_include_path_clear(struct xkb_ctx *ctx)
{ {
int i; int i;
for (i = 0; i < context->num_include_paths; i++) { for (i = 0; i < ctx->num_include_paths; i++) {
free(context->include_paths[i]); free(ctx->include_paths[i]);
context->include_paths[i] = NULL; ctx->include_paths[i] = NULL;
} }
free(context->include_paths); free(ctx->include_paths);
context->include_paths = NULL; ctx->include_paths = NULL;
context->num_include_paths = 0; ctx->num_include_paths = 0;
} }
/** /**
* xkb_context_include_path_clear() + xkb_context_include_path_append_default() * xkb_ctx_include_path_clear() + xkb_ctx_include_path_append_default()
*/ */
_X_EXPORT int _X_EXPORT int
xkb_context_include_path_reset_defaults(struct xkb_context *context) xkb_ctx_include_path_reset_defaults(struct xkb_ctx *ctx)
{ {
xkb_context_include_path_clear(context); xkb_ctx_include_path_clear(ctx);
return xkb_context_include_path_append_default(context); return xkb_ctx_include_path_append_default(ctx);
} }
/** /**
* Returns the number of entries in the context's include path. * Returns the number of entries in the context's include path.
*/ */
_X_EXPORT unsigned int _X_EXPORT unsigned int
xkb_context_num_include_paths(struct xkb_context *context) xkb_ctx_num_include_paths(struct xkb_ctx *ctx)
{ {
return context->num_include_paths; return ctx->num_include_paths;
} }
/** /**
@ -148,28 +148,28 @@ xkb_context_num_include_paths(struct xkb_context *context)
* invalid index is passed. * invalid index is passed.
*/ */
_X_EXPORT const char * _X_EXPORT const char *
xkb_context_include_path_get(struct xkb_context *context, unsigned int idx) xkb_ctx_include_path_get(struct xkb_ctx *ctx, unsigned int idx)
{ {
if (idx >= xkb_context_num_include_paths(context)) if (idx >= xkb_ctx_num_include_paths(ctx))
return NULL; return NULL;
return context->include_paths[idx]; return ctx->include_paths[idx];
} }
int int
xkb_context_take_file_id(struct xkb_context *context) xkb_ctx_take_file_id(struct xkb_ctx *ctx)
{ {
return context->file_id++; return ctx->file_id++;
} }
/** /**
* Take a new reference on the context. * Take a new reference on the context.
*/ */
_X_EXPORT struct xkb_context * _X_EXPORT struct xkb_ctx *
xkb_context_ref(struct xkb_context *context) xkb_ctx_ref(struct xkb_ctx *ctx)
{ {
context->refcnt++; ctx->refcnt++;
return context; return ctx;
} }
/** /**
@ -177,58 +177,58 @@ xkb_context_ref(struct xkb_context *context)
* now 0. * now 0.
*/ */
_X_EXPORT void _X_EXPORT void
xkb_context_unref(struct xkb_context *context) xkb_ctx_unref(struct xkb_ctx *ctx)
{ {
if (--context->refcnt > 0) if (--ctx->refcnt > 0)
return; return;
xkb_context_include_path_clear(context); xkb_ctx_include_path_clear(ctx);
atom_table_free(context->atom_table); atom_table_free(ctx->atom_table);
free(context); free(ctx);
} }
/** /**
* Create a new context. * Create a new context.
*/ */
_X_EXPORT struct xkb_context * _X_EXPORT struct xkb_ctx *
xkb_context_new(enum xkb_context_flags flags) xkb_ctx_new(enum xkb_ctx_flags flags)
{ {
struct xkb_context *context = calloc(1, sizeof(*context)); struct xkb_ctx *ctx = calloc(1, sizeof(*ctx));
if (!context) if (!ctx)
return NULL; return NULL;
context->refcnt = 1; ctx->refcnt = 1;
if (!(flags & XKB_CONTEXT_NO_DEFAULT_INCLUDES) && if (!(flags & XKB_CONTEXT_NO_DEFAULT_INCLUDES) &&
!xkb_context_include_path_append_default(context)) { !xkb_ctx_include_path_append_default(ctx)) {
xkb_context_unref(context); xkb_ctx_unref(ctx);
return NULL; return NULL;
} }
context->atom_table = atom_table_new(); ctx->atom_table = atom_table_new();
if (!context->atom_table) { if (!ctx->atom_table) {
xkb_context_unref(context); xkb_ctx_unref(ctx);
return NULL; return NULL;
} }
return context; return ctx;
} }
xkb_atom_t xkb_atom_t
xkb_atom_intern(struct xkb_context *context, const char *string) xkb_atom_intern(struct xkb_ctx *ctx, const char *string)
{ {
return atom_intern(context->atom_table, string); return atom_intern(ctx->atom_table, string);
} }
char * char *
xkb_atom_strdup(struct xkb_context *context, xkb_atom_t atom) xkb_atom_strdup(struct xkb_ctx *ctx, xkb_atom_t atom)
{ {
return atom_strdup(context->atom_table, atom); return atom_strdup(ctx->atom_table, atom);
} }
const char * const char *
xkb_atom_text(struct xkb_context *context, xkb_atom_t atom) xkb_atom_text(struct xkb_ctx *ctx, xkb_atom_t atom)
{ {
return atom_text(context->atom_table, atom); return atom_text(ctx->atom_table, atom);
} }

View File

@ -358,7 +358,7 @@ struct xkb_controls {
/* Common keyboard description structure */ /* Common keyboard description structure */
struct xkb_keymap { struct xkb_keymap {
struct xkb_context *context; struct xkb_ctx *ctx;
unsigned int refcnt; unsigned int refcnt;
unsigned short flags; unsigned short flags;
@ -431,13 +431,13 @@ typedef uint32_t xkb_atom_t;
#define XKB_ATOM_NONE 0 #define XKB_ATOM_NONE 0
xkb_atom_t xkb_atom_t
xkb_atom_intern(struct xkb_context *context, const char *string); xkb_atom_intern(struct xkb_ctx *ctx, const char *string);
char * char *
xkb_atom_strdup(struct xkb_context *context, xkb_atom_t atom); xkb_atom_strdup(struct xkb_ctx *ctx, xkb_atom_t atom);
const char * const char *
xkb_atom_text(struct xkb_context *context, xkb_atom_t atom); xkb_atom_text(struct xkb_ctx *ctx, xkb_atom_t atom);
extern unsigned int extern unsigned int
xkb_key_get_group(struct xkb_state *state, xkb_keycode_t key); xkb_key_get_group(struct xkb_state *state, xkb_keycode_t key);
@ -452,7 +452,7 @@ xkb_key_get_syms_by_level(struct xkb_keymap *keymap, xkb_keycode_t key,
const xkb_keysym_t **syms_out); const xkb_keysym_t **syms_out);
extern int extern int
xkb_context_take_file_id(struct xkb_context *context); xkb_ctx_take_file_id(struct xkb_ctx *ctx);
extern bool extern bool
XkbcComputeEffectiveMap(struct xkb_keymap *keymap, struct xkb_key_type *type, XkbcComputeEffectiveMap(struct xkb_keymap *keymap, struct xkb_key_type *type,

View File

@ -222,7 +222,7 @@ CheckLatchLockFlags(struct xkb_keymap *keymap, unsigned action,
tmp = XkbSA_LatchToLock; tmp = XkbSA_LatchToLock;
else else
return false; /* WSGO! */ return false; /* WSGO! */
if (!ExprResolveBoolean(keymap->context, value, &result)) if (!ExprResolveBoolean(keymap->ctx, value, &result))
return ReportMismatch(action, field, "boolean"); return ReportMismatch(action, field, "boolean");
if (result.uval) if (result.uval)
*flags_inout |= tmp; *flags_inout |= tmp;
@ -240,7 +240,7 @@ CheckModifierField(struct xkb_keymap *keymap, unsigned action, ExprDef *value,
if (value->op == ExprIdent) if (value->op == ExprIdent)
{ {
const char *valStr; const char *valStr;
valStr = xkb_atom_text(keymap->context, value->value.str); valStr = xkb_atom_text(keymap->ctx, value->value.str);
if (valStr && ((strcasecmp(valStr, "usemodmapmods") == 0) || if (valStr && ((strcasecmp(valStr, "usemodmapmods") == 0) ||
(strcasecmp(valStr, "modmapmods") == 0))) (strcasecmp(valStr, "modmapmods") == 0)))
{ {
@ -345,7 +345,7 @@ CheckGroupField(struct xkb_keymap *keymap, unsigned action,
spec = value; spec = value;
} }
if (!ExprResolveGroup(keymap->context, spec, &rtrn)) if (!ExprResolveGroup(keymap->ctx, spec, &rtrn))
return ReportMismatch(action, F_Group, "integer (range 1..8)"); return ReportMismatch(action, F_Group, "integer (range 1..8)");
if (value->op == OpNegate) if (value->op == OpNegate)
*grp_rtrn = -rtrn.ival; *grp_rtrn = -rtrn.ival;
@ -443,7 +443,7 @@ HandleMovePtr(struct xkb_keymap *keymap, struct xkb_any_action *action,
absolute = false; absolute = false;
else else
absolute = true; absolute = true;
if (!ExprResolveInteger(keymap->context, value, &rtrn)) if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "integer"); return ReportMismatch(action->type, field, "integer");
if (field == F_X) if (field == F_X)
{ {
@ -461,7 +461,7 @@ HandleMovePtr(struct xkb_keymap *keymap, struct xkb_any_action *action,
} }
else if (field == F_Accel) else if (field == F_Accel)
{ {
if (!ExprResolveBoolean(keymap->context, value, &rtrn)) if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "boolean"); return ReportMismatch(action->type, field, "boolean");
if (rtrn.uval) if (rtrn.uval)
act->flags &= ~XkbSA_NoAcceleration; act->flags &= ~XkbSA_NoAcceleration;
@ -491,7 +491,7 @@ HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
{ {
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveButton(keymap->context, value, &rtrn)) if (!ExprResolveButton(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, return ReportMismatch(action->type, field,
"integer (range 1..5)"); "integer (range 1..5)");
if ((rtrn.ival < 0) || (rtrn.ival > 5)) if ((rtrn.ival < 0) || (rtrn.ival > 5))
@ -507,7 +507,7 @@ HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
{ {
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveEnum(keymap->context, value, &rtrn, lockWhich)) if (!ExprResolveEnum(keymap->ctx, value, &rtrn, lockWhich))
return ReportMismatch(action->type, field, "lock or unlock"); return ReportMismatch(action->type, field, "lock or unlock");
act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock); act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock);
act->flags |= rtrn.ival; act->flags |= rtrn.ival;
@ -517,7 +517,7 @@ HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
{ {
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveButton(keymap->context, value, &rtrn)) if (!ExprResolveButton(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "integer"); return ReportMismatch(action->type, field, "integer");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) if ((rtrn.ival < 0) || (rtrn.ival > 255))
{ {
@ -550,7 +550,7 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, struct xkb_any_action *action,
{ {
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveEnum(keymap->context, value, &rtrn, ptrDflts)) if (!ExprResolveEnum(keymap->ctx, value, &rtrn, ptrDflts))
return ReportMismatch(action->type, field, "pointer component"); return ReportMismatch(action->type, field, "pointer component");
act->affect = rtrn.uval; act->affect = rtrn.uval;
return true; return true;
@ -571,7 +571,7 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, struct xkb_any_action *action,
btn = value; btn = value;
} }
if (!ExprResolveButton(keymap->context, btn, &rtrn)) if (!ExprResolveButton(keymap->ctx, btn, &rtrn))
return ReportMismatch(action->type, field, return ReportMismatch(action->type, field,
"integer (range 1..5)"); "integer (range 1..5)");
if ((rtrn.ival < 0) || (rtrn.ival > 5)) if ((rtrn.ival < 0) || (rtrn.ival > 5))
@ -647,7 +647,7 @@ HandleISOLock(struct xkb_keymap *keymap, struct xkb_any_action *action,
case F_Affect: case F_Affect:
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveMask(keymap->context, value, &rtrn, isoNames)) if (!ExprResolveMask(keymap->ctx, value, &rtrn, isoNames))
return ReportMismatch(action->type, field, "keyboard component"); return ReportMismatch(action->type, field, "keyboard component");
act->affect = (~rtrn.uval) & XkbSA_ISOAffectMask; act->affect = (~rtrn.uval) & XkbSA_ISOAffectMask;
return true; return true;
@ -679,7 +679,7 @@ HandleSwitchScreen(struct xkb_keymap *keymap, struct xkb_any_action *action,
scrn = value; scrn = value;
} }
if (!ExprResolveInteger(keymap->context, scrn, &rtrn)) if (!ExprResolveInteger(keymap->ctx, scrn, &rtrn))
return ReportMismatch(action->type, field, "integer (0..255)"); return ReportMismatch(action->type, field, "integer (0..255)");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) if ((rtrn.ival < 0) || (rtrn.ival > 255))
{ {
@ -697,7 +697,7 @@ HandleSwitchScreen(struct xkb_keymap *keymap, struct xkb_any_action *action,
{ {
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveBoolean(keymap->context, value, &rtrn)) if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "boolean"); return ReportMismatch(action->type, field, "boolean");
if (rtrn.uval) if (rtrn.uval)
act->flags &= ~XkbSA_SwitchApplication; act->flags &= ~XkbSA_SwitchApplication;
@ -741,7 +741,7 @@ HandleSetLockControls(struct xkb_keymap *keymap, struct xkb_any_action *action,
{ {
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveMask(keymap->context, value, &rtrn, ctrlNames)) if (!ExprResolveMask(keymap->ctx, value, &rtrn, ctrlNames))
return ReportMismatch(action->type, field, "controls mask"); return ReportMismatch(action->type, field, "controls mask");
act->ctrls = rtrn.uval; act->ctrls = rtrn.uval;
return true; return true;
@ -772,7 +772,7 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
case F_Report: case F_Report:
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveMask(keymap->context, value, &rtrn, evNames)) if (!ExprResolveMask(keymap->ctx, value, &rtrn, evNames))
return ReportMismatch(action->type, field, "key event mask"); return ReportMismatch(action->type, field, "key event mask");
act->flags &= ~(XkbSA_MessageOnPress | XkbSA_MessageOnRelease); act->flags &= ~(XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
act->flags = act->flags =
@ -781,7 +781,7 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
case F_GenKeyEvent: case F_GenKeyEvent:
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveBoolean(keymap->context, value, &rtrn)) if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "boolean"); return ReportMismatch(action->type, field, "boolean");
if (rtrn.uval) if (rtrn.uval)
act->flags |= XkbSA_MessageGenKeyEvent; act->flags |= XkbSA_MessageGenKeyEvent;
@ -791,7 +791,7 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
case F_Data: case F_Data:
if (array_ndx == NULL) if (array_ndx == NULL)
{ {
if (!ExprResolveString(keymap->context, value, &rtrn)) if (!ExprResolveString(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "string"); return ReportMismatch(action->type, field, "string");
else else
{ {
@ -808,7 +808,7 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
else else
{ {
unsigned ndx; unsigned ndx;
if (!ExprResolveInteger(keymap->context, array_ndx, &rtrn)) if (!ExprResolveInteger(keymap->ctx, array_ndx, &rtrn))
{ {
ERROR("Array subscript must be integer\n"); ERROR("Array subscript must be integer\n");
ACTION("Illegal subscript ignored\n"); ACTION("Illegal subscript ignored\n");
@ -821,7 +821,7 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
ACTION("Attempt to use data[%d] ignored\n", ndx); ACTION("Attempt to use data[%d] ignored\n", ndx);
return false; return false;
} }
if (!ExprResolveInteger(keymap->context, value, &rtrn)) if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "integer"); return ReportMismatch(action->type, field, "integer");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) if ((rtrn.ival < 0) || (rtrn.ival > 255))
{ {
@ -853,7 +853,7 @@ HandleRedirectKey(struct xkb_keymap *keymap, struct xkb_any_action *action,
switch (field) switch (field)
{ {
case F_Keycode: case F_Keycode:
if (!ExprResolveKeyName(keymap->context, value, &rtrn)) if (!ExprResolveKeyName(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "key name"); return ReportMismatch(action->type, field, "key name");
tmp = KeyNameToLong(rtrn.keyName.name); tmp = KeyNameToLong(rtrn.keyName.name);
if (!FindNamedKey(keymap, tmp, &kc, true, CreateKeyNames(keymap), 0)) if (!FindNamedKey(keymap, tmp, &kc, true, CreateKeyNames(keymap), 0))
@ -899,7 +899,7 @@ HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
{ {
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveInteger(keymap->context, value, &rtrn)) if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, return ReportMismatch(action->type, field,
"integer (range 1..255)"); "integer (range 1..255)");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) if ((rtrn.ival < 0) || (rtrn.ival > 255))
@ -915,7 +915,7 @@ HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
{ {
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveEnum(keymap->context, value, &rtrn, lockWhich)) if (!ExprResolveEnum(keymap->ctx, value, &rtrn, lockWhich))
return ReportMismatch(action->type, field, "lock or unlock"); return ReportMismatch(action->type, field, "lock or unlock");
act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock); act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock);
act->flags |= rtrn.ival; act->flags |= rtrn.ival;
@ -925,7 +925,7 @@ HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
{ {
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveButton(keymap->context, value, &rtrn)) if (!ExprResolveButton(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "integer"); return ReportMismatch(action->type, field, "integer");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) if ((rtrn.ival < 0) || (rtrn.ival > 255))
{ {
@ -940,7 +940,7 @@ HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
{ {
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveInteger(keymap->context, value, &rtrn)) if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, return ReportMismatch(action->type, field,
"integer (range 1..255)"); "integer (range 1..255)");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) if ((rtrn.ival < 0) || (rtrn.ival > 255))
@ -978,7 +978,7 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action,
switch (field) switch (field)
{ {
case F_Type: case F_Type:
if (!ExprResolveInteger(keymap->context, value, &rtrn)) if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return ReportMismatch(PrivateAction, field, "integer"); return ReportMismatch(PrivateAction, field, "integer");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) if ((rtrn.ival < 0) || (rtrn.ival > 255))
{ {
@ -991,7 +991,7 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action,
case F_Data: case F_Data:
if (array_ndx == NULL) if (array_ndx == NULL)
{ {
if (!ExprResolveString(keymap->context, value, &rtrn)) if (!ExprResolveString(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "string"); return ReportMismatch(action->type, field, "string");
else else
{ {
@ -1010,7 +1010,7 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action,
else else
{ {
unsigned ndx; unsigned ndx;
if (!ExprResolveInteger(keymap->context, array_ndx, &rtrn)) if (!ExprResolveInteger(keymap->ctx, array_ndx, &rtrn))
{ {
ERROR("Array subscript must be integer\n"); ERROR("Array subscript must be integer\n");
ACTION("Illegal subscript ignored\n"); ACTION("Illegal subscript ignored\n");
@ -1023,7 +1023,7 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action,
ACTION("Attempt to use data[%d] ignored\n", ndx); ACTION("Attempt to use data[%d] ignored\n", ndx);
return false; return false;
} }
if (!ExprResolveInteger(keymap->context, value, &rtrn)) if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "integer"); return ReportMismatch(action->type, field, "integer");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) if ((rtrn.ival < 0) || (rtrn.ival > 255))
{ {
@ -1085,7 +1085,7 @@ ApplyActionFactoryDefaults(union xkb_action * action)
} }
static void static void
ActionsInit(struct xkb_context *context); ActionsInit(struct xkb_ctx *ctx);
int int
HandleActionDef(ExprDef * def, HandleActionDef(ExprDef * def,
@ -1097,7 +1097,7 @@ HandleActionDef(ExprDef * def,
unsigned tmp, hndlrType; unsigned tmp, hndlrType;
if (!actionsInitialized) if (!actionsInitialized)
ActionsInit(keymap->context); ActionsInit(keymap->ctx);
if (def->op != ExprActionDecl) if (def->op != ExprActionDecl)
{ {
@ -1105,7 +1105,7 @@ HandleActionDef(ExprDef * def,
exprOpText(def->op)); exprOpText(def->op));
return false; return false;
} }
str = xkb_atom_text(keymap->context, def->value.action.name); str = xkb_atom_text(keymap->ctx, def->value.action.name);
if (!str) if (!str)
{ {
WSGO("Missing name in action definition!!\n"); WSGO("Missing name in action definition!!\n");
@ -1153,13 +1153,13 @@ HandleActionDef(ExprDef * def,
if ((arg->op == OpNot) || (arg->op == OpInvert)) if ((arg->op == OpNot) || (arg->op == OpInvert))
{ {
field = arg->value.child; field = arg->value.child;
constFalse.value.str = xkb_atom_intern(keymap->context, "false"); constFalse.value.str = xkb_atom_intern(keymap->ctx, "false");
value = &constFalse; value = &constFalse;
} }
else else
{ {
field = arg; field = arg;
constTrue.value.str = xkb_atom_intern(keymap->context, "true"); constTrue.value.str = xkb_atom_intern(keymap->ctx, "true");
value = &constTrue; value = &constTrue;
} }
} }
@ -1202,7 +1202,7 @@ SetActionField(struct xkb_keymap *keymap,
ActionInfo *new, *old; ActionInfo *new, *old;
if (!actionsInitialized) if (!actionsInitialized)
ActionsInit(keymap->context); ActionsInit(keymap->ctx);
new = uTypedAlloc(ActionInfo); new = uTypedAlloc(ActionInfo);
if (new == NULL) if (new == NULL)
@ -1249,7 +1249,7 @@ SetActionField(struct xkb_keymap *keymap,
/***====================================================================***/ /***====================================================================***/
static void static void
ActionsInit(struct xkb_context *context) ActionsInit(struct xkb_ctx *ctx)
{ {
if (!actionsInitialized) if (!actionsInitialized)
{ {
@ -1259,12 +1259,12 @@ ActionsInit(struct xkb_context *context)
constTrue.common.next = NULL; constTrue.common.next = NULL;
constTrue.op = ExprIdent; constTrue.op = ExprIdent;
constTrue.type = TypeBoolean; constTrue.type = TypeBoolean;
constTrue.value.str = xkb_atom_intern(context, "true"); constTrue.value.str = xkb_atom_intern(ctx, "true");
constFalse.common.stmtType = StmtExpr; constFalse.common.stmtType = StmtExpr;
constFalse.common.next = NULL; constFalse.common.next = NULL;
constFalse.op = ExprIdent; constFalse.op = ExprIdent;
constFalse.type = TypeBoolean; constFalse.type = TypeBoolean;
constFalse.value.str = xkb_atom_intern(context, "false"); constFalse.value.str = xkb_atom_intern(ctx, "false");
actionsInitialized = 1; actionsInitialized = 1;
} }
} }

View File

@ -115,7 +115,7 @@ InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap)
info->dflt.interp.act.type = XkbSA_NoAction; info->dflt.interp.act.type = XkbSA_NoAction;
for (i = 0; i < sizeof(info->dflt.interp.act.any.data); i++) for (i = 0; i < sizeof(info->dflt.interp.act.any.data); i++)
info->dflt.interp.act.any.data[i] = 0; info->dflt.interp.act.any.data[i] = 0;
ClearIndicatorMapInfo(keymap->context, &info->ledDflt); ClearIndicatorMapInfo(keymap->ctx, &info->ledDflt);
info->ledDflt.defs.fileID = info->fileID; info->ledDflt.defs.fileID = info->fileID;
info->ledDflt.defs.defined = 0; info->ledDflt.defs.defined = 0;
info->ledDflt.defs.merge = MergeOverride; info->ledDflt.defs.merge = MergeOverride;
@ -140,7 +140,7 @@ ClearCompatInfo(CompatInfo *info, struct xkb_keymap *keymap)
info->dflt.interp.act.type = XkbSA_NoAction; info->dflt.interp.act.type = XkbSA_NoAction;
for (i = 0; i < sizeof(info->dflt.interp.act.any.data); i++) for (i = 0; i < sizeof(info->dflt.interp.act.any.data); i++)
info->dflt.interp.act.any.data[i] = 0; info->dflt.interp.act.any.data[i] = 0;
ClearIndicatorMapInfo(keymap->context, &info->ledDflt); ClearIndicatorMapInfo(keymap->ctx, &info->ledDflt);
info->nInterps = 0; info->nInterps = 0;
info->interps = (SymInterpInfo *) ClearCommonInfo(&info->interps->defs); info->interps = (SymInterpInfo *) ClearCommonInfo(&info->interps->defs);
memset(&info->groupCompat[0], 0, memset(&info->groupCompat[0], 0,
@ -299,7 +299,7 @@ ResolveStateAndPredicate(ExprDef * expr,
*pred_rtrn = XkbSI_Exactly; *pred_rtrn = XkbSI_Exactly;
if (expr->op == ExprActionDecl) if (expr->op == ExprActionDecl)
{ {
const char *pred_txt = xkb_atom_text(info->keymap->context, const char *pred_txt = xkb_atom_text(info->keymap->ctx,
expr->value.action.name); expr->value.action.name);
if (strcasecmp(pred_txt, "noneof") == 0) if (strcasecmp(pred_txt, "noneof") == 0)
*pred_rtrn = XkbSI_NoneOf; *pred_rtrn = XkbSI_NoneOf;
@ -321,7 +321,7 @@ ResolveStateAndPredicate(ExprDef * expr,
} }
else if (expr->op == ExprIdent) else if (expr->op == ExprIdent)
{ {
const char *pred_txt = xkb_atom_text(info->keymap->context, const char *pred_txt = xkb_atom_text(info->keymap->ctx,
expr->value.str); expr->value.str);
if ((pred_txt) && (strcasecmp(pred_txt, "any") == 0)) if ((pred_txt) && (strcasecmp(pred_txt, "any") == 0))
{ {
@ -331,7 +331,7 @@ ResolveStateAndPredicate(ExprDef * expr,
} }
} }
if (ExprResolveModMask(info->keymap->context, expr, &result)) if (ExprResolveModMask(info->keymap->ctx, expr, &result))
{ {
*mods_rtrn = result.uval; *mods_rtrn = result.uval;
return true; return true;
@ -405,8 +405,8 @@ HandleIncludeCompatMap(IncludeStmt *stmt, struct xkb_keymap *keymap,
included = *info; included = *info;
memset(info, 0, sizeof(CompatInfo)); memset(info, 0, sizeof(CompatInfo));
} }
else if (ProcessIncludeFile(keymap->context, stmt, XkmCompatMapIndex, else if (ProcessIncludeFile(keymap->ctx, stmt, XkmCompatMapIndex, &rtrn,
&rtrn, &newMerge)) &newMerge))
{ {
InitCompatInfo(&included, keymap); InitCompatInfo(&included, keymap);
included.fileID = rtrn->id; included.fileID = rtrn->id;
@ -446,8 +446,8 @@ HandleIncludeCompatMap(IncludeStmt *stmt, struct xkb_keymap *keymap,
MergeIncludedCompatMaps(&included, info, next->merge); MergeIncludedCompatMaps(&included, info, next->merge);
ClearCompatInfo(info, keymap); ClearCompatInfo(info, keymap);
} }
else if (ProcessIncludeFile(keymap->context, next, else if (ProcessIncludeFile(keymap->ctx, next, XkmCompatMapIndex,
XkmCompatMapIndex, &rtrn, &op)) &rtrn, &op))
{ {
InitCompatInfo(&next_incl, keymap); InitCompatInfo(&next_incl, keymap);
next_incl.fileID = rtrn->id; next_incl.fileID = rtrn->id;
@ -522,7 +522,7 @@ SetInterpField(SymInterpInfo *si, struct xkb_keymap *keymap, char *field,
{ {
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportSINotArray(si, field, info); return ReportSINotArray(si, field, info);
ok = ExprResolveBoolean(keymap->context, value, &tmp); ok = ExprResolveBoolean(keymap->ctx, value, &tmp);
if (ok) if (ok)
{ {
if (tmp.uval) if (tmp.uval)
@ -538,7 +538,7 @@ SetInterpField(SymInterpInfo *si, struct xkb_keymap *keymap, char *field,
{ {
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportSINotArray(si, field, info); return ReportSINotArray(si, field, info);
ok = ExprResolveBoolean(keymap->context, value, &tmp); ok = ExprResolveBoolean(keymap->ctx, value, &tmp);
if (ok) if (ok)
{ {
if (tmp.uval) if (tmp.uval)
@ -555,7 +555,7 @@ SetInterpField(SymInterpInfo *si, struct xkb_keymap *keymap, char *field,
{ {
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportSINotArray(si, field, info); return ReportSINotArray(si, field, info);
ok = ExprResolveEnum(keymap->context, value, &tmp, useModMapValues); ok = ExprResolveEnum(keymap->ctx, value, &tmp, useModMapValues);
if (ok) if (ok)
{ {
if (tmp.uval) if (tmp.uval)

View File

@ -28,7 +28,7 @@
/***====================================================================***/ /***====================================================================***/
typedef bool (*IdentLookupFunc) (struct xkb_context *context, const void *priv, typedef bool (*IdentLookupFunc) (struct xkb_ctx *ctx, const void *priv,
xkb_atom_t field, unsigned type, xkb_atom_t field, unsigned type,
ExprResult *val_rtrn); ExprResult *val_rtrn);
@ -137,21 +137,21 @@ ExprResolveLhs(struct xkb_keymap *keymap, ExprDef *expr,
{ {
case ExprIdent: case ExprIdent:
elem_rtrn->str = NULL; elem_rtrn->str = NULL;
field_rtrn->str = xkb_atom_strdup(keymap->context, field_rtrn->str = xkb_atom_strdup(keymap->ctx,
expr->value.str); expr->value.str);
*index_rtrn = NULL; *index_rtrn = NULL;
return true; return true;
case ExprFieldRef: case ExprFieldRef:
elem_rtrn->str = xkb_atom_strdup(keymap->context, elem_rtrn->str = xkb_atom_strdup(keymap->ctx,
expr->value.field.element); expr->value.field.element);
field_rtrn->str = xkb_atom_strdup(keymap->context, field_rtrn->str = xkb_atom_strdup(keymap->ctx,
expr->value.field.field); expr->value.field.field);
*index_rtrn = NULL; *index_rtrn = NULL;
return true; return true;
case ExprArrayRef: case ExprArrayRef:
elem_rtrn->str = xkb_atom_strdup(keymap->context, elem_rtrn->str = xkb_atom_strdup(keymap->ctx,
expr->value.array.element); expr->value.array.element);
field_rtrn->str = xkb_atom_strdup(keymap->context, field_rtrn->str = xkb_atom_strdup(keymap->ctx,
expr->value.array.field); expr->value.array.field);
*index_rtrn = expr->value.array.entry; *index_rtrn = expr->value.array.entry;
return true; return true;
@ -161,7 +161,7 @@ ExprResolveLhs(struct xkb_keymap *keymap, ExprDef *expr,
} }
static bool static bool
SimpleLookup(struct xkb_context *context, const void *priv, SimpleLookup(struct xkb_ctx *ctx, const void *priv,
xkb_atom_t field, unsigned type, ExprResult *val_rtrn) xkb_atom_t field, unsigned type, ExprResult *val_rtrn)
{ {
const LookupEntry *entry; const LookupEntry *entry;
@ -171,7 +171,7 @@ SimpleLookup(struct xkb_context *context, const void *priv,
{ {
return false; return false;
} }
str = xkb_atom_text(context, field); str = xkb_atom_text(ctx, field);
for (entry = priv; (entry != NULL) && (entry->name != NULL); entry++) for (entry = priv; (entry != NULL) && (entry->name != NULL); entry++)
{ {
if (strcasecmp(str, entry->name) == 0) if (strcasecmp(str, entry->name) == 0)
@ -197,14 +197,14 @@ static const LookupEntry modIndexNames[] = {
}; };
bool bool
LookupModIndex(struct xkb_context *context, const void *priv, xkb_atom_t field, LookupModIndex(struct xkb_ctx *ctx, const void *priv, xkb_atom_t field,
unsigned type, ExprResult *val_rtrn) unsigned type, ExprResult *val_rtrn)
{ {
return SimpleLookup(context, modIndexNames, field, type, val_rtrn); return SimpleLookup(ctx, modIndexNames, field, type, val_rtrn);
} }
bool bool
LookupModMask(struct xkb_context *context, const void *priv, xkb_atom_t field, LookupModMask(struct xkb_ctx *ctx, const void *priv, xkb_atom_t field,
unsigned type, ExprResult *val_rtrn) unsigned type, ExprResult *val_rtrn)
{ {
const char *str; const char *str;
@ -212,14 +212,14 @@ LookupModMask(struct xkb_context *context, const void *priv, xkb_atom_t field,
if (type != TypeInt) if (type != TypeInt)
return false; return false;
str = xkb_atom_text(context, field); str = xkb_atom_text(ctx, field);
if (str == NULL) if (str == NULL)
return false; return false;
if (strcasecmp(str, "all") == 0) if (strcasecmp(str, "all") == 0)
val_rtrn->uval = 0xff; val_rtrn->uval = 0xff;
else if (strcasecmp(str, "none") == 0) else if (strcasecmp(str, "none") == 0)
val_rtrn->uval = 0; val_rtrn->uval = 0;
else if (LookupModIndex(context, priv, field, type, val_rtrn)) else if (LookupModIndex(ctx, priv, field, type, val_rtrn))
val_rtrn->uval = (1 << val_rtrn->uval); val_rtrn->uval = (1 << val_rtrn->uval);
else else
ret = false; ret = false;
@ -227,7 +227,7 @@ LookupModMask(struct xkb_context *context, const void *priv, xkb_atom_t field,
} }
int int
ExprResolveBoolean(struct xkb_context *context, ExprDef *expr, ExprResolveBoolean(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn) ExprResult *val_rtrn)
{ {
int ok = 0; int ok = 0;
@ -246,7 +246,7 @@ ExprResolveBoolean(struct xkb_context *context, ExprDef *expr,
val_rtrn->ival = expr->value.ival; val_rtrn->ival = expr->value.ival;
return true; return true;
case ExprIdent: case ExprIdent:
bogus = xkb_atom_text(context, expr->value.str); bogus = xkb_atom_text(ctx, expr->value.str);
if (bogus) if (bogus)
{ {
if ((strcasecmp(bogus, "true") == 0) || if ((strcasecmp(bogus, "true") == 0) ||
@ -265,16 +265,16 @@ ExprResolveBoolean(struct xkb_context *context, ExprDef *expr,
} }
} }
ERROR("Identifier \"%s\" of type int is unknown\n", ERROR("Identifier \"%s\" of type int is unknown\n",
xkb_atom_text(context, expr->value.str)); xkb_atom_text(ctx, expr->value.str));
return false; return false;
case ExprFieldRef: case ExprFieldRef:
ERROR("Default \"%s.%s\" of type boolean is unknown\n", ERROR("Default \"%s.%s\" of type boolean is unknown\n",
xkb_atom_text(context, expr->value.field.element), xkb_atom_text(ctx, expr->value.field.element),
xkb_atom_text(context, expr->value.field.field)); xkb_atom_text(ctx, expr->value.field.field));
return false; return false;
case OpInvert: case OpInvert:
case OpNot: case OpNot:
ok = ExprResolveBoolean(context, expr, val_rtrn); ok = ExprResolveBoolean(ctx, expr, val_rtrn);
if (ok) if (ok)
val_rtrn->uval = !val_rtrn->uval; val_rtrn->uval = !val_rtrn->uval;
return ok; return ok;
@ -309,7 +309,7 @@ ExprResolveBoolean(struct xkb_context *context, ExprDef *expr,
} }
int int
ExprResolveFloat(struct xkb_context *context, ExprDef *expr, ExprResolveFloat(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn) ExprResult *val_rtrn)
{ {
int ok = 0; int ok = 0;
@ -322,7 +322,7 @@ ExprResolveFloat(struct xkb_context *context, ExprDef *expr,
if (expr->type == TypeString) if (expr->type == TypeString)
{ {
const char *str; const char *str;
str = xkb_atom_text(context, expr->value.str); str = xkb_atom_text(ctx, expr->value.str);
if ((str != NULL) && (strlen(str) == 1)) if ((str != NULL) && (strlen(str) == 1))
{ {
val_rtrn->uval = str[0] * XkbGeomPtsPerMM; val_rtrn->uval = str[0] * XkbGeomPtsPerMM;
@ -341,12 +341,12 @@ ExprResolveFloat(struct xkb_context *context, ExprDef *expr,
return true; return true;
case ExprIdent: case ExprIdent:
ERROR("Numeric identifier \"%s\" unknown\n", ERROR("Numeric identifier \"%s\" unknown\n",
xkb_atom_text(context, expr->value.str)); xkb_atom_text(ctx, expr->value.str));
return ok; return ok;
case ExprFieldRef: case ExprFieldRef:
ERROR("Numeric default \"%s.%s\" unknown\n", ERROR("Numeric default \"%s.%s\" unknown\n",
xkb_atom_text(context, expr->value.field.element), xkb_atom_text(ctx, expr->value.field.element),
xkb_atom_text(context, expr->value.field.field)); xkb_atom_text(ctx, expr->value.field.field));
return false; return false;
case OpAdd: case OpAdd:
case OpSubtract: case OpSubtract:
@ -354,8 +354,8 @@ ExprResolveFloat(struct xkb_context *context, ExprDef *expr,
case OpDivide: case OpDivide:
left = expr->value.binary.left; left = expr->value.binary.left;
right = expr->value.binary.right; right = expr->value.binary.right;
if (ExprResolveFloat(context, left, &leftRtrn) && if (ExprResolveFloat(ctx, left, &leftRtrn) &&
ExprResolveFloat(context, right, &rightRtrn)) ExprResolveFloat(ctx, right, &rightRtrn))
{ {
switch (expr->op) switch (expr->op)
{ {
@ -384,7 +384,7 @@ ExprResolveFloat(struct xkb_context *context, ExprDef *expr,
case OpInvert: case OpInvert:
case OpNegate: case OpNegate:
left = expr->value.child; left = expr->value.child;
if (ExprResolveFloat(context, left, &leftRtrn)) if (ExprResolveFloat(ctx, left, &leftRtrn))
{ {
if (expr->op == OpNegate) if (expr->op == OpNegate)
val_rtrn->ival = -leftRtrn.ival; val_rtrn->ival = -leftRtrn.ival;
@ -395,7 +395,7 @@ ExprResolveFloat(struct xkb_context *context, ExprDef *expr,
return false; return false;
case OpUnaryPlus: case OpUnaryPlus:
left = expr->value.child; left = expr->value.child;
return ExprResolveFloat(context, left, val_rtrn); return ExprResolveFloat(ctx, left, val_rtrn);
default: default:
WSGO("Unknown operator %d in ResolveFloat\n", expr->op); WSGO("Unknown operator %d in ResolveFloat\n", expr->op);
break; break;
@ -404,7 +404,7 @@ ExprResolveFloat(struct xkb_context *context, ExprDef *expr,
} }
int int
ExprResolveKeyCode(struct xkb_context *context, ExprDef *expr, ExprResolveKeyCode(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn) ExprResult *val_rtrn)
{ {
ExprResult leftRtrn, rightRtrn; ExprResult leftRtrn, rightRtrn;
@ -428,8 +428,8 @@ ExprResolveKeyCode(struct xkb_context *context, ExprDef *expr,
case OpDivide: case OpDivide:
left = expr->value.binary.left; left = expr->value.binary.left;
right = expr->value.binary.right; right = expr->value.binary.right;
if (ExprResolveKeyCode(context, left, &leftRtrn) && if (ExprResolveKeyCode(ctx, left, &leftRtrn) &&
ExprResolveKeyCode(context, right, &rightRtrn)) ExprResolveKeyCode(ctx, right, &rightRtrn))
{ {
switch (expr->op) switch (expr->op)
{ {
@ -451,7 +451,7 @@ ExprResolveKeyCode(struct xkb_context *context, ExprDef *expr,
return false; return false;
case OpNegate: case OpNegate:
left = expr->value.child; left = expr->value.child;
if (ExprResolveKeyCode(context, left, &leftRtrn)) if (ExprResolveKeyCode(ctx, left, &leftRtrn))
{ {
val_rtrn->uval = ~leftRtrn.uval; val_rtrn->uval = ~leftRtrn.uval;
return true; return true;
@ -459,7 +459,7 @@ ExprResolveKeyCode(struct xkb_context *context, ExprDef *expr,
return false; return false;
case OpUnaryPlus: case OpUnaryPlus:
left = expr->value.child; left = expr->value.child;
return ExprResolveKeyCode(context, left, val_rtrn); return ExprResolveKeyCode(ctx, left, val_rtrn);
default: default:
WSGO("Unknown operator %d in ResolveKeyCode\n", expr->op); WSGO("Unknown operator %d in ResolveKeyCode\n", expr->op);
break; break;
@ -470,9 +470,9 @@ ExprResolveKeyCode(struct xkb_context *context, ExprDef *expr,
/** /**
* This function returns ... something. It's a bit of a guess, really. * This function returns ... something. It's a bit of a guess, really.
* *
* If a string is given in value context, its first character will be * If a string is given in value ctx, its first character will be
* returned in uval. If an integer is given in value context, it will be * returned in uval. If an integer is given in value ctx, it will be
* returned in ival. If a float is given in value context, it will be * returned in ival. If a float is given in value ctx, it will be
* returned as millimetres (rather than points) in ival. * returned as millimetres (rather than points) in ival.
* *
* If an ident or field reference is given, the lookup function (if given) * If an ident or field reference is given, the lookup function (if given)
@ -482,7 +482,7 @@ ExprResolveKeyCode(struct xkb_context *context, ExprDef *expr,
* Cool. * Cool.
*/ */
static int static int
ExprResolveIntegerLookup(struct xkb_context *context, ExprDef *expr, ExprResolveIntegerLookup(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn, IdentLookupFunc lookup, ExprResult *val_rtrn, IdentLookupFunc lookup,
const void *lookupPriv) const void *lookupPriv)
{ {
@ -496,7 +496,7 @@ ExprResolveIntegerLookup(struct xkb_context *context, ExprDef *expr,
if (expr->type == TypeString) if (expr->type == TypeString)
{ {
const char *str; const char *str;
str = xkb_atom_text(context, expr->value.str); str = xkb_atom_text(ctx, expr->value.str);
if (str != NULL) if (str != NULL)
switch (strlen(str)) switch (strlen(str))
{ {
@ -521,16 +521,16 @@ ExprResolveIntegerLookup(struct xkb_context *context, ExprDef *expr,
return true; return true;
case ExprIdent: case ExprIdent:
if (lookup) if (lookup)
ok = lookup(context, lookupPriv, expr->value.str, ok = lookup(ctx, lookupPriv, expr->value.str,
TypeInt, val_rtrn); TypeInt, val_rtrn);
if (!ok) if (!ok)
ERROR("Identifier \"%s\" of type int is unknown\n", ERROR("Identifier \"%s\" of type int is unknown\n",
xkb_atom_text(context, expr->value.str)); xkb_atom_text(ctx, expr->value.str));
return ok; return ok;
case ExprFieldRef: case ExprFieldRef:
ERROR("Default \"%s.%s\" of type int is unknown\n", ERROR("Default \"%s.%s\" of type int is unknown\n",
xkb_atom_text(context, expr->value.field.element), xkb_atom_text(ctx, expr->value.field.element),
xkb_atom_text(context, expr->value.field.field)); xkb_atom_text(ctx, expr->value.field.field));
return false; return false;
case OpAdd: case OpAdd:
case OpSubtract: case OpSubtract:
@ -538,8 +538,8 @@ ExprResolveIntegerLookup(struct xkb_context *context, ExprDef *expr,
case OpDivide: case OpDivide:
left = expr->value.binary.left; left = expr->value.binary.left;
right = expr->value.binary.right; right = expr->value.binary.right;
if (ExprResolveIntegerLookup(context, left, &leftRtrn, lookup, lookupPriv) && if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup, lookupPriv) &&
ExprResolveIntegerLookup(context, right, &rightRtrn, lookup, lookupPriv)) ExprResolveIntegerLookup(ctx, right, &rightRtrn, lookup, lookupPriv))
{ {
switch (expr->op) switch (expr->op)
{ {
@ -568,7 +568,7 @@ ExprResolveIntegerLookup(struct xkb_context *context, ExprDef *expr,
case OpInvert: case OpInvert:
case OpNegate: case OpNegate:
left = expr->value.child; left = expr->value.child;
if (ExprResolveIntegerLookup(context, left, &leftRtrn, lookup, if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup,
lookupPriv)) lookupPriv))
{ {
if (expr->op == OpNegate) if (expr->op == OpNegate)
@ -580,7 +580,7 @@ ExprResolveIntegerLookup(struct xkb_context *context, ExprDef *expr,
return false; return false;
case OpUnaryPlus: case OpUnaryPlus:
left = expr->value.child; left = expr->value.child;
return ExprResolveIntegerLookup(context, left, val_rtrn, lookup, return ExprResolveIntegerLookup(ctx, left, val_rtrn, lookup,
lookupPriv); lookupPriv);
default: default:
WSGO("Unknown operator %d in ResolveInteger\n", expr->op); WSGO("Unknown operator %d in ResolveInteger\n", expr->op);
@ -590,14 +590,14 @@ ExprResolveIntegerLookup(struct xkb_context *context, ExprDef *expr,
} }
int int
ExprResolveInteger(struct xkb_context *context, ExprDef *expr, ExprResolveInteger(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn) ExprResult *val_rtrn)
{ {
return ExprResolveIntegerLookup(context, expr, val_rtrn, NULL, NULL); return ExprResolveIntegerLookup(ctx, expr, val_rtrn, NULL, NULL);
} }
int int
ExprResolveGroup(struct xkb_context *context, ExprDef *expr, ExprResolveGroup(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn) ExprResult *val_rtrn)
{ {
int ret; int ret;
@ -613,7 +613,7 @@ ExprResolveGroup(struct xkb_context *context, ExprDef *expr,
{ NULL, 0 } { NULL, 0 }
}; };
ret = ExprResolveIntegerLookup(context, expr, val_rtrn, SimpleLookup, ret = ExprResolveIntegerLookup(ctx, expr, val_rtrn, SimpleLookup,
group_names); group_names);
if (ret == false) if (ret == false)
return ret; return ret;
@ -628,7 +628,7 @@ ExprResolveGroup(struct xkb_context *context, ExprDef *expr,
} }
int int
ExprResolveLevel(struct xkb_context *context, ExprDef *expr, ExprResolveLevel(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn) ExprResult *val_rtrn)
{ {
int ret; int ret;
@ -644,7 +644,7 @@ ExprResolveLevel(struct xkb_context *context, ExprDef *expr,
{ NULL, 0 } { NULL, 0 }
}; };
ret = ExprResolveIntegerLookup(context, expr, val_rtrn, SimpleLookup, ret = ExprResolveIntegerLookup(ctx, expr, val_rtrn, SimpleLookup,
level_names); level_names);
if (ret == false) if (ret == false)
return ret; return ret;
@ -659,7 +659,7 @@ ExprResolveLevel(struct xkb_context *context, ExprDef *expr,
} }
int int
ExprResolveButton(struct xkb_context *context, ExprDef *expr, ExprResolveButton(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn) ExprResult *val_rtrn)
{ {
static const LookupEntry button_names[] = { static const LookupEntry button_names[] = {
@ -672,12 +672,12 @@ ExprResolveButton(struct xkb_context *context, ExprDef *expr,
{ NULL, 0 } { NULL, 0 }
}; };
return ExprResolveIntegerLookup(context, expr, val_rtrn, SimpleLookup, return ExprResolveIntegerLookup(ctx, expr, val_rtrn, SimpleLookup,
button_names); button_names);
} }
int int
ExprResolveString(struct xkb_context *context, ExprDef *expr, ExprResolveString(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn) ExprResult *val_rtrn)
{ {
ExprResult leftRtrn, rightRtrn; ExprResult leftRtrn, rightRtrn;
@ -694,24 +694,24 @@ ExprResolveString(struct xkb_context *context, ExprDef *expr,
exprTypeText(expr->type)); exprTypeText(expr->type));
return false; return false;
} }
val_rtrn->str = xkb_atom_strdup(context, expr->value.str); val_rtrn->str = xkb_atom_strdup(ctx, expr->value.str);
if (val_rtrn->str == NULL) if (val_rtrn->str == NULL)
val_rtrn->str = strdup(""); val_rtrn->str = strdup("");
return true; return true;
case ExprIdent: case ExprIdent:
ERROR("Identifier \"%s\" of type string not found\n", ERROR("Identifier \"%s\" of type string not found\n",
xkb_atom_text(context, expr->value.str)); xkb_atom_text(ctx, expr->value.str));
return false; return false;
case ExprFieldRef: case ExprFieldRef:
ERROR("Default \"%s.%s\" of type string not found\n", ERROR("Default \"%s.%s\" of type string not found\n",
xkb_atom_text(context, expr->value.field.element), xkb_atom_text(ctx, expr->value.field.element),
xkb_atom_text(context, expr->value.field.field)); xkb_atom_text(ctx, expr->value.field.field));
return false; return false;
case OpAdd: case OpAdd:
left = expr->value.binary.left; left = expr->value.binary.left;
right = expr->value.binary.right; right = expr->value.binary.right;
if (ExprResolveString(context, left, &leftRtrn) && if (ExprResolveString(ctx, left, &leftRtrn) &&
ExprResolveString(context, right, &rightRtrn)) ExprResolveString(ctx, right, &rightRtrn))
{ {
int len; int len;
char *new; char *new;
@ -762,7 +762,7 @@ ExprResolveString(struct xkb_context *context, ExprDef *expr,
} }
int int
ExprResolveKeyName(struct xkb_context *context, ExprDef *expr, ExprResolveKeyName(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn) ExprResult *val_rtrn)
{ {
const char *bogus = NULL; const char *bogus = NULL;
@ -780,12 +780,12 @@ ExprResolveKeyName(struct xkb_context *context, ExprDef *expr,
return true; return true;
case ExprIdent: case ExprIdent:
ERROR("Identifier \"%s\" of type string not found\n", ERROR("Identifier \"%s\" of type string not found\n",
xkb_atom_text(context, expr->value.str)); xkb_atom_text(ctx, expr->value.str));
return false; return false;
case ExprFieldRef: case ExprFieldRef:
ERROR("Default \"%s.%s\" of type key name not found\n", ERROR("Default \"%s.%s\" of type key name not found\n",
xkb_atom_text(context, expr->value.field.element), xkb_atom_text(ctx, expr->value.field.element),
xkb_atom_text(context, expr->value.field.field)); xkb_atom_text(ctx, expr->value.field.field));
return false; return false;
case OpAdd: case OpAdd:
if (bogus == NULL) if (bogus == NULL)
@ -826,7 +826,7 @@ ExprResolveKeyName(struct xkb_context *context, ExprDef *expr,
/***====================================================================***/ /***====================================================================***/
int int
ExprResolveEnum(struct xkb_context *context, ExprDef *expr, ExprResolveEnum(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn, const LookupEntry *values) ExprResult *val_rtrn, const LookupEntry *values)
{ {
if (expr->op != ExprIdent) if (expr->op != ExprIdent)
@ -835,11 +835,11 @@ ExprResolveEnum(struct xkb_context *context, ExprDef *expr,
exprOpText(expr->op)); exprOpText(expr->op));
return false; return false;
} }
if (!SimpleLookup(context, values, expr->value.str, TypeInt, val_rtrn)) if (!SimpleLookup(ctx, values, expr->value.str, TypeInt, val_rtrn))
{ {
int nOut = 0; int nOut = 0;
ERROR("Illegal identifier %s (expected one of: ", ERROR("Illegal identifier %s (expected one of: ",
xkb_atom_text(context, expr->value.str)); xkb_atom_text(ctx, expr->value.str));
while (values && values->name) while (values && values->name)
{ {
if (nOut != 0) if (nOut != 0)
@ -856,7 +856,7 @@ ExprResolveEnum(struct xkb_context *context, ExprDef *expr,
} }
static int static int
ExprResolveMaskLookup(struct xkb_context *context, ExprDef *expr, ExprResolveMaskLookup(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn, IdentLookupFunc lookup, ExprResult *val_rtrn, IdentLookupFunc lookup,
const void *lookupPriv) const void *lookupPriv)
{ {
@ -878,15 +878,15 @@ ExprResolveMaskLookup(struct xkb_context *context, ExprDef *expr,
val_rtrn->ival = expr->value.ival; val_rtrn->ival = expr->value.ival;
return true; return true;
case ExprIdent: case ExprIdent:
ok = lookup(context, lookupPriv, expr->value.str, TypeInt, val_rtrn); ok = lookup(ctx, lookupPriv, expr->value.str, TypeInt, val_rtrn);
if (!ok) if (!ok)
ERROR("Identifier \"%s\" of type int is unknown\n", ERROR("Identifier \"%s\" of type int is unknown\n",
xkb_atom_text(context, expr->value.str)); xkb_atom_text(ctx, expr->value.str));
return ok; return ok;
case ExprFieldRef: case ExprFieldRef:
ERROR("Default \"%s.%s\" of type int is unknown\n", ERROR("Default \"%s.%s\" of type int is unknown\n",
xkb_atom_text(context, expr->value.field.element), xkb_atom_text(ctx, expr->value.field.element),
xkb_atom_text(context, expr->value.field.field)); xkb_atom_text(ctx, expr->value.field.field));
return false; return false;
case ExprArrayRef: case ExprArrayRef:
bogus = "array reference"; bogus = "array reference";
@ -902,8 +902,8 @@ ExprResolveMaskLookup(struct xkb_context *context, ExprDef *expr,
case OpDivide: case OpDivide:
left = expr->value.binary.left; left = expr->value.binary.left;
right = expr->value.binary.right; right = expr->value.binary.right;
if (ExprResolveMaskLookup(context, left, &leftRtrn, lookup, lookupPriv) && if (ExprResolveMaskLookup(ctx, left, &leftRtrn, lookup, lookupPriv) &&
ExprResolveMaskLookup(context, right, &rightRtrn, lookup, lookupPriv)) ExprResolveMaskLookup(ctx, right, &rightRtrn, lookup, lookupPriv))
{ {
switch (expr->op) switch (expr->op)
{ {
@ -928,7 +928,7 @@ ExprResolveMaskLookup(struct xkb_context *context, ExprDef *expr,
break; break;
case OpInvert: case OpInvert:
left = expr->value.child; left = expr->value.child;
if (ExprResolveIntegerLookup(context, left, &leftRtrn, lookup, if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup,
lookupPriv)) lookupPriv))
{ {
val_rtrn->ival = ~leftRtrn.ival; val_rtrn->ival = ~leftRtrn.ival;
@ -939,7 +939,7 @@ ExprResolveMaskLookup(struct xkb_context *context, ExprDef *expr,
case OpNegate: case OpNegate:
case OpNot: case OpNot:
left = expr->value.child; left = expr->value.child;
if (ExprResolveIntegerLookup(context, left, &leftRtrn, lookup, if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup,
lookupPriv)) lookupPriv))
{ {
ERROR("The %s operator cannot be used with a mask\n", ERROR("The %s operator cannot be used with a mask\n",
@ -954,29 +954,29 @@ ExprResolveMaskLookup(struct xkb_context *context, ExprDef *expr,
} }
int int
ExprResolveMask(struct xkb_context *context, ExprDef *expr, ExprResolveMask(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn, const LookupEntry *values) ExprResult *val_rtrn, const LookupEntry *values)
{ {
return ExprResolveMaskLookup(context, expr, val_rtrn, SimpleLookup, values); return ExprResolveMaskLookup(ctx, expr, val_rtrn, SimpleLookup, values);
} }
int int
ExprResolveModMask(struct xkb_context *context, ExprDef *expr, ExprResolveModMask(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn) ExprResult *val_rtrn)
{ {
return ExprResolveMaskLookup(context, expr, val_rtrn, LookupModMask, NULL); return ExprResolveMaskLookup(ctx, expr, val_rtrn, LookupModMask, NULL);
} }
int int
ExprResolveVModMask(ExprDef *expr, ExprResult *val_rtrn, ExprResolveVModMask(ExprDef *expr, ExprResult *val_rtrn,
struct xkb_keymap *keymap) struct xkb_keymap *keymap)
{ {
return ExprResolveMaskLookup(keymap->context, expr, val_rtrn, return ExprResolveMaskLookup(keymap->ctx, expr, val_rtrn, LookupVModMask,
LookupVModMask, keymap); keymap);
} }
int int
ExprResolveKeySym(struct xkb_context *context, ExprDef *expr, ExprResolveKeySym(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn) ExprResult *val_rtrn)
{ {
int ok = 0; int ok = 0;
@ -985,7 +985,7 @@ ExprResolveKeySym(struct xkb_context *context, ExprDef *expr,
if (expr->op == ExprIdent) if (expr->op == ExprIdent)
{ {
const char *str; const char *str;
str = xkb_atom_text(context, expr->value.str); str = xkb_atom_text(ctx, expr->value.str);
if (str) { if (str) {
sym = xkb_keysym_from_name(str); sym = xkb_keysym_from_name(str);
if (sym != XKB_KEYSYM_NO_SYMBOL) { if (sym != XKB_KEYSYM_NO_SYMBOL) {
@ -994,7 +994,7 @@ ExprResolveKeySym(struct xkb_context *context, ExprDef *expr,
} }
} }
} }
ok = ExprResolveInteger(context, expr, val_rtrn); ok = ExprResolveInteger(ctx, expr, val_rtrn);
if ((ok) && (val_rtrn->uval < 10)) if ((ok) && (val_rtrn->uval < 10))
val_rtrn->uval += '0'; val_rtrn->uval += '0';
return ok; return ok;

View File

@ -53,19 +53,19 @@ extern const char *
exprOpText(unsigned type); exprOpText(unsigned type);
extern bool extern bool
LookupModMask(struct xkb_context *context, const void *priv, xkb_atom_t field, LookupModMask(struct xkb_ctx *ctx, const void *priv, xkb_atom_t field,
unsigned type, ExprResult *val_rtrn); unsigned type, ExprResult *val_rtrn);
extern bool extern bool
LookupVModMask(struct xkb_context *context, const void *priv, xkb_atom_t field, LookupVModMask(struct xkb_ctx *ctx, const void *priv, xkb_atom_t field,
unsigned type, ExprResult *val_rtrn); unsigned type, ExprResult *val_rtrn);
extern bool extern bool
LookupModIndex(struct xkb_context *context, const void *priv, xkb_atom_t field, LookupModIndex(struct xkb_ctx *ctx, const void *priv, xkb_atom_t field,
unsigned type, ExprResult *val_rtrn); unsigned type, ExprResult *val_rtrn);
extern int extern int
ExprResolveModMask(struct xkb_context *context, ExprDef *expr, ExprResolveModMask(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn); ExprResult *val_rtrn);
extern int extern int
@ -73,51 +73,51 @@ ExprResolveVModMask(ExprDef *expr, ExprResult *val_rtrn,
struct xkb_keymap *keymap); struct xkb_keymap *keymap);
extern int extern int
ExprResolveBoolean(struct xkb_context *context, ExprDef *expr, ExprResolveBoolean(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn); ExprResult *val_rtrn);
extern int extern int
ExprResolveKeyCode(struct xkb_context *context, ExprDef *expr, ExprResolveKeyCode(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn); ExprResult *val_rtrn);
extern int extern int
ExprResolveInteger(struct xkb_context *context, ExprDef *expr, ExprResolveInteger(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn); ExprResult *val_rtrn);
extern int extern int
ExprResolveLevel(struct xkb_context *context, ExprDef *expr, ExprResolveLevel(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn); ExprResult *val_rtrn);
extern int extern int
ExprResolveGroup(struct xkb_context *context, ExprDef *expr, ExprResolveGroup(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn); ExprResult *val_rtrn);
extern int extern int
ExprResolveButton(struct xkb_context *context, ExprDef *expr, ExprResolveButton(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn); ExprResult *val_rtrn);
extern int extern int
ExprResolveFloat(struct xkb_context *context, ExprDef *expr, ExprResolveFloat(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn); ExprResult *val_rtrn);
extern int extern int
ExprResolveString(struct xkb_context *context, ExprDef *expr, ExprResolveString(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn); ExprResult *val_rtrn);
extern int extern int
ExprResolveKeyName(struct xkb_context *context, ExprDef *expr, ExprResolveKeyName(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn); ExprResult *val_rtrn);
extern int extern int
ExprResolveEnum(struct xkb_context *context, ExprDef *expr, ExprResolveEnum(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn, const LookupEntry *values); ExprResult *val_rtrn, const LookupEntry *values);
extern int extern int
ExprResolveMask(struct xkb_context *context, ExprDef *expr, ExprResolveMask(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn, const LookupEntry *values); ExprResult *val_rtrn, const LookupEntry *values);
extern int extern int
ExprResolveKeySym(struct xkb_context *context, ExprDef *expr, ExprResolveKeySym(struct xkb_ctx *ctx, ExprDef *expr,
ExprResult *val_rtrn); ExprResult *val_rtrn);
#endif /* EXPR_H */ #endif /* EXPR_H */

View File

@ -32,17 +32,17 @@
#define ReportIndicatorBadType(keymap, l, f, w) \ #define ReportIndicatorBadType(keymap, l, f, w) \
ReportBadType("indicator map", (f), \ ReportBadType("indicator map", (f), \
xkb_atom_text((keymap)->context, (l)->name), (w)) xkb_atom_text((keymap)->ctx, (l)->name), (w))
#define ReportIndicatorNotArray(keymap, l, f) \ #define ReportIndicatorNotArray(keymap, l, f) \
ReportNotArray("indicator map", (f), \ ReportNotArray("indicator map", (f), \
xkb_atom_text((keymap)->context, (l)->name)) xkb_atom_text((keymap)->ctx, (l)->name))
/***====================================================================***/ /***====================================================================***/
void void
ClearIndicatorMapInfo(struct xkb_context *context, LEDInfo * info) ClearIndicatorMapInfo(struct xkb_ctx *ctx, LEDInfo * info)
{ {
info->name = xkb_atom_intern(context, "default"); info->name = xkb_atom_intern(ctx, "default");
info->indicator = _LED_NotBound; info->indicator = _LED_NotBound;
info->flags = info->which_mods = info->real_mods = 0; info->flags = info->which_mods = info->real_mods = 0;
info->vmods = 0; info->vmods = 0;
@ -78,7 +78,7 @@ AddIndicatorMap(struct xkb_keymap *keymap, LEDInfo *oldLEDs, LEDInfo *new)
&& (warningLevel > 0)) || (warningLevel > 9)) && (warningLevel > 0)) || (warningLevel > 9))
{ {
WARN("Map for indicator %s redefined\n", WARN("Map for indicator %s redefined\n",
xkb_atom_text(keymap->context, old->name)); xkb_atom_text(keymap->ctx, old->name));
ACTION("Earlier definition ignored\n"); ACTION("Earlier definition ignored\n");
} }
*old = *new; *old = *new;
@ -130,7 +130,7 @@ AddIndicatorMap(struct xkb_keymap *keymap, LEDInfo *oldLEDs, LEDInfo *new)
if (collide) if (collide)
{ {
WARN("Map for indicator %s redefined\n", WARN("Map for indicator %s redefined\n",
xkb_atom_text(keymap->context, old->name)); xkb_atom_text(keymap->ctx, old->name));
ACTION("Using %s definition for duplicate fields\n", ACTION("Using %s definition for duplicate fields\n",
(new->defs.merge == MergeAugment ? "first" : "last")); (new->defs.merge == MergeAugment ? "first" : "last"));
} }
@ -145,7 +145,7 @@ AddIndicatorMap(struct xkb_keymap *keymap, LEDInfo *oldLEDs, LEDInfo *new)
{ {
WSGO("Couldn't allocate indicator map\n"); WSGO("Couldn't allocate indicator map\n");
ACTION("Map for indicator %s not compiled\n", ACTION("Map for indicator %s not compiled\n",
xkb_atom_text(keymap->context, new->name)); xkb_atom_text(keymap->ctx, new->name));
return NULL; return NULL;
} }
*old = *new; *old = *new;
@ -215,7 +215,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
{ {
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field); return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveMask(keymap->context, value, &rtrn, groupNames)) if (!ExprResolveMask(keymap->ctx, value, &rtrn, groupNames))
return ReportIndicatorBadType(keymap, led, field, "group mask"); return ReportIndicatorBadType(keymap, led, field, "group mask");
led->groups = rtrn.uval; led->groups = rtrn.uval;
led->defs.defined |= _LED_Groups; led->defs.defined |= _LED_Groups;
@ -225,7 +225,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
{ {
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field); return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveMask(keymap->context, value, &rtrn, ctrlNames)) if (!ExprResolveMask(keymap->ctx, value, &rtrn, ctrlNames))
return ReportIndicatorBadType(keymap, led, field, return ReportIndicatorBadType(keymap, led, field,
"controls mask"); "controls mask");
led->ctrls = rtrn.uval; led->ctrls = rtrn.uval;
@ -235,7 +235,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
{ {
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field); return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveBoolean(keymap->context, value, &rtrn)) if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
return ReportIndicatorBadType(keymap, led, field, "boolean"); return ReportIndicatorBadType(keymap, led, field, "boolean");
if (rtrn.uval) if (rtrn.uval)
led->flags &= ~XkbIM_NoExplicit; led->flags &= ~XkbIM_NoExplicit;
@ -248,7 +248,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
{ {
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field); return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveMask(keymap->context, value, &rtrn, modComponentNames)) if (!ExprResolveMask(keymap->ctx, value, &rtrn, modComponentNames))
{ {
return ReportIndicatorBadType(keymap, led, field, return ReportIndicatorBadType(keymap, led, field,
"mask of modifier state components"); "mask of modifier state components");
@ -259,7 +259,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
{ {
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field); return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveMask(keymap->context, value, &rtrn, groupComponentNames)) if (!ExprResolveMask(keymap->ctx, value, &rtrn, groupComponentNames))
{ {
return ReportIndicatorBadType(keymap, led, field, return ReportIndicatorBadType(keymap, led, field,
"mask of group state components"); "mask of group state components");
@ -275,7 +275,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
{ {
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field); return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveBoolean(keymap->context, value, &rtrn)) if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
return ReportIndicatorBadType(keymap, led, field, "boolean"); return ReportIndicatorBadType(keymap, led, field, "boolean");
if (rtrn.uval) if (rtrn.uval)
led->flags |= XkbIM_LEDDrivesKB; led->flags |= XkbIM_LEDDrivesKB;
@ -287,7 +287,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
{ {
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field); return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveInteger(keymap->context, value, &rtrn)) if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return ReportIndicatorBadType(keymap, led, field, return ReportIndicatorBadType(keymap, led, field,
"indicator index"); "indicator index");
if ((rtrn.uval < 1) || (rtrn.uval > 32)) if ((rtrn.uval < 1) || (rtrn.uval > 32))
@ -295,7 +295,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
ERROR("Illegal indicator index %d (range 1..%d)\n", ERROR("Illegal indicator index %d (range 1..%d)\n",
rtrn.uval, XkbNumIndicators); rtrn.uval, XkbNumIndicators);
ACTION("Index definition for %s indicator ignored\n", ACTION("Index definition for %s indicator ignored\n",
xkb_atom_text(keymap->context, led->name)); xkb_atom_text(keymap->ctx, led->name));
return false; return false;
} }
led->indicator = rtrn.uval; led->indicator = rtrn.uval;
@ -304,7 +304,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
else else
{ {
ERROR("Unknown field %s in map for %s indicator\n", field, ERROR("Unknown field %s in map for %s indicator\n", field,
xkb_atom_text(keymap->context, led->name)); xkb_atom_text(keymap->ctx, led->name));
ACTION("Definition ignored\n"); ACTION("Definition ignored\n");
ok = false; ok = false;
} }
@ -420,7 +420,7 @@ CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds,
{ {
free(UNCONSTIFY(keymap->names->indicators[led->indicator - 1])); free(UNCONSTIFY(keymap->names->indicators[led->indicator - 1]));
keymap->names->indicators[led->indicator-1] = keymap->names->indicators[led->indicator-1] =
xkb_atom_strdup(keymap->context, led->name); xkb_atom_strdup(keymap->ctx, led->name);
} }
free(led); free(led);
} }
@ -449,7 +449,7 @@ BindIndicators(struct xkb_keymap *keymap, bool force, LEDInfo *unbound,
{ {
if (keymap->names->indicators[i] && if (keymap->names->indicators[i] &&
strcmp(keymap->names->indicators[i], strcmp(keymap->names->indicators[i],
xkb_atom_text(keymap->context, led->name)) == 0) xkb_atom_text(keymap->ctx, led->name)) == 0)
{ {
led->indicator = i + 1; led->indicator = i + 1;
break; break;
@ -468,7 +468,7 @@ BindIndicators(struct xkb_keymap *keymap, bool force, LEDInfo *unbound,
if (keymap->names->indicators[i] == NULL) if (keymap->names->indicators[i] == NULL)
{ {
keymap->names->indicators[i] = keymap->names->indicators[i] =
xkb_atom_strdup(keymap->context, led->name); xkb_atom_strdup(keymap->ctx, led->name);
led->indicator = i + 1; led->indicator = i + 1;
break; break;
} }
@ -478,7 +478,7 @@ BindIndicators(struct xkb_keymap *keymap, bool force, LEDInfo *unbound,
ERROR("No unnamed indicators found\n"); ERROR("No unnamed indicators found\n");
ACTION ACTION
("Virtual indicator map \"%s\" not bound\n", ("Virtual indicator map \"%s\" not bound\n",
xkb_atom_text(keymap->context, led->name)); xkb_atom_text(keymap->ctx, led->name));
continue; continue;
} }
} }
@ -508,13 +508,13 @@ BindIndicators(struct xkb_keymap *keymap, bool force, LEDInfo *unbound,
{ {
if ((keymap->names != NULL) && if ((keymap->names != NULL) &&
(strcmp(keymap->names->indicators[led->indicator - 1], (strcmp(keymap->names->indicators[led->indicator - 1],
xkb_atom_text(keymap->context, led->name)) != 0)) xkb_atom_text(keymap->ctx, led->name)) != 0))
{ {
const char *old = keymap->names->indicators[led->indicator - 1]; const char *old = keymap->names->indicators[led->indicator - 1];
ERROR("Multiple names bound to indicator %d\n", ERROR("Multiple names bound to indicator %d\n",
(unsigned int) led->indicator); (unsigned int) led->indicator);
ACTION("Using %s, ignoring %s\n", old, ACTION("Using %s, ignoring %s\n", old,
xkb_atom_text(keymap->context, led->name)); xkb_atom_text(keymap->ctx, led->name));
led->indicator = _LED_NotBound; led->indicator = _LED_NotBound;
if (force) if (force)
{ {

View File

@ -54,7 +54,7 @@ typedef struct _LEDInfo
} LEDInfo; } LEDInfo;
extern void extern void
ClearIndicatorMapInfo(struct xkb_context *context, LEDInfo *info); ClearIndicatorMapInfo(struct xkb_ctx *ctx, LEDInfo *info);
extern LEDInfo * extern LEDInfo *

View File

@ -208,7 +208,7 @@ AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap,
|| (warningLevel > 9)) || (warningLevel > 9))
{ {
WARN("Multiple indicators named %s\n", WARN("Multiple indicators named %s\n",
xkb_atom_text(keymap->context, new->name)); xkb_atom_text(keymap->ctx, new->name));
if (old->ndx == new->ndx) if (old->ndx == new->ndx)
{ {
if (old->virtual != new->virtual) if (old->virtual != new->virtual)
@ -286,8 +286,8 @@ AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap,
ignoring = new->name; ignoring = new->name;
} }
ACTION("Using %s %s, ignoring %s %s\n", ACTION("Using %s %s, ignoring %s %s\n",
oldType, xkb_atom_text(keymap->context, using), oldType, xkb_atom_text(keymap->ctx, using),
newType, xkb_atom_text(keymap->context, ignoring)); newType, xkb_atom_text(keymap->ctx, ignoring));
} }
} }
if (replace) if (replace)
@ -565,8 +565,8 @@ HandleIncludeKeycodes(IncludeStmt *stmt, struct xkb_keymap *keymap,
info->explicitMax = XKB_KEYCODE_MAX; info->explicitMax = XKB_KEYCODE_MAX;
return (info->errorCount == 0); return (info->errorCount == 0);
} /* parse file, store returned info in the xkb struct */ } /* parse file, store returned info in the xkb struct */
else if (ProcessIncludeFile(keymap->context, stmt, XkmKeyNamesIndex, else if (ProcessIncludeFile(keymap->ctx, stmt, XkmKeyNamesIndex, &rtrn,
&rtrn, &newMerge)) &newMerge))
{ {
InitKeyNamesInfo(&included); InitKeyNamesInfo(&included);
HandleKeycodesFile(rtrn, keymap, MergeOverride, &included); HandleKeycodesFile(rtrn, keymap, MergeOverride, &included);
@ -598,8 +598,8 @@ HandleIncludeKeycodes(IncludeStmt *stmt, struct xkb_keymap *keymap,
MergeIncludedKeycodes(&included, keymap, info, next->merge); MergeIncludedKeycodes(&included, keymap, info, next->merge);
ClearKeyNamesInfo(info); ClearKeyNamesInfo(info);
} }
else if (ProcessIncludeFile(keymap->context, next, else if (ProcessIncludeFile(keymap->ctx, next, XkmKeyNamesIndex,
XkmKeyNamesIndex, &rtrn, &op)) &rtrn, &op))
{ {
InitKeyNamesInfo(&next_incl); InitKeyNamesInfo(&next_incl);
HandleKeycodesFile(rtrn, keymap, MergeOverride, &next_incl); HandleKeycodesFile(rtrn, keymap, MergeOverride, &next_incl);
@ -694,7 +694,7 @@ HandleKeyNameVar(VarDef *stmt, struct xkb_keymap *keymap, KeyNamesInfo *info)
goto err_out; goto err_out;
} }
if (ExprResolveKeyCode(keymap->context, stmt->value, &tmp) == 0) if (ExprResolveKeyCode(keymap->ctx, stmt->value, &tmp) == 0)
{ {
ACTION("Assignment to field %s ignored\n", field.str); ACTION("Assignment to field %s ignored\n", field.str);
goto err_out; goto err_out;
@ -771,14 +771,14 @@ HandleIndicatorNameDef(IndicatorNameDef *def, struct xkb_keymap *keymap,
} }
InitIndicatorNameInfo(&ii, info); InitIndicatorNameInfo(&ii, info);
ii.ndx = def->ndx; ii.ndx = def->ndx;
if (!ExprResolveString(keymap->context, def->name, &tmp)) if (!ExprResolveString(keymap->ctx, def->name, &tmp))
{ {
char buf[20]; char buf[20];
snprintf(buf, sizeof(buf), "%d", def->ndx); snprintf(buf, sizeof(buf), "%d", def->ndx);
info->errorCount++; info->errorCount++;
return ReportBadType("indicator", "name", buf, "string"); return ReportBadType("indicator", "name", buf, "string");
} }
ii.name = xkb_atom_intern(keymap->context, tmp.str); ii.name = xkb_atom_intern(keymap->ctx, tmp.str);
free(tmp.str); free(tmp.str);
ii.virtual = def->virtual; ii.virtual = def->virtual;
if (!AddIndicatorName(info, keymap, &ii)) if (!AddIndicatorName(info, keymap, &ii))
@ -913,7 +913,7 @@ CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap, unsigned merge)
for (ii = info.leds; ii; ii = (IndicatorNameInfo *)ii->defs.next) { for (ii = info.leds; ii; ii = (IndicatorNameInfo *)ii->defs.next) {
free(UNCONSTIFY(keymap->names->indicators[ii->ndx - 1])); free(UNCONSTIFY(keymap->names->indicators[ii->ndx - 1]));
keymap->names->indicators[ii->ndx - 1] = keymap->names->indicators[ii->ndx - 1] =
xkb_atom_strdup(keymap->context, ii->name); xkb_atom_strdup(keymap->ctx, ii->name);
} }
} }

View File

@ -33,7 +33,7 @@
* XkmKeyNamesIdx, etc.) * XkmKeyNamesIdx, etc.)
*/ */
struct xkb_keymap * struct xkb_keymap *
CompileKeymap(struct xkb_context *context, XkbFile *file) CompileKeymap(struct xkb_ctx *ctx, XkbFile *file)
{ {
unsigned have; unsigned have;
bool ok; bool ok;
@ -41,7 +41,7 @@ CompileKeymap(struct xkb_context *context, XkbFile *file)
unsigned mainType; unsigned mainType;
const char *mainName; const char *mainName;
LEDInfo *unbound = NULL, *next; LEDInfo *unbound = NULL, *next;
struct xkb_keymap *keymap = XkbcAllocKeyboard(context); struct xkb_keymap *keymap = XkbcAllocKeyboard(ctx);
struct { struct {
XkbFile *keycodes; XkbFile *keycodes;
XkbFile *types; XkbFile *types;

View File

@ -94,7 +94,7 @@ static xkb_atom_t tok_KEYPAD;
#define PreserveTxt(x, p) \ #define PreserveTxt(x, p) \
XkbcVModMaskText((x), (p)->preMods, (p)->preVMods) XkbcVModMaskText((x), (p)->preMods, (p)->preVMods)
#define TypeTxt(keymap, t) \ #define TypeTxt(keymap, t) \
xkb_atom_text((keymap)->context, (t)->name) xkb_atom_text((keymap)->ctx, (t)->name)
#define TypeMaskTxt(t, x) \ #define TypeMaskTxt(t, x) \
XkbcVModMaskText((x), (t)->mask, (t)->vmask) XkbcVModMaskText((x), (t)->mask, (t)->vmask)
@ -104,10 +104,10 @@ static void
InitKeyTypesInfo(KeyTypesInfo *info, struct xkb_keymap *keymap, InitKeyTypesInfo(KeyTypesInfo *info, struct xkb_keymap *keymap,
KeyTypesInfo *from) KeyTypesInfo *from)
{ {
tok_ONE_LEVEL = xkb_atom_intern(keymap->context, "ONE_LEVEL"); tok_ONE_LEVEL = xkb_atom_intern(keymap->ctx, "ONE_LEVEL");
tok_TWO_LEVEL = xkb_atom_intern(keymap->context, "TWO_LEVEL"); tok_TWO_LEVEL = xkb_atom_intern(keymap->ctx, "TWO_LEVEL");
tok_ALPHABETIC = xkb_atom_intern(keymap->context, "ALPHABETIC"); tok_ALPHABETIC = xkb_atom_intern(keymap->ctx, "ALPHABETIC");
tok_KEYPAD = xkb_atom_intern(keymap->context, "KEYPAD"); tok_KEYPAD = xkb_atom_intern(keymap->ctx, "KEYPAD");
info->name = strdup("default"); info->name = strdup("default");
info->errorCount = 0; info->errorCount = 0;
info->stdPresent = 0; info->stdPresent = 0;
@ -289,7 +289,7 @@ AddKeyType(struct xkb_keymap *keymap, KeyTypesInfo *info, KeyTypeInfo *new)
&& (warningLevel > 0)) || (warningLevel > 9)) && (warningLevel > 0)) || (warningLevel > 9))
{ {
WARN("Multiple definitions of the %s key type\n", WARN("Multiple definitions of the %s key type\n",
xkb_atom_text(keymap->context, new->name)); xkb_atom_text(keymap->ctx, new->name));
ACTION("Earlier definition ignored\n"); ACTION("Earlier definition ignored\n");
} }
FreeKeyTypeInfo(old); FreeKeyTypeInfo(old);
@ -305,7 +305,7 @@ AddKeyType(struct xkb_keymap *keymap, KeyTypesInfo *info, KeyTypeInfo *new)
if (report) if (report)
{ {
WARN("Multiple definitions of the %s key type\n", WARN("Multiple definitions of the %s key type\n",
xkb_atom_text(keymap->context, new->name)); xkb_atom_text(keymap->ctx, new->name));
ACTION("Later definition ignored\n"); ACTION("Later definition ignored\n");
} }
FreeKeyTypeInfo(new); FreeKeyTypeInfo(new);
@ -371,7 +371,7 @@ HandleIncludeKeyTypes(IncludeStmt *stmt, struct xkb_keymap *keymap,
included = *info; included = *info;
memset(info, 0, sizeof(KeyTypesInfo)); memset(info, 0, sizeof(KeyTypesInfo));
} }
else if (ProcessIncludeFile(keymap->context, stmt, XkmTypesIndex, &rtrn, else if (ProcessIncludeFile(keymap->ctx, stmt, XkmTypesIndex, &rtrn,
&newMerge)) &newMerge))
{ {
InitKeyTypesInfo(&included, keymap, info); InitKeyTypesInfo(&included, keymap, info);
@ -406,7 +406,7 @@ HandleIncludeKeyTypes(IncludeStmt *stmt, struct xkb_keymap *keymap,
MergeIncludedKeyTypes(&included, info, next->merge, keymap); MergeIncludedKeyTypes(&included, info, next->merge, keymap);
FreeKeyTypesInfo(info); FreeKeyTypesInfo(info);
} }
else if (ProcessIncludeFile(keymap->context, next, XkmTypesIndex, else if (ProcessIncludeFile(keymap->ctx, next, XkmTypesIndex,
&rtrn, &op)) &rtrn, &op))
{ {
InitKeyTypesInfo(&next_incl, keymap, &included); InitKeyTypesInfo(&next_incl, keymap, &included);
@ -659,7 +659,7 @@ SetMapEntry(KeyTypeInfo *type, struct xkb_keymap *keymap, ExprDef *arrayNdx,
entry.mods.real_mods &= type->mask; entry.mods.real_mods &= type->mask;
entry.mods.vmods &= type->vmask; entry.mods.vmods &= type->vmask;
} }
if (!ExprResolveLevel(keymap->context, value, &rtrn)) if (!ExprResolveLevel(keymap->ctx, value, &rtrn))
{ {
ERROR("Level specifications in a key type must be integer\n"); ERROR("Level specifications in a key type must be integer\n");
ACTION("Ignoring malformed level specification\n"); ACTION("Ignoring malformed level specification\n");
@ -761,8 +761,8 @@ AddLevelName(struct xkb_keymap *keymap, KeyTypeInfo *type,
if (warningLevel > 0) if (warningLevel > 0)
{ {
const char *old, *new; const char *old, *new;
old = xkb_atom_text(keymap->context, type->lvlNames[level]); old = xkb_atom_text(keymap->ctx, type->lvlNames[level]);
new = xkb_atom_text(keymap->context, name); new = xkb_atom_text(keymap->ctx, name);
WARN("Multiple names for level %d of key type %s\n", WARN("Multiple names for level %d of key type %s\n",
level + 1, TypeTxt(keymap, type)); level + 1, TypeTxt(keymap, type));
if (clobber) if (clobber)
@ -789,17 +789,17 @@ SetLevelName(KeyTypeInfo *type, struct xkb_keymap *keymap, ExprDef *arrayNdx,
if (arrayNdx == NULL) if (arrayNdx == NULL)
return ReportTypeShouldBeArray(keymap, type, "level name"); return ReportTypeShouldBeArray(keymap, type, "level name");
if (!ExprResolveLevel(keymap->context, arrayNdx, &rtrn)) if (!ExprResolveLevel(keymap->ctx, arrayNdx, &rtrn))
return ReportTypeBadType(keymap, type, "level name", "integer"); return ReportTypeBadType(keymap, type, "level name", "integer");
level = rtrn.ival - 1; level = rtrn.ival - 1;
if (!ExprResolveString(keymap->context, value, &rtrn)) if (!ExprResolveString(keymap->ctx, value, &rtrn))
{ {
ERROR("Non-string name for level %d in key type %s\n", level + 1, ERROR("Non-string name for level %d in key type %s\n", level + 1,
xkb_atom_text(keymap->context, type->name)); xkb_atom_text(keymap->ctx, type->name));
ACTION("Ignoring illegal level name definition\n"); ACTION("Ignoring illegal level name definition\n");
return false; return false;
} }
level_name = xkb_atom_intern(keymap->context, rtrn.str); level_name = xkb_atom_intern(keymap->ctx, rtrn.str);
free(rtrn.str); free(rtrn.str);
return AddLevelName(keymap, type, level, level_name, true); return AddLevelName(keymap, type, level, level_name, true);
} }
@ -838,7 +838,7 @@ SetKeyTypeField(KeyTypeInfo *type, struct xkb_keymap *keymap,
if (type->defs.defined & _KT_Mask) if (type->defs.defined & _KT_Mask)
{ {
WARN("Multiple modifier mask definitions for key type %s\n", WARN("Multiple modifier mask definitions for key type %s\n",
xkb_atom_text(keymap->context, type->name)); xkb_atom_text(keymap->ctx, type->name));
ACTION("Using %s, ", TypeMaskTxt(type, keymap)); ACTION("Using %s, ", TypeMaskTxt(type, keymap));
INFO("ignoring %s\n", XkbcVModMaskText(keymap, mods, vmods)); INFO("ignoring %s\n", XkbcVModMaskText(keymap, mods, vmods));
return false; return false;
@ -1102,7 +1102,7 @@ CopyDefToKeyType(struct xkb_keymap *keymap, struct xkb_key_type *type,
{ {
WARN("Couldn't allocate preserve array in CopyDefToKeyType\n"); WARN("Couldn't allocate preserve array in CopyDefToKeyType\n");
ACTION("Preserve setting for type %s lost\n", ACTION("Preserve setting for type %s lost\n",
xkb_atom_text(keymap->context, def->name)); xkb_atom_text(keymap->ctx, def->name));
} }
else else
{ {
@ -1118,7 +1118,7 @@ CopyDefToKeyType(struct xkb_keymap *keymap, struct xkb_key_type *type,
} }
else else
type->preserve = NULL; type->preserve = NULL;
type->name = xkb_atom_strdup(keymap->context, def->name); type->name = xkb_atom_strdup(keymap->ctx, def->name);
if (def->szNames > 0) if (def->szNames > 0)
{ {
type->level_names = uTypedCalloc(def->numLevels, const char *); type->level_names = uTypedCalloc(def->numLevels, const char *);
@ -1126,7 +1126,7 @@ CopyDefToKeyType(struct xkb_keymap *keymap, struct xkb_key_type *type,
/* assert def->szNames<=def->numLevels */ /* assert def->szNames<=def->numLevels */
for (i = 0; i < def->szNames; i++) for (i = 0; i < def->szNames; i++)
{ {
type->level_names[i] = xkb_atom_strdup(keymap->context, type->level_names[i] = xkb_atom_strdup(keymap->ctx,
def->lvlNames[i]); def->lvlNames[i]);
} }
} }
@ -1186,16 +1186,16 @@ CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap, unsigned merge)
if (missing & XkbOneLevelMask) if (missing & XkbOneLevelMask)
keymap->map->types[XkbOneLevelIndex].name = keymap->map->types[XkbOneLevelIndex].name =
xkb_atom_strdup(keymap->context, tok_ONE_LEVEL); xkb_atom_strdup(keymap->ctx, tok_ONE_LEVEL);
if (missing & XkbTwoLevelMask) if (missing & XkbTwoLevelMask)
keymap->map->types[XkbTwoLevelIndex].name = keymap->map->types[XkbTwoLevelIndex].name =
xkb_atom_strdup(keymap->context, tok_TWO_LEVEL); xkb_atom_strdup(keymap->ctx, tok_TWO_LEVEL);
if (missing & XkbAlphabeticMask) if (missing & XkbAlphabeticMask)
keymap->map->types[XkbAlphabeticIndex].name = keymap->map->types[XkbAlphabeticIndex].name =
xkb_atom_strdup(keymap->context, tok_ALPHABETIC); xkb_atom_strdup(keymap->ctx, tok_ALPHABETIC);
if (missing & XkbKeypadMask) if (missing & XkbKeypadMask)
keymap->map->types[XkbKeypadIndex].name = keymap->map->types[XkbKeypadIndex].name =
xkb_atom_strdup(keymap->context, tok_KEYPAD); xkb_atom_strdup(keymap->ctx, tok_KEYPAD);
} }
next = &keymap->map->types[XkbLastRequiredType + 1]; next = &keymap->map->types[XkbLastRequiredType + 1];

View File

@ -35,7 +35,7 @@
* If the statement defines a specific map to use, this map is returned in * If the statement defines a specific map to use, this map is returned in
* file_rtrn. Otherwise, the default map is returned. * file_rtrn. Otherwise, the default map is returned.
* *
* @param context The context containing include paths * @param ctx The ctx containing include paths
* @param stmt The include statement, specifying the file name to look for. * @param stmt The include statement, specifying the file name to look for.
* @param file_type Type of file (XkmKeyNamesIdx, etc.) * @param file_type Type of file (XkmKeyNamesIdx, etc.)
* @param file_rtrn Returns the key map to be used. * @param file_rtrn Returns the key map to be used.
@ -44,7 +44,7 @@
* @return true on success or false otherwise. * @return true on success or false otherwise.
*/ */
bool bool
ProcessIncludeFile(struct xkb_context *context, ProcessIncludeFile(struct xkb_ctx *ctx,
IncludeStmt * stmt, IncludeStmt * stmt,
unsigned file_type, unsigned file_type,
XkbFile ** file_rtrn, unsigned *merge_rtrn) XkbFile ** file_rtrn, unsigned *merge_rtrn)
@ -52,7 +52,7 @@ ProcessIncludeFile(struct xkb_context *context,
FILE *file; FILE *file;
XkbFile *rtrn, *mapToUse, *next; XkbFile *rtrn, *mapToUse, *next;
file = XkbFindFileInPath(context, stmt->file, file_type, &stmt->path); file = XkbFindFileInPath(ctx, stmt->file, file_type, &stmt->path);
if (file == NULL) if (file == NULL)
{ {
ERROR("Can't find file \"%s\" for %s include\n", stmt->file, ERROR("Can't find file \"%s\" for %s include\n", stmt->file,
@ -61,7 +61,7 @@ ProcessIncludeFile(struct xkb_context *context,
} }
if (!XKBParseFile(context, file, stmt->file, &rtrn)) if (!XKBParseFile(ctx, file, stmt->file, &rtrn))
{ {
ERROR("Error interpreting include file \"%s\"\n", stmt->file); ERROR("Error interpreting include file \"%s\"\n", stmt->file);
fclose(file); fclose(file);

View File

@ -176,7 +176,7 @@ XkbCompositeMap : OptFlags XkbCompositeType OptMapName OBRACE
XkbMapConfigList XkbMapConfigList
CBRACE SEMI CBRACE SEMI
{ {
$$ = CreateXKBFile(param->context, $2, $3, $$ = CreateXKBFile(param->ctx, $2, $3,
&$5->common, $1); &$5->common, $1);
} }
; ;
@ -209,7 +209,7 @@ XkbMapConfig : OptFlags FileType OptMapName OBRACE
} }
else else
{ {
$$ = CreateXKBFile(param->context, $2, $3, $5, $1); $$ = CreateXKBFile(param->ctx, $2, $3, $5, $1);
} }
} }
; ;
@ -224,7 +224,7 @@ XkbConfig : OptFlags FileType OptMapName DeclList
} }
else else
{ {
$$ = CreateXKBFile(param->context, $2, $3, $4, $1); $$ = CreateXKBFile(param->ctx, $2, $3, $4, $1);
} }
} }
; ;
@ -563,21 +563,21 @@ FieldSpec : Ident { $$= $1; }
; ;
Element : ACTION_TOK Element : ACTION_TOK
{ $$= xkb_atom_intern(param->context, "action"); } { $$= xkb_atom_intern(param->ctx, "action"); }
| INTERPRET | INTERPRET
{ $$= xkb_atom_intern(param->context, "interpret"); } { $$= xkb_atom_intern(param->ctx, "interpret"); }
| TYPE | TYPE
{ $$= xkb_atom_intern(param->context, "type"); } { $$= xkb_atom_intern(param->ctx, "type"); }
| KEY | KEY
{ $$= xkb_atom_intern(param->context, "key"); } { $$= xkb_atom_intern(param->ctx, "key"); }
| GROUP | GROUP
{ $$= xkb_atom_intern(param->context, "group"); } { $$= xkb_atom_intern(param->ctx, "group"); }
| MODIFIER_MAP | MODIFIER_MAP
{$$= xkb_atom_intern(param->context, "modifier_map");} {$$= xkb_atom_intern(param->ctx, "modifier_map");}
| INDICATOR | INDICATOR
{ $$= xkb_atom_intern(param->context, "indicator"); } { $$= xkb_atom_intern(param->ctx, "indicator"); }
| SHAPE | SHAPE
{ $$= xkb_atom_intern(param->context, "shape"); } { $$= xkb_atom_intern(param->ctx, "shape"); }
| ROW | ROW
{ $$= XKB_ATOM_NONE; } { $$= XKB_ATOM_NONE; }
| SECTION | SECTION
@ -769,18 +769,18 @@ KeyName : KEYNAME { $$= $1; }
Ident : IDENT Ident : IDENT
{ {
$$ = xkb_atom_intern(param->context, $1); $$ = xkb_atom_intern(param->ctx, $1);
free($1); free($1);
} }
| DEFAULT | DEFAULT
{ {
$$ = xkb_atom_intern(param->context, "default"); $$ = xkb_atom_intern(param->ctx, "default");
} }
; ;
String : STRING String : STRING
{ {
$$ = xkb_atom_intern(param->context, $1); $$ = xkb_atom_intern(param->ctx, $1);
free($1); free($1);
} }
; ;

View File

@ -684,7 +684,7 @@ EnsureSafeMapName(char *name)
} }
XkbFile * XkbFile *
CreateXKBFile(struct xkb_context *context, int type, char *name, CreateXKBFile(struct xkb_ctx *ctx, int type, char *name,
ParseCommon *defs, unsigned flags) ParseCommon *defs, unsigned flags)
{ {
XkbFile *file; XkbFile *file;
@ -698,7 +698,7 @@ CreateXKBFile(struct xkb_context *context, int type, char *name,
file->topName = uDupString(name); file->topName = uDupString(name);
file->name = name; file->name = name;
file->defs = defs; file->defs = defs;
file->id = xkb_context_take_file_id(context); file->id = xkb_ctx_take_file_id(ctx);
file->flags = flags; file->flags = flags;
} }
return file; return file;

View File

@ -33,7 +33,7 @@
#include "parser.h" #include "parser.h"
struct parser_param { struct parser_param {
struct xkb_context *context; struct xkb_ctx *ctx;
void *scanner; void *scanner;
XkbFile *rtrn; XkbFile *rtrn;
}; };
@ -120,16 +120,16 @@ extern void
CheckDefaultMap(XkbFile *maps, const char *fileName); CheckDefaultMap(XkbFile *maps, const char *fileName);
extern XkbFile * extern XkbFile *
CreateXKBFile(struct xkb_context *context, int type, char *name, CreateXKBFile(struct xkb_ctx *ctx, int type, char *name,
ParseCommon *defs, unsigned flags); ParseCommon *defs, unsigned flags);
extern bool extern bool
XKBParseFile(struct xkb_context *context, FILE *file, XKBParseFile(struct xkb_ctx *ctx, FILE *file,
const char *file_name, XkbFile **out); const char *file_name, XkbFile **out);
extern bool extern bool
XKBParseString(struct xkb_context *context, const char *string, XKBParseString(struct xkb_ctx *context, const char *string,
const char *file_name, XkbFile **out); const char *file_name, XkbFile **out);
extern void extern void
FreeXKBFile(XkbFile *file); FreeXKBFile(XkbFile *file);

View File

@ -174,7 +174,7 @@ XkbDirectoryForInclude(unsigned type)
/** /**
* Search for the given file name in the include directories. * Search for the given file name in the include directories.
* *
* @param context the XKB context containing the include paths * @param ctx the XKB ctx containing the include paths
* @param type one of XkbTypesIndex, XkbCompatMapIndex, ..., or * @param type one of XkbTypesIndex, XkbCompatMapIndex, ..., or
* XkbSemanticsFile, XkmKeymapFile, ... * XkbSemanticsFile, XkmKeymapFile, ...
* @param pathReturn is set to the full path of the file if found. * @param pathReturn is set to the full path of the file if found.
@ -183,7 +183,7 @@ XkbDirectoryForInclude(unsigned type)
* pathRtrn is undefined. * pathRtrn is undefined.
*/ */
FILE * FILE *
XkbFindFileInPath(struct xkb_context *context, XkbFindFileInPath(struct xkb_ctx *ctx,
const char *name, unsigned type, char **pathRtrn) const char *name, unsigned type, char **pathRtrn)
{ {
size_t i; size_t i;
@ -193,21 +193,21 @@ XkbFindFileInPath(struct xkb_context *context,
const char *typeDir; const char *typeDir;
typeDir = XkbDirectoryForInclude(type); typeDir = XkbDirectoryForInclude(type);
for (i = 0; i < xkb_context_num_include_paths(context); i++) for (i = 0; i < xkb_ctx_num_include_paths(ctx); i++)
{ {
ret = snprintf(buf, sizeof(buf), "%s/%s/%s", ret = snprintf(buf, sizeof(buf), "%s/%s/%s",
xkb_context_include_path_get(context, i), typeDir, name); xkb_ctx_include_path_get(ctx, i), typeDir, name);
if (ret >= (ssize_t)sizeof(buf)) if (ret >= (ssize_t)sizeof(buf))
{ {
ERROR("File name (%s/%s/%s) too long\n", ERROR("File name (%s/%s/%s) too long\n",
xkb_context_include_path_get(context, i), typeDir, name); xkb_ctx_include_path_get(ctx, i), typeDir, name);
ACTION("Ignored\n"); ACTION("Ignored\n");
continue; continue;
} }
file = fopen(buf, "r"); file = fopen(buf, "r");
if (file == NULL) { if (file == NULL) {
ERROR("Couldn't open file (%s/%s/%s): %s\n", ERROR("Couldn't open file (%s/%s/%s): %s\n",
xkb_context_include_path_get(context, i), typeDir, name, xkb_ctx_include_path_get(ctx, i), typeDir, name,
strerror(-errno)); strerror(-errno));
ACTION("Ignored\n"); ACTION("Ignored\n");
continue; continue;

View File

@ -205,7 +205,7 @@ yyerror(struct YYLTYPE *loc, void *scanner, const char *msg)
} }
bool bool
XKBParseString(struct xkb_context *context, const char *string, XKBParseString(struct xkb_ctx *ctx, const char *string,
const char *file_name, XkbFile **out) const char *file_name, XkbFile **out)
{ {
int ret; int ret;
@ -216,7 +216,7 @@ XKBParseString(struct xkb_context *context, const char *string,
if (string == NULL) if (string == NULL)
return false; return false;
param.context = context; param.ctx = ctx;
memset(&extra, 0, sizeof(extra)); memset(&extra, 0, sizeof(extra));
ret = yylex_init_extra(&extra, &param.scanner); ret = yylex_init_extra(&extra, &param.scanner);
@ -241,7 +241,7 @@ XKBParseString(struct xkb_context *context, const char *string,
} }
bool bool
XKBParseFile(struct xkb_context *context, FILE *file, XKBParseFile(struct xkb_ctx *ctx, FILE *file,
const char *file_name, XkbFile **out) const char *file_name, XkbFile **out)
{ {
int ret; int ret;
@ -251,7 +251,7 @@ XKBParseFile(struct xkb_context *context, FILE *file,
if (!file) if (!file)
return false; return false;
param.context = context; param.ctx = ctx;
memset(&extra, 0, sizeof(extra)); memset(&extra, 0, sizeof(extra));
ret = yylex_init_extra(&extra, &param.scanner); ret = yylex_init_extra(&extra, &param.scanner);

View File

@ -663,8 +663,8 @@ MergeKeys(SymbolsInfo *info, struct xkb_keymap *keymap,
("Multiple definitions for group %d type of key %s\n", ("Multiple definitions for group %d type of key %s\n",
i, longText(into->name)); i, longText(into->name));
ACTION("Using %s, ignoring %s\n", ACTION("Using %s, ignoring %s\n",
xkb_atom_text(keymap->context, use), xkb_atom_text(keymap->ctx, use),
xkb_atom_text(keymap->context, ignore)); xkb_atom_text(keymap->ctx, ignore));
} }
if ((from->defs.merge != MergeAugment) if ((from->defs.merge != MergeAugment)
|| (into->types[i] == XKB_ATOM_NONE)) || (into->types[i] == XKB_ATOM_NONE))
@ -889,8 +889,8 @@ HandleIncludeSymbols(IncludeStmt *stmt, struct xkb_keymap *keymap,
included = *info; included = *info;
memset(info, 0, sizeof(SymbolsInfo)); memset(info, 0, sizeof(SymbolsInfo));
} }
else if (ProcessIncludeFile(keymap->context, stmt, XkmSymbolsIndex, else if (ProcessIncludeFile(keymap->ctx, stmt, XkmSymbolsIndex, &rtrn,
&rtrn, &newMerge)) &newMerge))
{ {
InitSymbolsInfo(&included, keymap); InitSymbolsInfo(&included, keymap);
included.fileID = included.dflt.defs.fileID = rtrn->id; included.fileID = included.dflt.defs.fileID = rtrn->id;
@ -931,8 +931,8 @@ HandleIncludeSymbols(IncludeStmt *stmt, struct xkb_keymap *keymap,
MergeIncludedSymbols(&included, info, next->merge, keymap); MergeIncludedSymbols(&included, info, next->merge, keymap);
FreeSymbolsInfo(info); FreeSymbolsInfo(info);
} }
else if (ProcessIncludeFile(keymap->context, next, else if (ProcessIncludeFile(keymap->ctx, next, XkmSymbolsIndex,
XkmSymbolsIndex, &rtrn, &op)) &rtrn, &op))
{ {
InitSymbolsInfo(&next_incl, keymap); InitSymbolsInfo(&next_incl, keymap);
next_incl.fileID = next_incl.dflt.defs.fileID = rtrn->id; next_incl.fileID = next_incl.dflt.defs.fileID = rtrn->id;
@ -1009,7 +1009,7 @@ GetGroupIndex(KeyInfo *key, struct xkb_keymap *keymap,
ACTION("Ignoring %s defined for extra groups\n", name); ACTION("Ignoring %s defined for extra groups\n", name);
return false; return false;
} }
if (!ExprResolveGroup(keymap->context, arrayNdx, &tmp)) if (!ExprResolveGroup(keymap->ctx, arrayNdx, &tmp))
{ {
ERROR("Illegal group index for %s of key %s\n", name, ERROR("Illegal group index for %s of key %s\n", name,
longText(key->name)); longText(key->name));
@ -1070,7 +1070,7 @@ AddSymbolsToKey(KeyInfo *key, struct xkb_keymap *keymap,
&key->syms[ndx][key->symsMapIndex[ndx][i] + j])) { &key->syms[ndx][key->symsMapIndex[ndx][i] + j])) {
WARN("Could not resolve keysym %s for key %s, group %d (%s), level %d\n", WARN("Could not resolve keysym %s for key %s, group %d (%s), level %d\n",
value->value.list.syms[i], longText(key->name), ndx + 1, value->value.list.syms[i], longText(key->name), ndx + 1,
xkb_atom_text(keymap->context, info->groupNames[ndx]), nSyms); xkb_atom_text(keymap->ctx, info->groupNames[ndx]), nSyms);
while (--j >= 0) while (--j >= 0)
key->syms[ndx][key->symsMapIndex[ndx][i] + j] = NoSymbol; key->syms[ndx][key->symsMapIndex[ndx][i] + j] = NoSymbol;
key->symsMapIndex[ndx][i] = -1; key->symsMapIndex[ndx][i] = -1;
@ -1181,7 +1181,7 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
if (strcasecmp(field, "type") == 0) if (strcasecmp(field, "type") == 0)
{ {
ExprResult ndx; ExprResult ndx;
if ((!ExprResolveString(keymap->context, value, &tmp)) if ((!ExprResolveString(keymap->ctx, value, &tmp))
&& (warningLevel > 0)) && (warningLevel > 0))
{ {
WARN("The type field of a key symbol map must be a string\n"); WARN("The type field of a key symbol map must be a string\n");
@ -1189,10 +1189,10 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
} }
if (arrayNdx == NULL) if (arrayNdx == NULL)
{ {
key->dfltType = xkb_atom_intern(keymap->context, tmp.str); key->dfltType = xkb_atom_intern(keymap->ctx, tmp.str);
key->defs.defined |= _Key_Type_Dflt; key->defs.defined |= _Key_Type_Dflt;
} }
else if (!ExprResolveGroup(keymap->context, arrayNdx, &ndx)) else if (!ExprResolveGroup(keymap->ctx, arrayNdx, &ndx))
{ {
ERROR("Illegal group index for type of key %s\n", ERROR("Illegal group index for type of key %s\n",
longText(key->name)); longText(key->name));
@ -1202,8 +1202,7 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
} }
else else
{ {
key->types[ndx.uval - 1] = xkb_atom_intern(keymap->context, key->types[ndx.uval - 1] = xkb_atom_intern(keymap->ctx, tmp.str);
tmp.str);
key->typesDefined |= (1 << (ndx.uval - 1)); key->typesDefined |= (1 << (ndx.uval - 1));
} }
free(tmp.str); free(tmp.str);
@ -1234,7 +1233,7 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
(strcasecmp(field, "lock") == 0) || (strcasecmp(field, "lock") == 0) ||
(strcasecmp(field, "locks") == 0)) (strcasecmp(field, "locks") == 0))
{ {
ok = ExprResolveEnum(keymap->context, value, &tmp, lockingEntries); ok = ExprResolveEnum(keymap->ctx, value, &tmp, lockingEntries);
if (ok) if (ok)
key->behavior.type = tmp.uval; key->behavior.type = tmp.uval;
key->defs.defined |= _Key_Behavior; key->defs.defined |= _Key_Behavior;
@ -1257,7 +1256,7 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
(strcasecmp(field, "repeats") == 0) || (strcasecmp(field, "repeats") == 0) ||
(strcasecmp(field, "repeat") == 0)) (strcasecmp(field, "repeat") == 0))
{ {
ok = ExprResolveEnum(keymap->context, value, &tmp, repeatEntries); ok = ExprResolveEnum(keymap->ctx, value, &tmp, repeatEntries);
if (!ok) if (!ok)
{ {
ERROR("Illegal repeat setting for %s\n", ERROR("Illegal repeat setting for %s\n",
@ -1271,7 +1270,7 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
else if ((strcasecmp(field, "groupswrap") == 0) || else if ((strcasecmp(field, "groupswrap") == 0) ||
(strcasecmp(field, "wrapgroups") == 0)) (strcasecmp(field, "wrapgroups") == 0))
{ {
ok = ExprResolveBoolean(keymap->context, value, &tmp); ok = ExprResolveBoolean(keymap->ctx, value, &tmp);
if (!ok) if (!ok)
{ {
ERROR("Illegal groupsWrap setting for %s\n", ERROR("Illegal groupsWrap setting for %s\n",
@ -1288,7 +1287,7 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
else if ((strcasecmp(field, "groupsclamp") == 0) || else if ((strcasecmp(field, "groupsclamp") == 0) ||
(strcasecmp(field, "clampgroups") == 0)) (strcasecmp(field, "clampgroups") == 0))
{ {
ok = ExprResolveBoolean(keymap->context, value, &tmp); ok = ExprResolveBoolean(keymap->ctx, value, &tmp);
if (!ok) if (!ok)
{ {
ERROR("Illegal groupsClamp setting for %s\n", ERROR("Illegal groupsClamp setting for %s\n",
@ -1305,7 +1304,7 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
else if ((strcasecmp(field, "groupsredirect") == 0) || else if ((strcasecmp(field, "groupsredirect") == 0) ||
(strcasecmp(field, "redirectgroups") == 0)) (strcasecmp(field, "redirectgroups") == 0))
{ {
if (!ExprResolveGroup(keymap->context, value, &tmp)) if (!ExprResolveGroup(keymap->ctx, value, &tmp))
{ {
ERROR("Illegal group index for redirect of key %s\n", ERROR("Illegal group index for redirect of key %s\n",
longText(key->name)); longText(key->name));
@ -1337,20 +1336,20 @@ SetGroupName(SymbolsInfo *info, struct xkb_keymap *keymap, ExprDef *arrayNdx,
ACTION("Group name definition without array subscript ignored\n"); ACTION("Group name definition without array subscript ignored\n");
return false; return false;
} }
if (!ExprResolveGroup(keymap->context, arrayNdx, &tmp)) if (!ExprResolveGroup(keymap->ctx, arrayNdx, &tmp))
{ {
ERROR("Illegal index in group name definition\n"); ERROR("Illegal index in group name definition\n");
ACTION("Definition with non-integer array index ignored\n"); ACTION("Definition with non-integer array index ignored\n");
return false; return false;
} }
if (!ExprResolveString(keymap->context, value, &name)) if (!ExprResolveString(keymap->ctx, value, &name))
{ {
ERROR("Group name must be a string\n"); ERROR("Group name must be a string\n");
ACTION("Illegal name for group %d ignored\n", tmp.uval); ACTION("Illegal name for group %d ignored\n", tmp.uval);
return false; return false;
} }
info->groupNames[tmp.uval - 1 + info->explicit_group] = info->groupNames[tmp.uval - 1 + info->explicit_group] =
xkb_atom_intern(keymap->context, name.str); xkb_atom_intern(keymap->ctx, name.str);
free(name.str); free(name.str);
return true; return true;
@ -1380,7 +1379,7 @@ HandleSymbolsVar(VarDef *stmt, struct xkb_keymap *keymap, SymbolsInfo *info)
&& ((strcasecmp(field.str, "groupswrap") == 0) || && ((strcasecmp(field.str, "groupswrap") == 0) ||
(strcasecmp(field.str, "wrapgroups") == 0))) (strcasecmp(field.str, "wrapgroups") == 0)))
{ {
if (!ExprResolveBoolean(keymap->context, stmt->value, &tmp)) if (!ExprResolveBoolean(keymap->ctx, stmt->value, &tmp))
{ {
ERROR("Illegal setting for global groupsWrap\n"); ERROR("Illegal setting for global groupsWrap\n");
ACTION("Non-boolean value ignored\n"); ACTION("Non-boolean value ignored\n");
@ -1398,7 +1397,7 @@ HandleSymbolsVar(VarDef *stmt, struct xkb_keymap *keymap, SymbolsInfo *info)
&& ((strcasecmp(field.str, "groupsclamp") == 0) || && ((strcasecmp(field.str, "groupsclamp") == 0) ||
(strcasecmp(field.str, "clampgroups") == 0))) (strcasecmp(field.str, "clampgroups") == 0)))
{ {
if (!ExprResolveBoolean(keymap->context, stmt->value, &tmp)) if (!ExprResolveBoolean(keymap->ctx, stmt->value, &tmp))
{ {
ERROR("Illegal setting for global groupsClamp\n"); ERROR("Illegal setting for global groupsClamp\n");
ACTION("Non-boolean value ignored\n"); ACTION("Non-boolean value ignored\n");
@ -1416,7 +1415,7 @@ HandleSymbolsVar(VarDef *stmt, struct xkb_keymap *keymap, SymbolsInfo *info)
&& ((strcasecmp(field.str, "groupsredirect") == 0) || && ((strcasecmp(field.str, "groupsredirect") == 0) ||
(strcasecmp(field.str, "redirectgroups") == 0))) (strcasecmp(field.str, "redirectgroups") == 0)))
{ {
if (!ExprResolveGroup(keymap->context, stmt->value, &tmp)) if (!ExprResolveGroup(keymap->ctx, stmt->value, &tmp))
{ {
ERROR("Illegal group index for global groupsRedirect\n"); ERROR("Illegal group index for global groupsRedirect\n");
ACTION("Definition with non-integer group ignored\n"); ACTION("Definition with non-integer group ignored\n");
@ -1566,11 +1565,11 @@ HandleModMapDef(ModMapDef *def, struct xkb_keymap *keymap, SymbolsInfo *info)
ExprResult rtrn; ExprResult rtrn;
bool ok; bool ok;
if (!LookupModIndex(keymap->context, NULL, def->modifier, TypeInt, &rtrn)) if (!LookupModIndex(keymap->ctx, NULL, def->modifier, TypeInt, &rtrn))
{ {
ERROR("Illegal modifier map definition\n"); ERROR("Illegal modifier map definition\n");
ACTION("Ignoring map for non-modifier \"%s\"\n", ACTION("Ignoring map for non-modifier \"%s\"\n",
xkb_atom_text(keymap->context, def->modifier)); xkb_atom_text(keymap->ctx, def->modifier));
return false; return false;
} }
ok = true; ok = true;
@ -1582,7 +1581,7 @@ HandleModMapDef(ModMapDef *def, struct xkb_keymap *keymap, SymbolsInfo *info)
tmp.haveSymbol = false; tmp.haveSymbol = false;
tmp.u.keyName = KeyNameToLong(key->value.keyName); tmp.u.keyName = KeyNameToLong(key->value.keyName);
} }
else if (ExprResolveKeySym(keymap->context, key, &rtrn)) else if (ExprResolveKeySym(keymap->ctx, key, &rtrn))
{ {
tmp.haveSymbol = true; tmp.haveSymbol = true;
tmp.u.keySym = rtrn.uval; tmp.u.keySym = rtrn.uval;
@ -1699,7 +1698,7 @@ static bool
FindNamedType(struct xkb_keymap *keymap, xkb_atom_t atom, unsigned *type_rtrn) FindNamedType(struct xkb_keymap *keymap, xkb_atom_t atom, unsigned *type_rtrn)
{ {
unsigned n; unsigned n;
const char *name = xkb_atom_text(keymap->context, atom); const char *name = xkb_atom_text(keymap->ctx, atom);
if (keymap && keymap->map && keymap->map->types) if (keymap && keymap->map && keymap->map->types)
{ {
@ -1738,23 +1737,23 @@ FindAutomaticType(struct xkb_keymap *keymap, int width, xkb_keysym_t *syms,
*autoType = false; *autoType = false;
if ((width == 1) || (width == 0)) if ((width == 1) || (width == 0))
{ {
*typeNameRtrn = xkb_atom_intern(keymap->context, "ONE_LEVEL"); *typeNameRtrn = xkb_atom_intern(keymap->ctx, "ONE_LEVEL");
*autoType = true; *autoType = true;
} }
else if (width == 2) else if (width == 2)
{ {
if (syms && XkbcKSIsLower(syms[0]) && XkbcKSIsUpper(syms[1])) if (syms && XkbcKSIsLower(syms[0]) && XkbcKSIsUpper(syms[1]))
{ {
*typeNameRtrn = xkb_atom_intern(keymap->context, "ALPHABETIC"); *typeNameRtrn = xkb_atom_intern(keymap->ctx, "ALPHABETIC");
} }
else if (syms && (XkbKSIsKeypad(syms[0]) || XkbKSIsKeypad(syms[1]))) else if (syms && (XkbKSIsKeypad(syms[0]) || XkbKSIsKeypad(syms[1])))
{ {
*typeNameRtrn = xkb_atom_intern(keymap->context, "KEYPAD"); *typeNameRtrn = xkb_atom_intern(keymap->ctx, "KEYPAD");
*autoType = true; *autoType = true;
} }
else else
{ {
*typeNameRtrn = xkb_atom_intern(keymap->context, "TWO_LEVEL"); *typeNameRtrn = xkb_atom_intern(keymap->ctx, "TWO_LEVEL");
*autoType = true; *autoType = true;
} }
} }
@ -1763,15 +1762,15 @@ FindAutomaticType(struct xkb_keymap *keymap, int width, xkb_keysym_t *syms,
if (syms && XkbcKSIsLower(syms[0]) && XkbcKSIsUpper(syms[1])) if (syms && XkbcKSIsLower(syms[0]) && XkbcKSIsUpper(syms[1]))
if (XkbcKSIsLower(syms[2]) && XkbcKSIsUpper(syms[3])) if (XkbcKSIsLower(syms[2]) && XkbcKSIsUpper(syms[3]))
*typeNameRtrn = *typeNameRtrn =
xkb_atom_intern(keymap->context, "FOUR_LEVEL_ALPHABETIC"); xkb_atom_intern(keymap->ctx, "FOUR_LEVEL_ALPHABETIC");
else else
*typeNameRtrn = xkb_atom_intern(keymap->context, *typeNameRtrn = xkb_atom_intern(keymap->ctx,
"FOUR_LEVEL_SEMIALPHABETIC"); "FOUR_LEVEL_SEMIALPHABETIC");
else if (syms && (XkbKSIsKeypad(syms[0]) || XkbKSIsKeypad(syms[1]))) else if (syms && (XkbKSIsKeypad(syms[0]) || XkbKSIsKeypad(syms[1])))
*typeNameRtrn = xkb_atom_intern(keymap->context, "FOUR_LEVEL_KEYPAD"); *typeNameRtrn = xkb_atom_intern(keymap->ctx, "FOUR_LEVEL_KEYPAD");
else else
*typeNameRtrn = xkb_atom_intern(keymap->context, "FOUR_LEVEL"); *typeNameRtrn = xkb_atom_intern(keymap->ctx, "FOUR_LEVEL");
/* XXX: why not set autoType here? */ /* XXX: why not set autoType here? */
} }
return ((width >= 0) && (width <= 4)); return ((width >= 0) && (width <= 4));
@ -1985,7 +1984,7 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
WARN("No automatic type for %d symbols\n", WARN("No automatic type for %d symbols\n",
(unsigned int) key->numLevels[i]); (unsigned int) key->numLevels[i]);
ACTION("Using %s for the %s key (keycode %d)\n", ACTION("Using %s for the %s key (keycode %d)\n",
xkb_atom_text(keymap->context, key->types[i]), xkb_atom_text(keymap->ctx, key->types[i]),
longText(key->name), kc); longText(key->name), kc);
} }
} }
@ -2000,7 +1999,7 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
if (warningLevel >= 3) if (warningLevel >= 3)
{ {
WARN("Type \"%s\" is not defined\n", WARN("Type \"%s\" is not defined\n",
xkb_atom_text(keymap->context, key->types[i])); xkb_atom_text(keymap->ctx, key->types[i]));
ACTION("Using TWO_LEVEL for the %s key (keycode %d)\n", ACTION("Using TWO_LEVEL for the %s key (keycode %d)\n",
longText(key->name), kc); longText(key->name), kc);
} }
@ -2014,7 +2013,7 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
{ {
WARN("Type \"%s\" has %d levels, but %s has %d symbols\n", WARN("Type \"%s\" has %d levels, but %s has %d symbols\n",
type->name, type->num_levels, type->name, type->num_levels,
xkb_atom_text(keymap->context, key->name), key->numLevels[i]); xkb_atom_text(keymap->ctx, key->name), key->numLevels[i]);
ACTION("Ignoring extra symbols\n"); ACTION("Ignoring extra symbols\n");
} }
key->numLevels[i] = type->num_levels; key->numLevels[i] = type->num_levels;
@ -2223,7 +2222,7 @@ CompileSymbols(XkbFile *file, struct xkb_keymap *keymap, unsigned merge)
for (i = 0; i < XkbNumKbdGroups; i++) { for (i = 0; i < XkbNumKbdGroups; i++) {
if (info.groupNames[i] != XKB_ATOM_NONE) { if (info.groupNames[i] != XKB_ATOM_NONE) {
free(UNCONSTIFY(keymap->names->groups[i])); free(UNCONSTIFY(keymap->names->groups[i]));
keymap->names->groups[i] = xkb_atom_strdup(keymap->context, keymap->names->groups[i] = xkb_atom_strdup(keymap->ctx,
info.groupNames[i]); info.groupNames[i]);
} }
} }

View File

@ -83,7 +83,7 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, unsigned mergeMode,
{ {
if (names->vmods[i] && if (names->vmods[i] &&
strcmp(names->vmods[i], strcmp(names->vmods[i],
xkb_atom_text(keymap->context, stmt->name)) == 0) xkb_atom_text(keymap->ctx, stmt->name)) == 0)
{ /* already defined */ { /* already defined */
info->available |= bit; info->available |= bit;
if (stmt->value == NULL) if (stmt->value == NULL)
@ -92,16 +92,16 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, unsigned mergeMode,
{ {
const char *str1; const char *str1;
const char *str2 = ""; const char *str2 = "";
if (!ExprResolveModMask(keymap->context, stmt->value, &mod)) if (!ExprResolveModMask(keymap->ctx, stmt->value, &mod))
{ {
str1 = xkb_atom_text(keymap->context, stmt->name); str1 = xkb_atom_text(keymap->ctx, stmt->name);
ACTION("Declaration of %s ignored\n", str1); ACTION("Declaration of %s ignored\n", str1);
return false; return false;
} }
if (mod.uval == srv->vmods[i]) if (mod.uval == srv->vmods[i])
return true; return true;
str1 = xkb_atom_text(keymap->context, stmt->name); str1 = xkb_atom_text(keymap->ctx, stmt->name);
WARN("Virtual modifier %s multiply defined\n", str1); WARN("Virtual modifier %s multiply defined\n", str1);
str1 = XkbcModMaskText(srv->vmods[i], true); str1 = XkbcModMaskText(srv->vmods[i], true);
if (mergeMode == MergeOverride) if (mergeMode == MergeOverride)
@ -128,15 +128,15 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, unsigned mergeMode,
info->defined |= (1 << nextFree); info->defined |= (1 << nextFree);
info->newlyDefined |= (1 << nextFree); info->newlyDefined |= (1 << nextFree);
info->available |= (1 << nextFree); info->available |= (1 << nextFree);
names->vmods[nextFree] = xkb_atom_strdup(keymap->context, stmt->name); names->vmods[nextFree] = xkb_atom_strdup(keymap->ctx, stmt->name);
if (stmt->value == NULL) if (stmt->value == NULL)
return true; return true;
if (ExprResolveModMask(keymap->context, stmt->value, &mod)) if (ExprResolveModMask(keymap->ctx, stmt->value, &mod))
{ {
srv->vmods[nextFree] = mod.uval; srv->vmods[nextFree] = mod.uval;
return true; return true;
} }
ACTION("Declaration of %s ignored\n", xkb_atom_text(keymap->context, stmt->name)); ACTION("Declaration of %s ignored\n", xkb_atom_text(keymap->ctx, stmt->name));
return false; return false;
} }
@ -156,7 +156,7 @@ LookupVModIndex(const struct xkb_keymap *keymap, xkb_atom_t field,
unsigned type, ExprResult * val_rtrn) unsigned type, ExprResult * val_rtrn)
{ {
int i; int i;
const char *name = xkb_atom_text(keymap->context, field); const char *name = xkb_atom_text(keymap->ctx, field);
if ((keymap == NULL) || (keymap->names == NULL) || (type != TypeInt)) if ((keymap == NULL) || (keymap->names == NULL) || (type != TypeInt))
{ {
@ -190,10 +190,10 @@ LookupVModIndex(const struct xkb_keymap *keymap, xkb_atom_t field,
* undefined. * undefined.
*/ */
bool bool
LookupVModMask(struct xkb_context *context, const void *priv, xkb_atom_t field, LookupVModMask(struct xkb_ctx *ctx, const void *priv, xkb_atom_t field,
unsigned type, ExprResult *val_rtrn) unsigned type, ExprResult *val_rtrn)
{ {
if (LookupModMask(context, NULL, field, type, val_rtrn)) if (LookupModMask(ctx, NULL, field, type, val_rtrn))
{ {
return true; return true;
} }
@ -212,8 +212,8 @@ FindKeypadVMod(struct xkb_keymap *keymap)
xkb_atom_t name; xkb_atom_t name;
ExprResult rtrn; ExprResult rtrn;
name = xkb_atom_intern(keymap->context, "NumLock"); name = xkb_atom_intern(keymap->ctx, "NumLock");
if (keymap && LookupVModIndex(keymap, name, TypeInt, &rtrn)) if ((keymap) && LookupVModIndex(keymap, name, TypeInt, &rtrn))
{ {
return rtrn.ival; return rtrn.ival;
} }
@ -229,7 +229,7 @@ ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *keymap,
if (def->op == ExprIdent) if (def->op == ExprIdent)
{ {
int i, bit; int i, bit;
const char *name = xkb_atom_text(keymap->context, def->value.str); const char *name = xkb_atom_text(keymap->ctx, def->value.str);
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1)
{ {
if ((info->available & bit) && names->vmods[i] && if ((info->available & bit) && names->vmods[i] &&
@ -240,7 +240,7 @@ ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *keymap,
} }
} }
} }
if (ExprResolveInteger(keymap->context, def, val_rtrn)) if (ExprResolveInteger(keymap->ctx, def, val_rtrn))
{ {
if (val_rtrn->uval < XkbNumVirtualMods) if (val_rtrn->uval < XkbNumVirtualMods)
return true; return true;

View File

@ -64,7 +64,7 @@ extern int
ReportBadField(const char *type, const char *field, const char *name); ReportBadField(const char *type, const char *field, const char *name);
extern bool extern bool
ProcessIncludeFile(struct xkb_context *context, ProcessIncludeFile(struct xkb_ctx *ctx,
IncludeStmt *stmt, unsigned file_type, XkbFile **file_rtrn, IncludeStmt *stmt, unsigned file_type, XkbFile **file_rtrn,
unsigned *merge_rtrn); unsigned *merge_rtrn);
@ -84,7 +84,7 @@ extern const char *
XkbDirectoryForInclude(unsigned type); XkbDirectoryForInclude(unsigned type);
extern FILE * extern FILE *
XkbFindFileInPath(struct xkb_context *context, const char *name, XkbFindFileInPath(struct xkb_ctx *ctx, const char *name,
unsigned type, char **pathRtrn); unsigned type, char **pathRtrn);
extern bool extern bool

View File

@ -34,38 +34,38 @@ unsigned int warningLevel = 0;
#define ISEMPTY(str) (!(str) || (strlen(str) == 0)) #define ISEMPTY(str) (!(str) || (strlen(str) == 0))
static XkbFile * static XkbFile *
XkbKeymapFileFromComponents(struct xkb_context *context, XkbKeymapFileFromComponents(struct xkb_ctx *ctx,
const struct xkb_component_names *ktcsg) const struct xkb_component_names *ktcsg)
{ {
XkbFile *keycodes, *types, *compat, *symbols; XkbFile *keycodes, *types, *compat, *symbols;
IncludeStmt *inc; IncludeStmt *inc;
inc = IncludeCreate(ktcsg->keycodes, MergeDefault); inc = IncludeCreate(ktcsg->keycodes, MergeDefault);
keycodes = CreateXKBFile(context, XkmKeyNamesIndex, NULL, keycodes = CreateXKBFile(ctx, XkmKeyNamesIndex, NULL,
(ParseCommon *)inc, 0); (ParseCommon *)inc, 0);
inc = IncludeCreate(ktcsg->types, MergeDefault); inc = IncludeCreate(ktcsg->types, MergeDefault);
types = CreateXKBFile(context, XkmTypesIndex, NULL, types = CreateXKBFile(ctx, XkmTypesIndex, NULL,
(ParseCommon *)inc, 0); (ParseCommon *)inc, 0);
AppendStmt(&keycodes->common, &types->common); AppendStmt(&keycodes->common, &types->common);
inc = IncludeCreate(ktcsg->compat, MergeDefault); inc = IncludeCreate(ktcsg->compat, MergeDefault);
compat = CreateXKBFile(context, XkmCompatMapIndex, NULL, compat = CreateXKBFile(ctx, XkmCompatMapIndex, NULL,
(ParseCommon *)inc, 0); (ParseCommon *)inc, 0);
AppendStmt(&keycodes->common, &compat->common); AppendStmt(&keycodes->common, &compat->common);
inc = IncludeCreate(ktcsg->symbols, MergeDefault); inc = IncludeCreate(ktcsg->symbols, MergeDefault);
symbols = CreateXKBFile(context, XkmSymbolsIndex, NULL, symbols = CreateXKBFile(ctx, XkmSymbolsIndex, NULL,
(ParseCommon *)inc, 0); (ParseCommon *)inc, 0);
AppendStmt(&keycodes->common, &symbols->common); AppendStmt(&keycodes->common, &symbols->common);
return CreateXKBFile(context, XkmKeymapFile, return CreateXKBFile(ctx, XkmKeymapFile,
ktcsg->keymap ? ktcsg->keymap : strdup(""), ktcsg->keymap ? ktcsg->keymap : strdup(""),
&keycodes->common, 0); &keycodes->common, 0);
} }
static struct xkb_component_names * static struct xkb_component_names *
XkbComponentsFromRules(struct xkb_context *context, XkbComponentsFromRules(struct xkb_ctx *ctx,
const char *rules, const char *rules,
const XkbRF_VarDefsPtr defs) const XkbRF_VarDefsPtr defs)
{ {
@ -75,13 +75,13 @@ XkbComponentsFromRules(struct xkb_context *context,
struct xkb_component_names * names = NULL; struct xkb_component_names * names = NULL;
int i; int i;
rulesFile = XkbFindFileInPath(context, rules, XkmRulesFile, &rulesPath); rulesFile = XkbFindFileInPath(ctx, rules, XkmRulesFile, &rulesPath);
if (!rulesFile) { if (!rulesFile) {
ERROR("could not find \"%s\" rules in XKB path\n", rules); ERROR("could not find \"%s\" rules in XKB path\n", rules);
ERROR("%d include paths searched:\n", ERROR("%d include paths searched:\n",
xkb_context_num_include_paths(context)); xkb_ctx_num_include_paths(ctx));
for (i = 0; i < xkb_context_num_include_paths(context); i++) for (i = 0; i < xkb_ctx_num_include_paths(ctx); i++)
ERROR("\t%s\n", xkb_context_include_path_get(context, i)); ERROR("\t%s\n", xkb_ctx_include_path_get(ctx, i));
return NULL; return NULL;
} }
@ -120,7 +120,7 @@ unwind_file:
} }
_X_EXPORT struct xkb_keymap * _X_EXPORT struct xkb_keymap *
xkb_map_new_from_names(struct xkb_context *context, xkb_map_new_from_names(struct xkb_ctx *ctx,
const struct xkb_rule_names *rmlvo, const struct xkb_rule_names *rmlvo,
enum xkb_map_compile_flags flags) enum xkb_map_compile_flags flags)
{ {
@ -138,14 +138,14 @@ xkb_map_new_from_names(struct xkb_context *context,
defs.variant = rmlvo->variant; defs.variant = rmlvo->variant;
defs.options = rmlvo->options; defs.options = rmlvo->options;
names = XkbComponentsFromRules(context, rmlvo->rules, &defs); names = XkbComponentsFromRules(ctx, rmlvo->rules, &defs);
if (!names) { if (!names) {
ERROR("failed to generate XKB components from rules \"%s\"\n", ERROR("failed to generate XKB components from rules \"%s\"\n",
rmlvo->rules); rmlvo->rules);
return NULL; return NULL;
} }
keymap = xkb_map_new_from_kccgst(context, names, 0); keymap = xkb_map_new_from_kccgst(ctx, names, 0);
free(names->keymap); free(names->keymap);
free(names->keycodes); free(names->keycodes);
@ -192,7 +192,7 @@ XkbChooseMap(XkbFile *file, const char *name)
} }
static struct xkb_keymap * static struct xkb_keymap *
compile_keymap(struct xkb_context *context, XkbFile *file) compile_keymap(struct xkb_ctx *ctx, XkbFile *file)
{ {
XkbFile *mapToUse; XkbFile *mapToUse;
struct xkb_keymap *keymap = NULL; struct xkb_keymap *keymap = NULL;
@ -212,7 +212,7 @@ compile_keymap(struct xkb_context *context, XkbFile *file)
goto err; goto err;
} }
keymap = CompileKeymap(context, mapToUse); keymap = CompileKeymap(ctx, mapToUse);
if (!keymap) if (!keymap)
goto err; goto err;
@ -222,7 +222,7 @@ err:
} }
_X_EXPORT struct xkb_keymap * _X_EXPORT struct xkb_keymap *
xkb_map_new_from_kccgst(struct xkb_context *context, xkb_map_new_from_kccgst(struct xkb_ctx *ctx,
const struct xkb_component_names *kccgst, const struct xkb_component_names *kccgst,
enum xkb_map_compile_flags flags) enum xkb_map_compile_flags flags)
{ {
@ -253,16 +253,16 @@ xkb_map_new_from_kccgst(struct xkb_context *context,
return NULL; return NULL;
} }
if (!(file = XkbKeymapFileFromComponents(context, kccgst))) { if (!(file = XkbKeymapFileFromComponents(ctx, kccgst))) {
ERROR("failed to generate parsed XKB file from components\n"); ERROR("failed to generate parsed XKB file from components\n");
return NULL; return NULL;
} }
return compile_keymap(context, file); return compile_keymap(ctx, file);
} }
_X_EXPORT struct xkb_keymap * _X_EXPORT struct xkb_keymap *
xkb_map_new_from_string(struct xkb_context *context, xkb_map_new_from_string(struct xkb_ctx *ctx,
const char *string, const char *string,
enum xkb_keymap_format format, enum xkb_keymap_format format,
enum xkb_map_compile_flags flags) enum xkb_map_compile_flags flags)
@ -279,16 +279,16 @@ xkb_map_new_from_string(struct xkb_context *context,
return NULL; return NULL;
} }
if (!XKBParseString(context, string, "input", &file)) { if (!XKBParseString(ctx, string, "input", &file)) {
ERROR("failed to parse input xkb file\n"); ERROR("failed to parse input xkb file\n");
return NULL; return NULL;
} }
return compile_keymap(context, file); return compile_keymap(ctx, file);
} }
_X_EXPORT struct xkb_keymap * _X_EXPORT struct xkb_keymap *
xkb_map_new_from_fd(struct xkb_context *context, xkb_map_new_from_fd(struct xkb_ctx *ctx,
int fd, int fd,
enum xkb_keymap_format format, enum xkb_keymap_format format,
enum xkb_map_compile_flags flags) enum xkb_map_compile_flags flags)
@ -312,12 +312,12 @@ xkb_map_new_from_fd(struct xkb_context *context,
return NULL; return NULL;
} }
if (!XKBParseFile(context, fptr, "(unknown file)", &file)) { if (!XKBParseFile(ctx, fptr, "(unknown file)", &file)) {
ERROR("failed to parse input xkb file\n"); ERROR("failed to parse input xkb file\n");
return NULL; return NULL;
} }
return compile_keymap(context, file); return compile_keymap(ctx, file);
} }
_X_EXPORT struct xkb_keymap * _X_EXPORT struct xkb_keymap *

View File

@ -250,7 +250,7 @@ typedef struct _XkbFile
} XkbFile; } XkbFile;
extern struct xkb_keymap * extern struct xkb_keymap *
CompileKeymap(struct xkb_context *context, XkbFile *file); CompileKeymap(struct xkb_ctx *ctx, XkbFile *file);
extern bool extern bool
CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap, unsigned merge); CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap, unsigned merge);

View File

@ -30,13 +30,13 @@
int int
main(void) main(void)
{ {
struct xkb_context *context = xkb_context_new(0); struct xkb_ctx *ctx = xkb_ctx_new(0);
assert(context); assert(ctx);
/* FIXME: Test include path stuff. */ /* FIXME: Test include path stuff. */
xkb_context_unref(context); xkb_ctx_unref(ctx);
return 0; return 0;
} }

View File

@ -40,28 +40,28 @@ static int
test_file(const char *path) test_file(const char *path)
{ {
int fd; int fd;
struct xkb_context *context; struct xkb_ctx *ctx;
struct xkb_keymap *keymap; struct xkb_keymap *keymap;
fd = open(path, O_RDONLY); fd = open(path, O_RDONLY);
assert(fd >= 0); assert(fd >= 0);
context = xkb_context_new(0); ctx = xkb_ctx_new(0);
assert(context); assert(ctx);
fprintf(stderr, "\nCompiling path: %s\n", path); fprintf(stderr, "\nCompiling path: %s\n", path);
keymap = xkb_map_new_from_fd(context, fd, XKB_KEYMAP_FORMAT_TEXT_V1, 0); keymap = xkb_map_new_from_fd(ctx, fd, XKB_KEYMAP_FORMAT_TEXT_V1, 0);
close(fd); close(fd);
if (!keymap) { if (!keymap) {
fprintf(stderr, "Failed to compile keymap\n"); fprintf(stderr, "Failed to compile keymap\n");
xkb_context_unref(context); xkb_ctx_unref(ctx);
return 0; return 0;
} }
xkb_map_unref(keymap); xkb_map_unref(keymap);
xkb_context_unref(context); xkb_ctx_unref(ctx);
return 1; return 1;
} }
@ -78,23 +78,22 @@ test_file_name(const char *file_name)
static int static int
test_string(const char *string) test_string(const char *string)
{ {
struct xkb_context *context; struct xkb_ctx *ctx;
struct xkb_keymap *keymap; struct xkb_keymap *keymap;
context = xkb_context_new(0); ctx = xkb_ctx_new(0);
assert(context); assert(ctx);
fprintf(stderr, "\nCompiling string\n"); fprintf(stderr, "\nCompiling string\n");
keymap = xkb_map_new_from_string(context, string, keymap = xkb_map_new_from_string(ctx, string, XKB_KEYMAP_FORMAT_TEXT_V1, 0);
XKB_KEYMAP_FORMAT_TEXT_V1, 0);
if (!keymap) { if (!keymap) {
xkb_context_unref(context); xkb_ctx_unref(ctx);
return 0; return 0;
} }
xkb_map_unref(keymap); xkb_map_unref(keymap);
xkb_context_unref(context); xkb_ctx_unref(ctx);
return 1; return 1;
} }

View File

@ -36,7 +36,7 @@ test_names(const char *keycodes, const char *types,
const char *compat, const char *symbols) const char *compat, const char *symbols)
{ {
int ret = 1; int ret = 1;
struct xkb_context *context; struct xkb_ctx *ctx;
struct xkb_keymap *keymap; struct xkb_keymap *keymap;
struct xkb_component_names kccgst = { struct xkb_component_names kccgst = {
.keymap = NULL, .keymap = NULL,
@ -46,13 +46,13 @@ test_names(const char *keycodes, const char *types,
.symbols = strdup(symbols), .symbols = strdup(symbols),
}; };
context = xkb_context_new(0); ctx = xkb_ctx_new(0);
assert(context); assert(ctx);
fprintf(stderr, "\nCompiling %s %s %s %s\n", kccgst.keycodes, kccgst.types, fprintf(stderr, "\nCompiling %s %s %s %s\n", kccgst.keycodes, kccgst.types,
kccgst.compat, kccgst.symbols); kccgst.compat, kccgst.symbols);
keymap = xkb_map_new_from_kccgst(context, &kccgst, 0); keymap = xkb_map_new_from_kccgst(ctx, &kccgst, 0);
if (!keymap) { if (!keymap) {
ret = 0; ret = 0;
goto err_ctx; goto err_ctx;
@ -60,7 +60,7 @@ test_names(const char *keycodes, const char *types,
xkb_map_unref(keymap); xkb_map_unref(keymap);
err_ctx: err_ctx:
xkb_context_unref(context); xkb_ctx_unref(ctx);
free(kccgst.keycodes); free(kccgst.keycodes);
free(kccgst.types); free(kccgst.types);
free(kccgst.compat); free(kccgst.compat);

View File

@ -33,7 +33,7 @@ static int
test_rmlvo(const char *rules, const char *model, const char *layout, test_rmlvo(const char *rules, const char *model, const char *layout,
const char *variant, const char *options) const char *variant, const char *options)
{ {
struct xkb_context *context; struct xkb_ctx *ctx;
struct xkb_keymap *keymap; struct xkb_keymap *keymap;
struct xkb_rule_names rmlvo = { struct xkb_rule_names rmlvo = {
.rules = rules, .rules = rules,
@ -43,20 +43,20 @@ test_rmlvo(const char *rules, const char *model, const char *layout,
.options = options .options = options
}; };
context = xkb_context_new(0); ctx = xkb_ctx_new(0);
assert(context); assert(ctx);
fprintf(stderr, "\nCompiling %s %s %s %s %s\n", rmlvo.rules, rmlvo.model, fprintf(stderr, "\nCompiling %s %s %s %s %s\n", rmlvo.rules, rmlvo.model,
rmlvo.layout, rmlvo.variant, rmlvo.options); rmlvo.layout, rmlvo.variant, rmlvo.options);
keymap = xkb_map_new_from_names(context, &rmlvo, 0); keymap = xkb_map_new_from_names(ctx, &rmlvo, 0);
if (!keymap) { if (!keymap) {
xkb_context_unref(context); xkb_ctx_unref(ctx);
return 0; return 0;
} }
xkb_map_unref(keymap); xkb_map_unref(keymap);
xkb_context_unref(context); xkb_ctx_unref(ctx);
return 1; return 1;
} }

View File

@ -225,7 +225,7 @@ test_serialisation(struct xkb_keymap *keymap)
int int
main(void) main(void)
{ {
struct xkb_context *context; struct xkb_ctx *ctx;
struct xkb_keymap *keymap; struct xkb_keymap *keymap;
struct xkb_rule_names rmlvo = { struct xkb_rule_names rmlvo = {
.rules = "evdev", .rules = "evdev",
@ -235,15 +235,15 @@ main(void)
.options = NULL, .options = NULL,
}; };
context = xkb_context_new(0); ctx = xkb_ctx_new(0);
assert(context); assert(ctx);
keymap = xkb_map_new_from_names(context, &rmlvo, 0); keymap = xkb_map_new_from_names(ctx, &rmlvo, 0);
assert(keymap); assert(keymap);
test_update_key(keymap); test_update_key(keymap);
test_serialisation(keymap); test_serialisation(keymap);
xkb_map_unref(keymap); xkb_map_unref(keymap);
xkb_context_unref(context); xkb_ctx_unref(ctx);
} }