On 4 May 2011 19:40, Jeff Johnson <jeffjohns...@gmail.com> wrote: > So let me see if I can combine the thoughts I've heard and make a proposal: > > 1. Split enum.h into two files. enum.h for game stuff and > enum-for-tile-clients.h. > 2. The client enum header file will contain valid enum's and #ifdefs, > but no other variable declarations or prototypes. > 3. Create a perl script to parse enum-for-tile-clients.h and create > an enum-for-tile-clients.js > 4. enum-for-tile-clients.js is the mapping of enum names to numbers > to use for the Javascript client. > 5. JSClientOutput.cc (code that will create Javascript description of > GUI to be sent to Javascript client) will use numbers in place of > enums. > > Let me know if this proposal works for everyone.
Sounds good. > It sounds o.k. to me, but my perl knowledge is not that great. Is > there a volunteer to start the perl script? If someone can read the > enum.h file into data structures, I can output the correct stuff. > If not, I can muddle through it. :) If you do know some perl, it's not that difficult and a good opportunity to polish up your perl skills. You probably don't even need to know which data type a given enum belongs to. A simple list mapping all enums to their internal values might already be enough. Have a look at cmd-name.pl in the util directory for how to read information from a single file and output the processed data into another file. The enum header file follows a very strict syntax that should be easy to parse. Basically, you check each line for the "enum" keyword and start counting at zero at the line following it, skipping all comments. Worst case, enum definitions use the syntax "ENUM_DEF = 20, // comment" that can be read out using regexes (e.g. /\W([\w_]+)(\s*=\s*(\d+))?,/) with $1 as the enum and $3 (if defined) as the new value for the internal counter). Eventually, you might have to include checks for other commenting styles (/**/ or #if 0) but that can wait until the basic parsing works (and can be handled by adding a single boolean for whether the current code is commented out or not). As for the TAG_MAJOR_VERSION checks, as long as KiloByte is on the team (may he stay for a long while :)) you can be sure that these checks always refer to the current version and can simply treat them as true. Good luck with your coding, Johanna ------------------------------------------------------------------------------ WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd _______________________________________________ Crawl-ref-discuss mailing list Crawl-ref-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/crawl-ref-discuss