Move more of xkb_map_new_from_rmlvo into compilation

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
master
Daniel Stone 2012-08-03 03:00:20 +02:00
parent 5cf4f51044
commit 41d97df951
1 changed files with 22 additions and 23 deletions

View File

@ -31,31 +31,45 @@
#define ISEMPTY(str) (!(str) || (strlen(str) == 0)) #define ISEMPTY(str) (!(str) || (strlen(str) == 0))
static XkbFile * static XkbFile *
keymap_file_from_components(struct xkb_context *ctx, keymap_file_from_names(struct xkb_context *ctx,
const struct xkb_component_names *ktcsg) const struct xkb_rule_names *rmlvo)
{ {
struct xkb_component_names *kkctgs;
XkbFile *keycodes, *types, *compat, *symbols; XkbFile *keycodes, *types, *compat, *symbols;
IncludeStmt *inc; IncludeStmt *inc;
inc = IncludeCreate(ctx, ktcsg->keycodes, MERGE_DEFAULT); kkctgs = xkb_components_from_rules(ctx, rmlvo);
if (!kkctgs) {
log_err(ctx, "failed to generate XKB components from rules \"%s\"\n",
rmlvo->rules);
return NULL;
}
inc = IncludeCreate(ctx, kkctgs->keycodes, MERGE_DEFAULT);
keycodes = CreateXKBFile(ctx, FILE_TYPE_KEYCODES, NULL, keycodes = CreateXKBFile(ctx, FILE_TYPE_KEYCODES, NULL,
(ParseCommon *) inc, 0); (ParseCommon *) inc, 0);
inc = IncludeCreate(ctx, ktcsg->types, MERGE_DEFAULT); inc = IncludeCreate(ctx, kkctgs->types, MERGE_DEFAULT);
types = CreateXKBFile(ctx, FILE_TYPE_TYPES, NULL, types = CreateXKBFile(ctx, FILE_TYPE_TYPES, NULL,
(ParseCommon *) inc, 0); (ParseCommon *) inc, 0);
AppendStmt(&keycodes->common, &types->common); AppendStmt(&keycodes->common, &types->common);
inc = IncludeCreate(ctx, ktcsg->compat, MERGE_DEFAULT); inc = IncludeCreate(ctx, kkctgs->compat, MERGE_DEFAULT);
compat = CreateXKBFile(ctx, FILE_TYPE_COMPAT, NULL, compat = CreateXKBFile(ctx, FILE_TYPE_COMPAT, NULL,
(ParseCommon *) inc, 0); (ParseCommon *) inc, 0);
AppendStmt(&keycodes->common, &compat->common); AppendStmt(&keycodes->common, &compat->common);
inc = IncludeCreate(ctx, ktcsg->symbols, MERGE_DEFAULT); inc = IncludeCreate(ctx, kkctgs->symbols, MERGE_DEFAULT);
symbols = CreateXKBFile(ctx, FILE_TYPE_SYMBOLS, NULL, symbols = CreateXKBFile(ctx, FILE_TYPE_SYMBOLS, NULL,
(ParseCommon *) inc, 0); (ParseCommon *) inc, 0);
AppendStmt(&keycodes->common, &symbols->common); AppendStmt(&keycodes->common, &symbols->common);
free(kkctgs->keycodes);
free(kkctgs->types);
free(kkctgs->compat);
free(kkctgs->symbols);
free(kkctgs);
return CreateXKBFile(ctx, FILE_TYPE_KEYMAP, strdup(""), return CreateXKBFile(ctx, FILE_TYPE_KEYMAP, strdup(""),
&keycodes->common, 0); &keycodes->common, 0);
} }
@ -205,7 +219,6 @@ xkb_map_new_from_names(struct xkb_context *ctx,
const struct xkb_rule_names *rmlvo_in, const struct xkb_rule_names *rmlvo_in,
enum xkb_map_compile_flags flags) enum xkb_map_compile_flags flags)
{ {
struct xkb_component_names *kkctgs;
struct xkb_keymap *keymap = NULL; struct xkb_keymap *keymap = NULL;
struct xkb_rule_names rmlvo = *rmlvo_in; struct xkb_rule_names rmlvo = *rmlvo_in;
XkbFile *file; XkbFile *file;
@ -217,29 +230,15 @@ xkb_map_new_from_names(struct xkb_context *ctx,
if (ISEMPTY(rmlvo.layout)) if (ISEMPTY(rmlvo.layout))
rmlvo.layout = DEFAULT_XKB_LAYOUT; rmlvo.layout = DEFAULT_XKB_LAYOUT;
kkctgs = xkb_components_from_rules(ctx, &rmlvo); file = keymap_file_from_names(ctx, &rmlvo);
if (!kkctgs) {
log_err(ctx, "failed to generate XKB components from rules \"%s\"\n",
rmlvo.rules);
return NULL;
}
file = keymap_file_from_components(ctx, kkctgs);
if (!file) { if (!file) {
log_err(ctx, "Failed to generate parsed XKB file from components\n"); log_err(ctx, "Failed to generate parsed XKB file from components\n");
goto out; return NULL;
} }
keymap = compile_keymap(ctx, file); keymap = compile_keymap(ctx, file);
FreeXKBFile(file); FreeXKBFile(file);
out:
free(kkctgs->keycodes);
free(kkctgs->types);
free(kkctgs->compat);
free(kkctgs->symbols);
free(kkctgs);
return keymap; return keymap;
} }