Show
Ignore:
Timestamp:
10/08/08 23:10:24 (3 months ago)
Author:
tokuhirom
Message:

dry

Files:
1 modified

Legend:

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

    r20949 r20986  
    1919} 
    2020 
    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) { 
     21static inline Handle<Object> createObject(const char * type, xmlDocPtr doc, xmlNodePtr node_raw) { 
    4222    Handle<Value> consarg[2]; 
    4323    consarg[0] = External::New(node_raw); 
    4424    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); 
    4627} 
    4728 
    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); 
     29static 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; 
    5335} 
    5436 
    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) 
    6839 
    6940#define ARG_node(name, n) EXTERNAL(xmlNodePtr, name, args[n]->ToObject(), 0)