| Differences between
and this patch
- a/WebCore/ChangeLog +33 lines
Lines 1-3 a/WebCore/ChangeLog_sec1
1
2010-09-04  Kinuko Yasuda  <kinuko@chromium.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        Add JSON parameter support to JS/V8 binding generator scripts.
6
        https://bugs.webkit.org/show_bug.cgi?id=45237
7
8
        Adding a new extended attribute "AllowJSON" to support passing parameters in JSON format.
9
10
        Added a new test method methodWithAllowJSON in TestObj.idl.
11
12
        * bindings/scripts/CodeGeneratorJS.pm:
13
        * bindings/scripts/CodeGeneratorV8.pm:
14
        * fileapi/DirectoryEntry.idl:
15
16
        * bindings/scripts/test/JS/JSTestObj.cpp:
17
        (WebCore::jsTestObjPrototypeFunctionMethodWithAllowJSON):
18
        * bindings/scripts/test/CPP/WebDOMTestJSONObj.cpp: Added.
19
        * bindings/scripts/test/CPP/WebDOMTestJSONObj.h: Added.
20
        * bindings/scripts/test/GObject/WebKitDOMTestJSONObj.cpp: Added.
21
        * bindings/scripts/test/GObject/WebKitDOMTestJSONObj.h: Added.
22
        * bindings/scripts/test/GObject/WebKitDOMTestJSONObjPrivate.h: Added.
23
        * bindings/scripts/test/JS/JSTestJSONObj.cpp: Added.
24
        * bindings/scripts/test/JS/JSTestJSONObj.h: Added.
25
        * bindings/scripts/test/ObjC/DOMTestJSONObj.h: Added.
26
        * bindings/scripts/test/ObjC/DOMTestJSONObj.mm: Added.
27
        * bindings/scripts/test/ObjC/DOMTestJSONObjInternal.h: Added.
28
        * bindings/scripts/test/TestJSONObj.idl: Added.
29
        * bindings/scripts/test/V8/V8TestJSONObj.cpp: Added.
30
        * bindings/scripts/test/V8/V8TestJSONObj.h: Added.
31
        * bindings/scripts/test/V8/V8TestObj.cpp:
32
        (WebCore::TestObjInternal::methodWithAllowJSONCallback):
33
1
2010-09-09  Kinuko Yasuda  <kinuko@chromium.org>
34
2010-09-09  Kinuko Yasuda  <kinuko@chromium.org>
2
35
3
        Reviewed by Dumitru Daniliuc.
36
        Reviewed by Dumitru Daniliuc.
- a/WebCore/bindings/scripts/CodeGeneratorJS.pm -3 / +42 lines
Lines 227-232 sub GetCallbackClassName a/WebCore/bindings/scripts/CodeGeneratorJS.pm_sec1
227
    return "JS$className";
227
    return "JS$className";
228
}
228
}
229
229
230
# Returns signatures of read-write attributes for a given object.
231
# This subroutine is called for parameters that are annotated with "AllowJSON".
232
sub GetAttributesForJSONObject
233
{
234
    my $type = shift;
235
236
    my $parsed = $codeGenerator->ParseInterface($type);
237
    my @attributesArray = ();
238
    foreach my $attribute (@{$parsed->attributes}) {
239
        push(@attributesArray, $attribute) if ($attribute->type !~ /^readonly/);
240
    }
241
    return @attributesArray;
242
}
243
230
sub AvoidInclusionOfType
244
sub AvoidInclusionOfType
231
{
245
{
232
    my $type = shift;
246
    my $type = shift;
Lines 1968-1978 sub GenerateImplementation a/WebCore/bindings/scripts/CodeGeneratorJS.pm_sec2
1968
                                push(@implContent, "    RefPtr<" . $parameter->type . "> $name = ${callbackClassName}::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n");
1982
                                push(@implContent, "    RefPtr<" . $parameter->type . "> $name = ${callbackClassName}::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n");
1969
                            }
1983
                            }
1970
                        } else {
1984
                        } else {
1985
                            my $argValue = "exec->argument($argsIndex)";
1986
                            my $argType = $codeGenerator->StripModule($parameter->type);
1987
1971
                            # For functions with "StrictTypeChecking", if an input parameter's type does not match the signature,
1988
                            # For functions with "StrictTypeChecking", if an input parameter's type does not match the signature,
1972
                            # a TypeError is thrown instead of casting to null.
1989
                            # a TypeError is thrown instead of casting to null.
1973
                            if ($function->signature->extendedAttributes->{"StrictTypeChecking"}) {
1990
                            if ($function->signature->extendedAttributes->{"StrictTypeChecking"}) {
1974
                                my $argValue = "exec->argument($argsIndex)";
1975
                                my $argType = $codeGenerator->StripModule($parameter->type);
1976
                                if (!IsNativeType($argType)) {
1991
                                if (!IsNativeType($argType)) {
1977
                                    push(@implContent, "    if (exec->argumentCount() > $argsIndex && !${argValue}.isUndefinedOrNull() && !${argValue}.inherits(&JS${argType}::s_info))\n");
1992
                                    push(@implContent, "    if (exec->argumentCount() > $argsIndex && !${argValue}.isUndefinedOrNull() && !${argValue}.inherits(&JS${argType}::s_info))\n");
1978
                                    push(@implContent, "        return throwVMTypeError(exec);\n");
1993
                                    push(@implContent, "        return throwVMTypeError(exec);\n");
Lines 1982-1988 sub GenerateImplementation a/WebCore/bindings/scripts/CodeGeneratorJS.pm_sec3
1982
                                }
1997
                                }
1983
                            }
1998
                            }
1984
1999
1985
                            push(@implContent, "    " . GetNativeTypeFromSignature($parameter) . " $name = " . JSValueToNative($parameter, "exec->argument($argsIndex)") . ";\n");
2000
                            # For parameters with "AllowJSON", look for object properties and dynamically
2001
                            # create a desired type of instance.
2002
                            if (!IsNativeType($argType) && $parameter->extendedAttributes->{"AllowJSON"}) {
2003
                                my $parameterType = $parameter->type;
2004
                                $implIncludes{"$parameterType.h"} = 1;
2005
                                push(@implContent, "    RefPtr<$parameterType> $name;\n");
2006
                                push(@implContent, "    if (!$argValue.isNull() && !$argValue.isUndefined() && $argValue.isObject() && !${argValue}.inherits(&JS${argType}::s_info)) {\n");
2007
                                push(@implContent, "        JSObject* object = $argValue.getObject();\n");
2008
                                push(@implContent, "        $name = ${parameterType}::create();\n");
2009
2010
                                my @attributes = GetAttributesForJSONObject($parameterType);
2011
                                foreach my $attribute (@attributes) {
2012
                                    my $attrName = $attribute->signature->name;
2013
                                    my $jsVarName = "js" . $codeGenerator->WK_ucfirst($attrName);
2014
                                    my $setter = "set" . $codeGenerator->WK_ucfirst($attrName);
2015
                                    push(@implContent, "        JSValue $jsVarName = object->get(exec, Identifier(exec, \"$attrName\"));\n");
2016
                                    push(@implContent, "        if (!$jsVarName.isNull() && !$jsVarName.isUndefined())\n");
2017
                                    push(@implContent, "            $name->$setter(" . JSValueToNative($attribute->signature, $jsVarName) . ");\n");
2018
                                }
2019
                                push(@implContent, "    } else {\n");
2020
                                push(@implContent, "        $name = adoptRef(" . JSValueToNative($parameter, $argValue) . ");\n");
2021
                                push(@implContent, "    }\n");
2022
                            } else {
2023
                                push(@implContent, "    " . GetNativeTypeFromSignature($parameter) . " $name = " . JSValueToNative($parameter, "exec->argument($argsIndex)") . ";\n");
2024
                            }
1986
2025
1987
                            # If a parameter is "an index" and it's negative it should throw an INDEX_SIZE_ERR exception.
2026
                            # If a parameter is "an index" and it's negative it should throw an INDEX_SIZE_ERR exception.
1988
                            # But this needs to be done in the bindings, because the type is unsigned and the fact that it
2027
                            # But this needs to be done in the bindings, because the type is unsigned and the fact that it
- a/WebCore/bindings/scripts/CodeGeneratorV8.pm -4 / +54 lines
Lines 1323-1333 END a/WebCore/bindings/scripts/CodeGeneratorV8.pm_sec1
1323
            push(@implContentDecls, "    " . ConvertToV8Parameter($parameter, $nativeType, $parameterName, $value) . "\n");
1323
            push(@implContentDecls, "    " . ConvertToV8Parameter($parameter, $nativeType, $parameterName, $value) . "\n");
1324
        } else {
1324
        } else {
1325
            $implIncludes{"V8BindingMacros.h"} = 1;
1325
            $implIncludes{"V8BindingMacros.h"} = 1;
1326
            my $argValue = "args[$paramIndex]";
1327
            my $argType = GetTypeFromSignature($parameter);
1326
            # For functions with "StrictTypeChecking", if an input parameter's type does not match the signature,
1328
            # For functions with "StrictTypeChecking", if an input parameter's type does not match the signature,
1327
            # a TypeError is thrown instead of casting to null.
1329
            # a TypeError is thrown instead of casting to null.
1328
            if ($function->signature->extendedAttributes->{"StrictTypeChecking"}) {
1330
            if ($function->signature->extendedAttributes->{"StrictTypeChecking"}) {
1329
                my $argValue = "args[$paramIndex]";
1330
                my $argType = GetTypeFromSignature($parameter);
1331
                if (IsWrapperType($argType)) {
1331
                if (IsWrapperType($argType)) {
1332
                    push(@implContentDecls, "    if (args.Length() > $paramIndex && !isUndefinedOrNull($argValue) && !V8${argType}::HasInstance($argValue)) {\n");
1332
                    push(@implContentDecls, "    if (args.Length() > $paramIndex && !isUndefinedOrNull($argValue) && !V8${argType}::HasInstance($argValue)) {\n");
1333
                    push(@implContentDecls, "        V8Proxy::throwTypeError();\n");
1333
                    push(@implContentDecls, "        V8Proxy::throwTypeError();\n");
Lines 1340-1347 END a/WebCore/bindings/scripts/CodeGeneratorV8.pm_sec2
1340
                    push(@implContentDecls, "    }\n");
1340
                    push(@implContentDecls, "    }\n");
1341
                }
1341
                }
1342
            }
1342
            }
1343
            push(@implContentDecls, "    EXCEPTION_BLOCK($nativeType, $parameterName, " .
1343
1344
                 JSValueToNative($parameter, "args[$paramIndex]", BasicTypeCanFailConversion($parameter) ?  "${parameterName}Ok" : undef) . ");\n");
1344
            # For parameters with "AllowJSON", look for object properties and dynamically
1345
            # create a desired type of instance.
1346
            if (IsWrapperType($argType) && $parameter->extendedAttributes->{"AllowJSON"}) {
1347
                my $parameterType = $parameter->type;
1348
                $implIncludes{"$parameterType.h"} = 1;
1349
                push(@implContentDecls, "    RefPtr<$parameterType> $parameterName;\n");
1350
                push(@implContentDecls, "    if (!isUndefinedOrNull($argValue) && $argValue->IsObject() && !V8${argType}::HasInstance($argValue)) {\n");
1351
                push(@implContentDecls, "        EXCEPTION_BLOCK(v8::Handle<v8::Object>, object, v8::Handle<v8::Object>::Cast(args[$paramIndex]));\n");
1352
                push(@implContentDecls, "        $parameterName = ${parameterType}::create();\n");
1353
1354
                my @attributes = GetAttributesForJSONObject($parameterType);
1355
                foreach my $attribute (@attributes) {
1356
                    my $attrName = $attribute->signature->name;
1357
                    my $varName = $codeGenerator->WK_lcfirst($attrName);
1358
                    my $jsVarName = "v8" . $codeGenerator->WK_ucfirst($attrName);
1359
                    my $setter = "set" . $codeGenerator->WK_ucfirst($attrName);
1360
                    my $varType = $attribute->signature->type;
1361
                    push(@implContentDecls, "        v8::Local<v8::Value> $jsVarName = object->Get(v8::String::New(\"$attrName\"));\n");
1362
                    push(@implContentDecls, "        if (!$jsVarName.IsEmpty() && !isUndefinedOrNull($jsVarName)) {\n");
1363
                    my $varNativeType = GetNativeTypeFromSignature($attribute->signature, 1);
1364
                    if ($varNativeType =~ /^V8Parameter/) {
1365
                        push(@implContentDecls, "            " . ConvertToV8Parameter($attribute->signature, $varNativeType, $varName, JSValueToNative($attribute->signature, $jsVarName)) . "\n");
1366
                    } else {
1367
                        push(@implContentDecls, "            EXCEPTION_BLOCK($varNativeType, $varName, " . JSValueToNative($attribute->signature, $jsVarName) . ");\n");
1368
                    }
1369
                    push(@implContentDecls, "            $parameterName->$setter($varName);\n");
1370
                    push(@implContentDecls, "        }\n");
1371
                }
1372
                push(@implContentDecls, "    } else {\n");
1373
                push(@implContentDecls, "       EXCEPTION_BLOCK($nativeType, tmp_$parameterName, " .
1374
                        JSValueToNative($parameter, "args[$paramIndex]", BasicTypeCanFailConversion($parameter) ?  "${parameterName}Ok" : undef) . ");\n");
1375
                push(@implContentDecls, "       $parameterName = adoptRef(tmp_$parameterName);\n");
1376
                push(@implContentDecls, "    }\n");
1377
            } else {
1378
                push(@implContentDecls, "    EXCEPTION_BLOCK($nativeType, $parameterName, " .
1379
                    JSValueToNative($parameter, "args[$paramIndex]", BasicTypeCanFailConversion($parameter) ?  "${parameterName}Ok" : undef) . ");\n");
1380
            }
1345
        }
