WebCore/generated/JSXPathEvaluator.cpp
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2     This file is part of the WebKit open source project.
       
     3     This file has been generated by generate-bindings.pl. DO NOT MODIFY!
       
     4 
       
     5     This library is free software; you can redistribute it and/or
       
     6     modify it under the terms of the GNU Library General Public
       
     7     License as published by the Free Software Foundation; either
       
     8     version 2 of the License, or (at your option) any later version.
       
     9 
       
    10     This library is distributed in the hope that it will be useful,
       
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    13     Library General Public License for more details.
       
    14 
       
    15     You should have received a copy of the GNU Library General Public License
       
    16     along with this library; see the file COPYING.LIB.  If not, write to
       
    17     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
       
    18     Boston, MA 02110-1301, USA.
       
    19 */
       
    20 
       
    21 #include "config.h"
       
    22 
       
    23 #if ENABLE(XPATH)
       
    24 
       
    25 #include "JSXPathEvaluator.h"
       
    26 
       
    27 #include "JSCustomXPathNSResolver.h"
       
    28 #include "JSNode.h"
       
    29 #include "JSXPathExpression.h"
       
    30 #include "JSXPathNSResolver.h"
       
    31 #include "JSXPathResult.h"
       
    32 #include "PlatformString.h"
       
    33 #include "XPathEvaluator.h"
       
    34 #include "XPathExpression.h"
       
    35 #include "XPathNSResolver.h"
       
    36 #include "XPathResult.h"
       
    37 #include <runtime/Error.h>
       
    38 #include <wtf/GetPtr.h>
       
    39 
       
    40 using namespace JSC;
       
    41 
       
    42 namespace WebCore {
       
    43 
       
    44 ASSERT_CLASS_FITS_IN_CELL(JSXPathEvaluator);
       
    45 
       
    46 /* Hash table */
       
    47 #if ENABLE(JIT)
       
    48 #define THUNK_GENERATOR(generator) , generator
       
    49 #else
       
    50 #define THUNK_GENERATOR(generator)
       
    51 #endif
       
    52 
       
    53 static const HashTableValue JSXPathEvaluatorTableValues[2] =
       
    54 {
       
    55     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXPathEvaluatorConstructor), (intptr_t)0 THUNK_GENERATOR(0) },
       
    56     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    57 };
       
    58 
       
    59 #undef THUNK_GENERATOR
       
    60 static JSC_CONST_HASHTABLE HashTable JSXPathEvaluatorTable = { 2, 1, JSXPathEvaluatorTableValues, 0 };
       
    61 /* Hash table for constructor */
       
    62 #if ENABLE(JIT)
       
    63 #define THUNK_GENERATOR(generator) , generator
       
    64 #else
       
    65 #define THUNK_GENERATOR(generator)
       
    66 #endif
       
    67 
       
    68 static const HashTableValue JSXPathEvaluatorConstructorTableValues[1] =
       
    69 {
       
    70     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    71 };
       
    72 
       
    73 #undef THUNK_GENERATOR
       
    74 static JSC_CONST_HASHTABLE HashTable JSXPathEvaluatorConstructorTable = { 1, 0, JSXPathEvaluatorConstructorTableValues, 0 };
       
    75 class JSXPathEvaluatorConstructor : public DOMConstructorObject {
       
    76 public:
       
    77     JSXPathEvaluatorConstructor(JSC::ExecState*, JSDOMGlobalObject*);
       
    78 
       
    79     virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);
       
    80     virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);
       
    81     virtual const JSC::ClassInfo* classInfo() const { return &s_info; }
       
    82     static const JSC::ClassInfo s_info;
       
    83     static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)
       
    84     {
       
    85         return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);
       
    86     }
       
    87 protected:
       
    88     static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags;
       
    89     static JSC::EncodedJSValue JSC_HOST_CALL constructJSXPathEvaluator(JSC::ExecState*);
       
    90     virtual JSC::ConstructType getConstructData(JSC::ConstructData&);
       
    91 };
       
    92 
       
    93 const ClassInfo JSXPathEvaluatorConstructor::s_info = { "XPathEvaluatorConstructor", 0, &JSXPathEvaluatorConstructorTable, 0 };
       
    94 
       
    95 JSXPathEvaluatorConstructor::JSXPathEvaluatorConstructor(ExecState* exec, JSDOMGlobalObject* globalObject)
       
    96     : DOMConstructorObject(JSXPathEvaluatorConstructor::createStructure(globalObject->objectPrototype()), globalObject)
       
    97 {
       
    98     putDirect(exec->propertyNames().prototype, JSXPathEvaluatorPrototype::self(exec, globalObject), DontDelete | ReadOnly);
       
    99 }
       
   100 
       
   101 bool JSXPathEvaluatorConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   102 {
       
   103     return getStaticValueSlot<JSXPathEvaluatorConstructor, DOMObject>(exec, &JSXPathEvaluatorConstructorTable, this, propertyName, slot);
       
   104 }
       
   105 
       
   106 bool JSXPathEvaluatorConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   107 {
       
   108     return getStaticValueDescriptor<JSXPathEvaluatorConstructor, DOMObject>(exec, &JSXPathEvaluatorConstructorTable, this, propertyName, descriptor);
       
   109 }
       
   110 
       
   111 EncodedJSValue JSC_HOST_CALL JSXPathEvaluatorConstructor::constructJSXPathEvaluator(ExecState* exec)
       
   112 {
       
   113     return JSValue::encode(asObject(toJS(exec, static_cast<JSXPathEvaluatorConstructor*>(exec->callee())->globalObject(), XPathEvaluator::create())));
       
   114 }
       
   115 
       
   116 ConstructType JSXPathEvaluatorConstructor::getConstructData(ConstructData& constructData)
       
   117 {
       
   118     constructData.native.function = constructJSXPathEvaluator;
       
   119     return ConstructTypeHost;
       
   120 }
       
   121 
       
   122 /* Hash table for prototype */
       
   123 #if ENABLE(JIT)
       
   124 #define THUNK_GENERATOR(generator) , generator
       
   125 #else
       
   126 #define THUNK_GENERATOR(generator)
       
   127 #endif
       
   128 
       
   129 static const HashTableValue JSXPathEvaluatorPrototypeTableValues[4] =
       
   130 {
       
   131     { "createExpression", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsXPathEvaluatorPrototypeFunctionCreateExpression), (intptr_t)2 THUNK_GENERATOR(0) },
       
   132     { "createNSResolver", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsXPathEvaluatorPrototypeFunctionCreateNSResolver), (intptr_t)1 THUNK_GENERATOR(0) },
       
   133     { "evaluate", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsXPathEvaluatorPrototypeFunctionEvaluate), (intptr_t)5 THUNK_GENERATOR(0) },
       
   134     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
   135 };
       
   136 
       
   137 #undef THUNK_GENERATOR
       
   138 static JSC_CONST_HASHTABLE HashTable JSXPathEvaluatorPrototypeTable = { 8, 7, JSXPathEvaluatorPrototypeTableValues, 0 };
       
   139 const ClassInfo JSXPathEvaluatorPrototype::s_info = { "XPathEvaluatorPrototype", 0, &JSXPathEvaluatorPrototypeTable, 0 };
       
   140 
       
   141 JSObject* JSXPathEvaluatorPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
       
   142 {
       
   143     return getDOMPrototype<JSXPathEvaluator>(exec, globalObject);
       
   144 }
       
   145 
       
   146 bool JSXPathEvaluatorPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   147 {
       
   148     return getStaticFunctionSlot<JSObject>(exec, &JSXPathEvaluatorPrototypeTable, this, propertyName, slot);
       
   149 }
       
   150 
       
   151 bool JSXPathEvaluatorPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   152 {
       
   153     return getStaticFunctionDescriptor<JSObject>(exec, &JSXPathEvaluatorPrototypeTable, this, propertyName, descriptor);
       
   154 }
       
   155 
       
   156 const ClassInfo JSXPathEvaluator::s_info = { "XPathEvaluator", 0, &JSXPathEvaluatorTable, 0 };
       
   157 
       
   158 JSXPathEvaluator::JSXPathEvaluator(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<XPathEvaluator> impl)
       
   159     : DOMObjectWithGlobalPointer(structure, globalObject)
       
   160     , m_impl(impl)
       
   161 {
       
   162 }
       
   163 
       
   164 JSXPathEvaluator::~JSXPathEvaluator()
       
   165 {
       
   166     forgetDOMObject(this, impl());
       
   167 }
       
   168 
       
   169 JSObject* JSXPathEvaluator::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
       
   170 {
       
   171     return new (exec) JSXPathEvaluatorPrototype(globalObject, JSXPathEvaluatorPrototype::createStructure(globalObject->objectPrototype()));
       
   172 }
       
   173 
       
   174 bool JSXPathEvaluator::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   175 {
       
   176     return getStaticValueSlot<JSXPathEvaluator, Base>(exec, &JSXPathEvaluatorTable, this, propertyName, slot);
       
   177 }
       
   178 
       
   179 bool JSXPathEvaluator::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   180 {
       
   181     return getStaticValueDescriptor<JSXPathEvaluator, Base>(exec, &JSXPathEvaluatorTable, this, propertyName, descriptor);
       
   182 }
       
   183 
       
   184 JSValue jsXPathEvaluatorConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
       
   185 {
       
   186     JSXPathEvaluator* domObject = static_cast<JSXPathEvaluator*>(asObject(slotBase));
       
   187     return JSXPathEvaluator::getConstructor(exec, domObject->globalObject());
       
   188 }
       
   189 JSValue JSXPathEvaluator::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
       
   190 {
       
   191     return getDOMConstructor<JSXPathEvaluatorConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
       
   192 }
       
   193 
       
   194 EncodedJSValue JSC_HOST_CALL jsXPathEvaluatorPrototypeFunctionCreateExpression(ExecState* exec)
       
   195 {
       
   196     JSValue thisValue = exec->hostThisValue();
       
   197     if (!thisValue.inherits(&JSXPathEvaluator::s_info))
       
   198         return throwVMTypeError(exec);
       
   199     JSXPathEvaluator* castedThis = static_cast<JSXPathEvaluator*>(asObject(thisValue));
       
   200     XPathEvaluator* imp = static_cast<XPathEvaluator*>(castedThis->impl());
       
   201     ExceptionCode ec = 0;
       
   202     const String& expression = ustringToString(exec->argument(0).toString(exec));
       
   203     RefPtr<XPathNSResolver> customResolver;
       
   204     XPathNSResolver* resolver = toXPathNSResolver(exec->argument(1));
       
   205     if (!resolver) {
       
   206         customResolver = JSCustomXPathNSResolver::create(exec, exec->argument(1));
       
   207         if (exec->hadException())
       
   208             return JSValue::encode(jsUndefined());
       
   209         resolver = customResolver.get();
       
   210     }
       
   211 
       
   212 
       
   213     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->createExpression(expression, resolver, ec)));
       
   214     setDOMException(exec, ec);
       
   215     return JSValue::encode(result);
       
   216 }
       
   217 
       
   218 EncodedJSValue JSC_HOST_CALL jsXPathEvaluatorPrototypeFunctionCreateNSResolver(ExecState* exec)
       
   219 {
       
   220     JSValue thisValue = exec->hostThisValue();
       
   221     if (!thisValue.inherits(&JSXPathEvaluator::s_info))
       
   222         return throwVMTypeError(exec);
       
   223     JSXPathEvaluator* castedThis = static_cast<JSXPathEvaluator*>(asObject(thisValue));
       
   224     XPathEvaluator* imp = static_cast<XPathEvaluator*>(castedThis->impl());
       
   225     Node* nodeResolver = toNode(exec->argument(0));
       
   226 
       
   227 
       
   228     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->createNSResolver(nodeResolver)));
       
   229     return JSValue::encode(result);
       
   230 }
       
   231 
       
   232 EncodedJSValue JSC_HOST_CALL jsXPathEvaluatorPrototypeFunctionEvaluate(ExecState* exec)
       
   233 {
       
   234     JSValue thisValue = exec->hostThisValue();
       
   235     if (!thisValue.inherits(&JSXPathEvaluator::s_info))
       
   236         return throwVMTypeError(exec);
       
   237     JSXPathEvaluator* castedThis = static_cast<JSXPathEvaluator*>(asObject(thisValue));
       
   238     XPathEvaluator* imp = static_cast<XPathEvaluator*>(castedThis->impl());
       
   239     ExceptionCode ec = 0;
       
   240     const String& expression = ustringToString(exec->argument(0).toString(exec));
       
   241     Node* contextNode = toNode(exec->argument(1));
       
   242     RefPtr<XPathNSResolver> customResolver;
       
   243     XPathNSResolver* resolver = toXPathNSResolver(exec->argument(2));
       
   244     if (!resolver) {
       
   245         customResolver = JSCustomXPathNSResolver::create(exec, exec->argument(2));
       
   246         if (exec->hadException())
       
   247             return JSValue::encode(jsUndefined());
       
   248         resolver = customResolver.get();
       
   249     }
       
   250     unsigned short type = exec->argument(3).toInt32(exec);
       
   251     XPathResult* inResult = toXPathResult(exec->argument(4));
       
   252 
       
   253 
       
   254     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->evaluate(expression, contextNode, resolver, type, inResult, ec)));
       
   255     setDOMException(exec, ec);
       
   256     return JSValue::encode(result);
       
   257 }
       
   258 
       
   259 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, XPathEvaluator* object)
       
   260 {
       
   261     return getDOMObjectWrapper<JSXPathEvaluator>(exec, globalObject, object);
       
   262 }
       
   263 XPathEvaluator* toXPathEvaluator(JSC::JSValue value)
       
   264 {
       
   265     return value.inherits(&JSXPathEvaluator::s_info) ? static_cast<JSXPathEvaluator*>(asObject(value))->impl() : 0;
       
   266 }
       
   267 
       
   268 }
       
   269 
       
   270 #endif // ENABLE(XPATH)