summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2012-08-13 11:00:43 +0300
committerRan Benita <ran234@gmail.com>2012-09-01 10:58:10 +0300
commitcdc228eaf6e55e0dfc524fe62cd1021f2467e3bf (patch)
tree98ced0725cb0d98157f14690680d8565ff897faf
parent3634b1565e00f72fcbde655363b85f8f060d91b5 (diff)
Organize xkbcomp/ header files
Various non-functional changes: - Re-add keycodes.h and move some stuff there. - Add parser-priv.h for internal bison/flex stuff. - Don't include headers from other headers, such that file dependencies are immediate in each file. - Rename xkbcomp.h -> ast.h, parseutils.{c,h} -> ast-build.{c,h} - Rename path.{c,h} -> include.{c,h} - Rename keytypes.c -> types.c - Make the naming of XkbFile-related functions more consistent. - Move xkb_map_{new,ref,unref} to map.c. - Remove most extern keyword from function declarations, it's just noise (XKB_EXPORT is what's important here). - Append XKBCOMP_ to include guards. - Shuffle some code around to make all of this work. Splitting this would be a headache.. Signed-off-by: Ran Benita <ran234@gmail.com>
-rw-r--r--Makefile.am14
-rw-r--r--src/map.c53
-rw-r--r--src/xkb-priv.h3
-rw-r--r--src/xkbcomp/action.c4
-rw-r--r--src/xkbcomp/action.h19
-rw-r--r--src/xkbcomp/ast-build.c (renamed from src/xkbcomp/parseutils.c)92
-rw-r--r--src/xkbcomp/ast-build.h (renamed from src/xkbcomp/parseutils.h)97
-rw-r--r--src/xkbcomp/ast.h (renamed from src/xkbcomp/xkbcomp.h)24
-rw-r--r--src/xkbcomp/compat.c6
-rw-r--r--src/xkbcomp/expr.c2
-rw-r--r--src/xkbcomp/expr.h10
-rw-r--r--src/xkbcomp/include.c (renamed from src/xkbcomp/path.c)28
-rw-r--r--src/xkbcomp/include.h (renamed from src/xkbcomp/path.h)25
-rw-r--r--src/xkbcomp/keycodes.c6
-rw-r--r--src/xkbcomp/keycodes.h65
-rw-r--r--src/xkbcomp/parser-priv.h48
-rw-r--r--src/xkbcomp/parser.y13
-rw-r--r--src/xkbcomp/rules.c5
-rw-r--r--src/xkbcomp/rules.h8
-rw-r--r--src/xkbcomp/scanner.l41
-rw-r--r--src/xkbcomp/symbols.c33
-rw-r--r--src/xkbcomp/types.c (renamed from src/xkbcomp/keytypes.c)6
-rw-r--r--src/xkbcomp/vmod.c3
-rw-r--r--src/xkbcomp/vmod.h15
-rw-r--r--src/xkbcomp/xkbcomp-priv.h76
-rw-r--r--src/xkbcomp/xkbcomp.c138
-rw-r--r--test/rules-file.c4
27 files changed, 448 insertions, 390 deletions
diff --git a/Makefile.am b/Makefile.am
index 48bccca..ed96b66 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -41,24 +41,26 @@ libxkbcommon_la_LDFLAGS = -no-undefined
libxkbcommon_la_SOURCES = \
src/xkbcomp/action.c \
src/xkbcomp/action.h \
+ src/xkbcomp/ast.h \
+ src/xkbcomp/ast-build.c \
+ src/xkbcomp/ast-build.h \
src/xkbcomp/compat.c \
src/xkbcomp/expr.c \
src/xkbcomp/expr.h \
+ src/xkbcomp/include.c \
+ src/xkbcomp/include.h \
src/xkbcomp/keycodes.c \
- src/xkbcomp/keytypes.c \
+ src/xkbcomp/keycodes.h \
src/xkbcomp/parser.y \
- src/xkbcomp/parseutils.c \
- src/xkbcomp/parseutils.h \
- src/xkbcomp/path.c \
- src/xkbcomp/path.h \
+ src/xkbcomp/parser-priv.h \
src/xkbcomp/rules.c \
src/xkbcomp/rules.h \
src/xkbcomp/scanner.l \
src/xkbcomp/symbols.c \
+ src/xkbcomp/types.c \
src/xkbcomp/vmod.c \
src/xkbcomp/vmod.h \
src/xkbcomp/xkbcomp.c \
- src/xkbcomp/xkbcomp.h \
src/xkbcomp/xkbcomp-priv.h \
src/atom.c \
src/atom.h \
diff --git a/src/map.c b/src/map.c
index fa64246..9d65ba7 100644
--- a/src/map.c
+++ b/src/map.c
@@ -52,6 +52,59 @@
#include "xkb-priv.h"
#include "text.h"
+struct xkb_keymap *
+xkb_map_new(struct xkb_context *ctx)
+{
+ struct xkb_keymap *keymap;
+
+ keymap = calloc(1, sizeof(*keymap));
+ if (!keymap)
+ return NULL;
+
+ keymap->refcnt = 1;
+ keymap->ctx = xkb_context_ref(ctx);
+
+ return keymap;
+}
+
+XKB_EXPORT struct xkb_keymap *
+xkb_map_ref(struct xkb_keymap *keymap)
+{
+ keymap->refcnt++;
+ return keymap;
+}
+
+XKB_EXPORT void
+xkb_map_unref(struct xkb_keymap *keymap)
+{
+ unsigned int i;
+ struct xkb_key *key;
+
+ if (!keymap || --keymap->refcnt > 0)
+ return;
+
+ for (i = 0; i < keymap->num_types; i++) {
+ free(keymap->types[i].map);
+ free(keymap->types[i].level_names);
+ }
+ free(keymap->types);
+ darray_foreach(key, keymap->keys) {
+ free(key->sym_index);
+ free(key->num_syms);
+ darray_free(key->syms);
+ free(key->actions);
+ }
+ darray_free(keymap->keys);
+ darray_free(keymap->sym_interpret);
+ darray_free(keymap->key_aliases);
+ free(keymap->keycodes_section_name);
+ free(keymap->symbols_section_name);
+ free(keymap->types_section_name);
+ free(keymap->compat_section_name);
+ xkb_context_unref(keymap->ctx);
+ free(keymap);
+}
+
/**
* Returns the total number of modifiers active in the keymap.
*/
diff --git a/src/xkb-priv.h b/src/xkb-priv.h
index 9c42aeb..f61e2a5 100644
--- a/src/xkb-priv.h
+++ b/src/xkb-priv.h
@@ -438,6 +438,9 @@ XkbKeycodeInRange(struct xkb_keymap *keymap, xkb_keycode_t kc)
return kc >= keymap->min_key_code && kc <= keymap->max_key_code;
}
+struct xkb_keymap *
+xkb_map_new(struct xkb_context *ctx);
+
xkb_atom_t
xkb_atom_intern(struct xkb_context *ctx, const char *string);
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index 0d37688..9aa3c95 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -24,7 +24,11 @@
*
********************************************************/
+#include "xkbcomp-priv.h"
+#include "text.h"
+#include "expr.h"
#include "action.h"
+#include "keycodes.h"
static const ExprDef constTrue = {
.common = { .type = STMT_EXPR, .next = NULL },
diff --git a/src/xkbcomp/action.h b/src/xkbcomp/action.h
index 5cf67d9..f5c9443 100644
--- a/src/xkbcomp/action.h
+++ b/src/xkbcomp/action.h
@@ -24,11 +24,8 @@
*
********************************************************/
-#ifndef ACTION_H
-#define ACTION_H 1
-
-#include "xkbcomp-priv.h"
-#include "expr.h"
+#ifndef XKBCOMP_ACTION_H
+#define XKBCOMP_ACTION_H
#define F_ClearLocks 0
#define F_LatchToLock 1
@@ -66,16 +63,14 @@ typedef struct _ActionInfo {
struct _ActionInfo *next;
} ActionInfo;
-extern int
+int
HandleActionDef(ExprDef *def, struct xkb_keymap *keymap,
- union xkb_action *action,
- ActionInfo *info);
+ union xkb_action *action, ActionInfo *info);
-extern int
+int
SetActionField(struct xkb_keymap *keymap, const char *elem, const char *field,
- ExprDef *index, ExprDef *value,
- ActionInfo **info_rtrn);
+ ExprDef *index, ExprDef *value, ActionInfo **info_rtrn);
extern const LookupEntry ctrlNames[];
-#endif /* ACTION_H */
+#endif
diff --git a/src/xkbcomp/parseutils.c b/src/xkbcomp/ast-build.c
index fb6271d..e785081 100644
--- a/src/xkbcomp/parseutils.c
+++ b/src/xkbcomp/ast-build.c
@@ -24,8 +24,10 @@
*
********************************************************/
-#include "parseutils.h"
-#include "path.h"
+#include "xkbcomp-priv.h"
+#include "ast-build.h"
+#include "parser-priv.h"
+#include "include.h"
ATTR_MALLOC static void *
malloc_or_die(size_t size)
@@ -355,30 +357,6 @@ AppendMultiKeysymList(ExprDef * list, ExprDef * append)
return list;
}
-bool
-LookupKeysym(const char *str, xkb_keysym_t *sym_rtrn)
-{
- xkb_keysym_t sym;
-
- if (!str || istreq(str, "any") || istreq(str, "nosymbol")) {
- *sym_rtrn = XKB_KEY_NoSymbol;
- return 1;
- }
-
- if (istreq(str, "none") || istreq(str, "voidsymbol")) {
- *sym_rtrn = XKB_KEY_VoidSymbol;
- return 1;
- }
-
- sym = xkb_keysym_from_name(str);
- if (sym != XKB_KEY_NoSymbol) {
- *sym_rtrn = sym;
- return 1;
- }
-
- return 0;
-}
-
static void
FreeInclude(IncludeStmt *incl);
@@ -395,7 +373,7 @@ IncludeCreate(struct xkb_context *ctx, char *str, enum merge_mode merge)
stmt = strdup_safe(str);
while (tmp && *tmp)
{
- if (!XkbParseIncludeMap(&tmp, &file, &map, &nextop, &extra_data))
+ if (!ParseIncludeMap(&tmp, &file, &map, &nextop, &extra_data))
goto err;
if (first == NULL) {
@@ -441,30 +419,6 @@ err:
return NULL;
}
-void
-CheckDefaultMap(struct xkb_context *ctx, XkbFile *maps, const char *fileName)
-{
- XkbFile *dflt = NULL, *tmp;
-
- for (tmp = maps; tmp; tmp = (XkbFile *) tmp->common.next) {
- if (!(tmp->flags & XkbLC_Default))
- continue;
- if (!dflt) {
- dflt = tmp;
- continue;
- }
-
- log_lvl(ctx, 3,
- "Multiple default components in %s; "
- "Using %s, ignoring %s\n",
- (fileName ? fileName : "(unknown)"),
- (dflt->name ? dflt->name : "(first)"),
- (tmp->name ? tmp->name : "(subsequent)"));
-
- tmp->flags &= (~XkbLC_Default);
- }
-}
-
/*
* All latin-1 alphanumerics, plus parens, slash, minus, underscore and
* wildcards.
@@ -490,7 +444,7 @@ EnsureSafeMapName(char *name)
}
XkbFile *
-CreateXKBFile(struct xkb_context *ctx, enum xkb_file_type type, char *name,
+XkbFileCreate(struct xkb_context *ctx, enum xkb_file_type type, char *name,
ParseCommon *defs, unsigned flags)
{
XkbFile *file;
@@ -509,6 +463,36 @@ CreateXKBFile(struct xkb_context *ctx, enum xkb_file_type type, char *name,
return file;
}
+XkbFile *
+XkbFileFromComponents(struct xkb_context *ctx,
+ struct xkb_component_names *kkctgs)
+{
+ IncludeStmt *inc;
+ XkbFile *keycodes, *types, *compat, *symbols;
+
+ inc = IncludeCreate(ctx, kkctgs->keycodes, MERGE_DEFAULT);
+ keycodes = XkbFileCreate(ctx, FILE_TYPE_KEYCODES, NULL,
+ (ParseCommon *) inc, 0);
+
+ inc = IncludeCreate(ctx, kkctgs->types, MERGE_DEFAULT);
+ types = XkbFileCreate(ctx, FILE_TYPE_TYPES, NULL,
+ (ParseCommon *) inc, 0);
+ AppendStmt(&keycodes->common, &types->common);
+
+ inc = IncludeCreate(ctx, kkctgs->compat, MERGE_DEFAULT);
+ compat = XkbFileCreate(ctx, FILE_TYPE_COMPAT, NULL,
+ (ParseCommon *) inc, 0);
+ AppendStmt(&keycodes->common, &compat->common);
+
+ inc = IncludeCreate(ctx, kkctgs->symbols, MERGE_DEFAULT);
+ symbols = XkbFileCreate(ctx, FILE_TYPE_SYMBOLS, NULL,
+ (ParseCommon *) inc, 0);
+ AppendStmt(&keycodes->common, &symbols->common);
+
+ return XkbFileCreate(ctx, FILE_TYPE_KEYMAP, strdup(""),
+ &keycodes->common, 0);
+}
+
static void
FreeExpr(ExprDef *expr)
{
@@ -635,7 +619,7 @@ FreeStmt(ParseCommon *stmt)
}
void
-FreeXKBFile(XkbFile *file)
+FreeXkbFile(XkbFile *file)
{
XkbFile *next;
@@ -645,7 +629,7 @@ FreeXKBFile(XkbFile *file)
switch (file->file_type) {
case FILE_TYPE_KEYMAP:
- FreeXKBFile((XkbFile *) file->defs);
+ FreeXkbFile((XkbFile *) file->defs);
break;
case FILE_TYPE_TYPES:
diff --git a/src/xkbcomp/parseutils.h b/src/xkbcomp/ast-build.h
index 73db3d8..ec5ef38 100644
--- a/src/xkbcomp/parseutils.h
+++ b/src/xkbcomp/ast-build.h
@@ -24,122 +24,81 @@
*
********************************************************/
-#ifndef PARSEUTILS_H
-#define PARSEUTILS_H
+#ifndef XKBCOMP_AST_BUILD_H
+#define XKBCOMP_AST_BUILD_H
-#include <stdio.h>
-
-#include "xkbcomp-priv.h"
-
-struct parser_param {
- struct xkb_context *ctx;
- void *scanner;
- XkbFile *rtrn;
-};
-
-#include "parser.h"
-
-struct scanner_extra {
- struct xkb_context *ctx;
- char *scanFile;
- char scanBuf[1024];
- char *s;
-};
-
-extern ParseCommon *
+ParseCommon *
AppendStmt(ParseCommon *to, ParseCommon *append);
-extern ExprDef *
+ExprDef *
ExprCreate(enum expr_op_type op, enum expr_value_type type);
-extern ExprDef *
+ExprDef *
ExprCreateUnary(enum expr_op_type op, enum expr_value_type type,
ExprDef *child);
-extern ExprDef *
+ExprDef *
ExprCreateBinary(enum expr_op_type op, ExprDef *left, ExprDef *right);
KeycodeDef *
KeycodeCreate(char keyName[XkbKeyNameLength], unsigned long value);
-extern KeyAliasDef *
+KeyAliasDef *
KeyAliasCreate(char keyName[XkbKeyNameLength], char real[XkbKeyNameLength]);
-extern VModDef *
+VModDef *
VModCreate(xkb_atom_t name, ExprDef *value);
-extern VarDef *
+VarDef *
VarCreate(ExprDef *name, ExprDef *value);
-extern VarDef *
+VarDef *
BoolVarCreate(xkb_atom_t nameToken, unsigned set);
-extern InterpDef *
+InterpDef *
InterpCreate(char *sym, ExprDef *match);
-extern KeyTypeDef *
+KeyTypeDef *
KeyTypeCreate(xkb_atom_t name, VarDef *body);
-extern SymbolsDef *
+SymbolsDef *
SymbolsCreate(char keyName[XkbKeyNameLength], ExprDef *symbols);
-extern GroupCompatDef *
+GroupCompatDef *
GroupCompatCreate(int group, ExprDef *def);
-extern ModMapDef *
+ModMapDef *
ModMapCreate(uint32_t modifier, ExprDef *keys);
-extern IndicatorMapDef *
+IndicatorMapDef *
IndicatorMapCreate(xkb_atom_t name, VarDef *body);
-extern IndicatorNameDef *
+IndicatorNameDef *
IndicatorNameCreate(int ndx, ExprDef *name, bool virtual);
-extern ExprDef *
+ExprDef *
ActionCreate(xkb_atom_t name, ExprDef *args);
-extern ExprDef *
+ExprDef *
CreateMultiKeysymList(ExprDef *list);
-extern ExprDef *
+ExprDef *
CreateKeysymList(char *sym);
-extern ExprDef *
+ExprDef *
AppendMultiKeysymList(ExprDef *list, ExprDef *append);
-extern ExprDef *
+ExprDef *
AppendKeysymList(ExprDef *list, char *sym);
-bool
-LookupKeysym(const char *str, xkb_keysym_t *sym_rtrn);
-
-extern IncludeStmt *
+IncludeStmt *
IncludeCreate(struct xkb_context *ctx, char *str, enum merge_mode merge);
-extern void
-CheckDefaultMap(struct xkb_context *ctx, XkbFile *maps, const char *fileName);
-
-extern XkbFile *
-CreateXKBFile(struct xkb_context *ctx, enum xkb_file_type type, char *name,
- ParseCommon *defs,
- unsigned flags);
-
-extern bool
-XKBParseFile(struct xkb_context *ctx, FILE *file, const char *file_name,
- XkbFile **out);
-
-extern bool
-XKBParseString(struct xkb_context *context, const char *string,
- const char *file_name,
- XkbFile **out);
-
-extern void
-FreeXKBFile(XkbFile *file);
-
-extern void
-FreeStmt(ParseCommon *stmt);
+XkbFile *
+XkbFileCreate(struct xkb_context *ctx, enum xkb_file_type type, char *name,
+ ParseCommon *defs, unsigned flags);
void
-scanner_error(struct YYLTYPE *loc, void *scanner, const char *msg);
+FreeStmt(ParseCommon *stmt);
-#endif /* PARSEUTILS_H */
+#endif
diff --git a/src/xkbcomp/xkbcomp.h b/src/xkbcomp/ast.h
index b74d1c6..85741db 100644
--- a/src/xkbcomp/xkbcomp.h
+++ b/src/xkbcomp/ast.h
@@ -24,10 +24,8 @@
*
********************************************************/
-#ifndef XKBCOMP_H
-#define XKBCOMP_H 1
-
-#include "xkb-priv.h"
+#ifndef XKBCOMP_AST_H
+#define XKBCOMP_AST_H
enum stmt_type {
STMT_UNKNOWN = 0,
@@ -222,20 +220,4 @@ typedef struct _XkbFile {
unsigned flags;
} XkbFile;
-extern bool
-CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap,
- enum merge_mode merge);
-
-extern bool
-CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap,
- enum merge_mode merge);
-
-extern bool
-CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap,
- enum merge_mode merge);
-
-extern bool
-CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
- enum merge_mode merge);
-
-#endif /* XKBCOMP_H */
+#endif
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index b00f64a..e8f394b 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -25,9 +25,11 @@
********************************************************/
#include "xkbcomp-priv.h"
-#include "parseutils.h"
+#include "text.h"
+#include "expr.h"
#include "action.h"
#include "vmod.h"
+#include "include.h"
enum si_field {
SI_FIELD_VIRTUAL_MOD = (1 << 0),
@@ -607,7 +609,7 @@ HandleIncludeCompatMap(CompatInfo *info, IncludeStmt *stmt)
next_incl.act = NULL;
ClearCompatInfo(&next_incl);
- FreeXKBFile(rtrn);
+ FreeXkbFile(rtrn);
}
MergeIncludedCompatMaps(info, &included, merge);
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index aaeba28..98b32eb 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -24,6 +24,8 @@
*
********************************************************/
+#include "xkbcomp-priv.h"
+#include "text.h"
#include "expr.h"
typedef bool (*IdentLookupFunc)(struct xkb_context *ctx, const void *priv,
diff --git a/src/xkbcomp/expr.h b/src/xkbcomp/expr.h
index 7a2bf78..2771614 100644
--- a/src/xkbcomp/expr.h
+++ b/src/xkbcomp/expr.h
@@ -24,17 +24,15 @@
*
********************************************************/
-#ifndef EXPR_H
-#define EXPR_H 1
-
-#include "xkbcomp-priv.h"
+#ifndef XKBCOMP_EXPR_H
+#define XKBCOMP_EXPR_H
typedef struct _LookupEntry {
const char *name;
unsigned int value;
} LookupEntry;
-extern const char *
+const char *
exprOpText(enum expr_op_type op);
bool
@@ -106,4 +104,4 @@ bool
ExprResolveKeySym(struct xkb_context *ctx, const ExprDef *expr,
xkb_keysym_t *sym_rtrn);
-#endif /* EXPR_H */
+#endif
diff --git a/src/xkbcomp/path.c b/src/xkbcomp/include.c
index 5089f2c..a7a8bbc 100644
--- a/src/xkbcomp/path.c
+++ b/src/xkbcomp/include.c
@@ -26,9 +26,11 @@
#include <errno.h>
#include <limits.h>
+#include <stdio.h>
-#include "path.h"
-#include "parseutils.h"
+#include "xkbcomp-priv.h"
+#include "text.h"
+#include "include.h"
/**
* Extract the first token from an include statement.
@@ -57,8 +59,8 @@
*
*/
bool
-XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
- char *nextop_rtrn, char **extra_data)
+ParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
+ char *nextop_rtrn, char **extra_data)
{
char *tmp, *str, *next;
@@ -124,8 +126,8 @@ XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
/**
* Return the xkb directory based on the type.
*/
-const char *
-XkbDirectoryForInclude(enum xkb_file_type type)
+static const char *
+DirectoryForInclude(enum xkb_file_type type)
{
switch (type) {
case FILE_TYPE_KEYMAP:
@@ -168,7 +170,7 @@ XkbDirectoryForInclude(enum xkb_file_type type)
* pathRtrn is undefined.
*/
FILE *
-XkbFindFileInPath(struct xkb_context *ctx, const char *name,
+FindFileInXkbPath(struct xkb_context *ctx, const char *name,
enum xkb_file_type type, char **pathRtrn)
{
size_t i;
@@ -177,7 +179,7 @@ XkbFindFileInPath(struct xkb_context *ctx, const char *name,
char buf[PATH_MAX];
const char *typeDir;
- typeDir = XkbDirectoryForInclude(type);
+ typeDir = DirectoryForInclude(type);
for (i = 0; i < xkb_context_num_include_paths(ctx); i++) {
ret = snprintf(buf, sizeof(buf), "%s/%s/%s",
xkb_context_include_path_get(ctx, i), typeDir, name);
@@ -223,14 +225,14 @@ ProcessIncludeFile(struct xkb_context *ctx,
FILE *file;
XkbFile *rtrn, *mapToUse, *next;
- file = XkbFindFileInPath(ctx, stmt->file, file_type, NULL);
+ file = FindFileInXkbPath(ctx, stmt->file, file_type, NULL);
if (file == NULL) {
log_err(ctx, "Can't find file \"%s\" for %s include\n", stmt->file,
- XkbDirectoryForInclude(file_type));
+ DirectoryForInclude(file_type));
return false;
}
- if (!XKBParseFile(ctx, file, stmt->file, &rtrn)) {
+ if (!XkbParseFile(ctx, file, stmt->file, &rtrn)) {
log_err(ctx, "Error interpreting include file \"%s\"\n", stmt->file);
fclose(file);
return false;
@@ -245,11 +247,11 @@ ProcessIncludeFile(struct xkb_context *ctx,
mapToUse->common.next = NULL;
if (streq(mapToUse->name, stmt->map) &&
mapToUse->file_type == file_type) {
- FreeXKBFile(next);
+ FreeXkbFile(next);
break;
}
else {
- FreeXKBFile(mapToUse);
+ FreeXkbFile(mapToUse);
}
mapToUse = next;
}
diff --git a/src/xkbcomp/path.h b/src/xkbcomp/include.h
index be1a9cf..9ba0b55 100644
--- a/src/xkbcomp/path.h
+++ b/src/xkbcomp/include.h
@@ -24,23 +24,20 @@
*
********************************************************/
-#ifndef XKBCOMP_PATH_H
-#define XKBCOMP_PATH_H
-
-#include <stdio.h>
-
-#include "xkbcomp-priv.h"
+#ifndef XKBCOMP_INCLUDE_H
+#define XKBCOMP_INCLUDE_H
bool
-XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
- char *nextop_rtrn,
- char **extra_data);
-
-const char *
-XkbDirectoryForInclude(enum xkb_file_type type);
+ParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
+ char *nextop_rtrn, char **extra_data);
FILE *
-XkbFindFileInPath(struct xkb_context *ctx, const char *name,
+FindFileInXkbPath(struct xkb_context *ctx, const char *name,
enum xkb_file_type type, char **pathRtrn);
-#endif /* XKBCOMP_PATH_H */
+bool
+ProcessIncludeFile(struct xkb_context *ctx, IncludeStmt *stmt,
+ enum xkb_file_type file_type, XkbFile **file_rtrn,
+ enum merge_mode *merge_rtrn);
+
+#endif
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index 57d73a0..c3be7ff 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -25,8 +25,10 @@
********************************************************/
#include "xkbcomp-priv.h"
+#include "text.h"
#include "expr.h"
-#include "parseutils.h"
+#include "keycodes.h"
+#include "include.h"
/*
* The xkb_keycodes section
@@ -563,7 +565,7 @@ HandleIncludeKeycodes(KeyNamesInfo *info, IncludeStmt *stmt)
MergeIncludedKeycodes(&included, &next_incl, merge);
ClearKeyNamesInfo(&next_incl);
- FreeXKBFile(rtrn);
+ FreeXkbFile(rtrn);
}
MergeIncludedKeycodes(info, &included, merge);
diff --git a/src/xkbcomp/keycodes.h b/src/xkbcomp/keycodes.h
new file mode 100644
index 0000000..cb75250
--- /dev/null
+++ b/src/xkbcomp/keycodes.h
@@ -0,0 +1,65 @@
+/************************************************************
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ ********************************************************/
+
+#ifndef XKBCOMP_KEYCODES_H
+#define XKBCOMP_KEYCODES_H
+
+static inline unsigned long
+KeyNameToLong(const char name[XkbKeyNameLength])
+{
+ return
+ (((unsigned long)name[0]) << 24) |
+ (((unsigned long)name[1]) << 16) |
+ (((unsigned long)name[2]) << 8) |
+ (((unsigned long)name[3]) << 0);
+}
+
+static inline void
+LongToKeyName(unsigned long val, char name[XkbKeyNameLength])
+{
+ name[0] = ((val >> 24) & 0xff);
+ name[1] = ((val >> 16) & 0xff);
+ name[2] = ((val >> 8) & 0xff);
+ name[3] = ((val >> 0) & 0xff);
+}
+
+static inline const char *
+LongKeyNameText(unsigned long val)
+{
+ char buf[XkbKeyNameLength];
+ LongToKeyName(val, buf);
+ return KeyNameText(buf);
+}
+
+struct xkb_key *
+FindNamedKey(struct xkb_keymap *keymap, unsigned long name,
+ bool use_aliases, xkb_keycode_t start_from);
+
+bool
+FindKeyNameForAlias(struct xkb_keymap *keymap, unsigned long lname,
+ unsigned long *real_name);
+
+#endif
diff --git a/src/xkbcomp/parser-priv.h b/src/xkbcomp/parser-priv.h
new file mode 100644
index 0000000..17db6ed
--- /dev/null
+++ b/src/xkbcomp/parser-priv.h
@@ -0,0 +1,48 @@
+/************************************************************
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ ********************************************************/
+
+#ifndef XKBCOMP_PARSER_PRIV_H
+#define XKBCOMP_PARSER_PRIV_H
+
+#pragma GCC diagnostic ignored "-Wredundant-decls"
+
+struct scanner_extra;
+
+struct parser_param {
+ struct xkb_context *ctx;
+ void *scanner;
+ XkbFile *rtrn;
+};
+
+#include "parser.h"
+
+void
+scanner_error(YYLTYPE *loc, void *scanner, const char *msg);
+
+int
+yylex(YYSTYPE *val, YYLTYPE *loc, void *scanner);
+
+#endif
diff --git a/src/xkbcomp/parser.y b/src/xkbcomp/parser.y
index 5d8e080..b038371 100644
--- a/src/xkbcomp/parser.y
+++ b/src/xkbcomp/parser.y
@@ -26,11 +26,8 @@
%{
#include "xkbcomp-priv.h"
-#include "parseutils.h"
-
-#pragma GCC diagnostic ignored "-Wredundant-decls"
-
-extern int yylex(union YYSTYPE *val, struct YYLTYPE *loc, void *scanner);
+#include "ast-build.h"
+#include "parser-priv.h"
static void
yyerror(struct YYLTYPE *loc, struct parser_param *param, const char *msg)
@@ -193,7 +190,7 @@ XkbCompMapList : XkbCompMapList XkbCompositeMap
XkbCompositeMap : OptFlags XkbCompositeType OptMapName OBRACE
XkbMapConfigList
CBRACE SEMI
- { $$ = CreateXKBFile(param->ctx, $2, $3, &$5->common, $1); }
+ { $$ = XkbFileCreate(param->ctx, $2, $3, &$5->common, $1); }
;
XkbCompositeType: XKB_KEYMAP { $$ = FILE_TYPE_KEYMAP; }
@@ -222,7 +219,7 @@ XkbMapConfig : OptFlags FileType OptMapName OBRACE
$$ = NULL;
}
else {
- $$ = CreateXKBFile(param->ctx, $2, $3, $5, $1);
+ $$ = XkbFileCreate(param->ctx, $2, $3, $5, $1);
}
}
;
@@ -235,7 +232,7 @@ XkbConfig : OptFlags FileType OptMapName DeclList
$$ = NULL;
}
else {
- $$ = CreateXKBFile(param->ctx, $2, $3, $4, $1);
+ $$ = XkbFileCreate(param->ctx, $2, $3, $4, $1);
}
}
;
diff --git a/src/xkbcomp/rules.c b/src/xkbcomp/rules.c
index 02d7b23..a1a0da1 100644
--- a/src/xkbcomp/rules.c
+++ b/src/xkbcomp/rules.c
@@ -32,8 +32,9 @@
#include <sys/stat.h>
#include <sys/types.h>
+#include "xkbcomp-priv.h"
#include "rules.h"
-#include "path.h"
+#include "include.h"
static const char *
input_line_get(struct xkb_context *ctx, const char *buf, const char *end,
@@ -1089,7 +1090,7 @@ xkb_components_from_rules(struct xkb_context *ctx,
char *path;
char **include;
- file = XkbFindFileInPath(ctx, rmlvo->rules, FILE_TYPE_RULES, &path);
+ file = FindFileInXkbPath(ctx, rmlvo->rules, FILE_TYPE_RULES, &path);
if (!file) {
log_err(ctx, "Could not find \"%s\" rules in XKB path\n",
rmlvo->rules);
diff --git a/src/xkbcomp/rules.h b/src/xkbcomp/rules.h
index 0567a7b..9e73c3e 100644
--- a/src/xkbcomp/rules.h
+++ b/src/xkbcomp/rules.h
@@ -24,14 +24,12 @@
* authorization from the authors.
*/
-#ifndef RULES_H
-#define RULES_H
-
-#include "xkbcomp-priv.h"
+#ifndef XKBCOMP_RULES_H
+#define XKBCOMP_RULES_H
bool
xkb_components_from_rules(struct xkb_context *ctx,
const struct xkb_rule_names *rmlvo,
struct xkb_component_names *out);
-#endif /* RULES_H */
+#endif
diff --git a/src/xkbcomp/scanner.l b/src/xkbcomp/scanner.l
index d60515b..6dfa28b 100644
--- a/src/xkbcomp/scanner.l
+++ b/src/xkbcomp/scanner.l
@@ -25,15 +25,17 @@
********************************************************/
%{
-#include <stdio.h>
-
#include "xkbcomp-priv.h"
-#include "parseutils.h"
+#include "parser-priv.h"
-#pragma GCC diagnostic ignored "-Wredundant-decls"
#pragma GCC diagnostic ignored "-Wmissing-noreturn"
-extern int yyparse(struct parser_param *param);
+struct scanner_extra {
+ struct xkb_context *ctx;
+ char *scanFile;
+ char scanBuf[1024];
+ char *s;
+};
static void
scanner_error_extra(struct YYLTYPE *loc, struct scanner_extra *extra,
@@ -226,8 +228,33 @@ scanner_error(struct YYLTYPE *loc, void *scanner, const char *msg)
scanner_error_extra(loc, extra, msg);
}
+static void
+CheckDefaultMap(struct xkb_context *ctx, XkbFile *maps, const char *fileName)
+{
+ XkbFile *dflt = NULL, *tmp;
+
+ for (tmp = maps; tmp; tmp = (XkbFile *) tmp->common.next) {
+ if (!(tmp->flags & XkbLC_Default))
+ continue;
+
+ if (!dflt) {
+ dflt = tmp;
+ continue;
+ }
+
+ log_lvl(ctx, 3,
+ "Multiple default components in %s; "
+ "Using %s, ignoring %s\n",
+ (fileName ? fileName : "(unknown)"),
+ (dflt->name ? dflt->name : "(first)"),
+ (tmp->name ? tmp->name : "(subsequent)"));
+
+ tmp->flags &= (~XkbLC_Default);
+ }
+}
+
bool
-XKBParseString(struct xkb_context *ctx, const char *string,
+XkbParseString(struct xkb_context *ctx, const char *string,
const char *file_name, XkbFile **out)
{
int ret;
@@ -265,7 +292,7 @@ XKBParseString(struct xkb_context *ctx, const char *string,
}
bool
-XKBParseFile(struct xkb_context *ctx, FILE *file,
+XkbParseFile(struct xkb_context *ctx, FILE *file,
const char *file_name, XkbFile **out)
{
int ret;
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index bd1bfdc..b978deb 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -25,11 +25,12 @@
********************************************************/
#include "xkbcomp-priv.h"
-#include "parseutils.h"
+#include "text.h"
+#include "expr.h"
#include "action.h"
#include "vmod.h"
-
-/***====================================================================***/
+#include "keycodes.h"
+#include "include.h"
/* Needed to work with the typechecker. */
typedef darray(xkb_keysym_t) darray_xkb_keysym_t;
@@ -772,7 +773,7 @@ HandleIncludeSymbols(SymbolsInfo *info, IncludeStmt *stmt)
MergeIncludedSymbols(&included, &next_incl, merge);
FreeSymbolsInfo(&next_incl);
- FreeXKBFile(rtrn);
+ FreeXkbFile(rtrn);
}
MergeIncludedSymbols(info, &included, merge);
@@ -829,6 +830,30 @@ GetGroupIndex(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
return true;
}
+bool
+LookupKeysym(const char *str, xkb_keysym_t *sym_rtrn)
+{
+ xkb_keysym_t sym;
+
+ if (!str || istreq(str, "any") || istreq(str, "nosymbol")) {
+ *sym_rtrn = XKB_KEY_NoSymbol;
+ return 1;
+ }
+
+ if (istreq(str, "none") || istreq(str, "voidsymbol")) {
+ *sym_rtrn = XKB_KEY_VoidSymbol;
+ return 1;
+ }
+
+ sym = xkb_keysym_from_name(str);
+ if (sym != XKB_KEY_NoSymbol) {
+ *sym_rtrn = sym;
+ return 1;
+ }
+
+ return 0;
+}
+
static bool
AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
ExprDef *value)
diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/types.c
index 45015ea..8b60f61 100644
--- a/src/xkbcomp/keytypes.c
+++ b/src/xkbcomp/types.c
@@ -25,8 +25,10 @@
********************************************************/
#include "xkbcomp-priv.h"
-#include "parseutils.h"
+#include "text.h"
#include "vmod.h"
+#include "expr.h"
+#include "include.h"
/*
* The xkb_types section
@@ -368,7 +370,7 @@ HandleIncludeKeyTypes(KeyTypesInfo *info, IncludeStmt *stmt)
MergeIncludedKeyTypes(&included, &next_incl, merge);
FreeKeyTypesInfo(&next_incl);
- FreeXKBFile(rtrn);
+ FreeXkbFile(rtrn);
}
MergeIncludedKeyTypes(info, &included, merge);
diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c
index 72ec199..3560d70 100644
--- a/src/xkbcomp/vmod.c
+++ b/src/xkbcomp/vmod.c
@@ -24,6 +24,9 @@
*
********************************************************/
+#include "xkbcomp-priv.h"
+#include "text.h"
+#include "expr.h"
#include "vmod.h"
void
diff --git a/src/xkbcomp/vmod.h b/src/xkbcomp/vmod.h
index 070ff69..5748d01 100644
--- a/src/xkbcomp/vmod.h
+++ b/src/xkbcomp/vmod.h
@@ -24,24 +24,21 @@
*
********************************************************/
-#ifndef VMOD_H
-#define VMOD_H 1
-
-#include "xkbcomp-priv.h"
-#include "expr.h"
+#ifndef XKBCOMP_VMOD_H
+#define XKBCOMP_VMOD_H
typedef struct _VModInfo {
xkb_mod_mask_t defined;
xkb_mod_mask_t available;
} VModInfo;
-extern void
+void
InitVModInfo(VModInfo *info, struct xkb_keymap *keymap);
-extern void
+void
ClearVModInfo(VModInfo *info, struct xkb_keymap *keymap);
-extern bool
+bool
HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
enum merge_mode mergeMode, VModInfo *info);
@@ -49,4 +46,4 @@ bool
ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *keymap,
xkb_mod_index_t *ndx_rtrn, VModInfo *info);
-#endif /* VMOD_H */
+#endif
diff --git a/src/xkbcomp/xkbcomp-priv.h b/src/xkbcomp/xkbcomp-priv.h
index 33e9671..256307a 100644
--- a/src/xkbcomp/xkbcomp-priv.h
+++ b/src/xkbcomp/xkbcomp-priv.h
@@ -27,54 +27,50 @@
#ifndef XKBCOMP_PRIV_H
#define XKBCOMP_PRIV_H
-#include "xkbcomp.h"
-#include "text.h"
+#include "xkb-priv.h"
+#include "ast.h"
-extern bool
-ProcessIncludeFile(struct xkb_context *ctx, IncludeStmt *stmt,
- enum xkb_file_type file_type, XkbFile **file_rtrn,
- enum merge_mode *merge_rtrn);
+bool
+XkbParseFile(struct xkb_context *ctx, FILE *file, const char *file_name,
+ XkbFile **out);
-struct xkb_key *
-FindNamedKey(struct xkb_keymap *keymap, unsigned long name,
- bool use_aliases, xkb_keycode_t start_from);
+bool
+XkbParseString(struct xkb_context *context, const char *string,
+ const char *file_name, XkbFile **out);
-extern bool
-FindKeyNameForAlias(struct xkb_keymap *keymap, unsigned long lname,
- unsigned long *real_name);
+void
+FreeXkbFile(XkbFile *file);
-extern bool
+XkbFile *
+XkbFileFromComponents(struct xkb_context *ctx,
+ struct xkb_component_names *kkctgs);
+
+bool
+CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap,
+ enum merge_mode merge);
+
+bool
+CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap,
+ enum merge_mode merge);
+
+bool
+CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap,
+ enum merge_mode merge);
+
+bool
+CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
+ enum merge_mode merge);
+
+bool
UpdateModifiersFromCompat(struct xkb_keymap *keymap);
+bool
+LookupKeysym(const char *str, xkb_keysym_t *sym_rtrn);
+
const char *
StmtTypeToString(enum stmt_type type);
-static inline unsigned long
-KeyNameToLong(const char name[XkbKeyNameLength])
-{
- return
- (((unsigned long)name[0]) << 24) |
- (((unsigned long)name[1]) << 16) |
- (((unsigned long)name[2]) << 8) |
- (((unsigned long)name[3]) << 0);
-}
-
-static inline void
-LongToKeyName(unsigned long val, char name[XkbKeyNameLength])
-{
- name[0] = ((val >> 24) & 0xff);
- name[1] = ((val >> 16) & 0xff);
- name[2] = ((val >> 8) & 0xff);
- name[3] = ((val >> 0) & 0xff);
-}
-
-static inline const char *
-LongKeyNameText(unsigned long val)
-{
- char buf[XkbKeyNameLength];
- LongToKeyName(val, buf);
- return KeyNameText(buf);
-}
+/***====================================================================***/
static inline bool
ReportNotArray(struct xkb_keymap *keymap, const char *type, const char *field,
@@ -119,4 +115,4 @@ ReportBadField(struct xkb_keymap *keymap, const char *type, const char *field,
return false;
}
-#endif /* XKBCOMP_PRIV_H */
+#endif
diff --git a/src/xkbcomp/xkbcomp.c b/src/xkbcomp/xkbcomp.c
index 35e0ee1..a65550a 100644
--- a/src/xkbcomp/xkbcomp.c
+++ b/src/xkbcomp/xkbcomp.c
@@ -25,68 +25,8 @@
*/
#include "xkbcomp-priv.h"
+#include "text.h"
#include "rules.h"
-#include "parseutils.h"
-
-static XkbFile *
-keymap_file_from_names(struct xkb_context *ctx,
- const struct xkb_rule_names *rmlvo)
-{
- struct xkb_component_names kkctgs;
- XkbFile *keycodes, *types, *compat, *symbols;
- IncludeStmt *inc;
-
- if (!xkb_components_from_rules(ctx, rmlvo, &kkctgs)) {
- log_err(ctx,
- "Couldn't look up rules '%s', model '%s', layout '%s', "
- "variant '%s', options '%s'\n",
- rmlvo->rules, rmlvo->model, rmlvo->layout, rmlvo->variant,
- rmlvo->options);
- return NULL;
- }
-
- inc = IncludeCreate(ctx, kkctgs.keycodes, MERGE_DEFAULT);
- keycodes = CreateXKBFile(ctx, FILE_TYPE_KEYCODES, NULL,
- (ParseCommon *) inc, 0);
-
- inc = IncludeCreate(ctx, kkctgs.types, MERGE_DEFAULT);
- types = CreateXKBFile(ctx, FILE_TYPE_TYPES, NULL,
- (ParseCommon *) inc, 0);
- AppendStmt(&keycodes->common, &types->common);
-
- inc = IncludeCreate(ctx, kkctgs.compat, MERGE_DEFAULT);
- compat = CreateXKBFile(ctx, FILE_TYPE_COMPAT, NULL,
- (ParseCommon *) inc, 0);
- AppendStmt(&keycodes->common, &compat->common);
-
- inc = IncludeCreate(ctx, kkctgs.symbols, MERGE_DEFAULT);
- symbols = CreateXKBFile(ctx, FILE_TYPE_SYMBOLS, NULL,
- (ParseCommon *) inc, 0);
- AppendStmt(&keycodes->common, &symbols->common);
-
- free(kkctgs.keycodes);
- free(kkctgs.types);
- free(kkctgs.compat);
- free(kkctgs.symbols);
-
- return CreateXKBFile(ctx, FILE_TYPE_KEYMAP, strdup(""),
- &keycodes->common, 0);
-}
-
-static struct xkb_keymap *
-new_keymap(struct xkb_context *ctx)
-{
- struct xkb_keymap *keymap;
-
- keymap = calloc(1, sizeof(*keymap));
- if (!keymap)
- return NULL;
-
- keymap->refcnt = 1;
- keymap->ctx = xkb_context_ref(ctx);
-
- return keymap;
-}
/**
* Compile the given file and store the output in keymap.
@@ -105,7 +45,7 @@ compile_keymap(struct xkb_context *ctx, XkbFile *file)
XkbFile *compat = NULL;
XkbFile *symbols = NULL;
- keymap = new_keymap(ctx);
+ keymap = xkb_map_new(ctx);
if (!keymap)
goto err;
@@ -218,6 +158,8 @@ xkb_map_new_from_names(struct xkb_context *ctx,
const struct xkb_rule_names *rmlvo_in,
enum xkb_map_compile_flags flags)
{
+ bool ok;
+ struct xkb_component_names kccgst;
struct xkb_rule_names rmlvo = *rmlvo_in;
XkbFile *file;
struct xkb_keymap *keymap;
@@ -229,7 +171,23 @@ xkb_map_new_from_names(struct xkb_context *ctx,
if (isempty(rmlvo.layout))
rmlvo.layout = DEFAULT_XKB_LAYOUT;
- file = keymap_file_from_names(ctx, &rmlvo);
+ ok = xkb_components_from_rules(ctx, &rmlvo, &kccgst);
+ if (!ok) {
+ log_err(ctx,
+ "Couldn't look up rules '%s', model '%s', layout '%s', "
+ "variant '%s', options '%s'\n",
+ rmlvo.rules, rmlvo.model, rmlvo.layout, rmlvo.variant,
+ rmlvo.options);
+ return NULL;
+ }
+
+ file = XkbFileFromComponents(ctx, &kccgst);
+
+ free(kccgst.keycodes);
+ free(kccgst.types);
+ free(kccgst.compat);
+ free(kccgst.symbols);
+
if (!file) {
log_err(ctx,
"Failed to generate parsed XKB file from components\n");
@@ -237,7 +195,7 @@ xkb_map_new_from_names(struct xkb_context *ctx,
}
keymap = compile_keymap(ctx, file);
- FreeXKBFile(file);
+ FreeXkbFile(file);
return keymap;
}
@@ -261,14 +219,14 @@ xkb_map_new_from_string(struct xkb_context *ctx,
return NULL;
}
- ok = XKBParseString(ctx, string, "input", &file);
+ ok = XkbParseString(ctx, string, "input", &file);
if (!ok) {
log_err(ctx, "Failed to parse input xkb file\n");
return NULL;
}
keymap = compile_keymap(ctx, file);
- FreeXKBFile(file);
+ FreeXkbFile(file);
return keymap;
}
@@ -292,57 +250,13 @@ xkb_map_new_from_file(struct xkb_context *ctx,
return NULL;
}
- ok = XKBParseFile(ctx, file, "(unknown file)", &xkb_file);
+ ok = XkbParseFile(ctx, file, "(unknown file)", &xkb_file);
if (!ok) {
log_err(ctx, "Failed to parse input xkb file\n");
return NULL;
}
keymap = compile_keymap(ctx, xkb_file);
- FreeXKBFile(xkb_file);
- return keymap;
-}
-
-XKB_EXPORT struct xkb_keymap *
-xkb_map_ref(struct xkb_keymap *keymap)
-{
- keymap->refcnt++;
+ FreeXkbFile(xkb_file);
return keymap;
}
-
-XKB_EXPORT void
-xkb_map_unref(struct xkb_keymap *keymap)
-{
- unsigned int i;
- struct xkb_key *key;
-
- if (!keymap || --keymap->refcnt > 0)
- return;
-
- for (i = 0; i < keymap->num_types; i++) {
- free(keymap->types[i].map);
- free(keymap->types[i].level_names);
- }
- free(keymap->types);
-
- darray_foreach(key, keymap->keys) {
- free(key->sym_index);
- free(key->num_syms);
- darray_free(key->syms);
- free(key->actions);
- }
- darray_free(keymap->keys);
-
- darray_free(keymap->sym_interpret);
-
- darray_free(keymap->key_aliases);
-
- free(keymap->keycodes_section_name);
- free(keymap->symbols_section_name);
- free(keymap->types_section_name);
- free(keymap->compat_section_name);
-
- xkb_context_unref(keymap->ctx);
-
- free(keymap);
-}
diff --git a/test/rules-file.c b/test/rules-file.c
index d239c2e..ee53f09 100644
--- a/test/rules-file.c
+++ b/test/rules-file.c
@@ -26,9 +26,9 @@
#include <stdio.h>
#include <string.h>
-#include "xkbcommon/xkbcommon.h"
-#include "rules.h"
#include "test.h"
+#include "xkb-priv.h"
+#include "rules.h"
struct test_data {
/* Rules file */