From: Daniel Stone Date: Fri, 9 Mar 2012 19:29:29 +0000 (+0000) Subject: Remove geometry even harder X-Git-Tag: xkbcommon-0.2.0~747 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=17bcc4c163d625f4422f91fb8fd51f7918836678;p=platform%2Fupstream%2Flibxkbcommon.git Remove geometry even harder Not the most elegant fix, but will do for now. Signed-off-by: Daniel Stone --- diff --git a/src/xkbcomp/parseutils.c b/src/xkbcomp/parseutils.c index 88bfff8..a36d015 100644 --- a/src/xkbcomp/parseutils.c +++ b/src/xkbcomp/parseutils.c @@ -412,181 +412,6 @@ CreateKeysymList(char *sym) return NULL; } -ShapeDef * -ShapeDeclCreate(xkb_atom_t name, OutlineDef * outlines) -{ - ShapeDef *shape; - OutlineDef *ol; - - shape = uTypedAlloc(ShapeDef); - if (shape != NULL) - { - memset(shape, 0, sizeof(ShapeDef)); - shape->common.stmtType = StmtShapeDef; - shape->common.next = NULL; - shape->merge = MergeDefault; - shape->name = name; - shape->nOutlines = 0; - shape->outlines = outlines; - for (ol = outlines; ol != NULL; ol = (OutlineDef *) ol->common.next) - { - if (ol->nPoints > 0) - shape->nOutlines++; - } - } - return shape; -} - -OutlineDef * -OutlineCreate(xkb_atom_t field, ExprDef * points) -{ - OutlineDef *outline; - ExprDef *pt; - - outline = uTypedAlloc(OutlineDef); - if (outline != NULL) - { - memset(outline, 0, sizeof(OutlineDef)); - outline->common.stmtType = StmtOutlineDef; - outline->common.next = NULL; - outline->field = field; - outline->nPoints = 0; - if (points->op == ExprCoord) - { - for (pt = points; pt != NULL; pt = (ExprDef *) pt->common.next) - { - outline->nPoints++; - } - } - outline->points = points; - } - return outline; -} - -KeyDef * -KeyDeclCreate(char *name, ExprDef * expr) -{ - KeyDef *key; - - key = uTypedAlloc(KeyDef); - if (key != NULL) - { - memset(key, 0, sizeof(KeyDef)); - key->common.stmtType = StmtKeyDef; - key->common.next = NULL; - if (name) - key->name = name; - else - key->expr = expr; - } - return key; -} - -RowDef * -RowDeclCreate(KeyDef * keys) -{ - RowDef *row; - KeyDef *key; - - row = uTypedAlloc(RowDef); - if (row != NULL) - { - memset(row, 0, sizeof(RowDef)); - row->common.stmtType = StmtRowDef; - row->common.next = NULL; - row->nKeys = 0; - row->keys = keys; - for (key = keys; key != NULL; key = (KeyDef *) key->common.next) - { - if (key->common.stmtType == StmtKeyDef) - row->nKeys++; - } - } - return row; -} - -SectionDef * -SectionDeclCreate(xkb_atom_t name, RowDef * rows) -{ - SectionDef *section; - RowDef *row; - - section = uTypedAlloc(SectionDef); - if (section != NULL) - { - memset(section, 0, sizeof(SectionDef)); - section->common.stmtType = StmtSectionDef; - section->common.next = NULL; - section->name = name; - section->nRows = 0; - section->rows = rows; - for (row = rows; row != NULL; row = (RowDef *) row->common.next) - { - if (row->common.stmtType == StmtRowDef) - section->nRows++; - } - } - return section; -} - -OverlayKeyDef * -OverlayKeyCreate(char *under, char *over) -{ - OverlayKeyDef *key; - - key = uTypedAlloc(OverlayKeyDef); - if (key != NULL) - { - memset(key, 0, sizeof(OverlayKeyDef)); - key->common.stmtType = StmtOverlayKeyDef; - strncpy(key->over, over, XkbKeyNameLength); - strncpy(key->under, under, XkbKeyNameLength); - free(over); - free(under); - } - return key; -} - -OverlayDef * -OverlayDeclCreate(xkb_atom_t name, OverlayKeyDef * keys) -{ - OverlayDef *ol; - OverlayKeyDef *key; - - ol = uTypedAlloc(OverlayDef); - if (ol != NULL) - { - memset(ol, 0, sizeof(OverlayDef)); - ol->common.stmtType = StmtOverlayDef; - ol->name = name; - ol->keys = keys; - for (key = keys; key != NULL; - key = (OverlayKeyDef *) key->common.next) - { - ol->nKeys++; - } - } - return ol; -} - -DoodadDef * -DoodadCreate(unsigned type, xkb_atom_t name, VarDef * body) -{ - DoodadDef *doodad; - - doodad = uTypedAlloc(DoodadDef); - if (doodad != NULL) - { - memset(doodad, 0, sizeof(DoodadDef)); - doodad->common.stmtType = StmtDoodadDef; - doodad->common.next = NULL; - doodad->type = type; - doodad->name = name; - doodad->body = body; - } - return doodad; -} - ExprDef * AppendKeysymList(ExprDef * list, char *sym) { @@ -903,30 +728,6 @@ FreeStmt(ParseCommon *stmt) case StmtIndicatorNameDef: FreeStmt(&u.ledName->name->common); break; - case StmtOutlineDef: - FreeStmt(&u.outline->points->common); - break; - case StmtShapeDef: - FreeStmt(&u.shape->outlines->common); - break; - case StmtKeyDef: - free(u.key->name); - FreeStmt(&u.key->expr->common); - break; - case StmtRowDef: - FreeStmt(&u.row->keys->common); - break; - case StmtSectionDef: - FreeStmt(&u.section->rows->common); - break; - case StmtOverlayKeyDef: - break; - case StmtOverlayDef: - FreeStmt(&u.overlay->keys->common); - break; - case StmtDoodadDef: - FreeStmt(&u.doodad->body->common); - break; default: break; } diff --git a/src/xkbcomp/parseutils.h b/src/xkbcomp/parseutils.h index 2853e90..18c2c6c 100644 --- a/src/xkbcomp/parseutils.h +++ b/src/xkbcomp/parseutils.h @@ -110,38 +110,6 @@ extern ExprDef *ActionCreate(xkb_atom_t /* name */ , extern ExprDef *CreateKeysymList(char * /* sym */ ); -extern ShapeDef *ShapeDeclCreate(xkb_atom_t /* name */ , - OutlineDef * /* outlines */ - ); - -extern OutlineDef *OutlineCreate(xkb_atom_t /* field */ , - ExprDef * /* points */ - ); - -extern KeyDef *KeyDeclCreate(char * /* name */ , - ExprDef * /* expr */ - ); - -extern RowDef *RowDeclCreate(KeyDef * /* keys */ - ); - -extern SectionDef *SectionDeclCreate(xkb_atom_t /* name */ , - RowDef * /* rows */ - ); - -extern OverlayKeyDef *OverlayKeyCreate(char * /* under */ , - char * /* over */ - ); - -extern OverlayDef *OverlayDeclCreate(xkb_atom_t /* name */ , - OverlayKeyDef * /* rows */ - ); - -extern DoodadDef *DoodadCreate(unsigned /* type */ , - xkb_atom_t /* name */ , - VarDef * /* body */ - ); - extern ExprDef *AppendKeysymList(ExprDef * /* list */ , char * /* sym */ ); diff --git a/src/xkbcomp/xkbcomp.h b/src/xkbcomp/xkbcomp.h index baadaee..f03de4f 100644 --- a/src/xkbcomp/xkbcomp.h +++ b/src/xkbcomp/xkbcomp.h @@ -65,14 +65,6 @@ extern char *scanFile; #define StmtGroupCompatDef 11 #define StmtIndicatorMapDef 12 #define StmtIndicatorNameDef 13 -#define StmtOutlineDef 14 -#define StmtShapeDef 15 -#define StmtKeyDef 16 -#define StmtRowDef 17 -#define StmtSectionDef 18 -#define StmtOverlayKeyDef 19 -#define StmtOverlayDef 20 -#define StmtDoodadDef 21 #define FileSymInterp 100 @@ -254,76 +246,14 @@ typedef struct _IndicatorNameDef Bool virtual; } IndicatorNameDef; -typedef struct _OutlineDef -{ - ParseCommon common; - xkb_atom_t field; - int nPoints; - ExprDef *points; -} OutlineDef; - -typedef struct _ShapeDef -{ - ParseCommon common; - unsigned merge; - xkb_atom_t name; - int nOutlines; - OutlineDef *outlines; -} ShapeDef; - -typedef struct _KeyDef -{ - ParseCommon common; - unsigned defined; - char *name; - ExprDef *expr; -} KeyDef; - -typedef struct _RowDef -{ - ParseCommon common; - int nKeys; - KeyDef *keys; -} RowDef; - -typedef struct _SectionDef -{ - ParseCommon common; - unsigned merge; - xkb_atom_t name; - int nRows; - RowDef *rows; -} SectionDef; - -typedef struct _OverlayKeyDef -{ - ParseCommon common; - char over[5]; - char under[5]; -} OverlayKeyDef; - -typedef struct _OverlayDef -{ - ParseCommon common; - unsigned merge; - xkb_atom_t name; - int nKeys; - OverlayKeyDef *keys; -} OverlayDef; - -typedef struct _DoodadDef +typedef struct _IndicatorMapDef { ParseCommon common; unsigned merge; unsigned type; xkb_atom_t name; VarDef *body; -} DoodadDef; - -/* IndicatorMapDef doesn't use the type field, but the rest of the fields - need to be at the same offsets as in DoodadDef. Use #define to avoid - any strict aliasing problems. */ -#define IndicatorMapDef DoodadDef +} IndicatorMapDef; typedef struct _XkbFile { diff --git a/src/xkbcomp/xkbparse.y b/src/xkbcomp/xkbparse.y index da2383e..bf45dff 100644 --- a/src/xkbcomp/xkbparse.y +++ b/src/xkbcomp/xkbparse.y @@ -125,14 +125,7 @@ extern FILE *yyin; IndicatorNameDef *ledName; KeycodeDef *keyName; KeyAliasDef *keyAlias; - ShapeDef *shape; - SectionDef *section; - RowDef *row; - KeyDef *key; - OverlayDef *overlay; - OverlayKeyDef *olKey; - OutlineDef *outline; - DoodadDef *doodad; + void *geom; XkbFile *file; } %type Number Integer Float SignedNumber @@ -154,14 +147,9 @@ extern FILE *yyin; %type IndicatorNameDecl %type KeyNameDecl %type KeyAliasDecl -%type ShapeDecl -%type
SectionDecl -%type SectionBody SectionBodyItem -%type RowBody RowBodyItem Keys Key -%type OverlayDecl -%type OverlayKeyList OverlayKey -%type OutlineList OutlineInList -%type DoodadDecl +%type ShapeDecl SectionDecl SectionBody SectionBodyItem RowBody RowBodyItem +%type Keys Key OverlayDecl OverlayKeyList OverlayKey OutlineList OutlineInList +%type DoodadDecl %type XkbFile XkbMapConfigList XkbMapConfig XkbConfig %type XkbCompositeMap XkbCompMapList %% @@ -191,7 +179,12 @@ XkbCompositeType: XKB_KEYMAP { $$= XkmKeymapFile; } ; XkbMapConfigList : XkbMapConfigList XkbMapConfig - { $$= (XkbFile *)AppendStmt(&$1->common,&$2->common); } + { + if (!$2) + $$= $1; + else + $$= (XkbFile *)AppendStmt(&$1->common,&$2->common); + } | XkbMapConfig { $$= $1; } ; @@ -199,11 +192,21 @@ XkbMapConfigList : XkbMapConfigList XkbMapConfig XkbMapConfig : OptFlags FileType OptMapName OBRACE DeclList CBRACE SEMI - { $$= CreateXKBFile($2,$3,$5,$1); } + { + if ($2 == XkmGeometryIndex) + $$= NULL; + else + $$= CreateXKBFile($2,$3,$5,$1); + } ; XkbConfig : OptFlags FileType OptMapName DeclList - { $$= CreateXKBFile($2,$3,$4,$1); } + { + if ($2 == XkmGeometryIndex) + $$= NULL; + else + $$= CreateXKBFile($2,$3,$4,$1); + } ; @@ -294,18 +297,12 @@ Decl : OptMergeMode VarDecl } | OptMergeMode ShapeDecl { - $2->merge= StmtSetMerge(&$2->common,$1); - $$= &$2->common; } | OptMergeMode SectionDecl { - $2->merge= StmtSetMerge(&$2->common,$1); - $$= &$2->common; } | OptMergeMode DoodadDecl { - $2->merge= StmtSetMerge(&$2->common,$1); - $$= &$2->common; } | MergeMode STRING { @@ -440,110 +437,99 @@ IndicatorNameDecl: INDICATOR Integer EQUALS Expr SEMI ; ShapeDecl : SHAPE String OBRACE OutlineList CBRACE SEMI - { $$= ShapeDeclCreate($2,(OutlineDef *)&$4->common); } + { $$= NULL; } | SHAPE String OBRACE CoordList CBRACE SEMI - { - OutlineDef *outlines; - outlines= OutlineCreate(None,$4); - $$= ShapeDeclCreate($2,outlines); - } + { $$= NULL; } ; SectionDecl : SECTION String OBRACE SectionBody CBRACE SEMI - { $$= SectionDeclCreate($2,$4); } + { $$= NULL; } ; SectionBody : SectionBody SectionBodyItem - { $$=(RowDef *)AppendStmt(&$1->common,&$2->common);} + { $$= NULL;} | SectionBodyItem - { $$= $1; } + { $$= NULL; } ; SectionBodyItem : ROW OBRACE RowBody CBRACE SEMI - { $$= RowDeclCreate($3); } + { $$= NULL; } | VarDecl - { $$= (RowDef *)$1; } + { $$= NULL; } | DoodadDecl - { $$= (RowDef *)$1; } + { $$= NULL; } | IndicatorMapDecl - { $$= (RowDef *)$1; } + { $$= NULL; } | OverlayDecl - { $$= (RowDef *)$1; } + { $$= NULL; } ; RowBody : RowBody RowBodyItem - { $$=(KeyDef *)AppendStmt(&$1->common,&$2->common);} + { $$= NULL;} | RowBodyItem - { $$= $1; } + { $$= NULL; } ; RowBodyItem : KEYS OBRACE Keys CBRACE SEMI - { $$= $3; } + { $$= NULL; } | VarDecl - { $$= (KeyDef *)$1; } + { $$= NULL; } ; Keys : Keys COMMA Key - { $$=(KeyDef *)AppendStmt(&$1->common,&$3->common);} + { $$= NULL; } | Key - { $$= $1; } + { $$= NULL; } ; Key : KeyName - { $$= KeyDeclCreate($1,NULL); } + { $$= NULL; } | OBRACE ExprList CBRACE - { $$= KeyDeclCreate(NULL,$2); } + { $$= NULL; } ; OverlayDecl : OVERLAY String OBRACE OverlayKeyList CBRACE SEMI - { $$= OverlayDeclCreate($2,$4); } + { $$= NULL; } ; OverlayKeyList : OverlayKeyList COMMA OverlayKey { - $$= (OverlayKeyDef *) - AppendStmt(&$1->common,&$3->common); + $$= NULL; } | OverlayKey - { $$= $1; } + { $$= NULL; } ; OverlayKey : KeyName EQUALS KeyName - { $$= OverlayKeyCreate($1,$3); } + { $$= NULL; } ; OutlineList : OutlineList COMMA OutlineInList - { $$=(OutlineDef *)AppendStmt(&$1->common,&$3->common);} + { $$= NULL;} | OutlineInList - { $$= $1; } + { $$= NULL; } ; OutlineInList : OBRACE CoordList CBRACE - { $$= OutlineCreate(None,$2); } + { $$= NULL; } | Ident EQUALS OBRACE CoordList CBRACE - { $$= OutlineCreate($1,$4); } + { $$= NULL; } | Ident EQUALS Expr - { $$= OutlineCreate($1,$3); } + { $$= NULL; } ; CoordList : CoordList COMMA Coord - { $$= (ExprDef *)AppendStmt(&$1->common,&$3->common); } + { $$= NULL; } | Coord - { $$= $1; } + { $$= NULL; } ; Coord : OBRACKET SignedNumber COMMA SignedNumber CBRACKET - { - ExprDef *expr; - expr= ExprCreate(ExprCoord,TypeUnknown); - expr->value.coord.x= $2; - expr->value.coord.y= $4; - $$= expr; - } + { $$= NULL; } ; DoodadDecl : DoodadType String OBRACE VarDeclList CBRACE SEMI - { $$= DoodadCreate($1,$2,$4); } + { $$= NULL; } ; DoodadType : TEXT { $$= 0; } @@ -573,11 +559,11 @@ Element : ACTION_TOK | SHAPE { $$= xkb_intern_atom("shape"); } | ROW - { $$= xkb_intern_atom("row"); } + { $$= None; } | SECTION - { $$= xkb_intern_atom("section"); } + { $$= None; } | TEXT - { $$= xkb_intern_atom("text"); } + { $$= None; } ; OptMergeMode : MergeMode { $$= $1; } @@ -744,7 +730,7 @@ Number : FLOAT { $$= scanInt; } | INTEGER { $$= scanInt*XkbGeomPtsPerMM; } ; -Float : FLOAT { $$= scanInt; } +Float : FLOAT { $$= 0; } ; Integer : INTEGER { $$= scanInt; }