Changeset 247

Show
Ignore:
Timestamp:
11/26/07 15:39:47 (1 year ago)
Author:
JarrettBillingsley
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/minid/bind.d

    r244 r247  
    466466{ 
    467467    const name32 = ToUTF32!(name); 
    468     ns[name32] = new MDClosure(ns, &WrappedFunc!(func, name, funcType), name32); 
     468    ns[new MDString(name32)] = MDValue(new MDClosure(ns, &WrappedFunc!(func, name, funcType), name32)); 
    469469} 
    470470 
  • trunk/minid/mathlib.d

    r183 r247  
    5252        namespace.addList 
    5353        ( 
    54             "e"d,        tango.math.Math.E, 
    55             "pi"d,       tango.math.Math.PI, 
    56             "nan"d,      mdfloat.nan, 
    57             "infinity"d, mdfloat.infinity, 
    58             "abs"d,      new MDClosure(namespace, &lib.abs,     "math.abs"), 
    59             "sin"d,      new MDClosure(namespace, &lib.sin,     "math.sin"), 
    60             "cos"d,      new MDClosure(namespace, &lib.cos,     "math.cos"), 
    61             "tan"d,      new MDClosure(namespace, &lib.tan,     "math.tan"), 
    62             "asin"d,     new MDClosure(namespace, &lib.asin,    "math.asin"), 
    63             "acos"d,     new MDClosure(namespace, &lib.acos,    "math.acos"), 
    64             "atan"d,     new MDClosure(namespace, &lib.atan,    "math.atan"), 
    65             "atan2"d,    new MDClosure(namespace, &lib.atan2,   "math.atan2"), 
    66             "sqrt"d,     new MDClosure(namespace, &lib.sqrt,    "math.sqrt"), 
    67             "cbrt"d,     new MDClosure(namespace, &lib.cbrt,    "math.cbrt"), 
    68             "pow"d,      new MDClosure(namespace, &lib.pow,     "math.pow"), 
    69             "exp"d,      new MDClosure(namespace, &lib.exp,     "math.exp"), 
    70             "ln"d,       new MDClosure(namespace, &lib.ln,      "math.ln"), 
    71             "log2"d,     new MDClosure(namespace, &lib.log2,    "math.log2"), 
    72             "log10"d,    new MDClosure(namespace, &lib.log10,   "math.log10"), 
    73             "hypot"d,    new MDClosure(namespace, &lib.hypot,   "math.hypot"), 
    74             "lgamma"d,   new MDClosure(namespace, &lib.lgamma,  "math.lgamma"), 
    75             "gamma"d,    new MDClosure(namespace, &lib.gamma,   "math.gamma"), 
    76             "ceil"d,     new MDClosure(namespace, &lib.ceil,    "math.ceil"), 
    77             "floor"d,    new MDClosure(namespace, &lib.floor,   "math.floor"), 
    78             "round"d,    new MDClosure(namespace, &lib.round,   "math.round"), 
    79             "trunc"d,    new MDClosure(namespace, &lib.trunc,   "math.trunc"), 
    80             "isNan"d,    new MDClosure(namespace, &lib.isNan,   "math.isNan"), 
    81             "isInf"d,    new MDClosure(namespace, &lib.isInf,   "math.isInf"), 
    82             "sign"d,     new MDClosure(namespace, &lib.sign,    "math.sign"), 
    83             "rand"d,     new MDClosure(namespace, &lib.rand,    "math.rand") 
     54            "e"d,         tango.math.Math.E, 
     55            "pi"d,        tango.math.Math.PI, 
     56            "nan"d,       mdfloat.nan, 
     57            "infinity"d,  mdfloat.infinity, 
     58            "int_min"d,   int.min, 
     59            "int_max"d,   int.max, 
     60            "float_min"d, mdfloat.min, 
     61            "float_max"d, mdfloat.max, 
     62            "abs"d,       new MDClosure(namespace, &lib.abs,     "math.abs"), 
     63            "sin"d,       new MDClosure(namespace, &lib.sin,     "math.sin"), 
     64            "cos"d,       new MDClosure(namespace, &lib.cos,     "math.cos"), 
     65            "tan"d,       new MDClosure(namespace, &lib.tan,     "math.tan"), 
     66            "asin"d,      new MDClosure(namespace, &lib.asin,    "math.asin"), 
     67            "acos"d,      new MDClosure(namespace, &lib.acos,    "math.acos"), 
     68            "atan"d,      new MDClosure(namespace, &lib.atan,    "math.atan"), 
     69            "atan2"d,     new MDClosure(namespace, &lib.atan2,   "math.atan2"), 
     70            "sqrt"d,      new MDClosure(namespace, &lib.sqrt,    "math.sqrt"), 
     71            "cbrt"d,      new MDClosure(namespace, &lib.cbrt,    "math.cbrt"), 
     72            "pow"d,       new MDClosure(namespace, &lib.pow,     "math.pow"), 
     73            "exp"d,       new MDClosure(namespace, &lib.exp,     "math.exp"), 
     74            "ln"d,        new MDClosure(namespace, &lib.ln,      "math.ln"), 
     75            "log2"d,      new MDClosure(namespace, &lib.log2,    "math.log2"), 
     76            "log10"d,     new MDClosure(namespace, &lib.log10,   "math.log10"), 
     77            "hypot"d,     new MDClosure(namespace, &lib.hypot,   "math.hypot"), 
     78            "lgamma"d,    new MDClosure(namespace, &lib.lgamma,  "math.lgamma"), 
     79            "gamma"d,     new MDClosure(namespace, &lib.gamma,   "math.gamma"), 
     80            "ceil"d,      new MDClosure(namespace, &lib.ceil,    "math.ceil"), 
     81            "floor"d,     new MDClosure(namespace, &lib.floor,   "math.floor"), 
     82            "round"d,     new MDClosure(namespace, &lib.round,   "math.round"), 
     83            "trunc"d,     new MDClosure(namespace, &lib.trunc,   "math.trunc"), 
     84            "isNan"d,     new MDClosure(namespace, &lib.isNan,   "math.isNan"), 
     85            "isInf"d,     new MDClosure(namespace, &lib.isInf,   "math.isInf"), 
     86            "sign"d,      new MDClosure(namespace, &lib.sign,    "math.sign"), 
     87            "rand"d,      new MDClosure(namespace, &lib.rand,    "math.rand"), 
     88            "frand"d,     new MDClosure(namespace, &lib.frand,   "math.frand") 
    8489        ); 
    8590         
     
    283288    int rand(MDState s, uint numParams) 
    284289    { 
     290        uint num = Random.shared.next(); 
     291 
    285292        switch(numParams) 
    286293        { 
    287294            case 0: 
    288                 s.push(cast(int)Random.shared.next()); 
     295                s.push(cast(int)num); 
    289296                break; 
    290297 
    291298            case 1: 
    292                 s.push(cast(uint)Random.shared.next() % s.getParam!(int)(0)); 
     299                s.push(cast(uint)num % s.getParam!(int)(0)); 
    293300                break; 
    294301 
     
    296303                int lo = s.getParam!(int)(0); 
    297304                int hi = s.getParam!(int)(1); 
    298                  
    299                 s.push(cast(int)(Random.shared.next() % (hi - lo)) + lo); 
     305 
     306                s.push(cast(int)(num % (hi - lo)) + lo); 
    300307                break; 
    301308        } 
     
    303310        return 1; 
    304311    } 
     312 
     313    int frand(MDState s, uint numParams) 
     314    { 
     315        auto num = cast(mdfloat)Random.shared.next() / uint.max; 
     316 
     317        switch(numParams) 
     318        { 
     319            case 0: 
     320                s.push(num); 
     321                break; 
     322 
     323            case 1: 
     324                s.push(num * s.getParam!(mdfloat)(0)); 
     325                break; 
     326 
     327            default: 
     328                auto lo = s.getParam!(mdfloat)(0); 
     329                auto hi = s.getParam!(mdfloat)(1); 
     330 
     331                s.push((num * (hi - lo)) + lo); 
     332                break; 
     333        } 
     334         
     335        return 1; 
     336    } 
    305337} 
  • trunk/test.d

    r242 r247  
    66import tango.io.Stdout; 
    77 
     8version = Arc; 
     9 
    810void main() 
    911{ 
     
    1315    { 
    1416        ctx = NewContext(); 
    15         //LoadArc(ctx); 
     17 
     18        version(Arc) 
     19            LoadArc(ctx); 
    1620 
    1721        ctx.addImportPath(`samples`); 
     
    3034} 
    3135 
    32 /+ 
     36version(Arc) 
     37
     38 
    3339import arc.draw.color; 
    3440import arc.draw.image; 
     
    335341        .func!(arc.time.limitFPS)() 
    336342        .func!(arc.time.getTime)(); 
    337              
     343 
     344    MDNamespace coordinates = new MDNamespace("coordinates"); 
     345     
     346    with(arc.window.coordinates) 
     347    { 
     348        WrapFunc!(setSize)(coordinates); 
     349        WrapFunc!(setOrigin)(coordinates); 
     350        WrapFunc!(getSize)(coordinates); 
     351        WrapFunc!(getWidth)(coordinates); 
     352        WrapFunc!(getHeight)(coordinates); 
     353        WrapFunc!(getOrigin)(coordinates); 
     354    } 
     355 
    338356    WrapModule("arc.window", ctx) 
    339357        .func!(arc.window.open)() 
    340358        .func!(arc.window.close)() 
     359        .func!(arc.window.getWidth)() 
     360        .func!(arc.window.getHeight)() 
     361        .func!(arc.window.getSize)() 
     362        .func!(arc.window.isFullScreen)() 
     363        .func!(arc.window.resize)() 
     364        .func!(arc.window.toggleFullScreen)() 
    341365        .func!(arc.window.clear)() 
    342         .func!(arc.window.swap)(); 
    343 }+/ 
     366        .func!(arc.window.swap)() 
     367        .func!(arc.window.swapClear)() 
     368        .func!(arc.window.screenshot)() 
     369        .custom("coordinates", coordinates); 
     370
     371 
     372