Changeset 837 for trunk/mkstructinfo.awk


Ignore:
Timestamp:
2012-03-25T04:14:44+02:00 (2 years ago)
Author:
moo
Message:

PHP_5_4: improves traits support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mkstructinfo.awk

    r719 r837  
    55    incomment = 0; 
    66    buffer_len = 0; 
     7} 
     8function printstruct(structname) { 
     9    printf "define(`ELEMENTSOF_%s', `%s')\n", structname, ELEMENTSOF[structname]; 
     10    printf "define(`COUNTOF_%s', `%s')\n", structname, COUNTOF[structname]; 
     11    printf "define(`SIZEOF_%s', `(  %s  )')\n", structname, SIZEOF[structname]; 
    712} 
    813 
     
    3540    if (instruct) { 
    3641        sub(";", ""); 
    37         if (instruct == 1 && $2) { 
    38             instruct = $2; 
     42        structname = instruct; 
     43        if (structname == 1 && $2) { 
     44            structname = $2; 
    3945        } 
    40         if (instruct in typedefs) { 
    41             instruct = typedefs[instruct]; 
     46        if (structname in typedefs) { 
     47            structname = typedefs[structname]; 
    4248        } 
    4349        sizeinfo = ""; 
     
    4753                sizeinfo = sizeinfo " + "; 
    4854            } 
    49             sizeinfo = sizeinfo "sizeof(((" instruct "*)NULL)->" buffer[i] ")"; 
     55            sizeinfo = sizeinfo "sizeof(((" structname "*)NULL)->" buffer[i] ")"; 
    5056 
    5157            if (i == 0) { 
     
    5662            } 
    5763        } 
    58         printf "define(`ELEMENTSOF_%s', `%s')\n", instruct, elms; 
    59         printf "define(`COUNTOF_%s', `%s')\n", instruct, i; 
    60         printf "define(`SIZEOF_%s', `(  %s  )')\n", instruct, sizeinfo; 
     64        ELEMENTSOF[structname] = elms; 
     65        COUNTOF[structname]    = i; 
     66        SIZEOF[structname]     = sizeinfo; 
     67        printstruct(structname); 
    6168        print "\n"; 
    6269        for (i in buffer) { 
     
    149156/^typedef struct [^{]*;/ { 
    150157    sub(";", ""); 
    151     typedefs[$3] = $4; 
     158    typename=$3; 
     159    newtypename=$4; 
     160    typedefs[typename] = newtypename; 
     161    if (ELEMENTSOF[typename]) { 
     162        ELEMENTSOF[newtypename] = ELEMENTSOF[typename]; 
     163        COUNTOF[newtypename]    = COUNTOF[typename]; 
     164        sub(/.*/, SIZEOF[typename]); 
     165        gsub(typename, newtypename); 
     166        SIZEOF[newtypename]     = $0; 
     167        printstruct(newtypename); 
     168    } 
    152169    next; 
    153170} 
Note: See TracChangeset for help on using the changeset viewer.