On 12/01/11 17:01, Coen Schalkwijk wrote:
Thanks for your suggestion. Is it possible in pike to do/use/consume something like 'they' do in dotNET:
[XMLNode name="A"] classA{ [XMLNode name="aVar"] string a; [XMLNode name="cookieCount"] int b; }
There is no real need for this when it is so easy to look into objects, iterate, etc.
To map special names to variables, just use a mapping:
mapping XMLNames = ([ classA : ([ "a" : "aVar", "b" : "cookieCount" ]), classB : ([ "a" : "aVar", "b" : "somethingElse" ]) ]);
mapping default_XMLNames = ([ "a" : "aVar" ]);
object o = get_object(); mapping o_xml_names = XMLNames[object_program(o)] || default_XMLNames;
foreach (o; string var_name; mixed val) { string name = o_xml_names[var_name]; if (!name) continue; /* add to xml */ }
This way seems preferable to editing and cluttering old code with annotations.
There is also Program.implements() which is probably good to use.