From 71bff88df52a4d1387776aa859df36879d787ecb Mon Sep 17 00:00:00 2001 From: walter Date: Sun, 12 Oct 2008 20:03:44 +0000 Subject: [PATCH] restored Object.factory() git-svn-id: http://svn.dsource.org/projects/druntime/trunk@22 4a9d5153-6564-4b3f-b5e1-7e8e9dac548f --- src/compiler/dmd/object_.d | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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; + } } /** -- 2.43.0