]> git.llucax.com Git - software/druntime.git/commitdiff
restored Object.factory()
authorwalter <walter@4a9d5153-6564-4b3f-b5e1-7e8e9dac548f>
Sun, 12 Oct 2008 20:03:44 +0000 (20:03 +0000)
committerwalter <walter@4a9d5153-6564-4b3f-b5e1-7e8e9dac548f>
Sun, 12 Oct 2008 20:03:44 +0000 (20:03 +0000)
git-svn-id: http://svn.dsource.org/projects/druntime/trunk@22 4a9d5153-6564-4b3f-b5e1-7e8e9dac548f

src/compiler/dmd/object_.d

index ff69938c57a2836028991563b6db0550cf896d09..4e78220bdbdc077056859dad67d6af11438a8c88 100644 (file)
@@ -125,6 +125,23 @@ class Object
         void lock();
         void unlock();
     }
         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;
+    }
 }
 
 /**
 }
 
 /**