Created
May 20, 2010 05:12
-
-
Save polotek/407224 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// doc, name, attrs, content, callback | |
v8::Handle<v8::Value> | |
XmlElement::New(const v8::Arguments& args) { | |
v8::HandleScope scope; | |
// was created by BUILD_NODE | |
if (args.Length() == 0 || args[0]->StrictEquals(v8::Null())) | |
return scope.Close(args.This()); | |
XmlDocument *document = LibXmlObj::Unwrap<XmlDocument>(args[0]->ToObject()); | |
v8::String::Utf8Value name(args[1]->ToString()); | |
v8::Handle<v8::Function> callback; | |
v8::String::Utf8Value content; | |
if(!args[3]->IsUndefined() && !args[3]->IsNull()) { | |
v8::String::Utf8Value content(args[3]->ToString()); | |
} | |
if (args[4]->IsFunction()) | |
callback = v8::Handle<v8::Function>::Cast(args[4]); | |
xmlNode* elem = xmlNewDocNode(document->xml_obj, | |
NULL, | |
(const xmlChar*)*name, | |
(*content) ? (const xmlChar*)*content : NULL); | |
v8::Persistent<v8::Object> obj = | |
LXJS_GET_MAYBE_BUILD(XmlElement, elem); | |
XmlElement *element = LibXmlObj::Unwrap<XmlElement>(obj); | |
if (args[2]->IsObject()) { | |
v8::Handle<v8::Object> attributes = args[2]->ToObject(); | |
v8::Handle<v8::Array> props = attributes->GetPropertyNames(); | |
for (unsigned int i = 0; i < props->Length(); i++) { | |
v8::String::Utf8Value name( | |
props->Get(v8::Number::New(i))); | |
v8::String::Utf8Value value( | |
attributes->Get(props->Get(v8::Number::New(i)))); | |
element->set_attr(*name, *value); | |
} | |
} | |
obj->Set(v8::String::NewSymbol("document"), args[0]->ToObject()); | |
if (*callback && !callback->IsNull()) { | |
v8::Handle<v8::Value> argv[1] = { obj }; | |
*callback->Call(obj, 1, argv); | |
} | |
return scope.Close(obj); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
src/xml_element.cc: In static member function 'static v8::Handle<v8::Value> libxmljs::XmlElement::New(const v8::Arguments&)': | |
src/xml_element.cc:27: error: no matching function for call to 'v8::String::Utf8Value::Utf8Value()' | |
/Users/polotek/.nvm/v0.1.95/include/node/v8.h:1166: note: candidates are: | |
v8::String::Utf8Value::Utf8Value(const v8::String::Utf8Value&) | |
/Users/polotek/.nvm/v0.1.95/include/node/v8.h:1156: note: | |
v8::String::Utf8Value::Utf8Value(v8::Handle<v8::Value>) | |
scons: *** [src/xml_element.os] Error 1 | |
scons: building terminated because of errors. | |
make: *** [node] Error 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment