Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: Source/bindings/scripts/code_generator_v8.pm

Issue 138223002: WIP: Implement binding layer for Blink-in-JavaScript Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
5 # Copyright (C) 2006 Apple Computer, Inc. 5 # Copyright (C) 2006 Apple Computer, Inc.
6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc.
7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved.
9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 # Copyright (C) 2012 Ericsson AB. All rights reserved. 10 # Copyright (C) 2012 Ericsson AB. All rights reserved.
(...skipping 2436 matching lines...) Expand 10 before | Expand all | Expand 10 after
2447 $code .= " exceptionState.throwDOMException(NoModificationAll owedError, \"The object is read-only.\");\n"; 2447 $code .= " exceptionState.throwDOMException(NoModificationAll owedError, \"The object is read-only.\");\n";
2448 $code .= " exceptionState.throwIfNeeded();\n"; 2448 $code .= " exceptionState.throwIfNeeded();\n";
2449 $code .= " return;\n"; 2449 $code .= " return;\n";
2450 $code .= " }\n"; 2450 $code .= " }\n";
2451 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfac eName); 2451 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfac eName);
2452 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n"; 2452 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n";
2453 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; 2453 $code .= " $svgWrappedNativeType* imp = &impInstance;\n";
2454 } 2454 }
2455 } elsif (!$function->isStatic) { 2455 } elsif (!$function->isStatic) {
2456 $code .= <<END; 2456 $code .= <<END;
2457 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); 2457 ${implClassName}* ALLOW_UNUSED imp = ${v8ClassName}::toNative(info.Holder()) ;
2458 END 2458 END
2459 } 2459 }
2460 2460
2461 $code .= GenerateCustomElementInvocationScopeIfNeeded($funcExt); 2461 $code .= GenerateCustomElementInvocationScopeIfNeeded($funcExt);
2462 2462
2463 # Check domain security if needed 2463 # Check domain security if needed
2464 if ($isSecurityCheckNecessary) { 2464 if ($isSecurityCheckNecessary) {
2465 # We have not find real use cases yet. 2465 # We have not find real use cases yet.
2466 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 2466 AddToImplIncludes("bindings/v8/BindingSecurity.h");
2467 $code .= <<END; 2467 $code .= <<END;
2468 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) { 2468 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) {
2469 exceptionState.throwIfNeeded(); 2469 exceptionState.throwIfNeeded();
2470 return; 2470 return;
2471 } 2471 }
2472 END 2472 END
2473 } 2473 }
2474 2474
2475 if ($function->extendedAttributes->{"CheckSecurity"}) { 2475 if ($function->extendedAttributes->{"CheckSecurity"}) {
2476 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 2476 AddToImplIncludes("bindings/v8/BindingSecurity.h");
2477 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($function) . "(exceptionState), exceptionState)) {\n"; 2477 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($function) . "(exceptionState), exceptionState)) {\n";
2478 $code .= " v8SetReturnValueNull(info);\n"; 2478 $code .= " v8SetReturnValueNull(info);\n";
2479 $code .= " exceptionState.throwIfNeeded();\n"; 2479 $code .= " exceptionState.throwIfNeeded();\n";
2480 $code .= " return;\n"; 2480 $code .= " return;\n";
2481 $code .= " }\n"; 2481 $code .= " }\n";
2482 END 2482 END
2483 } 2483 }
2484 2484
2485 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, $forMainWorldSuffix, $hasExceptionState); 2485 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, $forMainWorldSuffix, $hasExceptionState);
2486 $code .= $parameterCheckString; 2486 if (!$function->extendedAttributes->{"BlinkInJavaScript"}) {
2487 $code .= $parameterCheckString;
2488 }
2487 2489
2488 # Build the function call string. 2490 # Build the function call string.
2489 $code .= GenerateFunctionCallString($function, $paramIndex, " ", $interfa ce, $forMainWorldSuffix, $hasExceptionState, %replacements); 2491 $code .= GenerateFunctionCallString($function, $paramIndex, " ", $interfa ce, $forMainWorldSuffix, $hasExceptionState, %replacements);
2490 $code .= "}\n"; 2492 $code .= "}\n";
2491 $code .= "#endif // ${conditionalString}\n" if $conditionalString; 2493 $code .= "#endif // ${conditionalString}\n" if $conditionalString;
2492 $code .= "\n"; 2494 $code .= "\n";
2493 $implementation{nameSpaceInternal}->add($code); 2495 $implementation{nameSpaceInternal}->add($code);
2494 } 2496 }
2495 2497
2496 sub GenerateCallWith 2498 sub GenerateCallWith
(...skipping 2722 matching lines...) Expand 10 before | Expand all | Expand 10 after
5219 my $returnType = $function->type; 5221 my $returnType = $function->type;
5220 my $nativeReturnType = GetNativeType($returnType, {}, ""); 5222 my $nativeReturnType = GetNativeType($returnType, {}, "");
5221 my $code = ""; 5223 my $code = "";
5222 5224
5223 my $isSVGTearOffType = (IsSVGTypeNeedingTearOff($returnType) and not $interf aceName =~ /List$/); 5225 my $isSVGTearOffType = (IsSVGTypeNeedingTearOff($returnType) and not $interf aceName =~ /List$/);
5224 $nativeReturnType = GetSVGWrappedTypeNeedingTearOff($returnType) if $isSVGTe arOffType; 5226 $nativeReturnType = GetSVGWrappedTypeNeedingTearOff($returnType) if $isSVGTe arOffType;
5225 5227
5226 my $index = 0; 5228 my $index = 0;
5227 my $humanFriendlyIndex = $index + 1; 5229 my $humanFriendlyIndex = $index + 1;
5228 5230
5231 # FIXME: Implement [BlinkInJavaScript] for DOM attributes as well.
5232 if ($function->extendedAttributes->{"BlinkInJavaScript"}) {
5233 AddToImplIncludes("bindings/v8/V8BlinkInJavaScript.h");
5234 $code .= " v8::Handle<v8::Value> argv[] = { ";
5235 foreach (my $index = 0; $index < @{$function->parameters}; $index++) {
5236 $code .= "info[$index], ";
5237 }
5238 $code .= "};\n";
5239 my $implementedBy = $function->extendedAttributes->{"ImplementedBy"};
5240 my $className = $implementedBy ? GetImplNameFromImplementedBy($implement edBy) : $implClassName;
5241 $code .= " v8SetReturnValue(info, V8BlinkInJavaScript::runBlinkInJava Script(\"${className}\", \"${name}\", info.Holder(), WTF_ARRAY_LENGTH(argv), arg v, info.GetIsolate()));\n";
5242 return $code;
5243 }
5244
5229 my @arguments; 5245 my @arguments;
5230 my $functionName; 5246 my $functionName;
5231 my $implementedBy = $function->extendedAttributes->{"ImplementedBy"}; 5247 my $implementedBy = $function->extendedAttributes->{"ImplementedBy"};
5232 if ($implementedBy) { 5248 if ($implementedBy) {
5233 my $implementedByImplName = GetImplNameFromImplementedBy($implementedBy) ; 5249 my $implementedByImplName = GetImplNameFromImplementedBy($implementedBy) ;
5234 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implementedBy ImplName)); 5250 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implementedBy ImplName));
5235 unshift(@arguments, "imp") if !$function->isStatic; 5251 unshift(@arguments, "imp") if !$function->isStatic;
5236 $functionName = "${implementedByImplName}::${name}"; 5252 $functionName = "${implementedByImplName}::${name}";
5237 } elsif ($function->isStatic) { 5253 } elsif ($function->isStatic) {
5238 $functionName = "${implClassName}::${name}"; 5254 $functionName = "${implClassName}::${name}";
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
6391 if ($parameter->type eq "SerializedScriptValue") { 6407 if ($parameter->type eq "SerializedScriptValue") {
6392 return 1; 6408 return 1;
6393 } elsif (IsIntegerType($parameter->type)) { 6409 } elsif (IsIntegerType($parameter->type)) {
6394 return 1; 6410 return 1;
6395 } 6411 }
6396 } 6412 }
6397 return 0; 6413 return 0;
6398 } 6414 }
6399 6415
6400 1; 6416 1;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698