Lines Matching +full:- +full:- +full:info

52 #include "xkbcomp-priv.h"
101 siText(SymInterpInfo *si, CompatInfo *info) in siText() argument
103 char *buf = xkb_context_get_buffer(info->ctx, 128); in siText()
105 if (si == &info->default_interp) in siText()
109 KeysymText(info->ctx, si->interp.sym), in siText()
110 SIMatchText(si->interp.match), in siText()
111 ModMaskText(info->ctx, &info->mods, si->interp.mods)); in siText()
117 ReportSINotArray(CompatInfo *info, SymInterpInfo *si, const char *field) in ReportSINotArray() argument
119 return ReportNotArray(info->ctx, "symbol interpretation", field, in ReportSINotArray()
120 siText(si, info)); in ReportSINotArray()
124 ReportSIBadType(CompatInfo *info, SymInterpInfo *si, const char *field, in ReportSIBadType() argument
127 return ReportBadType(info->ctx, "symbol interpretation", field, in ReportSIBadType()
128 siText(si, info), wanted); in ReportSIBadType()
132 ReportLedBadType(CompatInfo *info, LedInfo *ledi, const char *field, in ReportLedBadType() argument
135 return ReportBadType(info->ctx, "indicator map", field, in ReportLedBadType()
136 xkb_atom_text(info->ctx, ledi->led.name), in ReportLedBadType()
141 ReportLedNotArray(CompatInfo *info, LedInfo *ledi, const char *field) in ReportLedNotArray() argument
143 return ReportNotArray(info->ctx, "indicator map", field, in ReportLedNotArray()
144 xkb_atom_text(info->ctx, ledi->led.name)); in ReportLedNotArray()
148 InitCompatInfo(CompatInfo *info, struct xkb_context *ctx, in InitCompatInfo() argument
151 memset(info, 0, sizeof(*info)); in InitCompatInfo()
152 info->ctx = ctx; in InitCompatInfo()
153 info->actions = actions; in InitCompatInfo()
154 info->mods = *mods; in InitCompatInfo()
155 info->default_interp.merge = MERGE_OVERRIDE; in InitCompatInfo()
156 info->default_interp.interp.virtual_mod = XKB_MOD_INVALID; in InitCompatInfo()
157 info->default_led.merge = MERGE_OVERRIDE; in InitCompatInfo()
161 ClearCompatInfo(CompatInfo *info) in ClearCompatInfo() argument
163 free(info->name); in ClearCompatInfo()
164 darray_free(info->interps); in ClearCompatInfo()
168 FindMatchingInterp(CompatInfo *info, SymInterpInfo *new) in FindMatchingInterp() argument
172 darray_foreach(old, info->interps) in FindMatchingInterp()
173 if (old->interp.sym == new->interp.sym && in FindMatchingInterp()
174 old->interp.mods == new->interp.mods && in FindMatchingInterp()
175 old->interp.match == new->interp.match) in FindMatchingInterp()
185 if (!(old->defined & field)) in UseNewInterpField()
188 if (new->defined & field) { in UseNewInterpField()
192 if (new->merge != MERGE_AUGMENT) in UseNewInterpField()
200 AddInterp(CompatInfo *info, SymInterpInfo *new, bool same_file) in AddInterp() argument
202 SymInterpInfo *old = FindMatchingInterp(info, new); in AddInterp()
204 const int verbosity = xkb_context_get_log_verbosity(info->ctx); in AddInterp()
208 if (new->merge == MERGE_REPLACE) { in AddInterp()
210 log_warn(info->ctx, in AddInterp()
213 siText(new, info)); in AddInterp()
220 old->interp.virtual_mod = new->interp.virtual_mod; in AddInterp()
221 old->defined |= SI_FIELD_VIRTUAL_MOD; in AddInterp()
225 old->interp.action = new->interp.action; in AddInterp()
226 old->defined |= SI_FIELD_ACTION; in AddInterp()
230 old->interp.repeat = new->interp.repeat; in AddInterp()
231 old->defined |= SI_FIELD_AUTO_REPEAT; in AddInterp()
235 old->interp.level_one_only = new->interp.level_one_only; in AddInterp()
236 old->defined |= SI_FIELD_LEVEL_ONE_ONLY; in AddInterp()
240 log_warn(info->ctx, in AddInterp()
243 siText(new, info), in AddInterp()
244 (new->merge != MERGE_AUGMENT ? "last" : "first")); in AddInterp()
250 darray_append(info->interps, *new); in AddInterp()
258 xkb_mod_mask_t *mods_rtrn, CompatInfo *info) in ResolveStateAndPredicate() argument
267 if (expr->expr.op == EXPR_ACTION_DECL) { in ResolveStateAndPredicate()
268 const char *pred_txt = xkb_atom_text(info->ctx, expr->action.name); in ResolveStateAndPredicate()
270 !expr->action.args || expr->action.args->common.next) { in ResolveStateAndPredicate()
271 log_err(info->ctx, in ResolveStateAndPredicate()
275 expr = expr->action.args; in ResolveStateAndPredicate()
277 else if (expr->expr.op == EXPR_IDENT) { in ResolveStateAndPredicate()
278 const char *pred_txt = xkb_atom_text(info->ctx, expr->ident.ident); in ResolveStateAndPredicate()
286 return ExprResolveModMask(info->ctx, expr, MOD_REAL, &info->mods, in ResolveStateAndPredicate()
296 if (!(old->defined & field)) in UseNewLEDField()
299 if (new->defined & field) { in UseNewLEDField()
303 if (new->merge != MERGE_AUGMENT) in UseNewLEDField()
311 AddLedMap(CompatInfo *info, LedInfo *new, bool same_file) in AddLedMap() argument
314 const int verbosity = xkb_context_get_log_verbosity(info->ctx); in AddLedMap()
317 for (xkb_led_index_t i = 0; i < info->num_leds; i++) { in AddLedMap()
318 LedInfo *old = &info->leds[i]; in AddLedMap()
320 if (old->led.name != new->led.name) in AddLedMap()
323 if (old->led.mods.mods == new->led.mods.mods && in AddLedMap()
324 old->led.groups == new->led.groups && in AddLedMap()
325 old->led.ctrls == new->led.ctrls && in AddLedMap()
326 old->led.which_mods == new->led.which_mods && in AddLedMap()
327 old->led.which_groups == new->led.which_groups) { in AddLedMap()
328 old->defined |= new->defined; in AddLedMap()
332 if (new->merge == MERGE_REPLACE) { in AddLedMap()
334 log_warn(info->ctx, in AddLedMap()
337 xkb_atom_text(info->ctx, old->led.name)); in AddLedMap()
344 old->led.which_mods = new->led.which_mods; in AddLedMap()
345 old->led.mods = new->led.mods; in AddLedMap()
346 old->defined |= LED_FIELD_MODS; in AddLedMap()
349 old->led.which_groups = new->led.which_groups; in AddLedMap()
350 old->led.groups = new->led.groups; in AddLedMap()
351 old->defined |= LED_FIELD_GROUPS; in AddLedMap()
354 old->led.ctrls = new->led.ctrls; in AddLedMap()
355 old->defined |= LED_FIELD_CTRLS; in AddLedMap()
359 log_warn(info->ctx, in AddLedMap()
362 xkb_atom_text(info->ctx, old->led.name), in AddLedMap()
363 (new->merge == MERGE_AUGMENT ? "first" : "last")); in AddLedMap()
369 if (info->num_leds >= XKB_MAX_LEDS) { in AddLedMap()
370 log_err(info->ctx, in AddLedMap()
375 info->leds[info->num_leds++] = *new; in AddLedMap()
383 if (from->errorCount > 0) { in MergeIncludedCompatMaps()
384 into->errorCount += from->errorCount; in MergeIncludedCompatMaps()
388 into->mods = from->mods; in MergeIncludedCompatMaps()
390 if (into->name == NULL) { in MergeIncludedCompatMaps()
391 into->name = from->name; in MergeIncludedCompatMaps()
392 from->name = NULL; in MergeIncludedCompatMaps()
395 if (darray_empty(into->interps)) { in MergeIncludedCompatMaps()
396 into->interps = from->interps; in MergeIncludedCompatMaps()
397 darray_init(from->interps); in MergeIncludedCompatMaps()
401 darray_foreach(si, from->interps) { in MergeIncludedCompatMaps()
402 si->merge = (merge == MERGE_DEFAULT ? si->merge : merge); in MergeIncludedCompatMaps()
404 into->errorCount++; in MergeIncludedCompatMaps()
408 if (into->num_leds == 0) { in MergeIncludedCompatMaps()
409 memcpy(into->leds, from->leds, sizeof(*from->leds) * from->num_leds); in MergeIncludedCompatMaps()
410 into->num_leds = from->num_leds; in MergeIncludedCompatMaps()
411 from->num_leds = 0; in MergeIncludedCompatMaps()
414 for (xkb_led_index_t i = 0; i < from->num_leds; i++) { in MergeIncludedCompatMaps()
415 LedInfo *ledi = &from->leds[i]; in MergeIncludedCompatMaps()
416 ledi->merge = (merge == MERGE_DEFAULT ? ledi->merge : merge); in MergeIncludedCompatMaps()
418 into->errorCount++; in MergeIncludedCompatMaps()
424 HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge);
427 HandleIncludeCompatMap(CompatInfo *info, IncludeStmt *include) in HandleIncludeCompatMap() argument
431 InitCompatInfo(&included, info->ctx, info->actions, &info->mods); in HandleIncludeCompatMap()
432 included.name = include->stmt; in HandleIncludeCompatMap()
433 include->stmt = NULL; in HandleIncludeCompatMap()
435 for (IncludeStmt *stmt = include; stmt; stmt = stmt->next_incl) { in HandleIncludeCompatMap()
439 file = ProcessIncludeFile(info->ctx, stmt, FILE_TYPE_COMPAT); in HandleIncludeCompatMap()
441 info->errorCount += 10; in HandleIncludeCompatMap()
446 InitCompatInfo(&next_incl, info->ctx, info->actions, &included.mods); in HandleIncludeCompatMap()
447 next_incl.default_interp = info->default_interp; in HandleIncludeCompatMap()
448 next_incl.default_interp.merge = stmt->merge; in HandleIncludeCompatMap()
449 next_incl.default_led = info->default_led; in HandleIncludeCompatMap()
450 next_incl.default_led.merge = stmt->merge; in HandleIncludeCompatMap()
454 MergeIncludedCompatMaps(&included, &next_incl, stmt->merge); in HandleIncludeCompatMap()
460 MergeIncludedCompatMaps(info, &included, include->merge); in HandleIncludeCompatMap()
463 return (info->errorCount == 0); in HandleIncludeCompatMap()
467 SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field, in SetInterpField() argument
474 return ReportSINotArray(info, si, field); in SetInterpField()
476 if (!HandleActionDef(info->ctx, info->actions, &info->mods, in SetInterpField()
477 value, &si->interp.action)) in SetInterpField()
480 si->defined |= SI_FIELD_ACTION; in SetInterpField()
485 return ReportSINotArray(info, si, field); in SetInterpField()
487 if (!ExprResolveMod(info->ctx, value, MOD_VIRT, &info->mods, &ndx)) in SetInterpField()
488 return ReportSIBadType(info, si, field, "virtual modifier"); in SetInterpField()
490 si->interp.virtual_mod = ndx; in SetInterpField()
491 si->defined |= SI_FIELD_VIRTUAL_MOD; in SetInterpField()
497 return ReportSINotArray(info, si, field); in SetInterpField()
499 if (!ExprResolveBoolean(info->ctx, value, &set)) in SetInterpField()
500 return ReportSIBadType(info, si, field, "boolean"); in SetInterpField()
502 si->interp.repeat = set; in SetInterpField()
504 si->defined |= SI_FIELD_AUTO_REPEAT; in SetInterpField()
507 log_dbg(info->ctx, in SetInterpField()
516 return ReportSINotArray(info, si, field); in SetInterpField()
518 if (!ExprResolveEnum(info->ctx, value, &val, useModMapValueNames)) in SetInterpField()
519 return ReportSIBadType(info, si, field, "level specification"); in SetInterpField()
521 si->interp.level_one_only = val; in SetInterpField()
522 si->defined |= SI_FIELD_LEVEL_ONE_ONLY; in SetInterpField()
525 return ReportBadField(info->ctx, "symbol interpretation", field, in SetInterpField()
526 siText(si, info)); in SetInterpField()
533 SetLedMapField(CompatInfo *info, LedInfo *ledi, const char *field, in SetLedMapField() argument
540 return ReportLedNotArray(info, ledi, field); in SetLedMapField()
542 if (!ExprResolveModMask(info->ctx, value, MOD_BOTH, in SetLedMapField()
543 &info->mods, &ledi->led.mods.mods)) in SetLedMapField()
544 return ReportLedBadType(info, ledi, field, "modifier mask"); in SetLedMapField()
546 ledi->defined |= LED_FIELD_MODS; in SetLedMapField()
552 return ReportLedNotArray(info, ledi, field); in SetLedMapField()
554 if (!ExprResolveMask(info->ctx, value, &mask, groupMaskNames)) in SetLedMapField()
555 return ReportLedBadType(info, ledi, field, "group mask"); in SetLedMapField()
557 ledi->led.groups = mask; in SetLedMapField()
558 ledi->defined |= LED_FIELD_GROUPS; in SetLedMapField()
564 return ReportLedNotArray(info, ledi, field); in SetLedMapField()
566 if (!ExprResolveMask(info->ctx, value, &mask, ctrlMaskNames)) in SetLedMapField()
567 return ReportLedBadType(info, ledi, field, "controls mask"); in SetLedMapField()
569 ledi->led.ctrls = mask; in SetLedMapField()
570 ledi->defined |= LED_FIELD_CTRLS; in SetLedMapField()
573 log_dbg(info->ctx, in SetLedMapField()
582 return ReportLedNotArray(info, ledi, field); in SetLedMapField()
584 if (!ExprResolveMask(info->ctx, value, &mask, in SetLedMapField()
586 return ReportLedBadType(info, ledi, field, in SetLedMapField()
589 ledi->led.which_mods = mask; in SetLedMapField()
595 return ReportLedNotArray(info, ledi, field); in SetLedMapField()
597 if (!ExprResolveMask(info->ctx, value, &mask, in SetLedMapField()
599 return ReportLedBadType(info, ledi, field, in SetLedMapField()
602 ledi->led.which_groups = mask; in SetLedMapField()
610 log_dbg(info->ctx, in SetLedMapField()
616 log_err(info->ctx, in SetLedMapField()
621 log_err(info->ctx, in SetLedMapField()
624 field, xkb_atom_text(info->ctx, ledi->led.name)); in SetLedMapField()
632 HandleGlobalVar(CompatInfo *info, VarDef *stmt) in HandleGlobalVar() argument
638 if (!ExprResolveLhs(info->ctx, stmt->name, &elem, &field, &ndx)) in HandleGlobalVar()
641 ret = SetInterpField(info, &info->default_interp, field, ndx, in HandleGlobalVar()
642 stmt->value); in HandleGlobalVar()
644 ret = SetLedMapField(info, &info->default_led, field, ndx, in HandleGlobalVar()
645 stmt->value); in HandleGlobalVar()
647 ret = SetActionField(info->ctx, info->actions, &info->mods, in HandleGlobalVar()
648 elem, field, ndx, stmt->value); in HandleGlobalVar()
653 HandleInterpBody(CompatInfo *info, VarDef *def, SymInterpInfo *si) in HandleInterpBody() argument
659 for (; def; def = (VarDef *) def->common.next) { in HandleInterpBody()
660 if (def->name && def->name->expr.op == EXPR_FIELD_REF) { in HandleInterpBody()
661 log_err(info->ctx, in HandleInterpBody()
668 ok = ExprResolveLhs(info->ctx, def->name, &elem, &field, &arrayNdx); in HandleInterpBody()
672 ok = SetInterpField(info, si, field, arrayNdx, def->value); in HandleInterpBody()
679 HandleInterpDef(CompatInfo *info, InterpDef *def, enum merge_mode merge) in HandleInterpDef() argument
685 if (!ResolveStateAndPredicate(def->match, &pred, &mods, info)) { in HandleInterpDef()
686 log_err(info->ctx, in HandleInterpDef()
692 si = info->default_interp; in HandleInterpDef()
693 si.merge = merge = (def->merge == MERGE_DEFAULT ? merge : def->merge); in HandleInterpDef()
694 si.interp.sym = def->sym; in HandleInterpDef()
698 if (!HandleInterpBody(info, def->def, &si)) { in HandleInterpDef()
699 info->errorCount++; in HandleInterpDef()
703 if (!AddInterp(info, &si, true)) { in HandleInterpDef()
704 info->errorCount++; in HandleInterpDef()
712 HandleLedMapDef(CompatInfo *info, LedMapDef *def, enum merge_mode merge) in HandleLedMapDef() argument
718 if (def->merge != MERGE_DEFAULT) in HandleLedMapDef()
719 merge = def->merge; in HandleLedMapDef()
721 ledi = info->default_led; in HandleLedMapDef()
723 ledi.led.name = def->name; in HandleLedMapDef()
726 for (var = def->body; var != NULL; var = (VarDef *) var->common.next) { in HandleLedMapDef()
729 if (!ExprResolveLhs(info->ctx, var->name, &elem, &field, &arrayNdx)) { in HandleLedMapDef()
735 log_err(info->ctx, in HandleLedMapDef()
741 ok = SetLedMapField(info, &ledi, field, arrayNdx, var->value) && ok; in HandleLedMapDef()
746 return AddLedMap(info, &ledi, true); in HandleLedMapDef()
752 HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge) in HandleCompatMapFile() argument
758 free(info->name); in HandleCompatMapFile()
759 info->name = strdup_safe(file->name); in HandleCompatMapFile()
761 for (ParseCommon *stmt = file->defs; stmt; stmt = stmt->next) { in HandleCompatMapFile()
762 switch (stmt->type) { in HandleCompatMapFile()
764 ok = HandleIncludeCompatMap(info, (IncludeStmt *) stmt); in HandleCompatMapFile()
767 ok = HandleInterpDef(info, (InterpDef *) stmt, merge); in HandleCompatMapFile()
770 log_dbg(info->ctx, in HandleCompatMapFile()
776 ok = HandleLedMapDef(info, (LedMapDef *) stmt, merge); in HandleCompatMapFile()
779 ok = HandleGlobalVar(info, (VarDef *) stmt); in HandleCompatMapFile()
782 ok = HandleVModDef(info->ctx, &info->mods, (VModDef *) stmt, merge); in HandleCompatMapFile()
785 log_err(info->ctx, in HandleCompatMapFile()
787 "Ignoring %s\n", stmt_type_to_string(stmt->type)); in HandleCompatMapFile()
793 info->errorCount++; in HandleCompatMapFile()
795 if (info->errorCount > 10) { in HandleCompatMapFile()
796 log_err(info->ctx, in HandleCompatMapFile()
797 "Abandoning compatibility map \"%s\"\n", file->name); in HandleCompatMapFile()
809 CopyInterps(CompatInfo *info, bool needSymbol, enum xkb_match_operation pred, in CopyInterps() argument
814 darray_foreach(si, info->interps) in CopyInterps()
815 if (si->interp.match == pred && in CopyInterps()
816 (si->interp.sym != XKB_KEY_NoSymbol) == needSymbol) in CopyInterps()
817 darray_append(collect->sym_interprets, si->interp); in CopyInterps()
821 CopyLedMapDefsToKeymap(struct xkb_keymap *keymap, CompatInfo *info) in CopyLedMapDefsToKeymap() argument
823 for (xkb_led_index_t idx = 0; idx < info->num_leds; idx++) { in CopyLedMapDefsToKeymap()
824 LedInfo *ledi = &info->leds[idx]; in CopyLedMapDefsToKeymap()
833 if (led->name == ledi->led.name) in CopyLedMapDefsToKeymap()
837 if (i >= keymap->num_leds) { in CopyLedMapDefsToKeymap()
838 log_dbg(keymap->ctx, in CopyLedMapDefsToKeymap()
841 xkb_atom_text(keymap->ctx, ledi->led.name)); in CopyLedMapDefsToKeymap()
844 if (led->name == XKB_ATOM_NONE) in CopyLedMapDefsToKeymap()
847 if (i >= keymap->num_leds) { in CopyLedMapDefsToKeymap()
850 log_err(keymap->ctx, in CopyLedMapDefsToKeymap()
854 xkb_atom_text(keymap->ctx, ledi->led.name)); in CopyLedMapDefsToKeymap()
859 led = &keymap->leds[keymap->num_leds++]; in CopyLedMapDefsToKeymap()
863 *led = ledi->led; in CopyLedMapDefsToKeymap()
864 if (led->groups != 0 && led->which_groups == 0) in CopyLedMapDefsToKeymap()
865 led->which_groups = XKB_STATE_LAYOUT_EFFECTIVE; in CopyLedMapDefsToKeymap()
866 if (led->mods.mods != 0 && led->which_mods == 0) in CopyLedMapDefsToKeymap()
867 led->which_mods = XKB_STATE_MODS_EFFECTIVE; in CopyLedMapDefsToKeymap()
872 CopyCompatToKeymap(struct xkb_keymap *keymap, CompatInfo *info) in CopyCompatToKeymap() argument
874 keymap->compat_section_name = strdup_safe(info->name); in CopyCompatToKeymap()
875 XkbEscapeMapName(keymap->compat_section_name); in CopyCompatToKeymap()
877 keymap->mods = info->mods; in CopyCompatToKeymap()
879 if (!darray_empty(info->interps)) { in CopyCompatToKeymap()
884 CopyInterps(info, true, MATCH_EXACTLY, &collect); in CopyCompatToKeymap()
885 CopyInterps(info, true, MATCH_ALL, &collect); in CopyCompatToKeymap()
886 CopyInterps(info, true, MATCH_NONE, &collect); in CopyCompatToKeymap()
887 CopyInterps(info, true, MATCH_ANY, &collect); in CopyCompatToKeymap()
888 CopyInterps(info, true, MATCH_ANY_OR_NONE, &collect); in CopyCompatToKeymap()
889 CopyInterps(info, false, MATCH_EXACTLY, &collect); in CopyCompatToKeymap()
890 CopyInterps(info, false, MATCH_ALL, &collect); in CopyCompatToKeymap()
891 CopyInterps(info, false, MATCH_NONE, &collect); in CopyCompatToKeymap()
892 CopyInterps(info, false, MATCH_ANY, &collect); in CopyCompatToKeymap()
893 CopyInterps(info, false, MATCH_ANY_OR_NONE, &collect); in CopyCompatToKeymap()
896 &keymap->sym_interprets, &keymap->num_sym_interprets); in CopyCompatToKeymap()
899 CopyLedMapDefsToKeymap(keymap, info); in CopyCompatToKeymap()
908 CompatInfo info; in CompileCompatMap() local
915 InitCompatInfo(&info, keymap->ctx, actions, &keymap->mods); in CompileCompatMap()
916 info.default_interp.merge = merge; in CompileCompatMap()
917 info.default_led.merge = merge; in CompileCompatMap()
919 HandleCompatMapFile(&info, file, merge); in CompileCompatMap()
920 if (info.errorCount != 0) in CompileCompatMap()
923 if (!CopyCompatToKeymap(keymap, &info)) in CompileCompatMap()
926 ClearCompatInfo(&info); in CompileCompatMap()
931 ClearCompatInfo(&info); in CompileCompatMap()