Converting iso-4217-currencies.scm to C?

Phil Longstaff plongstaff at rogers.com
Mon Feb 9 12:14:20 EST 2009


On February 9, 2009 11:54:54 am Derek Atkins wrote:
> Christian Stimming <stimming at tuhh.de> writes:
> > Right now we have a scheme -> C generator that generates a list of 3000
> > function calls. I think Alan's proposal was to change this into a
> > generator that generates a C array with 3000 entries, and writing some
> > simple looping code that loops over this array. In effect, I think this
> > isn't much of a difference (meaning Alan's time can probably be spent on
> > more important things instead), but if Alan would like to submit a patch,
> > I'd probably agree to commit this.
>
> That seems relatively silly, IMHO.  Why have scheme generate a
> C array?  Why not just encode the list in the C array in the first
> place?
>
> I.e., I can imagine something like:
>
> typedef struct {
>   const char* fullname;
>   const char* unitname;
>   const char* partname;
>   const char* namespace;
>   const char* mnemonic;
>   const char* exchange_code;
>   unsigned    parts_per_unit;
>   unsigned    smallest_fraction;
> } GNCCurrencyDef;
>
> static GNCCurrencyDef gncISOCurrencies[] = {
>  { "Afghanistan Afghani (old)", "afghani", "pul", "ISO4217", "AFA", "004",
> 100, 100 }, // through 2003-01-02 { "Afghanistan Afghani", "afghani",
> "afghani", "ISO4217", "AFN", "971", 1, 1 }, // from 2002-10-07 ...
> };
>
> Alan, is this what you had in mind?

Any reason to build these into the code and not just in an external data file 
(either text or XML)?

Phil


More information about the gnucash-devel mailing list