Changeset 20818 for lang/cplusplus

Show
Ignore:
Timestamp:
10/05/08 23:35:19 (2 months ago)
Author:
tokuhirom
Message:

refactoring document generator

Location:
lang/cplusplus/llv8call/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/cplusplus/llv8call/trunk/manual/ext/index.html

    r20816 r20818  
    1919        <ul> 
    2020            <li><a href="clearsilver/clearsilver.html">clearsilver.clearsilver</a></li> 
    21             <li><a href="sqlite3/sqlite3.html">sqlite3.sqlite3</a></li> 
    2221            <li><a href="fs/dir.html">fs.dir</a></li> 
    2322            <li><a href="fs/file.html">fs.file</a></li> 
     
    2524            <li><a href="mysql/mysql.html">mysql.mysql</a></li> 
    2625            <li><a href="shttpd/shttpd.html">shttpd.shttpd</a></li> 
     26            <li><a href="sqlite3/sqlite3.html">sqlite3.sqlite3</a></li> 
    2727        </ul> 
    2828        <a href="../index.html">up</a> 
  • lang/cplusplus/llv8call/trunk/t/020_ext/08_clearsilver.js

    r20788 r20818  
    3737}()); 
    3838 
     39(function () { 
     40    clearsilver.HDF.prototype.SetAny = function (base, stuff) { 
     41        switch (typeof stuff) { 
     42        case 'boolean': 
     43        case 'string': 
     44        case 'null': 
     45        case 'number': 
     46            this.SetValue(base, stuff); 
     47            break; 
     48        case 'object': 
     49        case 'array': 
     50            for (key in stuff) { 
     51                this.SetAny(base + "." + key, stuff[key]); 
     52            } 
     53            break; 
     54        case 'function': 
     55            throw "cannot use function"; 
     56        default: 
     57            throw "unknown stuff: " + typeof(stuff); 
     58        } 
     59    }; 
     60 
     61    var test = function (stuff, expected) { 
     62        var hdf = new clearsilver.HDF(); 
     63        hdf.SetAny("data", stuff); 
     64        is(hdf.DumpStr(undefined, 0), expected); 
     65        hdf.Close(); 
     66    }; 
     67 
     68    test(1, "data = 1\n"); 
     69    test([1,2,3], 
     70        "data.0 = 1\n" + 
     71        "data.1 = 2\n" + 
     72        "data.2 = 3\n" 
     73    ); 
     74    test({"foo":"bar", "baz":"eee"}, 
     75        "data.foo = bar\n" + 
     76        "data.baz = eee\n" 
     77    ); 
     78    test({"foo":[1,2,3], "baz":"eee"}, 
     79        "data.foo.0 = 1\n" + 
     80        "data.foo.1 = 2\n" + 
     81        "data.foo.2 = 3\n" + 
     82        "data.baz = eee\n" 
     83    ); 
     84}()); 
     85 
  • lang/cplusplus/llv8call/trunk/tools/makedoc/make-docs.js

    r20815 r20818  
    44var TMPLDIR = 'tools/makedoc/tmpl'; 
    55 
    6 clearsilver.HDF.prototype.AddArray = function (basekey, ary) { 
    7     for (var i=0; i<ary.length; i++) { 
    8         this.SetValue(basekey + "." + i, ary[i]); 
    9     } 
    10 }; 
    11 clearsilver.HDF.prototype.AddHash = function (basekey, hash) { 
    12     for (i in hash) { 
    13         this.SetValue(basekey + "." + i, hash[i]); 
     6clearsilver.HDF.prototype.SetAny = function (base, stuff) { 
     7    switch (typeof stuff) { 
     8    case 'boolean': 
     9    case 'string': 
     10    case 'null': 
     11    case 'number': 
     12        this.SetValue(base, stuff); 
     13        break; 
     14    case 'object': 
     15    case 'array': 
     16        for (key in stuff) { 
     17            this.SetAny(base + "." + key, stuff[key]); 
     18        } 
     19        break; 
     20    case 'function': 
     21        throw "cannot use function"; 
     22    default: 
     23        throw "unknown stuff: " + typeof(stuff); 
    1424    } 
    1525}; 
     
    6070        var hdf = new clearsilver.HDF(); 
    6171        var res; 
    62         for (var i=0; i<data.modules.length; i++) { 
    63             var entry = data.modules[i]; 
    64             var basekey = "data.modules." + i 
    65             hdf.SetValue(basekey + ".CLASSNAME", entry['CLASSNAME']); 
    66             hdf.AddArray(basekey + ".CCV", entry["CCV"]); 
    67             hdf.AddArray(basekey + ".CM",  entry["CM"]); 
    68             hdf.AddArray(basekey + ".IM",  entry["IM"]); 
    69         } 
    70         if(data.sections.SYNOPSIS) { 
    71             hdf.SetValue("data.sections.SYNOPSIS", data.sections.SYNOPSIS); 
    72         } 
    73         if(data.sections.DESCRIPTION) { 
    74             hdf.SetValue("data.sections.DESCRIPTION", data.sections.DESCRIPTION); 
    75         } 
    76         // p(hdf.DumpStr(undefined, 0)); 
     72        hdf.SetAny("data", data); 
     73        //p(hdf.DumpStr(undefined, 0)); 
    7774        var cs = new clearsilver.CS(hdf); 
    7875        cs.ParseFile(TMPLDIR + "/doc.cs"); 
     
    144141            var res; 
    145142            for (i in pages) { 
    146                 hdf.AddHash("pages." + i, {"url":pages[i], "title":pages[i].replace(".html", '').replace("/", ".")}); 
     143                hdf.SetAny("pages." + i, {"url":pages[i], "title":pages[i].replace(".html", '').replace("/", ".")}); 
    147144            } 
    148145            // p(hdf.DumpStr(undefined, 0));