summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/WebCore/generated/JSSVGMatrix.cpp
blob: ba8dfe85b170c19061796177501f05f95056408e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
/*
    This file is part of the WebKit open source project.
    This file has been generated by generate-bindings.pl. DO NOT MODIFY!

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/

#include "config.h"

#if ENABLE(SVG)

#include "JSSVGMatrix.h"

#include "JSSVGMatrix.h"
#include <runtime/Error.h>
#include <runtime/JSNumberCell.h>
#include <wtf/GetPtr.h>

using namespace JSC;

namespace WebCore {

ASSERT_CLASS_FITS_IN_CELL(JSSVGMatrix);

/* Hash table */

static const HashTableValue JSSVGMatrixTableValues[7] =
{
    { "a", DontDelete, (intptr_t)jsSVGMatrixA, (intptr_t)setJSSVGMatrixA },
    { "b", DontDelete, (intptr_t)jsSVGMatrixB, (intptr_t)setJSSVGMatrixB },
    { "c", DontDelete, (intptr_t)jsSVGMatrixC, (intptr_t)setJSSVGMatrixC },
    { "d", DontDelete, (intptr_t)jsSVGMatrixD, (intptr_t)setJSSVGMatrixD },
    { "e", DontDelete, (intptr_t)jsSVGMatrixE, (intptr_t)setJSSVGMatrixE },
    { "f", DontDelete, (intptr_t)jsSVGMatrixF, (intptr_t)setJSSVGMatrixF },
    { 0, 0, 0, 0 }
};

static JSC_CONST_HASHTABLE HashTable JSSVGMatrixTable =
#if ENABLE(PERFECT_HASH_SIZE)
    { 15, JSSVGMatrixTableValues, 0 };
#else
    { 16, 15, JSSVGMatrixTableValues, 0 };
#endif

/* Hash table for prototype */

static const HashTableValue JSSVGMatrixPrototypeTableValues[12] =
{
    { "multiply", DontDelete|Function, (intptr_t)jsSVGMatrixPrototypeFunctionMultiply, (intptr_t)1 },
    { "inverse", DontDelete|Function, (intptr_t)jsSVGMatrixPrototypeFunctionInverse, (intptr_t)0 },
    { "translate", DontDelete|Function, (intptr_t)jsSVGMatrixPrototypeFunctionTranslate, (intptr_t)2 },
    { "scale", DontDelete|Function, (intptr_t)jsSVGMatrixPrototypeFunctionScale, (intptr_t)1 },
    { "scaleNonUniform", DontDelete|Function, (intptr_t)jsSVGMatrixPrototypeFunctionScaleNonUniform, (intptr_t)2 },
    { "rotate", DontDelete|Function, (intptr_t)jsSVGMatrixPrototypeFunctionRotate, (intptr_t)1 },
    { "rotateFromVector", DontDelete|Function, (intptr_t)jsSVGMatrixPrototypeFunctionRotateFromVector, (intptr_t)2 },
    { "flipX", DontDelete|Function, (intptr_t)jsSVGMatrixPrototypeFunctionFlipX, (intptr_t)0 },
    { "flipY", DontDelete|Function, (intptr_t)jsSVGMatrixPrototypeFunctionFlipY, (intptr_t)0 },
    { "skewX", DontDelete|Function, (intptr_t)jsSVGMatrixPrototypeFunctionSkewX, (intptr_t)1 },
    { "skewY", DontDelete|Function, (intptr_t)jsSVGMatrixPrototypeFunctionSkewY, (intptr_t)1 },
    { 0, 0, 0, 0 }
};

static JSC_CONST_HASHTABLE HashTable JSSVGMatrixPrototypeTable =
#if ENABLE(PERFECT_HASH_SIZE)
    { 63, JSSVGMatrixPrototypeTableValues, 0 };
#else
    { 33, 31, JSSVGMatrixPrototypeTableValues, 0 };
#endif

const ClassInfo JSSVGMatrixPrototype::s_info = { "SVGMatrixPrototype", 0, &JSSVGMatrixPrototypeTable, 0 };

JSObject* JSSVGMatrixPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
{
    return getDOMPrototype<JSSVGMatrix>(exec, globalObject);
}

bool JSSVGMatrixPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
    return getStaticFunctionSlot<JSObject>(exec, &JSSVGMatrixPrototypeTable, this, propertyName, slot);
}

