]> git.llucax.com Git - software/druntime.git/blobdiff - src/compiler/dmd/object_.d
restored Object.factory()
[software/druntime.git] / 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;
+    }
 }
 
 /**
 }
 
 /**