- if(!n) return naNil();
- SGPropertyNode_ptr* ghost = new SGPropertyNode_ptr(n);
- return naNewGhost(c, &PropNodeGhostType, ghost);
+ if(!ghost) return naNil();
+ SGPropertyNode::get(ghost);
+ return naNewGhost(c, &PropNodeGhostType, ghost);
}
#define NASTR(s) s ? naStr_fromdata(naNewString(c),(char*)(s),strlen(s)) : naNil()
//
// Standard header for the extension functions. It turns the "ghost"
}
#define NASTR(s) s ? naStr_fromdata(naNewString(c),(char*)(s),strlen(s)) : naNil()
//
// Standard header for the extension functions. It turns the "ghost"
// vector found in the second argument into a normal-looking args
// array. This allows the Nasal handlers to do things like:
// Node.getChild = func { _getChild(me.ghost, arg) }
// vector found in the second argument into a normal-looking args
// array. This allows the Nasal handlers to do things like:
// Node.getChild = func { _getChild(me.ghost, arg) }
if(argc < 2 || !naIsGhost(args[0]) || \
naGhost_type(args[0]) != &PropNodeGhostType) \
naRuntimeError(c, "bad argument to props function"); \
if(argc < 2 || !naIsGhost(args[0]) || \
naGhost_type(args[0]) != &PropNodeGhostType) \
naRuntimeError(c, "bad argument to props function"); \
- SGPropertyNode_ptr node_rhs = *(SGPropertyNode_ptr*)naGhost_ptr(rhs);
- return naNum(node == node_rhs);
+ SGPropertyNode* node_rhs = static_cast<SGPropertyNode*>(naGhost_ptr(rhs));
+ return naNum(node.ptr() == node_rhs);
naRef child = naVec_get(argv, 0);
naRef index = naVec_get(argv, 1);
if(!naIsString(child) || !naIsNum(index)) return naNil();
naRef child = naVec_get(argv, 0);
naRef index = naVec_get(argv, 1);
if(!naIsString(child) || !naIsNum(index)) return naNil();
} catch (const string& err) {
naRuntimeError(c, (char *)err.c_str());
}
} catch (const string& err) {
naRuntimeError(c, (char *)err.c_str());
}
- naVec_append(result, propNodeGhostCreate(c, node->removeChild(i, false)));
+ naVec_append(result, propNodeGhostCreate(c, node->removeChild(i)));
} else {
// Remove all children of a specified name
naRef name = naVec_get(argv, 0);
if(!naIsString(name)) return naNil();
try {
vector<SGPropertyNode_ptr> children
} else {
// Remove all children of a specified name
naRef name = naVec_get(argv, 0);
if(!naIsString(name)) return naNil();
try {
vector<SGPropertyNode_ptr> children
for(unsigned int i=0; i<children.size(); i++)
naVec_append(result, propNodeGhostCreate(c, children[i]));
} catch (const string& err) {
for(unsigned int i=0; i<children.size(); i++)
naVec_append(result, propNodeGhostCreate(c, children[i]));
} catch (const string& err) {
naRef prop = naVec_get(argv, 0);
try {
if(naIsString(prop)) al = globals->get_props()->getNode(naStr_data(prop), true);
naRef prop = naVec_get(argv, 0);
try {
if(naIsString(prop)) al = globals->get_props()->getNode(naStr_data(prop), true);
else throw string("props.alias() with bad argument");
} catch (const string& err) {
naRuntimeError(c, (char *)err.c_str());
else throw string("props.alias() with bad argument");
} catch (const string& err) {
naRuntimeError(c, (char *)err.c_str());