props.copy: add third argument that, if set, also copies the node attributes
This commit is contained in:
parent
66e53fb67f
commit
38c170baa5
1 changed files with 5 additions and 3 deletions
|
@ -119,12 +119,13 @@ var dump = func {
|
|||
|
||||
##
|
||||
# Recursively copy property branch from source Node to
|
||||
# destination Node. Doesn't copy aliases.
|
||||
# destination Node. Doesn't copy aliases. Copies attributes
|
||||
# if optional third argument is set and non-zero.
|
||||
#
|
||||
var copy = func(src, dest) {
|
||||
var copy = func(src, dest, attr = 0) {
|
||||
foreach(c; src.getChildren()) {
|
||||
name = c.getName() ~ "[" ~ c.getIndex() ~ "]";
|
||||
copy(src.getNode(name), dest.getNode(name, 1));
|
||||
copy(src.getNode(name), dest.getNode(name, 1), attr);
|
||||
}
|
||||
var type = src.getType();
|
||||
var val = src.getValue();
|
||||
|
@ -133,6 +134,7 @@ var copy = func(src, dest) {
|
|||
elsif(type == "INT") { dest.setIntValue(val); }
|
||||
elsif(type == "DOUBLE") { dest.setDoubleValue(val); }
|
||||
else { dest.setValue(val); }
|
||||
if(attr) dest.setAttribute(src.getAttribute());
|
||||
}
|
||||
|
||||
##
|
||||
|
|
Loading…
Add table
Reference in a new issue