Changeset 64835 in webkit


Ignore:
Timestamp:
Aug 6, 2010 4:47:10 AM (14 years ago)
Author:
dumi@chromium.org
Message:

WebCore: Auto-generate all HTML5 DB bindings.
https://bugs.webkit.org/show_bug.cgi?id=43382

Reviewed by Adam Barth.

  • Android.jscbindings.mk: Remove {JS|V8}Database{Sync}Custom.cpp

and the custom implementations of openDatabas{Sync}().

  • Android.v8bindings.mk:
  • CMakeLists.txt:
  • GNUmakefile.am:
  • WebCore.gypi:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSBindingsAllInOne.cpp:
  • bindings/js/JSDOMWindowCustom.cpp:
  • bindings/js/JSDatabaseCustom.cpp: Removed.
  • bindings/js/JSDatabaseSyncCustom.cpp: Removed.
  • bindings/js/JSWorkerContextCustom.cpp:
  • bindings/v8/custom/V8DOMWindowCustom.cpp:
  • bindings/v8/custom/V8DatabaseCustom.cpp: Removed.
  • bindings/v8/custom/V8DatabaseSyncCustom.cpp: Removed.
  • bindings/v8/custom/V8WorkerContextCustom.cpp:
  • bindings/scripts/CodeGeneratorJS.pm: Change the code generators

to check that a value was passed for each non-optional argument,
and that the value can be converted to the argument type.

  • bindings/scripts/CodeGeneratorV8.pm:
  • bindings/scripts/test/JS/JSTestCallback.cpp:

(WebCore::JSTestCallback::~JSTestCallback):

  • bindings/scripts/test/JS/JSTestObj.cpp:

(WebCore::jsTestObjPrototypeFunctionVoidMethodWithArgs):
(WebCore::jsTestObjPrototypeFunctionIntMethodWithArgs):
(WebCore::jsTestObjPrototypeFunctionObjMethodWithArgs):
(WebCore::jsTestObjPrototypeFunctionMethodThatRequiresAllArgs):
(WebCore::jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows):
(WebCore::jsTestObjPrototypeFunctionSerializedValue):
(WebCore::jsTestObjPrototypeFunctionIdbKey):
(WebCore::jsTestObjPrototypeFunctionCustomArgsAndException):
(WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndArg):
(WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg):
(WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture):
(WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalArg):
(WebCore::jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg):
(WebCore::jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs):
(WebCore::jsTestObjPrototypeFunctionMethodWithCallbackArg):
(WebCore::jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg):
(WebCore::jsTestObjPrototypeFunctionMethodWithCallbackAndOptionalArg):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod1):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod2):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod3):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod4):

  • bindings/scripts/test/TestObj.idl:
  • bindings/scripts/test/V8/V8TestObj.cpp:

(WebCore::TestObjInternal::voidMethodWithArgsCallback):
(WebCore::TestObjInternal::intMethodWithArgsCallback):
(WebCore::TestObjInternal::objMethodWithArgsCallback):
(WebCore::TestObjInternal::methodThatRequiresAllArgsCallback):
(WebCore::TestObjInternal::methodThatRequiresAllArgsAndThrowsCallback):
(WebCore::TestObjInternal::serializedValueCallback):
(WebCore::TestObjInternal::idbKeyCallback):
(WebCore::TestObjInternal::customArgsAndExceptionCallback):
(WebCore::TestObjInternal::withDynamicFrameAndArgCallback):
(WebCore::TestObjInternal::withDynamicFrameAndOptionalArgCallback):
(WebCore::TestObjInternal::withDynamicFrameAndUserGestureCallback):
(WebCore::TestObjInternal::withDynamicFrameAndUserGestureASADCallback):
(WebCore::TestObjInternal::methodWithOptionalArgCallback):
(WebCore::TestObjInternal::methodWithNonOptionalArgAndOptionalArgCallback):
(WebCore::TestObjInternal::methodWithNonOptionalArgAndTwoOptionalArgsCallback):
(WebCore::TestObjInternal::methodWithCallbackArgCallback):
(WebCore::TestObjInternal::methodWithNonCallbackArgAndCallbackArgCallback):
(WebCore::TestObjInternal::methodWithCallbackAndOptionalArgCallback):
(WebCore::TestObjInternal::overloadedMethod1Callback):
(WebCore::TestObjInternal::overloadedMethod2Callback):
(WebCore::TestObjInternal::overloadedMethod3Callback):
(WebCore::TestObjInternal::overloadedMethod4Callback):
(WebCore::):
(WebCore::ConfigureV8TestObjTemplate):

  • bindings/v8/V8Binding.h:

(WebCore::String):
(WebCore::AtomicString):

  • page/DOMWindow.idl: Minor changes required by the auto-generated

bindings.

  • storage/Database.cpp:

(WebCore::Database::transaction):
(WebCore::Database::readTransaction):
(WebCore::Database::runTransaction):

  • storage/Database.h:
  • storage/Database.idl:
  • storage/DatabaseSync.cpp:

(WebCore::DatabaseSync::transaction):
(WebCore::DatabaseSync::readTransaction):
(WebCore::DatabaseSync::runTransaction):

  • storage/DatabaseSync.h:
  • storage/DatabaseSync.idl:
  • workers/WorkerContext.idl:

LayoutTests: Cosmetic changes to two tests.
https://bugs.webkit.org/show_bug.cgi?id=43382

Reviewed by Adam Barth.

  • fast/workers/storage/open-database-inputs-sync-expected.txt:
  • fast/workers/storage/resources/open-database-inputs-sync.js:
  • storage/null-callbacks.html:
