| 21 | | inline v8::Handle<v8::Function> node_class() { |
| 22 | | return Handle<Function>::Cast( libxml_namespace()->Get(String::New("Node")) ); |
| 23 | | } |
| 24 | | |
| 25 | | inline v8::Handle<v8::Function> attr_class() { |
| 26 | | return Handle<Function>::Cast( libxml_namespace()->Get(String::New("Attr")) ); |
| 27 | | } |
| 28 | | |
| 29 | | inline v8::Handle<v8::Function> elem_class() { |
| 30 | | return Handle<Function>::Cast( libxml_namespace()->Get(String::New("Element")) ); |
| 31 | | } |
| 32 | | |
| 33 | | inline v8::Handle<v8::Function> document_class() { |
| 34 | | return Handle<Function>::Cast( libxml_namespace()->Get(String::New("Document")) ); |
| 35 | | } |
| 36 | | |
| 37 | | inline v8::Handle<v8::Function> cdata_class() { |
| 38 | | return Handle<Function>::Cast( libxml_namespace()->Get(String::New("CDATASection")) ); |
| 39 | | } |
| 40 | | |
| 41 | | static inline Handle<Object> createNode(xmlDocPtr doc, xmlNodePtr node_raw) { |
| | 21 | static inline Handle<Object> createObject(const char * type, xmlDocPtr doc, xmlNodePtr node_raw) { |
| 48 | | static inline Handle<Object> createElem(xmlDocPtr doc, xmlNodePtr elem_raw) { |
| 49 | | Handle<Value> consarg[2]; |
| 50 | | consarg[0] = External::New(elem_raw); |
| 51 | | consarg[1] = External::New(doc); |
| 52 | | return elem_class()->NewInstance(2, consarg); |
| | 29 | static inline Handle<Object> createDocument(xmlDocPtr doc) { |
| | 30 | Handle<Function> f = Handle<Function>::Cast( libxml_namespace()->Get(String::New("Document")) ); |
| | 31 | Handle<Object> t = f->NewInstance(); |
| | 32 | t->SetInternalField(0, External::New(doc)); |
| | 33 | t->SetInternalField(1, External::New(xmlNewDocFragment(doc))); |
| | 34 | return t; |
| 55 | | static inline Handle<Object> createAttr(xmlDocPtr doc, xmlAttrPtr attr_raw) { |
| 56 | | Handle<Value> consarg[2]; |
| 57 | | consarg[0] = External::New(attr_raw); |
| 58 | | consarg[1] = External::New(doc); |
| 59 | | return attr_class()->NewInstance(2, consarg); |
| 60 | | } |
| 61 | | |
| 62 | | static inline Handle<Object> createCDATA(xmlDocPtr doc, xmlNodePtr attr_raw) { |
| 63 | | Handle<Value> consarg[2]; |
| 64 | | consarg[0] = External::New(attr_raw); |
| 65 | | consarg[1] = External::New(doc); |
| 66 | | return cdata_class()->NewInstance(2, consarg); |
| 67 | | } |
| | 37 | #define CREATE_NODE(doc, node) createObject("Node", doc, node) |
| | 38 | #define CREATE_ATTR(doc, node) createObject("Attribute", doc, node) |