ast: cast to ParseCommon explictly instead of using ->common Some tools were getting mighty confused with what we were doing. Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
diff --git a/src/xkbcomp/ast-build.c b/src/xkbcomp/ast-build.c
index 1982b32..11bc091 100644
--- a/src/xkbcomp/ast-build.c
+++ b/src/xkbcomp/ast-build.c
@@ -53,7 +53,6 @@
#include "xkbcomp-priv.h"
#include "ast-build.h"
-#include "parser-priv.h"
#include "include.h"
ParseCommon *
@@ -533,7 +532,7 @@ XkbFileFromComponents(struct xkb_context *ctx,
if (!include)
goto err;
- file = XkbFileCreate(type, NULL, &include->common, 0);
+ file = XkbFileCreate(type, NULL, (ParseCommon *) include, 0);
if (!file) {
FreeInclude(include);
goto err;
@@ -565,7 +564,7 @@ FreeExpr(ExprDef *expr)
case EXPR_UNARY_PLUS:
case EXPR_NOT:
case EXPR_INVERT:
- FreeStmt(&expr->unary.child->common);
+ FreeStmt((ParseCommon *) expr->unary.child);
break;
case EXPR_DIVIDE:
@@ -573,16 +572,16 @@ FreeExpr(ExprDef *expr)
case EXPR_SUBTRACT:
case EXPR_MULTIPLY:
case EXPR_ASSIGN:
- FreeStmt(&expr->binary.left->common);
- FreeStmt(&expr->binary.right->common);
+ FreeStmt((ParseCommon *) expr->binary.left);
+ FreeStmt((ParseCommon *) expr->binary.right);
break;
case EXPR_ACTION_DECL:
- FreeStmt(&expr->action.args->common);
+ FreeStmt((ParseCommon *) expr->action.args);
break;
case EXPR_ARRAY_REF:
- FreeStmt(&expr->array_ref.entry->common);
+ FreeStmt((ParseCommon *) expr->array_ref.entry);
break;
case EXPR_KEYSYM_LIST:
@@ -619,12 +618,10 @@ void
FreeStmt(ParseCommon *stmt)
{
ParseCommon *next;
- YYSTYPE u;
while (stmt)
{
next = stmt->next;
- u.any = stmt;
switch (stmt->type) {
case STMT_INCLUDE:
@@ -633,36 +630,36 @@ FreeStmt(ParseCommon *stmt)
stmt = NULL;
break;
case STMT_EXPR:
- FreeExpr(u.expr);
+ FreeExpr((ExprDef *) stmt);
break;
case STMT_VAR:
- FreeStmt(&u.var->name->common);
- FreeStmt(&u.var->value->common);
+ FreeStmt((ParseCommon *) ((VarDef *) stmt)->name);
+ FreeStmt((ParseCommon *) ((VarDef *) stmt)->value);
break;
case STMT_TYPE:
- FreeStmt(&u.keyType->body->common);
+ FreeStmt((ParseCommon *) ((KeyTypeDef *) stmt)->body);
break;
case STMT_INTERP:
- FreeStmt(&u.interp->match->common);
- FreeStmt(&u.interp->def->common);
+ FreeStmt((ParseCommon *) ((InterpDef *) stmt)->match);
+ FreeStmt((ParseCommon *) ((InterpDef *) stmt)->def);
break;
case STMT_VMOD:
- FreeStmt(&u.vmod->value->common);
+ FreeStmt((ParseCommon *) ((VModDef *) stmt)->value);
break;
case STMT_SYMBOLS:
- FreeStmt(&u.syms->symbols->common);
+ FreeStmt((ParseCommon *) ((SymbolsDef *) stmt)->symbols);
break;
case STMT_MODMAP:
- FreeStmt(&u.modMask->keys->common);
+ FreeStmt((ParseCommon *) ((ModMapDef *) stmt)->keys);
break;
case STMT_GROUP_COMPAT:
- FreeStmt(&u.groupCompat->def->common);
+ FreeStmt((ParseCommon *) ((GroupCompatDef *) stmt)->def);
break;
case STMT_LED_MAP:
- FreeStmt(&u.ledMap->body->common);
+ FreeStmt((ParseCommon *) ((LedMapDef *) stmt)->body);
break;
case STMT_LED_NAME:
- FreeStmt(&u.ledName->name->common);
+ FreeStmt((ParseCommon *) ((LedNameDef *) stmt)->name);
break;
default:
break;
diff --git a/src/xkbcomp/parser.y b/src/xkbcomp/parser.y
index d9f6cbc..d94e7cb 100644
--- a/src/xkbcomp/parser.y
+++ b/src/xkbcomp/parser.y
@@ -240,7 +240,7 @@ XkbFile : XkbCompositeMap
XkbCompositeMap : OptFlags XkbCompositeType OptMapName OBRACE
XkbMapConfigList
CBRACE SEMI
- { $$ = XkbFileCreate($2, $3, &$5->common, $1); }
+ { $$ = XkbFileCreate($2, $3, (ParseCommon *) $5, $1); }
;
XkbCompositeType: XKB_KEYMAP { $$ = FILE_TYPE_KEYMAP; }
@@ -253,7 +253,8 @@ XkbMapConfigList : XkbMapConfigList XkbMapConfig
if (!$2)
$$ = $1;
else
- $$ = (XkbFile *)AppendStmt(&$1->common, &$2->common);
+ $$ = (XkbFile *) AppendStmt((ParseCommon *) $1,
+ (ParseCommon *) $2);
}
| XkbMapConfig
{ $$ = $1; }
@@ -307,64 +308,64 @@ DeclList : DeclList Decl
Decl : OptMergeMode VarDecl
{
$2->merge = $1;
- $$ = &$2->common;
+ $$ = (ParseCommon *) $2;
}
| OptMergeMode VModDecl
{
$2->merge = $1;
- $$ = &$2->common;
+ $$ = (ParseCommon *) $2;
}
| OptMergeMode InterpretDecl
{
$2->merge = $1;
- $$ = &$2->common;
+ $$ = (ParseCommon *) $2;
}
| OptMergeMode KeyNameDecl
{
$2->merge = $1;
- $$ = &$2->common;
+ $$ = (ParseCommon *) $2;
}
| OptMergeMode KeyAliasDecl
{
$2->merge = $1;
- $$ = &$2->common;
+ $$ = (ParseCommon *) $2;
}
| OptMergeMode KeyTypeDecl
{
$2->merge = $1;
- $$ = &$2->common;
+ $$ = (ParseCommon *) $2;
}
| OptMergeMode SymbolsDecl
{
$2->merge = $1;
- $$ = &$2->common;
+ $$ = (ParseCommon *) $2;
}
| OptMergeMode ModMapDecl
{
$2->merge = $1;
- $$ = &$2->common;
+ $$ = (ParseCommon *) $2;
}
| OptMergeMode GroupCompatDecl
{
$2->merge = $1;
- $$ = &$2->common;
+ $$ = (ParseCommon *) $2;
}
| OptMergeMode LedMapDecl
{
$2->merge = $1;
- $$ = &$2->common;
+ $$ = (ParseCommon *) $2;
}
| OptMergeMode LedNameDecl
{
$2->merge = $1;
- $$ = &$2->common;
+ $$ = (ParseCommon *) $2;
}
| OptMergeMode ShapeDecl { $$ = NULL; }
| OptMergeMode SectionDecl { $$ = NULL; }
| OptMergeMode DoodadDecl { $$ = NULL; }
| MergeMode STRING
{
- $$ = &IncludeCreate(param->ctx, $2, $1)->common;
+ $$ = (ParseCommon *) IncludeCreate(param->ctx, $2, $1);
free($2);
}
;
@@ -390,7 +391,8 @@ VModDecl : VIRTUAL_MODS VModDefList SEMI
;
VModDefList : VModDefList COMMA VModDef
- { $$ = (VModDef *)AppendStmt(&$1->common, &$3->common); }
+ { $$ = (VModDef *) AppendStmt((ParseCommon *) $1,
+ (ParseCommon *) $3); }
| VModDef
{ $$ = $1; }
;
@@ -414,7 +416,8 @@ InterpretMatch : KeySym PLUS Expr
;
VarDeclList : VarDeclList VarDecl
- { $$ = (VarDef *)AppendStmt(&$1->common, &$2->common); }
+ { $$ = (VarDef *) AppendStmt((ParseCommon *) $1,
+ (ParseCommon *) $2); }
| VarDecl
{ $$ = $1; }
;
@@ -432,7 +435,8 @@ SymbolsDecl : KEY KEYNAME OBRACE
;
SymbolsBody : SymbolsBody COMMA SymbolsVarDecl
- { $$ = (VarDef *)AppendStmt(&$1->common, &$3->common); }
+ { $$ = (VarDef *) AppendStmt((ParseCommon *) $1,
+ (ParseCommon *) $3); }
| SymbolsVarDecl
{ $$ = $1; }
| { $$ = NULL; }
@@ -486,11 +490,11 @@ SectionBody : SectionBody SectionBodyItem { $$ = NULL;}
SectionBodyItem : ROW OBRACE RowBody CBRACE SEMI
{ $$ = NULL; }
| VarDecl
- { FreeStmt(&$1->common); $$ = NULL; }
+ { FreeStmt((ParseCommon *) $1); $$ = NULL; }
| DoodadDecl
{ $$ = NULL; }
| LedMapDecl
- { FreeStmt(&$1->common); $$ = NULL; }
+ { FreeStmt((ParseCommon *) $1); $$ = NULL; }
| OverlayDecl
{ $$ = NULL; }
;
@@ -501,7 +505,7 @@ RowBody : RowBody RowBodyItem { $$ = NULL;}
RowBodyItem : KEYS OBRACE Keys CBRACE SEMI { $$ = NULL; }
| VarDecl
- { FreeStmt(&$1->common); $$ = NULL; }
+ { FreeStmt((ParseCommon *) $1); $$ = NULL; }
;
Keys : Keys COMMA Key { $$ = NULL; }
@@ -511,7 +515,7 @@ Keys : Keys COMMA Key { $$ = NULL; }
Key : KEYNAME
{ $$ = NULL; }
| OBRACE ExprList CBRACE
- { FreeStmt(&$2->common); $$ = NULL; }
+ { FreeStmt((ParseCommon *) $2); $$ = NULL; }
;
OverlayDecl : OVERLAY String OBRACE OverlayKeyList CBRACE SEMI
@@ -536,7 +540,7 @@ OutlineInList : OBRACE CoordList CBRACE
| Ident EQUALS OBRACE CoordList CBRACE
{ $$ = NULL; }
| Ident EQUALS Expr
- { FreeStmt(&$3->common); $$ = NULL; }
+ { FreeStmt((ParseCommon *) $3); $$ = NULL; }
;
CoordList : CoordList COMMA Coord
@@ -550,7 +554,7 @@ Coord : OBRACKET SignedNumber COMMA SignedNumber CBRACKET
;
DoodadDecl : DoodadType String OBRACE VarDeclList CBRACE SEMI
- { FreeStmt(&$4->common); $$ = NULL; }
+ { FreeStmt((ParseCommon *) $4); $$ = NULL; }
;
DoodadType : TEXT { $$ = 0; }
@@ -610,7 +614,8 @@ OptExprList : ExprList { $$ = $1; }
;
ExprList : ExprList COMMA Expr
- { $$ = (ExprDef *)AppendStmt(&$1->common, &$3->common); }
+ { $$ = (ExprDef *) AppendStmt((ParseCommon *) $1,
+ (ParseCommon *) $3); }
| Expr
{ $$ = $1; }
;
@@ -648,7 +653,8 @@ Term : MINUS Term
;
ActionList : ActionList COMMA Action
- { $$ = (ExprDef *)AppendStmt(&$1->common, &$3->common); }
+ { $$ = (ExprDef *) AppendStmt((ParseCommon *) $1,
+ (ParseCommon *) $3); }
| Action
{ $$ = $1; }
;