1381
        }
1346
1382
1347
        if ($parameter->extendedAttributes->{"IsIndex"}) {
1383
        if ($parameter->extendedAttributes->{"IsIndex"}) {
Lines 2557-2562 sub IsActiveDomType a/WebCore/bindings/scripts/CodeGeneratorV8.pm_sec3
2557
    return 0;
2593
    return 0;
2558
}
2594
}
2559
2595
2596
# Returns signatures of read-write attributes for a given object.
2597
# This subroutine is called for parameters that are annotated with "AllowJSON".
2598
sub GetAttributesForJSONObject
2599
{
2600
    my $type = shift;
2601
2602
    my $parsed = $codeGenerator->ParseInterface($type);
2603
    my @attributesArray = ();
2604
    foreach my $attribute (@{$parsed->attributes}) {
2605
        push(@attributesArray, $attribute) if ($attribute->type !~ /^readonly/);
2606
    }
2607
    return @attributesArray;
2608
}
2609
2560
sub GetNativeTypeForConversions
2610
sub GetNativeTypeForConversions
2561
{
2611
{
2562
    my $type = shift;
2612
    my $type = shift;
- a/WebCore/bindings/scripts/test/CPP/WebDOMTestJSONObj.cpp +167 lines
Line 0 a/WebCore/bindings/scripts/test/CPP/WebDOMTestJSONObj.cpp_sec1
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
#include "WebDOMTestJSONObj.h"
23
24
#include "KURL.h"
25
#include "TestJSONObj.h"
26
#include "TestObj.h"
27
#include "WebDOMString.h"
28
#include "WebDOMTestObj.h"
29
#include "WebExceptionHandler.h"
30
#include "wtf/text/AtomicString.h"
31
#include <wtf/GetPtr.h>
32
#include <wtf/RefPtr.h>
33
34
struct WebDOMTestJSONObj::WebDOMTestJSONObjPrivate {
35
    WebDOMTestJSONObjPrivate(WebCore::TestJSONObj* object = 0)
36
        : impl(object)
37
    {
38
    }
39
40
    RefPtr<WebCore::TestJSONObj> impl;
41
};
42
43
WebDOMTestJSONObj::WebDOMTestJSONObj()
44
    : WebDOMObject()
45
    , m_impl(0)
46
{
47
}
48
49
WebDOMTestJSONObj::WebDOMTestJSONObj(WebCore::TestJSONObj* impl)
50
    : WebDOMObject()
51
    , m_impl(new WebDOMTestJSONObjPrivate(impl))
52
{
53
}
54
55
WebDOMTestJSONObj::WebDOMTestJSONObj(const WebDOMTestJSONObj& copy)
56
    : WebDOMObject()
57
{
58
    m_impl = copy.impl() ? new WebDOMTestJSONObjPrivate(copy.impl()) : 0;
59
}
60
61
WebDOMTestJSONObj& WebDOMTestJSONObj::operator=(const WebDOMTestJSONObj& copy)
62
{
63
    delete m_impl;
64
    m_impl = copy.impl() ? new WebDOMTestJSONObjPrivate(copy.impl()) : 0;
65
    return *this;
66
}
67
68
WebCore::TestJSONObj* WebDOMTestJSONObj::impl() const
69
{
70
    return m_impl ? m_impl->impl.get() : 0;
71
}
72
73
WebDOMTestJSONObj::~WebDOMTestJSONObj()
74
{
75
    delete m_impl;
76
    m_impl = 0;
77
}
78
79
int WebDOMTestJSONObj::intAttr() const
80
{
81
    if (!impl())
82
        return 0;
83
84
    return impl()->intAttr();
85
}
86
87
void WebDOMTestJSONObj::setIntAttr(int newIntAttr)
88
{
89
    if (!impl())
90
        return;
91
92
    impl()->setIntAttr(newIntAttr);
93
}
94
95
long long WebDOMTestJSONObj::longLongAttr() const
96
{
97
    if (!impl())
98
        return 0;
99
100
    return impl()->longLongAttr();
101
}
102
103
void WebDOMTestJSONObj::setLongLongAttr(long long newLongLongAttr)
104
{
105
    if (!impl())
106
        return;
107
108
    impl()->setLongLongAttr(newLongLongAttr);
109
}
110
111
unsigned long long WebDOMTestJSONObj::unsignedLongLongAttr() const
112
{
113
    if (!impl())
114
        return 0;
115
116
    return impl()->unsignedLongLongAttr();
117
}
118
119
void WebDOMTestJSONObj::setUnsignedLongLongAttr(unsigned long long newUnsignedLongLongAttr)
120
{
121
    if (!impl())
122
        return;
123
124
    impl()->setUnsignedLongLongAttr(newUnsignedLongLongAttr);
125
}
126
127
WebDOMString WebDOMTestJSONObj::stringAttr() const
128
{
129
    if (!impl())
130
        return WebDOMString();
131
132
    return static_cast<const WTF::String&>(impl()->stringAttr());
133
}
134
135
void WebDOMTestJSONObj::setStringAttr(const WebDOMString& newStringAttr)
136
{
137
    if (!impl())
138
        return;
139
140
    impl()->setStringAttr(newStringAttr);
141
}
142
143
WebDOMTestObj WebDOMTestJSONObj::testObjAttr() const
144
{
145
    if (!impl())
146
        return WebDOMTestObj();
147
148
    return toWebKit(WTF::getPtr(impl()->testObjAttr()));
149
}
150
151
void WebDOMTestJSONObj::setTestObjAttr(const WebDOMTestObj& newTestObjAttr)
152
{
153
    if (!impl())
154
        return;
155
156
    impl()->setTestObjAttr(toWebCore(newTestObjAttr));
157
}
158
159
WebCore::TestJSONObj* toWebCore(const WebDOMTestJSONObj& wrapper)
160
{
161
    return wrapper.impl();
162
}
163
164
WebDOMTestJSONObj toWebKit(WebCore::TestJSONObj* value)
165
{
166
    return WebDOMTestJSONObj(value);
167
}
- a/WebCore/bindings/scripts/test/CPP/WebDOMTestJSONObj.h +64 lines
Line 0 a/WebCore/bindings/scripts/test/CPP/WebDOMTestJSONObj.h_sec1
1
/*
2
 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3
 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
4
 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
5
 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
6
 *
7
 * This library is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Library General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2 of the License, or (at your option) any later version.
11
 *
12
 * This library is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Library General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Library General Public License
18
 * along with this library; see the file COPYING.LIB.  If not, write to
19
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20
 * Boston, MA 02110-1301, USA.
21
 */
22
23
#ifndef WebDOMTestJSONObj_h
24
#define WebDOMTestJSONObj_h
25
26
#include <WebDOMObject.h>
27
#include <WebDOMString.h>
28
29
namespace WebCore {
30
class TestJSONObj;
31
};
32
33
class WebDOMTestObj;
34
35
class WebDOMTestJSONObj : public WebDOMObject {
36
public:
37
    WebDOMTestJSONObj();
38
    explicit WebDOMTestJSONObj(WebCore::TestJSONObj*);
39
    WebDOMTestJSONObj(const WebDOMTestJSONObj&);
40
    WebDOMTestJSONObj& operator=(const WebDOMTestJSONObj&);
41
    virtual ~WebDOMTestJSONObj();
42
43
    int intAttr() const;
44
    void setIntAttr(int);
45
    long long longLongAttr() const;
46
    void setLongLongAttr(long long);
47
    unsigned long long unsignedLongLongAttr() const;
48
    void setUnsignedLongLongAttr(unsigned long long);
49
    WebDOMString stringAttr() const;
50
    void setStringAttr(const WebDOMString&);
51
    WebDOMTestObj testObjAttr() const;
52
    void setTestObjAttr(const WebDOMTestObj&);
53
54
    WebCore::TestJSONObj* impl() const;
55
56
protected:
57
    struct WebDOMTestJSONObjPrivate;
58
    WebDOMTestJSONObjPrivate* m_impl;
59
};
60
61
WebCore::TestJSONObj* toWebCore(const WebDOMTestJSONObj&);
62
WebDOMTestJSONObj toWebKit(WebCore::TestJSONObj*);
63
64
#endif
- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestJSONObj.cpp +344 lines
Line 0 a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestJSONObj.cpp_sec1
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 <glib-object.h>
22
#include "config.h"
23
24
#include <wtf/GetPtr.h>
25
#include <wtf/RefPtr.h>
26
#include "ExceptionCode.h"
27
#include "JSMainThreadExecState.h"
28
#include "TestJSONObj.h"
29
#include "TestObj.h"
30
#include "WebKitDOMBinding.h"
31
#include "gobject/ConvertToUTF8String.h"
32
#include "webkit/WebKitDOMTestJSONObj.h"
33
#include "webkit/WebKitDOMTestJSONObjPrivate.h"
34
#include "webkit/WebKitDOMTestObj.h"
35
#include "webkit/WebKitDOMTestObjPrivate.h"
36
#include "webkitmarshal.h"
37
#include "webkitprivate.h"
38
39
namespace WebKit {
40
    
41
gpointer kit(WebCore::TestJSONObj* obj)
42
{
43
    g_return_val_if_fail(obj, 0);
44
45
    if (gpointer ret = DOMObjectCache::get(obj))
46
        return ret;
47
48
    return DOMObjectCache::put(obj, WebKit::wrapTestJSONObj(obj));
49
}
50
    
51
} // namespace WebKit //
52
53
glong
54
webkit_dom_test_json_obj_get_int_attr(WebKitDOMTestJSONObj* self)
55
{
56
    WebCore::JSMainThreadNullState state;
57
    g_return_val_if_fail(self, 0);
58
    WebCore::TestJSONObj * item = WebKit::core(self);
59
    glong res = item->intAttr();
60
    return res;
61
}
62
63
void
64
webkit_dom_test_json_obj_set_int_attr(WebKitDOMTestJSONObj* self, glong value)
65
{
66
    WebCore::JSMainThreadNullState state;
67
    g_return_if_fail(self);
68
    WebCore::TestJSONObj * item = WebKit::core(self);
69
    item->setIntAttr(value);
70
}
71
72
gint64
73
webkit_dom_test_json_obj_get_long_long_attr(WebKitDOMTestJSONObj* self)
74
{
75
    WebCore::JSMainThreadNullState state;
76
    g_return_val_if_fail(self, 0);
77
    WebCore::TestJSONObj * item = WebKit::core(self);
78
    gint64 res = item->longLongAttr();
79
    return res;
80
}
81
82
void
83
webkit_dom_test_json_obj_set_long_long_attr(WebKitDOMTestJSONObj* self, gint64 value)
84
{
85
    WebCore::JSMainThreadNullState state;
86
    g_return_if_fail(self);
87
    WebCore::TestJSONObj * item = WebKit::core(self);
88
    item->setLongLongAttr(value);
89
}
90
91
guint64
92
webkit_dom_test_json_obj_get_unsigned_long_long_attr(WebKitDOMTestJSONObj* self)
93
{
94
    WebCore::JSMainThreadNullState state;
95
    g_return_val_if_fail(self, 0);
96
    WebCore::TestJSONObj * item = WebKit::core(self);
97
    guint64 res = item->unsignedLongLongAttr();
98
    return res;
99
}
100
101
void
102
webkit_dom_test_json_obj_set_unsigned_long_long_attr(WebKitDOMTestJSONObj* self, guint64 value)
103
{
104
    WebCore::JSMainThreadNullState state;
105
    g_return_if_fail(self);
106
    WebCore::TestJSONObj * item = WebKit::core(self);
107
    item->setUnsignedLongLongAttr(value);
108
}
109
110
gchar*
111
webkit_dom_test_json_obj_get_string_attr(WebKitDOMTestJSONObj* self)
112
{
113
    WebCore::JSMainThreadNullState state;
114
    g_return_val_if_fail(self, 0);
115
    WebCore::TestJSONObj * item = WebKit::core(self);
116
    gchar* res = convertToUTF8String(item->stringAttr());
117
    return res;
118
}
119
120
void
121
webkit_dom_test_json_obj_set_string_attr(WebKitDOMTestJSONObj* self, const gchar* value)
122
{
123
    WebCore::JSMainThreadNullState state;
124
    g_return_if_fail(self);
125
    WebCore::TestJSONObj * item = WebKit::core(self);
126
    g_return_if_fail(value);
127
    WTF::String converted_value = WTF::String::fromUTF8(value);
128
    item->setStringAttr(converted_value);
129
}
130
131
WebKitDOMTestObj*
132
webkit_dom_test_json_obj_get_test_obj_attr(WebKitDOMTestJSONObj* self)
133
{
134
    WebCore::JSMainThreadNullState state;
135
    g_return_val_if_fail(self, 0);
136
    WebCore::TestJSONObj * item = WebKit::core(self);
137
    PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->testObjAttr());
138
    WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj*>(WebKit::kit(g_res.get()));
139
    return res;
140
}
141
142
void
143
webkit_dom_test_json_obj_set_test_obj_attr(WebKitDOMTestJSONObj* self, WebKitDOMTestObj* value)
144
{
145
    WebCore::JSMainThreadNullState state;
146
    g_return_if_fail(self);
147
    WebCore::TestJSONObj * item = WebKit::core(self);
148
    g_return_if_fail(value);
149
    WebCore::TestObj * converted_value = NULL;
150
    if (value != NULL) {
151
        converted_value = WebKit::core(value);
152
        g_return_if_fail(converted_value);
153
    }
154
    item->setTestObjAttr(converted_value);
155
}
156
157
158
G_DEFINE_TYPE(WebKitDOMTestJSONObj, webkit_dom_test_json_obj, WEBKIT_TYPE_DOM_OBJECT)
159
160
namespace WebKit {
161
162
WebCore::TestJSONObj* core(WebKitDOMTestJSONObj* request)
163
{
164
    g_return_val_if_fail(request, 0);
165
166
    WebCore::TestJSONObj* coreObject = static_cast<WebCore::TestJSONObj*>(WEBKIT_DOM_OBJECT(request)->coreObject);
167
    g_return_val_if_fail(coreObject, 0);
168
169
    return coreObject;
170
}
171
172
} // namespace WebKit
173
enum {
174
    PROP_0,
175
    PROP_INT_ATTR,
176
    PROP_LONG_LONG_ATTR,
177
    PROP_UNSIGNED_LONG_LONG_ATTR,
178
    PROP_STRING_ATTR,
179
    PROP_TEST_OBJ_ATTR,
180
};
181
182
183
static void webkit_dom_test_json_obj_finalize(GObject* object)
184
{
185
    WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object);
186
    
187
    if (dom_object->coreObject) {
188
        WebCore::TestJSONObj* coreObject = static_cast<WebCore::TestJSONObj *>(dom_object->coreObject);
189
190
        WebKit::DOMObjectCache::forget(coreObject);
191
        coreObject->deref();
192
193
        dom_object->coreObject = NULL;
194
    }
195
196
    G_OBJECT_CLASS(webkit_dom_test_json_obj_parent_class)->finalize(object);
197
}
198
199
static void webkit_dom_test_json_obj_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec)
200
{
201
    WebCore::JSMainThreadNullState state;
202
    WebKitDOMTestJSONObj* self = WEBKIT_DOM_TEST_JSON_OBJ(object);
203
    WebCore::TestJSONObj* coreSelf = WebKit::core(self);
204
    switch (prop_id) {
205
    case PROP_INT_ATTR:
206
    {
207
        coreSelf->setIntAttr((g_value_get_long(value)));
208
        break;
209
    }
210
    case PROP_UNSIGNED_LONG_LONG_ATTR:
211
    {
212
        coreSelf->setUnsignedLongLongAttr((g_value_get_uint64(value)));
213
        break;
214
    }
215
    case PROP_STRING_ATTR:
216
    {
217
        coreSelf->setStringAttr(WTF::String::fromUTF8(g_value_get_string(value)));
218
        break;
219
    }
220
    default:
221
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
222
        break;
223
    }
224
}
225
226
227
static void webkit_dom_test_json_obj_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
228
{
229
    WebCore::JSMainThreadNullState state;
230
    WebKitDOMTestJSONObj* self = WEBKIT_DOM_TEST_JSON_OBJ(object);
231
    WebCore::TestJSONObj* coreSelf = WebKit::core(self);
232
    switch (prop_id) {
233
    case PROP_INT_ATTR:
234
    {
235
        g_value_set_long(value, coreSelf->intAttr());
236
        break;
237
    }
238
    case PROP_LONG_LONG_ATTR:
239
    {
240
        g_value_set_int64(value, coreSelf->longLongAttr());
241
        break;
242
    }
243
    case PROP_UNSIGNED_LONG_LONG_ATTR:
244
    {
245
        g_value_set_uint64(value, coreSelf->unsignedLongLongAttr());
246
        break;
247
    }
248
    case PROP_STRING_ATTR:
249
    {
250
        g_value_take_string(value, convertToUTF8String(coreSelf->stringAttr()));
251
        break;
252
    }
253
    case PROP_TEST_OBJ_ATTR:
254
    {
255
        RefPtr<WebCore::TestObj> ptr = coreSelf->testObjAttr();
256
        g_value_set_object(value, WebKit::kit(ptr.get()));
257
        break;
258
    }
259
    default:
260
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
261
        break;
262
    }
263
}
264
265
266
static void webkit_dom_test_json_obj_constructed(GObject* object)
267
{
268
269
    if (G_OBJECT_CLASS(webkit_dom_test_json_obj_parent_class)->constructed)
270
        G_OBJECT_CLASS(webkit_dom_test_json_obj_parent_class)->constructed(object);
271
}
272
273
static void webkit_dom_test_json_obj_class_init(WebKitDOMTestJSONObjClass* requestClass)
274
{
275
    GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass);
