Copy all fields/methods (public/private) from one class to another another at compile time

41 views
Skip to first unread message

Ian Harrigan

unread,
May 18, 2015, 8:36:08 AM5/18/15
to haxe...@googlegroups.com
Hi Guys,

So as the title says, im looking to copy all fields from one class to another at compile time, this includes private members of the source class, basically the lot. Eg:

class Something {
   
function test() {
        trace
("something");
   
}

   
function test2() {
        trace
("original");
   
}
}

class Else {
   
private var _counter:Int = 100;
   
function test() {
        _counter
++;
        trace
("else " + _counter);
   
}
}

Macros.copyClass(Else, Something); // Else would be source, Something would be target
var s:Something = new Something();
s
.test();  // would output "else 101"
s
.test2();  // would output "original"


I seems like mpartial might be the lib im after, but i couldnt get it to compile, it errors with:

/mpartial/1,3,2/mpartial/util/Macros.hx:10: characters 0-34 : Type not found : tink.macro.tools.MacroTools

Any one have an experience with mpartial, or any other lib that will do what im after?

Cheers,
Ian

Juraj Kirchheim

unread,
May 18, 2015, 9:10:38 AM5/18/15
to haxe...@googlegroups.com
The missing tink.macro.tools.MacroTools is defined in the old tinkerbell: https://github.com/back2dos/tinkerbell/

Best,
Juraj

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages