Re: [CEDET-devel] [PATCH] srt: Upcase and (re)normalize FILENAME_SYMBOL
Brought to you by:
zappo
From: Eric M. L. <er...@si...> - 2013-01-18 02:54:41
|
On 01/15/2013 01:41 PM, Lluís wrote: > Eric M Ludlam writes: >> Hi Lluis, > >> I agree with the typical use being all uppercase for for C code macros, such as: > >> #ifdef MYHEADER_H >> #define MYHEADER_H 1 >> ... > >> #endif > >> I wonder if it is instead better to tweak the template to upcase on a >> per-usecase basis (see patch), or always for that symbol. > >> I'm curious what other C / C++ developers think. Is a same-case symbol of the >> filename useful? > > I've never got to need it, but you never know; so I'd go for your patch (note > that my patch also contains a fix on the symbol generation). Ok, I'll check in a mix of the two then after running the unit tests. > BTW, I don't really use srecode very much, but I'm curious how would you > implement the following header guard pattern (which I use very often): > > * take the file path relative to the project root > * eliminate uninformative prefix directories (e.g., "src/" or "include/") I'd go into srecode/cpp.el and add a new dictionary entry for the :c argument, perhaps PROJECT_FILENAME_SYMBOL, and calculate it. EDE can tell you the file name with file-relative-name against (ede-toplevel-project default-directory) and the current file. > * replace the directory separator with "__" > * replace symbols by "_" Your new code snippet would do some of that. > * upcase Probably in the use of the new dictionary entry. > So, for example, "foo/bar.h" would be "FOO__BAR_H". This concept seems useful. The attached patch adds a new argument called :project that could be used to add a variable similar to what you asked for. I tried it out, and it seems to work ok. Eric |