276
    gobjectClass->finalize = webkit_dom_test_json_obj_finalize;
277
    gobjectClass->set_property = webkit_dom_test_json_obj_set_property;
278
    gobjectClass->get_property = webkit_dom_test_json_obj_get_property;
279
    gobjectClass->constructed = webkit_dom_test_json_obj_constructed;
280
281
    g_object_class_install_property(gobjectClass,
282
                                    PROP_INT_ATTR,
283
                                    g_param_spec_long("int-attr", /* name */
284
                                                           "test_json_obj_int-attr", /* short description */
285
                                                           "read-write  glong TestJSONObj.int-attr", /* longer - could do with some extra doc stuff here */
286
                                                           G_MINLONG, /* min */
287
G_MAXLONG, /* max */
288
0, /* default */
289
                                                           WEBKIT_PARAM_READWRITE));
290
    g_object_class_install_property(gobjectClass,
291
                                    PROP_LONG_LONG_ATTR,
292
                                    g_param_spec_int64("long-long-attr", /* name */
293
                                                           "test_json_obj_long-long-attr", /* short description */
294
                                                           "read-write  gint64 TestJSONObj.long-long-attr", /* longer - could do with some extra doc stuff here */
295
                                                           G_MININT64, /* min */
296
G_MAXINT64, /* max */
297
0, /* default */
298
                                                           WEBKIT_PARAM_READWRITE));