bool JSSVGMatrixPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
    return getStaticFunctionDescriptor<JSObject>(exec, &JSSVGMatrixPrototypeTable, this, propertyName, descriptor);
}

const ClassInfo JSSVGMatrix::s_info = { "SVGMatrix", 0, &JSSVGMatrixTable, 0 };

JSSVGMatrix::JSSVGMatrix(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<JSSVGPODTypeWrapper<TransformationMatrix> > impl, SVGElement* context)
    : DOMObjectWithSVGContext(structure, globalObject, context)
    , m_impl(impl)
{
}

JSSVGMatrix::~JSSVGMatrix()
{
    forgetDOMObject(*Heap::heap(this)->globalData(), impl());
}

JSObject* JSSVGMatrix::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
{
    return new (exec) JSSVGMatrixPrototype(JSSVGMatrixPrototype::createStructure(globalObject->objectPrototype()));
}

bool JSSVGMatrix::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
    return getStaticValueSlot<JSSVGMatrix, Base>(exec, &JSSVGMatrixTable, this, propertyName, slot);
}

bool JSSVGMatrix::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
    return getStaticValueDescriptor<JSSVGMatrix, Base>(exec, &JSSVGMatrixTable, this, propertyName, descriptor);
}

JSValue jsSVGMatrixA(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
    JSSVGMatrix* castedThis = static_cast<JSSVGMatrix*>(asObject(slot.slotBase()));
    UNUSED_PARAM(exec);
    TransformationMatrix imp(*castedThis->impl());
    return jsNumber(exec, imp.a());
}

JSValue jsSVGMatrixB(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
    JSSVGMatrix* castedThis = static_cast<JSSVGMatrix*>(asObject(slot.slotBase()));
    UNUSED_PARAM(exec);
    TransformationMatrix imp(*castedThis->impl());
    return jsNumber(exec, imp.b());
}

JSValue jsSVGMatrixC(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
    JSSVGMatrix* castedThis = static_cast<JSSVGMatrix*>(asObject(slot.slotBase()));
    UNUSED_PARAM(exec);
    TransformationMatrix imp(*castedThis->impl());
    return jsNumber(exec, imp.c());
}

JSValue jsSVGMatrixD(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
    JSSVGMatrix* castedThis = static_cast<JSSVGMatrix*>(asObject(slot.slotBase()));
    UNUSED_PARAM(exec);
    TransformationMatrix imp(*castedThis->impl());
    return jsNumber(exec, imp.d());
}

JSValue jsSVGMatrixE(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
    JSSVGMatrix* castedThis = static_cast<JSSVGMatrix*>(asObject(slot.slotBase()));
    UNUSED_PARAM(exec);
    TransformationMatrix imp(*castedThis->impl());
    return jsNumber(exec, imp.e());
}

JSValue jsSVGMatrixF(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
    JSSVGMatrix* castedThis = static_cast<JSSVGMatrix*>(asObject(slot.slotBase()));
    UNUSED_PARAM(exec);
    TransformationMatrix imp(*castedThis->impl());
    return jsNumber(exec, imp.f());
}

void JSSVGMatrix::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
    lookupPut<JSSVGMatrix, Base>(exec, propertyName, value, &JSSVGMatrixTable, this, slot);
}

void setJSSVGMatrixA(ExecState* exec, JSObject* thisObject, JSValue value)
{
    TransformationMatrix imp(*static_cast<JSSVGMatrix*>(thisObject)->impl());
    imp.setA(value.toNumber(exec));
        static_cast<JSSVGMatrix*>(thisObject)->impl()->commitChange(imp, static_cast<JSSVGMatrix*>(thisObject)->context());
}

void setJSSVGMatrixB(ExecState* exec, JSObject* thisObject, JSValue value)
{
    TransformationMatrix imp(*static_cast<JSSVGMatrix*>(thisObject)->impl());
    imp.setB(value.toNumber(exec));
        static_cast<JSSVGMatrix*>(thisObject)->impl()->commitChange(imp, static_cast<JSSVGMatrix*>(thisObject)->context());
}

void setJSSVGMatrixC(ExecState* exec, JSObject* thisObject, JSValue value)
{
    TransformationMatrix imp(*static_cast<JSSVGMatrix*>(thisObject)->impl());
    imp.setC(value.toNumber(exec));
        static_cast<JSSVGMatrix*>(thisObject)->impl()->commitChange(imp, static_cast<JSSVGMatrix*>(thisObject)->context());
}

void setJSSVGMatrixD(ExecState* exec, JSObject* thisObject, JSValue value)
{
    TransformationMatrix imp(*static_cast<JSSVGMatrix*>(thisObject)->impl());
    imp.setD(value.toNumber(exec));
        static_cast<JSSVGMatrix*>(thisObject)->impl()->commitChange(imp, static_cast<JSSVGMatrix*>(thisObject)->context());
}

void setJSSVGMatrixE(ExecState* exec, JSObject* thisObject, JSValue value)
{
    TransformationMatrix imp(*static_cast<JSSVGMatrix*>(thisObject)->impl());
    imp.setE(value.toNumber(exec));
        static_cast<JSSVGMatrix*>(thisObject)->impl()->commitChange(imp, static_cast<JSSVGMatrix*>(thisObject)->context());
}

void setJSSVGMatrixF(ExecState* exec, JSObject* thisObject, JSValue value)
{
    TransformationMatrix imp(*static_cast<JSSVGMatrix*>(thisObject)->impl());
    imp.setF(value.toNumber(exec));
        static_cast<JSSVGMatrix*>(thisObject)->impl()->commitChange(imp, static_cast<JSSVGMatrix*>(thisObject)->context());
}

JSValue JSC_HOST_CALL jsSVGMatrixPrototypeFunctionMultiply(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.inherits(&JSSVGMatrix::s_info))
        return throwError(exec, TypeError);
    JSSVGMatrix* castedThisObj = static_cast<JSSVGMatrix*>(asObject(thisValue));
    JSSVGPODTypeWrapper<TransformationMatrix>* wrapper = castedThisObj->impl();
    TransformationMatrix imp(*wrapper);
    TransformationMatrix secondMatrix = toSVGMatrix(args.at(0));


    JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGStaticPODTypeWrapper<TransformationMatrix>::create(imp.multiply(secondMatrix)).get(), castedThisObj->context());
    return result;
}

JSValue JSC_HOST_CALL jsSVGMatrixPrototypeFunctionInverse(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.inherits(&JSSVGMatrix::s_info))
        return throwError(exec, TypeError);
    JSSVGMatrix* castedThisObj = static_cast<JSSVGMatrix*>(asObject(thisValue));
    return castedThisObj->inverse(exec, args);
}

JSValue JSC_HOST_CALL jsSVGMatrixPrototypeFunctionTranslate(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.inherits(&JSSVGMatrix::s_info))
        return throwError(exec, TypeError);
    JSSVGMatrix* castedThisObj = static_cast<JSSVGMatrix*>(asObject(thisValue));
    JSSVGPODTypeWrapper<TransformationMatrix>* wrapper = castedThisObj->impl();
    TransformationMatrix imp(*wrapper);
    float x = args.at(0).toFloat(exec);
    float y = args.at(1).toFloat(exec);


    JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGStaticPODTypeWrapper<TransformationMatrix>::create(imp.translate(x, y)).get(), castedThisObj->context());
    return result;
}

JSValue JSC_HOST_CALL jsSVGMatrixPrototypeFunctionScale(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.inherits(&JSSVGMatrix::s_info))
        return throwError(exec, TypeError);
    JSSVGMatrix* castedThisObj = static_cast<JSSVGMatrix*>(asObject(thisValue));
    JSSVGPODTypeWrapper<TransformationMatrix>* wrapper = castedThisObj->impl();
    TransformationMatrix imp(*wrapper);
    float scaleFactor = args.at(0).toFloat(exec);


    JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGStaticPODTypeWrapper<TransformationMatrix>::create(imp.scale(scaleFactor)).get(), castedThisObj->context());
    return result;
}

JSValue JSC_HOST_CALL jsSVGMatrixPrototypeFunctionScaleNonUniform(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.inherits(&JSSVGMatrix::s_info))
        return throwError(exec, TypeError);
    JSSVGMatrix* castedThisObj = static_cast<JSSVGMatrix*>(asObject(thisValue));
    JSSVGPODTypeWrapper<TransformationMatrix>* wrapper = castedThisObj->impl();
    TransformationMatrix imp(*wrapper);
    float scaleFactorX = args.at(0).toFloat(exec);
    float scaleFactorY = args.at(1).toFloat(exec);


    JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGStaticPODTypeWrapper<TransformationMatrix>::create(imp.scaleNonUniform(scaleFactorX, scaleFactorY)).get(), castedThisObj->context());
    return result;
}

JSValue JSC_HOST_CALL jsSVGMatrixPrototypeFunctionRotate(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.inherits(&JSSVGMatrix::s_info))
        return throwError(exec, TypeError);
    JSSVGMatrix* castedThisObj = static_cast<JSSVGMatrix*>(asObject(thisValue));
    JSSVGPODTypeWrapper<TransformationMatrix>* wrapper = castedThisObj->impl();
    TransformationMatrix imp(*wrapper);
    float angle = args.at(0).toFloat(exec);


    JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGStaticPODTypeWrapper<TransformationMatrix>::create(imp.rotate(angle)).get(), castedThisObj->context());
    return result;
}

JSValue JSC_HOST_CALL jsSVGMatrixPrototypeFunctionRotateFromVector(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.inherits(&JSSVGMatrix::s_info))
        return throwError(exec, TypeError);
    JSSVGMatrix* castedThisObj = static_cast<JSSVGMatrix*>(asObject(thisValue));
    return castedThisObj->rotateFromVector(exec, args);
}

JSValue JSC_HOST_CALL jsSVGMatrixPrototypeFunctionFlipX(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.inherits(&JSSVGMatrix::s_info))
        return throwError(exec, TypeError);
    JSSVGMatrix* castedThisObj = static_cast<JSSVGMatrix*>(asObject(thisValue));
    JSSVGPODTypeWrapper<TransformationMatrix>* wrapper = castedThisObj->impl();
    TransformationMatrix imp(*wrapper);


    JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGStaticPODTypeWrapper<TransformationMatrix>::create(imp.flipX()).get(), castedThisObj->context());
    return result;
}

JSValue JSC_HOST_CALL jsSVGMatrixPrototypeFunctionFlipY(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.inherits(&JSSVGMatrix::s_info))
        return throwError(exec, TypeError);
    JSSVGMatrix* castedThisObj = static_cast<JSSVGMatrix*>(asObject(thisValue));
    JSSVGPODTypeWrapper<TransformationMatrix>* wrapper = castedThisObj->impl();
    TransformationMatrix imp(*wrapper);


    JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGStaticPODTypeWrapper<TransformationMatrix>::create(imp.flipY()).get(), castedThisObj->context());
    return result;
}

JSValue JSC_HOST_CALL jsSVGMatrixPrototypeFunctionSkewX(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.inherits(&JSSVGMatrix::s_info))
        return throwError(exec, TypeError);
    JSSVGMatrix* castedThisObj = static_cast<JSSVGMatrix*>(asObject(thisValue));
    JSSVGPODTypeWrapper<TransformationMatrix>* wrapper = castedThisObj->impl();
    TransformationMatrix imp(*wrapper);
    float angle = args.at(0).toFloat(exec);


    JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGStaticPODTypeWrapper<TransformationMatrix>::create(imp.skewX(angle)).get(), castedThisObj->context());
    return result;
}

JSValue JSC_HOST_CALL jsSVGMatrixPrototypeFunctionSkewY(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.inherits(&JSSVGMatrix::s_info))
        return throwError(exec, TypeError);
    JSSVGMatrix* castedThisObj = static_cast<JSSVGMatrix*>(asObject(thisValue));
    JSSVGPODTypeWrapper<TransformationMatrix>* wrapper = castedThisObj->impl();
    TransformationMatrix imp(*wrapper);
    float angle = args.at(0).toFloat(exec);


    JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGStaticPODTypeWrapper<TransformationMatrix>::create(imp.skewY(angle)).get(), castedThisObj->context());
    return result;
}

JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, JSSVGPODTypeWrapper<TransformationMatrix>* object, SVGElement* context)
{
    return getDOMObjectWrapper<JSSVGMatrix, JSSVGPODTypeWrapper<TransformationMatrix> >(exec, globalObject, object, context);
}
TransformationMatrix toSVGMatrix(JSC::JSValue value)
{
    return value.inherits(&JSSVGMatrix::s_info) ? (TransformationMatrix) *static_cast<JSSVGMatrix*>(asObject(value))->impl() : TransformationMatrix();
}

}

#endif // ENABLE(SVG)