Changeset 20988 for lang/cplusplus

Show
Ignore:
Timestamp:
10/08/08 23:28:16 (6 weeks ago)
Author:
tokuhirom
Message:

added node.getAttribute.

Location:
lang/cplusplus/llv8call/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/cplusplus/llv8call/trunk/ext/libxml/element.cc

    r20986 r20988  
    3030    xmlNodeAddContent(node, (const xmlChar*)*content); 
    3131    return Undefined(); 
     32END 
     33 
     34FUNCTION(getAttribute) 
     35    ARG_COUNT(1); 
     36    ARG_str(name, 0); 
     37    EXTERNAL_NODE(); 
     38    xmlChar* ret = xmlGetNoNsProp(node, (xmlChar*)*name); 
     39    if (ret) { 
     40        Handle<String> s = String::New((const char*)ret); 
     41        xmlFree(ret); 
     42        return s; 
     43    } else { 
     44        return Undefined(); 
     45    } 
    3246END 
    3347 
     
    6579    BIND_IM("appendText",       appendText); 
    6680    BIND_IM("appendTextNode",   appendText); // alias 
     81    BIND_IM("getAttribute",     getAttribute); 
    6782    setupNodeIM(OBJECT_TEMPLATE); 
    6883    EXPORT_CLASS("Element"); 
     
    7388// TODO: elem.setAttribute 
    7489// TODO: elem.setAttributeNS 
    75 // TODO: elem.getAttribute 
    7690// TODO: elem.getAttributeNS 
    7791// TODO: elem.getAttributeNode 
  • lang/cplusplus/llv8call/trunk/t/070_libxml/02_dom.js

    r20949 r20988  
    11require('t/util.js'); 
    22 
    3 plan({tests:23}); 
     3plan({tests:25}); 
    44 
    55check_lib("org.coderepos.libxml"); 
     
    101101    is(root.toString(),  '<foo foo="baz"/>',               'doc.createAttribute()'); 
    102102    is(attr.getOwnerElement().toString(), root.toString(), "attr.getOwnerElement"); 
     103    is(root.getAttribute("foo"),  'baz',                   'node.getAttribute()'); 
     104    is(root.getAttribute("notfound"),  undefined,          'node.getAttribute()'); 
    103105}); 
    104106