Remove geometry even harder

Not the most elegant fix, but will do for now.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
master
Daniel Stone 2012-03-09 19:29:29 +00:00
parent a0e756fd83
commit 17bcc4c163
4 changed files with 59 additions and 374 deletions

View File

@ -412,181 +412,6 @@ CreateKeysymList(char *sym)
return NULL; 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 * ExprDef *
AppendKeysymList(ExprDef * list, char *sym) AppendKeysymList(ExprDef * list, char *sym)
{ {
@ -903,30 +728,6 @@ FreeStmt(ParseCommon *stmt)
case StmtIndicatorNameDef: case StmtIndicatorNameDef:
FreeStmt(&u.ledName->name->common); FreeStmt(&u.ledName->name->common);
break; 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: default:
break; break;
} }

View File

@ -110,38 +110,6 @@ extern ExprDef *ActionCreate(xkb_atom_t /* name */ ,
extern ExprDef *CreateKeysymList(char * /* sym */ 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 */ , extern ExprDef *AppendKeysymList(ExprDef * /* list */ ,
char * /* sym */ char * /* sym */
); );

View File

@ -65,14 +65,6 @@ extern char *scanFile;
#define StmtGroupCompatDef 11 #define StmtGroupCompatDef 11
#define StmtIndicatorMapDef 12 #define StmtIndicatorMapDef 12
#define StmtIndicatorNameDef 13 #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 #define FileSymInterp 100
@ -254,76 +246,14 @@ typedef struct _IndicatorNameDef
Bool virtual; Bool virtual;
} IndicatorNameDef; } IndicatorNameDef;
typedef struct _OutlineDef typedef struct _IndicatorMapDef
{
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
{ {
ParseCommon common; ParseCommon common;
unsigned merge; unsigned merge;
unsigned type; unsigned type;
xkb_atom_t name; xkb_atom_t name;
VarDef *body; VarDef *body;
} DoodadDef; } IndicatorMapDef;
/* 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
typedef struct _XkbFile typedef struct _XkbFile
{ {

View File

@ -125,14 +125,7 @@ extern FILE *yyin;
IndicatorNameDef *ledName; IndicatorNameDef *ledName;
KeycodeDef *keyName; KeycodeDef *keyName;
KeyAliasDef *keyAlias; KeyAliasDef *keyAlias;
ShapeDef *shape; void *geom;
SectionDef *section;
RowDef *row;
KeyDef *key;
OverlayDef *overlay;
OverlayKeyDef *olKey;
OutlineDef *outline;
DoodadDef *doodad;
XkbFile *file; XkbFile *file;
} }
%type <ival> Number Integer Float SignedNumber %type <ival> Number Integer Float SignedNumber
@ -154,14 +147,9 @@ extern FILE *yyin;
%type <ledName> IndicatorNameDecl %type <ledName> IndicatorNameDecl
%type <keyName> KeyNameDecl %type <keyName> KeyNameDecl
%type <keyAlias> KeyAliasDecl %type <keyAlias> KeyAliasDecl
%type <shape> ShapeDecl %type <geom> ShapeDecl SectionDecl SectionBody SectionBodyItem RowBody RowBodyItem
%type <section> SectionDecl %type <geom> Keys Key OverlayDecl OverlayKeyList OverlayKey OutlineList OutlineInList
%type <row> SectionBody SectionBodyItem %type <geom> DoodadDecl
%type <key> RowBody RowBodyItem Keys Key
%type <overlay> OverlayDecl
%type <olKey> OverlayKeyList OverlayKey
%type <outline> OutlineList OutlineInList
%type <doodad> DoodadDecl
%type <file> XkbFile XkbMapConfigList XkbMapConfig XkbConfig %type <file> XkbFile XkbMapConfigList XkbMapConfig XkbConfig
%type <file> XkbCompositeMap XkbCompMapList %type <file> XkbCompositeMap XkbCompMapList
%% %%
@ -191,7 +179,12 @@ XkbCompositeType: XKB_KEYMAP { $$= XkmKeymapFile; }
; ;
XkbMapConfigList : XkbMapConfigList XkbMapConfig XkbMapConfigList : XkbMapConfigList XkbMapConfig
{ $$= (XkbFile *)AppendStmt(&$1->common,&$2->common); } {
if (!$2)
$$= $1;
else
$$= (XkbFile *)AppendStmt(&$1->common,&$2->common);
}
| XkbMapConfig | XkbMapConfig
{ $$= $1; } { $$= $1; }
; ;
@ -199,11 +192,21 @@ XkbMapConfigList : XkbMapConfigList XkbMapConfig
XkbMapConfig : OptFlags FileType OptMapName OBRACE XkbMapConfig : OptFlags FileType OptMapName OBRACE
DeclList DeclList
CBRACE SEMI CBRACE SEMI
{ $$= CreateXKBFile($2,$3,$5,$1); } {
if ($2 == XkmGeometryIndex)
$$= NULL;
else
$$= CreateXKBFile($2,$3,$5,$1);
}
; ;
XkbConfig : OptFlags FileType OptMapName DeclList 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 | OptMergeMode ShapeDecl
{ {
$2->merge= StmtSetMerge(&$2->common,$1);
$$= &$2->common;
} }
| OptMergeMode SectionDecl | OptMergeMode SectionDecl
{ {
$2->merge= StmtSetMerge(&$2->common,$1);
$$= &$2->common;
} }
| OptMergeMode DoodadDecl | OptMergeMode DoodadDecl
{ {
$2->merge= StmtSetMerge(&$2->common,$1);
$$= &$2->common;
} }
| MergeMode STRING | MergeMode STRING
{ {
@ -440,110 +437,99 @@ IndicatorNameDecl: INDICATOR Integer EQUALS Expr SEMI
; ;
ShapeDecl : SHAPE String OBRACE OutlineList CBRACE SEMI ShapeDecl : SHAPE String OBRACE OutlineList CBRACE SEMI
{ $$= ShapeDeclCreate($2,(OutlineDef *)&$4->common); } { $$= NULL; }
| SHAPE String OBRACE CoordList CBRACE SEMI | SHAPE String OBRACE CoordList CBRACE SEMI
{ { $$= NULL; }
OutlineDef *outlines;
outlines= OutlineCreate(None,$4);
$$= ShapeDeclCreate($2,outlines);
}
; ;
SectionDecl : SECTION String OBRACE SectionBody CBRACE SEMI SectionDecl : SECTION String OBRACE SectionBody CBRACE SEMI
{ $$= SectionDeclCreate($2,$4); } { $$= NULL; }
; ;
SectionBody : SectionBody SectionBodyItem SectionBody : SectionBody SectionBodyItem
{ $$=(RowDef *)AppendStmt(&$1->common,&$2->common);} { $$= NULL;}
| SectionBodyItem | SectionBodyItem
{ $$= $1; } { $$= NULL; }
; ;
SectionBodyItem : ROW OBRACE RowBody CBRACE SEMI SectionBodyItem : ROW OBRACE RowBody CBRACE SEMI
{ $$= RowDeclCreate($3); } { $$= NULL; }
| VarDecl | VarDecl
{ $$= (RowDef *)$1; } { $$= NULL; }
| DoodadDecl | DoodadDecl
{ $$= (RowDef *)$1; } { $$= NULL; }
| IndicatorMapDecl | IndicatorMapDecl
{ $$= (RowDef *)$1; } { $$= NULL; }
| OverlayDecl | OverlayDecl
{ $$= (RowDef *)$1; } { $$= NULL; }
; ;
RowBody : RowBody RowBodyItem RowBody : RowBody RowBodyItem
{ $$=(KeyDef *)AppendStmt(&$1->common,&$2->common);} { $$= NULL;}
| RowBodyItem | RowBodyItem
{ $$= $1; } { $$= NULL; }
; ;
RowBodyItem : KEYS OBRACE Keys CBRACE SEMI RowBodyItem : KEYS OBRACE Keys CBRACE SEMI
{ $$= $3; } { $$= NULL; }
| VarDecl | VarDecl
{ $$= (KeyDef *)$1; } { $$= NULL; }
; ;
Keys : Keys COMMA Key Keys : Keys COMMA Key
{ $$=(KeyDef *)AppendStmt(&$1->common,&$3->common);} { $$= NULL; }
| Key | Key
{ $$= $1; } { $$= NULL; }
; ;
Key : KeyName Key : KeyName
{ $$= KeyDeclCreate($1,NULL); } { $$= NULL; }
| OBRACE ExprList CBRACE | OBRACE ExprList CBRACE
{ $$= KeyDeclCreate(NULL,$2); } { $$= NULL; }
; ;
OverlayDecl : OVERLAY String OBRACE OverlayKeyList CBRACE SEMI OverlayDecl : OVERLAY String OBRACE OverlayKeyList CBRACE SEMI
{ $$= OverlayDeclCreate($2,$4); } { $$= NULL; }
; ;
OverlayKeyList : OverlayKeyList COMMA OverlayKey OverlayKeyList : OverlayKeyList COMMA OverlayKey
{ {
$$= (OverlayKeyDef *) $$= NULL;
AppendStmt(&$1->common,&$3->common);
} }
| OverlayKey | OverlayKey
{ $$= $1; } { $$= NULL; }
; ;
OverlayKey : KeyName EQUALS KeyName OverlayKey : KeyName EQUALS KeyName
{ $$= OverlayKeyCreate($1,$3); } { $$= NULL; }
; ;
OutlineList : OutlineList COMMA OutlineInList OutlineList : OutlineList COMMA OutlineInList
{ $$=(OutlineDef *)AppendStmt(&$1->common,&$3->common);} { $$= NULL;}
| OutlineInList | OutlineInList
{ $$= $1; } { $$= NULL; }
; ;
OutlineInList : OBRACE CoordList CBRACE OutlineInList : OBRACE CoordList CBRACE
{ $$= OutlineCreate(None,$2); } { $$= NULL; }
| Ident EQUALS OBRACE CoordList CBRACE | Ident EQUALS OBRACE CoordList CBRACE
{ $$= OutlineCreate($1,$4); } { $$= NULL; }
| Ident EQUALS Expr | Ident EQUALS Expr
{ $$= OutlineCreate($1,$3); } { $$= NULL; }
; ;
CoordList : CoordList COMMA Coord CoordList : CoordList COMMA Coord
{ $$= (ExprDef *)AppendStmt(&$1->common,&$3->common); } { $$= NULL; }
| Coord | Coord
{ $$= $1; } { $$= NULL; }
; ;
Coord : OBRACKET SignedNumber COMMA SignedNumber CBRACKET Coord : OBRACKET SignedNumber COMMA SignedNumber CBRACKET
{ { $$= NULL; }
ExprDef *expr;
expr= ExprCreate(ExprCoord,TypeUnknown);
expr->value.coord.x= $2;
expr->value.coord.y= $4;
$$= expr;
}
; ;
DoodadDecl : DoodadType String OBRACE VarDeclList CBRACE SEMI DoodadDecl : DoodadType String OBRACE VarDeclList CBRACE SEMI
{ $$= DoodadCreate($1,$2,$4); } { $$= NULL; }
; ;
DoodadType : TEXT { $$= 0; } DoodadType : TEXT { $$= 0; }
@ -573,11 +559,11 @@ Element : ACTION_TOK
| SHAPE | SHAPE
{ $$= xkb_intern_atom("shape"); } { $$= xkb_intern_atom("shape"); }
| ROW | ROW
{ $$= xkb_intern_atom("row"); } { $$= None; }
| SECTION | SECTION
{ $$= xkb_intern_atom("section"); } { $$= None; }
| TEXT | TEXT
{ $$= xkb_intern_atom("text"); } { $$= None; }
; ;
OptMergeMode : MergeMode { $$= $1; } OptMergeMode : MergeMode { $$= $1; }
@ -744,7 +730,7 @@ Number : FLOAT { $$= scanInt; }
| INTEGER { $$= scanInt*XkbGeomPtsPerMM; } | INTEGER { $$= scanInt*XkbGeomPtsPerMM; }
; ;
Float : FLOAT { $$= scanInt; } Float : FLOAT { $$= 0; }
; ;
Integer : INTEGER { $$= scanInt; } Integer : INTEGER { $$= scanInt; }