Changeset 99793 in webkit
- Timestamp:
- Nov 9, 2011, 5:41:24 PM (15 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
bindings/scripts/CodeGeneratorJS.pm (modified) (3 diffs)
-
bindings/scripts/CodeGeneratorV8.pm (modified) (3 diffs)
-
bindings/scripts/test/TestInterface.idl (modified) (1 diff)
-
bindings/v8/V8Proxy.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r99782 r99793 1 2011-11-09 Kentaro Hara <haraken@chromium.org> 2 3 Remove [CanBeConstructed] IDL from CodeGenerator{JS,V8}.pm 4 https://bugs.webkit.org/show_bug.cgi?id=71938 5 6 Reviewed by Darin Adler. 7 8 Now no IDL files are using [CanBeConstructed] IDL. 9 We can safely remove [CanBeConstructed] IDL from CodeGenerator{JS,V8}.pm. 10 11 No tests. No change in behavior. 12 13 * bindings/scripts/CodeGeneratorJS.pm: Removed [CanBeConstructed]-related code. 14 (GenerateConstructorDeclaration): 15 (GenerateConstructorDefinition): 16 * bindings/scripts/CodeGeneratorV8.pm: Ditto. 17 (GenerateImplementation): 18 * bindings/scripts/test/TestInterface.idl: Removed [CanBeConstructed]. 19 * bindings/v8/V8Proxy.h: Removed V8Proxy::constructDOMObject and V8Proxy::constructDOMObjectWithScriptExecutionContext, which had been used only by [CanBeConstructed]. 20 1 21 2011-11-09 Tim Horton <timothy_horton@apple.com> 2 22 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r99754 r99793 3192 3192 3193 3193 my $constructorClassName = "${className}Constructor"; 3194 my $canConstruct = $dataNode->extendedAttributes->{"C anBeConstructed"} || $dataNode->extendedAttributes->{"Constructor"} || $dataNode->extendedAttributes->{"JSCustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"};3194 my $canConstruct = $dataNode->extendedAttributes->{"Constructor"} || $dataNode->extendedAttributes->{"JSCustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"}; 3195 3195 my $callWith = $dataNode->extendedAttributes->{"CallWith"}; 3196 3196 … … 3270 3270 push(@$outputArray, "}\n\n"); 3271 3271 3272 if ($dataNode->extendedAttributes->{"C anBeConstructed"} || $dataNode->extendedAttributes->{"Constructor"} || $dataNode->extendedAttributes->{"JSCustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"}) {3272 if ($dataNode->extendedAttributes->{"Constructor"} || $dataNode->extendedAttributes->{"JSCustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"}) { 3273 3273 if (!($dataNode->extendedAttributes->{"JSCustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) { 3274 3274 push(@$outputArray, "EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}(ExecState* exec)\n"); … … 3277 3277 push(@$outputArray, " ${constructorClassName}* jsConstructor = static_cast<${constructorClassName}*>(exec->callee());\n"); 3278 3278 3279 if ($dataNode->extendedAttributes->{"Constructor"}) { 3280 my $function = $dataNode->constructor; 3281 my @constructorArgList; 3282 3283 $implIncludes{"<runtime/Error.h>"} = 1; 3284 3285 GenerateArgumentsCountCheck($outputArray, $function, $dataNode); 3286 3287 if (@{$function->raisesExceptions} || $dataNode->extendedAttributes->{"ConstructorRaisesException"}) { 3288 $implIncludes{"ExceptionCode.h"} = 1; 3289 push(@$outputArray, " ExceptionCode ec = 0;\n"); 3290 } 3291 3292 # For now, we do not support SVG constructors. 3293 # We do not also support a constructor [Optional] argument without CallWithDefaultValue 3294 # nor CallWithNullValue. 3295 my $numParameters = @{$function->parameters}; 3296 my ($dummy, $paramIndex) = GenerateParametersCheck($outputArray, $function, $dataNode, $numParameters, $interfaceName, "constructorCallback", undef, undef, undef); 3297 3298 if ($dataNode->extendedAttributes->{"CallWith"} && $dataNode->extendedAttributes->{"CallWith"} eq "ScriptExecutionContext") { 3299 push(@constructorArgList, "context"); 3300 push(@$outputArray, " ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();\n"); 3301 push(@$outputArray, " if (!context)\n"); 3302 push(@$outputArray, " return throwVMError(exec, createReferenceError(exec, \"${interfaceName} constructor associated document is unavailable\"));\n"); 3303 } 3304 3305 my $index = 0; 3306 foreach my $parameter (@{$function->parameters}) { 3307 last if $index eq $paramIndex; 3308 push(@constructorArgList, $parameter->name); 3309 $index++; 3310 } 3311 3312 if ($dataNode->extendedAttributes->{"ConstructorRaisesException"}) { 3313 push(@constructorArgList, "ec"); 3314 } 3315 my $constructorArg = join(", ", @constructorArgList); 3316 push(@$outputArray, " RefPtr<${interfaceName}> object = ${interfaceName}::create(${constructorArg});\n"); 3317 if ($dataNode->extendedAttributes->{"ConstructorRaisesException"}) { 3318 push(@$outputArray, " if (ec) {\n"); 3319 push(@$outputArray, " setDOMException(exec, ec);\n"); 3320 push(@$outputArray, " return JSValue::encode(JSValue());\n"); 3321 push(@$outputArray, " }\n"); 3322 } 3323 } else { 3324 my $constructorArg = ""; 3325 if ($dataNode->extendedAttributes->{"CallWith"} and $dataNode->extendedAttributes->{"CallWith"} eq "ScriptExecutionContext") { 3326 $constructorArg = "context"; 3327 push(@$outputArray, " ScriptExecutionContext* context = static_cast<${constructorClassName}*>(exec->callee())->scriptExecutionContext();\n"); 3328 push(@$outputArray, " if (!context)\n"); 3329 push(@$outputArray, " return throwVMError(exec, createReferenceError(exec, \"${interfaceName} constructor associated document is unavailable\"));\n"); 3330 } 3331 push(@$outputArray, " RefPtr<${interfaceName}> object = ${interfaceName}::create(${constructorArg});\n"); 3279 my $function = $dataNode->constructor; 3280 my @constructorArgList; 3281 3282 $implIncludes{"<runtime/Error.h>"} = 1; 3283 3284 GenerateArgumentsCountCheck($outputArray, $function, $dataNode); 3285 3286 if (@{$function->raisesExceptions} || $dataNode->extendedAttributes->{"ConstructorRaisesException"}) { 3287 $implIncludes{"ExceptionCode.h"} = 1; 3288 push(@$outputArray, " ExceptionCode ec = 0;\n"); 3289 } 3290 3291 # For now, we do not support SVG constructors. 3292 # We do not also support a constructor [Optional] argument without CallWithDefaultValue 3293 # nor CallWithNullValue. 3294 my $numParameters = @{$function->parameters}; 3295 my ($dummy, $paramIndex) = GenerateParametersCheck($outputArray, $function, $dataNode, $numParameters, $interfaceName, "constructorCallback", undef, undef, undef); 3296 3297 if ($dataNode->extendedAttributes->{"CallWith"} && $dataNode->extendedAttributes->{"CallWith"} eq "ScriptExecutionContext") { 3298 push(@constructorArgList, "context"); 3299 push(@$outputArray, " ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();\n"); 3300 push(@$outputArray, " if (!context)\n"); 3301 push(@$outputArray, " return throwVMError(exec, createReferenceError(exec, \"${interfaceName} constructor associated document is unavailable\"));\n"); 3302 } 3303 3304 my $index = 0; 3305 foreach my $parameter (@{$function->parameters}) { 3306 last if $index eq $paramIndex; 3307 push(@constructorArgList, $parameter->name); 3308 $index++; 3309 } 3310 3311 if ($dataNode->extendedAttributes->{"ConstructorRaisesException"}) { 3312 push(@constructorArgList, "ec"); 3313 } 3314 my $constructorArg = join(", ", @constructorArgList); 3315 push(@$outputArray, " RefPtr<${interfaceName}> object = ${interfaceName}::create(${constructorArg});\n"); 3316 if ($dataNode->extendedAttributes->{"ConstructorRaisesException"}) { 3317 push(@$outputArray, " if (ec) {\n"); 3318 push(@$outputArray, " setDOMException(exec, ec);\n"); 3319 push(@$outputArray, " return JSValue::encode(JSValue());\n"); 3320 push(@$outputArray, " }\n"); 3332 3321 } 3333 3322 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
r99732 r99793 394 394 } 395 395 396 if ($dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"C anBeConstructed"} || $dataNode->extendedAttributes->{"Constructor"}) {396 if ($dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"Constructor"}) { 397 397 push(@headerContent, <<END); 398 398 static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&); … … 2287 2287 push(@implContentDecls, "} // namespace ${interfaceName}Internal\n\n"); 2288 2288 2289 # In namespace WebCore, add generated implementation for 'CanBeConstructed'. 2290 if ($dataNode->extendedAttributes->{"CanBeConstructed"} && !$dataNode->extendedAttributes->{"CustomConstructor"} && !$dataNode->extendedAttributes->{"V8CustomConstructor"} && !$dataNode->extendedAttributes->{"Constructor"}) { 2291 my $v8ConstructFunction; 2292 my $callWith = $dataNode->extendedAttributes->{"CallWith"}; 2293 if ($callWith and $callWith eq "ScriptExecutionContext") { 2294 $v8ConstructFunction = "constructDOMObjectWithScriptExecutionContext"; 2295 } else { 2296 $v8ConstructFunction = "constructDOMObject"; 2297 } 2298 push(@implContent, <<END); 2299 v8::Handle<v8::Value> ${className}::constructorCallback(const v8::Arguments& args) 2300 { 2301 INC_STATS("DOM.${interfaceName}.Contructor"); 2302 return V8Proxy::${v8ConstructFunction}<$interfaceName>(args, &info); 2303 } 2304 2305 END 2306 } elsif ($dataNode->extendedAttributes->{"NamedConstructor"} && !($dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) { 2289 if ($dataNode->extendedAttributes->{"NamedConstructor"} && !($dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) { 2307 2290 GenerateNamedConstructorCallback($dataNode->constructor, $dataNode, $interfaceName); 2308 } elsif ( ($dataNode->extendedAttributes->{"CanBeConstructed"} || $dataNode->extendedAttributes->{"Constructor"})&& !($dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {2291 } elsif ($dataNode->extendedAttributes->{"Constructor"} && !($dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) { 2309 2292 GenerateConstructorCallback($dataNode->constructor, $dataNode, $interfaceName); 2310 2293 } … … 2380 2363 END 2381 2364 2382 if ($dataNode->extendedAttributes->{"C anBeConstructed"} || $dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"Constructor"}) {2365 if ($dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"Constructor"}) { 2383 2366 push(@implContent, <<END); 2384 2367 desc->SetCallHandler(V8${interfaceName}::constructorCallback); -
trunk/Source/WebCore/bindings/scripts/test/TestInterface.idl
r98695 r99793 33 33 ActiveDOMObject, 34 34 Conditional=Condition1|Condition2, 35 CanBeConstructed,36 35 CallWith=ScriptExecutionContext, 37 36 Constructor(in DOMString str1, in [Optional=CallWithDefaultValue] DOMString str2), -
trunk/Source/WebCore/bindings/v8/V8Proxy.h
r99588 r99793 252 252 static v8::Handle<v8::Value> throwSyntaxError(); 253 253 254 template <typename T>255 static v8::Handle<v8::Value> constructDOMObject(const v8::Arguments&, WrapperTypeInfo*);256 257 template <typename T>258 static v8::Handle<v8::Value> constructDOMObjectWithScriptExecutionContext(const v8::Arguments&, WrapperTypeInfo*);259 260 254 v8::Local<v8::Context> context(); 261 255 v8::Local<v8::Context> mainWorldContext(); … … 338 332 }; 339 333 340 template <typename T>341 v8::Handle<v8::Value> V8Proxy::constructDOMObject(const v8::Arguments& args, WrapperTypeInfo* type)342 {343 if (!args.IsConstructCall())344 return throwError(V8Proxy::TypeError, "DOM object constructor cannot be called as a function.");345 346 // Note: it's OK to let this RefPtr go out of scope because we also call347 // SetDOMWrapper(), which effectively holds a reference to obj.348 RefPtr<T> obj = T::create();349 V8DOMWrapper::setDOMWrapper(args.Holder(), type, obj.get());350 obj->ref();351 V8DOMWrapper::setJSWrapperForDOMObject(obj.get(), v8::Persistent<v8::Object>::New(args.Holder()));352 return args.Holder();353 }354 355 template <typename T>356 v8::Handle<v8::Value> V8Proxy::constructDOMObjectWithScriptExecutionContext(const v8::Arguments& args, WrapperTypeInfo* type)357 {358 if (!args.IsConstructCall())359 return throwError(V8Proxy::TypeError, "");360 361 ScriptExecutionContext* context = getScriptExecutionContext();362 if (!context)363 return throwError(V8Proxy::ReferenceError, "");364 365 // Note: it's OK to let this RefPtr go out of scope because we also call366 // SetDOMWrapper(), which effectively holds a reference to obj.367 RefPtr<T> obj = T::create(context);368 V8DOMWrapper::setDOMWrapper(args.Holder(), type, obj.get());369 obj->ref();370 V8DOMWrapper::setJSWrapperForDOMObject(obj.get(), v8::Persistent<v8::Object>::New(args.Holder()));371 return args.Holder();372 }373 374 375 334 v8::Local<v8::Context> toV8Context(ScriptExecutionContext*, const WorldContextHandle& worldContext); 376 335
Note:
See TracChangeset
for help on using the changeset viewer.