tizen beta release
[profile/ivi/webkit-efl.git] / DerivedSources / WebCore / JSSVGPoint.cpp
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(SVG)
24
25 #include "JSSVGPoint.h"
26
27 #include "ExceptionCode.h"
28 #include "JSDOMBinding.h"
29 #include "JSSVGMatrix.h"
30 #include "JSSVGPoint.h"
31 #include <runtime/Error.h>
32 #include <wtf/GetPtr.h>
33
34 using namespace JSC;
35
36 namespace WebCore {
37
38 ASSERT_CLASS_FITS_IN_CELL(JSSVGPoint);
39
40 /* Hash table */
41 #if ENABLE(JIT)
42 #define THUNK_GENERATOR(generator) , generator
43 #else
44 #define THUNK_GENERATOR(generator)
45 #endif
46 #if ENABLE(DFG_JIT)
47 #define INTRINSIC(intrinsic) , intrinsic
48 #else
49 #define INTRINSIC(intrinsic)
50 #endif
51
52 static const HashTableValue JSSVGPointTableValues[] =
53 {
54     { "x", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGPointX), (intptr_t)setJSSVGPointX THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
55     { "y", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGPointY), (intptr_t)setJSSVGPointY THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
56     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGPointConstructor), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
57     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
58 };
59
60 #undef THUNK_GENERATOR
61 static const HashTable JSSVGPointTable = { 9, 7, JSSVGPointTableValues, 0 };
62 /* Hash table for constructor */
63 #if ENABLE(JIT)
64 #define THUNK_GENERATOR(generator) , generator
65 #else
66 #define THUNK_GENERATOR(generator)
67 #endif
68 #if ENABLE(DFG_JIT)
69 #define INTRINSIC(intrinsic) , intrinsic
70 #else
71 #define INTRINSIC(intrinsic)
72 #endif
73
74 static const HashTableValue JSSVGPointConstructorTableValues[] =
75 {
76     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
77 };
78
79 #undef THUNK_GENERATOR
80 static const HashTable JSSVGPointConstructorTable = { 1, 0, JSSVGPointConstructorTableValues, 0 };
81 const ClassInfo JSSVGPointConstructor::s_info = { "SVGPointConstructor", &DOMConstructorObject::s_info, &JSSVGPointConstructorTable, 0, CREATE_METHOD_TABLE(JSSVGPointConstructor) };
82
83 JSSVGPointConstructor::JSSVGPointConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
84     : DOMConstructorObject(structure, globalObject)
85 {
86 }
87
88 void JSSVGPointConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
89 {
90     Base::finishCreation(exec->globalData());
91     ASSERT(inherits(&s_info));
92     putDirect(exec->globalData(), exec->propertyNames().prototype, JSSVGPointPrototype::self(exec, globalObject), DontDelete | ReadOnly);
93 }
94
95 bool JSSVGPointConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
96 {
97     return getStaticValueSlot<JSSVGPointConstructor, JSDOMWrapper>(exec, &JSSVGPointConstructorTable, static_cast<JSSVGPointConstructor*>(cell), propertyName, slot);
98 }
99
100 bool JSSVGPointConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
101 {
102     return getStaticValueDescriptor<JSSVGPointConstructor, JSDOMWrapper>(exec, &JSSVGPointConstructorTable, static_cast<JSSVGPointConstructor*>(object), propertyName, descriptor);
103 }
104
105 /* Hash table for prototype */
106 #if ENABLE(JIT)
107 #define THUNK_GENERATOR(generator) , generator
108 #else
109 #define THUNK_GENERATOR(generator)
110 #endif
111 #if ENABLE(DFG_JIT)
112 #define INTRINSIC(intrinsic) , intrinsic
113 #else
114 #define INTRINSIC(intrinsic)
115 #endif
116
117 static const HashTableValue JSSVGPointPrototypeTableValues[] =
118 {
119     { "matrixTransform", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsSVGPointPrototypeFunctionMatrixTransform), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
120     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
121 };
122
123 #undef THUNK_GENERATOR
124 static const HashTable JSSVGPointPrototypeTable = { 2, 1, JSSVGPointPrototypeTableValues, 0 };
125 const ClassInfo JSSVGPointPrototype::s_info = { "SVGPointPrototype", &JSC::JSNonFinalObject::s_info, &JSSVGPointPrototypeTable, 0, CREATE_METHOD_TABLE(JSSVGPointPrototype) };
126
127 JSObject* JSSVGPointPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
128 {
129     return getDOMPrototype<JSSVGPoint>(exec, globalObject);
130 }
131
132 bool JSSVGPointPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
133 {
134     JSSVGPointPrototype* thisObject = jsCast<JSSVGPointPrototype*>(cell);
135     return getStaticFunctionSlot<JSObject>(exec, &JSSVGPointPrototypeTable, thisObject, propertyName, slot);
136 }
137
138 bool JSSVGPointPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
139 {
140     JSSVGPointPrototype* thisObject = jsCast<JSSVGPointPrototype*>(object);
141     return getStaticFunctionDescriptor<JSObject>(exec, &JSSVGPointPrototypeTable, thisObject, propertyName, descriptor);
142 }
143
144 const ClassInfo JSSVGPoint::s_info = { "SVGPoint", &JSDOMWrapper::s_info, &JSSVGPointTable, 0 , CREATE_METHOD_TABLE(JSSVGPoint) };
145
146 JSSVGPoint::JSSVGPoint(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<SVGPropertyTearOff<FloatPoint> > impl)
147     : JSDOMWrapper(structure, globalObject)
148     , m_impl(impl.leakRef())
149 {
150 }
151
152 void JSSVGPoint::finishCreation(JSGlobalData& globalData)
153 {
154     Base::finishCreation(globalData);
155     ASSERT(inherits(&s_info));
156 }
157
158 JSObject* JSSVGPoint::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
159 {
160     return JSSVGPointPrototype::create(exec->globalData(), globalObject, JSSVGPointPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
161 }
162
163 bool JSSVGPoint::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
164 {
165     JSSVGPoint* thisObject = jsCast<JSSVGPoint*>(cell);
166     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
167     return getStaticValueSlot<JSSVGPoint, Base>(exec, &JSSVGPointTable, thisObject, propertyName, slot);
168 }
169
170 bool JSSVGPoint::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
171 {
172     JSSVGPoint* thisObject = jsCast<JSSVGPoint*>(object);
173     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
174     return getStaticValueDescriptor<JSSVGPoint, Base>(exec, &JSSVGPointTable, thisObject, propertyName, descriptor);
175 }
176
177 JSValue jsSVGPointX(ExecState* exec, JSValue slotBase, const Identifier&)
178 {
179     JSSVGPoint* castedThis = static_cast<JSSVGPoint*>(asObject(slotBase));
180     UNUSED_PARAM(exec);
181     FloatPoint& imp = castedThis->impl()->propertyReference();
182     JSValue result =  jsNumber(imp.x());
183     return result;
184 }
185
186
187 JSValue jsSVGPointY(ExecState* exec, JSValue slotBase, const Identifier&)
188 {
189     JSSVGPoint* castedThis = static_cast<JSSVGPoint*>(asObject(slotBase));
190     UNUSED_PARAM(exec);
191     FloatPoint& imp = castedThis->impl()->propertyReference();
192     JSValue result =  jsNumber(imp.y());
193     return result;
194 }
195
196
197 JSValue jsSVGPointConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
198 {
199     JSSVGPoint* domObject = static_cast<JSSVGPoint*>(asObject(slotBase));
200     return JSSVGPoint::getConstructor(exec, domObject->globalObject());
201 }
202
203 void JSSVGPoint::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
204 {
205     JSSVGPoint* thisObject = jsCast<JSSVGPoint*>(cell);
206     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
207     lookupPut<JSSVGPoint, Base>(exec, propertyName, value, &JSSVGPointTable, thisObject, slot);
208 }
209
210 void setJSSVGPointX(ExecState* exec, JSObject* thisObject, JSValue value)
211 {
212     JSSVGPoint* castedThis = static_cast<JSSVGPoint*>(thisObject);
213     SVGPropertyTearOff<FloatPoint> * imp = static_cast<SVGPropertyTearOff<FloatPoint> *>(castedThis->impl());
214     if (imp->role() == AnimValRole) {
215         setDOMException(exec, NO_MODIFICATION_ALLOWED_ERR);
216         return;
217     }
218     FloatPoint& podImp = imp->propertyReference();
219     podImp.setX(value.toFloat(exec));
220     imp->commitChange();
221 }
222
223
224 void setJSSVGPointY(ExecState* exec, JSObject* thisObject, JSValue value)
225 {
226     JSSVGPoint* castedThis = static_cast<JSSVGPoint*>(thisObject);
227     SVGPropertyTearOff<FloatPoint> * imp = static_cast<SVGPropertyTearOff<FloatPoint> *>(castedThis->impl());
228     if (imp->role() == AnimValRole) {
229         setDOMException(exec, NO_MODIFICATION_ALLOWED_ERR);
230         return;
231     }
232     FloatPoint& podImp = imp->propertyReference();
233     podImp.setY(value.toFloat(exec));
234     imp->commitChange();
235 }
236
237
238 JSValue JSSVGPoint::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
239 {
240     return getDOMConstructor<JSSVGPointConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
241 }
242
243 EncodedJSValue JSC_HOST_CALL jsSVGPointPrototypeFunctionMatrixTransform(ExecState* exec)
244 {
245     JSValue thisValue = exec->hostThisValue();
246     if (!thisValue.inherits(&JSSVGPoint::s_info))
247         return throwVMTypeError(exec);
248     JSSVGPoint* castedThis = static_cast<JSSVGPoint*>(asObject(thisValue));
249     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSSVGPoint::s_info);
250     SVGPropertyTearOff<FloatPoint> * imp = static_cast<SVGPropertyTearOff<FloatPoint> *>(castedThis->impl());
251     if (imp->role() == AnimValRole) {
252         setDOMException(exec, NO_MODIFICATION_ALLOWED_ERR);
253         return JSValue::encode(jsUndefined());
254     }
255     FloatPoint& podImp = imp->propertyReference();
256     if (exec->argumentCount() < 1)
257         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
258     if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull() && !exec->argument(0).inherits(&JSSVGMatrix::s_info))
259         return throwVMTypeError(exec);
260     SVGPropertyTearOff<SVGMatrix>* matrix(toSVGMatrix(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
261     if (exec->hadException())
262         return JSValue::encode(jsUndefined());
263     if (!matrix) {
264         setDOMException(exec, TYPE_MISMATCH_ERR);
265         return JSValue::encode(jsUndefined());
266     }
267
268     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(SVGPropertyTearOff<FloatPoint>::create(podImp.matrixTransform(matrix->propertyReference()))));
269     return JSValue::encode(result);
270 }
271
272 static inline bool isObservable(JSSVGPoint* jsSVGPoint)
273 {
274     if (jsSVGPoint->hasCustomProperties())
275         return true;
276     return false;
277 }
278
279 bool JSSVGPointOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
280 {
281     JSSVGPoint* jsSVGPoint = static_cast<JSSVGPoint*>(handle.get().asCell());
282     if (!isObservable(jsSVGPoint))
283         return false;
284     UNUSED_PARAM(visitor);
285     return false;
286 }
287
288 void JSSVGPointOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
289 {
290     JSSVGPoint* jsSVGPoint = static_cast<JSSVGPoint*>(handle.get().asCell());
291     DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
292     uncacheWrapper(world, jsSVGPoint->impl(), jsSVGPoint);
293     jsSVGPoint->releaseImpl();
294 }
295
296 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, SVGPropertyTearOff<FloatPoint> * impl)
297 {
298     return wrap<JSSVGPoint, SVGPropertyTearOff<FloatPoint> >(exec, globalObject, impl);
299 }
300
301 SVGPropertyTearOff<FloatPoint> * toSVGPoint(JSC::JSValue value)
302 {
303     return value.inherits(&JSSVGPoint::s_info) ? static_cast<JSSVGPoint*>(asObject(value))->impl() : 0;
304 }
305
306 }
307
308 #endif // ENABLE(SVG)