diff options
Diffstat (limited to 'WebCore/bindings/scripts')
-rw-r--r-- | WebCore/bindings/scripts/CodeGeneratorCPP.pm | 19 | ||||
-rw-r--r-- | WebCore/bindings/scripts/CodeGeneratorGObject.pm | 22 | ||||
-rw-r--r-- | WebCore/bindings/scripts/CodeGeneratorJS.pm | 96 | ||||
-rw-r--r-- | WebCore/bindings/scripts/CodeGeneratorObjC.pm | 6 | ||||
-rw-r--r-- | WebCore/bindings/scripts/CodeGeneratorV8.pm | 155 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp | 26 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp | 2 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp | 46 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/JS/JSTestCallback.cpp | 36 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/JS/JSTestCallback.h | 13 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/JS/JSTestObj.cpp | 105 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm | 2 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/V8/V8TestCallback.cpp | 23 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/V8/V8TestCallback.h | 20 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/V8/V8TestObj.cpp | 98 |
15 files changed, 398 insertions, 271 deletions
diff --git a/WebCore/bindings/scripts/CodeGeneratorCPP.pm b/WebCore/bindings/scripts/CodeGeneratorCPP.pm index 27cf854..ff63615 100644 --- a/WebCore/bindings/scripts/CodeGeneratorCPP.pm +++ b/WebCore/bindings/scripts/CodeGeneratorCPP.pm @@ -261,7 +261,7 @@ sub GetCPPTypeGetter return $argName if $codeGenerator->IsPrimitiveType($type) or $codeGenerator->IsStringType($type); return "static_cast<WebCore::Range::CompareHow>($argName)" if $type eq "CompareHow"; - return "WebCore::SerializedScriptValue::create(WebCore::String($argName))" if $type eq "SerializedScriptValue"; + return "WebCore::SerializedScriptValue::create(WTF::String($argName))" if $type eq "SerializedScriptValue"; return "toWebCore($argName)"; } @@ -421,10 +421,14 @@ sub GenerateHeader foreach my $attribute (@{$dataNode->attributes}) { next if ShouldSkipTypeInHeader($attribute); + my $attributeConditionalString = GenerateConditionalString($attribute->signature); my $attributeName = $attribute->signature->name; my $attributeType = GetCPPType($attribute->signature->type, 0); my $attributeIsReadonly = ($attribute->type =~ /^readonly/); - my $property = " " . $attributeType . ($attributeType =~ /\*$/ ? "" : " ") . $attributeName . "() const"; + my $property = ""; + + $property .= "#if ${attributeConditionalString}\n" if $attributeConditionalString; + $property .= " " . $attributeType . ($attributeType =~ /\*$/ ? "" : " ") . $attributeName . "() const"; my $availabilityMacro = ""; my $declarationSuffix = ";\n"; @@ -439,10 +443,11 @@ sub GenerateHeader if (!$attributeIsReadonly and !$attribute->signature->extendedAttributes->{"Replaceable"}) { $property = " void $setterName($attributeType)"; $property .= $declarationSuffix; - push(@headerAttributes, $property); + push(@headerAttributes, $property); } - } + push(@headerAttributes, "#endif\n") if $attributeConditionalString; + } push(@headerContent, @headerAttributes) if @headerAttributes > 0; } @@ -554,7 +559,7 @@ sub AddReturnStatement # Used to invoke KURLs "const String&" operator if ($codeGenerator->IsStringType($typeInfo->signature->type)) { - return " return static_cast<const WebCore::String&>($returnValue);\n"; + return " return static_cast<const WTF::String&>($returnValue);\n"; } return " return $returnValue;\n"; @@ -677,7 +682,7 @@ sub GenerateImplementation # Special cases my @customGetterContent = (); if ($attribute->signature->extendedAttributes->{"ConvertToString"}) { - $getterContentHead = "WebCore::String::number(" . $getterContentHead; + $getterContentHead = "WTF::String::number(" . $getterContentHead; $getterContentTail .= ")"; } elsif ($attribute->signature->type eq "SerializedScriptValue") { $getterContentHead = "$getterContentHead"; @@ -731,7 +736,7 @@ sub GenerateImplementation # The definition of ConvertToString is flipped for the setter if ($attribute->signature->extendedAttributes->{"ConvertToString"}) { - $arg = "WebCore::String($arg).toInt()"; + $arg = "WTF::String($arg).toInt()"; } my $attributeType = GetCPPType($attribute->signature->type, 1); diff --git a/WebCore/bindings/scripts/CodeGeneratorGObject.pm b/WebCore/bindings/scripts/CodeGeneratorGObject.pm index bc5aace..5700ff7 100644 --- a/WebCore/bindings/scripts/CodeGeneratorGObject.pm +++ b/WebCore/bindings/scripts/CodeGeneratorGObject.pm @@ -126,6 +126,7 @@ sub ClassNameToGObjectType { $CLASS_NAME =~ s/DOMCDATA/DOM_CDATA/; $CLASS_NAME =~ s/DOMX_PATH/DOM_XPATH/; $CLASS_NAME =~ s/DOM_WEB_KIT/DOM_WEBKIT/; + $CLASS_NAME =~ s/DOMUI/DOM_UI/; return $CLASS_NAME; } @@ -207,6 +208,14 @@ sub SkipFunction { return 1; } + # Skip functions that have ["Callback"] parameters, because this + # code generator doesn't know how to auto-generate callbacks. + foreach my $param (@{$function->parameters}) { + if ($param->extendedAttributes->{"Callback"}) { + return 1; + } + } + return 0; } @@ -239,7 +248,7 @@ sub GetGlibTypeName { my $type = shift; my $name = GetClassName($type); - my %types = ("DOMString", "gchar* ", + my %types = ("DOMString", "gchar*", "DOMTimeStamp", "guint32", "CompareHow", "gushort", "float", "gfloat", @@ -258,7 +267,7 @@ sub GetGlibTypeName { "unsigned short", "gushort", "void", "void"); - return $types{$type} ? $types{$type} : "$name* "; + return $types{$type} ? $types{$type} : "$name*"; } sub IsGDOMClassType { @@ -360,7 +369,7 @@ sub GenerateProperty { my $convertFunction = ""; if ($gtype eq "string") { - $convertFunction = "WebCore::String::fromUTF8"; + $convertFunction = "WTF::String::fromUTF8"; } my $getterExpressionPrefix = $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); @@ -802,9 +811,10 @@ sub GenerateFunction { } addIncludeInBody($paramIDLType); my $paramType = GetGlibTypeName($paramIDLType); + my $const = $paramType eq "gchar*" ? "const " : ""; my $paramName = decamelize($param->name); - $functionSig .= ", $paramType $paramName"; + $functionSig .= ", ${const}$paramType $paramName"; my $paramIsGDOMType = IsGDOMClassType($paramIDLType); if ($paramIsGDOMType) { @@ -892,7 +902,7 @@ sub GenerateFunction { my $paramIsGDOMType = IsGDOMClassType($paramIDLType); if ($paramIDLType eq "DOMString") { - push(@cBody, " WebCore::String converted_${paramName} = WebCore::String::fromUTF8($paramName);\n"); + push(@cBody, " WTF::String converted_${paramName} = WTF::String::fromUTF8($paramName);\n"); } elsif ($paramIDLType eq "CompareHow") { push(@cBody, " WebCore::Range::CompareHow converted_${paramName} = static_cast<WebCore::Range::CompareHow>($paramName);\n"); } elsif ($paramIsGDOMType) { @@ -1222,7 +1232,7 @@ EOF sub UsesManualKitImplementation { my $type = shift; - return 1 if $type eq "Node" or $type eq "Element"; + return 1 if $type eq "Node" or $type eq "Element" or $type eq "Event"; return 0; } diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm index 247430f..200a95d 100644 --- a/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -299,7 +299,7 @@ sub AddIncludesForSVGAnimatedType sub IsScriptProfileType { my $type = shift; - return 1 if ($type eq "ScriptProfile" or $type eq "ScriptProfileNode"); + return 1 if ($type eq "ScriptProfileNode"); return 0; } @@ -1853,12 +1853,20 @@ sub GenerateImplementation my $requiresAllArguments = $function->signature->extendedAttributes->{"RequiresAllArguments"}; if ($requiresAllArguments) { - push(@implContent, " if (exec->argumentCount() < $numParameters)\n"); - if ($requiresAllArguments eq "Raise") { - push(@implContent, " return throwVMError(exec, createSyntaxError(exec, \"Not enough arguments\"));\n"); + my $numMandatoryParams = @{$function->parameters}; + foreach my $param (reverse(@{$function->parameters})) { + if ($param->extendedAttributes->{"Optional"}) { + $numMandatoryParams--; } else { - push(@implContent, " return JSValue::encode(jsUndefined());\n"); + last; } + } + push(@implContent, " if (exec->argumentCount() < $numMandatoryParams)\n"); + if ($requiresAllArguments eq "Raise") { + push(@implContent, " return throwVMError(exec, createSyntaxError(exec, \"Not enough arguments\"));\n"); + } else { + push(@implContent, " return JSValue::encode(jsUndefined());\n"); + } } if (@{$function->raisesExceptions}) { @@ -1908,14 +1916,18 @@ sub GenerateImplementation $paramIndex++; } + $implIncludes{"ExceptionCode.h"} = 1; + $implIncludes{"JSDOMBinding.h"} = 1; foreach my $parameter (@{$function->parameters}) { - if ($parameter->extendedAttributes->{"Optional"}) { + # Optional callbacks should be treated differently, because they always have a default value (0), + # and we can reduce the number of overloaded functions that take a different number of parameters. + if ($parameter->extendedAttributes->{"Optional"} && !$parameter->extendedAttributes->{"Callback"}) { # Generate early call if there are enough parameters. if (!$hasOptionalArguments) { push(@implContent, "\n int argsCount = exec->argumentCount();\n"); $hasOptionalArguments = 1; } - push(@implContent, " if (argsCount < " . ($argsIndex + 1) . ") {\n"); + push(@implContent, " if (argsCount <= $argsIndex) {\n"); GenerateImplementationFunctionCall($function, $functionString, $paramIndex, " " x 2, $podType, $implClassName); push(@implContent, " }\n\n"); } @@ -1934,12 +1946,22 @@ sub GenerateImplementation } elsif ($parameter->extendedAttributes->{"Callback"}) { my $callbackClassName = GetCallbackClassName($parameter->type); $implIncludes{"$callbackClassName.h"} = 1; - $implIncludes{"ExceptionCode.h"} = 1; - push(@implContent, " if (exec->argumentCount() <= $argsIndex || !exec->argument($argsIndex).isObject()) {\n"); - push(@implContent, " setDOMException(exec, TYPE_MISMATCH_ERR);\n"); - push(@implContent, " return jsUndefined();\n"); - push(@implContent, " }\n"); - push(@implContent, " RefPtr<" . $parameter->type . "> $name = " . $callbackClassName . "::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n"); + if ($parameter->extendedAttributes->{"Optional"}) { + push(@implContent, " RefPtr<" . $parameter->type. "> $name;\n"); + push(@implContent, " if (exec->argumentCount() > $argsIndex && !exec->argument($argsIndex).isNull() && !exec->argument($argsIndex).isUndefined()) {\n"); + push(@implContent, " if (!exec->argument($argsIndex).isObject()) {\n"); + push(@implContent, " setDOMException(exec, TYPE_MISMATCH_ERR);\n"); + push(@implContent, " return JSValue::encode(jsUndefined());\n"); + push(@implContent, " }\n"); + push(@implContent, " $name = ${callbackClassName}::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n"); + push(@implContent, " }\n"); + } else { + push(@implContent, " if (exec->argumentCount() <= $argsIndex || !exec->argument($argsIndex).isObject()) {\n"); + push(@implContent, " setDOMException(exec, TYPE_MISMATCH_ERR);\n"); + push(@implContent, " return JSValue::encode(jsUndefined());\n"); + push(@implContent, " }\n"); + push(@implContent, " RefPtr<" . $parameter->type . "> $name = ${callbackClassName}::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n"); + } } else { push(@implContent, " " . GetNativeTypeFromSignature($parameter) . " $name = " . JSValueToNative($parameter, "exec->argument($argsIndex)") . ";\n"); @@ -1947,12 +1969,15 @@ sub GenerateImplementation # But this needs to be done in the bindings, because the type is unsigned and the fact that it # was negative will be lost by the time we're inside the DOM. if ($parameter->extendedAttributes->{"IsIndex"}) { - $implIncludes{"ExceptionCode.h"} = 1; push(@implContent, " if ($name < 0) {\n"); push(@implContent, " setDOMException(exec, INDEX_SIZE_ERR);\n"); push(@implContent, " return JSValue::encode(jsUndefined());\n"); push(@implContent, " }\n"); } + + # Check if the type conversion succeeded. + push(@implContent, " if (exec->hadException())\n"); + push(@implContent, " return JSValue::encode(jsUndefined());\n"); } $functionString .= ", " if $paramIndex; @@ -2084,12 +2109,13 @@ sub GenerateCallbackHeader # - Add default header template and header protection push(@headerContentHeader, GenerateHeaderContentHeader($dataNode)); + $headerIncludes{"ActiveDOMCallback.h"} = 1; $headerIncludes{"$interfaceName.h"} = 1; $headerIncludes{"JSCallbackData.h"} = 1; $headerIncludes{"<wtf/Forward.h>"} = 1; push(@headerContent, "\nnamespace WebCore {\n\n"); - push(@headerContent, "class $className : public $interfaceName {\n"); + push(@headerContent, "class $className : public $interfaceName, public ActiveDOMCallback {\n"); push(@headerContent, "public:\n"); # The static create() method. @@ -2112,10 +2138,13 @@ sub GenerateCallbackHeader push(@headerContent, " COMPILE_ASSERT(false)"); } - push(@headerContent, " virtual " . GetNativeType($function->signature->type) . " " . $function->signature->name . "(ScriptExecutionContext*"); + push(@headerContent, " virtual " . GetNativeType($function->signature->type) . " " . $function->signature->name . "("); + + my @args = (); foreach my $param (@params) { - push(@headerContent, ", " . GetNativeType($param->type) . " " . $param->name); + push(@args, GetNativeType($param->type) . " " . $param->name); } + push(@headerContent, join(", ", @args)); push(@headerContent, ");\n"); } @@ -2128,8 +2157,6 @@ sub GenerateCallbackHeader # Private members push(@headerContent, " JSCallbackData* m_data;\n"); - push(@headerContent, " RefPtr<DOMWrapperWorld> m_isolatedWorld;\n"); - push(@headerContent, " ScriptExecutionContext* m_scriptExecutionContext;\n"); push(@headerContent, "};\n\n"); push(@headerContent, "} // namespace WebCore\n\n"); @@ -2159,19 +2186,21 @@ sub GenerateCallbackImplementation # Constructor push(@implContent, "${className}::${className}(JSObject* callback, JSDOMGlobalObject* globalObject)\n"); - push(@implContent, " : m_data(new JSCallbackData(callback, globalObject))\n"); - push(@implContent, " , m_isolatedWorld(globalObject->world())\n"); - push(@implContent, " , m_scriptExecutionContext(globalObject->scriptExecutionContext())\n"); + push(@implContent, " : ActiveDOMCallback(globalObject->scriptExecutionContext())\n"); + push(@implContent, " , m_data(new JSCallbackData(callback, globalObject))\n"); push(@implContent, "{\n"); push(@implContent, "}\n\n"); # Destructor push(@implContent, "${className}::~${className}()\n"); push(@implContent, "{\n"); - push(@implContent, " if (m_scriptExecutionContext->isContextThread())\n"); + push(@implContent, " ScriptExecutionContext* context = scriptExecutionContext();\n"); + push(@implContent, " // When the context is destroyed, all tasks with a reference to a callback\n"); + push(@implContent, " // should be deleted. So if the context is 0, we are on the context thread.\n"); + push(@implContent, " if (!context || context->isContextThread())\n"); push(@implContent, " delete m_data;\n"); push(@implContent, " else\n"); - push(@implContent, " m_scriptExecutionContext->postTask(DeleteCallbackDataTask::create(m_data));\n"); + push(@implContent, " context->postTask(DeleteCallbackDataTask::create(m_data));\n"); push(@implContent, "#ifndef NDEBUG\n"); push(@implContent, " m_data = 0;\n"); push(@implContent, "#endif\n"); @@ -2189,24 +2218,22 @@ sub GenerateCallbackImplementation } AddIncludesForType($function->signature->type); - push(@implContent, "\n" . GetNativeType($function->signature->type) . " ${className}::" . $function->signature->name . "(ScriptExecutionContext* context"); + push(@implContent, "\n" . GetNativeType($function->signature->type) . " ${className}::" . $function->signature->name . "("); + my @args = (); foreach my $param (@params) { AddIncludesForType($param->type, 1); - push(@implContent, ", " . GetNativeType($param->type) . " " . $param->name); + push(@args, GetNativeType($param->type) . " " . $param->name); } - + push(@implContent, join(", ", @args)); push(@implContent, ")\n"); push(@implContent, "{\n"); - push(@implContent, " ASSERT(m_data);\n"); - push(@implContent, " ASSERT(context);\n\n"); + push(@implContent, " if (!canInvokeCallback())\n"); + push(@implContent, " return true;\n\n"); push(@implContent, " RefPtr<$className> protect(this);\n\n"); push(@implContent, " JSLock lock(SilenceAssertionsOnly);\n\n"); - push(@implContent, " JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get());\n"); - push(@implContent, " if (!globalObject)\n"); - push(@implContent, " return true;\n\n"); - push(@implContent, " ExecState* exec = globalObject->globalExec();\n"); + push(@implContent, " ExecState* exec = m_data->globalObject()->globalExec();\n"); push(@implContent, " MarkedArgumentBuffer args;\n"); foreach my $param (@params) { @@ -2341,7 +2368,8 @@ sub JSValueToNative return "$value.toBoolean(exec)" if $type eq "boolean"; return "$value.toNumber(exec)" if $type eq "double"; return "$value.toFloat(exec)" if $type eq "float" or $type eq "SVGNumber"; - return "$value.toInt32(exec)" if $type eq "unsigned long" or $type eq "long" or $type eq "unsigned short"; + return "$value.toInt32(exec)" if $type eq "long"; + return "$value.toUInt32(exec)" if $type eq "unsigned long" or $type eq "unsigned short"; return "static_cast<$type>($value.toInteger(exec))" if $type eq "long long" or $type eq "unsigned long long"; return "valueToDate(exec, $value)" if $type eq "Date"; diff --git a/WebCore/bindings/scripts/CodeGeneratorObjC.pm b/WebCore/bindings/scripts/CodeGeneratorObjC.pm index 91cbd0b..7e17008 100644 --- a/WebCore/bindings/scripts/CodeGeneratorObjC.pm +++ b/WebCore/bindings/scripts/CodeGeneratorObjC.pm @@ -524,7 +524,7 @@ sub GetObjCTypeGetter if ($type eq "SerializedScriptValue") { $implIncludes{"SerializedScriptValue.h"} = 1; - return "WebCore::SerializedScriptValue::create(WebCore::String($argName))"; + return "WebCore::SerializedScriptValue::create(WTF::String($argName))"; } return "core($argName)"; } @@ -1242,7 +1242,7 @@ sub GenerateImplementation } $implIncludes{"DOMPrivate.h"} = 1; } elsif ($attribute->signature->extendedAttributes->{"ConvertToString"}) { - $getterContentHead = "WebCore::String::number(" . $getterContentHead; + $getterContentHead = "WTF::String::number(" . $getterContentHead; $getterContentTail .= ")"; } elsif ($codeGenerator->IsPodType($idlType) or $idlType eq "Date") { $getterContentHead = "kit($getterContentHead"; @@ -1304,7 +1304,7 @@ sub GenerateImplementation # The definition of ConvertToString is flipped for the setter if ($attribute->signature->extendedAttributes->{"ConvertToString"}) { - $arg = "WebCore::String($arg).toInt()"; + $arg = "WTF::String($arg).toInt()"; } my $setterSig = "- (void)$setterName:($attributeType)$argName\n"; diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm index c852f7b..4da8150 100644 --- a/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -1106,7 +1106,15 @@ END my $requiresAllArguments = $function->signature->extendedAttributes->{"RequiresAllArguments"}; if ($requiresAllArguments) { - push(@implContentDecls, " if (args.Length() < $numParameters)\n"); + my $numMandatoryParams = @{$function->parameters}; + foreach my $param (reverse(@{$function->parameters})) { + if ($param->extendedAttributes->{"Optional"}) { + $numMandatoryParams--; + } else { + last; + } + } + push(@implContentDecls, " if (args.Length() < $numMandatoryParams)\n"); if ($requiresAllArguments eq "Raise") { push(@implContentDecls, " return throwError(\"Not enough arguments\", V8Proxy::SyntaxError);\n"); } else { @@ -1175,7 +1183,9 @@ END my $parameterName = $parameter->name; - if ($parameter->extendedAttributes->{"Optional"}) { + # Optional callbacks should be treated differently, because they always have a default value (0), + # and we can reduce the number of overloaded functions that take a different number of parameters. + if ($parameter->extendedAttributes->{"Optional"} && !$parameter->extendedAttributes->{"Callback"}) { # Generate early call if there are not enough parameters. push(@implContentDecls, " if (args.Length() <= $paramIndex) {\n"); my $functionCall = GenerateFunctionCallString($function, $paramIndex, " " x 2, $implClassName); @@ -1183,55 +1193,60 @@ END push(@implContentDecls, " }\n"); } + if (BasicTypeCanFailConversion($parameter)) { + push(@implContentDecls, " bool ${parameterName}Ok;\n"); + } + + $implIncludes{"ExceptionCode.h"} = 1; + my $nativeType = GetNativeTypeFromSignature($parameter, $paramIndex); if ($parameter->extendedAttributes->{"Callback"}) { my $className = GetCallbackClassName($parameter->type); $implIncludes{"$className.h"} = 1; - $implIncludes{"ExceptionCode.h"} = 1; - push(@implContentDecls, " if (args.Length() <= $paramIndex || !args[$paramIndex]->IsObject())\n"); - push(@implContentDecls, " return throwError(TYPE_MISMATCH_ERR);\n"); - if ($parameter->type eq "VoidCallback") { - push(@implContentDecls, " RefPtr<" . $parameter->type . "> $parameterName = " . $className . "::create(args[$paramIndex], getScriptExecutionContext());\n"); + if ($parameter->extendedAttributes->{"Optional"}) { + push(@implContentDecls, " RefPtr<" . $parameter->type . "> $parameterName;\n"); + push(@implContentDecls, " if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n"); + push(@implContentDecls, " if (!args[$paramIndex]->IsObject())\n"); + push(@implContentDecls, " return throwError(TYPE_MISMATCH_ERR);\n"); + push(@implContentDecls, " $parameterName = ${className}::create(args[$paramIndex], getScriptExecutionContext());\n"); + push(@implContentDecls, " }\n"); } else { - push(@implContentDecls, " RefPtr<" . $parameter->type . "> $parameterName = " . $className . "::create(args[$paramIndex]);\n"); + push(@implContentDecls, " if (args.Length() <= $paramIndex || !args[$paramIndex]->IsObject())\n"); + push(@implContentDecls, " return throwError(TYPE_MISMATCH_ERR);\n"); + push(@implContentDecls, " RefPtr<" . $parameter->type . "> $parameterName = ${className}::create(args[$paramIndex], getScriptExecutionContext());\n"); } - $paramIndex++; - next; - } - - if ($parameter->type eq "SerializedScriptValue") { + } elsif ($parameter->type eq "SerializedScriptValue") { $implIncludes{"SerializedScriptValue.h"} = 1; push(@implContentDecls, " bool ${parameterName}DidThrow = false;\n"); - } elsif (BasicTypeCanFailConversion($parameter)) { - push(@implContentDecls, " bool ${parameterName}Ok;\n"); - } - - push(@implContentDecls, " " . GetNativeTypeFromSignature($parameter, $paramIndex) . " $parameterName = "); - - if ($parameter->type eq "SerializedScriptValue") { - push(@implContentDecls, "SerializedScriptValue::create(args[$paramIndex], ${parameterName}DidThrow);\n"); + push(@implContentDecls, " $nativeType $parameterName = SerializedScriptValue::create(args[$paramIndex], ${parameterName}DidThrow);\n"); push(@implContentDecls, " if (${parameterName}DidThrow)\n"); push(@implContentDecls, " return v8::Undefined();\n"); + } elsif (TypeCanFailConversion($parameter)) { + push(@implContentDecls, " $nativeType $parameterName = " . + JSValueToNative($parameter, "args[$paramIndex]", BasicTypeCanFailConversion($parameter) ? "${parameterName}Ok" : undef) . ";\n"); + push(@implContentDecls, " if (UNLIKELY(!$parameterName" . (BasicTypeCanFailConversion($parameter) ? "Ok" : "") . ")) {\n"); + push(@implContentDecls, " ec = TYPE_MISMATCH_ERR;\n"); + push(@implContentDecls, " goto fail;\n"); + push(@implContentDecls, " }\n"); + } elsif ($nativeType =~ /^V8Parameter/) { + my $value = JSValueToNative($parameter, "args[$paramIndex]", BasicTypeCanFailConversion($parameter) ? "${parameterName}Ok" : undef); + if ($parameter->type eq "DOMString") { + $implIncludes{"V8BindingMacros.h"} = 1; + push(@implContentDecls, " STRING_TO_V8PARAMETER_EXCEPTION_BLOCK($nativeType, $parameterName, $value);\n"); + } else { + # Don't know how to properly check for conversion exceptions when $parameter->type is "DOMUserData" + push(@implContentDecls, " $nativeType $parameterName = $value;\n"); + } } else { - push(@implContentDecls, JSValueToNative($parameter, "args[$paramIndex]", - BasicTypeCanFailConversion($parameter) ? "${parameterName}Ok" : undef) . ";\n"); - } - - if (TypeCanFailConversion($parameter)) { - $implIncludes{"ExceptionCode.h"} = 1; - push(@implContentDecls, -" if (UNLIKELY(!$parameterName" . (BasicTypeCanFailConversion($parameter) ? "Ok" : "") . ")) {\n" . -" ec = TYPE_MISMATCH_ERR;\n" . -" goto fail;\n" . -" }\n"); + $implIncludes{"V8BindingMacros.h"} = 1; + push(@implContentDecls, " EXCEPTION_BLOCK($nativeType, $parameterName, " . + JSValueToNative($parameter, "args[$paramIndex]", BasicTypeCanFailConversion($parameter) ? "${parameterName}Ok" : undef) . ");\n"); } if ($parameter->extendedAttributes->{"IsIndex"}) { - $implIncludes{"ExceptionCode.h"} = 1; - push(@implContentDecls, -" if (UNLIKELY($parameterName < 0)) {\n" . -" ec = INDEX_SIZE_ERR;\n" . -" goto fail;\n" . -" }\n"); + push(@implContentDecls, " if (UNLIKELY($parameterName < 0)) {\n"); + push(@implContentDecls, " ec = INDEX_SIZE_ERR;\n"); + push(@implContentDecls, " goto fail;\n"); + push(@implContentDecls, " }\n"); } $paramIndex++; @@ -2129,25 +2144,25 @@ sub GenerateCallbackHeader # - Add default header template push(@headerContent, GenerateHeaderContentHeader($dataNode)); - if ("$interfaceName.h" lt "WorldContextHandle.h") { - push(@headerContent, "#include \"$interfaceName.h\"\n"); - push(@headerContent, "#include \"WorldContextHandle.h\"\n"); - } else { - push(@headerContent, "#include \"WorldContextHandle.h\"\n"); - push(@headerContent, "#include \"$interfaceName.h\"\n"); - } - push(@headerContent, "#include <v8.h>\n"); - push(@headerContent, "#include <wtf/Forward.h>\n"); + my @unsortedIncludes = (); + push(@unsortedIncludes, "#include \"ActiveDOMCallback.h\""); + push(@unsortedIncludes, "#include \"$interfaceName.h\""); + push(@unsortedIncludes, "#include \"WorldContextHandle.h\""); + push(@unsortedIncludes, "#include <v8.h>"); + push(@unsortedIncludes, "#include <wtf/Forward.h>"); + push(@headerContent, join("\n", sort @unsortedIncludes)); - push(@headerContent, "\nnamespace WebCore {\n\n"); - push(@headerContent, "class $className : public $interfaceName {\n"); + push(@headerContent, "\n\nnamespace WebCore {\n\n"); + push(@headerContent, "class ScriptExecutionContext;\n\n"); + push(@headerContent, "class $className : public $interfaceName, public ActiveDOMCallback {\n"); push(@headerContent, <<END); public: - static PassRefPtr<${className}> create(v8::Local<v8::Value> value) + static PassRefPtr<${className}> create(v8::Local<v8::Value> value, ScriptExecutionContext* context) { ASSERT(value->IsObject()); - return adoptRef(new ${className}(value->ToObject())); + ASSERT(context); + return adoptRef(new ${className}(value->ToObject(), context)); } virtual ~${className}(); @@ -2165,11 +2180,13 @@ END push(@headerContent, " COMPILE_ASSERT(false)"); } - push(@headerContent, " virtual " . GetNativeTypeForCallbacks($function->signature->type) . " " . $function->signature->name . "(ScriptExecutionContext*"); + push(@headerContent, " virtual " . GetNativeTypeForCallbacks($function->signature->type) . " " . $function->signature->name . "("); + + my @args = (); foreach my $param (@params) { - push(@headerContent, ", " . GetNativeTypeForCallbacks($param->type) . " " . $param->name); + push(@args, GetNativeTypeForCallbacks($param->type) . " " . $param->name); } - + push(@headerContent, join(", ", @args)); push(@headerContent, ");\n"); } } @@ -2177,7 +2194,7 @@ END push(@headerContent, <<END); private: - ${className}(v8::Local<v8::Object>); + ${className}(v8::Local<v8::Object>, ScriptExecutionContext*); v8::Persistent<v8::Object> m_callback; WorldContextHandle m_worldContext; @@ -2209,8 +2226,9 @@ sub GenerateCallbackImplementation push(@implContent, "#include <wtf/Assertions.h>\n\n"); push(@implContent, "namespace WebCore {\n\n"); push(@implContent, <<END); -${className}::${className}(v8::Local<v8::Object> callback) - : m_callback(v8::Persistent<v8::Object>::New(callback)) +${className}::${className}(v8::Local<v8::Object> callback, ScriptExecutionContext* context) + : ActiveDOMCallback(context) + , m_callback(v8::Persistent<v8::Object>::New(callback)) , m_worldContext(UseCurrentWorld) { } @@ -2234,22 +2252,26 @@ END } AddIncludesForType($function->signature->type); - push(@implContent, "\n" . GetNativeTypeForCallbacks($function->signature->type) . " ${className}::" . $function->signature->name . "(ScriptExecutionContext* context"); + push(@implContent, "\n" . GetNativeTypeForCallbacks($function->signature->type) . " ${className}::" . $function->signature->name . "("); + my @args = (); foreach my $param (@params) { AddIncludesForType($param->type); - push(@implContent, ", " . GetNativeTypeForCallbacks($param->type) . " " . $param->name); + push(@args, GetNativeTypeForCallbacks($param->type) . " " . $param->name); } + push(@implContent, join(", ", @args)); push(@implContent, ")\n"); push(@implContent, "{\n"); + push(@implContent, " if (!canInvokeCallback())\n"); + push(@implContent, " return true;\n\n"); push(@implContent, " v8::HandleScope handleScope;\n\n"); - push(@implContent, " v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext);\n"); + push(@implContent, " v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);\n"); push(@implContent, " if (v8Context.IsEmpty())\n"); push(@implContent, " return true;\n\n"); push(@implContent, " v8::Context::Scope scope(v8Context);\n\n"); - my @argvs = (); + @args = (); foreach my $param (@params) { my $paramName = $param->name; push(@implContent, " v8::Handle<v8::Value> ${paramName}Handle = toV8(${paramName});\n"); @@ -2257,14 +2279,14 @@ END push(@implContent, " CRASH();\n"); push(@implContent, " return true;\n"); push(@implContent, " }\n"); - push(@argvs, " ${paramName}Handle"); + push(@args, " ${paramName}Handle"); } push(@implContent, "\n v8::Handle<v8::Value> argv[] = {\n"); - push(@implContent, join(",\n", @argvs)); + push(@implContent, join(",\n", @args)); push(@implContent, "\n };\n\n"); push(@implContent, " bool callbackReturnValue = false;\n"); - push(@implContent, " return !invokeCallback(m_callback, " . scalar(@params) . ", argv, callbackReturnValue, context);\n"); + push(@implContent, " return !invokeCallback(m_callback, " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n"); push(@implContent, "}\n"); } } @@ -2822,7 +2844,8 @@ sub JSValueToNative return "static_cast<$type>($value->NumberValue())" if $type eq "float" or $type eq "double"; return "$value->NumberValue()" if $type eq "SVGNumber"; - return "toInt32($value${maybeOkParam})" if $type eq "unsigned long" or $type eq "unsigned short" or $type eq "long"; + return "toInt32($value${maybeOkParam})" if $type eq "long"; + return "toUInt32($value${maybeOkParam})" if $type eq "unsigned long" or $type eq "unsigned short"; return "toInt64($value)" if $type eq "unsigned long long" or $type eq "long long"; return "static_cast<Range::CompareHow>($value->Int32Value())" if $type eq "CompareHow"; return "static_cast<SVGPaint::SVGPaintType>($value->ToInt32()->Int32Value())" if $type eq "SVGPaintType"; @@ -2952,7 +2975,7 @@ sub RequiresCustomSignature } foreach my $parameter (@{$function->parameters}) { - if ($parameter->extendedAttributes->{"Optional"}) { + if ($parameter->extendedAttributes->{"Optional"} || $parameter->extendedAttributes->{"Callback"}) { return 0; } } diff --git a/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp b/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp index b8c551e..20de4fc 100644 --- a/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp +++ b/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp @@ -85,7 +85,7 @@ WebDOMString WebDOMTestObj::readOnlyStringAttr() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->readOnlyStringAttr()); + return static_cast<const WTF::String&>(impl()->readOnlyStringAttr()); } WebDOMTestObj WebDOMTestObj::readOnlyTestObjAttr() const @@ -149,7 +149,7 @@ WebDOMString WebDOMTestObj::stringAttr() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->stringAttr()); + return static_cast<const WTF::String&>(impl()->stringAttr()); } void WebDOMTestObj::setStringAttr(const WebDOMString& newStringAttr) @@ -213,7 +213,7 @@ WebDOMString WebDOMTestObj::reflectedStringAttr() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr)); + return static_cast<const WTF::String&>(impl()->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr)); } void WebDOMTestObj::setReflectedStringAttr(const WebDOMString& newReflectedStringAttr) @@ -261,7 +261,7 @@ WebDOMString WebDOMTestObj::reflectedURLAttr() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr)); + return static_cast<const WTF::String&>(impl()->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr)); } void WebDOMTestObj::setReflectedURLAttr(const WebDOMString& newReflectedURLAttr) @@ -277,7 +277,7 @@ WebDOMString WebDOMTestObj::reflectedNonEmptyURLAttr() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->getNonEmptyURLAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr)); + return static_cast<const WTF::String&>(impl()->getNonEmptyURLAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr)); } void WebDOMTestObj::setReflectedNonEmptyURLAttr(const WebDOMString& newReflectedNonEmptyURLAttr) @@ -293,7 +293,7 @@ WebDOMString WebDOMTestObj::reflectedStringAttr() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr)); + return static_cast<const WTF::String&>(impl()->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr)); } void WebDOMTestObj::setReflectedStringAttr(const WebDOMString& newReflectedStringAttr) @@ -341,7 +341,7 @@ WebDOMString WebDOMTestObj::reflectedCustomURLAttr() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr)); + return static_cast<const WTF::String&>(impl()->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr)); } void WebDOMTestObj::setReflectedCustomURLAttr(const WebDOMString& newReflectedCustomURLAttr) @@ -357,7 +357,7 @@ WebDOMString WebDOMTestObj::reflectedCustomNonEmptyURLAttr() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->getNonEmptyURLAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr)); + return static_cast<const WTF::String&>(impl()->getNonEmptyURLAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr)); } void WebDOMTestObj::setReflectedCustomNonEmptyURLAttr(const WebDOMString& newReflectedCustomNonEmptyURLAttr) @@ -415,7 +415,7 @@ WebDOMString WebDOMTestObj::stringAttrWithGetterException() const WebCore::ExceptionCode ec = 0; WebDOMString result = impl()->stringAttrWithGetterException(ec); webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); - return static_cast<const WebCore::String&>(result); + return static_cast<const WTF::String&>(result); } void WebDOMTestObj::setStringAttrWithGetterException(const WebDOMString& newStringAttrWithGetterException) @@ -433,7 +433,7 @@ WebDOMString WebDOMTestObj::stringAttrWithSetterException() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->stringAttrWithSetterException()); + return static_cast<const WTF::String&>(impl()->stringAttrWithSetterException()); } void WebDOMTestObj::setStringAttrWithSetterException(const WebDOMString& newStringAttrWithSetterException) @@ -451,7 +451,7 @@ WebDOMString WebDOMTestObj::scriptStringAttr() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->scriptStringAttr()); + return static_cast<const WTF::String&>(impl()->scriptStringAttr()); } #if ENABLE(Condition1) @@ -537,7 +537,7 @@ WebDOMString WebDOMTestObj::hash() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->hash()); + return static_cast<const WTF::String&>(impl()->hash()); } void WebDOMTestObj::voidMethod() @@ -612,7 +612,7 @@ void WebDOMTestObj::serializedValue(const WebDOMString& serializedArg) if (!impl()) return; - impl()->serializedValue(WebCore::SerializedScriptValue::create(WebCore::String(serializedArg))); + impl()->serializedValue(WebCore::SerializedScriptValue::create(WTF::String(serializedArg))); } void WebDOMTestObj::idbKey(const WebDOMIDBKey& key) diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp index 6581b1f..8f69a9f 100644 --- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp @@ -78,7 +78,7 @@ webkit_dom_test_callback_callback_with_class2param(WebKitDOMTestCallback* self, g_return_val_if_fail(str_arg, 0); WebCore::Class2 * converted_class2param = WebKit::core(class2param); g_return_val_if_fail(converted_class2param, 0); - WebCore::String converted_str_arg = WebCore::String::fromUTF8(str_arg); + WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); gboolean res = item->callbackWithClass2Param(converted_class2param, converted_str_arg); return res; } diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp index 6a8399e..8cad49d 100644 --- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp @@ -69,7 +69,7 @@ webkit_dom_test_obj_void_method_with_args(WebKitDOMTestObj* self, glong int_arg, WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(str_arg); g_return_if_fail(obj_arg); - WebCore::String converted_str_arg = WebCore::String::fromUTF8(str_arg); + WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); WebCore::TestObj * converted_obj_arg = WebKit::core(obj_arg); g_return_if_fail(converted_obj_arg); item->voidMethodWithArgs(int_arg, converted_str_arg, converted_obj_arg); @@ -93,7 +93,7 @@ webkit_dom_test_obj_int_method_with_args(WebKitDOMTestObj* self, glong int_arg, WebCore::TestObj * item = WebKit::core(self); g_return_val_if_fail(str_arg, 0); g_return_val_if_fail(obj_arg, 0); - WebCore::String converted_str_arg = WebCore::String::fromUTF8(str_arg); + WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); WebCore::TestObj * converted_obj_arg = WebKit::core(obj_arg); g_return_val_if_fail(converted_obj_arg, 0); glong res = item->intMethodWithArgs(int_arg, converted_str_arg, converted_obj_arg); @@ -119,7 +119,7 @@ webkit_dom_test_obj_obj_method_with_args(WebKitDOMTestObj* self, glong int_arg, WebCore::TestObj * item = WebKit::core(self); g_return_val_if_fail(str_arg, 0); g_return_val_if_fail(obj_arg, 0); - WebCore::String converted_str_arg = WebCore::String::fromUTF8(str_arg); + WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); WebCore::TestObj * converted_obj_arg = WebKit::core(obj_arg); g_return_val_if_fail(converted_obj_arg, 0); PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->objMethodWithArgs(int_arg, converted_str_arg, converted_obj_arg)); @@ -135,7 +135,7 @@ webkit_dom_test_obj_method_that_requires_all_args(WebKitDOMTestObj* self, gchar* WebCore::TestObj * item = WebKit::core(self); g_return_val_if_fail(str_arg, 0); g_return_val_if_fail(obj_arg, 0); - WebCore::String converted_str_arg = WebCore::String::fromUTF8(str_arg); + WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); WebCore::TestObj * converted_obj_arg = WebKit::core(obj_arg); g_return_val_if_fail(converted_obj_arg, 0); PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->methodThatRequiresAllArgs(converted_str_arg, converted_obj_arg)); @@ -151,7 +151,7 @@ webkit_dom_test_obj_method_that_requires_all_args_and_throws(WebKitDOMTestObj* s WebCore::TestObj * item = WebKit::core(self); g_return_val_if_fail(str_arg, 0); g_return_val_if_fail(obj_arg, 0); - WebCore::String converted_str_arg = WebCore::String::fromUTF8(str_arg); + WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); WebCore::TestObj * converted_obj_arg = WebKit::core(obj_arg); g_return_val_if_fail(converted_obj_arg, 0); WebCore::ExceptionCode ec = 0; @@ -448,7 +448,7 @@ webkit_dom_test_obj_set_string_attr(WebKitDOMTestObj* self, gchar* value) g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); - WebCore::String converted_value = WebCore::String::fromUTF8(value); + WTF::String converted_value = WTF::String::fromUTF8(value); item->setStringAttr(converted_value); } @@ -534,7 +534,7 @@ webkit_dom_test_obj_set_reflected_string_attr(WebKitDOMTestObj* self, gchar* va g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); - WebCore::String converted_value = WebCore::String::fromUTF8(value); + WTF::String converted_value = WTF::String::fromUTF8(value); item->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, converted_value); } @@ -593,7 +593,7 @@ webkit_dom_test_obj_set_reflected_url_attr(WebKitDOMTestObj* self, gchar* value g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); - WebCore::String converted_value = WebCore::String::fromUTF8(value); + WTF::String converted_value = WTF::String::fromUTF8(value); item->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, converted_value); } @@ -614,7 +614,7 @@ webkit_dom_test_obj_set_reflected_non_empty_url_attr(WebKitDOMTestObj* self, gch g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); - WebCore::String converted_value = WebCore::String::fromUTF8(value); + WTF::String converted_value = WTF::String::fromUTF8(value); item->setAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr, converted_value); } @@ -635,7 +635,7 @@ webkit_dom_test_obj_set_reflected_string_attr(WebKitDOMTestObj* self, gchar* va g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); - WebCore::String converted_value = WebCore::String::fromUTF8(value); + WTF::String converted_value = WTF::String::fromUTF8(value); item->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, converted_value); } @@ -694,7 +694,7 @@ webkit_dom_test_obj_set_reflected_custom_url_attr(WebKitDOMTestObj* self, gchar* g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); - WebCore::String converted_value = WebCore::String::fromUTF8(value); + WTF::String converted_value = WTF::String::fromUTF8(value); item->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, converted_value); } @@ -715,7 +715,7 @@ webkit_dom_test_obj_set_reflected_custom_non_empty_url_attr(WebKitDOMTestObj* se g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); - WebCore::String converted_value = WebCore::String::fromUTF8(value); + WTF::String converted_value = WTF::String::fromUTF8(value); item->setAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr, converted_value); } @@ -793,7 +793,7 @@ webkit_dom_test_obj_set_string_attr_with_getter_exception(WebKitDOMTestObj* self g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); - WebCore::String converted_value = WebCore::String::fromUTF8(value); + WTF::String converted_value = WTF::String::fromUTF8(value); WebCore::ExceptionCode ec = 0; item->setStringAttrWithGetterException(converted_value, ec); if (ec) { @@ -820,7 +820,7 @@ webkit_dom_test_obj_set_string_attr_with_setter_exception(WebKitDOMTestObj* self g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); - WebCore::String converted_value = WebCore::String::fromUTF8(value); + WTF::String converted_value = WTF::String::fromUTF8(value); WebCore::ExceptionCode ec = 0; item->setStringAttrWithSetterException(converted_value, ec); if (ec) { @@ -1041,7 +1041,7 @@ static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, con } case PROP_STRING_ATTR: { - coreSelf->setStringAttr(WebCore::String::fromUTF8(g_value_get_string(value))); + coreSelf->setStringAttr(WTF::String::fromUTF8(g_value_get_string(value))); break; } case PROP_CREATE: @@ -1051,7 +1051,7 @@ static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, con } case PROP_REFLECTED_STRING_ATTR: { - coreSelf->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, WebCore::String::fromUTF8(g_value_get_string(value))); + coreSelf->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, WTF::String::fromUTF8(g_value_get_string(value))); break; } case PROP_REFLECTED_INTEGRAL_ATTR: @@ -1066,17 +1066,17 @@ static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, con } case PROP_REFLECTED_URL_ATTR: { - coreSelf->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, WebCore::String::fromUTF8(g_value_get_string(value))); + coreSelf->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, WTF::String::fromUTF8(g_value_get_string(value))); break; } case PROP_REFLECTED_NON_EMPTY_URL_ATTR: { - coreSelf->setAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr, WebCore::String::fromUTF8(g_value_get_string(value))); + coreSelf->setAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr, WTF::String::fromUTF8(g_value_get_string(value))); break; } case PROP_REFLECTED_STRING_ATTR: { - coreSelf->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, WebCore::String::fromUTF8(g_value_get_string(value))); + coreSelf->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, WTF::String::fromUTF8(g_value_get_string(value))); break; } case PROP_REFLECTED_CUSTOM_INTEGRAL_ATTR: @@ -1091,12 +1091,12 @@ static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, con } case PROP_REFLECTED_CUSTOM_URL_ATTR: { - coreSelf->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, WebCore::String::fromUTF8(g_value_get_string(value))); + coreSelf->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, WTF::String::fromUTF8(g_value_get_string(value))); break; } case PROP_REFLECTED_CUSTOM_NON_EMPTY_URL_ATTR: { - coreSelf->setAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr, WebCore::String::fromUTF8(g_value_get_string(value))); + coreSelf->setAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr, WTF::String::fromUTF8(g_value_get_string(value))); break; } case PROP_ATTR_WITH_GETTER_EXCEPTION: @@ -1114,13 +1114,13 @@ static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, con case PROP_STRING_ATTR_WITH_GETTER_EXCEPTION: { WebCore::ExceptionCode ec = 0; - coreSelf->setStringAttrWithGetterException(WebCore::String::fromUTF8(g_value_get_string(value)), ec); + coreSelf->setStringAttrWithGetterException(WTF::String::fromUTF8(g_value_get_string(value)), ec); break; } case PROP_STRING_ATTR_WITH_SETTER_EXCEPTION: { WebCore::ExceptionCode ec = 0; - coreSelf->setStringAttrWithSetterException(WebCore::String::fromUTF8(g_value_get_string(value)), ec); + coreSelf->setStringAttrWithSetterException(WTF::String::fromUTF8(g_value_get_string(value)), ec); break; } #if ENABLE(Condition1) diff --git a/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp b/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp index 6f6b568..069b8ae 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp +++ b/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp @@ -35,18 +35,20 @@ using namespace JSC; namespace WebCore { JSTestCallback::JSTestCallback(JSObject* callback, JSDOMGlobalObject* globalObject) - : m_data(new JSCallbackData(callback, globalObject)) - , m_isolatedWorld(globalObject->world()) - , m_scriptExecutionContext(globalObject->scriptExecutionContext()) + : ActiveDOMCallback(globalObject->scriptExecutionContext()) + , m_data(new JSCallbackData(callback, globalObject)) { } JSTestCallback::~JSTestCallback() { - if (m_scriptExecutionContext->isContextThread()) + ScriptExecutionContext* context = scriptExecutionContext(); + // When the context is destroyed, all tasks with a reference to a callback + // should be deleted. So if the context is 0, we are on the context thread. + if (!context || context->isContextThread()) delete m_data; else - m_scriptExecutionContext->postTask(DeleteCallbackDataTask::create(m_data)); + context->postTask(DeleteCallbackDataTask::create(m_data)); #ifndef NDEBUG m_data = 0; #endif @@ -54,20 +56,16 @@ JSTestCallback::~JSTestCallback() // Functions -bool JSTestCallback::callbackWithClass1Param(ScriptExecutionContext* context, Class1* class1Param) +bool JSTestCallback::callbackWithClass1Param(Class1* class1Param) { - ASSERT(m_data); - ASSERT(context); + if (!canInvokeCallback()) + return true; RefPtr<JSTestCallback> protect(this); JSLock lock(SilenceAssertionsOnly); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get()); - if (!globalObject) - return true; - - ExecState* exec = globalObject->globalExec(); + ExecState* exec = m_data->globalObject()->globalExec(); MarkedArgumentBuffer args; args.append(toJS(exec, class1Param)); @@ -76,20 +74,16 @@ bool JSTestCallback::callbackWithClass1Param(ScriptExecutionContext* context, Cl return !raisedException; } -bool JSTestCallback::callbackWithClass2Param(ScriptExecutionContext* context, Class2* class2Param, const String& strArg) +bool JSTestCallback::callbackWithClass2Param(Class2* class2Param, const String& strArg) { - ASSERT(m_data); - ASSERT(context); + if (!canInvokeCallback()) + return true; RefPtr<JSTestCallback> protect(this); JSLock lock(SilenceAssertionsOnly); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get()); - if (!globalObject) - return true; - - ExecState* exec = globalObject->globalExec(); + ExecState* exec = m_data->globalObject()->globalExec(); MarkedArgumentBuffer args; args.append(toJS(exec, class2Param)); args.append(jsString(exec, strArg)); diff --git a/WebCore/bindings/scripts/test/JS/JSTestCallback.h b/WebCore/bindings/scripts/test/JS/JSTestCallback.h index 47a5e95..ae91a6c 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestCallback.h +++ b/WebCore/bindings/scripts/test/JS/JSTestCallback.h @@ -23,13 +23,14 @@ #if ENABLE(DATABASE) +#include "ActiveDOMCallback.h" #include "JSCallbackData.h" #include "TestCallback.h" #include <wtf/Forward.h> namespace WebCore { -class JSTestCallback : public TestCallback { +class JSTestCallback : public TestCallback, public ActiveDOMCallback { public: static PassRefPtr<JSTestCallback> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject) { @@ -39,17 +40,15 @@ public: virtual ~JSTestCallback(); // Functions - virtual bool callbackWithClass1Param(ScriptExecutionContext*, Class1* class1Param); - virtual bool callbackWithClass2Param(ScriptExecutionContext*, Class2* class2Param, const String& strArg); - COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(ScriptExecutionContext*, Class3* class3Param); - virtual int customCallback(ScriptExecutionContext*, Class5* class5Param, Class6* class6Param); + virtual bool callbackWithClass1Param(Class1* class1Param); + virtual bool callbackWithClass2Param(Class2* class2Param, const String& strArg); + COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(Class3* class3Param); + virtual int customCallback(Class5* class5Param, Class6* class6Param); private: JSTestCallback(JSC::JSObject* callback, JSDOMGlobalObject*); JSCallbackData* m_data; - RefPtr<DOMWrapperWorld> m_isolatedWorld; - ScriptExecutionContext* m_scriptExecutionContext; }; } // namespace WebCore diff --git a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp index 9c11bde..01a860c 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp +++ b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp @@ -25,6 +25,7 @@ #include "HTMLNames.h" #include "IDBBindingUtilities.h" #include "IDBKey.h" +#include "JSDOMBinding.h" #include "JSEventListener.h" #include "JSTestCallback.h" #include "JSTestObj.h" @@ -794,8 +795,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethodWithArgs(ExecSt JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); const String& strArg = ustringToString(exec->argument(1).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); TestObj* objArg = toTestObj(exec->argument(2)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->voidMethodWithArgs(intArg, strArg, objArg); return JSValue::encode(jsUndefined()); @@ -822,8 +829,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethodWithArgs(ExecSta JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); const String& strArg = ustringToString(exec->argument(1).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); TestObj* objArg = toTestObj(exec->argument(2)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); JSC::JSValue result = jsNumber(exec, imp->intMethodWithArgs(intArg, strArg, objArg)); @@ -851,8 +864,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(ExecSta JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); const String& strArg = ustringToString(exec->argument(1).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); TestObj* objArg = toTestObj(exec->argument(2)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->objMethodWithArgs(intArg, strArg, objArg))); @@ -869,7 +888,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgs if (exec->argumentCount() < 2) return JSValue::encode(jsUndefined()); const String& strArg = ustringToString(exec->argument(0).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); TestObj* objArg = toTestObj(exec->argument(1)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->methodThatRequiresAllArgs(strArg, objArg))); @@ -887,7 +910,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgs return throwVMError(exec, createSyntaxError(exec, "Not enough arguments")); ExceptionCode ec = 0; const String& strArg = ustringToString(exec->argument(0).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); TestObj* objArg = toTestObj(exec->argument(1)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->methodThatRequiresAllArgsAndThrows(strArg, objArg, ec))); @@ -903,6 +930,8 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(ExecState JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(exec, exec->argument(0)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->serializedValue(serializedArg); return JSValue::encode(jsUndefined()); @@ -916,6 +945,8 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIdbKey(ExecState* exec) JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); RefPtr<IDBKey> key = createIDBKeyFromValue(exec, exec->argument(0)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->idbKey(key); return JSValue::encode(jsUndefined()); @@ -963,6 +994,8 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomArgsAndException(Ex ExceptionCode ec = 0; ScriptCallStack callStack(exec, 1); log* intArg = tolog(exec->argument(0)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->customArgsAndException(intArg, &callStack, ec); setDOMException(exec, ec); @@ -1023,6 +1056,8 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndArg(Ex if (!dynamicFrame) return JSValue::encode(jsUndefined()); int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->withDynamicFrameAndArg(dynamicFrame, intArg); return JSValue::encode(jsUndefined()); @@ -1039,14 +1074,18 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndOption if (!dynamicFrame) return JSValue::encode(jsUndefined()); int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); int argsCount = exec->argumentCount(); - if (argsCount < 2) { + if (argsCount <= 1) { imp->withDynamicFrameAndOptionalArg(dynamicFrame, intArg); return JSValue::encode(jsUndefined()); } int optionalArg = exec->argument(1).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->withDynamicFrameAndOptionalArg(dynamicFrame, intArg, optionalArg); return JSValue::encode(jsUndefined()); @@ -1063,6 +1102,8 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGe if (!dynamicFrame) return JSValue::encode(jsUndefined()); int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->withDynamicFrameAndUserGesture(dynamicFrame, intArg, processingUserGesture(exec)); return JSValue::encode(jsUndefined()); @@ -1079,14 +1120,18 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGe if (!dynamicFrame) return JSValue::encode(jsUndefined()); int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); int argsCount = exec->argumentCount(); - if (argsCount < 2) { + if (argsCount <= 1) { imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg); return JSValue::encode(jsUndefined()); } int optionalArg = exec->argument(1).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg, optionalArg, processingUserGesture(exec)); return JSValue::encode(jsUndefined()); @@ -1174,12 +1219,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(Exe TestObj* imp = static_cast<TestObj*>(castedThis->impl()); int argsCount = exec->argumentCount(); - if (argsCount < 1) { + if (argsCount <= 0) { imp->methodWithOptionalArg(); return JSValue::encode(jsUndefined()); } int opt = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->methodWithOptionalArg(opt); return JSValue::encode(jsUndefined()); @@ -1193,14 +1240,18 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgA JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); int nonOpt = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); int argsCount = exec->argumentCount(); - if (argsCount < 2) { + if (argsCount <= 1) { imp->methodWithNonOptionalArgAndOptionalArg(nonOpt); return JSValue::encode(jsUndefined()); } int opt = exec->argument(1).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt); return JSValue::encode(jsUndefined()); @@ -1214,15 +1265,21 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgA JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); int nonOpt = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); int argsCount = exec->argumentCount(); - if (argsCount < 2) { + if (argsCount <= 1) { imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt); return JSValue::encode(jsUndefined()); } int opt1 = exec->argument(1).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); int opt2 = exec->argument(2).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2); return JSValue::encode(jsUndefined()); @@ -1237,7 +1294,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackArg(Exe TestObj* imp = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() <= 0 || !exec->argument(0).isObject()) { setDOMException(exec, TYPE_MISMATCH_ERR); - return jsUndefined(); + return JSValue::encode(jsUndefined()); } RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject()); @@ -1253,9 +1310,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonCallbackArgA JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); int nonCallback = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); if (exec->argumentCount() <= 1 || !exec->argument(1).isObject()) { setDOMException(exec, TYPE_MISMATCH_ERR); - return jsUndefined(); + return JSValue::encode(jsUndefined()); } RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(1)), castedThis->globalObject()); @@ -1270,18 +1329,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackAndOpti return throwVMTypeError(exec); JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - - int argsCount = exec->argumentCount(); - if (argsCount < 1) { - imp->methodWithCallbackAndOptionalArg(); - return JSValue::encode(jsUndefined()); - } - - if (exec->argumentCount() <= 0 || !exec->argument(0).isObject()) { - setDOMException(exec, TYPE_MISMATCH_ERR); - return jsUndefined(); + RefPtr<TestCallback> callback; + if (exec->argumentCount() > 0 && !exec->argument(0).isNull() && !exec->argument(0).isUndefined()) { + if (!exec->argument(0).isObject()) { + setDOMException(exec, TYPE_MISMATCH_ERR); + return JSValue::encode(jsUndefined()); + } + callback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject()); } - RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject()); imp->methodWithCallbackAndOptionalArg(callback); return JSValue::encode(jsUndefined()); @@ -1295,7 +1350,11 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod1( JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); TestObj* objArg = toTestObj(exec->argument(0)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); const String& strArg = ustringToString(exec->argument(1).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->overloadedMethod(objArg, strArg); return JSValue::encode(jsUndefined()); @@ -1309,14 +1368,18 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod2( JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); TestObj* objArg = toTestObj(exec->argument(0)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); int argsCount = exec->argumentCount(); - if (argsCount < 2) { + if (argsCount <= 1) { imp->overloadedMethod(objArg); return JSValue::encode(jsUndefined()); } int intArg = exec->argument(1).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->overloadedMethod(objArg, intArg); return JSValue::encode(jsUndefined()); @@ -1330,6 +1393,8 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod3( JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); const String& strArg = ustringToString(exec->argument(0).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->overloadedMethod(strArg); return JSValue::encode(jsUndefined()); @@ -1343,6 +1408,8 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod4( JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->overloadedMethod(intArg); return JSValue::encode(jsUndefined()); diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm index 71d3508..01fcf34 100644 --- a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm @@ -500,7 +500,7 @@ - (void)serializedValue:(NSString *)serializedArg { WebCore::JSMainThreadNullState state; - IMPL->serializedValue(WebCore::SerializedScriptValue::create(WebCore::String(serializedArg))); + IMPL->serializedValue(WebCore::SerializedScriptValue::create(WTF::String(serializedArg))); } - (void)idbKey:(DOMIDBKey *)key diff --git a/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp b/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp index eff4ebd..c286c24 100644 --- a/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp +++ b/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp @@ -34,8 +34,9 @@ namespace WebCore { -V8TestCallback::V8TestCallback(v8::Local<v8::Object> callback) - : m_callback(v8::Persistent<v8::Object>::New(callback)) +V8TestCallback::V8TestCallback(v8::Local<v8::Object> callback, ScriptExecutionContext* context) + : ActiveDOMCallback(context) + , m_callback(v8::Persistent<v8::Object>::New(callback)) , m_worldContext(UseCurrentWorld) { } @@ -47,11 +48,14 @@ V8TestCallback::~V8TestCallback() // Functions -bool V8TestCallback::callbackWithClass1Param(ScriptExecutionContext* context, Class1* class1Param) +bool V8TestCallback::callbackWithClass1Param(Class1* class1Param) { + if (!canInvokeCallback()) + return true; + v8::HandleScope handleScope; - v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext); + v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext); if (v8Context.IsEmpty()) return true; @@ -68,14 +72,17 @@ bool V8TestCallback::callbackWithClass1Param(ScriptExecutionContext* context, Cl }; bool callbackReturnValue = false; - return !invokeCallback(m_callback, 1, argv, callbackReturnValue, context); + return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext()); } -bool V8TestCallback::callbackWithClass2Param(ScriptExecutionContext* context, Class2* class2Param, const String& strArg) +bool V8TestCallback::callbackWithClass2Param(Class2* class2Param, const String& strArg) { + if (!canInvokeCallback()) + return true; + v8::HandleScope handleScope; - v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext); + v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext); if (v8Context.IsEmpty()) return true; @@ -98,7 +105,7 @@ bool V8TestCallback::callbackWithClass2Param(ScriptExecutionContext* context, Cl }; bool callbackReturnValue = false; - return !invokeCallback(m_callback, 2, argv, callbackReturnValue, context); + return !invokeCallback(m_callback, 2, argv, callbackReturnValue, scriptExecutionContext()); } } // namespace WebCore diff --git a/WebCore/bindings/scripts/test/V8/V8TestCallback.h b/WebCore/bindings/scripts/test/V8/V8TestCallback.h index aed6b22..a105d75 100644 --- a/WebCore/bindings/scripts/test/V8/V8TestCallback.h +++ b/WebCore/bindings/scripts/test/V8/V8TestCallback.h @@ -23,6 +23,7 @@ #ifndef V8TestCallback_h #define V8TestCallback_h +#include "ActiveDOMCallback.h" #include "TestCallback.h" #include "WorldContextHandle.h" #include <v8.h> @@ -30,24 +31,27 @@ namespace WebCore { -class V8TestCallback : public TestCallback { +class ScriptExecutionContext; + +class V8TestCallback : public TestCallback, public ActiveDOMCallback { public: - static PassRefPtr<V8TestCallback> create(v8::Local<v8::Value> value) + static PassRefPtr<V8TestCallback> create(v8::Local<v8::Value> value, ScriptExecutionContext* context) { ASSERT(value->IsObject()); - return adoptRef(new V8TestCallback(value->ToObject())); + ASSERT(context); + return adoptRef(new V8TestCallback(value->ToObject(), context)); } virtual ~V8TestCallback(); // Functions - virtual bool callbackWithClass1Param(ScriptExecutionContext*, Class1* class1Param); - virtual bool callbackWithClass2Param(ScriptExecutionContext*, Class2* class2Param, const String& strArg); - COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(ScriptExecutionContext*, Class3* class3Param); - virtual int customCallback(ScriptExecutionContext*, Class5* class5Param, Class6* class6Param); + virtual bool callbackWithClass1Param(Class1* class1Param); + virtual bool callbackWithClass2Param(Class2* class2Param, const String& strArg); + COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(Class3* class3Param); + virtual int customCallback(Class5* class5Param, Class6* class6Param); private: - V8TestCallback(v8::Local<v8::Object>); + V8TestCallback(v8::Local<v8::Object>, ScriptExecutionContext*); v8::Persistent<v8::Object> m_callback; WorldContextHandle m_worldContext; diff --git a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp index 5584eaf..7428c93 100644 --- a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp +++ b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp @@ -29,6 +29,7 @@ #include "ScriptCallStack.h" #include "SerializedScriptValue.h" #include "V8Binding.h" +#include "V8BindingMacros.h" #include "V8BindingState.h" #include "V8DOMWrapper.h" #include "V8IsolatedContext.h" @@ -556,9 +557,9 @@ static v8::Handle<v8::Value> voidMethodWithArgsCallback(const v8::Arguments& arg { INC_STATS("DOM.TestObj.voidMethodWithArgs"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int intArg = toInt32(args[0]); - V8Parameter<> strArg = args[1]; - TestObj* objArg = V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0; + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]); + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0); imp->voidMethodWithArgs(intArg, strArg, objArg); return v8::Handle<v8::Value>(); } @@ -574,9 +575,9 @@ static v8::Handle<v8::Value> intMethodWithArgsCallback(const v8::Arguments& args { INC_STATS("DOM.TestObj.intMethodWithArgs"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int intArg = toInt32(args[0]); - V8Parameter<> strArg = args[1]; - TestObj* objArg = V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0; + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]); + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0); return v8::Integer::New(imp->intMethodWithArgs(intArg, strArg, objArg)); } @@ -591,9 +592,9 @@ static v8::Handle<v8::Value> objMethodWithArgsCallback(const v8::Arguments& args { INC_STATS("DOM.TestObj.objMethodWithArgs"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int intArg = toInt32(args[0]); - V8Parameter<> strArg = args[1]; - TestObj* objArg = V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0; + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]); + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0); return toV8(imp->objMethodWithArgs(intArg, strArg, objArg)); } @@ -603,8 +604,8 @@ static v8::Handle<v8::Value> methodThatRequiresAllArgsCallback(const v8::Argumen if (args.Length() < 2) return v8::Handle<v8::Value>(); TestObj* imp = V8TestObj::toNative(args.Holder()); - V8Parameter<> strArg = args[0]; - TestObj* objArg = V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0; + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[0]); + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0); return toV8(imp->methodThatRequiresAllArgs(strArg, objArg)); } @@ -616,8 +617,8 @@ static v8::Handle<v8::Value> methodThatRequiresAllArgsAndThrowsCallback(const v8 TestObj* imp = V8TestObj::toNative(args.Holder()); ExceptionCode ec = 0; { - V8Parameter<> strArg = args[0]; - TestObj* objArg = V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0; + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[0]); + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0); RefPtr<TestObj> result = imp->methodThatRequiresAllArgsAndThrows(strArg, objArg, ec); if (UNLIKELY(ec)) goto fail; @@ -644,7 +645,7 @@ static v8::Handle<v8::Value> idbKeyCallback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.idbKey"); TestObj* imp = V8TestObj::toNative(args.Holder()); - RefPtr<IDBKey> key = createIDBKeyFromValue(args[0]); + EXCEPTION_BLOCK(RefPtr<IDBKey>, key, createIDBKeyFromValue(args[0])); imp->idbKey(key); return v8::Handle<v8::Value>(); } @@ -674,7 +675,7 @@ static v8::Handle<v8::Value> customArgsAndExceptionCallback(const v8::Arguments& OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, 1)); if (!callStack) return v8::Undefined(); - log* intArg = V8log::HasInstance(args[0]) ? V8log::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0; + EXCEPTION_BLOCK(log*, intArg, V8log::HasInstance(args[0]) ? V8log::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0); imp->customArgsAndException(intArg, callStack.get(), ec); if (UNLIKELY(ec)) goto fail; @@ -722,7 +723,7 @@ static v8::Handle<v8::Value> withDynamicFrameAndArgCallback(const v8::Arguments& { INC_STATS("DOM.TestObj.withDynamicFrameAndArg"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int intArg = toInt32(args[0]); + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); if (!enteredFrame) return v8::Undefined(); @@ -734,7 +735,7 @@ static v8::Handle<v8::Value> withDynamicFrameAndOptionalArgCallback(const v8::Ar { INC_STATS("DOM.TestObj.withDynamicFrameAndOptionalArg"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int intArg = toInt32(args[0]); + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); if (args.Length() <= 1) { Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); if (!enteredFrame) @@ -742,7 +743,7 @@ static v8::Handle<v8::Value> withDynamicFrameAndOptionalArgCallback(const v8::Ar imp->withDynamicFrameAndOptionalArg(enteredFrame, intArg); return v8::Handle<v8::Value>(); } - int optionalArg = toInt32(args[1]); + EXCEPTION_BLOCK(int, optionalArg, toInt32(args[1])); Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); if (!enteredFrame) return v8::Undefined(); @@ -754,7 +755,7 @@ static v8::Handle<v8::Value> withDynamicFrameAndUserGestureCallback(const v8::Ar { INC_STATS("DOM.TestObj.withDynamicFrameAndUserGesture"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int intArg = toInt32(args[0]); + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); if (!enteredFrame) return v8::Undefined(); @@ -766,7 +767,7 @@ static v8::Handle<v8::Value> withDynamicFrameAndUserGestureASADCallback(const v8 { INC_STATS("DOM.TestObj.withDynamicFrameAndUserGestureASAD"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int intArg = toInt32(args[0]); + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); if (args.Length() <= 1) { Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); if (!enteredFrame) @@ -774,7 +775,7 @@ static v8::Handle<v8::Value> withDynamicFrameAndUserGestureASADCallback(const v8 imp->withDynamicFrameAndUserGestureASAD(enteredFrame, intArg, processingUserGesture()); return v8::Handle<v8::Value>(); } - int optionalArg = toInt32(args[1]); + EXCEPTION_BLOCK(int, optionalArg, toInt32(args[1])); Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); if (!enteredFrame) return v8::Undefined(); @@ -861,7 +862,7 @@ static v8::Handle<v8::Value> methodWithOptionalArgCallback(const v8::Arguments& imp->methodWithOptionalArg(); return v8::Handle<v8::Value>(); } - int opt = toInt32(args[0]); + EXCEPTION_BLOCK(int, opt, toInt32(args[0])); imp->methodWithOptionalArg(opt); return v8::Handle<v8::Value>(); } @@ -870,12 +871,12 @@ static v8::Handle<v8::Value> methodWithNonOptionalArgAndOptionalArgCallback(cons { INC_STATS("DOM.TestObj.methodWithNonOptionalArgAndOptionalArg"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int nonOpt = toInt32(args[0]); + EXCEPTION_BLOCK(int, nonOpt, toInt32(args[0])); if (args.Length() <= 1) { imp->methodWithNonOptionalArgAndOptionalArg(nonOpt); return v8::Handle<v8::Value>(); } - int opt = toInt32(args[1]); + EXCEPTION_BLOCK(int, opt, toInt32(args[1])); imp->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt); return v8::Handle<v8::Value>(); } @@ -884,13 +885,13 @@ static v8::Handle<v8::Value> methodWithNonOptionalArgAndTwoOptionalArgsCallback( { INC_STATS("DOM.TestObj.methodWithNonOptionalArgAndTwoOptionalArgs"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int nonOpt = toInt32(args[0]); + EXCEPTION_BLOCK(int, nonOpt, toInt32(args[0])); if (args.Length() <= 1) { imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt); return v8::Handle<v8::Value>(); } - int opt1 = toInt32(args[1]); - int opt2 = toInt32(args[2]); + EXCEPTION_BLOCK(int, opt1, toInt32(args[1])); + EXCEPTION_BLOCK(int, opt2, toInt32(args[2])); imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2); return v8::Handle<v8::Value>(); } @@ -901,7 +902,7 @@ static v8::Handle<v8::Value> methodWithCallbackArgCallback(const v8::Arguments& TestObj* imp = V8TestObj::toNative(args.Holder()); if (args.Length() <= 0 || !args[0]->IsObject()) return throwError(TYPE_MISMATCH_ERR); - RefPtr<TestCallback> callback = V8TestCallback::create(args[0]); + RefPtr<TestCallback> callback = V8TestCallback::create(args[0], getScriptExecutionContext()); imp->methodWithCallbackArg(callback); return v8::Handle<v8::Value>(); } @@ -910,10 +911,10 @@ static v8::Handle<v8::Value> methodWithNonCallbackArgAndCallbackArgCallback(cons { INC_STATS("DOM.TestObj.methodWithNonCallbackArgAndCallbackArg"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int nonCallback = toInt32(args[0]); + EXCEPTION_BLOCK(int, nonCallback, toInt32(args[0])); if (args.Length() <= 1 || !args[1]->IsObject()) return throwError(TYPE_MISMATCH_ERR); - RefPtr<TestCallback> callback = V8TestCallback::create(args[1]); + RefPtr<TestCallback> callback = V8TestCallback::create(args[1], getScriptExecutionContext()); imp->methodWithNonCallbackArgAndCallbackArg(nonCallback, callback); return v8::Handle<v8::Value>(); } @@ -922,13 +923,12 @@ static v8::Handle<v8::Value> methodWithCallbackAndOptionalArgCallback(const v8:: { INC_STATS("DOM.TestObj.methodWithCallbackAndOptionalArg"); TestObj* imp = V8TestObj::toNative(args.Holder()); - if (args.Length() <= 0) { - imp->methodWithCallbackAndOptionalArg(); - return v8::Handle<v8::Value>(); + RefPtr<TestCallback> callback; + if (args.Length() > 0 && !args[0]->IsNull() && !args[0]->IsUndefined()) { + if (!args[0]->IsObject()) + return throwError(TYPE_MISMATCH_ERR); + callback = V8TestCallback::create(args[0], getScriptExecutionContext()); } - if (args.Length() <= 0 || !args[0]->IsObject()) - return throwError(TYPE_MISMATCH_ERR); - RefPtr<TestCallback> callback = V8TestCallback::create(args[0]); imp->methodWithCallbackAndOptionalArg(callback); return v8::Handle<v8::Value>(); } @@ -937,8 +937,8 @@ static v8::Handle<v8::Value> overloadedMethod1Callback(const v8::Arguments& args { INC_STATS("DOM.TestObj.overloadedMethod1"); TestObj* imp = V8TestObj::toNative(args.Holder()); - TestObj* objArg = V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0; - V8Parameter<> strArg = args[1]; + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]); imp->overloadedMethod(objArg, strArg); return v8::Handle<v8::Value>(); } @@ -947,12 +947,12 @@ static v8::Handle<v8::Value> overloadedMethod2Callback(const v8::Arguments& args { INC_STATS("DOM.TestObj.overloadedMethod2"); TestObj* imp = V8TestObj::toNative(args.Holder()); - TestObj* objArg = V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0; + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0); if (args.Length() <= 1) { imp->overloadedMethod(objArg); return v8::Handle<v8::Value>(); } - int intArg = toInt32(args[1]); + EXCEPTION_BLOCK(int, intArg, toInt32(args[1])); imp->overloadedMethod(objArg, intArg); return v8::Handle<v8::Value>(); } @@ -961,7 +961,7 @@ static v8::Handle<v8::Value> overloadedMethod3Callback(const v8::Arguments& args { INC_STATS("DOM.TestObj.overloadedMethod3"); TestObj* imp = V8TestObj::toNative(args.Holder()); - V8Parameter<> strArg = args[0]; + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[0]); imp->overloadedMethod(strArg); return v8::Handle<v8::Value>(); } @@ -970,7 +970,7 @@ static v8::Handle<v8::Value> overloadedMethod4Callback(const v8::Arguments& args { INC_STATS("DOM.TestObj.overloadedMethod4"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int intArg = toInt32(args[0]); + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); imp->overloadedMethod(intArg); return v8::Handle<v8::Value>(); } @@ -1088,6 +1088,8 @@ static const BatchedCallback TestObjCallbacks[] = { {"methodWithOptionalArg", TestObjInternal::methodWithOptionalArgCallback}, {"methodWithNonOptionalArgAndOptionalArg", TestObjInternal::methodWithNonOptionalArgAndOptionalArgCallback}, {"methodWithNonOptionalArgAndTwoOptionalArgs", TestObjInternal::methodWithNonOptionalArgAndTwoOptionalArgsCallback}, + {"methodWithCallbackArg", TestObjInternal::methodWithCallbackArgCallback}, + {"methodWithNonCallbackArgAndCallbackArg", TestObjInternal::methodWithNonCallbackArgAndCallbackArgCallback}, {"methodWithCallbackAndOptionalArg", TestObjInternal::methodWithCallbackAndOptionalArgCallback}, {"overloadedMethod", TestObjInternal::overloadedMethodCallback}, }; @@ -1161,18 +1163,6 @@ static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestObjTemplate(v8::Persi v8::Handle<v8::FunctionTemplate> customArgsAndExceptionArgv[customArgsAndExceptionArgc] = { V8log::GetRawTemplate() }; v8::Handle<v8::Signature> customArgsAndExceptionSignature = v8::Signature::New(desc, customArgsAndExceptionArgc, customArgsAndExceptionArgv); proto->Set(v8::String::New("customArgsAndException"), v8::FunctionTemplate::New(TestObjInternal::customArgsAndExceptionCallback, v8::Handle<v8::Value>(), customArgsAndExceptionSignature)); - - // Custom Signature 'methodWithCallbackArg' - const int methodWithCallbackArgArgc = 1; - v8::Handle<v8::FunctionTemplate> methodWithCallbackArgArgv[methodWithCallbackArgArgc] = { V8TestCallback::GetRawTemplate() }; - v8::Handle<v8::Signature> methodWithCallbackArgSignature = v8::Signature::New(desc, methodWithCallbackArgArgc, methodWithCallbackArgArgv); - proto->Set(v8::String::New("methodWithCallbackArg"), v8::FunctionTemplate::New(TestObjInternal::methodWithCallbackArgCallback, v8::Handle<v8::Value>(), methodWithCallbackArgSignature)); - - // Custom Signature 'methodWithNonCallbackArgAndCallbackArg' - const int methodWithNonCallbackArgAndCallbackArgArgc = 2; - v8::Handle<v8::FunctionTemplate> methodWithNonCallbackArgAndCallbackArgArgv[methodWithNonCallbackArgAndCallbackArgArgc] = { v8::Handle<v8::FunctionTemplate>(), V8TestCallback::GetRawTemplate() }; - v8::Handle<v8::Signature> methodWithNonCallbackArgAndCallbackArgSignature = v8::Signature::New(desc, methodWithNonCallbackArgAndCallbackArgArgc, methodWithNonCallbackArgAndCallbackArgArgv); - proto->Set(v8::String::New("methodWithNonCallbackArgAndCallbackArg"), v8::FunctionTemplate::New(TestObjInternal::methodWithNonCallbackArgAndCallbackArgCallback, v8::Handle<v8::Value>(), methodWithNonCallbackArgAndCallbackArgSignature)); batchConfigureConstants(desc, proto, TestObjConsts, sizeof(TestObjConsts) / sizeof(*TestObjConsts)); // Custom toString template |