From: walter Date: Sun, 12 Oct 2008 20:03:44 +0000 (+0000) Subject: restored Object.factory() X-Git-Url: https://git.llucax.com/software/druntime.git/commitdiff_plain/71bff88df52a4d1387776aa859df36879d787ecb?ds=sidebyside restored Object.factory() git-svn-id: http://svn.dsource.org/projects/druntime/trunk@22 4a9d5153-6564-4b3f-b5e1-7e8e9dac548f --- diff --git a/src/compiler/dmd/object_.d b/src/compiler/dmd/object_.d index ff69938..4e78220 100644 --- a/src/compiler/dmd/object_.d +++ b/src/compiler/dmd/object_.d @@ -125,6 +125,23 @@ class Object void lock(); void unlock(); } + + /****** + * Create instance of class specified by classname. + * The class must either have no constructors or have + * a default constructor. + * Returns: + * null if failed + */ + static Object factory(string classname) + { + auto ci = ClassInfo.find(classname); + if (ci) + { + return ci.create(); + } + return null; + } } /**