Changeset 97
- Timestamp:
- 08/13/08 10:19:30 (4 years ago)
- Files:
-
- trunk/dconstructor/TODO (modified) (1 diff)
- trunk/dconstructor/dconstructor/build.d (modified) (14 diffs)
- trunk/dconstructor/dconstructor/interceptor.d (modified) (1 diff)
- trunk/dconstructor/dsss_docs/dconstructor/dconstructor.aggregate.html (modified) (1 diff)
- trunk/dconstructor/dsss_docs/dconstructor/dconstructor.api.html (modified) (1 diff)
- trunk/dconstructor/dsss_docs/dconstructor/dconstructor.build.html (modified) (6 diffs)
- trunk/dconstructor/dsss_docs/dconstructor/dconstructor.build_utils.html (modified) (1 diff)
- trunk/dconstructor/dsss_docs/dconstructor/dconstructor.exception.html (modified) (1 diff)
- trunk/dconstructor/dsss_docs/dconstructor/dconstructor.interceptor.html (modified) (1 diff)
- trunk/dconstructor/dsss_docs/dconstructor/dconstructor.multibuilder.html (modified) (1 diff)
- trunk/dconstructor/dsss_docs/dconstructor/dconstructor.object_builder.html (modified) (1 diff)
- trunk/dconstructor/dsss_docs/dconstructor/dconstructor.provider.html (modified) (1 diff)
- trunk/dconstructor/dsss_docs/dconstructor/dconstructor.singleton.html (modified) (1 diff)
- trunk/dconstructor/dsss_docs/dconstructor/dconstructor.traits.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dconstructor/TODO
r94 r97 4 4 custom providers 5 5 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.7 6 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 36 36 37 37 /** 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. 40 39 * 41 40 * 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. 43 43 * 44 44 * 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. 46 48 */ 47 49 T get (T) () … … 52 54 Entity!(T) obj = b.build(this); 53 55 post_build(this, obj.object); 54 _interceptor.intercept(obj , _build_target_stack.dup);56 _interceptor.intercept(obj); 55 57 _build_target_stack = _build_target_stack[0..$-1]; 56 58 return obj.object; … … 76 78 // again, only possible b/c no inheritance for structs 77 79 wrap!(TVisible)(new DelegatingBuilder!(typeof(this), TVisible, TImpl)()); 78 register!(TImpl)();79 80 return this; 80 81 } … … 135 136 return _build_target_stack.dup; 136 137 } 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 }147 138 148 139 /** If set to true, dconstructor will try to build any type you give it. If set to … … 161 152 { 162 153 _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; 163 165 } 164 166 … … 292 294 293 295 private Builder!() _builder; 294 /** The default object builder. Forward reference issues, arg*/296 /** The default object builder. */ 295 297 public Builder!() builder() 296 298 { … … 335 337 } 336 338 337 Builder getbuilder() ()338 { 339 auto b = new Builder ();339 Builder getbuilder() 340 { 341 auto b = new Builder!()(); 340 342 b.autobuild = true; 341 343 b.register!(Foo)(); … … 356 358 357 359 unittest { 358 auto b = getbuilder() ();360 auto b = getbuilder(); 359 361 auto o = b.get!(Foo)(); 360 362 auto p = b.get!(Bar)(); … … 363 365 364 366 unittest { 365 auto b = getbuilder() ();367 auto b = getbuilder(); 366 368 auto o = b.get!(Frumious)(); 367 369 assert (o !is null); … … 370 372 371 373 unittest { 372 auto b = getbuilder() ();374 auto b = getbuilder(); 373 375 b.bind!(IFrumious, Frumious)(); 374 376 auto o = b.get!(IFrumious)(); … … 389 391 390 392 unittest { 391 auto b = getbuilder() ();393 auto b = getbuilder(); 392 394 b.bind!(IFrumious, Frumious)(); 393 395 b.bind!(Foo, Bar)(); … … 401 403 402 404 unittest { 403 auto b = getbuilder() ();405 auto b = getbuilder(); 404 406 try 405 407 { … … 418 420 unittest { 419 421 // tests no explicit constructor and singleton 420 auto b = getbuilder() ();422 auto b = getbuilder(); 421 423 auto one = b.get!(Wha)(); 422 424 auto two = b.get!(Wha)(); … … 425 427 426 428 unittest { 427 auto b = getbuilder() ();429 auto b = getbuilder(); 428 430 auto o = new Object; 429 431 b.provide(o); trunk/dconstructor/dconstructor/interceptor.d
r95 r97 27 27 } 28 28 29 public void intercept(T) (Entity!(T) built , char[][] buildStack)29 public void intercept(T) (Entity!(T) built) 30 30 { 31 31 if (built.intercepted) return; trunk/dconstructor/dsss_docs/dconstructor/dconstructor.aggregate.html
r96 r97 68 68 Page was generated with 69 69 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 70 on Tue Aug 12 15:43:38200870 on Wed Aug 13 09:56:12 2008 71 71 72 72 </td></tr> trunk/dconstructor/dsss_docs/dconstructor/dconstructor.api.html
r96 r97 19 19 Page was generated with 20 20 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 21 on Tue Aug 12 15:43:38200821 on Wed Aug 13 09:56:12 2008 22 22 23 23 </td></tr> trunk/dconstructor/dsss_docs/dconstructor/dconstructor.build.html
r96 r97 44 44 45 45 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. 48 47 <br><br> 49 48 If 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. 51 51 <br><br> 52 52 53 53 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. 55 57 56 58 <br><br> … … 69 71 70 72 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. 73 74 <br><br> 74 75 If 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. 76 78 <br><br> 77 79 78 80 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. 80 84 81 85 <br><br> … … 344 348 345 349 <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>361 350 <dt><span class="decl">void 362 351 <span class="currsymbol">autobuild</span> … … 392 381 393 382 </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> 394 398 </dl> 395 399 <script>explorer.outline.decSymbolLevel();</script> … … 412 416 <script>explorer.outline.addDecl('builder');</script> 413 417 414 . Forward reference issues, arg418 . 415 419 <br><br> 416 420 … … 424 428 Page was generated with 425 429 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 426 on Tue Aug 12 15:43:382008430 on Wed Aug 13 09:56:12 2008 427 431 428 432 </td></tr> trunk/dconstructor/dsss_docs/dconstructor/dconstructor.build_utils.html
r96 r97 19 19 Page was generated with 20 20 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 21 on Tue Aug 12 15:43:38200821 on Wed Aug 13 09:56:12 2008 22 22 23 23 </td></tr> trunk/dconstructor/dsss_docs/dconstructor/dconstructor.exception.html
r96 r97 19 19 Page was generated with 20 20 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 21 on Tue Aug 12 15:43:38200821 on Wed Aug 13 09:56:12 2008 22 22 23 23 </td></tr> trunk/dconstructor/dsss_docs/dconstructor/dconstructor.interceptor.html
r96 r97 19 19 Page was generated with 20 20 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 21 on Tue Aug 12 15:43:38200821 on Wed Aug 13 09:56:12 2008 22 22 23 23 </td></tr> trunk/dconstructor/dsss_docs/dconstructor/dconstructor.multibuilder.html
r96 r97 19 19 Page was generated with 20 20 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 21 on Tue Aug 12 15:43:38200821 on Wed Aug 13 09:56:12 2008 22 22 23 23 </td></tr> trunk/dconstructor/dsss_docs/dconstructor/dconstructor.object_builder.html
r96 r97 19 19 Page was generated with 20 20 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 21 on Tue Aug 12 15:43:38200821 on Wed Aug 13 09:56:12 2008 22 22 23 23 </td></tr> trunk/dconstructor/dsss_docs/dconstructor/dconstructor.provider.html
r96 r97 49 49 Page was generated with 50 50 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 51 on Tue Aug 12 15:43:38200851 on Wed Aug 13 09:56:12 2008 52 52 53 53 </td></tr> trunk/dconstructor/dsss_docs/dconstructor/dconstructor.singleton.html
r96 r97 80 80 Page was generated with 81 81 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 82 on Tue Aug 12 15:43:38200882 on Wed Aug 13 09:56:12 2008 83 83 84 84 </td></tr> trunk/dconstructor/dsss_docs/dconstructor/dconstructor.traits.html
r96 r97 19 19 Page was generated with 20 20 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 21 on Tue Aug 12 15:43:38200821 on Wed Aug 13 09:56:12 2008 22 22 23 23 </td></tr>
