Get specific functions of unknown type at runtime?
    F i L 
    witte2008 at gmail.com
       
    Sun Dec 16 17:39:53 PST 2012
    
    
  
My goal is this, to have an XML file:
     <!-- scene.xml -->
     <scene>
         <object class="Person" event="greet"/>
     </scene>
and a D file:
     module person;
     import std.stdio;
     class Person
     {
         void greet() {
             writeln("hello");
         }
     }
and then another D file:
     module main;
     import person;
     import std.xml;
     import std.file;
     static class Engine
     {
         static void delegate() event;
         static void callEvent() { event(); }
     }
     void main() {
         auto doc = new Document(read("scene.xml"));
         auto className = /* find class name in xml file */;
         auto eventName = /* find event name in xml file */;
         auto obj = Object.factory(className);
         Engine.event = /* get 'eventName' void in 'obj' */;
         for (/* some loop */) { Engine.callEvent(); }
     }
So yeah, basically is is possible to create a general object, 
then look at it's members at runtime? Through maybe a .classinfo 
or something? Or is this level of runtime reflection simply not 
supported in D (yet)? If so, what are my best alternative options 
here?
    
    
More information about the Digitalmars-d-learn
mailing list