Changeset 20947
- Timestamp:
- 10/08/08 09:00:07 (3 months ago)
- Location:
- lang/cplusplus/llv8call/trunk
- Files:
-
- 6 modified
-
ext/libxml/attr.cc (modified) (1 diff)
-
ext/libxml/document.cc (modified) (1 diff)
-
ext/libxml/element.cc (modified) (1 diff)
-
ext/libxml/libxml.h (modified) (1 diff)
-
ext/libxml/node.h (modified) (1 diff)
-
t/070_libxml/02_dom.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/cplusplus/llv8call/trunk/ext/libxml/attr.cc
r20881 r20947 21 21 // THE SOFTWARE. 22 22 23 #include " libxml.h"23 #include "node.h" 24 24 25 25 #define EXTERNAL_ATTR() EXTERNAL(xmlAttrPtr, attr, args.This(), 0) 26 26 27 FUNCTION( _new)27 FUNCTION(setValue) 28 28 ARG_COUNT(1); 29 assert(args[0]->IsExternal()); 30 args.This()->SetInternalField(0, args[0]); 31 return args.This(); 29 ARG_str(val, 0); 30 EXTERNAL_NODE(); 31 domSetNodeValue(node, (xmlChar*)*val); 32 return Undefined(); 32 33 END 33 34 34 35 SUBMODULE(init_attr) 35 36 CLASS_WITH_CONSTRUCTOR(_new); 36 INTERNALCOUNT(1); 37 setupNodeIM(OBJECT_TEMPLATE); 38 BIND_IM("getValue", getValue); 39 BIND_IM("value", getValue); 40 BIND_IM("setValue", setValue); 41 BIND_IM("getOwnerElement", parentNode); 37 42 EXPORT_CLASS("Attr"); 38 43 ENDSUBMODULE 39 44 40 // REST: 0/8 41 // TODO: node.new 42 // TODO: node.getValue 43 // TODO: node.value 44 // TODO: node.setValue 45 // TODO: node.getOwnerElement 46 // TODO: node.setNamespace 47 // TODO: node.isId 48 // TODO: node.serializeContent($docencoding) 45 // REST: 5/8 46 // TODO: attr.setNamespace 47 // TODO: attr.isId 48 // TODO: attr.serializeContent($docencoding) 49 -
lang/cplusplus/llv8call/trunk/ext/libxml/document.cc
r20881 r20947 120 120 121 121 xmlAttrPtr attr = xmlNewDocProp(doc, (const xmlChar*)*name, args.Length() == 2 ? (const xmlChar*)*value : NULL); 122 return createAttr( attr);122 return createAttr(doc, attr); 123 123 END 124 124 -
lang/cplusplus/llv8call/trunk/ext/libxml/element.cc
r20882 r20947 56 56 return Undefined(); 57 57 } else { 58 return createAttr( ret);58 return createAttr(doc, ret); 59 59 } 60 60 END -
lang/cplusplus/llv8call/trunk/ext/libxml/libxml.h
r20881 r20947 49 49 } 50 50 51 static inline Handle<Object> createAttr(xml AttrPtr attr_raw) {52 Handle<Value> consarg[ 1];51 static inline Handle<Object> createAttr(xmlDocPtr doc, xmlAttrPtr attr_raw) { 52 Handle<Value> consarg[2]; 53 53 consarg[0] = External::New(attr_raw); 54 return attr_class()->NewInstance(1, consarg); 54 consarg[1] = External::New(doc); 55 return attr_class()->NewInstance(2, consarg); 55 56 } 56 57 -
lang/cplusplus/llv8call/trunk/ext/libxml/node.h
r20881 r20947 173 173 END 174 174 175 FUNCTION(getValue) 176 ARG_COUNT(0); 177 EXTERNAL_NODE(); 178 xmlChar * content = domGetNodeValue(node); 179 if (content) { 180 Handle<String> s = String::New((const char*)content); 181 xmlFree(content); 182 return s; 183 } else { 184 return Undefined(); 185 } 186 END 187 175 188 static inline void setupNodeIM(Handle<ObjectTemplate> OBJECT_TEMPLATE) { 176 189 BIND_IM("nodeName", nodeName); -
lang/cplusplus/llv8call/trunk/t/070_libxml/02_dom.js
r20882 r20947 1 1 require('t/util.js'); 2 2 3 plan({tests: 19});3 plan({tests:22}); 4 4 5 5 check_lib("org.coderepos.libxml"); … … 94 94 95 95 test(function () { 96 root.setAttributeNode(doc.createAttribute("foo", "bar")); 97 is(root.toString(), '<foo foo="bar"/>', 'node.createAttribute()'); 96 var attr = doc.createAttribute("foo", "bar"); 97 is(attr.getValue(), 'bar', 'attr.getValue()'); 98 is(attr.value(), 'bar', 'attr.value()'); 99 attr.setValue("baz"); 100 root.setAttributeNode(attr); 101 is(root.toString(), '<foo foo="baz"/>', 'doc.createAttribute()'); 102 is(attr.getOwnerElement().toString(), root.toString(), "attr.getOwnerElement"); 98 103 }); 99 104
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)