Changeset 281

Show
Ignore:
Timestamp:
03/27/10 08:24:14 (2 years ago)
Author:
dhasenan
Message:

Some updates, not sure what exactly.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dconstructor/trunk/dconstructor/build2.d

    r280 r281  
    7171        circular = new Circular (stack); 
    7272        defaultLifecycle = new SingletonLifecycle; 
    73         lifecycleProviders ~= new InstanceLifecycleProvider; 
    74         lifecycleProviders ~= new SingletonLifecycleProvider; 
     73        auto instance = new InstanceLifecycleProvider; 
     74        assert (instance !is null); 
     75        auto singleton = new SingletonLifecycleProvider; 
     76        assert (singleton !is null); 
     77        lifecycleProviders = [cast(ILifecycleProvider)instance, singleton].dup; 
    7578    } 
    7679 
     
    134137    Builder provide(T) (T value) 
    135138    { 
    136         void[] arr = (cast(void*) (&value))[0 .. T.sizeof]; 
     139        static if (is (T == interface)) 
     140        { 
     141            // always store interface values as Object 
     142            Object o = cast(Object) value; 
     143            void[] arr = (cast(void*) (&o))[0 .. Object.sizeof]; 
     144        } 
     145        else 
     146        { 
     147            void[] arr = (cast(void*) (&value))[0 .. T.sizeof]; 
     148        } 
    137149        registerBuilder (typeid(T), new ConstantBuilder (arr), null); 
    138150        return this; 
     
    222234        foreach (provider; lifecycleProviders) 
    223235        { 
     236            assert (provider !is null); 
    224237            auto cycle = provider.get(type); 
    225             if (cycle) return cycle; 
     238            if (cycle)  
     239            { 
     240                return cycle; 
     241            } 
    226242        } 
    227243        return defaultLifecycle; 
  • dconstructor/trunk/dconstructor/circular.d

    r269 r281  
    33import dconstructor.stack; 
    44import dconstructor.exception; 
     5import tango.io.Stdout; 
    56 
    67// Something can be in here many times -- once for a constructor, and once 
     
    2223    in 
    2324    { 
    24         assert (_stack.last () is info, "trying to exit a constructor that has not been entered -- this is a bug"); 
     25        assert (_stack !is null); 
     26        assert (info !is null, "tried to exit constructor for null typeinfo"); 
     27        auto last = _stack.last; 
     28        assert (last !is null); 
     29    } 
     30    out 
     31    { 
     32        assert (!_stack.contains (info)); 
    2533    } 
    2634    body 
    2735    { 
    2836        _stack.pop (); 
    29         assert (!_stack.contains (info)); 
    3037    } 
    3138 
  • dconstructor/trunk/dconstructor/lifecycles.d

    r271 r281  
    4242{ 
    4343    private InstanceLifecycle _single; 
     44 
    4445    this () 
    4546    { 
  • dconstructor/trunk/dconstructor/property.d

    r268 r281  
    3030    static this () 
    3131    { 
    32         builder().bind!(` ~ T.stringof ~ `, typeof(this)); 
     32        auto b = builder; 
     33        builder.bind!(` ~ T.stringof ~ `, typeof(this)); 
    3334    } 
    3435    `; 
  • dconstructor/trunk/dconstructor/subbuilders.d

    r272 r281  
    5959    this (void[] instance) 
    6060    { 
    61         this.instance = instance
     61        this.instance = instance.dup
    6262    } 
    6363 
     
    7979    void build (Builder parent, void* fill) 
    8080    { 
    81         parent.circular.push (typeid(T)); 
     81        auto t = typeid(T); 
     82        parent.circular.push (t); 
    8283        auto object = get (parent); 
    83         parent.circular.endCtor (typeid(T)); 
     84        parent.circular.endCtor (t); 
    8485        static if (is (typeof(T.inject) == function)) 
    8586        { 
  • dconstructor/trunk/examples/LICENSE.TXT

    r132 r281  
    1 The documentation and examples in this directory are copyright 2008 by Christopher Wright. It is released under the WTFPL: 
     1The documentation and examples in this directory are originally copyright 2008 by Christopher Wright. It is released under public domain where applicable, otherwise under the WTFPL: 
    22 
    33DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
     
    550. You just DO WHAT THE FUCK YOU WANT TO.  
    66 
     7 
  • dconstructor/trunk/examples/custom.d

    r269 r281  
    5353{ 
    5454    auto build = builder (); 
    55     builder ().autobuild (true)
     55    builder ().autobuild = true
    5656    auto special = new SpecializedBuilder!(typeof(build)) (); 
    57     builder ().config.custom!(Specialized) (special); 
     57    builder ().provide!(Specialized) (special); 
    5858    builder ().get!(NeedsSpecialized); 
    5959    builder ().get!(WantsSpecialized); 
  • dconstructor/trunk/examples/speedctor.d

    r268 r281  
    11module speedctor; 
    22 
    3 //import dconstructor.api; 
    4 //import dconstructor.default_builder; 
    53import tango.io.Stdout; 
    64import tango.time.StopWatch; 
     
    86void main () 
    97{ 
    10 //  builder ().register!(Thingaaaaa); 
    11 //  builder ().get!(Thingaaaaa); 
    12     Stdout.formatln ("built 10,000 iterations in {} seconds with instances", -1); 
    138    StopWatch watch; 
    149    watch.start (); 
    15     Stdout.formatln ("built 10,000 iterations in {} seconds with instances", -1); 
    1610    for (int i = 0; i < 10_000; i++) 
    1711        new Thing (); 
    18     Stdout.formatln ("built 10,000 iterations in {} seconds with instances", -1); 
    1912    double d = watch.stop (); 
    2013    Stdout.formatln ("built 10,000 iterations in {} seconds with instances", d);