Location:
trunk
Files:
4 deleted
33 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r64833 r64835  
     12010-08-06  Dumitru Daniliuc  <dumi@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Cosmetic changes to two tests.
     6        https://bugs.webkit.org/show_bug.cgi?id=43382
     7
     8        * fast/workers/storage/open-database-inputs-sync-expected.txt:
     9        * fast/workers/storage/resources/open-database-inputs-sync.js:
     10        * storage/null-callbacks.html:
     11
    1122010-08-06  Nikolas Zimmermann  <nzimmermann@rim.com>
    213
  • trunk/LayoutTests/fast/workers/storage/open-database-inputs-sync-expected.txt

    r63278 r64835  
    11This test makes sure that openDatabaseSync() accepts only valid parameters.
    2 PASS: SYNTAX_ERR: DOM Exception 12
    3 PASS: SYNTAX_ERR: DOM Exception 12
     2PASS: TYPE_MISMATCH_ERR: DOM Exception 17
     3PASS: TYPE_MISMATCH_ERR: DOM Exception 17
    44PASS: undefined
    55PASS: undefined
    66PASS: undefined
    7 PASS: TYPE_MISMATCH_ERR: DOM Exception 17
     7PASS: calling openDatabaseSync() with a null creation callback succeeded.
    88PASS: openDatabaseSync() succeeded.
    99PASS: openDatabaseSync() succeeded.
  • trunk/LayoutTests/fast/workers/storage/resources/open-database-inputs-sync.js

    r63278 r64835  
    4242try {
    4343    db = openDatabaseSync("DBName", "DBVersion", "DBDescription", 1024, 0);
    44     postMessage("FAIL: the fifth argument to openDatabaseSync() must be an object, if present.");
     44    postMessage("PASS: calling openDatabaseSync() with a null creation callback succeeded.");
    4545} catch (err) {
    46     postMessage("PASS: " + err.message);
     46    postMessage("FAIL: " + err.message);
    4747}
    4848
  • trunk/LayoutTests/storage/null-callbacks.html

    r54910 r64835  
    3131        }, null, function() { finishTest(); });
    3232    } catch(err) {
    33         document.getElementById("console").innerHTML = "FAIL";
     33        document.getElementById("console").innerHTML = "FAIL: " + err.message;
    3434        finishTest();
    3535    }
  • trunk/WebCore/Android.jscbindings.mk

    r64642 r64835  
    9191        bindings/js/JSDataGridColumnListCustom.cpp \
    9292        bindings/js/JSDataGridDataSource.cpp \
    93         bindings/js/JSDatabaseCustom.cpp \
    9493        bindings/js/JSDedicatedWorkerContextCustom.cpp \
    9594        bindings/js/JSDesktopNotificationsCustom.cpp \
  • trunk/WebCore/Android.v8bindings.mk

    r63193 r64835  
    107107        bindings/v8/custom/V8DataGridColumnListCustom.cpp \
    108108        bindings/v8/custom/V8DatabaseCallback.cpp \
    109         bindings/v8/custom/V8DatabaseCustom.cpp \
    110109        bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp \
    111110        bindings/v8/custom/V8DeviceOrientationEventCustom.cpp \
  • trunk/WebCore/CMakeLists.txt

    r64828 r64835  
    590590    bindings/js/JSCustomVoidCallback.cpp
    591591    bindings/js/JSCustomXPathNSResolver.cpp
    592     bindings/js/JSDatabaseCustom.cpp
    593     bindings/js/JSDatabaseCustom.cpp
    594     bindings/js/JSDatabaseSyncCustom.cpp
    595592    bindings/js/JSDataGridColumnListCustom.cpp
    596593    bindings/js/JSDataGridDataSource.cpp
  • trunk/WebCore/ChangeLog

    r64834 r64835  
     12010-08-06  Dumitru Daniliuc  <dumi@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Auto-generate all HTML5 DB bindings.
     6        https://bugs.webkit.org/show_bug.cgi?id=43382
     7
     8        * Android.jscbindings.mk: Remove {JS|V8}Database{Sync}Custom.cpp
     9        and the custom implementations of openDatabas{Sync}().
     10        * Android.v8bindings.mk:
     11        * CMakeLists.txt:
     12        * GNUmakefile.am:
     13        * WebCore.gypi:
     14        * WebCore.pro:
     15        * WebCore.vcproj/WebCore.vcproj:
     16        * WebCore.xcodeproj/project.pbxproj:
     17        * bindings/js/JSBindingsAllInOne.cpp:
     18        * bindings/js/JSDOMWindowCustom.cpp:
     19        * bindings/js/JSDatabaseCustom.cpp: Removed.
     20        * bindings/js/JSDatabaseSyncCustom.cpp: Removed.
     21        * bindings/js/JSWorkerContextCustom.cpp:
     22        * bindings/v8/custom/V8DOMWindowCustom.cpp:
     23        * bindings/v8/custom/V8DatabaseCustom.cpp: Removed.
     24        * bindings/v8/custom/V8DatabaseSyncCustom.cpp: Removed.
     25        * bindings/v8/custom/V8WorkerContextCustom.cpp:
     26
     27        * bindings/scripts/CodeGeneratorJS.pm: Change the code generators
     28        to check that a value was passed for each non-optional argument,
     29        and that the value can be converted to the argument type.
     30        * bindings/scripts/CodeGeneratorV8.pm:
     31        * bindings/scripts/test/JS/JSTestCallback.cpp:
     32        (WebCore::JSTestCallback::~JSTestCallback):
     33        * bindings/scripts/test/JS/JSTestObj.cpp:
     34        (WebCore::jsTestObjPrototypeFunctionVoidMethodWithArgs):
     35        (WebCore::jsTestObjPrototypeFunctionIntMethodWithArgs):
     36        (WebCore::jsTestObjPrototypeFunctionObjMethodWithArgs):
     37        (WebCore::jsTestObjPrototypeFunctionMethodThatRequiresAllArgs):
     38        (WebCore::jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows):
     39        (WebCore::jsTestObjPrototypeFunctionSerializedValue):
     40        (WebCore::jsTestObjPrototypeFunctionIdbKey):
     41        (WebCore::jsTestObjPrototypeFunctionCustomArgsAndException):
     42        (WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndArg):
     43        (WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg):
     44        (WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture):
     45        (WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD):
     46        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalArg):
     47        (WebCore::jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg):
     48        (WebCore::jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs):
     49        (WebCore::jsTestObjPrototypeFunctionMethodWithCallbackArg):
     50        (WebCore::jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg):
     51        (WebCore::jsTestObjPrototypeFunctionMethodWithCallbackAndOptionalArg):
     52        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod1):
     53        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod2):
     54        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod3):
     55        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod4):
     56        * bindings/scripts/test/TestObj.idl:
     57        * bindings/scripts/test/V8/V8TestObj.cpp:
     58        (WebCore::TestObjInternal::voidMethodWithArgsCallback):
     59        (WebCore::TestObjInternal::intMethodWithArgsCallback):
     60        (WebCore::TestObjInternal::objMethodWithArgsCallback):
     61        (WebCore::TestObjInternal::methodThatRequiresAllArgsCallback):
     62        (WebCore::TestObjInternal::methodThatRequiresAllArgsAndThrowsCallback):
     63        (WebCore::TestObjInternal::serializedValueCallback):
     64        (WebCore::TestObjInternal::idbKeyCallback):
     65        (WebCore::TestObjInternal::customArgsAndExceptionCallback):
     66        (WebCore::TestObjInternal::withDynamicFrameAndArgCallback):
     67        (WebCore::TestObjInternal::withDynamicFrameAndOptionalArgCallback):
     68        (WebCore::TestObjInternal::withDynamicFrameAndUserGestureCallback):
     69        (WebCore::TestObjInternal::withDynamicFrameAndUserGestureASADCallback):
     70        (WebCore::TestObjInternal::methodWithOptionalArgCallback):
     71        (WebCore::TestObjInternal::methodWithNonOptionalArgAndOptionalArgCallback):
     72        (WebCore::TestObjInternal::methodWithNonOptionalArgAndTwoOptionalArgsCallback):
     73        (WebCore::TestObjInternal::methodWithCallbackArgCallback):
     74        (WebCore::TestObjInternal::methodWithNonCallbackArgAndCallbackArgCallback):
     75        (WebCore::TestObjInternal::methodWithCallbackAndOptionalArgCallback):
     76        (WebCore::TestObjInternal::overloadedMethod1Callback):
     77        (WebCore::TestObjInternal::overloadedMethod2Callback):
     78        (WebCore::TestObjInternal::overloadedMethod3Callback):
     79        (WebCore::TestObjInternal::overloadedMethod4Callback):
     80        (WebCore::):
     81        (WebCore::ConfigureV8TestObjTemplate):
     82        * bindings/v8/V8Binding.h:
     83        (WebCore::String):
     84        (WebCore::AtomicString):
     85
     86        * page/DOMWindow.idl: Minor changes required by the auto-generated
     87        bindings.
     88        * storage/Database.cpp:
     89        (WebCore::Database::transaction):
     90        (WebCore::Database::readTransaction):
     91        (WebCore::Database::runTransaction):
     92        * storage/Database.h:
     93        * storage/Database.idl:
     94        * storage/DatabaseSync.cpp:
     95        (WebCore::DatabaseSync::transaction):
     96        (WebCore::DatabaseSync::readTransaction):
     97        (WebCore::DatabaseSync::runTransaction):
     98        * storage/DatabaseSync.h:
     99        * storage/DatabaseSync.idl:
     100        * workers/WorkerContext.idl:
     101
    11022010-08-06  Nikolas Zimmermann  <nzimmermann@rim.com>
    2103
  • trunk/WebCore/GNUmakefile.am

    r64828 r64835  
    27282728webcore_sources += \
    27292729        WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp \
    2730         WebCore/bindings/js/JSDatabaseCustom.cpp \
    2731         WebCore/bindings/js/JSDatabaseSyncCustom.cpp \
    27322730        WebCore/bindings/js/JSSQLResultSetRowListCustom.cpp \
    27332731        WebCore/bindings/js/JSSQLTransactionCustom.cpp \
  • trunk/WebCore/WebCore.gypi

    r64828 r64835  
    543543            'bindings/js/JSCustomXPathNSResolver.cpp',
    544544            'bindings/js/JSCustomXPathNSResolver.h',
    545             'bindings/js/JSDatabaseCustom.cpp',
    546             'bindings/js/JSDatabaseSyncCustom.cpp',
    547545            'bindings/js/JSDataGridColumnListCustom.cpp',
    548546            'bindings/js/JSDataGridDataSource.cpp',
     
    741739            'bindings/v8/custom/V8CustomXPathNSResolver.cpp',
    742740            'bindings/v8/custom/V8CustomXPathNSResolver.h',
    743             'bindings/v8/custom/V8DatabaseCustom.cpp',
    744             'bindings/v8/custom/V8DatabaseSyncCustom.cpp',
    745741            'bindings/v8/custom/V8DataGridColumnListCustom.cpp',
    746742            'bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp',
  • trunk/WebCore/WebCore.pro

    r64829 r64835  
    24132413        storage/SQLTransactionSync.cpp \
    24142414        bindings/js/JSCustomSQLStatementErrorCallback.cpp \
    2415         bindings/js/JSDatabaseCustom.cpp \
    2416         bindings/js/JSDatabaseSyncCustom.cpp \
    24172415        bindings/js/JSSQLResultSetRowListCustom.cpp \
    24182416        bindings/js/JSSQLTransactionCustom.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r64828 r64835  
    4208142081                                </File>
    4208242082                                <File
    42083                                         RelativePath="..\bindings\js\JSDatabaseCustom.cpp"
    42084                                         >
    42085                                         <FileConfiguration
    42086                                                 Name="Debug|Win32"
    42087                                                 ExcludedFromBuild="true"
    42088                                                 >
    42089                                                 <Tool
    42090                                                         Name="VCCLCompilerTool"
    42091                                                 />
    42092                                         </FileConfiguration>
    42093                                         <FileConfiguration
    42094                                                 Name="Release|Win32"
    42095                                                 ExcludedFromBuild="true"
    42096                                                 >
    42097                                                 <Tool
    42098                                                         Name="VCCLCompilerTool"
    42099                                                 />
    42100                                         </FileConfiguration>
    42101                                         <FileConfiguration
    42102                                                 Name="Debug_Internal|Win32"
    42103                                                 ExcludedFromBuild="true"
    42104                                                 >
    42105                                                 <Tool
    42106                                                         Name="VCCLCompilerTool"
    42107                                                 />
    42108                                         </FileConfiguration>
    42109                                         <FileConfiguration
    42110                                                 Name="Debug_Cairo|Win32"
    42111                                                 ExcludedFromBuild="true"
    42112                                                 >
    42113                                                 <Tool
    42114                                                         Name="VCCLCompilerTool"
    42115                                                 />
    42116                                         </FileConfiguration>
    42117                                         <FileConfiguration
    42118                                                 Name="Release_Cairo|Win32"
    42119                                                 ExcludedFromBuild="true"
    42120                                                 >
    42121                                                 <Tool
    42122                                                         Name="VCCLCompilerTool"
    42123                                                 />
    42124                                         </FileConfiguration>
    42125                                         <FileConfiguration
    42126                                                 Name="Debug_All|Win32"
    42127                                                 ExcludedFromBuild="true"
    42128                                                 >
    42129                                                 <Tool
    42130                                                         Name="VCCLCompilerTool"
    42131                                                 />
    42132                                         </FileConfiguration>
    42133                                 </File>
    42134                                 <File
    42135                                         RelativePath="..\bindings\js\JSDatabaseSyncCustom.cpp"
    42136                                         >
    42137                                         <FileConfiguration
    42138                                                 Name="Debug|Win32"
    42139                                                 ExcludedFromBuild="true"
    42140                                                 >
    42141                                                 <Tool
    42142                                                         Name="VCCLCompilerTool"
    42143                                                 />
    42144                                         </FileConfiguration>
    42145                                         <FileConfiguration
    42146                                                 Name="Release|Win32"
    42147                                                 ExcludedFromBuild="true"
    42148                                                 >
    42149                                                 <Tool
    42150                                                         Name="VCCLCompilerTool"
    42151                                                 />
    42152                                         </FileConfiguration>
    42153                                         <FileConfiguration
    42154                                                 Name="Debug_Internal|Win32"
    42155                                                 ExcludedFromBuild="true"
    42156                                                 >
    42157                                                 <Tool
    42158                                                         Name="VCCLCompilerTool"
    42159                                                 />
    42160                                         </FileConfiguration>
    42161                                         <FileConfiguration
    42162                                                 Name="Debug_Cairo|Win32"
    42163                                                 ExcludedFromBuild="true"
    42164                                                 >
    42165                                                 <Tool
    42166                                                         Name="VCCLCompilerTool"
    42167                                                 />
    42168                                         </FileConfiguration>
    42169                                         <FileConfiguration
    42170                                                 Name="Release_Cairo|Win32"
    42171                                                 ExcludedFromBuild="true"
    42172                                                 >
    42173                                                 <Tool
    42174                                                         Name="VCCLCompilerTool"
    42175                                                 />
    42176                                         </FileConfiguration>
    42177                                         <FileConfiguration
    42178                                                 Name="Debug_All|Win32"
    42179                                                 ExcludedFromBuild="true"
    42180                                                 >
    42181                                                 <Tool
    42182                                                         Name="VCCLCompilerTool"
    42183                                                 />
    42184                                         </FileConfiguration>
    42185                                 </File>
    42186                                 <File
    4218742083                                        RelativePath="..\bindings\js\JSDataGridColumnListCustom.cpp"
    4218842084                                        >
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r64834 r64835  
    43374337                B55D5AA4119131FC00BCC315 /* JSSQLTransactionSyncCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = B55D5AA2119131FC00BCC315 /* JSSQLTransactionSyncCallback.h */; };
    43384338                B55D5AA5119131FC00BCC315 /* JSSQLTransactionSyncCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55D5AA3119131FC00BCC315 /* JSSQLTransactionSyncCallback.cpp */; };
    4339                 B55D5AA81191325000BCC315 /* JSDatabaseSyncCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55D5AA61191325000BCC315 /* JSDatabaseSyncCustom.cpp */; };
    43404339                B55D5AA91191325000BCC315 /* JSSQLTransactionSyncCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55D5AA71191325000BCC315 /* JSSQLTransactionSyncCustom.cpp */; };
    43414340                B56EBA8511C9FF8100B04477 /* SQLException.h in Headers */ = {isa = PBXBuildFile; fileRef = B56EBA8311C9FF8100B04477 /* SQLException.h */; };
     
    47954794                BCCD74DC0A4C8D35005FDA6D /* HTMLViewSourceDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = BCCD74DB0A4C8D35005FDA6D /* HTMLViewSourceDocument.h */; };
    47964795                BCCD74E50A4C8DDF005FDA6D /* HTMLViewSourceDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCCD74E40A4C8DDF005FDA6D /* HTMLViewSourceDocument.cpp */; };
    4797                 BCCE58AC1061E8CF008FB35A /* JSDatabaseCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCCE58AB1061E8CF008FB35A /* JSDatabaseCustom.cpp */; };
    47984796                BCCFBAE80B5152ED0001F1D7 /* DocumentParser.h in Headers */ = {isa = PBXBuildFile; fileRef = BCCFBAE70B5152ED0001F1D7 /* DocumentParser.h */; settings = {ATTRIBUTES = (Private, ); }; };
    47994797                BCD0E0FA0E972C3500265DEA /* SecurityOrigin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCD0E0F70E972C3500265DEA /* SecurityOrigin.cpp */; };
     
    1000610004                B55D5AA2119131FC00BCC315 /* JSSQLTransactionSyncCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSQLTransactionSyncCallback.h; sourceTree = "<group>"; };
    1000710005                B55D5AA3119131FC00BCC315 /* JSSQLTransactionSyncCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSQLTransactionSyncCallback.cpp; sourceTree = "<group>"; };
    10008                 B55D5AA61191325000BCC315 /* JSDatabaseSyncCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDatabaseSyncCustom.cpp; sourceTree = "<group>"; };
    1000910006                B55D5AA71191325000BCC315 /* JSSQLTransactionSyncCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSQLTransactionSyncCustom.cpp; sourceTree = "<group>"; };
    1001010007                B55D5ABB1191327200BCC315 /* DatabaseSync.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DatabaseSync.idl; sourceTree = "<group>"; };
     
    1050110498                BCCD74DB0A4C8D35005FDA6D /* HTMLViewSourceDocument.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HTMLViewSourceDocument.h; sourceTree = "<group>"; };
    1050210499                BCCD74E40A4C8DDF005FDA6D /* HTMLViewSourceDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLViewSourceDocument.cpp; sourceTree = "<group>"; };
    10503                 BCCE58AB1061E8CF008FB35A /* JSDatabaseCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDatabaseCustom.cpp; sourceTree = "<group>"; };
    1050410500                BCCFBAE70B5152ED0001F1D7 /* DocumentParser.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DocumentParser.h; sourceTree = "<group>"; };
    1050510501                BCD0E0F70E972C3500265DEA /* SecurityOrigin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SecurityOrigin.cpp; sourceTree = "<group>"; };
     
    1595015946                                BC5825F20C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp */,
    1595115947                                BC20FB7E0C0E8E6C00D1447F /* JSCSSValueCustom.cpp */,
    15952                                 BCCE58AB1061E8CF008FB35A /* JSDatabaseCustom.cpp */,
    15953                                 B55D5AA61191325000BCC315 /* JSDatabaseSyncCustom.cpp */,
    1595415948                                BC77D1510FF19C730070887B /* JSDataGridColumnListCustom.cpp */,
    1595515949                                4162A453101145E300DFF3ED /* JSDedicatedWorkerContextCustom.cpp */,
     
    2120821202                                1AE82F8F0CAAFA9D002237AE /* JSDatabase.cpp in Sources */,
    2120921203                                B59DD69A119029E5007E9684 /* JSDatabaseCallback.cpp in Sources */,
    21210                                 BCCE58AC1061E8CF008FB35A /* JSDatabaseCustom.cpp in Sources */,
    2121121204                                B58CEB6A11913607002A6790 /* JSDatabaseSync.cpp in Sources */,
    21212                                 B55D5AA81191325000BCC315 /* JSDatabaseSyncCustom.cpp in Sources */,
    2121321205                                BC77D1690FF19F560070887B /* JSDataGridColumn.cpp in Sources */,
    2121421206                                BC77D16B0FF19F560070887B /* JSDataGridColumnList.cpp in Sources */,
  • trunk/WebCore/bindings/js/JSBindingsAllInOne.cpp

    r64738 r64835  
    5858#include "JSDataGridColumnListCustom.cpp"
    5959#include "JSDataGridDataSource.cpp"
    60 #include "JSDatabaseCustom.cpp"
    61 #include "JSDatabaseSyncCustom.cpp"
    6260#include "JSDebugWrapperSet.cpp"
    6361#include "JSDedicatedWorkerContextCustom.cpp"
  • trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r61143 r64835  
    2323#include "AtomicString.h"
    2424#include "Chrome.h"
    25 #include "Database.h"
    2625#include "DOMWindow.h"
    2726#include "Document.h"
     
    3736#include "History.h"
    3837#include "JSAudioConstructor.h"
    39 #if ENABLE(DATABASE)
    40 #include "JSDatabase.h"
    41 #include "JSDatabaseCallback.h"
    42 #endif
    4338#include "JSDOMWindowShell.h"
    4439#include "JSEvent.h"
     
    10071002}
    10081003
    1009 #if ENABLE(DATABASE)
    1010 JSValue JSDOMWindow::openDatabase(ExecState* exec)
    1011 {
    1012     if (!allowsAccessFrom(exec) || (exec->argumentCount() < 4)) {
    1013         setDOMException(exec, SYNTAX_ERR);
    1014         return jsUndefined();
    1015     }
    1016 
    1017     String name = ustringToString(exec->argument(0).toString(exec));
    1018     if (exec->hadException())
    1019         return jsUndefined();
    1020 
    1021     String version = ustringToString(exec->argument(1).toString(exec));
    1022     if (exec->hadException())
    1023         return jsUndefined();
    1024 
    1025     String displayName = ustringToString(exec->argument(2).toString(exec));
    1026     if (exec->hadException())
    1027         return jsUndefined();
    1028 
    1029     // exec->argument(3) = estimated size
    1030     unsigned long estimatedSize = exec->argument(3).toUInt32(exec);
    1031     if (exec->hadException())
    1032         return jsUndefined();
    1033 
    1034     RefPtr<DatabaseCallback> creationCallback;
    1035     if (exec->argumentCount() >= 5) {
    1036         if (!exec->argument(4).isObject()) {
    1037             setDOMException(exec, TYPE_MISMATCH_ERR);
    1038             return jsUndefined();
    1039         }
    1040 
    1041         creationCallback = JSDatabaseCallback::create(asObject(exec->argument(4)), globalObject());
    1042     }
    1043 
    1044     ExceptionCode ec = 0;
    1045     JSValue result = toJS(exec, globalObject(), WTF::getPtr(impl()->openDatabase(name, version, displayName, estimatedSize, creationCallback.release(), ec)));
    1046 
    1047     setDOMException(exec, ec);
    1048     return result;
    1049 }
    1050 #endif
    1051 
    10521004DOMWindow* toDOMWindow(JSValue value)
    10531005{
  • trunk/WebCore/bindings/js/JSWorkerContextCustom.cpp

    r61388 r64835  
    3030#include "JSWorkerContext.h"
    3131
    32 #if ENABLE(DATABASE)
    33 #include "Database.h"
    34 #include "DatabaseSync.h"
    35 #include "JSDatabase.h"
    36 #include "JSDatabaseCallback.h"
    37 #include "JSDatabaseSync.h"
    38 #endif
    3932#include "ExceptionCode.h"
    4033#include "JSDOMBinding.h"
     
    154147#endif
    155148
    156 #if ENABLE(DATABASE)
    157 JSValue JSWorkerContext::openDatabase(ExecState* exec)
    158 {
    159     if (exec->argumentCount() < 4) {
    160         setDOMException(exec, SYNTAX_ERR);
    161         return jsUndefined();
    162     }
    163 
    164     String name = ustringToString(exec->argument(0).toString(exec));
    165     if (exec->hadException())
    166         return jsUndefined();
    167 
    168     String version = ustringToString(exec->argument(1).toString(exec));
    169     if (exec->hadException())
    170         return jsUndefined();
    171 
    172     String displayName = ustringToString(exec->argument(2).toString(exec));
    173     if (exec->hadException())
    174         return jsUndefined();
    175 
    176     // exec->argument(3) = estimated size
    177     unsigned long estimatedSize = exec->argument(3).toUInt32(exec);
    178     if (exec->hadException())
    179         return jsUndefined();
    180 
    181     RefPtr<DatabaseCallback> creationCallback;
    182     if (exec->argumentCount() >= 5) {
    183         if (!exec->argument(4).isObject()) {
    184             setDOMException(exec, TYPE_MISMATCH_ERR);
    185             return jsUndefined();
    186         }
    187 
    188         creationCallback = JSDatabaseCallback::create(asObject(exec->argument(4)), globalObject());
    189     }
    190  
    191     ExceptionCode ec = 0;
    192     JSValue result = toJS(exec, globalObject(), WTF::getPtr(impl()->openDatabase(name, version, displayName, estimatedSize, creationCallback.release(), ec)));
    193     setDOMException(exec, ec);
    194     return result;
    195 }
    196  
    197 JSValue JSWorkerContext::openDatabaseSync(ExecState* exec)
    198 {
    199     if (exec->argumentCount() < 4) {
    200         setDOMException(exec, SYNTAX_ERR);
    201         return jsUndefined();
    202     }
    203 
    204     String name = ustringToString(exec->argument(0).toString(exec));
    205     if (exec->hadException())
    206         return jsUndefined();
    207 
    208     String version = ustringToString(exec->argument(1).toString(exec));
    209     if (exec->hadException())
    210         return jsUndefined();
    211 
    212     String displayName = ustringToString(exec->argument(2).toString(exec));
    213     if (exec->hadException())
    214         return jsUndefined();
    215 
    216     // exec->argument(3) = estimated size
    217     unsigned long estimatedSize = exec->argument(3).toUInt32(exec);
    218     if (exec->hadException())
    219         return jsUndefined();
    220 
    221     RefPtr<DatabaseCallback> creationCallback;
    222     if (exec->argumentCount() >= 5) {
    223         if (!exec->argument(4).isObject()) {
    224             setDOMException(exec, TYPE_MISMATCH_ERR);
    225             return jsUndefined();
    226         }
    227 
    228         creationCallback = JSDatabaseCallback::create(asObject(exec->argument(4)), globalObject());
    229     }
    230 
    231     ExceptionCode ec = 0;
    232     JSValue result = toJS(exec, globalObject(), WTF::getPtr(impl()->openDatabaseSync(name, version, displayName, estimatedSize, creationCallback.release(), ec)));
    233 
    234     setDOMException(exec, ec);
    235     return result;
    236 }
    237 #endif
    238 
    239149} // namespace WebCore
    240150
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r64642 r64835  
    19101910
    19111911                    foreach my $parameter (@{$function->parameters}) {
     1912                        push(@implContent, "\n");
    19121913                        if ($parameter->extendedAttributes->{"Optional"}) {
    1913                             # Generate early call if there are enough parameters.
    1914                             if (!$hasOptionalArguments) {
    1915                                 push(@implContent, "\n    int argsCount = exec->argumentCount();\n");
    1916                                 $hasOptionalArguments = 1;
     1914                            # Optional callbacks should be handled differently because:
     1915                            # - they always have a default value: 0
     1916                            # - it reduces the number of overloaded functions with different number of parameters
     1917                            if (!$parameter->extendedAttributes->{"Callback"}) {
     1918                                # Generate early call if there are enough parameters.
     1919                                if (!$hasOptionalArguments) {
     1920                                    push(@implContent, "    int argsCount = exec->argumentCount();\n");
     1921                                    $hasOptionalArguments = 1;
     1922                                }
     1923                                push(@implContent, "    if (argsCount <= $argsIndex) {\n");
     1924                                GenerateImplementationFunctionCall($function, $functionString, $paramIndex, "    " x 2, $podType, $implClassName);
     1925                                push(@implContent, "    }\n");
    19171926                            }
    1918                             push(@implContent, "    if (argsCount < " . ($argsIndex + 1) . ") {\n");
    1919                             GenerateImplementationFunctionCall($function, $functionString, $paramIndex, "    " x 2, $podType, $implClassName);
    1920                             push(@implContent, "    }\n\n");
     1927                        } else {
     1928                            push(@implContent, "    if (exec->argumentCount() <= $argsIndex) {\n");
     1929                            push(@implContent, "        setDOMException(exec, TYPE_MISMATCH_ERR);\n");
     1930                            push(@implContent, "        return JSValue::encode(jsUndefined());\n");
     1931                            push(@implContent, "    }\n");
    19211932                        }
    19221933
     
    19361947                            $implIncludes{"$callbackClassName.h"} = 1;
    19371948                            $implIncludes{"ExceptionCode.h"} = 1;
    1938                             push(@implContent, "    if (exec->argumentCount() <= $argsIndex || !exec->argument($argsIndex).isObject()) {\n");
    1939                             push(@implContent, "        setDOMException(exec, TYPE_MISMATCH_ERR);\n");
    1940                             push(@implContent, "        return jsUndefined();\n");
    1941                             push(@implContent, "    }\n");
    1942                             push(@implContent, "    RefPtr<" . $parameter->type . "> $name = " . $callbackClassName . "::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n");
     1949                            if ($parameter->extendedAttributes->{"Optional"}) {
     1950                                push(@implContent, "    RefPtr<" . $parameter->type . "> $name;\n");
     1951                                push(@implContent, "    if (exec->argumentCount() > $argsIndex && exec->argument($argsIndex).isObject()) {\n");
     1952                                push(@implContent, "        JSObject* object = exec->argument($argsIndex).getObject();\n");
     1953                                push(@implContent, "        if (!object) {\n");
     1954                                push(@implContent, "            setDOMException(exec, TYPE_MISMATCH_ERR);\n");
     1955                                push(@implContent, "            return JSValue::encode(jsUndefined());\n");
     1956                                push(@implContent, "        }\n");
     1957                                push(@implContent, "        $name = ${callbackClassName}::create(object, castedThis->globalObject());\n");
     1958                                push(@implContent, "    }\n");
     1959                            } else {
     1960                                push(@implContent, "    if (!exec->argument($argsIndex).isObject() || !exec->argument($argsIndex).getObject()) {\n");
     1961                                push(@implContent, "        setDOMException(exec, TYPE_MISMATCH_ERR);\n");
     1962                                push(@implContent, "        return JSValue::encode(jsUndefined());\n");
     1963                                push(@implContent, "    }\n");
     1964                                push(@implContent, "    RefPtr<" . $parameter->type . "> $name = " . $callbackClassName . "::create(exec->argument($argsIndex).getObject(), castedThis->globalObject());\n");
     1965                            }
    19431966                        } else {
    19441967                            push(@implContent, "    " . GetNativeTypeFromSignature($parameter) . " $name = " . JSValueToNative($parameter, "exec->argument($argsIndex)") . ";\n");
     
    19541977                                push(@implContent, "    }\n");
    19551978                            }
     1979                        }
     1980
     1981                        # Callback parameters have their special error checking code.
     1982                        if (!$parameter->extendedAttributes->{"Callback"}) {
     1983                            push(@implContent, "    if (exec->hadException())\n");
     1984                            push(@implContent, "        return JSValue::encode(jsUndefined());\n");
    19561985                        }
    19571986
     
    23442373    return "$value.toNumber(exec)" if $type eq "double";
    23452374    return "$value.toFloat(exec)" if $type eq "float" or $type eq "SVGNumber";
    2346     return "$value.toInt32(exec)" if $type eq "unsigned long" or $type eq "long" or $type eq "unsigned short";
     2375    return "$value.toInt32(exec)" if $type eq "long";
     2376    return "$value.toUInt32(exec)" if $type eq "unsigned long" or $type eq "unsigned short";
    23472377    return "static_cast<$type>($value.toInteger(exec))" if $type eq "long long" or $type eq "unsigned long long";
    23482378
  • trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r64537 r64835  
    11771177
    11781178        if ($parameter->extendedAttributes->{"Optional"}) {
    1179             # Generate early call if there are not enough parameters.
    1180             push(@implContentDecls, "    if (args.Length() <= $paramIndex) {\n");
    1181             my $functionCall = GenerateFunctionCallString($function, $paramIndex, "    " x 2, $implClassName);
    1182             push(@implContentDecls, $functionCall);
    1183             push(@implContentDecls, "    }\n");
    1184         }
    1185 
     1179            # Optional callbacks should be handled differently because:
     1180            # - they always have a default value: 0
     1181            # - it reduces the number of overloaded functions with different number of parameters
     1182            if (!$parameter->extendedAttributes->{"Callback"}) {
     1183                # Generate early call if there are not enough parameters.
     1184                push(@implContentDecls, "    if (args.Length() <= $paramIndex) {\n");
     1185                my $functionCall = GenerateFunctionCallString($function, $paramIndex, "    " x 2, $implClassName);
     1186                push(@implContentDecls, $functionCall);
     1187                push(@implContentDecls, "    }\n");
     1188            }
     1189        } else {
     1190          push(@implContentDecls, "    if (args.Length() <= $paramIndex)\n");
     1191          push(@implContentDecls, "        return throwError(TYPE_MISMATCH_ERR);\n");
     1192        }
     1193
     1194        if (BasicTypeCanFailConversion($parameter)) {
     1195            push(@implContentDecls, "    bool ${parameterName}Ok;\n");
     1196        }
     1197
     1198        my $nativeType = GetNativeTypeFromSignature($parameter, $paramIndex);
    11861199        if ($parameter->extendedAttributes->{"Callback"}) {
    11871200            my $className = GetCallbackClassName($parameter->type);
    11881201            $implIncludes{"$className.h"} = 1;
    11891202            $implIncludes{"ExceptionCode.h"} = 1;
    1190             push(@implContentDecls, "    if (args.Length() <= $paramIndex || !args[$paramIndex]->IsObject())\n");
    1191             push(@implContentDecls, "        return throwError(TYPE_MISMATCH_ERR);\n");
    1192             push(@implContentDecls, "    RefPtr<" . $parameter->type . "> $parameterName = ${className}::create(args[$paramIndex], getScriptExecutionContext());\n");
     1203            if ($parameter->extendedAttributes->{"Optional"}) {
     1204                push(@implContentDecls, "    RefPtr<" . $parameter->type . "> $parameterName;\n");
     1205                push(@implContentDecls, "    if (args.Length() > $paramIndex && args[$paramIndex]->IsObject())\n");
     1206                push(@implContentDecls, "        $parameterName = ${className}::create(args[$paramIndex], getScriptExecutionContext());\n");
     1207            } else {
     1208                push(@implContentDecls, "    if (!args[$paramIndex]->IsObject())\n");
     1209                push(@implContentDecls, "        return throwError(TYPE_MISMATCH_ERR);\n");
     1210                push(@implContentDecls, "    RefPtr<" . $parameter->type . "> $parameterName = ${className}::create(args[$paramIndex], getScriptExecutionContext());\n");
     1211            }
    11931212            $paramIndex++;
    11941213            next;
    1195         }
    1196 
    1197         if ($parameter->type eq "SerializedScriptValue") {
     1214        } elsif ($parameter->type eq "SerializedScriptValue") {
    11981215            $implIncludes{"SerializedScriptValue.h"} = 1;
    11991216            push(@implContentDecls, "    bool ${parameterName}DidThrow = false;\n");
    1200         } elsif (BasicTypeCanFailConversion($parameter)) {
    1201             push(@implContentDecls, "    bool ${parameterName}Ok;\n");
    1202         }
    1203 
    1204         push(@implContentDecls, "    " . GetNativeTypeFromSignature($parameter, $paramIndex) . " $parameterName = ");
    1205 
    1206         if ($parameter->type eq "SerializedScriptValue") {
    1207             push(@implContentDecls, "SerializedScriptValue::create(args[$paramIndex], ${parameterName}DidThrow);\n");
     1217            push(@implContentDecls, "    $nativeType $parameterName = SerializedScriptValue::create(args[$paramIndex], ${parameterName}DidThrow);\n");
    12081218            push(@implContentDecls, "    if (${parameterName}DidThrow)\n");
    12091219            push(@implContentDecls, "        return v8::Undefined();\n");
     1220        } elsif (TypeCanFailConversion($parameter)) {
     1221            $implIncludes{"ExceptionCode.h"} = 1;
     1222            push(@implContentDecls, "    $nativeType $parameterName = " .
     1223                 JSValueToNative($parameter, "args[$paramIndex]",
     1224                                 BasicTypeCanFailConversion($parameter) ? "${parameterName}Ok" : undef) . ";\n");
     1225            push(@implContentDecls, "    if (UNLIKELY(!$parameterName" . (BasicTypeCanFailConversion($parameter) ? "Ok" : "") . ")) {\n");
     1226            push(@implContentDecls, "        ec = TYPE_MISMATCH_ERR;\n");
     1227            push(@implContentDecls, "        goto fail;\n");
     1228            push(@implContentDecls, "    }\n");
     1229        } elsif ($nativeType =~ /^V8Parameter/) {
     1230            # Exceptions are handled in V8Parameter's operators.
     1231            push(@implContentDecls, "    $nativeType $parameterName = " .
     1232                 JSValueToNative($parameter, "args[$paramIndex]",
     1233                                 BasicTypeCanFailConversion($parameter) ? "{$parameterName}Ok" : undef) . ";\n");
    12101234        } else {
    1211             push(@implContentDecls, JSValueToNative($parameter, "args[$paramIndex]",
    1212                                                     BasicTypeCanFailConversion($parameter) ?  "${parameterName}Ok" : undef) . ";\n");
    1213         }
    1214 
    1215         if (TypeCanFailConversion($parameter)) {
    1216             $implIncludes{"ExceptionCode.h"} = 1;
    1217             push(@implContentDecls,
    1218 "    if (UNLIKELY(!$parameterName" . (BasicTypeCanFailConversion($parameter) ? "Ok" : "") . ")) {\n" .
    1219 "        ec = TYPE_MISMATCH_ERR;\n" .
    1220 "        goto fail;\n" .
    1221 "    }\n");
     1235            $implIncludes{"V8BindingMacros.h"} = 1;
     1236            push(@implContentDecls, "    EXCEPTION_BLOCK($nativeType, $parameterName, " .
     1237                 JSValueToNative($parameter, "args[$paramIndex]",
     1238                                 BasicTypeCanFailConversion($parameter) ? "{$parameterName}Ok" : undef) . ");\n");
    12221239        }
    12231240
    12241241        if ($parameter->extendedAttributes->{"IsIndex"}) {
    12251242            $implIncludes{"ExceptionCode.h"} = 1;
    1226             push(@implContentDecls,
    1227 "    if (UNLIKELY($parameterName < 0)) {\n" .
    1228 "        ec = INDEX_SIZE_ERR;\n" .
    1229 "        goto fail;\n" .
    1230 "    }\n");
     1243            push(@implContentDecls, "    if (UNLIKELY($parameterName < 0)) {\n");
     1244            push(@implContentDecls, "        ec = INDEX_SIZE_ERR;\n");
     1245            push(@implContentDecls, "        goto fail;\n");
     1246            push(@implContentDecls, "    }\n");
    12311247        }
    12321248
     
    28262842    return "$value->NumberValue()" if $type eq "SVGNumber";
    28272843
    2828     return "toInt32($value${maybeOkParam})" if $type eq "unsigned long" or $type eq "unsigned short" or $type eq "long";
     2844    return "toInt32($value${maybeOkParam})" if $type eq "long";
     2845    return "toUInt32($value${maybeOkParam})" if $type eq "unsigned long" or $type eq "unsigned short";
    28292846    return "toInt64($value)" if $type eq "unsigned long long" or $type eq "long long";
    28302847    return "static_cast<Range::CompareHow>($value->Int32Value())" if $type eq "CompareHow";
     
    29562973
    29572974    foreach my $parameter (@{$function->parameters}) {
    2958         if ($parameter->extendedAttributes->{"Optional"}) {
     2975        if ($parameter->extendedAttributes->{"Optional"} ||
     2976            $parameter->extendedAttributes->{"Callback"}) {
    29592977            return 0;
    29602978        }
  • trunk/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp

    r64537 r64835  
    4343JSTestCallback::~JSTestCallback()
    4444{
    45     if (m_scriptExecutionContext->isContextThread())
     45    ScriptExecutionContext* context = scriptExecutionContext();
     46    // When the context is destroyed, all tasks with a reference to a callback
     47    // should be deleted. So if the context is NULL, we are on the context thread.
     48    if (!context || context->isContextThread())
    4649        delete m_data;
    4750    else
    48         m_data->globalObject()->scriptExecutionContext()->postTask(DeleteCallbackDataTask::create(m_data));
     51        context->postTask(DeleteCallbackDataTask::create(m_data));
    4952#ifndef NDEBUG
    5053    m_data = 0;
  • trunk/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r64415 r64835  
    794794    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
    795795    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
     796
     797    if (exec->argumentCount() <= 0) {
     798        setDOMException(exec, TYPE_MISMATCH_ERR);
     799        return JSValue::encode(jsUndefined());
     800    }
    796801    int intArg = exec->argument(0).toInt32(exec);
     802    if (exec->hadException())
     803        return JSValue::encode(jsUndefined());
     804
     805    if (exec->argumentCount() <= 1) {
     806        setDOMException(exec, TYPE_MISMATCH_ERR);
     807        return JSValue::encode(jsUndefined());
     808    }
    797809    const String& strArg = ustringToString(exec->argument(1).toString(exec));
     810    if (exec->hadException())
     811        return JSValue::encode(jsUndefined());
     812
     813    if (exec->argumentCount() <= 2) {
     814        setDOMException(exec, TYPE_MISMATCH_ERR);
     815        return JSValue::encode(jsUndefined());
     816    }
    798817    TestObj* objArg = toTestObj(exec->argument(2));
     818    if (exec->hadException())
     819        return JSValue::encode(jsUndefined());
    799820
    800821    imp->voidMethodWithArgs(intArg, strArg, objArg);
     
    822843    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
    823844    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
     845
     846    if (exec->argumentCount() <= 0) {
     847        setDOMException(exec, TYPE_MISMATCH_ERR);
     848        return JSValue::encode(jsUndefined());
     849    }
    824850    int intArg = exec->argument(0).toInt32(exec);
     851    if (exec->hadException())
     852        return JSValue::encode(jsUndefined());
     853
     854    if (exec->argumentCount() <= 1) {
     855        setDOMException(exec, TYPE_MISMATCH_ERR);
     856        return JSValue::encode(jsUndefined());
     857    }
    825858    const String& strArg = ustringToString(exec->argument(1).toString(exec));
     859    if (exec->hadException())
     860        return JSValue::encode(jsUndefined());
     861
     862    if (exec->argumentCount() <= 2) {
     863        setDOMException(exec, TYPE_MISMATCH_ERR);
     864        return JSValue::encode(jsUndefined());
     865    }
    826866    TestObj* objArg = toTestObj(exec->argument(2));
     867    if (exec->hadException())
     868        return JSValue::encode(jsUndefined());
    827869
    828870
     
    851893    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
    852894    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
     895
     896    if (exec->argumentCount() <= 0) {
     897        setDOMException(exec, TYPE_MISMATCH_ERR);
     898        return JSValue::encode(jsUndefined());
     899    }
    853900    int intArg = exec->argument(0).toInt32(exec);
     901    if (exec->hadException())
     902        return JSValue::encode(jsUndefined());
     903
     904    if (exec->argumentCount() <= 1) {
     905        setDOMException(exec, TYPE_MISMATCH_ERR);
     906        return JSValue::encode(jsUndefined());
     907    }
    854908    const String& strArg = ustringToString(exec->argument(1).toString(exec));
     909    if (exec->hadException())
     910        return JSValue::encode(jsUndefined());
     911
     912    if (exec->argumentCount() <= 2) {
     913        setDOMException(exec, TYPE_MISMATCH_ERR);
     914        return JSValue::encode(jsUndefined());
     915    }
    855916    TestObj* objArg = toTestObj(exec->argument(2));
     917    if (exec->hadException())
     918        return JSValue::encode(jsUndefined());
    856919
    857920
     
    869932    if (exec->argumentCount() < 2)
    870933        return JSValue::encode(jsUndefined());
     934
     935    if (exec->argumentCount() <= 0) {
     936        setDOMException(exec, TYPE_MISMATCH_ERR);
     937        return JSValue::encode(jsUndefined());
     938    }
    871939    const String& strArg = ustringToString(exec->argument(0).toString(exec));
     940    if (exec->hadException())
     941        return JSValue::encode(jsUndefined());
     942
     943    if (exec->argumentCount() <= 1) {
     944        setDOMException(exec, TYPE_MISMATCH_ERR);
     945        return JSValue::encode(jsUndefined());
     946    }
    872947    TestObj* objArg = toTestObj(exec->argument(1));
     948    if (exec->hadException())
     949        return JSValue::encode(jsUndefined());
    873950
    874951
     
    887964        return throwVMError(exec, createSyntaxError(exec, "Not enough arguments"));
    888965    ExceptionCode ec = 0;
     966
     967    if (exec->argumentCount() <= 0) {
     968        setDOMException(exec, TYPE_MISMATCH_ERR);
     969        return JSValue::encode(jsUndefined());
     970    }
    889971    const String& strArg = ustringToString(exec->argument(0).toString(exec));
     972    if (exec->hadException())
     973        return JSValue::encode(jsUndefined());
     974
     975    if (exec->argumentCount() <= 1) {
     976        setDOMException(exec, TYPE_MISMATCH_ERR);
     977        return JSValue::encode(jsUndefined());
     978    }
    890979    TestObj* objArg = toTestObj(exec->argument(1));
     980    if (exec->hadException())
     981        return JSValue::encode(jsUndefined());
    891982
    892983
     
    903994    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
    904995    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
     996
     997    if (exec->argumentCount() <= 0) {
     998        setDOMException(exec, TYPE_MISMATCH_ERR);
     999        return JSValue::encode(jsUndefined());
     1000    }
    9051001    RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(exec, exec->argument(0));
     1002    if (exec->hadException())
     1003        return JSValue::encode(jsUndefined());
    9061004
    9071005    imp->serializedValue(serializedArg);
     
    9161014    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
    9171015    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
     1016
     1017    if (exec->argumentCount() <= 0) {
     1018        setDOMException(exec, TYPE_MISMATCH_ERR);
     1019        return JSValue::encode(jsUndefined());
     1020    }
    9181021    RefPtr<IDBKey> key = createIDBKeyFromValue(exec, exec->argument(0));
     1022    if (exec->hadException())
     1023        return JSValue::encode(jsUndefined());
    9191024
    9201025    imp->idbKey(key);
     
    9631068    ExceptionCode ec = 0;
    9641069    ScriptCallStack callStack(exec, 1);
     1070
     1071    if (exec->argumentCount() <= 0) {
     1072        setDOMException(exec, TYPE_MISMATCH_ERR);
     1073        return JSValue::encode(jsUndefined());
     1074    }
    9651075    log* intArg = tolog(exec->argument(0));
     1076    if (exec->hadException())
     1077        return JSValue::encode(jsUndefined());
    9661078
    9671079    imp->customArgsAndException(intArg, &callStack, ec);
     
    10231135    if (!dynamicFrame)
    10241136        return JSValue::encode(jsUndefined());
     1137
     1138    if (exec->argumentCount() <= 0) {
     1139        setDOMException(exec, TYPE_MISMATCH_ERR);
     1140        return JSValue::encode(jsUndefined());
     1141    }
    10251142    int intArg = exec->argument(0).toInt32(exec);
     1143    if (exec->hadException())
     1144        return JSValue::encode(jsUndefined());
    10261145
    10271146    imp->withDynamicFrameAndArg(dynamicFrame, intArg);
     
    10391158    if (!dynamicFrame)
    10401159        return JSValue::encode(jsUndefined());
     1160
     1161    if (exec->argumentCount() <= 0) {
     1162        setDOMException(exec, TYPE_MISMATCH_ERR);
     1163        return JSValue::encode(jsUndefined());
     1164    }
    10411165    int intArg = exec->argument(0).toInt32(exec);
     1166    if (exec->hadException())
     1167        return JSValue::encode(jsUndefined());
    10421168
    10431169    int argsCount = exec->argumentCount();
    1044     if (argsCount < 2) {
     1170    if (argsCount <= 1) {
    10451171        imp->withDynamicFrameAndOptionalArg(dynamicFrame, intArg);
    10461172        return JSValue::encode(jsUndefined());
    10471173    }
    1048 
    10491174    int optionalArg = exec->argument(1).toInt32(exec);
     1175    if (exec->hadException())
     1176        return JSValue::encode(jsUndefined());
    10501177
    10511178    imp->withDynamicFrameAndOptionalArg(dynamicFrame, intArg, optionalArg);
     
    10631190    if (!dynamicFrame)
    10641191        return JSValue::encode(jsUndefined());
     1192
     1193    if (exec->argumentCount() <= 0) {
     1194        setDOMException(exec, TYPE_MISMATCH_ERR);
     1195        return JSValue::encode(jsUndefined());
     1196    }
    10651197    int intArg = exec->argument(0).toInt32(exec);
     1198    if (exec->hadException())
     1199        return JSValue::encode(jsUndefined());
    10661200
    10671201    imp->withDynamicFrameAndUserGesture(dynamicFrame, intArg, processingUserGesture(exec));
     
    10791213    if (!dynamicFrame)
    10801214        return JSValue::encode(jsUndefined());
     1215
     1216    if (exec->argumentCount() <= 0) {
     1217        setDOMException(exec, TYPE_MISMATCH_ERR);
     1218        return JSValue::encode(jsUndefined());
     1219    }
    10811220    int intArg = exec->argument(0).toInt32(exec);
     1221    if (exec->hadException())
     1222        return JSValue::encode(jsUndefined());
    10821223
    10831224    int argsCount = exec->argumentCount();
    1084     if (argsCount < 2) {
     1225    if (argsCount <= 1) {
    10851226        imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg);
    10861227        return JSValue::encode(jsUndefined());
    10871228    }
    1088 
    10891229    int optionalArg = exec->argument(1).toInt32(exec);
     1230    if (exec->hadException())
     1231        return JSValue::encode(jsUndefined());
    10901232
    10911233    imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg, optionalArg, processingUserGesture(exec));
     
    11751317
    11761318    int argsCount = exec->argumentCount();
    1177     if (argsCount < 1) {
     1319    if (argsCount <= 0) {
    11781320        imp->methodWithOptionalArg();
    11791321        return JSValue::encode(jsUndefined());
    11801322    }
    1181 
    11821323    int opt = exec->argument(0).toInt32(exec);
     1324    if (exec->hadException())
     1325        return JSValue::encode(jsUndefined());
    11831326
    11841327    imp->methodWithOptionalArg(opt);
     
    11931336    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
    11941337    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
     1338
     1339    if (exec->argumentCount() <= 0) {
     1340        setDOMException(exec, TYPE_MISMATCH_ERR);
     1341        return JSValue::encode(jsUndefined());
     1342    }
    11951343    int nonOpt = exec->argument(0).toInt32(exec);
     1344    if (exec->hadException())
     1345        return JSValue::encode(jsUndefined());
    11961346
    11971347    int argsCount = exec->argumentCount();
    1198     if (argsCount < 2) {
     1348    if (argsCount <= 1) {
    11991349        imp->methodWithNonOptionalArgAndOptionalArg(nonOpt);
    12001350        return JSValue::encode(jsUndefined());
    12011351    }
    1202 
    12031352    int opt = exec->argument(1).toInt32(exec);
     1353    if (exec->hadException())
     1354        return JSValue::encode(jsUndefined());
    12041355
    12051356    imp->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt);
     
    12141365    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
    12151366    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
     1367
     1368    if (exec->argumentCount() <= 0) {
     1369        setDOMException(exec, TYPE_MISMATCH_ERR);
     1370        return JSValue::encode(jsUndefined());
     1371    }
    12161372    int nonOpt = exec->argument(0).toInt32(exec);
     1373    if (exec->hadException())
     1374        return JSValue::encode(jsUndefined());
    12171375
    12181376    int argsCount = exec->argumentCount();
    1219     if (argsCount < 2) {
     1377    if (argsCount <= 1) {
    12201378        imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt);
    12211379        return JSValue::encode(jsUndefined());
    12221380    }
    1223 
    12241381    int opt1 = exec->argument(1).toInt32(exec);
     1382    if (exec->hadException())
     1383        return JSValue::encode(jsUndefined());
     1384
     1385    if (argsCount <= 2) {
     1386        imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1);
     1387        return JSValue::encode(jsUndefined());
     1388    }
    12251389    int opt2 = exec->argument(2).toInt32(exec);
     1390    if (exec->hadException())
     1391        return JSValue::encode(jsUndefined());
    12261392
    12271393    imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2);
     
    12361402    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
    12371403    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
    1238     if (exec->argumentCount() <= 0 || !exec->argument(0).isObject()) {
    1239         setDOMException(exec, TYPE_MISMATCH_ERR);
    1240         return jsUndefined();
    1241     }
    1242     RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject());
     1404
     1405    if (exec->argumentCount() <= 0) {
     1406        setDOMException(exec, TYPE_MISMATCH_ERR);
     1407        return JSValue::encode(jsUndefined());
     1408    }
     1409    if (!exec->argument(0).isObject() || !exec->argument(0).getObject()) {
     1410        setDOMException(exec, TYPE_MISMATCH_ERR);
     1411        return JSValue::encode(jsUndefined());
     1412    }
     1413    RefPtr<TestCallback> callback = JSTestCallback::create(exec->argument(0).getObject(), castedThis->globalObject());
    12431414
    12441415    imp->methodWithCallbackArg(callback);
     
    12531424    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
    12541425    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
     1426
     1427    if (exec->argumentCount() <= 0) {
     1428        setDOMException(exec, TYPE_MISMATCH_ERR);
     1429        return JSValue::encode(jsUndefined());
     1430    }
    12551431    int nonCallback = exec->argument(0).toInt32(exec);
    1256     if (exec->argumentCount() <= 1 || !exec->argument(1).isObject()) {
    1257         setDOMException(exec, TYPE_MISMATCH_ERR);
    1258         return jsUndefined();
    1259     }
    1260     RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(1)), castedThis->globalObject());
     1432    if (exec->hadException())
     1433        return JSValue::encode(jsUndefined());
     1434
     1435    if (exec->argumentCount() <= 1) {
     1436        setDOMException(exec, TYPE_MISMATCH_ERR);
     1437        return JSValue::encode(jsUndefined());
     1438    }
     1439    if (!exec->argument(1).isObject() || !exec->argument(1).getObject()) {
     1440        setDOMException(exec, TYPE_MISMATCH_ERR);
     1441        return JSValue::encode(jsUndefined());
     1442    }
     1443    RefPtr<TestCallback> callback = JSTestCallback::create(exec->argument(1).getObject(), castedThis->globalObject());
    12611444
    12621445    imp->methodWithNonCallbackArgAndCallbackArg(nonCallback, callback);
     
    12721455    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
    12731456
     1457    RefPtr<TestCallback> callback;
     1458    if (exec->argumentCount() > 0 && exec->argument(0).isObject()) {
     1459        JSObject* object = exec->argument(0).getObject();
     1460        if (!object) {
     1461            setDOMException(exec, TYPE_MISMATCH_ERR);
     1462            return JSValue::encode(jsUndefined());
     1463        }
     1464        callback = JSTestCallback::create(object, castedThis->globalObject());
     1465    }
     1466
     1467    imp->methodWithCallbackAndOptionalArg(callback);
     1468    return JSValue::encode(jsUndefined());
     1469}
     1470
     1471static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod1(ExecState* exec)
     1472{
     1473    JSValue thisValue = exec->hostThisValue();
     1474    if (!thisValue.inherits(&JSTestObj::s_info))
     1475        return throwVMTypeError(exec);
     1476    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
     1477    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
     1478
     1479    if (exec->argumentCount() <= 0) {
     1480        setDOMException(exec, TYPE_MISMATCH_ERR);
     1481        return JSValue::encode(jsUndefined());
     1482    }
     1483    TestObj* objArg = toTestObj(exec->argument(0));
     1484    if (exec->hadException())
     1485        return JSValue::encode(jsUndefined());
     1486
     1487    if (exec->argumentCount() <= 1) {
     1488        setDOMException(exec, TYPE_MISMATCH_ERR);
     1489        return JSValue::encode(jsUndefined());
     1490    }
     1491    const String& strArg = ustringToString(exec->argument(1).toString(exec));
     1492    if (exec->hadException())
     1493        return JSValue::encode(jsUndefined());
     1494
     1495    imp->overloadedMethod(objArg, strArg);
     1496    return JSValue::encode(jsUndefined());
     1497}
     1498
     1499static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod2(ExecState* exec)
     1500{
     1501    JSValue thisValue = exec->hostThisValue();
     1502    if (!thisValue.inherits(&JSTestObj::s_info))
     1503        return throwVMTypeError(exec);
     1504    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
     1505    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
     1506
     1507    if (exec->argumentCount() <= 0) {
     1508        setDOMException(exec, TYPE_MISMATCH_ERR);
     1509        return JSValue::encode(jsUndefined());
     1510    }
     1511    TestObj* objArg = toTestObj(exec->argument(0));
     1512    if (exec->hadException())
     1513        return JSValue::encode(jsUndefined());
     1514
    12741515    int argsCount = exec->argumentCount();
    1275     if (argsCount < 1) {
    1276         imp->methodWithCallbackAndOptionalArg();
    1277         return JSValue::encode(jsUndefined());
    1278     }
    1279 
    1280     if (exec->argumentCount() <= 0 || !exec->argument(0).isObject()) {
    1281         setDOMException(exec, TYPE_MISMATCH_ERR);
    1282         return jsUndefined();
    1283     }
    1284     RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject());
    1285 
    1286     imp->methodWithCallbackAndOptionalArg(callback);
    1287     return JSValue::encode(jsUndefined());
    1288 }
    1289 
    1290 static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod1(ExecState* exec)
    1291 {
    1292     JSValue thisValue = exec->hostThisValue();
    1293     if (!thisValue.inherits(&JSTestObj::s_info))
    1294         return throwVMTypeError(exec);
    1295     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
    1296     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
    1297     TestObj* objArg = toTestObj(exec->argument(0));
    1298     const String& strArg = ustringToString(exec->argument(1).toString(exec));
    1299 
    1300     imp->overloadedMethod(objArg, strArg);
    1301     return JSValue::encode(jsUndefined());
    1302 }
    1303 
    1304 static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod2(ExecState* exec)
    1305 {
    1306     JSValue thisValue = exec->hostThisValue();
    1307     if (!thisValue.inherits(&JSTestObj::s_info))
    1308         return throwVMTypeError(exec);
    1309     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
    1310     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
    1311     TestObj* objArg = toTestObj(exec->argument(0));
    1312 
    1313     int argsCount = exec->argumentCount();
    1314     if (argsCount < 2) {
     1516    if (argsCount <= 1) {
    13151517        imp->overloadedMethod(objArg);
    13161518        return JSValue::encode(jsUndefined());
    13171519    }
    1318 
    13191520    int intArg = exec->argument(1).toInt32(exec);
     1521    if (exec->hadException())
     1522        return JSValue::encode(jsUndefined());
    13201523
    13211524    imp->overloadedMethod(objArg, intArg);
     
    13301533    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
    13311534    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
     1535
     1536    if (exec->argumentCount() <= 0) {
     1537        setDOMException(exec, TYPE_MISMATCH_ERR);
     1538        return JSValue::encode(jsUndefined());
     1539    }
    13321540    const String& strArg = ustringToString(exec->argument(0).toString(exec));
     1541    if (exec->hadException())
     1542        return JSValue::encode(jsUndefined());
    13331543
    13341544    imp->overloadedMethod(strArg);
     
    13431553    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
    13441554    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
     1555
     1556    if (exec->argumentCount() <= 0) {
     1557        setDOMException(exec, TYPE_MISMATCH_ERR);
     1558        return JSValue::encode(jsUndefined());
     1559    }
    13451560    int intArg = exec->argument(0).toInt32(exec);
     1561    if (exec->hadException())
     1562        return JSValue::encode(jsUndefined());
    13461563
    13471564    imp->overloadedMethod(intArg);
  • trunk/WebCore/bindings/scripts/test/TestObj.idl

    r64415 r64835  
    113113        void    methodWithOptionalArg(in [Optional] long opt);
    114114        void    methodWithNonOptionalArgAndOptionalArg(in long nonOpt, in [Optional] long opt);
    115         void    methodWithNonOptionalArgAndTwoOptionalArgs(in long nonOpt, in [Optional] long opt1, in long opt2);
     115        void    methodWithNonOptionalArgAndTwoOptionalArgs(in long nonOpt, in [Optional] long opt1, in [Optional] long opt2);
    116116
    117117#if defined(TESTING_V8) || defined(TESTING_JS)
  • trunk/WebCore/bindings/scripts/test/V8/V8TestObj.cpp

    r64537 r64835  
    3030#include "SerializedScriptValue.h"
    3131#include "V8Binding.h"
     32#include "V8BindingMacros.h"
    3233#include "V8BindingState.h"
    3334#include "V8DOMWrapper.h"
     
    557558    INC_STATS("DOM.TestObj.voidMethodWithArgs");
    558559    TestObj* imp = V8TestObj::toNative(args.Holder());
    559     int intArg = toInt32(args[0]);
     560    if (args.Length() <= 0)
     561        return throwError(TYPE_MISMATCH_ERR);
     562    EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
     563    if (args.Length() <= 1)
     564        return throwError(TYPE_MISMATCH_ERR);
    560565    V8Parameter<> strArg = args[1];
    561     TestObj* objArg = V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0;
     566    if (args.Length() <= 2)
     567        return throwError(TYPE_MISMATCH_ERR);
     568    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0);
    562569    imp->voidMethodWithArgs(intArg, strArg, objArg);
    563570    return v8::Handle<v8::Value>();
     
    575582    INC_STATS("DOM.TestObj.intMethodWithArgs");
    576583    TestObj* imp = V8TestObj::toNative(args.Holder());
    577     int intArg = toInt32(args[0]);
     584    if (args.Length() <= 0)
     585        return throwError(TYPE_MISMATCH_ERR);
     586    EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
     587    if (args.Length() <= 1)
     588        return throwError(TYPE_MISMATCH_ERR);
    578589    V8Parameter<> strArg = args[1];
    579     TestObj* objArg = V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0;
     590    if (args.Length() <= 2)
     591        return throwError(TYPE_MISMATCH_ERR);
     592    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0);
    580593    return v8::Integer::New(imp->intMethodWithArgs(intArg, strArg, objArg));
    581594}
     
    592605    INC_STATS("DOM.TestObj.objMethodWithArgs");
    593606    TestObj* imp = V8TestObj::toNative(args.Holder());
    594     int intArg = toInt32(args[0]);
     607    if (args.Length() <= 0)
     608        return throwError(TYPE_MISMATCH_ERR);
     609    EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
     610    if (args.Length() <= 1)
     611        return throwError(TYPE_MISMATCH_ERR);
    595612    V8Parameter<> strArg = args[1];
    596     TestObj* objArg = V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0;
     613    if (args.Length() <= 2)
     614        return throwError(TYPE_MISMATCH_ERR);
     615    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0);
    597616    return toV8(imp->objMethodWithArgs(intArg, strArg, objArg));
    598617}
     
    604623        return v8::Handle<v8::Value>();
    605624    TestObj* imp = V8TestObj::toNative(args.Holder());
     625    if (args.Length() <= 0)
     626        return throwError(TYPE_MISMATCH_ERR);
    606627    V8Parameter<> strArg = args[0];
    607     TestObj* objArg = V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0;
     628    if (args.Length() <= 1)
     629        return throwError(TYPE_MISMATCH_ERR);
     630    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0);
    608631    return toV8(imp->methodThatRequiresAllArgs(strArg, objArg));
    609632}
     
    617640    ExceptionCode ec = 0;
    618641    {
     642    if (args.Length() <= 0)
     643        return throwError(TYPE_MISMATCH_ERR);
    619644    V8Parameter<> strArg = args[0];
    620     TestObj* objArg = V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0;
     645    if (args.Length() <= 1)
     646        return throwError(TYPE_MISMATCH_ERR);
     647    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0);
    621648    RefPtr<TestObj> result = imp->methodThatRequiresAllArgsAndThrows(strArg, objArg, ec);
    622649    if (UNLIKELY(ec))
     
    633660    INC_STATS("DOM.TestObj.serializedValue");
    634661    TestObj* imp = V8TestObj::toNative(args.Holder());
     662    if (args.Length() <= 0)
     663        return throwError(TYPE_MISMATCH_ERR);
    635664    bool serializedArgDidThrow = false;
    636665    RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(args[0], serializedArgDidThrow);
     
    645674    INC_STATS("DOM.TestObj.idbKey");
    646675    TestObj* imp = V8TestObj::toNative(args.Holder());
    647     RefPtr<IDBKey> key = createIDBKeyFromValue(args[0]);
     676    if (args.Length() <= 0)
     677        return throwError(TYPE_MISMATCH_ERR);
     678    EXCEPTION_BLOCK(RefPtr<IDBKey>, key, createIDBKeyFromValue(args[0]));
    648679    imp->idbKey(key);
    649680    return v8::Handle<v8::Value>();
     
    675706    if (!callStack)
    676707        return v8::Undefined();
    677     log* intArg = V8log::HasInstance(args[0]) ? V8log::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
     708    if (args.Length() <= 0)
     709        return throwError(TYPE_MISMATCH_ERR);
     710    EXCEPTION_BLOCK(log*, intArg, V8log::HasInstance(args[0]) ? V8log::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
    678711    imp->customArgsAndException(intArg, callStack.get(), ec);
    679712    if (UNLIKELY(ec))
     
    723756    INC_STATS("DOM.TestObj.withDynamicFrameAndArg");
    724757    TestObj* imp = V8TestObj::toNative(args.Holder());
    725     int intArg = toInt32(args[0]);
     758    if (args.Length() <= 0)
     759        return throwError(TYPE_MISMATCH_ERR);
     760    EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
    726761    Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
    727762    if (!enteredFrame)
     
    735770    INC_STATS("DOM.TestObj.withDynamicFrameAndOptionalArg");
    736771    TestObj* imp = V8TestObj::toNative(args.Holder());
    737     int intArg = toInt32(args[0]);
     772    if (args.Length() <= 0)
     773        return throwError(TYPE_MISMATCH_ERR);
     774    EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
    738775    if (args.Length() <= 1) {
    739776        Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
     
    743780        return v8::Handle<v8::Value>();
    744781    }
    745     int optionalArg = toInt32(args[1]);
     782    EXCEPTION_BLOCK(int, optionalArg, toInt32(args[1]));
    746783    Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
    747784    if (!enteredFrame)
     
    755792    INC_STATS("DOM.TestObj.withDynamicFrameAndUserGesture");
    756793    TestObj* imp = V8TestObj::toNative(args.Holder());
    757     int intArg = toInt32(args[0]);
     794    if (args.Length() <= 0)
     795        return throwError(TYPE_MISMATCH_ERR);
     796    EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
    758797    Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
    759798    if (!enteredFrame)
     
    767806    INC_STATS("DOM.TestObj.withDynamicFrameAndUserGestureASAD");
    768807    TestObj* imp = V8TestObj::toNative(args.Holder());
    769     int intArg = toInt32(args[0]);
     808    if (args.Length() <= 0)
     809        return throwError(TYPE_MISMATCH_ERR);
     810    EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
    770811    if (args.Length() <= 1) {
    771812        Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
     
    775816        return v8::Handle<v8::Value>();
    776817    }
    777     int optionalArg = toInt32(args[1]);
     818    EXCEPTION_BLOCK(int, optionalArg, toInt32(args[1]));
    778819    Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
    779820    if (!enteredFrame)
     
    862903        return v8::Handle<v8::Value>();
    863904    }
    864     int opt = toInt32(args[0]);
     905    EXCEPTION_BLOCK(int, opt, toInt32(args[0]));
    865906    imp->methodWithOptionalArg(opt);
    866907    return v8::Handle<v8::Value>();
     
    871912    INC_STATS("DOM.TestObj.methodWithNonOptionalArgAndOptionalArg");
    872913    TestObj* imp = V8TestObj::toNative(args.Holder());
    873     int nonOpt = toInt32(args[0]);
     914    if (args.Length() <= 0)
     915        return throwError(TYPE_MISMATCH_ERR);
     916    EXCEPTION_BLOCK(int, nonOpt, toInt32(args[0]));
    874917    if (args.Length() <= 1) {
    875918        imp->methodWithNonOptionalArgAndOptionalArg(nonOpt);
    876919        return v8::Handle<v8::Value>();
    877920    }
    878     int opt = toInt32(args[1]);
     921    EXCEPTION_BLOCK(int, opt, toInt32(args[1]));
    879922    imp->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt);
    880923    return v8::Handle<v8::Value>();
     
    885928    INC_STATS("DOM.TestObj.methodWithNonOptionalArgAndTwoOptionalArgs");
    886929    TestObj* imp = V8TestObj::toNative(args.Holder());
    887     int nonOpt = toInt32(args[0]);
     930    if (args.Length() <= 0)
     931        return throwError(TYPE_MISMATCH_ERR);
     932    EXCEPTION_BLOCK(int, nonOpt, toInt32(args[0]));
    888933    if (args.Length() <= 1) {
    889934        imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt);
    890935        return v8::Handle<v8::Value>();
    891936    }
    892     int opt1 = toInt32(args[1]);
    893     int opt2 = toInt32(args[2]);
     937    EXCEPTION_BLOCK(int, opt1, toInt32(args[1]));
     938    if (args.Length() <= 2) {
     939        imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1);
     940        return v8::Handle<v8::Value>();
     941    }
     942    EXCEPTION_BLOCK(int, opt2, toInt32(args[2]));
    894943    imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2);
    895944    return v8::Handle<v8::Value>();
     
    900949    INC_STATS("DOM.TestObj.methodWithCallbackArg");
    901950    TestObj* imp = V8TestObj::toNative(args.Holder());
    902     if (args.Length() <= 0 || !args[0]->IsObject())
     951    if (args.Length() <= 0)
     952        return throwError(TYPE_MISMATCH_ERR);
     953    if (!args[0]->IsObject())
    903954        return throwError(TYPE_MISMATCH_ERR);
    904955    RefPtr<TestCallback> callback = V8TestCallback::create(args[0], getScriptExecutionContext());
     
    911962    INC_STATS("DOM.TestObj.methodWithNonCallbackArgAndCallbackArg");
    912963    TestObj* imp = V8TestObj::toNative(args.Holder());
    913     int nonCallback = toInt32(args[0]);
    914     if (args.Length() <= 1 || !args[1]->IsObject())
     964    if (args.Length() <= 0)
     965        return throwError(TYPE_MISMATCH_ERR);
     966    EXCEPTION_BLOCK(int, nonCallback, toInt32(args[0]));
     967    if (args.Length() <= 1)
     968        return throwError(TYPE_MISMATCH_ERR);
     969    if (!args[1]->IsObject())
    915970        return throwError(TYPE_MISMATCH_ERR);
    916971    RefPtr<TestCallback> callback = V8TestCallback::create(args[1], getScriptExecutionContext());
     
    923978    INC_STATS("DOM.TestObj.methodWithCallbackAndOptionalArg");
    924979    TestObj* imp = V8TestObj::toNative(args.Holder());
    925     if (args.Length() <= 0) {
    926         imp->methodWithCallbackAndOptionalArg();
    927         return v8::Handle<v8::Value>();
    928     }
    929     if (args.Length() <= 0 || !args[0]->IsObject())
    930         return throwError(TYPE_MISMATCH_ERR);
    931     RefPtr<TestCallback> callback = V8TestCallback::create(args[0], getScriptExecutionContext());
     980    RefPtr<TestCallback> callback;
     981    if (args.Length() > 0 && args[0]->IsObject())
     982        callback = V8TestCallback::create(args[0], getScriptExecutionContext());
    932983    imp->methodWithCallbackAndOptionalArg(callback);
    933984    return v8::Handle<v8::Value>();
     
    938989    INC_STATS("DOM.TestObj.overloadedMethod1");
    939990    TestObj* imp = V8TestObj::toNative(args.Holder());
    940     TestObj* objArg = V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
     991    if (args.Length() <= 0)
     992        return throwError(TYPE_MISMATCH_ERR);
     993    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
     994    if (args.Length() <= 1)
     995        return throwError(TYPE_MISMATCH_ERR);
    941996    V8Parameter<> strArg = args[1];
    942997    imp->overloadedMethod(objArg, strArg);
     
    9481003    INC_STATS("DOM.TestObj.overloadedMethod2");
    9491004    TestObj* imp = V8TestObj::toNative(args.Holder());
    950     TestObj* objArg = V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
     1005    if (args.Length() <= 0)
     1006        return throwError(TYPE_MISMATCH_ERR);
     1007    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
    9511008    if (args.Length() <= 1) {
    9521009        imp->overloadedMethod(objArg);
    9531010        return v8::Handle<v8::Value>();
    9541011    }
    955     int intArg = toInt32(args[1]);
     1012    EXCEPTION_BLOCK(int, intArg, toInt32(args[1]));
    9561013    imp->overloadedMethod(objArg, intArg);
    9571014    return v8::Handle<v8::Value>();
     
    9621019    INC_STATS("DOM.TestObj.overloadedMethod3");
    9631020    TestObj* imp = V8TestObj::toNative(args.Holder());
     1021    if (args.Length() <= 0)
     1022        return throwError(TYPE_MISMATCH_ERR);
    9641023    V8Parameter<> strArg = args[0];
    9651024    imp->overloadedMethod(strArg);
     
    9711030    INC_STATS("DOM.TestObj.overloadedMethod4");
    9721031    TestObj* imp = V8TestObj::toNative(args.Holder());
    973     int intArg = toInt32(args[0]);
     1032    if (args.Length() <= 0)
     1033        return throwError(TYPE_MISMATCH_ERR);
     1034    EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
    9741035    imp->overloadedMethod(intArg);
    9751036    return v8::Handle<v8::Value>();
     
    10891150    {"methodWithNonOptionalArgAndOptionalArg", TestObjInternal::methodWithNonOptionalArgAndOptionalArgCallback},
    10901151    {"methodWithNonOptionalArgAndTwoOptionalArgs", TestObjInternal::methodWithNonOptionalArgAndTwoOptionalArgsCallback},
     1152    {"methodWithCallbackArg", TestObjInternal::methodWithCallbackArgCallback},
     1153    {"methodWithNonCallbackArgAndCallbackArg", TestObjInternal::methodWithNonCallbackArgAndCallbackArgCallback},
    10911154    {"methodWithCallbackAndOptionalArg", TestObjInternal::methodWithCallbackAndOptionalArgCallback},
    10921155    {"overloadedMethod", TestObjInternal::overloadedMethodCallback},
     
    11621225    v8::Handle<v8::Signature> customArgsAndExceptionSignature = v8::Signature::New(desc, customArgsAndExceptionArgc, customArgsAndExceptionArgv);
    11631226    proto->Set(v8::String::New("customArgsAndException"), v8::FunctionTemplate::New(TestObjInternal::customArgsAndExceptionCallback, v8::Handle<v8::Value>(), customArgsAndExceptionSignature));
    1164 
    1165     // Custom Signature 'methodWithCallbackArg'
    1166     const int methodWithCallbackArgArgc = 1;
    1167     v8::Handle<v8::FunctionTemplate> methodWithCallbackArgArgv[methodWithCallbackArgArgc] = { V8TestCallback::GetRawTemplate() };
    1168     v8::Handle<v8::Signature> methodWithCallbackArgSignature = v8::Signature::New(desc, methodWithCallbackArgArgc, methodWithCallbackArgArgv);
    1169     proto->Set(v8::String::New("methodWithCallbackArg"), v8::FunctionTemplate::New(TestObjInternal::methodWithCallbackArgCallback, v8::Handle<v8::Value>(), methodWithCallbackArgSignature));
    1170 
    1171     // Custom Signature 'methodWithNonCallbackArgAndCallbackArg'
    1172     const int methodWithNonCallbackArgAndCallbackArgArgc = 2;
    1173     v8::Handle<v8::FunctionTemplate> methodWithNonCallbackArgAndCallbackArgArgv[methodWithNonCallbackArgAndCallbackArgArgc] = { v8::Handle<v8::FunctionTemplate>(), V8TestCallback::GetRawTemplate() };
    1174     v8::Handle<v8::Signature> methodWithNonCallbackArgAndCallbackArgSignature = v8::Signature::New(desc, methodWithNonCallbackArgAndCallbackArgArgc, methodWithNonCallbackArgAndCallbackArgArgv);
    1175     proto->Set(v8::String::New("methodWithNonCallbackArgAndCallbackArg"), v8::FunctionTemplate::New(TestObjInternal::methodWithNonCallbackArgAndCallbackArgCallback, v8::Handle<v8::Value>(), methodWithNonCallbackArgAndCallbackArgSignature));
    11761227    batchConfigureConstants(desc, proto, TestObjConsts, sizeof(TestObjConsts) / sizeof(*TestObjConsts));
    11771228
  • trunk/WebCore/bindings/v8/V8Binding.h

    r62174 r64835  
    3434#include "AtomicString.h"
    3535#include "BindingSecurity.h"
     36#include "ExceptionCode.h"
    3637#include "MathExtras.h"
    3738#include "PlatformString.h"
    3839#include "V8DOMWrapper.h"
     40#include "V8Proxy.h"
    3941
    4042#include <v8.h>
     
    226228    };
    227229   
    228     template<> inline V8Parameter<DefaultMode>::operator String() { return toWebCoreString(m_v8Object); }
    229     template<> inline V8Parameter<WithNullCheck>::operator String() { return toWebCoreStringWithNullCheck(m_v8Object); }
    230     template<> inline V8Parameter<WithUndefinedOrNullCheck>::operator String() { return toWebCoreStringWithNullOrUndefinedCheck(m_v8Object); }
    231 
    232     template<> inline V8Parameter<DefaultMode>::operator AtomicString() { return v8ValueToAtomicWebCoreString(m_v8Object); }
    233     template<> inline V8Parameter<WithNullCheck>::operator AtomicString() { return toAtomicWebCoreStringWithNullCheck(m_v8Object); }
    234     template<> inline V8Parameter<WithUndefinedOrNullCheck>::operator AtomicString() { return toAtomicWebCoreStringWithNullCheck(m_v8Object); }
     230    template<> inline V8Parameter<DefaultMode>::operator String()
     231    {
     232        String result;
     233        v8::TryCatch block;
     234        result = toWebCoreString(m_v8Object);
     235        if (block.HasCaught()) {
     236            V8Proxy::setDOMException(TYPE_MISMATCH_ERR);
     237            return String();
     238        }
     239        return result;
     240    }
     241    template<> inline V8Parameter<WithNullCheck>::operator String()
     242    {
     243        String result;
     244        v8::TryCatch block;
     245        result = toWebCoreStringWithNullCheck(m_v8Object);
     246        if (block.HasCaught()) {
     247            V8Proxy::setDOMException(TYPE_MISMATCH_ERR);
     248            return String();
     249        }
     250        return result;
     251    }
     252    template<> inline V8Parameter<WithUndefinedOrNullCheck>::operator String()
     253    {
     254        String result;
     255        v8::TryCatch block;
     256        result = toWebCoreStringWithNullOrUndefinedCheck(m_v8Object);
     257        if (block.HasCaught()) {
     258            V8Proxy::setDOMException(TYPE_MISMATCH_ERR);
     259            return String();
     260        }
     261        return result;
     262    }
     263
     264    template<> inline V8Parameter<DefaultMode>::operator AtomicString()
     265    {
     266        AtomicString result;
     267        v8::TryCatch block;
     268        result = v8ValueToAtomicWebCoreString(m_v8Object);
     269        if (block.HasCaught()) {
     270            V8Proxy::setDOMException(TYPE_MISMATCH_ERR);
     271            return AtomicString();
     272        }
     273        return result;
     274    }
     275    template<> inline V8Parameter<WithNullCheck>::operator AtomicString()
     276    {
     277        AtomicString result;
     278        v8::TryCatch block;
     279        result = toAtomicWebCoreStringWithNullCheck(m_v8Object);
     280        if (block.HasCaught()) {
     281            V8Proxy::setDOMException(TYPE_MISMATCH_ERR);
     282            return AtomicString();
     283        }
     284        return result;
     285    }
     286    template<> inline V8Parameter<WithUndefinedOrNullCheck>::operator AtomicString()
     287    {
     288        AtomicString result;
     289        v8::TryCatch block;
     290        result = toAtomicWebCoreStringWithNullCheck(m_v8Object);
     291        if (block.HasCaught()) {
     292            V8Proxy::setDOMException(TYPE_MISMATCH_ERR);
     293            return AtomicString();
     294        }
     295        return result;
     296    }
    235297
    236298} // namespace WebCore
  • trunk/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp

    r64537 r64835  
    3333
    3434#include "Chrome.h"
    35 #include "Database.h"
    3635#include "DOMTimer.h"
    3736#include "DOMWindow.h"
     
    5655#include "V8BindingState.h"
    5756#include "V8CustomEventListener.h"
    58 #include "V8Database.h"
    59 #include "V8DatabaseCallback.h"
    6057#include "V8GCForContextDispose.h"
    6158#include "V8HiddenPropertyName.h"
     
    791788}
    792789
    793 #if ENABLE(DATABASE)
    794 v8::Handle<v8::Value> V8DOMWindow::openDatabaseCallback(const v8::Arguments& args)
    795 {
    796     INC_STATS("DOM.DOMWindow.openDatabase");
    797     if (args.Length() < 4)
    798         return throwError(SYNTAX_ERR);
    799 
    800     TO_WEBCORE_STRING_EXCEPTION_BLOCK(name, args[0]);
    801     TO_WEBCORE_STRING_EXCEPTION_BLOCK(version, args[1]);
    802     TO_WEBCORE_STRING_EXCEPTION_BLOCK(displayName, args[2]);
    803     EXCEPTION_BLOCK(unsigned long, estimatedSize, args[3]->Uint32Value());
    804 
    805     DOMWindow* imp = V8DOMWindow::toNative(args.Holder());
    806     if (!V8BindingSecurity::canAccessFrame(V8BindingState::Only(), imp->frame(), true))
    807         return v8::Undefined();
    808 
    809     ScriptExecutionContext* scriptExecutionContext = getScriptExecutionContext();
    810     RefPtr<DatabaseCallback> creationCallback;
    811     if (args.Length() >= 5) {
    812         if (!args[4]->IsObject())
    813             return throwError(TYPE_MISMATCH_ERR);
    814 
    815         creationCallback = V8DatabaseCallback::create(args[4], scriptExecutionContext);
    816     }
    817 
    818     ExceptionCode ec = 0;
    819     v8::Handle<v8::Value> result = toV8(imp->openDatabase(name, version, displayName, estimatedSize, creationCallback.release(), ec));
    820 
    821     V8Proxy::setDOMException(ec);
    822     return result;
    823 }
    824 #endif // ENABLE(DATABASE)
    825 
    826790bool V8DOMWindow::namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>)
    827791{
  • trunk/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp

    r64537 r64835  
    3434#include "V8WorkerContext.h"
    3535
    36 #if ENABLE(DATABASE)
    37 #include "Database.h"
    38 #include "V8Database.h"
    39 #include "V8DatabaseCallback.h"
    40 #include "V8DatabaseSync.h"
    41 #endif
    4236#include "DOMTimer.h"
    4337#include "ExceptionCode.h"
     
    144138}
    145139
    146 #if ENABLE(DATABASE)
    147 v8::Handle<v8::Value> V8WorkerContext::openDatabaseCallback(const v8::Arguments& args)
    148 {
    149     INC_STATS("DOM.V8WorkerContext.openDatabase()");
    150     if (args.Length() < 4)
    151         return throwError(SYNTAX_ERR);
    152 
    153     TO_WEBCORE_STRING_EXCEPTION_BLOCK(name, args[0]);
    154     TO_WEBCORE_STRING_EXCEPTION_BLOCK(version, args[1]);
    155     TO_WEBCORE_STRING_EXCEPTION_BLOCK(displayName, args[2]);
    156     EXCEPTION_BLOCK(unsigned long, estimatedSize, args[3]->Uint32Value());
    157 
    158     WorkerContext* workerContext = V8WorkerContext::toNative(args.Holder());
    159 
    160     ScriptExecutionContext* scriptExecutionContext = getScriptExecutionContext();
    161     RefPtr<DatabaseCallback> creationCallback;
    162     if (args.Length() >= 5) {
    163         if (!args[4]->IsObject())
    164             return throwError(TYPE_MISMATCH_ERR);
    165 
    166         creationCallback = V8DatabaseCallback::create(args[4], scriptExecutionContext);
    167     }
    168 
    169     ExceptionCode ec = 0;
    170     v8::Handle<v8::Value> result = toV8(workerContext->openDatabase(name, version, displayName, estimatedSize, creationCallback.release(), ec));
    171 
    172     V8Proxy::setDOMException(ec);
    173     return result;
    174 }
    175 
    176 v8::Handle<v8::Value> V8WorkerContext::openDatabaseSyncCallback(const v8::Arguments& args)
    177 {
    178     INC_STATS("DOM.V8WorkerContext.openDatabaseSync()");
    179     if (args.Length() < 4)
    180         return throwError(SYNTAX_ERR);
    181 
    182     TO_WEBCORE_STRING_EXCEPTION_BLOCK(name, args[0]);
    183     TO_WEBCORE_STRING_EXCEPTION_BLOCK(version, args[1]);
    184     TO_WEBCORE_STRING_EXCEPTION_BLOCK(displayName, args[2]);
    185     EXCEPTION_BLOCK(unsigned long, estimatedSize, args[3]->Uint32Value());
    186 
    187     WorkerContext* workerContext = V8WorkerContext::toNative(args.Holder());
    188 
    189     ScriptExecutionContext* scriptExecutionContext = getScriptExecutionContext();
    190     RefPtr<DatabaseCallback> creationCallback;
    191     if (args.Length() >= 5) {
    192         if (!args[4]->IsObject())
    193             return throwError(TYPE_MISMATCH_ERR);
    194 
    195         creationCallback = V8DatabaseCallback::create(args[4], scriptExecutionContext);
    196     }
    197 
    198     ExceptionCode ec = 0;
    199     v8::Handle<v8::Value> result = toV8(workerContext->openDatabaseSync(name, version, displayName, estimatedSize, creationCallback.release(), ec));
    200 
    201     V8Proxy::setDOMException(ec);
    202     return result;
    203 }
    204 #endif
    205 
    206140} // namespace WebCore
    207141
  • trunk/WebCore/page/DOMWindow.idl

    r64763 r64835  
    161161#endif   
    162162#if defined(ENABLE_DATABASE) && ENABLE_DATABASE
    163         [EnabledAtRuntime, Custom] Database openDatabase(in DOMString name, in DOMString version, in DOMString displayName, in unsigned long estimatedSize, in DatabaseCallback creationCallback)
     163        [EnabledAtRuntime] Database openDatabase(in DOMString name, in DOMString version, in DOMString displayName, in unsigned long estimatedSize, in [Optional, Callback] DatabaseCallback creationCallback)
    164164            raises(DOMException);
    165165#endif
  • trunk/WebCore/storage/Database.cpp

    r64650 r64835  
    271271}
    272272
    273 void Database::transaction(PassRefPtr<SQLTransactionCallback> callback, PassRefPtr<SQLTransactionErrorCallback> errorCallback,
    274                            PassRefPtr<VoidCallback> successCallback, bool readOnly)
     273void Database::transaction(PassRefPtr<SQLTransactionCallback> callback, PassRefPtr<SQLTransactionErrorCallback> errorCallback, PassRefPtr<VoidCallback> successCallback)
     274{
     275    runTransaction(callback, errorCallback, successCallback, false);
     276}
     277
     278void Database::readTransaction(PassRefPtr<SQLTransactionCallback> callback, PassRefPtr<SQLTransactionErrorCallback> errorCallback, PassRefPtr<VoidCallback> successCallback)
     279{
     280    runTransaction(callback, errorCallback, successCallback, true);
     281}
     282
     283void Database::runTransaction(PassRefPtr<SQLTransactionCallback> callback, PassRefPtr<SQLTransactionErrorCallback> errorCallback,
     284                              PassRefPtr<VoidCallback> successCallback, bool readOnly)
    275285{
    276286    m_transactionQueue.append(SQLTransaction::create(this, callback, errorCallback, successCallback, 0, readOnly));
  • trunk/WebCore/storage/Database.h

    r63278 r64835  
    6060    void changeVersion(const String& oldVersion, const String& newVersion, PassRefPtr<SQLTransactionCallback>,
    6161                       PassRefPtr<SQLTransactionErrorCallback>, PassRefPtr<VoidCallback> successCallback);
    62     void transaction(PassRefPtr<SQLTransactionCallback>, PassRefPtr<SQLTransactionErrorCallback>,
    63                      PassRefPtr<VoidCallback> successCallback, bool readOnly);
     62    void transaction(PassRefPtr<SQLTransactionCallback>, PassRefPtr<SQLTransactionErrorCallback>, PassRefPtr<VoidCallback> successCallback);
     63    void readTransaction(PassRefPtr<SQLTransactionCallback>, PassRefPtr<SQLTransactionErrorCallback>, PassRefPtr<VoidCallback> successCallback);
    6464
    6565    // Internal engine support
     
    9191    Database(ScriptExecutionContext*, const String& name, const String& expectedVersion,
    9292             const String& displayName, unsigned long estimatedSize);
     93    void runTransaction(PassRefPtr<SQLTransactionCallback>, PassRefPtr<SQLTransactionErrorCallback>,
     94                        PassRefPtr<VoidCallback> successCallback, bool readOnly);
    9395
    9496    bool openAndVerifyVersion(bool setVersionInNewDatabase, ExceptionCode&);
  • trunk/WebCore/storage/Database.idl

    r58989 r64835  
    3535    ] Database {
    3636        readonly attribute DOMString version;
    37         [Custom] void changeVersion(in DOMString oldVersion, in DOMString newVersion, in SQLTransactionCallback callback, in SQLTransactionErrorCallback errorCallback, in VoidCallback successCallback);
    38         [Custom] void transaction(in SQLTransactionCallback callback, in SQLTransactionErrorCallback errorCallback, in VoidCallback successCallback);
    39         [Custom] void readTransaction(in SQLTransactionCallback callback, in SQLTransactionErrorCallback errorCallback, in VoidCallback successCallback);
     37        void changeVersion(in DOMString oldVersion, in DOMString newVersion, in [Optional, Callback] SQLTransactionCallback callback, in [Optional, Callback] SQLTransactionErrorCallback errorCallback, in [Optional, Callback] VoidCallback successCallback);
     38        void transaction(in [Callback] SQLTransactionCallback callback, in [Optional, Callback] SQLTransactionErrorCallback errorCallback, in [Optional, Callback] VoidCallback successCallback);
     39        void readTransaction(in [Callback] SQLTransactionCallback callback, in [Optional, Callback] SQLTransactionErrorCallback errorCallback, in [Optional, Callback] VoidCallback successCallback);
    4040    };
    4141
  • trunk/WebCore/storage/DatabaseSync.cpp

    r64537 r64835  
    129129}
    130130
    131 void DatabaseSync::transaction(PassRefPtr<SQLTransactionSyncCallback> callback, bool readOnly, ExceptionCode& ec)
     131void DatabaseSync::transaction(PassRefPtr<SQLTransactionSyncCallback> callback, ExceptionCode& ec)
     132{
     133    runTransaction(callback, false, ec);
     134}
     135
     136void DatabaseSync::readTransaction(PassRefPtr<SQLTransactionSyncCallback> callback, ExceptionCode& ec)
     137{
     138    runTransaction(callback, true, ec);
     139}
     140
     141void DatabaseSync::runTransaction(PassRefPtr<SQLTransactionSyncCallback> callback, bool readOnly, ExceptionCode& ec)
    132142{
    133143    ASSERT(m_scriptExecutionContext->isContextThread());
  • trunk/WebCore/storage/DatabaseSync.h

    r63278 r64835  
    5757                                                     const String& displayName, unsigned long estimatedSize, PassRefPtr<DatabaseCallback>, ExceptionCode&);
    5858    void changeVersion(const String& oldVersion, const String& newVersion, PassRefPtr<SQLTransactionSyncCallback>, ExceptionCode&);
    59     void transaction(PassRefPtr<SQLTransactionSyncCallback>, bool readOnly, ExceptionCode&);
     59    void transaction(PassRefPtr<SQLTransactionSyncCallback>, ExceptionCode&);
     60    void readTransaction(PassRefPtr<SQLTransactionSyncCallback>, ExceptionCode&);
    6061
    6162    virtual void markAsDeletedAndClose();
     
    6566    DatabaseSync(ScriptExecutionContext*, const String& name, const String& expectedVersion,
    6667                 const String& displayName, unsigned long estimatedSize);
     68    void runTransaction(PassRefPtr<SQLTransactionSyncCallback>, bool readOnly, ExceptionCode&);
    6769};
    6870
  • trunk/WebCore/storage/DatabaseSync.idl

    r63278 r64835  
    3737    ] DatabaseSync {
    3838        readonly attribute DOMString version;
    39         [Custom] void changeVersion(in DOMString oldVersion, in DOMString newVersion, in SQLTransactionSyncCallback callback);
    40         [Custom] void transaction(in SQLTransactionSyncCallback callback);
    41         [Custom] void readTransaction(in SQLTransactionSyncCallback callback);
     39        void changeVersion(in DOMString oldVersion, in DOMString newVersion, in [Callback, Optional] SQLTransactionSyncCallback callback) raises(DOMException);
     40        void transaction(in [Callback] SQLTransactionSyncCallback callback) raises(DOMException);
     41        void readTransaction(in [Callback] SQLTransactionSyncCallback callback) raises(DOMException);
    4242    };
    4343
  • trunk/WebCore/workers/WorkerContext.idl

    r60784 r64835  
    5151                 attribute [Replaceable] WorkerNavigator navigator;
    5252#if defined(ENABLE_DATABASE) && ENABLE_DATABASE
    53         [EnabledAtRuntime, Custom] Database openDatabase(in DOMString name, in DOMString version, in DOMString displayName, in unsigned long estimatedSize, in DatabaseCallback creationCallback)
     53        [EnabledAtRuntime] Database openDatabase(in DOMString name, in DOMString version, in DOMString displayName, in unsigned long estimatedSize, in [Optional, Callback] DatabaseCallback creationCallback)
    5454            raises(DOMException);
    55         [EnabledAtRuntime, Custom] DatabaseSync openDatabaseSync(in DOMString name, in DOMString version, in DOMString displayName, in unsigned long estimatedSize, in DatabaseCallback creationCallback);
     55        [EnabledAtRuntime] DatabaseSync openDatabaseSync(in DOMString name, in DOMString version, in DOMString displayName, in unsigned long estimatedSize, in [Optional, Callback] DatabaseCallback creationCallback)
     56            raises(DOMException);
    5657#endif
    5758
Note: See TracChangeset for help on using the changeset viewer.