Changeset 772

Show
Ignore:
Timestamp:
03/28/10 17:09:18 (2 years ago)
Author:
Mike Wey
Message:

some more work on GtkClass?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/gtkD2/wrap/utils/GtkClass.d

    r771 r772  
    1919module utils.GtkClass; 
    2020 
     21import std.array; 
     22import std.algorithm; 
     23import std.string : strip, splitlines, chompPrefix; 
     24 
    2125import utils.ConvParms; 
    2226import utils.HtmlStrip; 
     27import utils.Utils; 
    2328 
    2429class GtkClass 
     
    4550        string api = HtmlStrip.stripFile(convParms.inFile); 
    4651 
    47         getParent( api.find("\nObject Hierarchy\n").consumeUntil("\n\n") ); 
    48         getDescription( api.find("\nDescription\n").consumeUntil("\nDetails\n") ); 
    49  
    50 //      getMembers( getBlock("Details") ); 
    51 //      getProperties( getBlock("Property Details"); ); 
    52 //      getStyleProperties( getBlock("Style Property Details") ); 
    53 //     getSignals( getBlock("Signal Details") ); 
     52        getParent( getBlock(api, "Object Hierarchy") ); 
     53        getDescription( getBlock(api, "Description") ); 
     54        getMembers( getBlock(api, "Details") ); 
     55//      getProperties( getBlock(api, "Property Details") ); 
     56//      getProperties( getBlock(api, "Child Property") ); 
     57//      getProperties( getBlock(api, "Style Property Details") ); 
     58       getSignals( getBlock(api, "Signal Details") ); 
    5459    } 
    5560 
    56     void getParrent(string api) 
     61    void getParent(string api) 
    5762    { 
    5863        string[] lines = api.strip().splitlines(); 
     
    7479    } 
    7580 
    76     string getBlock(string api, string block); 
     81    void getMembers(string api) 
     82    { 
     83        while ( !api.empty ) 
     84        { 
     85            getMember(api.consumeUntil("<hr>")); 
     86        } 
     87    } 
     88 
     89    void getMember(string api) 
     90    { 
     91        string[] lines = api.splitlines(); 
     92 
     93        if ( lines.length < 2 ) 
     94            return; 
     95 
     96        if ( endsWith(lines[0], "()") ) 
     97        { 
     98            //Function. 
     99        } 
     100        else if ( startsWith(lines[1], "typedef enum") ) 
     101        { 
     102            //Enum 
     103        } 
     104        else if ( startsWith(lines[1], "typedef struct", "struct") ) 
     105        { 
     106            //Struct 
     107        } 
     108        else if ( startsWith(lines[0], "union") ) 
     109        { 
     110            //Union 
     111        } 
     112        else if ( startsWith(lines[1], "typedef") ) 
     113        { 
     114            //Alias 
     115        } 
     116        else if ( startsWith(lines[0], "GTK_STOCK_") ) 
     117        { 
     118            //Stock icons 
     119        } 
     120        else if ( startsWith(lines[0], "G_TYPE_") && convParms.outFile == "Type" ) 
     121        { 
     122            //Type 
     123        } 
     124    } 
     125 
     126    void getSignals(string api) 
     127    { 
     128 
     129    } 
     130 
     131    string getBlock(string api, string block) 
    77132    { 
    78133        block = "\n" ~ block ~ "\n"; 
     
    81136        api = api.find(block).chompPrefix(block); 
    82137 
     138        //Special case because of the block ending. 
     139        if ( block == "\nObject Hierarchy\n" ) 
     140        { 
     141            api.consumeUntil("\n\n"); 
     142            return api; 
     143        } 
     144 
    83145        //Consume until the posible endings in reverse order 
    84146        //so only the current block remains. 
     
    86148        api = api.consumeUntil("\nSignal Details\n"); 
    87149        api = api.consumeUntil("\nStyle Property Details\n"); 
     150        api = api.consumeUntil("\nChild Property Details\n"); 
    88151        api = api.consumeUntil("\nProperty Details\n"); 
     152        api = api.consumeUntil("\nDetails\n") 
    89153 
    90         return block
     154        return api
    91155    } 
    92156}