299
    g_object_class_install_property(gobjectClass,
300
                                    PROP_UNSIGNED_LONG_LONG_ATTR,
301
                                    g_param_spec_uint64("unsigned-long-long-attr", /* name */
302
                                                           "test_json_obj_unsigned-long-long-attr", /* short description */
303
                                                           "read-write  guint64 TestJSONObj.unsigned-long-long-attr", /* longer - could do with some extra doc stuff here */
304
                                                           0, /* min */
305
G_MAXUINT64, /* min */
306
0, /* default */
307
                                                           WEBKIT_PARAM_READWRITE));
308
    g_object_class_install_property(gobjectClass,
309
                                    PROP_STRING_ATTR,
310
                                    g_param_spec_string("string-attr", /* name */
311
                                                           "test_json_obj_string-attr", /* short description */
312
                                                           "read-write  gchar* TestJSONObj.string-attr", /* longer - could do with some extra doc stuff here */
313
                                                           "", /* default */
314
                                                           WEBKIT_PARAM_READWRITE));
315
    g_object_class_install_property(gobjectClass,
316
                                    PROP_TEST_OBJ_ATTR,
317
                                    g_param_spec_object("test-obj-attr", /* name */
318
                                                           "test_json_obj_test-obj-attr", /* short description */
319
                                                           "read-write  WebKitDOMTestObj* TestJSONObj.test-obj-attr", /* longer - could do with some extra doc stuff here */
320
                                                           WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */
321
                                                           WEBKIT_PARAM_READWRITE));
322
323
324
}
325
326
static void webkit_dom_test_json_obj_init(WebKitDOMTestJSONObj* request)
327
{
328
}
329
330
namespace WebKit {
331
WebKitDOMTestJSONObj* wrapTestJSONObj(WebCore::TestJSONObj* coreObject)
332
{
333
    g_return_val_if_fail(coreObject, 0);
334
335
    /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object
336
     * in a C-allocated GObject structure.  See the finalize() code for the
337
     * matching deref().
338
     */
339
    coreObject->ref();
340
341
    return  WEBKIT_DOM_TEST_JSON_OBJ(g_object_new(WEBKIT_TYPE_DOM_TEST_JSON_OBJ,
342
                                               "core-object", coreObject, NULL));
343
}
344
} // namespace WebKit
- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestJSONObj.h +81 lines
Line 0 a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestJSONObj.h_sec1
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
#ifndef WebKitDOMTestJSONObj_h
22
#define WebKitDOMTestJSONObj_h
23
24
#include "webkit/webkitdomdefines.h"
25
#include <glib-object.h>
26
#include <webkit/webkitdefines.h>
27
#include "webkit/WebKitDOMObject.h"
28
29
30
G_BEGIN_DECLS
31
#define WEBKIT_TYPE_DOM_TEST_JSON_OBJ            (webkit_dom_test_json_obj_get_type())
32
#define WEBKIT_DOM_TEST_JSON_OBJ(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_TEST_JSON_OBJ, WebKitDOMTestJSONObj))
33
#define WEBKIT_DOM_TEST_JSON_OBJ_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_DOM_TEST_JSON_OBJ, WebKitDOMTestJSONObjClass)
34
#define WEBKIT_DOM_IS_TEST_JSON_OBJ(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DOM_TEST_JSON_OBJ))
35
#define WEBKIT_DOM_IS_TEST_JSON_OBJ_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_DOM_TEST_JSON_OBJ))
36
#define WEBKIT_DOM_TEST_JSON_OBJ_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_DOM_TEST_JSON_OBJ, WebKitDOMTestJSONObjClass))
37
38
struct _WebKitDOMTestJSONObj {
39
    WebKitDOMObject parent_instance;
40
};
41
42
struct _WebKitDOMTestJSONObjClass {
43
    WebKitDOMObjectClass parent_class;
44
};
45
46
WEBKIT_API GType
47
webkit_dom_test_json_obj_get_type (void);
48
49
WEBKIT_API glong
50
webkit_dom_test_json_obj_get_int_attr(WebKitDOMTestJSONObj* self);
51
52
WEBKIT_API void
53
webkit_dom_test_json_obj_set_int_attr(WebKitDOMTestJSONObj* self, glong value);
54
55
WEBKIT_API gint64
56
webkit_dom_test_json_obj_get_long_long_attr(WebKitDOMTestJSONObj* self);
57
58
WEBKIT_API void
59
webkit_dom_test_json_obj_set_long_long_attr(WebKitDOMTestJSONObj* self, gint64 value);
60
61
WEBKIT_API guint64
62
webkit_dom_test_json_obj_get_unsigned_long_long_attr(WebKitDOMTestJSONObj* self);
63
64
WEBKIT_API void
65
webkit_dom_test_json_obj_set_unsigned_long_long_attr(WebKitDOMTestJSONObj* self, guint64 value);
66
67
WEBKIT_API gchar*
68
webkit_dom_test_json_obj_get_string_attr(WebKitDOMTestJSONObj* self);
69
70
WEBKIT_API void
71
webkit_dom_test_json_obj_set_string_attr(WebKitDOMTestJSONObj* self, const gchar* value);
72
73
WEBKIT_API WebKitDOMTestObj*
74
webkit_dom_test_json_obj_get_test_obj_attr(WebKitDOMTestJSONObj* self);
75
76
WEBKIT_API void
77
webkit_dom_test_json_obj_set_test_obj_attr(WebKitDOMTestJSONObj* self, WebKitDOMTestObj* value);
78
79
G_END_DECLS
80
81
#endif /* WebKitDOMTestJSONObj_h */
- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestJSONObjPrivate.h +39 lines
Line 0 a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestJSONObjPrivate.h_sec1
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
#ifndef WEB_KIT_DOM_TEST_JSON_OBJ_PRIVATE_H
22
#define WEB_KIT_DOM_TEST_JSON_OBJ_PRIVATE_H
23
24
#include <glib-object.h>
25
#include <webkit/WebKitDOMObject.h>
26
#include "TestJSONObj.h"
27
namespace WebKit {
28
    WebKitDOMTestJSONObj *
29
    wrapTestJSONObj(WebCore::TestJSONObj *coreObject);
30
31
    WebCore::TestJSONObj *
32
    core(WebKitDOMTestJSONObj *request);
33
34
    gpointer
35
    kit(WebCore::TestJSONObj* node);
36
37
} // namespace WebKit
38
39
#endif /* WEB_KIT_DOM_TEST_JSON_OBJ_PRIVATE_H */
- a/WebCore/bindings/scripts/test/JS/JSTestJSONObj.cpp +259 lines
Line 0 a/WebCore/bindings/scripts/test/JS/JSTestJSONObj.cpp_sec1
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
#include "JSTestJSONObj.h"
23
24
#include "JSTestObj.h"
25
#include "KURL.h"
26
#include "TestJSONObj.h"
27
#include "TestObj.h"
28
#include <runtime/JSNumberCell.h>
29
#include <runtime/JSString.h>
30
#include <wtf/GetPtr.h>
31
32
using namespace JSC;
33
34
namespace WebCore {
35
36
ASSERT_CLASS_FITS_IN_CELL(JSTestJSONObj);
37
38
/* Hash table */
39
#if ENABLE(JIT)
40
#define THUNK_GENERATOR(generator) , generator
41
#else
42
#define THUNK_GENERATOR(generator)
43
#endif
44
45
static const HashTableValue JSTestJSONObjTableValues[7] =
46
{
47
    { "intAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestJSONObjIntAttr), (intptr_t)setJSTestJSONObjIntAttr THUNK_GENERATOR(0) },
48
    { "longLongAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestJSONObjLongLongAttr), (intptr_t)setJSTestJSONObjLongLongAttr THUNK_GENERATOR(0) },
49
    { "unsignedLongLongAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestJSONObjUnsignedLongLongAttr), (intptr_t)setJSTestJSONObjUnsignedLongLongAttr THUNK_GENERATOR(0) },
50
    { "stringAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestJSONObjStringAttr), (intptr_t)setJSTestJSONObjStringAttr THUNK_GENERATOR(0) },
51
    { "testObjAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestJSONObjTestObjAttr), (intptr_t)setJSTestJSONObjTestObjAttr THUNK_GENERATOR(0) },
52
    { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestJSONObjConstructor), (intptr_t)0 THUNK_GENERATOR(0) },
53
    { 0, 0, 0, 0 THUNK_GENERATOR(0) }
54
};
55
56
#undef THUNK_GENERATOR
57
static JSC_CONST_HASHTABLE HashTable JSTestJSONObjTable = { 16, 15, JSTestJSONObjTableValues, 0 };
58
/* Hash table for constructor */
59
#if ENABLE(JIT)
60
#define THUNK_GENERATOR(generator) , generator
61
#else
62
#define THUNK_GENERATOR(generator)
63
#endif
64
65
static const HashTableValue JSTestJSONObjConstructorTableValues[1] =
66
{
67
    { 0, 0, 0, 0 THUNK_GENERATOR(0) }
68
};
69
70
#undef THUNK_GENERATOR
71
static JSC_CONST_HASHTABLE HashTable JSTestJSONObjConstructorTable = { 1, 0, JSTestJSONObjConstructorTableValues, 0 };
72
class JSTestJSONObjConstructor : public DOMConstructorObject {
73
public:
74
    JSTestJSONObjConstructor(JSC::ExecState*, JSDOMGlobalObject*);
75
76
    virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);
77
    virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);
78
    virtual const JSC::ClassInfo* classInfo() const { return &s_info; }
79
    static const JSC::ClassInfo s_info;
80
    static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)
81
    {
82
        return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);
83
    }
84
protected:
85
    static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags;
86
};
87
88
const ClassInfo JSTestJSONObjConstructor::s_info = { "TestJSONObjConstructor", 0, &JSTestJSONObjConstructorTable, 0 };
89
90
JSTestJSONObjConstructor::JSTestJSONObjConstructor(ExecState* exec, JSDOMGlobalObject* globalObject)
91
    : DOMConstructorObject(JSTestJSONObjConstructor::createStructure(globalObject->objectPrototype()), globalObject)
92
{
93
    putDirect(exec->propertyNames().prototype, JSTestJSONObjPrototype::self(exec, globalObject), DontDelete | ReadOnly);
94
}
95
96
bool JSTestJSONObjConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
97
{
98
    return getStaticValueSlot<JSTestJSONObjConstructor, DOMObject>(exec, &JSTestJSONObjConstructorTable, this, propertyName, slot);
99
}
100
101
bool JSTestJSONObjConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
102
{
103
    return getStaticValueDescriptor<JSTestJSONObjConstructor, DOMObject>(exec, &JSTestJSONObjConstructorTable, this, propertyName, descriptor);
104
}
105
106
/* Hash table for prototype */
107
#if ENABLE(JIT)
108
#define THUNK_GENERATOR(generator) , generator
109
#else
110
#define THUNK_GENERATOR(generator)
111
#endif
112
113
static const HashTableValue JSTestJSONObjPrototypeTableValues[1] =
114
{
115
    { 0, 0, 0, 0 THUNK_GENERATOR(0) }
116
};
117
118
#undef THUNK_GENERATOR
119
static JSC_CONST_HASHTABLE HashTable JSTestJSONObjPrototypeTable = { 1, 0, JSTestJSONObjPrototypeTableValues, 0 };
120
const ClassInfo JSTestJSONObjPrototype::s_info = { "TestJSONObjPrototype", 0, &JSTestJSONObjPrototypeTable, 0 };
121
122
JSObject* JSTestJSONObjPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
123
{
124
    return getDOMPrototype<JSTestJSONObj>(exec, globalObject);
125
}
126
127
const ClassInfo JSTestJSONObj::s_info = { "TestJSONObj", 0, &JSTestJSONObjTable, 0 };
128
129
JSTestJSONObj::JSTestJSONObj(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestJSONObj> impl)
130
    : DOMObjectWithGlobalPointer(structure, globalObject)
131
    , m_impl(impl)
132
{
133
}
134
135
JSTestJSONObj::~JSTestJSONObj()
136
{
137
    forgetDOMObject(this, impl());
138
}
139
140
JSObject* JSTestJSONObj::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
141
{
142
    return new (exec) JSTestJSONObjPrototype(globalObject, JSTestJSONObjPrototype::createStructure(globalObject->objectPrototype()));
143
}
144
145
bool JSTestJSONObj::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
146
{
147
    return getStaticValueSlot<JSTestJSONObj, Base>(exec, &JSTestJSONObjTable, this, propertyName, slot);
148
}
149
150
bool JSTestJSONObj::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
151
{
152
    return getStaticValueDescriptor<JSTestJSONObj, Base>(exec, &JSTestJSONObjTable, this, propertyName, descriptor);
153
}
154
155
JSValue jsTestJSONObjIntAttr(ExecState* exec, JSValue slotBase, const Identifier&)
156
{
157
    JSTestJSONObj* castedThis = static_cast<JSTestJSONObj*>(asObject(slotBase));
158
    UNUSED_PARAM(exec);
159
    TestJSONObj* imp = static_cast<TestJSONObj*>(castedThis->impl());
160
    JSValue result = jsNumber(exec, imp->intAttr());
161
    return result;
162
}
163
164
JSValue jsTestJSONObjLongLongAttr(ExecState* exec, JSValue slotBase, const Identifier&)
165
{
166
    JSTestJSONObj* castedThis = static_cast<JSTestJSONObj*>(asObject(slotBase));
167
    UNUSED_PARAM(exec);
168
    TestJSONObj* imp = static_cast<TestJSONObj*>(castedThis->impl());
169
    JSValue result = jsNumber(exec, imp->longLongAttr());
170
    return result;
171
}
172
173
JSValue jsTestJSONObjUnsignedLongLongAttr(ExecState* exec, JSValue slotBase, const Identifier&)
174
{
175
    JSTestJSONObj* castedThis = static_cast<JSTestJSONObj*>(asObject(slotBase));
176
    UNUSED_PARAM(exec);
177
    TestJSONObj* imp = static_cast<TestJSONObj*>(castedThis->impl());
178
    JSValue result = jsNumber(exec, imp->unsignedLongLongAttr());
179
    return result;
180
}
181
182
JSValue jsTestJSONObjStringAttr(ExecState* exec, JSValue slotBase, const Identifier&)
183
{
184
    JSTestJSONObj* castedThis = static_cast<JSTestJSONObj*>(asObject(slotBase));
185
    UNUSED_PARAM(exec);
186
    TestJSONObj* imp = static_cast<TestJSONObj*>(castedThis->impl());
187
    JSValue result = jsString(exec, imp->stringAttr());
188
    return result;
189
}
190
191
JSValue jsTestJSONObjTestObjAttr(ExecState* exec, JSValue slotBase, const Identifier&)
192
{
193
    JSTestJSONObj* castedThis = static_cast<JSTestJSONObj*>(asObject(slotBase));
194
    UNUSED_PARAM(exec);
195
    TestJSONObj* imp = static_cast<TestJSONObj*>(castedThis->impl());
196
    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->testObjAttr()));
