|
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 |
|
24 #if ENABLE(XPATH) |
|
25 |
|
26 #include "JSXPathExpression.h" |
|
27 |
|
28 #include <wtf/GetPtr.h> |
|
29 |
|
30 #include "JSNode.h" |
|
31 #include "JSXPathResult.h" |
|
32 #include "XPathExpression.h" |
|
33 #include "XPathResult.h" |
|
34 |
|
35 using namespace KJS; |
|
36 |
|
37 namespace WebCore { |
|
38 |
|
39 /* Hash table for prototype */ |
|
40 |
|
41 static const HashEntry JSXPathExpressionPrototypeTableEntries[] = |
|
42 { |
|
43 { "evaluate", JSXPathExpression::EvaluateFuncNum, DontDelete|Function, 3, 0 } |
|
44 }; |
|
45 |
|
46 static const HashTable JSXPathExpressionPrototypeTable = |
|
47 { |
|
48 2, 1, JSXPathExpressionPrototypeTableEntries, 1 |
|
49 }; |
|
50 |
|
51 const ClassInfo JSXPathExpressionPrototype::info = { "XPathExpressionPrototype", 0, &JSXPathExpressionPrototypeTable, 0 }; |
|
52 |
|
53 JSObject* JSXPathExpressionPrototype::self(ExecState* exec) |
|
54 { |
|
55 return KJS::cacheGlobalObject<JSXPathExpressionPrototype>(exec, "[[JSXPathExpression.prototype]]"); |
|
56 } |
|
57 |
|
58 bool JSXPathExpressionPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
59 { |
|
60 return getStaticFunctionSlot<JSXPathExpressionPrototypeFunction, JSObject>(exec, &JSXPathExpressionPrototypeTable, this, propertyName, slot); |
|
61 } |
|
62 |
|
63 const ClassInfo JSXPathExpression::info = { "XPathExpression", 0, 0, 0 }; |
|
64 |
|
65 JSXPathExpression::JSXPathExpression(ExecState* exec, XPathExpression* impl) |
|
66 : m_impl(impl) |
|
67 { |
|
68 setPrototype(JSXPathExpressionPrototype::self(exec)); |
|
69 } |
|
70 |
|
71 JSXPathExpression::~JSXPathExpression() |
|
72 { |
|
73 ScriptInterpreter::forgetDOMObject(m_impl.get()); |
|
74 } |
|
75 |
|
76 JSValue* JSXPathExpressionPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) |
|
77 { |
|
78 if (!thisObj->inherits(&JSXPathExpression::info)) |
|
79 return throwError(exec, TypeError); |
|
80 |
|
81 XPathExpression* imp = static_cast<XPathExpression*>(static_cast<JSXPathExpression*>(thisObj)->impl()); |
|
82 |
|
83 switch (id) { |
|
84 case JSXPathExpression::EvaluateFuncNum: { |
|
85 ExceptionCode ec = 0; |
|
86 Node* contextNode = toNode(args[0]); |
|
87 unsigned short type = args[1]->toInt32(exec); |
|
88 XPathResult* inResult = toXPathResult(args[2]); |
|
89 |
|
90 |
|
91 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->evaluate(contextNode, type, inResult, ec))); |
|
92 setDOMException(exec, ec); |
|
93 return result; |
|
94 } |
|
95 } |
|
96 return 0; |
|
97 } |
|
98 KJS::JSValue* toJS(KJS::ExecState* exec, XPathExpression* obj) |
|
99 { |
|
100 return KJS::cacheDOMObject<XPathExpression, JSXPathExpression>(exec, obj); |
|
101 } |
|
102 XPathExpression* toXPathExpression(KJS::JSValue* val) |
|
103 { |
|
104 return val->isObject(&JSXPathExpression::info) ? static_cast<JSXPathExpression*>(val)->impl() : 0; |
|
105 } |
|
106 |
|
107 } |
|
108 |
|
109 #endif // ENABLE(XPATH) |