[Github-comments] [geany/geany] TM cleanups (#957)

Colomban Wendling notifications at xxxxx
Wed May 4 17:19:48 UTC 2016


> +};
> +
> +/* not in universal-ctags */
> +static TMParserMapEntry powershell_map[] = {
> +	{'f', tm_tag_function_t},
> +	{'v', tm_tag_variable_t},
> +};
> +
> +
> +typedef struct
> +{
> +    TMParserMapEntry *entries;
> +    guint size;
> +} TMParserMap;
> +
> +#define MAP_ENTRY(map) {map, (sizeof(map)/sizeof(TMParserMapEntry))}

> Could do the macro stuff you suggest too, just to me it usually takes more time to decode what macros with ## do than not using such features ;-).

It sure hides some logic, but OTOH it can avoid typos in repetitive code, as well as making it easier to change it.
In this case, instead of doing `[TM_PARSER_C] = { map_C, G_N_ELEMENTS(map_C) }` we get `MAP_ENTRY(C)`, which, IMO, is worth it, esp. as it's very repetitive.

BTW, I see I made a typo in my previous post's macro, missing the `TM_PARSER_##` prefix to `lang`.

> After posting the patch I realized it would be probably nicer instead of doing […]

Indeed.  Can even be a simple `#define map_CPP map_C` avoiding any actual data duplication.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/957/files/aea7d7845917843dd6b02e5a8dc9031cabc87a86..5d9376ea801a6e6c3ec22748741362a3a2eff7ac#r62078649
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20160504/e607500e/attachment.html>


More information about the Github-comments mailing list