Changeset 97

Show
Ignore:
Timestamp:
08/13/08 10:19:30 (4 years ago)
Author:
dhasenan
Message:

minor improvements and documentation fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dconstructor/TODO

    r94 r97  
    44custom providers 
    55    I want to give a different logger instance for each type being built, with the name of the relevant classe. 
    6     This requires some sort of Context object, with information on the build stack. 
    76 
    8 The system for interface bindings is not to my liking. You end up building an interface, and that depends on the concrete implementation...not very nice. 
    9  
    10 Singletons are intercepted every time they are provided. This is not good. 
  • trunk/dconstructor/dconstructor/build.d

    r95 r97  
    3636     
    3737    /** 
    38      * Get an instance of type T. T can be anything -- primitive, array, 
    39      * interface, struct, or class. 
     38     * Get an instance of type T. T can be an interface or class. 
    4039     * 
    4140     * If T is an interface and there are no bindings for it, throw a 
    42      * BindingException. 
     41     * BindingException. If T is a class that was not registered, and 
     42     * autobuild is set to false, throw a BindingException. 
    4343     * 
    4444     * If T is a singleton (if it implements the Singleton interface),  
    45      * build a copy if none exist, else return the existing copy. 
     45     * or if T is not an instance class (does not implement Instance) 
     46     * and autobuild is set to true, build a copy if none exist, else  
     47     * return the existing copy. 
    4648     */ 
    4749    T get (T) () 
     
    5254        Entity!(T) obj = b.build(this); 
    5355        post_build(this, obj.object); 
    54         _interceptor.intercept(obj, _build_target_stack.dup); 
     56        _interceptor.intercept(obj); 
    5557        _build_target_stack = _build_target_stack[0..$-1]; 
    5658        return obj.object; 
     
    7678        // again, only possible b/c no inheritance for structs 
    7779        wrap!(TVisible)(new DelegatingBuilder!(typeof(this), TVisible, TImpl)()); 
    78         register!(TImpl)(); 
    7980        return this; 
    8081    } 
     
    135136        return _build_target_stack.dup; 
    136137    } 
    137  
    138     /** Internal use only. */ 
    139     public char[] _build_for () 
    140     { 
    141         if (_build_target_stack.length >= 2) 
    142         { 
    143             return _build_target_stack[$ - 2]; 
    144         } 
    145         return null; 
    146     } 
    147138     
    148139    /** If set to true, dconstructor will try to build any type you give it. If set to 
     
    161152    { 
    162153        _defaultSingleton = value; 
     154    } 
     155 
     156    /** Internal use only. */ 
     157    public char[] _build_for () 
     158    { 
     159        // TODO: this is ugly. What is it doing? 
     160        if (_build_target_stack.length >= 2) 
     161        { 
     162            return _build_target_stack[$ - 2]; 
     163        } 
     164        return null; 
    163165    } 
    164166 
     
    292294 
    293295private Builder!() _builder; 
    294 /** The default object builder. Forward reference issues, arg */ 
     296/** The default object builder. */ 
    295297public Builder!() builder() 
    296298{ 
     
    335337    } 
    336338 
    337     Builder getbuilder()() 
    338     { 
    339         auto b = new Builder(); 
     339    Builder getbuilder() 
     340    { 
     341        auto b = new Builder!()(); 
    340342        b.autobuild = true; 
    341343        b.register!(Foo)(); 
     
    356358 
    357359    unittest { 
    358         auto b = getbuilder()()
     360        auto b = getbuilder()
    359361        auto o = b.get!(Foo)(); 
    360362        auto p = b.get!(Bar)(); 
     
    363365 
    364366    unittest { 
    365         auto b = getbuilder()()
     367        auto b = getbuilder()
    366368        auto o = b.get!(Frumious)(); 
    367369        assert (o !is null); 
     
    370372 
    371373    unittest { 
    372         auto b = getbuilder()()
     374        auto b = getbuilder()
    373375        b.bind!(IFrumious, Frumious)(); 
    374376        auto o = b.get!(IFrumious)(); 
     
    389391 
    390392    unittest { 
    391         auto b = getbuilder()()
     393        auto b = getbuilder()
    392394        b.bind!(IFrumious, Frumious)(); 
    393395        b.bind!(Foo, Bar)(); 
     
    401403 
    402404    unittest { 
    403         auto b = getbuilder()()
     405        auto b = getbuilder()
    404406        try 
    405407        { 
     
    418420    unittest { 
    419421        // tests no explicit constructor and singleton 
    420         auto b = getbuilder()()
     422        auto b = getbuilder()
    421423        auto one = b.get!(Wha)(); 
    422424        auto two = b.get!(Wha)(); 
     
    425427 
    426428    unittest { 
    427         auto b = getbuilder()()
     429        auto b = getbuilder()
    428430        auto o = new Object; 
    429431        b.provide(o); 
  • trunk/dconstructor/dconstructor/interceptor.d

    r95 r97  
    2727    } 
    2828 
    29     public void intercept(T) (Entity!(T) built, char[][] buildStack
     29    public void intercept(T) (Entity!(T) built
    3030    { 
    3131        if (built.intercepted) return; 
  • trunk/dconstructor/dsss_docs/dconstructor/dconstructor.aggregate.html

    r96 r97  
    6868            Page was generated with 
    6969            <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 
    70             on Tue Aug 12 15:43:38 2008 
     70            on Wed Aug 13 09:56:12 2008 
    7171 
    7272        </td></tr> 
  • trunk/dconstructor/dsss_docs/dconstructor/dconstructor.api.html

    r96 r97  
    1919            Page was generated with 
    2020            <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 
    21             on Tue Aug 12 15:43:38 2008 
     21            on Wed Aug 13 09:56:12 2008 
    2222 
    2323        </td></tr> 
  • trunk/dconstructor/dsss_docs/dconstructor/dconstructor.build.html

    r96 r97  
    4444 
    4545 
    46 <dd>Get an instance of type T. T can be anything -- primitive, array, 
    47  interface, struct, or class. 
     46<dd>Get an instance of type T. T can be an interface or class. 
    4847<br><br> 
    4948If T is an interface and there are no bindings for it, throw a 
    50  BindingException. 
     49 BindingException. If T is a class that was not registered, and 
     50 autobuild is set to <b>false</b>, throw a BindingException. 
    5151<br><br> 
    5252 
    5353 If T is a singleton (if it implements the Singleton interface), 
    54  build a copy if none exist, else return the existing copy. 
     54 or if T is not an instance class (does not implement Instance) 
     55 and autobuild is set to <b>true</b>, build a copy if none exist, else 
     56 return the existing copy. 
    5557      
    5658<br><br> 
     
    6971 
    7072 
    71 <dd>Get an instance of type T. T can be anything -- primitive, array, 
    72  interface, struct, or class. 
     73<dd>Get an instance of type T. T can be an interface or class. 
    7374<br><br> 
    7475If T is an interface and there are no bindings for it, throw a 
    75  BindingException. 
     76 BindingException. If T is a class that was not registered, and 
     77 autobuild is set to <b>false</b>, throw a BindingException. 
    7678<br><br> 
    7779 
    7880 If T is a singleton (if it implements the Singleton interface), 
    79  build a copy if none exist, else return the existing copy. 
     81 or if T is not an instance class (does not implement Instance) 
     82 and autobuild is set to <b>true</b>, build a copy if none exist, else 
     83 return the existing copy. 
    8084      
    8185<br><br> 
     
    344348 
    345349<script>explorer.outline.writeEnabled = true;</script> 
    346 <dt><span class="decl">char[]  
    347 <span class="currsymbol">_build_for</span> 
    348 <script>explorer.outline.addDecl('_build_for');</script> 
    349  
    350 (); 
    351 </span></dt> 
    352 <script>explorer.outline.writeEnabled = false;</script> 
    353  
    354  
    355 <dd>Internal use only.  
    356 <br><br> 
    357  
    358 </dd> 
    359  
    360 <script>explorer.outline.writeEnabled = true;</script> 
    361350<dt><span class="decl">void  
    362351<span class="currsymbol">autobuild</span> 
     
    392381 
    393382</dd> 
     383 
     384<script>explorer.outline.writeEnabled = true;</script> 
     385<dt><span class="decl">char[]  
     386<span class="currsymbol">_build_for</span> 
     387<script>explorer.outline.addDecl('_build_for');</script> 
     388 
     389(); 
     390</span></dt> 
     391<script>explorer.outline.writeEnabled = false;</script> 
     392 
     393 
     394<dd>Internal use only.  
     395<br><br> 
     396 
     397</dd> 
    394398</dl> 
    395399<script>explorer.outline.decSymbolLevel();</script> 
     
    412416<script>explorer.outline.addDecl('builder');</script> 
    413417 
    414 . Forward reference issues, arg  
     418.  
    415419<br><br> 
    416420 
     
    424428            Page was generated with 
    425429            <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 
    426             on Tue Aug 12 15:43:38 2008 
     430            on Wed Aug 13 09:56:12 2008 
    427431 
    428432        </td></tr> 
  • trunk/dconstructor/dsss_docs/dconstructor/dconstructor.build_utils.html

    r96 r97  
    1919            Page was generated with 
    2020            <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 
    21             on Tue Aug 12 15:43:38 2008 
     21            on Wed Aug 13 09:56:12 2008 
    2222 
    2323        </td></tr> 
  • trunk/dconstructor/dsss_docs/dconstructor/dconstructor.exception.html

    r96 r97  
    1919            Page was generated with 
    2020            <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 
    21             on Tue Aug 12 15:43:38 2008 
     21            on Wed Aug 13 09:56:12 2008 
    2222 
    2323        </td></tr> 
  • trunk/dconstructor/dsss_docs/dconstructor/dconstructor.interceptor.html

    r96 r97  
    1919            Page was generated with 
    2020            <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 
    21             on Tue Aug 12 15:43:38 2008 
     21            on Wed Aug 13 09:56:12 2008 
    2222 
    2323        </td></tr> 
  • trunk/dconstructor/dsss_docs/dconstructor/dconstructor.multibuilder.html

    r96 r97  
    1919            Page was generated with 
    2020            <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 
    21             on Tue Aug 12 15:43:38 2008 
     21            on Wed Aug 13 09:56:12 2008 
    2222 
    2323        </td></tr> 
  • trunk/dconstructor/dsss_docs/dconstructor/dconstructor.object_builder.html

    r96 r97  
    1919            Page was generated with 
    2020            <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 
    21             on Tue Aug 12 15:43:38 2008 
     21            on Wed Aug 13 09:56:12 2008 
    2222 
    2323        </td></tr> 
  • trunk/dconstructor/dsss_docs/dconstructor/dconstructor.provider.html

    r96 r97  
    4949            Page was generated with 
    5050            <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 
    51             on Tue Aug 12 15:43:38 2008 
     51            on Wed Aug 13 09:56:12 2008 
    5252 
    5353        </td></tr> 
  • trunk/dconstructor/dsss_docs/dconstructor/dconstructor.singleton.html

    r96 r97  
    8080            Page was generated with 
    8181            <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 
    82             on Tue Aug 12 15:43:38 2008 
     82            on Wed Aug 13 09:56:12 2008 
    8383 
    8484        </td></tr> 
  • trunk/dconstructor/dsss_docs/dconstructor/dconstructor.traits.html

    r96 r97  
    1919            Page was generated with 
    2020            <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 
    21             on Tue Aug 12 15:43:38 2008 
     21            on Wed Aug 13 09:56:12 2008 
    2222 
    2323        </td></tr>