-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Hi, thanks for the wonderfull library.
I tried to use a clone macro in a class that I parse somewhere else but json2object complained, so I ended up to manually copy all fields, line by line.
I tried with @:jignored but didn't help
class Clone {
public static macro function make_clone_code() {
var cls = Context.getLocalClass().get().name;
var fields = Context.getLocalClass().get().fields.get();
var exprs:Array<Expr> = [];
exprs.push(macro var temp=$i{"new "+cls+"()"});
for (f in fields){
var name=f.name;
var expr=f.expr;
exprs.push(macro temp.$name = $i{name});
}
exprs.push(macro return temp);
// Add a clone() method to the class
return macro $b{exprs}
}
}
Metadata
Metadata
Assignees
Labels
No labels