197
    return result;
198
}
199
200
JSValue jsTestJSONObjConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
201
{
202
    JSTestJSONObj* domObject = static_cast<JSTestJSONObj*>(asObject(slotBase));
203
    return JSTestJSONObj::getConstructor(exec, domObject->globalObject());
204
}
205
void JSTestJSONObj::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
206
{
207
    lookupPut<JSTestJSONObj, Base>(exec, propertyName, value, &JSTestJSONObjTable, this, slot);
208
}
209
210
void setJSTestJSONObjIntAttr(ExecState* exec, JSObject* thisObject, JSValue value)
211
{
212
    JSTestJSONObj* castedThis = static_cast<JSTestJSONObj*>(thisObject);
213
    TestJSONObj* imp = static_cast<TestJSONObj*>(castedThis->impl());
214
    imp->setIntAttr(value.toInt32(exec));
215
}
216
217
void setJSTestJSONObjLongLongAttr(ExecState* exec, JSObject* thisObject, JSValue value)
218
{
219
    JSTestJSONObj* castedThis = static_cast<JSTestJSONObj*>(thisObject);
220
    TestJSONObj* imp = static_cast<TestJSONObj*>(castedThis->impl());
221
    imp->setLongLongAttr(static_cast<long long>(value.toInteger(exec)));
222
}
223
224
void setJSTestJSONObjUnsignedLongLongAttr(ExecState* exec, JSObject* thisObject, JSValue value)
225
{
226
    JSTestJSONObj* castedThis = static_cast<JSTestJSONObj*>(thisObject);
227
    TestJSONObj* imp = static_cast<TestJSONObj*>(castedThis->impl());
228
    imp->setUnsignedLongLongAttr(static_cast<unsigned long long>(value.toInteger(exec)));
229
}
230
231
void setJSTestJSONObjStringAttr(ExecState* exec, JSObject* thisObject, JSValue value)
232
{
233
    JSTestJSONObj* castedThis = static_cast<JSTestJSONObj*>(thisObject);
234
    TestJSONObj* imp = static_cast<TestJSONObj*>(castedThis->impl());
235
    imp->setStringAttr(ustringToString(value.toString(exec)));
236
}
237
238
void setJSTestJSONObjTestObjAttr(ExecState* exec, JSObject* thisObject, JSValue value)
239
{
240
    JSTestJSONObj* castedThis = static_cast<JSTestJSONObj*>(thisObject);
241
    TestJSONObj* imp = static_cast<TestJSONObj*>(castedThis->impl());
242
    imp->setTestObjAttr(toTestObj(value));
243
}
244
245
JSValue JSTestJSONObj::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
246
{
247
    return getDOMConstructor<JSTestJSONObjConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
248
}
249
250
JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestJSONObj* object)
251
{
252
    return getDOMObjectWrapper<JSTestJSONObj>(exec, globalObject, object);
253
}
254
TestJSONObj* toTestJSONObj(JSC::JSValue value)
255
{
256
    return value.inherits(&JSTestJSONObj::s_info) ? static_cast<JSTestJSONObj*>(asObject(value))->impl() : 0;
257
}
258
259
}
- a/WebCore/bindings/scripts/test/JS/JSTestJSONObj.h +93 lines
Line 0 a/WebCore/bindings/scripts/test/JS/JSTestJSONObj.h_sec1
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
#ifndef JSTestJSONObj_h
22
#define JSTestJSONObj_h
23
24
#include "JSDOMBinding.h"
25
#include <runtime/JSGlobalObject.h>
26
#include <runtime/JSObjectWithGlobalObject.h>
27
#include <runtime/ObjectPrototype.h>
28
29
namespace WebCore {
30
31
class TestJSONObj;
32
33
class JSTestJSONObj : public DOMObjectWithGlobalPointer {
34
    typedef DOMObjectWithGlobalPointer Base;
35
public:
36
    JSTestJSONObj(NonNullPassRefPtr<JSC::Structure>, JSDOMGlobalObject*, PassRefPtr<TestJSONObj>);
37
    virtual ~JSTestJSONObj();
38
    static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*);
39
    virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&);
40
    virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&);
41
    virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&);
42
    virtual const JSC::ClassInfo* classInfo() const { return &s_info; }
43
    static const JSC::ClassInfo s_info;
44
45
    static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)
46
    {
47
        return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);
48
    }
49
50
    static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*);
51
    TestJSONObj* impl() const { return m_impl.get(); }
52
53
private:
54
    RefPtr<TestJSONObj> m_impl;
55
protected:
56
    static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags;
57
};
58
59
JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestJSONObj*);
60
TestJSONObj* toTestJSONObj(JSC::JSValue);
61
62
class JSTestJSONObjPrototype : public JSC::JSObjectWithGlobalObject {
63
    typedef JSC::JSObjectWithGlobalObject Base;
64
public:
65
    static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*);
66
    virtual const JSC::ClassInfo* classInfo() const { return &s_info; }
67
    static const JSC::ClassInfo s_info;
68
    static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)
69
    {
70
        return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);
71
    }
72
    JSTestJSONObjPrototype(JSC::JSGlobalObject* globalObject, NonNullPassRefPtr<JSC::Structure> structure) : JSC::JSObjectWithGlobalObject(globalObject, structure) { }
73
protected:
74
    static const unsigned StructureFlags = Base::StructureFlags;
