Changeset 20859
- Timestamp:
- 10/06/08 23:59:56 (2 months ago)
- Location:
- lang/cplusplus/llv8call/trunk
- Files:
-
- 1 added
- 4 modified
-
ext/libxml/document.cc (modified) (4 diffs)
-
ext/libxml/libxml.h (modified) (2 diffs)
-
ext/libxml/node.cc (modified) (1 diff)
-
t/070_libxml/01_simple.js (modified) (2 diffs)
-
t/070_libxml/02_dom.js (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/cplusplus/llv8call/trunk/ext/libxml/document.cc
r20851 r20859 24 24 25 25 #define EXTERNAL_DOC() EXTERNAL(xmlDocPtr, doc, args.This(), 0); 26 27 FUNCTION(createDocument) 28 ARG_BETWEEN(1, 2); 29 ARG_str(version, 0); 30 xmlDocPtr doc = xmlNewDoc((const xmlChar*)*version); 31 assert(doc); 32 if (args.Length() == 2) { 33 ARG_str(encoding, 1); 34 doc->encoding = (const xmlChar*)xmlStrdup((const xmlChar*)*encoding); 35 } 36 Handle<Object> t = document_class()->NewInstance(); 37 t->SetInternalField(0, External::New(doc)); 38 return t; 39 END 26 40 27 41 FUNCTION(_readFile) … … 53 67 assert(node_raw); 54 68 return createNode( doc, node_raw ); 69 END 70 71 FUNCTION(setDocumentElement) 72 ARG_COUNT(1); 73 EXTERNAL_DOC(); 74 ARG_node(node, 0); 75 76 if (doc!=node->doc) { 77 domImportNode(doc, node, 1, 1); 78 } 79 xmlNodePtr oelem = xmlDocGetRootElement( doc ); 80 if ( oelem == NULL || oelem->_private == NULL ) { 81 xmlDocSetRootElement( doc, node ); 82 } else { 83 abort(); // TODO: implement 84 } 85 return Undefined(); 55 86 END 56 87 … … 93 124 SUBMODULE(init_document) 94 125 CLASS(); 126 BIND_CM("createDocument", createDocument); 127 95 128 BIND_IM("readFile", _readFile); 96 129 BIND_IM("encoding", _encoding); 97 130 BIND_IM("version", _version); 98 131 BIND_IM("documentElement", _documentElement); 132 BIND_IM("setDocumentElement", setDocumentElement); 99 133 BIND_IM("createElement", _createElement); 100 134 BIND_IM("toString", toString); … … 106 140 // rest: 7/51 107 141 108 // TODO: doc.createDocument109 142 // TODO: doc.actualEncoding 110 143 // TODO: doc.setEncoding -
lang/cplusplus/llv8call/trunk/ext/libxml/libxml.h
r20851 r20859 23 23 } 24 24 25 inline v8::Handle<v8::Function> document_class() { 26 return Handle<Function>::Cast( libxml_namespace()->Get(String::New("Document")) ); 27 } 28 25 29 static inline Handle<Object> createNode(xmlDocPtr doc, xmlNodePtr node_raw) { 26 30 Handle<Value> consarg[2]; … … 30 34 } 31 35 36 #define ARG_node(name, n) EXTERNAL(xmlNodePtr, name, args[n]->ToObject(), 0) 37 -
lang/cplusplus/llv8call/trunk/ext/libxml/node.cc
r20855 r20859 25 25 #define EXTERNAL_NODE() EXTERNAL(xmlNodePtr, node, args.This(), 0) 26 26 #define EXTERNAL_DOC() EXTERNAL(xmlDocPtr, doc, args.This(), 1) 27 #define ARG_node(name, n) EXTERNAL(xmlNodePtr, name, args[n]->ToObject(), 0)28 27 29 28 FUNCTION(_new) -
lang/cplusplus/llv8call/trunk/t/070_libxml/01_simple.js
r20855 r20859 1 1 require('t/util.js'); 2 2 3 plan({tests: 11});3 plan({tests:7}); 4 4 5 5 check_lib("org.coderepos.libxml"); … … 15 15 is(doc.createElement("bar").toString(), "<bar/>", 'node.toString'); 16 16 is(root.toString(), "<foo/>", "node.toString"); 17 var bar = doc.createElement("bar");18 var eee = doc.createElement("eee");19 root.appendChild(bar);20 is(root.toString(), "<foo><bar/></foo>", "node.appendChild");21 root.removeChild(bar);22 is(root.toString(), "<foo/>", "node.removeChild");23 root.appendChild(bar);24 root.appendChild(eee);25 is(root.toString(), "<foo><bar/><eee/></foo>", "node.appendChild");26 root.removeChildNodes();27 is(root.toString(), "<foo/>", "node.removeChildNodes");28 root.appendChild(bar);29 is(root.insertBefore(eee, bar).nodeName(), 'eee', 'node.insertBefore');30 is(root.toString(), "<foo><eee/><bar/></foo>", "node.insertBefore");31 root.removeChildNodes();32 root.appendChild(bar);33 is(root.insertAfter(eee, bar).nodeName(), 'eee', 'node.insertAfter');34 is(root.toString(), "<foo><bar/><eee/></foo>", "node.insertAfter");35 17 doc.close(); 36 18
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)