Uri Guttman <[EMAIL PROTECTED]> wrote:

> boy, was this easy with this module. all we need to do is mess around
> with the output to get whatever leo needs.

s/leo/Joe R. Parrot Hacker/ - I can craft initializers by hand ;)

1) some script e.g. gen_struct (struct2pasm ...) located in tools/dev or
build_tools.

2) options:

   --gen-pasm, -p    (default, *if* src file =~ /\.pasm$/
   --pmc=Px          (for --gen-pasm only, default P15)
   --gen-pir         (default)
   --named-initializer=0,1   (1)
   --named-accessor=0,1      (0)
   --out-file, -o=file (default: change input in place unless stdin)

3) Operation

3a) Take a C structure, spit out initializer
3b) take a commented C structure, add or change initializer
    3b) is for source-files that may contain multiple C structures
        like in my original posting WRT this util or like below

> with this struct (from leo with some minor changes):

## &gen_struct(--options, --pmc=P20, --gen-pasm)
# struct xt {
#       char x;
#       struct yt {
#               char i,k;
#               int  j;
#       } Y;
#       char z;
#} X;
## &end_gen

## begin autogeneratedd bla bla

4) The output
4a) initializer name / P-register  => $init_pmc

   new P20, .OrderedHash       # .PerlArray if --no-named-initializer

 or
   .local pmc struct_xt_init   # --gen-pir
   struct_xt_init = new OrderedHash

 and

   .include "datatypes.pasm"    # for DATATYPE_ consts below

4b) data type of item

   push $init_pmc, .DATATYPE_$type  # --no-named-init...

 or

   set $init_pmc["$var"], .DATATYPE_$type  # --name-init..

 If item is a nested struct or a pointer to nested struct please
 consult docs/pmc/struct.pod

4c) item count = 0, or N for array of items

   push $init_pmc, $item_count

4d) offset - always 0 for now

   push $init_pmc, 0

4e) nice to have: preserve C comments (put these after '#')


S. also t/pmc/nci.t for examples of initializers and src/nci_test.c for
the referenced C structs.

I hope above outline is somewhat clear else please just ask.

> uri

leo

Reply via email to