75
};
76
77
// Attributes
78
79
JSC::JSValue jsTestJSONObjIntAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
80
void setJSTestJSONObjIntAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);
81
JSC::JSValue jsTestJSONObjLongLongAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
82
void setJSTestJSONObjLongLongAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);
83
JSC::JSValue jsTestJSONObjUnsignedLongLongAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
84
void setJSTestJSONObjUnsignedLongLongAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);
85
JSC::JSValue jsTestJSONObjStringAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
86
void setJSTestJSONObjStringAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);
87
JSC::JSValue jsTestJSONObjTestObjAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
88
void setJSTestJSONObjTestObjAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);
89
JSC::JSValue jsTestJSONObjConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
90
91
} // namespace WebCore
92
93
#endif
- a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp -1 / +40 lines
Lines 28-38 a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp_sec1
28
#include "JSDOMBinding.h"
28
#include "JSDOMBinding.h"
29
#include "JSEventListener.h"
29
#include "JSEventListener.h"
30
#include "JSTestCallback.h"
30
#include "JSTestCallback.h"
31
#include "JSTestJSONObj.h"
31
#include "JSTestObj.h"
32
#include "JSTestObj.h"
32
#include "JSlog.h"
33
#include "JSlog.h"
33
#include "KURL.h"
34
#include "KURL.h"
34
#include "ScriptCallStack.h"
35
#include "ScriptCallStack.h"
35
#include "SerializedScriptValue.h"
36
#include "SerializedScriptValue.h"
37
#include "TestJSONObj.h"
36
#include "TestObj.h"
38
#include "TestObj.h"
37
#include <runtime/Error.h>
39
#include <runtime/Error.h>
38
#include <runtime/JSNumberCell.h>
40
#include <runtime/JSNumberCell.h>
Lines 225-235 static const HashTableValue JSTestObjPrototypeTableValues[47] = a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp_sec2
225
    { "overloadedMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOverloadedMethod), (intptr_t)2 THUNK_GENERATOR(0) },
227
    { "overloadedMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOverloadedMethod), (intptr_t)2 THUNK_GENERATOR(0) },
226
    { "classMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionClassMethod), (intptr_t)0 THUNK_GENERATOR(0) },
228
    { "classMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionClassMethod), (intptr_t)0 THUNK_GENERATOR(0) },
227
    { "classMethodWithOptional", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionClassMethodWithOptional), (intptr_t)1 THUNK_GENERATOR(0) },
229
    { "classMethodWithOptional", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionClassMethodWithOptional), (intptr_t)1 THUNK_GENERATOR(0) },
230
    { "methodWithAllowJSON", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithAllowJSON), (intptr_t)1 THUNK_GENERATOR(0) },
228
    { 0, 0, 0, 0 THUNK_GENERATOR(0) }
231
    { 0, 0, 0, 0 THUNK_GENERATOR(0) }
229
};
232
};
230
233
231
#undef THUNK_GENERATOR
234
#undef THUNK_GENERATOR
232
static JSC_CONST_HASHTABLE HashTable JSTestObjPrototypeTable = { 135, 127, JSTestObjPrototypeTableValues, 0 };
235
static JSC_CONST_HASHTABLE HashTable JSTestObjPrototypeTable = { 136, 127, JSTestObjPrototypeTableValues, 0 };
233
const ClassInfo JSTestObjPrototype::s_info = { "TestObjPrototype", 0, &JSTestObjPrototypeTable, 0 };
236
const ClassInfo JSTestObjPrototype::s_info = { "TestObjPrototype", 0, &JSTestObjPrototypeTable, 0 };
234
237
235
JSObject* JSTestObjPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
238
JSObject* JSTestObjPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
Lines 1485-1490 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionClassMethodWithOptional(E a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp_sec3
1485
    return JSValue::encode(result);
1488
    return JSValue::encode(result);
1486
}
1489
}
1487
1490
1491
EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithAllowJSON(ExecState* exec)
1492
{
1493
    JSValue thisValue = exec->hostThisValue();
1494
    if (!thisValue.inherits(&JSTestObj::s_info))
1495
        return throwVMTypeError(exec);
1496
    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
1497
    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
1498
    RefPtr<TestJSONObj> testJsonObj;
1499
    if (!exec->argument(0).isNull() && !exec->argument(0).isUndefined() && exec->argument(0).isObject() && !exec->argument(0).inherits(&JSTestJSONObj::s_info)) {
1500
        JSObject* object = exec->argument(0).getObject();
1501
        testJsonObj = TestJSONObj::create();
1502
        JSValue jsIntAttr = object->get(exec, Identifier(exec, "intAttr"));
1503
        if (!jsIntAttr.isNull() && !jsIntAttr.isUndefined())
1504
            testJsonObj->setIntAttr(jsIntAttr.toInt32(exec));
1505
        JSValue jsLongLongAttr = object->get(exec, Identifier(exec, "longLongAttr"));
1506
        if (!jsLongLongAttr.isNull() && !jsLongLongAttr.isUndefined())
1507
            testJsonObj->setLongLongAttr(static_cast<long long>(jsLongLongAttr.toInteger(exec)));
1508
        JSValue jsUnsignedLongLongAttr = object->get(exec, Identifier(exec, "unsignedLongLongAttr"));
1509
        if (!jsUnsignedLongLongAttr.isNull() && !jsUnsignedLongLongAttr.isUndefined())
1510
            testJsonObj->setUnsignedLongLongAttr(static_cast<unsigned long long>(jsUnsignedLongLongAttr.toInteger(exec)));
1511
        JSValue jsStringAttr = object->get(exec, Identifier(exec, "stringAttr"));
1512
        if (!jsStringAttr.isNull() && !jsStringAttr.isUndefined())
1513
            testJsonObj->setStringAttr(ustringToString(jsStringAttr.toString(exec)));
1514
        JSValue jsTestObjAttr = object->get(exec, Identifier(exec, "testObjAttr"));
1515
        if (!jsTestObjAttr.isNull() && !jsTestObjAttr.isUndefined())
1516
            testJsonObj->setTestObjAttr(toTestObj(jsTestObjAttr));
1517
    } else {
1518
        testJsonObj = adoptRef(toTestJSONObj(exec->argument(0)));
1519
    }
1520
    if (exec->hadException())
1521
        return JSValue::encode(jsUndefined());
1522
1523
    imp->methodWithAllowJSON(testJsonObj);
1524
    return JSValue::encode(jsUndefined());
1525
}
1526
1488
// Constant getters
1527
// Constant getters
1489
1528
1490
JSValue jsTestObjCONST_VALUE_0(ExecState* exec, JSValue, const Identifier&)
1529
JSValue jsTestObjCONST_VALUE_0(ExecState* exec, JSValue, const Identifier&)
- a/WebCore/bindings/scripts/test/JS/JSTestObj.h +1 lines
Lines 121-126 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackAn a/WebCore/bindings/scripts/test/JS/JSTestObj.h_sec1
121
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod(JSC::ExecState*);
121
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod(JSC::ExecState*);
122
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionClassMethod(JSC::ExecState*);
122
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionClassMethod(JSC::ExecState*);
123
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionClassMethodWithOptional(JSC::ExecState*);
123
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionClassMethodWithOptional(JSC::ExecState*);
124
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithAllowJSON(JSC::ExecState*);
124
// Attributes
125
// Attributes
125
126
126
JSC::JSValue jsTestObjReadOnlyIntAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
127
JSC::JSValue jsTestObjReadOnlyIntAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
- a/WebCore/bindings/scripts/test/ObjC/DOMTestJSONObj.h +47 lines
Line 0 a/WebCore/bindings/scripts/test/ObjC/DOMTestJSONObj.h_sec1
1
/*
2
 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3
 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
25
 */
26
27
#import <WebCore/DOMObject.h>
28
29
#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST
30
31
@class DOMTestObj;
32
@class NSString;
33
34
@interface DOMTestJSONObj : DOMObject
35
- (int)intAttr;
36
- (void)setIntAttr:(int)newIntAttr;
37
- (long long)longLongAttr;
38
- (void)setLongLongAttr:(long long)newLongLongAttr;
39
- (unsigned long long)unsignedLongLongAttr;
40
- (void)setUnsignedLongLongAttr:(unsigned long long)newUnsignedLongLongAttr;
41
- (NSString *)stringAttr;
42
- (void)setStringAttr:(NSString *)newStringAttr;
43
- (DOMTestObj *)testObjAttr;
44
- (void)setTestObjAttr:(DOMTestObj *)newTestObjAttr;
45
@end
46
47
#endif
- a/WebCore/bindings/scripts/test/ObjC/DOMTestJSONObj.mm +152 lines
Line 0 a/WebCore/bindings/scripts/test/ObjC/DOMTestJSONObj.mm_sec1
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
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
25
 */
26
27
#import "config.h"
28
#import "DOMInternal.h"
29
30
#import "DOMTestJSONObj.h"
31
32
#import "DOMBlobInternal.h"
33
#import "DOMCSSRuleInternal.h"
34
#import "DOMCSSValueInternal.h"
35
#import "DOMEventInternal.h"
36
#import "DOMNodeInternal.h"
37
#import "DOMStyleSheetInternal.h"
38
#import "DOMTestJSONObjInternal.h"
39
#import "DOMTestObjInternal.h"
40
#import "ExceptionHandlers.h"
41
#import "JSMainThreadExecState.h"
42
#import "KURL.h"
43
#import "TestJSONObj.h"
44
#import "TestObj.h"
45
#import "ThreadCheck.h"
46
#import "WebCoreObjCExtras.h"
47
#import "WebScriptObjectPrivate.h"
48
#import <wtf/GetPtr.h>
49
50
#define IMPL reinterpret_cast<WebCore::TestJSONObj*>(_internal)
51
52
@implementation DOMTestJSONObj
53
54
- (void)dealloc
55
{
56
    if (WebCoreObjCScheduleDeallocateOnMainThread([DOMTestJSONObj class], self))
57
        return;
58
59
    if (_internal)
60
        IMPL->deref();
61
    [super dealloc];
62
}
63
64
- (void)finalize
65
{
66
    if (_internal)
67
        IMPL->deref();
68
    [super finalize];
69
}
70
71
- (int)intAttr
72
{
73
    WebCore::JSMainThreadNullState state;
74
    return IMPL->intAttr();
75
}
76
77
- (void)setIntAttr:(int)newIntAttr
78
{
79
    WebCore::JSMainThreadNullState state;
80
    IMPL->setIntAttr(newIntAttr);
81
}
82
83
- (long long)longLongAttr
84
{
85
    WebCore::JSMainThreadNullState state;
86
    return IMPL->longLongAttr();
87
}
88
89
- (void)setLongLongAttr:(long long)newLongLongAttr
90
{
91
    WebCore::JSMainThreadNullState state;
92
    IMPL->setLongLongAttr(newLongLongAttr);
93
}
94
95
- (unsigned long long)unsignedLongLongAttr
96
{
97
    WebCore::JSMainThreadNullState state;
98
    return IMPL->unsignedLongLongAttr();
99
}
100
101
- (void)setUnsignedLongLongAttr:(unsigned long long)newUnsignedLongLongAttr
102
{
103
    WebCore::JSMainThreadNullState state;
104
    IMPL->setUnsignedLongLongAttr(newUnsignedLongLongAttr);
105
}
106
107
- (NSString *)stringAttr
108
{
109
    WebCore::JSMainThreadNullState state;
110
    return IMPL->stringAttr();
111
}
112
113
- (void)setStringAttr:(NSString *)newStringAttr
114
{
115
    WebCore::JSMainThreadNullState state;
116
    IMPL->setStringAttr(newStringAttr);
117
}
118
119
- (DOMTestObj *)testObjAttr
120
{
121
    WebCore::JSMainThreadNullState state;
122
    return kit(WTF::getPtr(IMPL->testObjAttr()));
123
}
124
125
- (void)setTestObjAttr:(DOMTestObj *)newTestObjAttr
126
{
127
    WebCore::JSMainThreadNullState state;
128
    ASSERT(newTestObjAttr);
129
130
    IMPL->setTestObjAttr(core(newTestObjAttr));
131
}
132
133
@end
134
135
WebCore::TestJSONObj* core(DOMTestJSONObj *wrapper)
136
{
137
    return wrapper ? reinterpret_cast<WebCore::TestJSONObj*>(wrapper->_internal) : 0;
138
}
139
140
DOMTestJSONObj *kit(WebCore::TestJSONObj* value)
141
{
142
    { DOM_ASSERT_MAIN_THREAD(); WebCoreThreadViolationCheckRoundOne(); };
143
    if (!value)
144
        return nil;
145
    if (DOMTestJSONObj *wrapper = getDOMWrapper(value))
146
        return [[wrapper retain] autorelease];
147
    DOMTestJSONObj *wrapper = [[DOMTestJSONObj alloc] _init];
148
    wrapper->_internal = reinterpret_cast<DOMObjectInternal*>(value);
149
    value->ref();
150
    addDOMWrapper(wrapper, value);
151
    return [wrapper autorelease];
152
}
- a/WebCore/bindings/scripts/test/ObjC/DOMTestJSONObjInternal.h +38 lines
Line 0 a/WebCore/bindings/scripts/test/ObjC/DOMTestJSONObjInternal.h_sec1
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
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
25
 */
