Changeset 20986
- Timestamp:
- 10/08/08 23:10:24 (5 years ago)
- Location:
- lang/cplusplus/llv8call/trunk/ext/libxml
- Files:
-
- 4 modified
-
document.cc (modified) (7 diffs)
-
element.cc (modified) (1 diff)
-
libxml.h (modified) (1 diff)
-
node.h (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/cplusplus/llv8call/trunk/ext/libxml/document.cc
r20949 r20986 35 35 doc->encoding = (const xmlChar*)xmlStrdup((const xmlChar*)*encoding); 36 36 } 37 Handle<Object> t = document_class()->NewInstance(); 38 t->SetInternalField(0, External::New(doc)); 39 t->SetInternalField(1, External::New(xmlNewDocFragment(doc))); 40 return t; 37 return createDocument(doc); 41 38 END 42 39 … … 80 77 xmlNodePtr node_raw = xmlDocGetRootElement(doc); 81 78 assert(node_raw); 82 return create Elem(doc, node_raw );79 return createObject( "Element", doc, node_raw ); 83 80 END 84 81 … … 109 106 assert(node_raw); 110 107 xmlAddChild(fragment, node_raw); 111 return create Elem(doc, node_raw );108 return createObject( "Element", doc, node_raw ); 112 109 END 113 110 … … 121 118 assert(node_raw); 122 119 xmlAddChild(fragment, node_raw); 123 return create CDATA(doc, node_raw );120 return createObject( "CDATASection", doc, node_raw ); 124 121 END 125 122 … … 132 129 133 130 xmlAttrPtr attr = xmlNewDocProp(doc, (const xmlChar*)*name, args.Length() == 2 ? (const xmlChar*)*value : NULL); 134 return create Attr(doc,attr);131 return createObject("Attr", doc, (xmlNodePtr)attr); 135 132 END 136 133 … … 145 142 textnode->doc = doc; 146 143 xmlAddChild(fragment, textnode); 147 return createNode( doc, textnode );144 return CREATE_NODE( doc, textnode ); 148 145 END 149 146 … … 158 155 textnode->doc = doc; 159 156 xmlAddChild(fragment, textnode); 160 return createNode( doc, textnode );157 return CREATE_NODE( doc, textnode ); 161 158 END 162 159 -
lang/cplusplus/llv8call/trunk/ext/libxml/element.cc
r20947 r20986 56 56 return Undefined(); 57 57 } else { 58 return create Attr(doc,ret);58 return createObject("Attr", doc, (xmlNode*)ret); 59 59 } 60 60 END -
lang/cplusplus/llv8call/trunk/ext/libxml/libxml.h
r20949 r20986 19 19 } 20 20 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) { 42 22 Handle<Value> consarg[2]; 43 23 consarg[0] = External::New(node_raw); 44 24 consarg[1] = External::New(doc); 45 return node_class()->NewInstance(2, consarg); 25 Handle<Function> f = Handle<Function>::Cast( libxml_namespace()->Get(String::New(type)) ); 26 return f->NewInstance(2, consarg); 46 27 } 47 28 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; 53 35 } 54 36 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) 68 39 69 40 #define ARG_node(name, n) EXTERNAL(xmlNodePtr, name, args[n]->ToObject(), 0) -
lang/cplusplus/llv8call/trunk/ext/libxml/node.h
r20947 r20986 56 56 ARG_node(argnode, 0); 57 57 xmlNodePtr rNode = domAppendChild( node, argnode ); 58 return createNode( doc, rNode );58 return CREATE_NODE( doc, rNode ); 59 59 END 60 60 … … 67 67 xmlNodePtr rNode = domInsertBefore( node, newnode, refnode ); 68 68 assert(rNode); 69 return createNode( doc, rNode );69 return CREATE_NODE( doc, rNode ); 70 70 END 71 71 … … 78 78 xmlNodePtr rNode = domInsertAfter( node, newnode, refnode ); 79 79 assert(rNode); 80 return createNode( doc, rNode );80 return CREATE_NODE( doc, rNode ); 81 81 END 82 82 … … 87 87 ARG_node(argnode, 0); 88 88 xmlNodePtr rNode = domRemoveChild( node, argnode ); 89 return createNode( doc, rNode );89 return CREATE_NODE( doc, rNode ); 90 90 END 91 91 … … 149 149 xmlNodePtr ret = _CloneNodeIn( node, deep ); 150 150 assert(ret); 151 return createNode( doc, ret );151 return CREATE_NODE( doc, ret ); 152 152 END 153 153 … … 156 156 EXTERNAL_NODE(); 157 157 EXTERNAL_DOC(); 158 return createNode( doc, node->children );158 return CREATE_NODE( doc, node->children ); 159 159 END 160 160 … … 163 163 EXTERNAL_NODE(); 164 164 EXTERNAL_DOC(); 165 return createNode( doc, node->last );165 return CREATE_NODE( doc, node->last ); 166 166 END 167 167 … … 170 170 EXTERNAL_NODE(); 171 171 EXTERNAL_DOC(); 172 return createNode( doc, node->parent );172 return CREATE_NODE( doc, node->parent ); 173 173 END 174 174
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)