mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 21:51:03 +03:00
restored Object.factory()
This commit is contained in:
parent
844127aa90
commit
eb91542f26
1 changed files with 17 additions and 0 deletions
|
@ -125,6 +125,23 @@ class Object
|
||||||
void lock();
|
void lock();
|
||||||
void unlock();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue