webengine/osswebengine/DerivedSources/WebCore/JSSVGPoint.cpp
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     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(SVG)
       
    25 
       
    26 #include "Document.h"
       
    27 #include "Frame.h"
       
    28 #include "SVGDocumentExtensions.h"
       
    29 #include "SVGElement.h"
       
    30 #include "SVGAnimatedTemplate.h"
       
    31 #include "JSSVGPoint.h"
       
    32 
       
    33 #include <wtf/GetPtr.h>
       
    34 
       
    35 #include "JSSVGMatrix.h"
       
    36 #include "JSSVGPoint.h"
       
    37 
       
    38 using namespace KJS;
       
    39 
       
    40 namespace WebCore {
       
    41 
       
    42 /* Hash table */
       
    43 
       
    44 static const HashEntry JSSVGPointTableEntries[] =
       
    45 {
       
    46     { "y", JSSVGPoint::YAttrNum, DontDelete, 0, 0 },
       
    47     { "x", JSSVGPoint::XAttrNum, DontDelete, 0, 0 }
       
    48 };
       
    49 
       
    50 static const HashTable JSSVGPointTable = 
       
    51 {
       
    52     2, 2, JSSVGPointTableEntries, 2
       
    53 };
       
    54 
       
    55 /* Hash table for prototype */
       
    56 
       
    57 static const HashEntry JSSVGPointPrototypeTableEntries[] =
       
    58 {
       
    59     { "matrixTransform", JSSVGPoint::MatrixTransformFuncNum, DontDelete|Function, 1, 0 }
       
    60 };
       
    61 
       
    62 static const HashTable JSSVGPointPrototypeTable = 
       
    63 {
       
    64     2, 1, JSSVGPointPrototypeTableEntries, 1
       
    65 };
       
    66 
       
    67 const ClassInfo JSSVGPointPrototype::info = { "SVGPointPrototype", 0, &JSSVGPointPrototypeTable, 0 };
       
    68 
       
    69 JSObject* JSSVGPointPrototype::self(ExecState* exec)
       
    70 {
       
    71     return KJS::cacheGlobalObject<JSSVGPointPrototype>(exec, "[[JSSVGPoint.prototype]]");
       
    72 }
       
    73 
       
    74 bool JSSVGPointPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
    75 {
       
    76     return getStaticFunctionSlot<JSSVGPointPrototypeFunction, JSObject>(exec, &JSSVGPointPrototypeTable, this, propertyName, slot);
       
    77 }
       
    78 
       
    79 const ClassInfo JSSVGPoint::info = { "SVGPoint", 0, &JSSVGPointTable, 0 };
       
    80 
       
    81 JSSVGPoint::JSSVGPoint(ExecState* exec, JSSVGPODTypeWrapper<FloatPoint>* impl)
       
    82     : m_impl(impl)
       
    83 {
       
    84     setPrototype(JSSVGPointPrototype::self(exec));
       
    85 }
       
    86 
       
    87 JSSVGPoint::~JSSVGPoint()
       
    88 {
       
    89     ScriptInterpreter::forgetDOMObject(m_impl.get());
       
    90 }
       
    91 
       
    92 bool JSSVGPoint::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
    93 {
       
    94     return getStaticValueSlot<JSSVGPoint, KJS::DOMObject>(exec, &JSSVGPointTable, this, propertyName, slot);
       
    95 }
       
    96 
       
    97 JSValue* JSSVGPoint::getValueProperty(ExecState* exec, int token) const
       
    98 {
       
    99     switch (token) {
       
   100     case XAttrNum: {
       
   101         FloatPoint& imp(*impl());
       
   102 
       
   103         return jsNumber(imp.x());
       
   104     }
       
   105     case YAttrNum: {
       
   106         FloatPoint& imp(*impl());
       
   107 
       
   108         return jsNumber(imp.y());
       
   109     }
       
   110     }
       
   111     return 0;
       
   112 }
       
   113 
       
   114 void JSSVGPoint::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
       
   115 {
       
   116     lookupPut<JSSVGPoint, KJS::DOMObject>(exec, propertyName, value, attr, &JSSVGPointTable, this);
       
   117 }
       
   118 
       
   119 void JSSVGPoint::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)
       
   120 {
       
   121     switch (token) {
       
   122     case XAttrNum: {
       
   123         FloatPoint& imp(*impl());
       
   124 
       
   125         imp.setX(value->toFloat(exec));
       
   126         m_impl->commitChange(exec);
       
   127         break;
       
   128     }
       
   129     case YAttrNum: {
       
   130         FloatPoint& imp(*impl());
       
   131 
       
   132         imp.setY(value->toFloat(exec));
       
   133         m_impl->commitChange(exec);
       
   134         break;
       
   135     }
       
   136     }
       
   137 }
       
   138 
       
   139 JSValue* JSSVGPointPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
       
   140 {
       
   141     if (!thisObj->inherits(&JSSVGPoint::info))
       
   142       return throwError(exec, TypeError);
       
   143 
       
   144     JSSVGPODTypeWrapper<FloatPoint>* wrapper = static_cast<JSSVGPoint*>(thisObj)->impl();
       
   145     FloatPoint& imp(*wrapper);
       
   146 
       
   147     switch (id) {
       
   148     case JSSVGPoint::MatrixTransformFuncNum: {
       
   149         AffineTransform matrix = toSVGMatrix(args[0]);
       
   150 
       
   151 
       
   152         KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<FloatPoint>(imp.matrixTransform(matrix)));
       
   153         wrapper->commitChange(exec);
       
   154         return result;
       
   155     }
       
   156     }
       
   157     return 0;
       
   158 }
       
   159 KJS::JSValue* toJS(KJS::ExecState* exec, JSSVGPODTypeWrapper<FloatPoint>* obj)
       
   160 {
       
   161     return KJS::cacheDOMObject<JSSVGPODTypeWrapper<FloatPoint>, JSSVGPoint>(exec, obj);
       
   162 }
       
   163 FloatPoint toSVGPoint(KJS::JSValue* val)
       
   164 {
       
   165     return val->isObject(&JSSVGPoint::info) ? (FloatPoint) *static_cast<JSSVGPoint*>(val)->impl() : FloatPoint();
       
   166 }
       
   167 
       
   168 }
       
   169 
       
   170 #endif // ENABLE(SVG)