26
27
#import <WebCore/DOMTestJSONObj.h>
28
29
#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST
30
31
namespace WebCore {
32
    class TestJSONObj;
33
}
34
35
WebCore::TestJSONObj* core(DOMTestJSONObj *);
36
DOMTestJSONObj *kit(WebCore::TestJSONObj*);
37
38
#endif
- a/WebCore/bindings/scripts/test/TestJSONObj.idl +40 lines
Line 0 a/WebCore/bindings/scripts/test/TestJSONObj.idl_sec1
1
/*
2
 * Copyright (C) 2010 Google Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary formstrArg, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 *
8
 * 1.  Redistributions of source code must retain the above copyright
9
 *     notice, this list of conditions and the following disclaimer.
10
 * 2.  Redistributions in binary form must reproduce the above copyright
11
 *     notice, this list of conditions and the following disclaimer in the
12
 *     documentation and/or other materials provided with the distribution.
13
 * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14
 *     its contributors may be used to endorse or promote products derived
15
 *     from this software without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18
 * EXPRESS OR IMPLIED WARRANTIEstrArg, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
28
29
// This IDL file is for testing the bindings code generator with an interface
30
// that has the "AllowJSON" attribute and for tracking changes in its ouput.
31
module test {
32
    interface TestJSONObj {
33
        // Attributes
34
        attribute long                     intAttr;
35
        attribute long long                longLongAttr;
36
        attribute unsigned long long       unsignedLongLongAttr;
37
        attribute DOMString                stringAttr;
38
        attribute TestObj                  testObjAttr;
39
    };
40
}
- a/WebCore/bindings/scripts/test/TestObj.idl +5 lines
Lines 142-147 module test { a/WebCore/bindings/scripts/test/TestObj.idl_sec1
142
        [ClassMethod] void classMethod();
142
        [ClassMethod] void classMethod();
143
        [ClassMethod] long classMethodWithOptional(in [Optional] long arg);
143
        [ClassMethod] long classMethodWithOptional(in [Optional] long arg);
144
144
145
#if defined(TESTING_V8) || defined(TESTING_JS)
146
        // AllowJSON
147
        void    methodWithAllowJSON(in [AllowJSON] TestJSONObj testJsonObj);
148
#endif
149
145
        // ObjectiveC reserved words.
150
        // ObjectiveC reserved words.
146
        readonly attribute long      description;
151
        readonly attribute long      description;
147
        attribute long               id;
152
        attribute long               id;
- a/WebCore/bindings/scripts/test/V8/V8TestJSONObj.cpp +206 lines
Line 0 a/WebCore/bindings/scripts/test/V8/V8TestJSONObj.cpp_sec1
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., 59 Temple Place - Suite 330,
18
    Boston, MA 02111-1307, USA.
19
*/
20
21
#include "config.h"
22
#include "V8TestJSONObj.h"
23
24
#include "RuntimeEnabledFeatures.h"
25
#include "V8Binding.h"
26
#include "V8BindingMacros.h"
27
#include "V8BindingState.h"
28
#include "V8DOMWrapper.h"
29
#include "V8IsolatedContext.h"
30
#include "V8Proxy.h"
31
#include "V8TestObj.h"
32
#include <wtf/GetPtr.h>
33
#include <wtf/RefCounted.h>
34
#include <wtf/RefPtr.h>
35
36
namespace WebCore {
37
38
WrapperTypeInfo V8TestJSONObj::info = { V8TestJSONObj::GetTemplate, V8TestJSONObj::derefObject, 0 };
39
40
namespace TestJSONObjInternal {
41
42
template <typename T> void V8_USE(T) { }
43
44
static v8::Handle<v8::Value> intAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
45
{
46
    INC_STATS("DOM.TestJSONObj.intAttr._get");
47
    TestJSONObj* imp = V8TestJSONObj::toNative(info.Holder());
48
    return v8::Integer::New(imp->intAttr());
49
}
50
51
static void intAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
52
{
53
    INC_STATS("DOM.TestJSONObj.intAttr._set");
54
    TestJSONObj* imp = V8TestJSONObj::toNative(info.Holder());
55
    int v = toInt32(value);
56
    imp->setIntAttr(v);
57
    return;
58
}
59
60
static v8::Handle<v8::Value> longLongAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
61
{
62
    INC_STATS("DOM.TestJSONObj.longLongAttr._get");
63
    TestJSONObj* imp = V8TestJSONObj::toNative(info.Holder());
64
    return v8::Number::New(static_cast<double>(imp->longLongAttr()));
65
}
66
67
static void longLongAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
68
{
69
    INC_STATS("DOM.TestJSONObj.longLongAttr._set");
70
    TestJSONObj* imp = V8TestJSONObj::toNative(info.Holder());
71
    long long v = toInt64(value);
72
    imp->setLongLongAttr(WTF::getPtr(v));
73
    return;
74
}
75
76
static v8::Handle<v8::Value> unsignedLongLongAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
77
{
78
    INC_STATS("DOM.TestJSONObj.unsignedLongLongAttr._get");
79
    TestJSONObj* imp = V8TestJSONObj::toNative(info.Holder());
80
    return v8::Number::New(static_cast<double>(imp->unsignedLongLongAttr()));
81
}
82
83
static void unsignedLongLongAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
84
{
85
    INC_STATS("DOM.TestJSONObj.unsignedLongLongAttr._set");
86
    TestJSONObj* imp = V8TestJSONObj::toNative(info.Holder());
87
    unsigned long long v = toInt64(value);
88
    imp->setUnsignedLongLongAttr(WTF::getPtr(v));
89
    return;
90
}
91
92
static v8::Handle<v8::Value> stringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
93
{
94
    INC_STATS("DOM.TestJSONObj.stringAttr._get");
95
    TestJSONObj* imp = V8TestJSONObj::toNative(info.Holder());
96
    return v8String(imp->stringAttr());
97
}
98
99
static void stringAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
100
{
101
    INC_STATS("DOM.TestJSONObj.stringAttr._set");
102
    TestJSONObj* imp = V8TestJSONObj::toNative(info.Holder());
103
    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK_VOID(V8Parameter<>, v, value);
104
    imp->setStringAttr(v);
105
    return;
106
}
107
108
static v8::Handle<v8::Value> testObjAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
109
{
110
    INC_STATS("DOM.TestJSONObj.testObjAttr._get");
111
    TestJSONObj* imp = V8TestJSONObj::toNative(info.Holder());
112
    return toV8(imp->testObjAttr());
113
}
114
115
static void testObjAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
116
{
117
    INC_STATS("DOM.TestJSONObj.testObjAttr._set");
118
    TestJSONObj* imp = V8TestJSONObj::toNative(info.Holder());
119
    TestObj* v = V8TestObj::HasInstance(value) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(value)) : 0;
120
    imp->setTestObjAttr(WTF::getPtr(v));
121
    return;
122
}
123
124
} // namespace TestJSONObjInternal
125
126
static const BatchedAttribute TestJSONObjAttrs[] = {
127
    // Attribute 'intAttr' (Type: 'attribute' ExtAttr: '')
128
    {"intAttr", TestJSONObjInternal::intAttrAttrGetter, TestJSONObjInternal::intAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
129
    // Attribute 'longLongAttr' (Type: 'attribute' ExtAttr: '')
130
    {"longLongAttr", TestJSONObjInternal::longLongAttrAttrGetter, TestJSONObjInternal::longLongAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
131
    // Attribute 'unsignedLongLongAttr' (Type: 'attribute' ExtAttr: '')
132
    {"unsignedLongLongAttr", TestJSONObjInternal::unsignedLongLongAttrAttrGetter, TestJSONObjInternal::unsignedLongLongAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
133
    // Attribute 'stringAttr' (Type: 'attribute' ExtAttr: '')
134
    {"stringAttr", TestJSONObjInternal::stringAttrAttrGetter, TestJSONObjInternal::stringAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
135
    // Attribute 'testObjAttr' (Type: 'attribute' ExtAttr: '')
136
    {"testObjAttr", TestJSONObjInternal::testObjAttrAttrGetter, TestJSONObjInternal::testObjAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
137
};
138
static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestJSONObjTemplate(v8::Persistent<v8::FunctionTemplate> desc)
139
{
140
    v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "TestJSONObj", v8::Persistent<v8::FunctionTemplate>(), V8TestJSONObj::internalFieldCount,
141
        TestJSONObjAttrs, sizeof(TestJSONObjAttrs) / sizeof(*TestJSONObjAttrs),
142
        0, 0);
143
    
144
145
    // Custom toString template
146
    desc->Set(getToStringName(), getToStringTemplate());
147
    return desc;
148
}
149
150
v8::Persistent<v8::FunctionTemplate> V8TestJSONObj::GetRawTemplate()
151
{
152
    static v8::Persistent<v8::FunctionTemplate> V8TestJSONObjRawCache = createRawTemplate();
153
    return V8TestJSONObjRawCache;
154
}
155
156
v8::Persistent<v8::FunctionTemplate> V8TestJSONObj::GetTemplate()
157
{
158
    static v8::Persistent<v8::FunctionTemplate> V8TestJSONObjCache = ConfigureV8TestJSONObjTemplate(GetRawTemplate());
159
    return V8TestJSONObjCache;
160
}
161
162
TestJSONObj* V8TestJSONObj::toNative(v8::Handle<v8::Object> object)
163
{
164
    return reinterpret_cast<TestJSONObj*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex));
165
}
166
167
bool V8TestJSONObj::HasInstance(v8::Handle<v8::Value> value)
168
{
169
    return GetRawTemplate()->HasInstance(value);
170
}
171
172
173
v8::Handle<v8::Object> V8TestJSONObj::wrap(TestJSONObj* impl)
174
{
175
    v8::Handle<v8::Object> wrapper;
176
    V8Proxy* proxy = 0;
177
        wrapper = getDOMObjectMap().get(impl);
178
        if (!wrapper.IsEmpty())
179
            return wrapper;
180
    wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl);
181
    if (wrapper.IsEmpty())
182
        return wrapper;
183
184
    impl->ref();
185
    getDOMObjectMap().set(impl, v8::Persistent<v8::Object>::New(wrapper));
186
    return wrapper;
187
}
188
189
v8::Handle<v8::Value> toV8(PassRefPtr<TestJSONObj > impl)
190
{
191
    return toV8(impl.get());
192
}
193
194
v8::Handle<v8::Value> toV8(TestJSONObj* impl)
195
{
196
    if (!impl)
197
        return v8::Null();
198
    return V8TestJSONObj::wrap(impl);
199
}
200
201
void V8TestJSONObj::derefObject(void* object)
202
{
203
    static_cast<TestJSONObj*>(object)->deref();
204
}
205
206
} // namespace WebCore
- a/WebCore/bindings/scripts/test/V8/V8TestJSONObj.h +49 lines
Line 0 a/WebCore/bindings/scripts/test/V8/V8TestJSONObj.h_sec1
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., 59 Temple Place - Suite 330,
18
    Boston, MA 02111-1307, USA.
19
*/
20
21
#ifndef V8TestJSONObj_h
22
#define V8TestJSONObj_h
23
24
#include "TestJSONObj.h"
25
#include "WrapperTypeInfo.h"
26
#include "wtf/text/StringHash.h"
27
#include <v8.h>
28
#include <wtf/HashMap.h>
29
30
namespace WebCore {
31
32
class V8TestJSONObj {
33
34
public:
35
    static bool HasInstance(v8::Handle<v8::Value> value);
36
    static v8::Persistent<v8::FunctionTemplate> GetRawTemplate();
37
    static v8::Persistent<v8::FunctionTemplate> GetTemplate();
38
    static TestJSONObj* toNative(v8::Handle<v8::Object>);
39
    static v8::Handle<v8::Object> wrap(TestJSONObj*);
40
    static void derefObject(void*);
41
    static WrapperTypeInfo info;
42
    static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0;
43
};
44
45
v8::Handle<v8::Value> toV8(TestJSONObj*);
46
v8::Handle<v8::Value> toV8(PassRefPtr<TestJSONObj >);
47
}
48
49
#endif // V8TestJSONObj_h
- a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp +49 lines
Lines 28-33 a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp_sec1
28
#include "RuntimeEnabledFeatures.h"
28
#include "RuntimeEnabledFeatures.h"
29
#include "ScriptCallStack.h"
29
#include "ScriptCallStack.h"
30
#include "SerializedScriptValue.h"
30
#include "SerializedScriptValue.h"
31
#include "TestJSONObj.h"
31
#include "V8Binding.h"
32
#include "V8Binding.h"
32
#include "V8BindingMacros.h"
33
#include "V8BindingMacros.h"
33
#include "V8BindingState.h"
34
#include "V8BindingState.h"
Lines 35-40 a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp_sec2
35
#include "V8IsolatedContext.h"
36
#include "V8IsolatedContext.h"
36
#include "V8Proxy.h"
37
#include "V8Proxy.h"
37
#include "V8TestCallback.h"
38
#include "V8TestCallback.h"
39
#include "V8TestJSONObj.h"
38
#include "V8log.h"
40
#include "V8log.h"
39
#include <wtf/GetPtr.h>
41
#include <wtf/GetPtr.h>
40
#include <wtf/RefCounted.h>
42
#include <wtf/RefCounted.h>
Lines 1020-1025 static v8::Handle<v8::Value> classMethodWithOptionalCallback(const v8::Arguments a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp_sec3
1020
    return v8::Integer::New(TestObj::classMethodWithOptional(arg));
1022
    return v8::Integer::New(TestObj::classMethodWithOptional(arg));
1021
}
1023
}
1022
1024
1025
static v8::Handle<v8::Value> methodWithAllowJSONCallback(const v8::Arguments& args)
1026
{
1027
    INC_STATS("DOM.TestObj.methodWithAllowJSON");
1028
    TestObj* imp = V8TestObj::toNative(args.Holder());
1029
    RefPtr<TestJSONObj> testJsonObj;
1030
    if (!isUndefinedOrNull(args[0]) && args[0]->IsObject() && !V8TestJSONObj::HasInstance(args[0])) {
1031
        EXCEPTION_BLOCK(v8::Handle<v8::Object>, object, v8::Handle<v8::Object>::Cast(args[0]));
1032
        testJsonObj = TestJSONObj::create();
1033
        v8::Local<v8::Value> v8IntAttr = object->Get(v8::String::New("intAttr"));
1034
        if (!v8IntAttr.IsEmpty() && !isUndefinedOrNull(v8IntAttr)) {
1035
            EXCEPTION_BLOCK(int, intAttr, toInt32(v8IntAttr));
1036
            testJsonObj->setIntAttr(intAttr);
1037
        }
1038
        v8::Local<v8::Value> v8LongLongAttr = object->Get(v8::String::New("longLongAttr"));
1039
        if (!v8LongLongAttr.IsEmpty() && !isUndefinedOrNull(v8LongLongAttr)) {
1040
            EXCEPTION_BLOCK(long long, longLongAttr, toInt64(v8LongLongAttr));
1041
            testJsonObj->setLongLongAttr(longLongAttr);
1042
        }
1043
        v8::Local<v8::Value> v8UnsignedLongLongAttr = object->Get(v8::String::New("unsignedLongLongAttr"));
1044
        if (!v8UnsignedLongLongAttr.IsEmpty() && !isUndefinedOrNull(v8UnsignedLongLongAttr)) {
1045
            EXCEPTION_BLOCK(unsigned long long, unsignedLongLongAttr, toInt64(v8UnsignedLongLongAttr));
1046
            testJsonObj->setUnsignedLongLongAttr(unsignedLongLongAttr);
1047
        }
1048
        v8::Local<v8::Value> v8StringAttr = object->Get(v8::String::New("stringAttr"));
1049
        if (!v8StringAttr.IsEmpty() && !isUndefinedOrNull(v8StringAttr)) {
1050
            STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, stringAttr, v8StringAttr);
1051
            testJsonObj->setStringAttr(stringAttr);
1052
        }
1053
        v8::Local<v8::Value> v8TestObjAttr = object->Get(v8::String::New("testObjAttr"));
1054
        if (!v8TestObjAttr.IsEmpty() && !isUndefinedOrNull(v8TestObjAttr)) {
1055
            EXCEPTION_BLOCK(TestObj*, testObjAttr, V8TestObj::HasInstance(v8TestObjAttr) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(v8TestObjAttr)) : 0);
1056
            testJsonObj->setTestObjAttr(testObjAttr);
1057
        }
1058
    } else {
1059
       EXCEPTION_BLOCK(TestJSONObj*, tmp_testJsonObj, V8TestJSONObj::HasInstance(args[0]) ? V8TestJSONObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
1060
       testJsonObj = adoptRef(tmp_testJsonObj);
1061
    }
1062
    imp->methodWithAllowJSON(testJsonObj);
1063
    return v8::Handle<v8::Value>();
1064
}
1065
1023
} // namespace TestObjInternal
1066
} // namespace TestObjInternal
1024
1067
1025
static const BatchedAttribute TestObjAttrs[] = {
1068
static const BatchedAttribute TestObjAttrs[] = {
Lines 1195-1200 static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestObjTemplate(v8::Persi a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp_sec4
1195
    proto->Set(v8::String::New("customArgsAndException"), v8::FunctionTemplate::New(TestObjInternal::customArgsAndExceptionCallback, v8::Handle<v8::Value>(), customArgsAndExceptionSignature));
1238
    proto->Set(v8::String::New("customArgsAndException"), v8::FunctionTemplate::New(TestObjInternal::customArgsAndExceptionCallback, v8::Handle<v8::Value>(), customArgsAndExceptionSignature));
1196
    desc->Set(v8::String::New("classMethod"), v8::FunctionTemplate::New(TestObjInternal::classMethodCallback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>()));
1239
    desc->Set(v8::String::New("classMethod"), v8::FunctionTemplate::New(TestObjInternal::classMethodCallback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>()));
1197
    desc->Set(v8::String::New("classMethodWithOptional"), v8::FunctionTemplate::New(TestObjInternal::classMethodWithOptionalCallback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>()));
1240
    desc->Set(v8::String::New("classMethodWithOptional"), v8::FunctionTemplate::New(TestObjInternal::classMethodWithOptionalCallback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>()));
1241
1242
    // Custom Signature 'methodWithAllowJSON'
1243
    const int methodWithAllowJSONArgc = 1;
1244
    v8::Handle<v8::FunctionTemplate> methodWithAllowJSONArgv[methodWithAllowJSONArgc] = { V8TestJSONObj::GetRawTemplate() };
1245
    v8::Handle<v8::Signature> methodWithAllowJSONSignature = v8::Signature::New(desc, methodWithAllowJSONArgc, methodWithAllowJSONArgv);
1246
    proto->Set(v8::String::New("methodWithAllowJSON"), v8::FunctionTemplate::New(TestObjInternal::methodWithAllowJSONCallback, v8::Handle<v8::Value>(), methodWithAllowJSONSignature));
1198
    batchConfigureConstants(desc, proto, TestObjConsts, sizeof(TestObjConsts) / sizeof(*TestObjConsts));
1247
    batchConfigureConstants(desc, proto, TestObjConsts, sizeof(TestObjConsts) / sizeof(*TestObjConsts));
1199
1248
1200
    // Custom toString template
1249
    // Custom toString template
- a/WebCore/fileapi/DirectoryEntry.idl -2 / +3 lines
Lines 35-41 module storage { a/WebCore/fileapi/DirectoryEntry.idl_sec1
35
        GenerateToJS
35
        GenerateToJS
36
    ] DirectoryEntry : Entry {
36
    ] DirectoryEntry : Entry {
37
        DirectoryReader createReader();
37
        DirectoryReader createReader();
38
        void getFile(in DOMString path, in [Optional] Flags options, in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
38
39
        void getDirectory(in DOMString path, in [Optional] Flags options, in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
39
        void getFile(in DOMString path, in [Optional, AllowJSON] Flags flags, in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
40
        void getDirectory(in DOMString path, in [Optional, AllowJSON] Flags flags, in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
40
    };
41
    };
41
}
42
}

Return to Bug 45237