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

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

Issue 17572008: WIP IDL compiler rewrite (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Branch: const + primitive type readonly attributes Created 7 years, 4 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
« no previous file with comments | « Source/bindings/scripts/code_generator_v8.py ('k') | Source/bindings/scripts/idl_compiler.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 my %enumTypeHash = (); 192 my %enumTypeHash = ();
193 193
194 my %svgAttributesInHTMLHash = ("class" => 1, "id" => 1, "onabort" => 1, "onclick " => 1, 194 my %svgAttributesInHTMLHash = ("class" => 1, "id" => 1, "onabort" => 1, "onclick " => 1,
195 "onerror" => 1, "onload" => 1, "onmousedown" => 1 , 195 "onerror" => 1, "onload" => 1, "onmousedown" => 1 ,
196 "onmouseenter" => 1, "onmouseleave" => 1, 196 "onmouseenter" => 1, "onmouseleave" => 1,
197 "onmousemove" => 1, "onmouseout" => 1, "onmouseov er" => 1, 197 "onmousemove" => 1, "onmouseout" => 1, "onmouseov er" => 1,
198 "onmouseup" => 1, "onresize" => 1, "onscroll" => 1, 198 "onmouseup" => 1, "onresize" => 1, "onscroll" => 1,
199 "onunload" => 1); 199 "onunload" => 1);
200 200
201 ### DONE
201 my %svgTypeNeedingTearOff = ( 202 my %svgTypeNeedingTearOff = (
202 "SVGAngle" => "SVGPropertyTearOff<SVGAngle>", 203 "SVGAngle" => "SVGPropertyTearOff<SVGAngle>",
203 "SVGLength" => "SVGPropertyTearOff<SVGLength>", 204 "SVGLength" => "SVGPropertyTearOff<SVGLength>",
204 "SVGLengthList" => "SVGListPropertyTearOff<SVGLengthList>", 205 "SVGLengthList" => "SVGListPropertyTearOff<SVGLengthList>",
205 "SVGMatrix" => "SVGPropertyTearOff<SVGMatrix>", 206 "SVGMatrix" => "SVGPropertyTearOff<SVGMatrix>",
206 "SVGNumber" => "SVGPropertyTearOff<SVGNumber>", 207 "SVGNumber" => "SVGPropertyTearOff<SVGNumber>",
207 "SVGNumberList" => "SVGListPropertyTearOff<SVGNumberList>", 208 "SVGNumberList" => "SVGListPropertyTearOff<SVGNumberList>",
208 "SVGPathSegList" => "SVGPathSegListPropertyTearOff", 209 "SVGPathSegList" => "SVGPathSegListPropertyTearOff",
209 "SVGPoint" => "SVGPropertyTearOff<SVGPoint>", 210 "SVGPoint" => "SVGPropertyTearOff<SVGPoint>",
210 "SVGPointList" => "SVGListPropertyTearOff<SVGPointList>", 211 "SVGPointList" => "SVGListPropertyTearOff<SVGPointList>",
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 bless($reference, $object); 261 bless($reference, $object);
261 return $reference; 262 return $reference;
262 } 263 }
263 264
264 265
265 sub IDLFileForInterface 266 sub IDLFileForInterface
266 { 267 {
267 my $interfaceName = shift; 268 my $interfaceName = shift;
268 269
269 unless ($idlFiles) { 270 unless ($idlFiles) {
271 # use Data::Dumper;
272 # print "[direc]", Dumper($idlDirectories), "\n";
270 my @directories = map { $_ = "$sourceRoot/$_" if -d "$sourceRoot/$_"; $_ } @$idlDirectories; 273 my @directories = map { $_ = "$sourceRoot/$_" if -d "$sourceRoot/$_"; $_ } @$idlDirectories;
271 push(@directories, "."); 274 push(@directories, ".");
275 # print "[directories]", Dumper(@directories), "\n";
272 276
273 $idlFiles = { }; 277 $idlFiles = { };
274 foreach my $idlFile (@$interfaceIdlFiles) { 278 foreach my $idlFile (@$interfaceIdlFiles) {
275 $idlFiles->{fileparse(basename($idlFile), ".idl")} = $idlFile; 279 $idlFiles->{fileparse(basename($idlFile), ".idl")} = $idlFile;
276 } 280 }
281 # use Data::Dumper;
282 # print "[idlFiles]", Dumper($idlFiles), "\n";
277 283
278 my $wanted = sub { 284 my $wanted = sub {
285 # print "<find> ", $File::Find::name, "\n";
279 $idlFiles->{$1} = $File::Find::name if /^([A-Z].*)\.idl$/; 286 $idlFiles->{$1} = $File::Find::name if /^([A-Z].*)\.idl$/;
280 $File::Find::prune = 1 if /^\../; 287 $File::Find::prune = 1 if /^\../;
281 }; 288 };
282 find($wanted, @directories); 289 find($wanted, @directories);
290 # print "[idlFiles]", scalar(keys($idlFiles)), "\n";
283 } 291 }
284 292
285 return $idlFiles->{$interfaceName}; 293 return $idlFiles->{$interfaceName};
286 } 294 }
287 295
288 sub ParseInterface 296 sub ParseInterface
289 { 297 {
290 my $interfaceName = shift; 298 my $interfaceName = shift;
291 299
292 if (exists $cachedInterfaces->{$interfaceName}) { 300 if (exists $cachedInterfaces->{$interfaceName}) {
293 return $cachedInterfaces->{$interfaceName}; 301 return $cachedInterfaces->{$interfaceName};
294 } 302 }
295 303
296 # Step #1: Find the IDL file associated with 'interface' 304 # Step #1: Find the IDL file associated with 'interface'
297 my $filename = IDLFileForInterface($interfaceName) 305 my $filename = IDLFileForInterface($interfaceName)
298 or die("Could NOT find IDL file for interface \"$interfaceName\" $!\n"); 306 or die("Could NOT find IDL file for interface \"$interfaceName\" $!\n");
299 307
300 print " | |> Parsing parent IDL \"$filename\" for interface \"$interfaceN ame\"\n" if $verbose; 308 # use Carp qw(cluck);
309 # cluck "HEY";
310 # print " | |> Parsing parent IDL \"$filename\" for interface \"$interface Name\"\n" if $verbose;
311 print " | |> Parsing $interfaceName ( $filename )\n";
301 312
302 # Step #2: Parse the found IDL file (in quiet mode). 313 # Step #2: Parse the found IDL file (in quiet mode).
303 my $parser = deprecated_idl_parser->new(1); 314 my $parser = deprecated_idl_parser->new(1);
304 my $document = $parser->Parse($filename, $preprocessor); 315 my $document = $parser->Parse($filename, $preprocessor);
305 316
306 foreach my $interface (@{$document->interfaces}) { 317 foreach my $interface (@{$document->interfaces}) {
307 if ($interface->name eq $interfaceName or $interface->isPartial) { 318 if ($interface->name eq $interfaceName or $interface->isPartial) {
308 $cachedInterfaces->{$interfaceName} = $interface; 319 $cachedInterfaces->{$interfaceName} = $interface;
309 return $interface; 320 return $interface;
310 } 321 }
311 } 322 }
312 323
313 die("Could NOT find interface definition for $interfaceName in $filename"); 324 die("Could NOT find interface definition for $interfaceName in $filename");
314 } 325 }
315 326
316 sub GenerateInterface 327 sub GenerateInterface
317 { 328 {
318 my $object = shift; 329 my $object = shift;
319 my $interface = shift; 330 my $interface = shift;
320 331
332 print "[GenerateInterface] ", $interface->name, "\n";
333 # ForAllParents($interface, sub {
334 # my $parent = shift;
335 # print " - ", $parent->name, "\n"
336 # });
321 %callbackFunctionTypeHash = map { $_->name => $_ } @{$idlDocument->callbackF unctions}; 337 %callbackFunctionTypeHash = map { $_->name => $_ } @{$idlDocument->callbackF unctions};
322 %enumTypeHash = map { $_->name => $_->values } @{$idlDocument->enumerations} ; 338 %enumTypeHash = map { $_->name => $_->values } @{$idlDocument->enumerations} ;
323 my $v8ClassName = GetV8ClassName($interface); 339 my $v8ClassName = GetV8ClassName($interface);
324 my $defineName = $v8ClassName . "_h"; 340 my $defineName = $v8ClassName . "_h";
325 my $internalNamespace = GetImplName($interface) . "V8Internal"; 341 my $internalNamespace = GetImplName($interface) . "V8Internal";
326 342
327 my $conditionalString = GenerateConditionalString($interface); 343 my $conditionalString = GenerateConditionalString($interface);
328 my $conditionalIf = ""; 344 my $conditionalIf = "";
329 my $conditionalEndif = ""; 345 my $conditionalEndif = "";
330 if ($conditionalString) { 346 if ($conditionalString) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 } else { 401 } else {
386 $object->GenerateHeader($interface); 402 $object->GenerateHeader($interface);
387 $object->GenerateImplementation($interface); 403 $object->GenerateImplementation($interface);
388 } 404 }
389 } 405 }
390 406
391 sub AddToImplIncludes 407 sub AddToImplIncludes
392 { 408 {
393 my $header = shift; 409 my $header = shift;
394 $implIncludes{$header} = 1; 410 $implIncludes{$header} = 1;
411 if($header eq "core/svg/properties/SVGAnimatedPropertyTearOff.h") {
412 # use Carp qw(cluck);
413 # cluck "HEY";
414 }
395 } 415 }
396 416
397 sub AddToHeaderIncludes 417 sub AddToHeaderIncludes
398 { 418 {
399 my @includes = @_; 419 my @includes = @_;
400 420
401 for my $include (@includes) { 421 for my $include (@includes) {
402 $headerIncludes{$include} = 1; 422 $headerIncludes{$include} = 1;
403 } 423 }
404 } 424 }
405 425
426 ### DONE
406 sub SkipIncludeHeader 427 sub SkipIncludeHeader
407 { 428 {
408 my $type = shift; 429 my $type = shift;
409 430
410 return 1 if IsPrimitiveType($type); 431 return 1 if IsPrimitiveType($type);
411 return 1 if IsEnumType($type); 432 return 1 if IsEnumType($type);
412 return 1 if IsCallbackFunctionType($type); 433 return 1 if IsCallbackFunctionType($type);
413 return 1 if $type eq "DOMString"; 434 return 1 if $type eq "DOMString";
414 return 0; 435 return 0;
415 } 436 }
416 437
417 sub AddIncludesForType 438 sub AddIncludesForType
418 { 439 {
419 my $type = shift; 440 my $type = shift;
441 # print "BEBE AddIncludesForType ", $type, "\n";
420 442
421 return if SkipIncludeHeader($type); 443 return if SkipIncludeHeader($type);
422 444
423 # Default includes 445 # Default includes
424 if ($type eq "EventListener" or $type eq "EventHandler") { 446 if ($type eq "EventListener" or $type eq "EventHandler") {
425 AddToImplIncludes("core/dom/EventListener.h"); 447 AddToImplIncludes("core/dom/EventListener.h");
426 } elsif ($type eq "SerializedScriptValue") { 448 } elsif ($type eq "SerializedScriptValue") {
427 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); 449 AddToImplIncludes("bindings/v8/SerializedScriptValue.h");
428 } elsif ($type eq "any" || IsCallbackFunctionType($type)) { 450 } elsif ($type eq "any" || IsCallbackFunctionType($type)) {
429 AddToImplIncludes("bindings/v8/ScriptValue.h"); 451 AddToImplIncludes("bindings/v8/ScriptValue.h");
430 } elsif (IsTypedArrayType($type)) { 452 } elsif (IsTypedArrayType($type)) {
431 AddToImplIncludes("bindings/v8/custom/V8${type}Custom.h"); 453 AddToImplIncludes("bindings/v8/custom/V8${type}Custom.h");
432 } else { 454 } else {
433 AddToImplIncludes("V8${type}.h"); 455 AddToImplIncludes("V8${type}.h");
434 } 456 }
435 } 457 }
436 458
437 sub HeaderFilesForInterface 459 sub HeaderFilesForInterface
438 { 460 {
439 my $interfaceName = shift; 461 my $interfaceName = shift;
440 my $implClassName = shift; 462 my $implClassName = shift;
441 463
464 use Data::Dumper;
442 my @includes = (); 465 my @includes = ();
443 if (IsTypedArrayType($interfaceName)) { 466 if (IsTypedArrayType($interfaceName)) {
467 ### DONE
444 push(@includes, "wtf/${interfaceName}.h"); 468 push(@includes, "wtf/${interfaceName}.h");
445 } elsif (!SkipIncludeHeader($interfaceName)) { 469 } elsif (!SkipIncludeHeader($interfaceName)) {
470 ### DONE
446 my $idlFilename = IDLFileForInterface($interfaceName) or die("Could NOT find IDL file for interface \"$interfaceName\" $!\n"); 471 my $idlFilename = IDLFileForInterface($interfaceName) or die("Could NOT find IDL file for interface \"$interfaceName\" $!\n");
447 my $idlRelPath= "bindings/" . File::Spec->abs2rel($idlFilename, $sourceR oot); 472 my $idlRelPath= "bindings/" . File::Spec->abs2rel($idlFilename, $sourceR oot);
473 # print "GEHEHE ", $idlRelPath, "\n";
474 # print "GEHEHE ", dirname($idlRelPath), "\n";
448 push(@includes, dirname($idlRelPath) . "/" . $implClassName . ".h"); 475 push(@includes, dirname($idlRelPath) . "/" . $implClassName . ".h");
449 } 476 }
477 # print "[HeaderFilesForInterface]", Dumper(@includes);
450 return @includes; 478 return @includes;
451 } 479 }
452 480
481 ### DONE
453 sub NeedsOpaqueRootForGC 482 sub NeedsOpaqueRootForGC
454 { 483 {
455 my $interface = shift; 484 my $interface = shift;
456 return $interface->extendedAttributes->{"GenerateIsReachable"} || $interface ->extendedAttributes->{"CustomIsReachable"}; 485 return $interface->extendedAttributes->{"GenerateIsReachable"} || $interface ->extendedAttributes->{"CustomIsReachable"};
457 } 486 }
458 487
488 ### DONE
459 sub GenerateOpaqueRootForGC 489 sub GenerateOpaqueRootForGC
460 { 490 {
461 my $interface = shift; 491 my $interface = shift;
462 my $implClassName = GetImplName($interface); 492 my $implClassName = GetImplName($interface);
463 my $v8ClassName = GetV8ClassName($interface); 493 my $v8ClassName = GetV8ClassName($interface);
464 494
465 if ($interface->extendedAttributes->{"CustomIsReachable"}) { 495 if ($interface->extendedAttributes->{"CustomIsReachable"}) {
466 return; 496 return;
467 } 497 }
468 498
(...skipping 13 matching lines...) Expand all
482 } 512 }
483 513
484 $code .= <<END; 514 $code .= <<END;
485 return object; 515 return object;
486 } 516 }
487 517
488 END 518 END
489 $implementation{nameSpaceWebCore}->add($code); 519 $implementation{nameSpaceWebCore}->add($code);
490 } 520 }
491 521
522 ### DONE
492 sub GetSVGPropertyTypes 523 sub GetSVGPropertyTypes
493 { 524 {
494 my $implType = shift; 525 my $implType = shift;
495 526
496 my $svgPropertyType; 527 my $svgPropertyType;
497 my $svgListPropertyType; 528 my $svgListPropertyType;
498 my $svgNativeType; 529 my $svgNativeType;
499 530
500 return ($svgPropertyType, $svgListPropertyType, $svgNativeType) if not $impl Type =~ /SVG/; 531 return ($svgPropertyType, $svgListPropertyType, $svgNativeType) if not $impl Type =~ /SVG/;
501 532
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 my $object = shift; 620 my $object = shift;
590 my $interface = shift; 621 my $interface = shift;
591 622
592 my $interfaceName = $interface->name; 623 my $interfaceName = $interface->name;
593 my $implClassName = GetImplName($interface); 624 my $implClassName = GetImplName($interface);
594 my $v8ClassName = GetV8ClassName($interface); 625 my $v8ClassName = GetV8ClassName($interface);
595 626
596 LinkOverloadedFunctions($interface); 627 LinkOverloadedFunctions($interface);
597 628
598 # Ensure the IsDOMNodeType function is in sync. 629 # Ensure the IsDOMNodeType function is in sync.
599 die("IsDOMNodeType is out of date with respect to $interfaceName") if IsDOMN odeType($interfaceName) != InheritsInterface($interface, "Node"); 630 # my $_dom = IsDOMNodeType($interfaceName) ? "DOM" : "";
631 # my $_inh = InheritsInterface($interface, "Node") ? "INH" : "";
632 # print "[DOMDOM] $_dom $_inh ", $interface->name, "\n";
633 if(IsDOMNodeType($interfaceName) != InheritsInterface($interface, "Node")) {
634 die("IsDOMNodeType is out of date with respect to $interfaceName")
635 }
600 636
601 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName); 637 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName);
602 638
603 my $parentInterface = $interface->parent; 639 my $parentInterface = $interface->parent;
604 AddToHeaderIncludes("V8${parentInterface}.h") if $parentInterface; 640 AddToHeaderIncludes("V8${parentInterface}.h") if $parentInterface;
605 AddToHeaderIncludes("bindings/v8/WrapperTypeInfo.h"); 641 AddToHeaderIncludes("bindings/v8/WrapperTypeInfo.h");
606 AddToHeaderIncludes("bindings/v8/V8Binding.h"); 642 AddToHeaderIncludes("bindings/v8/V8Binding.h");
607 AddToHeaderIncludes("bindings/v8/V8DOMWrapper.h"); 643 AddToHeaderIncludes("bindings/v8/V8DOMWrapper.h");
608 AddToHeaderIncludes(HeaderFilesForInterface($interfaceName, $implClassName)) ; 644 AddToHeaderIncludes(HeaderFilesForInterface($interfaceName, $implClassName)) ;
609 foreach my $headerInclude (sort keys(%headerIncludes)) { 645 foreach my $headerInclude (sort keys(%headerIncludes)) {
610 $header{includes}->add("#include \"${headerInclude}\"\n"); 646 $header{includes}->add("#include \"${headerInclude}\"\n");
611 } 647 }
612 648
649 ### DONE
613 $header{nameSpaceWebCore}->addHeader("\ntemplate<typename PropertyType> clas s SVGPropertyTearOff;\n") if $svgPropertyType; 650 $header{nameSpaceWebCore}->addHeader("\ntemplate<typename PropertyType> clas s SVGPropertyTearOff;\n") if $svgPropertyType;
614 if ($svgNativeType) { 651 if ($svgNativeType) {
615 if ($svgNativeType =~ /SVGStaticListPropertyTearOff/) { 652 if ($svgNativeType =~ /SVGStaticListPropertyTearOff/) {
616 $header{nameSpaceWebCore}->addHeader("\ntemplate<typename PropertyTy pe> class SVGStaticListPropertyTearOff;\n"); 653 $header{nameSpaceWebCore}->addHeader("\ntemplate<typename PropertyTy pe> class SVGStaticListPropertyTearOff;\n");
617 } else { 654 } else {
618 $header{nameSpaceWebCore}->addHeader("\ntemplate<typename PropertyTy pe> class SVGListPropertyTearOff;\n"); 655 $header{nameSpaceWebCore}->addHeader("\ntemplate<typename PropertyTy pe> class SVGListPropertyTearOff;\n");
619 } 656 }
620 } 657 }
621 658
659 ### DONE
622 $header{nameSpaceWebCore}->addHeader("\nclass Dictionary;") if IsConstructor Template($interface, "Event"); 660 $header{nameSpaceWebCore}->addHeader("\nclass Dictionary;") if IsConstructor Template($interface, "Event");
623 661
662 ### impl_class_name and svg_type_needing_tear_off in python generator
624 my $nativeType = GetNativeTypeForConversions($interface); 663 my $nativeType = GetNativeTypeForConversions($interface);
625 if ($interface->extendedAttributes->{"NamedConstructor"}) { 664 if ($interface->extendedAttributes->{"NamedConstructor"}) {
626 $header{nameSpaceWebCore}->addHeader(<<END); 665 $header{nameSpaceWebCore}->addHeader(<<END);
627 666
628 class V8${nativeType}Constructor { 667 class V8${nativeType}Constructor {
629 public: 668 public:
630 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor ldType); 669 static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWor ldType);
631 static WrapperTypeInfo info; 670 static WrapperTypeInfo info;
632 }; 671 };
633 END 672 END
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 static v8::Handle<v8::ObjectTemplate> GetShadowObjectTemplate(v8::Isolate*, WrapperWorldType); 704 static v8::Handle<v8::ObjectTemplate> GetShadowObjectTemplate(v8::Isolate*, WrapperWorldType);
666 END 705 END
667 } 706 }
668 707
669 my @enabledPerContextFunctions; 708 my @enabledPerContextFunctions;
670 foreach my $function (@{$interface->functions}) { 709 foreach my $function (@{$interface->functions}) {
671 my $name = $function->name; 710 my $name = $function->name;
672 next if $name eq ""; 711 next if $name eq "";
673 my $attrExt = $function->extendedAttributes; 712 my $attrExt = $function->extendedAttributes;
674 713
714 # if (HasCustomMethod($attrExt) && !$attrExt->{"ImplementedBy"} && $funct ion->{overloadIndex} == 1) {
675 if (HasCustomMethod($attrExt) && $function->{overloadIndex} == 1) { 715 if (HasCustomMethod($attrExt) && $function->{overloadIndex} == 1) {
676 my $conditionalString = GenerateConditionalString($function); 716 my $conditionalString = GenerateConditionalString($function);
677 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio nalString; 717 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio nalString;
678 $header{classPublic}->add(<<END); 718 $header{classPublic}->add(<<END);
679 static void ${name}MethodCustom(const v8::FunctionCallbackInfo<v8::Value>&); 719 static void ${name}MethodCustom(const v8::FunctionCallbackInfo<v8::Value>&);
680 END 720 END
681 $header{classPublic}->add("#endif // ${conditionalString}\n") if $co nditionalString; 721 $header{classPublic}->add("#endif // ${conditionalString}\n") if $co nditionalString;
682 } 722 }
683 if ($attrExt->{"EnabledPerContext"}) { 723 if ($attrExt->{"EnabledPerContext"}) {
684 push(@enabledPerContextFunctions, $function); 724 push(@enabledPerContextFunctions, $function);
685 } 725 }
686 } 726 }
687 727
688 if (IsConstructable($interface)) { 728 if (IsConstructable($interface)) {
689 $header{classPublic}->add(" static void constructorCallback(const v8: :FunctionCallbackInfo<v8::Value>&);\n"); 729 $header{classPublic}->add(" static void constructorCallback(const v8: :FunctionCallbackInfo<v8::Value>&);\n");
690 END 730 END
691 } 731 }
692 if (HasCustomConstructor($interface)) { 732 if (HasCustomConstructor($interface)) {
693 $header{classPublic}->add(" static void constructorCustom(const v8::F unctionCallbackInfo<v8::Value>&);\n"); 733 $header{classPublic}->add(" static void constructorCustom(const v8::F unctionCallbackInfo<v8::Value>&);\n");
694 } 734 }
695 735
696 my @enabledPerContextAttributes; 736 my @enabledPerContextAttributes;
697 foreach my $attribute (@{$interface->attributes}) { 737 foreach my $attribute (@{$interface->attributes}) {
698 my $name = $attribute->name; 738 my $name = $attribute->name;
699 my $attrExt = $attribute->extendedAttributes; 739 my $attrExt = $attribute->extendedAttributes;
700 my $conditionalString = GenerateConditionalString($attribute); 740 my $conditionalString = GenerateConditionalString($attribute);
701 if (HasCustomGetter($attrExt) && !$attrExt->{"ImplementedBy"}) { 741 # if (HasCustomGetter($attrExt) && !$attrExt->{"ImplementedBy"}) {
742 if (HasCustomGetter($attrExt)) {
702 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio nalString; 743 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio nalString;
703 $header{classPublic}->add(<<END); 744 $header{classPublic}->add(<<END);
704 static void ${name}AttrGetterCustom(v8::Local<v8::String> name, const v8::Pr opertyCallbackInfo<v8::Value>&); 745 static void ${name}AttrGetterCustom(v8::Local<v8::String> name, const v8::Pr opertyCallbackInfo<v8::Value>&);
705 END 746 END
706 $header{classPublic}->add("#endif // ${conditionalString}\n") if $co nditionalString; 747 $header{classPublic}->add("#endif // ${conditionalString}\n") if $co nditionalString;
707 } 748 }
708 if (HasCustomSetter($attrExt) && !$attrExt->{"ImplementedBy"}) { 749 # if (HasCustomSetter($attrExt) && !$attrExt->{"ImplementedBy"}) {
750 if (HasCustomSetter($attrExt)) {
709 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio nalString; 751 $header{classPublic}->add("#if ${conditionalString}\n") if $conditio nalString;
710 $header{classPublic}->add(<<END); 752 $header{classPublic}->add(<<END);
711 static void ${name}AttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8 ::Value>, const v8::PropertyCallbackInfo<void>&); 753 static void ${name}AttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8 ::Value>, const v8::PropertyCallbackInfo<void>&);
712 END 754 END
713 $header{classPublic}->add("#endif // ${conditionalString}\n") if $co nditionalString; 755 $header{classPublic}->add("#endif // ${conditionalString}\n") if $co nditionalString;
714 } 756 }
715 if ($attrExt->{"EnabledPerContext"}) { 757 if ($attrExt->{"EnabledPerContext"}) {
716 push(@enabledPerContextAttributes, $attribute); 758 push(@enabledPerContextAttributes, $attribute);
717 } 759 }
718 } 760 }
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 v8::Handle<v8::Value> data = info.Data(); 1227 v8::Handle<v8::Value> data = info.Data();
1186 ASSERT(data->IsExternal()); 1228 ASSERT(data->IsExternal());
1187 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre ationContext()); 1229 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre ationContext());
1188 if (!perContextData) 1230 if (!perContextData)
1189 return; 1231 return;
1190 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u nwrap(data))); 1232 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u nwrap(data)));
1191 } 1233 }
1192 END 1234 END
1193 } 1235 }
1194 1236
1237 ### macro get_feature_observation_parameter in template
1195 sub GenerateFeatureObservation 1238 sub GenerateFeatureObservation
1196 { 1239 {
1197 my $measureAs = shift; 1240 my $measureAs = shift;
1198 1241
1199 if ($measureAs) { 1242 if ($measureAs) {
1200 AddToImplIncludes("core/page/UseCounter.h"); 1243 AddToImplIncludes("core/page/UseCounter.h");
1201 return " UseCounter::count(activeDOMWindow(), UseCounter::${measureAs });\n"; 1244 return " UseCounter::count(activeDOMWindow(), UseCounter::${measureAs });\n";
1202 } 1245 }
1203 1246
1204 return ""; 1247 return "";
1205 } 1248 }
1206 1249
1250 ### macro deprecation_notification_parameter in template
1207 sub GenerateDeprecationNotification 1251 sub GenerateDeprecationNotification
1208 { 1252 {
1209 my $deprecateAs = shift; 1253 my $deprecateAs = shift;
1210 if ($deprecateAs) { 1254 if ($deprecateAs) {
1211 AddToImplIncludes("core/page/PageConsole.h"); 1255 AddToImplIncludes("core/page/PageConsole.h");
1212 AddToImplIncludes("core/page/UseCounter.h"); 1256 AddToImplIncludes("core/page/UseCounter.h");
1213 return " UseCounter::countDeprecation(activeDOMWindow(), UseCounter:: ${deprecateAs});\n"; 1257 return " UseCounter::countDeprecation(activeDOMWindow(), UseCounter:: ${deprecateAs});\n";
1214 } 1258 }
1215 return ""; 1259 return "";
1216 } 1260 }
1217 1261
1262 ### DONE
1218 sub GenerateActivityLogging 1263 sub GenerateActivityLogging
1219 { 1264 {
1220 my $accessType = shift; 1265 my $accessType = shift;
1221 my $interface = shift; 1266 my $interface = shift;
1222 my $propertyName = shift; 1267 my $propertyName = shift;
1223 1268
1224 my $interfaceName = $interface->name; 1269 my $interfaceName = $interface->name;
1225 1270
1226 AddToImplIncludes("bindings/v8/V8Binding.h"); 1271 AddToImplIncludes("bindings/v8/V8Binding.h");
1227 AddToImplIncludes("bindings/v8/V8DOMActivityLogger.h"); 1272 AddToImplIncludes("bindings/v8/V8DOMActivityLogger.h");
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 { 1306 {
1262 my $attribute = shift; 1307 my $attribute = shift;
1263 my $interface = shift; 1308 my $interface = shift;
1264 my $forMainWorldSuffix = shift; 1309 my $forMainWorldSuffix = shift;
1265 1310
1266 my $implClassName = GetImplName($interface); 1311 my $implClassName = GetImplName($interface);
1267 my $v8ClassName = GetV8ClassName($interface); 1312 my $v8ClassName = GetV8ClassName($interface);
1268 my $attrExt = $attribute->extendedAttributes; 1313 my $attrExt = $attribute->extendedAttributes;
1269 my $attrName = $attribute->name; 1314 my $attrName = $attribute->name;
1270 1315
1316 ### DONE
1271 my $conditionalString = GenerateConditionalString($attribute); 1317 my $conditionalString = GenerateConditionalString($attribute);
1272 my $code = ""; 1318 my $code = "";
1273 $code .= "#if ${conditionalString}\n\n" if $conditionalString; 1319 $code .= "#if ${conditionalString}\n\n" if $conditionalString;
1274 1320
1275 $code .= "static void ${attrName}AttrGetterCallback${forMainWorldSuffix}(v8: :Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)\n"; 1321 $code .= "static void ${attrName}AttrGetterCallback${forMainWorldSuffix}(v8: :Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)\n";
1276 $code .= "{\n"; 1322 $code .= "{\n";
1323 ### DONE
1277 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMGetter\");\n"; 1324 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMGetter\");\n";
1278 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); 1325 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"});
1326 ### DONE
1279 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"}); 1327 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"});
1328 ### DONE
1280 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Getter")) { 1329 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Getter")) {
1281 $code .= GenerateActivityLogging("Getter", $interface, "${attrName}"); 1330 $code .= GenerateActivityLogging("Getter", $interface, "${attrName}");
1282 } 1331 }
1283 if (HasCustomGetter($attrExt)) { 1332 if (HasCustomGetter($attrExt)) {
1333 ### DONE
1284 $code .= " ${v8ClassName}::${attrName}AttrGetterCustom(name, info);\n "; 1334 $code .= " ${v8ClassName}::${attrName}AttrGetterCustom(name, info);\n ";
1285 } else { 1335 } else {
1336 ### TODO
1286 $code .= " ${implClassName}V8Internal::${attrName}AttrGetter${forMain WorldSuffix}(name, info);\n"; 1337 $code .= " ${implClassName}V8Internal::${attrName}AttrGetter${forMain WorldSuffix}(name, info);\n";
1287 } 1338 }
1288 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"Execution\");\n"; 1339 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"Execution\");\n";
1289 $code .= "}\n\n"; 1340 $code .= "}\n\n";
1341 ### DONE
1290 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; 1342 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString;
1291 1343
1292 $implementation{nameSpaceInternal}->add($code); 1344 $implementation{nameSpaceInternal}->add($code);
1293 } 1345 }
1294 1346
1295 sub GenerateNormalAttrGetter 1347 sub GenerateNormalAttrGetter
1296 { 1348 {
1297 my $attribute = shift; 1349 my $attribute = shift;
1298 my $interface = shift; 1350 my $interface = shift;
1299 my $forMainWorldSuffix = shift; 1351 my $forMainWorldSuffix = shift;
1300 1352
1353 print " [GenerateNormalAttrGetter]", $attribute->type, " ", $attribute->name, "\ n";
1301 my $interfaceName = $interface->name; 1354 my $interfaceName = $interface->name;
1302 my $implClassName = GetImplName($interface); 1355 my $implClassName = GetImplName($interface);
1303 my $v8ClassName = GetV8ClassName($interface); 1356 my $v8ClassName = GetV8ClassName($interface);
1304 my $attrExt = $attribute->extendedAttributes; 1357 my $attrExt = $attribute->extendedAttributes;
1305 my $attrName = $attribute->name; 1358 my $attrName = $attribute->name;
1306 my $attrType = $attribute->type; 1359 my $attrType = $attribute->type;
1307 1360
1308 if (HasCustomGetter($attrExt)) { 1361 if (HasCustomGetter($attrExt)) {
1309 return; 1362 return;
1310 } 1363 }
1311 1364
1312 AssertNotSequenceType($attrType); 1365 AssertNotSequenceType($attrType);
1313 my $nativeType = GetNativeType($attribute->type, $attribute->extendedAttribu tes, ""); 1366 my $nativeType = GetNativeType($attribute->type, $attribute->extendedAttribu tes, "");
1314 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); 1367 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName);
1315 1368
1316 my $conditionalString = GenerateConditionalString($attribute); 1369 my $conditionalString = GenerateConditionalString($attribute);
1317 my $code = ""; 1370 my $code = "";
1318 $code .= "#if ${conditionalString}\n\n" if $conditionalString; 1371 $code .= "#if ${conditionalString}\n\n" if $conditionalString;
1319 $code .= <<END; 1372 $code .= <<END;
1320 static void ${attrName}AttrGetter${forMainWorldSuffix}(v8::Local<v8::String> nam e, const v8::PropertyCallbackInfo<v8::Value>& info) 1373 static void ${attrName}AttrGetter${forMainWorldSuffix}(v8::Local<v8::String> nam e, const v8::PropertyCallbackInfo<v8::Value>& info)
1321 { 1374 {
1322 END 1375 END
1376 ### First, get impl_class instance
1323 if ($svgNativeType) { 1377 if ($svgNativeType) {
1378 ### TODO
1324 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam e); 1379 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam e);
1325 if ($svgWrappedNativeType =~ /List/) { 1380 if ($svgWrappedNativeType =~ /List/) {
1326 $code .= <<END; 1381 $code .= <<END;
1327 $svgNativeType* imp = ${v8ClassName}::toNative(info.Holder()); 1382 $svgNativeType* imp = ${v8ClassName}::toNative(info.Holder());
1328 END 1383 END
1329 } else { 1384 } else {
1330 $code .= <<END; 1385 $code .= <<END;
1331 $svgNativeType* wrapper = ${v8ClassName}::toNative(info.Holder()); 1386 $svgNativeType* wrapper = ${v8ClassName}::toNative(info.Holder());
1332 $svgWrappedNativeType& impInstance = wrapper->propertyReference(); 1387 $svgWrappedNativeType& impInstance = wrapper->propertyReference();
1333 $svgWrappedNativeType* imp = &impInstance; 1388 $svgWrappedNativeType* imp = &impInstance;
1334 END 1389 END
1335 } 1390 }
1336 } elsif ($attrExt->{"OnProto"} || $attrExt->{"Unforgeable"}) { 1391 } elsif ($attrExt->{"OnProto"} || $attrExt->{"Unforgeable"}) {
1392 ### TODO
1337 if ($interfaceName eq "Window") { 1393 if ($interfaceName eq "Window") {
1338 $code .= <<END; 1394 $code .= <<END;
1339 v8::Handle<v8::Object> holder = info.Holder(); 1395 v8::Handle<v8::Object> holder = info.Holder();
1340 END 1396 END
1341 } else { 1397 } else {
1342 # perform lookup first 1398 # perform lookup first
1343 $code .= <<END; 1399 $code .= <<END;
1344 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8ClassName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); 1400 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8ClassName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate())));
1345 if (holder.IsEmpty()) 1401 if (holder.IsEmpty())
1346 return; 1402 return;
1347 END 1403 END
1348 } 1404 }
1349 $code .= <<END; 1405 $code .= <<END;
1350 ${implClassName}* imp = ${v8ClassName}::toNative(holder); 1406 ${implClassName}* imp = ${v8ClassName}::toNative(holder);
1351 END 1407 END
1352 } else { 1408 } else {
1409 ### DONE
1353 my $reflect = $attribute->extendedAttributes->{"Reflect"}; 1410 my $reflect = $attribute->extendedAttributes->{"Reflect"};
1354 my $url = $attribute->extendedAttributes->{"URL"}; 1411 my $url = $attribute->extendedAttributes->{"URL"};
1355 if ($reflect && !$url && InheritsInterface($interface, "Node") && $attrT ype eq "DOMString") { 1412 if ($reflect && !$url && InheritsInterface($interface, "Node") && $attrT ype eq "DOMString") {
1356 # Generate super-compact call for regular attribute getter: 1413 # Generate super-compact call for regular attribute getter:
1357 my ($functionName, @arguments) = GetterExpression($interfaceName, $a ttribute); 1414 my ($functionName, @arguments) = GetterExpression($interfaceName, $a ttribute);
1358 $code .= " Element* imp = V8Element::toNative(info.Holder());\n"; 1415 $code .= " Element* imp = V8Element::toNative(info.Holder());\n";
1359 $code .= " v8SetReturnValueString(info, imp->${functionName}(" . join(", ", @arguments) . "), info.GetIsolate());\n"; 1416 $code .= " v8SetReturnValueString(info, imp->${functionName}(" . join(", ", @arguments) . "), info.GetIsolate());\n";
1360 $code .= " return;\n"; 1417 $code .= " return;\n";
1361 $code .= "}\n\n"; 1418 $code .= "}\n\n";
1362 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; 1419 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString;
1363 $implementation{nameSpaceInternal}->add($code); 1420 $implementation{nameSpaceInternal}->add($code);
1364 return; 1421 return;
1365 # Skip the rest of the function! 1422 # Skip the rest of the function!
1366 } 1423 }
1367 if ($attribute->type eq "SerializedScriptValue" && $attrExt->{"CachedAtt ribute"}) { 1424 if ($attribute->type eq "SerializedScriptValue" && $attrExt->{"CachedAtt ribute"}) {
1368 $code .= <<END; 1425 $code .= <<END;
1369 v8::Handle<v8::String> propertyName = v8::String::NewSymbol("${attrName}"); 1426 v8::Handle<v8::String> propertyName = v8::String::NewSymbol("${attrName}");
1370 v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(propertyName); 1427 v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(propertyName);
1371 if (!value.IsEmpty()) { 1428 if (!value.IsEmpty()) {
1372 v8SetReturnValue(info, value); 1429 v8SetReturnValue(info, value);
1373 return; 1430 return;
1374 } 1431 }
1375 END 1432 END
1376 } 1433 }
1377 if (!$attribute->isStatic) { 1434 if (!$attribute->isStatic) {
1435 ### generally this is taken.
1378 $code .= <<END; 1436 $code .= <<END;
1379 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); 1437 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder());
1380 END 1438 END
1381 } 1439 }
1382 } 1440 }
1383 1441
1442 ### DONE
1384 # Generate security checks if necessary 1443 # Generate security checks if necessary
1385 if ($attribute->extendedAttributes->{"CheckSecurityForNode"}) { 1444 if ($attribute->extendedAttributes->{"CheckSecurityForNode"}) {
1386 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 1445 AddToImplIncludes("bindings/v8/BindingSecurity.h");
1387 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($attribute) . "())) {\n"; 1446 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($attribute) . "())) {\n";
1388 $code .= " v8SetReturnValueNull(info);\n"; 1447 $code .= " v8SetReturnValueNull(info);\n";
1389 $code .= " return;\n"; 1448 $code .= " return;\n";
1390 $code .= " }\n"; 1449 $code .= " }\n";
1391 } 1450 }
1392 1451
1393 my $useExceptions = 1 if $attribute->extendedAttributes->{"GetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"}; 1452 my $useExceptions = 1 if $attribute->extendedAttributes->{"GetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"};
(...skipping 28 matching lines...) Expand all
1422 $code .= $subCode; 1481 $code .= $subCode;
1423 unshift(@arguments, @$arg); 1482 unshift(@arguments, @$arg);
1424 $getterString = "${functionName}(" . join(", ", @arguments) . ")"; 1483 $getterString = "${functionName}(" . join(", ", @arguments) . ")";
1425 1484
1426 my $expression; 1485 my $expression;
1427 if ($attribute->type eq "EventHandler" && $interface->name eq "Window") { 1486 if ($attribute->type eq "EventHandler" && $interface->name eq "Window") {
1428 $code .= " if (!imp->document())\n"; 1487 $code .= " if (!imp->document())\n";
1429 $code .= " return;\n"; 1488 $code .= " return;\n";
1430 } 1489 }
1431 1490
1491 ### TODO: always use intermediate variable v!
1432 if ($useExceptions || $isNullable) { 1492 if ($useExceptions || $isNullable) {
1433 if ($nativeType =~ /^V8StringResource/) { 1493 if ($nativeType =~ /^V8StringResource/) {
1494 ### is it necessary???
1434 $code .= " " . ConvertToV8StringResource($attribute, $nativeType, "v", $getterString) . ";\n"; 1495 $code .= " " . ConvertToV8StringResource($attribute, $nativeType, "v", $getterString) . ";\n";
1435 } else { 1496 } else {
1497 # Done
1436 $code .= " $nativeType v = $getterString;\n"; 1498 $code .= " $nativeType v = $getterString;\n";
1437 } 1499 }
1438 1500
1501 ### DONE
1439 if ($isNullable) { 1502 if ($isNullable) {
1440 $code .= " if (isNull) {\n"; 1503 $code .= " if (isNull) {\n";
1441 $code .= " v8SetReturnValueNull(info);\n"; 1504 $code .= " v8SetReturnValueNull(info);\n";
1442 $code .= " return;\n"; 1505 $code .= " return;\n";
1443 $code .= " }\n"; 1506 $code .= " }\n";
1444 } 1507 }
1445 1508
1446 if ($useExceptions) { 1509 if ($useExceptions) {
1510 ### DONE
1447 if ($useExceptions) { 1511 if ($useExceptions) {
1448 $code .= " if (UNLIKELY(es.throwIfNeeded()))\n"; 1512 $code .= " if (UNLIKELY(es.throwIfNeeded()))\n";
1449 $code .= " return;\n"; 1513 $code .= " return;\n";
1450 } 1514 }
1451 1515
1452 if (ExtendedAttributeContains($attribute->extendedAttributes->{"Call With"}, "ScriptState")) { 1516 if (ExtendedAttributeContains($attribute->extendedAttributes->{"Call With"}, "ScriptState")) {
1517 ### TODO
1453 $code .= " if (state.hadException()) {\n"; 1518 $code .= " if (state.hadException()) {\n";
1454 $code .= " throwError(state.exception());\n"; 1519 $code .= " throwError(state.exception());\n";
1455 $code .= " return;\n"; 1520 $code .= " return;\n";
1456 $code .= " }\n"; 1521 $code .= " }\n";
1457 } 1522 }
1458 } 1523 }
1459 1524
1525 ## getter_expression in python
1460 $expression = "v"; 1526 $expression = "v";
1461 $expression .= ".release()" if (IsRefPtrType($returnType)); 1527 $expression .= ".release()" if (IsRefPtrType($returnType));
1462 } else { 1528 } else {
1463 # Can inline the function call into the return statement to avoid overhe ad of using a Ref<> temporary 1529 # Can inline the function call into the return statement to avoid overhe ad of using a Ref<> temporary
1464 $expression = $getterString; 1530 $expression = $getterString;
1465 # Fix amigious conversion problem, by casting to the base type first ($g etterString returns a type that inherits from SVGAnimatedEnumeration, not the ba se class directly). 1531 # Fix amigious conversion problem, by casting to the base type first ($g etterString returns a type that inherits from SVGAnimatedEnumeration, not the ba se class directly).
1466 $expression = "static_pointer_cast<SVGAnimatedEnumeration>($expression)" if $returnType eq "SVGAnimatedEnumeration"; 1532 $expression = "static_pointer_cast<SVGAnimatedEnumeration>($expression)" if $returnType eq "SVGAnimatedEnumeration";
1467 } 1533 }
1468 1534
1535 # print "[BAR] ", $expression, "\n" if $interface->name eq "WebKitSourceBuffe r";
1536 ### FIXME: remove this special case!
1469 if (ShouldKeepAttributeAlive($interface, $attribute, $returnType)) { 1537 if (ShouldKeepAttributeAlive($interface, $attribute, $returnType)) {
1538 ### DONE
1470 my $arrayType = GetArrayType($returnType); 1539 my $arrayType = GetArrayType($returnType);
1471 if ($arrayType) { 1540 if ($arrayType) {
1472 AddIncludeForType("V8$arrayType.h"); 1541 AddIncludeForType("V8$arrayType.h");
1473 $code .= " v8SetReturnValue(info, v8Array(${getterString}, info.G etIsolate()));\n"; 1542 $code .= " v8SetReturnValue(info, v8Array(${getterString}, info.G etIsolate()));\n";
1474 $code .= " return;\n"; 1543 $code .= " return;\n";
1475 $code .= "}\n\n"; 1544 $code .= "}\n\n";
1476 $implementation{nameSpaceInternal}->add($code); 1545 $implementation{nameSpaceInternal}->add($code);
1477 return; 1546 return;
1478 } 1547 }
1479 1548
1480 AddIncludesForType($returnType); 1549 AddIncludesForType($returnType);
1481 AddToImplIncludes("bindings/v8/V8HiddenPropertyName.h"); 1550 AddToImplIncludes("bindings/v8/V8HiddenPropertyName.h");
1482 # Check for a wrapper in the wrapper cache. If there is one, we know tha t a hidden reference has already 1551 # Check for a wrapper in the wrapper cache. If there is one, we know tha t a hidden reference has already
1483 # been created. If we don't find a wrapper, we create both a wrapper and a hidden reference. 1552 # been created. If we don't find a wrapper, we create both a wrapper and a hidden reference.
1484 my $nativeReturnType = GetNativeType($returnType); 1553 my $nativeReturnType = GetNativeType($returnType);
1554 # getterString is native_value_expression in python generator
1485 my $v8ReturnType = "V8" . $returnType; 1555 my $v8ReturnType = "V8" . $returnType;
1486 $code .= " $nativeReturnType result = ${getterString};\n"; 1556 $code .= " $nativeReturnType result = ${getterString};\n";
1487 if ($forMainWorldSuffix) { 1557 if ($forMainWorldSuffix) {
1488 $code .= " v8::Handle<v8::Value> wrapper = result.get() ? v8::Handl e<v8::Value>(DOMDataStore::getWrapper${forMainWorldSuffix}<${v8ReturnType}>(resu lt.get())) : v8Undefined();\n"; 1558 $code .= " v8::Handle<v8::Value> wrapper = result.get() ? v8::Handl e<v8::Value>(DOMDataStore::getWrapper${forMainWorldSuffix}<${v8ReturnType}>(resu lt.get())) : v8Undefined();\n";
1489 } else { 1559 } else {
1490 $code .= " v8::Handle<v8::Value> wrapper = result.get() ? v8::Handl e<v8::Value>(DOMDataStore::getWrapper<${v8ReturnType}>(result.get(), info.GetIso late())) : v8Undefined();\n"; 1560 $code .= " v8::Handle<v8::Value> wrapper = result.get() ? v8::Handl e<v8::Value>(DOMDataStore::getWrapper<${v8ReturnType}>(result.get(), info.GetIso late())) : v8Undefined();\n";
1491 } 1561 }
1492 $code .= " if (wrapper.IsEmpty()) {\n"; 1562 $code .= " if (wrapper.IsEmpty()) {\n";
1493 $code .= " wrapper = toV8(result.get(), info.Holder(), info.GetIs olate());\n"; # FIXME: Could use wrap here since the wrapper is empty. 1563 $code .= " wrapper = toV8(result.get(), info.Holder(), info.GetIs olate());\n"; # FIXME: Could use wrap here since the wrapper is empty.
1494 $code .= " if (!wrapper.IsEmpty())\n"; 1564 $code .= " if (!wrapper.IsEmpty())\n";
1495 $code .= " V8HiddenPropertyName::setNamedHiddenReference(info .Holder(), \"${attrName}\", wrapper);\n"; 1565 $code .= " V8HiddenPropertyName::setNamedHiddenReference(info .Holder(), \"${attrName}\", wrapper);\n";
1496 $code .= " }\n"; 1566 $code .= " }\n";
1497 $code .= " v8SetReturnValue(info, wrapper);\n"; 1567 $code .= " v8SetReturnValue(info, wrapper);\n";
1498 $code .= " return;\n"; 1568 $code .= " return;\n";
1499 $code .= "}\n\n"; 1569 $code .= "}\n\n";
1500 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; 1570 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString;
1501 $implementation{nameSpaceInternal}->add($code); 1571 $implementation{nameSpaceInternal}->add($code);
1502 return; 1572 return;
1503 } 1573 }
1504 1574
1505 if ((IsSVGAnimatedType($interfaceName) or $interfaceName eq "SVGViewSpec") a nd IsSVGTypeNeedingTearOff($attrType)) { 1575 if ((IsSVGAnimatedType($interfaceName) or $interfaceName eq "SVGViewSpec") a nd IsSVGTypeNeedingTearOff($attrType)) {
1576 ### DONE
1506 AddToImplIncludes("V8$attrType.h"); 1577 AddToImplIncludes("V8$attrType.h");
1507 my $svgNativeType = GetSVGTypeNeedingTearOff($attrType); 1578 my $svgNativeType = GetSVGTypeNeedingTearOff($attrType);
1508 # Convert from abstract SVGProperty to real type, so the right toJS() me thod can be invoked. 1579 # Convert from abstract SVGProperty to real type, so the right toJS() me thod can be invoked.
1509 if ($forMainWorldSuffix eq "ForMainWorld") { 1580 if ($forMainWorldSuffix eq "ForMainWorld") {
1510 $code .= " v8SetReturnValue(info, toV8ForMainWorld(static_cast<$s vgNativeType*>($expression), info.Holder(), info.GetIsolate()));\n"; 1581 $code .= " v8SetReturnValue(info, toV8ForMainWorld(static_cast<$s vgNativeType*>($expression), info.Holder(), info.GetIsolate()));\n";
1511 } else { 1582 } else {
1512 $code .= " v8SetReturnValue(info, toV8Fast(static_cast<$svgNative Type*>($expression), info, imp));\n"; 1583 $code .= " v8SetReturnValue(info, toV8Fast(static_cast<$svgNative Type*>($expression), info, imp));\n";
1513 } 1584 }
1514 $code .= " return;\n"; 1585 $code .= " return;\n";
1515 } elsif (IsSVGTypeNeedingTearOff($attrType) and not $interfaceName =~ /List$ /) { 1586 } elsif (IsSVGTypeNeedingTearOff($attrType) and not $interfaceName =~ /List$ /) {
1587 ### DONE
1516 AddToImplIncludes("V8$attrType.h"); 1588 AddToImplIncludes("V8$attrType.h");
1517 AddToImplIncludes("core/svg/properties/SVGPropertyTearOff.h"); 1589 AddToImplIncludes("core/svg/properties/SVGPropertyTearOff.h");
1518 my $tearOffType = GetSVGTypeNeedingTearOff($attrType); 1590 my $tearOffType = GetSVGTypeNeedingTearOff($attrType);
1519 my $wrappedValue; 1591 my $wrappedValue;
1520 if (IsSVGTypeWithWritablePropertiesNeedingTearOff($attrType) and not def ined $attribute->extendedAttributes->{"Immutable"}) { 1592 if (IsSVGTypeWithWritablePropertiesNeedingTearOff($attrType) and not def ined $attribute->extendedAttributes->{"Immutable"}) {
1521 my $getter = $expression; 1593 my $getter = $expression;
1522 $getter =~ s/imp->//; 1594 $getter =~ s/imp->//;
1523 $getter =~ s/\(\)//; 1595 $getter =~ s/\(\)//;
1524 1596
1525 my $updateMethod = "&${implClassName}::update" . FirstLetterToUpperC ase($getter); 1597 my $updateMethod = "&${implClassName}::update" . FirstLetterToUpperC ase($getter);
(...skipping 17 matching lines...) Expand all
1543 } else { 1615 } else {
1544 $wrappedValue = "WTF::getPtr(${tearOffType}::create($expression) )"; 1616 $wrappedValue = "WTF::getPtr(${tearOffType}::create($expression) )";
1545 } 1617 }
1546 if ($forMainWorldSuffix eq "ForMainWorld") { 1618 if ($forMainWorldSuffix eq "ForMainWorld") {
1547 $code .= " v8SetReturnValue(info, toV8ForMainWorld($wrappedValue, info.Holder(), info.GetIsolate()));\n"; 1619 $code .= " v8SetReturnValue(info, toV8ForMainWorld($wrappedValue, info.Holder(), info.GetIsolate()));\n";
1548 } else { 1620 } else {
1549 $code .= " v8SetReturnValue(info, toV8Fast($wrappedValue, info, i mp));\n"; 1621 $code .= " v8SetReturnValue(info, toV8Fast($wrappedValue, info, i mp));\n";
1550 } 1622 }
1551 $code .= " return;\n"; 1623 $code .= " return;\n";
1552 } elsif ($attribute->type eq "SerializedScriptValue" && $attrExt->{"CachedAt tribute"}) { 1624 } elsif ($attribute->type eq "SerializedScriptValue" && $attrExt->{"CachedAt tribute"}) {
1625 ### DONE
1553 my $getterFunc = ToMethodName($attribute->name); 1626 my $getterFunc = ToMethodName($attribute->name);
1554 $code .= <<END; 1627 $code .= <<END;
1555 RefPtr<SerializedScriptValue> serialized = imp->${getterFunc}(); 1628 RefPtr<SerializedScriptValue> serialized = imp->${getterFunc}();
1556 value = serialized ? serialized->deserialize() : v8::Handle<v8::Value>(v8::N ull(info.GetIsolate())); 1629 value = serialized ? serialized->deserialize() : v8::Handle<v8::Value>(v8::N ull(info.GetIsolate()));
1557 info.Holder()->SetHiddenValue(propertyName, value); 1630 info.Holder()->SetHiddenValue(propertyName, value);
1558 v8SetReturnValue(info, value); 1631 v8SetReturnValue(info, value);
1559 return; 1632 return;
1560 END 1633 END
1561 } elsif ($attribute->type eq "EventHandler") { 1634 } elsif ($attribute->type eq "EventHandler") {
1635 ### DONE
1562 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); 1636 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h");
1563 my $getterFunc = ToMethodName($attribute->name); 1637 my $getterFunc = ToMethodName($attribute->name);
1564 # FIXME: Pass the main world ID for main-world-only getters. 1638 # FIXME: Pass the main world ID for main-world-only getters.
1565 $code .= " EventListener* listener = imp->${getterFunc}(isolatedWorld ForIsolate(info.GetIsolate()));\n"; 1639 $code .= " EventListener* listener = imp->${getterFunc}(isolatedWorld ForIsolate(info.GetIsolate()));\n";
1566 $code .= " v8SetReturnValue(info, listener ? v8::Handle<v8::Value>(V8 AbstractEventListener::cast(listener)->getListenerObject(imp->scriptExecutionCon text())) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate())));\n"; 1640 $code .= " v8SetReturnValue(info, listener ? v8::Handle<v8::Value>(V8 AbstractEventListener::cast(listener)->getListenerObject(imp->scriptExecutionCon text())) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate())));\n";
1567 $code .= " return;\n"; 1641 $code .= " return;\n";
1568 } else { 1642 } else {
1643 ### main
1569 my $nativeValue = NativeToJSValue($attribute->type, $attribute->extended Attributes, $expression, " ", "", "info.Holder()", "info.GetIsolate()", "info ", "imp", $forMainWorldSuffix, "return"); 1644 my $nativeValue = NativeToJSValue($attribute->type, $attribute->extended Attributes, $expression, " ", "", "info.Holder()", "info.GetIsolate()", "info ", "imp", $forMainWorldSuffix, "return");
1570 $code .= "${nativeValue}\n"; 1645 $code .= "${nativeValue}\n";
1571 $code .= " return;\n"; 1646 $code .= " return;\n";
1572 } 1647 }
1573 1648
1574 $code .= "}\n\n"; # end of getter 1649 $code .= "}\n\n"; # end of getter
1575 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; 1650 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString;
1576 $implementation{nameSpaceInternal}->add($code); 1651 $implementation{nameSpaceInternal}->add($code);
1577 } 1652 }
1578 1653
(...skipping 21 matching lines...) Expand all
1600 # depending on the attribute name. 1675 # depending on the attribute name.
1601 return 0 if $attrName eq "self"; 1676 return 0 if $attrName eq "self";
1602 1677
1603 # FIXME: Remove these hard-coded hacks. 1678 # FIXME: Remove these hard-coded hacks.
1604 return 0 if $returnType eq "EventTarget"; 1679 return 0 if $returnType eq "EventTarget";
1605 return 0 if $returnType eq "SerializedScriptValue"; 1680 return 0 if $returnType eq "SerializedScriptValue";
1606 return 0 if $returnType eq "Window"; 1681 return 0 if $returnType eq "Window";
1607 return 0 if $returnType =~ /SVG/; 1682 return 0 if $returnType =~ /SVG/;
1608 return 0 if $returnType =~ /HTML/; 1683 return 0 if $returnType =~ /HTML/;
1609 1684
1685 # print "[FOO] ", $returnType, "\n";
1610 return 1; 1686 return 1;
1611 } 1687 }
1612 1688
1689 ### TODO
1613 sub GenerateReplaceableAttrSetterCallback 1690 sub GenerateReplaceableAttrSetterCallback
1614 { 1691 {
1615 my $interface = shift; 1692 my $interface = shift;
1616 my $implClassName = GetImplName($interface); 1693 my $implClassName = GetImplName($interface);
1617 1694
1618 my $code = ""; 1695 my $code = "";
1619 $code .= "static void ${implClassName}ReplaceableAttrSetterCallback(v8::Loca l<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v oid>& info)\n"; 1696 $code .= "static void ${implClassName}ReplaceableAttrSetterCallback(v8::Loca l<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v oid>& info)\n";
1620 $code .= "{\n"; 1697 $code .= "{\n";
1621 $code .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur eAs"}); 1698 $code .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur eAs"});
1622 $code .= GenerateDeprecationNotification($interface->extendedAttributes->{"D eprecateAs"}); 1699 $code .= GenerateDeprecationNotification($interface->extendedAttributes->{"D eprecateAs"});
(...skipping 29 matching lines...) Expand all
1652 } 1729 }
1653 1730
1654 $code .= <<END; 1731 $code .= <<END;
1655 info.This()->ForceSet(name, value); 1732 info.This()->ForceSet(name, value);
1656 } 1733 }
1657 1734
1658 END 1735 END
1659 $implementation{nameSpaceInternal}->add($code); 1736 $implementation{nameSpaceInternal}->add($code);
1660 } 1737 }
1661 1738
1739 ### DONE ... macro custom_element_invocation in python
1662 sub GenerateCustomElementInvocationScopeIfNeeded 1740 sub GenerateCustomElementInvocationScopeIfNeeded
1663 { 1741 {
1664 my $code = ""; 1742 my $code = "";
1665 my $ext = shift; 1743 my $ext = shift;
1666 my $annotation = $ext->{"CustomElementCallbacks"} || ""; 1744 my $annotation = $ext->{"CustomElementCallbacks"} || "";
1667 1745
1668 if ($annotation eq "None") { 1746 if ($annotation eq "None") {
1669 # Explicit CustomElementCallbacks=None overrides any other 1747 # Explicit CustomElementCallbacks=None overrides any other
1670 # heuristic. 1748 # heuristic.
1671 return $code; 1749 return $code;
(...skipping 14 matching lines...) Expand all
1686 my $interface = shift; 1764 my $interface = shift;
1687 my $forMainWorldSuffix = shift; 1765 my $forMainWorldSuffix = shift;
1688 1766
1689 my $implClassName = GetImplName($interface); 1767 my $implClassName = GetImplName($interface);
1690 my $v8ClassName = GetV8ClassName($interface); 1768 my $v8ClassName = GetV8ClassName($interface);
1691 my $attrExt = $attribute->extendedAttributes; 1769 my $attrExt = $attribute->extendedAttributes;
1692 my $attrName = $attribute->name; 1770 my $attrName = $attribute->name;
1693 1771
1694 my $conditionalString = GenerateConditionalString($attribute); 1772 my $conditionalString = GenerateConditionalString($attribute);
1695 my $code = ""; 1773 my $code = "";
1774 ### DONE
1696 $code .= "#if ${conditionalString}\n\n" if $conditionalString; 1775 $code .= "#if ${conditionalString}\n\n" if $conditionalString;
1697 1776
1698 $code .= "static void ${attrName}AttrSetterCallback${forMainWorldSuffix}(v8: :Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackI nfo<void>& info)\n"; 1777 $code .= "static void ${attrName}AttrSetterCallback${forMainWorldSuffix}(v8: :Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackI nfo<void>& info)\n";
1699 $code .= "{\n"; 1778 $code .= "{\n";
1779 ### DONE
1700 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMSetter\");\n"; 1780 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMSetter\");\n";
1781 ### DONE
1701 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"}); 1782 $code .= GenerateFeatureObservation($attrExt->{"MeasureAs"});
1783 ### DONE
1702 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"}); 1784 $code .= GenerateDeprecationNotification($attrExt->{"DeprecateAs"});
1785 ### DONE
1703 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Setter")) { 1786 if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Setter")) {
1704 $code .= GenerateActivityLogging("Setter", $interface, "${attrName}"); 1787 $code .= GenerateActivityLogging("Setter", $interface, "${attrName}");
1705 } 1788 }
1789 ### DONE
1706 $code .= GenerateCustomElementInvocationScopeIfNeeded($attrExt); 1790 $code .= GenerateCustomElementInvocationScopeIfNeeded($attrExt);
1707 if (HasCustomSetter($attrExt)) { 1791 if (HasCustomSetter($attrExt)) {
1792 ### DONE
1708 $code .= " ${v8ClassName}::${attrName}AttrSetterCustom(name, value, i nfo);\n"; 1793 $code .= " ${v8ClassName}::${attrName}AttrSetterCustom(name, value, i nfo);\n";
1709 } else { 1794 } else {
1795 ### DONE
1710 $code .= " ${implClassName}V8Internal::${attrName}AttrSetter${forMain WorldSuffix}(name, value, info);\n"; 1796 $code .= " ${implClassName}V8Internal::${attrName}AttrSetter${forMain WorldSuffix}(name, value, info);\n";
1711 } 1797 }
1798 ### DONE
1712 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"Execution\");\n"; 1799 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"Execution\");\n";
1713 $code .= "}\n\n"; 1800 $code .= "}\n\n";
1801 ### DONE
1714 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; 1802 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString;
1715 $implementation{nameSpaceInternal}->add($code); 1803 $implementation{nameSpaceInternal}->add($code);
1716 } 1804 }
1717 1805
1718 sub GenerateNormalAttrSetter 1806 sub GenerateNormalAttrSetter
1719 { 1807 {
1720 my $attribute = shift; 1808 my $attribute = shift;
1721 my $interface = shift; 1809 my $interface = shift;
1722 my $forMainWorldSuffix = shift; 1810 my $forMainWorldSuffix = shift;
1723 1811
(...skipping 12 matching lines...) Expand all
1736 my $code = ""; 1824 my $code = "";
1737 $code .= "#if ${conditionalString}\n\n" if $conditionalString; 1825 $code .= "#if ${conditionalString}\n\n" if $conditionalString;
1738 $code .= "static void ${attrName}AttrSetter${forMainWorldSuffix}(v8::Local<v 8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void >& info)\n"; 1826 $code .= "static void ${attrName}AttrSetter${forMainWorldSuffix}(v8::Local<v 8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void >& info)\n";
1739 $code .= "{\n"; 1827 $code .= "{\n";
1740 1828
1741 # If the "StrictTypeChecking" extended attribute is present, and the attribu te's type is an 1829 # If the "StrictTypeChecking" extended attribute is present, and the attribu te's type is an
1742 # interface type, then if the incoming value does not implement that interfa ce, a TypeError is 1830 # interface type, then if the incoming value does not implement that interfa ce, a TypeError is
1743 # thrown rather than silently passing NULL to the C++ code. 1831 # thrown rather than silently passing NULL to the C++ code.
1744 # Per the Web IDL and ECMAScript specifications, incoming values can always be converted to both 1832 # Per the Web IDL and ECMAScript specifications, incoming values can always be converted to both
1745 # strings and numbers, so do not throw TypeError if the attribute is of thes e types. 1833 # strings and numbers, so do not throw TypeError if the attribute is of thes e types.
1834 ### TODO
1746 if ($attribute->extendedAttributes->{"StrictTypeChecking"}) { 1835 if ($attribute->extendedAttributes->{"StrictTypeChecking"}) {
1747 my $argType = $attribute->type; 1836 my $argType = $attribute->type;
1748 if (IsWrapperType($argType)) { 1837 if (IsWrapperType($argType)) {
1749 $code .= " if (!isUndefinedOrNull(value) && !V8${argType}::HasIns tance(value, info.GetIsolate(), worldType(info.GetIsolate()))) {\n"; 1838 $code .= " if (!isUndefinedOrNull(value) && !V8${argType}::HasIns tance(value, info.GetIsolate(), worldType(info.GetIsolate()))) {\n";
1750 $code .= " throwTypeError(info.GetIsolate());\n"; 1839 $code .= " throwTypeError(info.GetIsolate());\n";
1751 $code .= " return;\n"; 1840 $code .= " return;\n";
1752 $code .= " }\n"; 1841 $code .= " }\n";
1753 } 1842 }
1754 } 1843 }
1755 1844
1756 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); 1845 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName);
1757 if ($svgNativeType) { 1846 if ($svgNativeType) {
1847 ### TODO
1758 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam e); 1848 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam e);
1759 if ($svgWrappedNativeType =~ /List$/) { 1849 if ($svgWrappedNativeType =~ /List$/) {
1760 $code .= <<END; 1850 $code .= <<END;
1761 $svgNativeType* imp = ${v8ClassName}::toNative(info.Holder()); 1851 $svgNativeType* imp = ${v8ClassName}::toNative(info.Holder());
1762 END 1852 END
1763 } else { 1853 } else {
1764 AddToImplIncludes("bindings/v8/ExceptionState.h"); 1854 AddToImplIncludes("bindings/v8/ExceptionState.h");
1765 $code .= " $svgNativeType* wrapper = ${v8ClassName}::toNative(inf o.Holder());\n"; 1855 $code .= " $svgNativeType* wrapper = ${v8ClassName}::toNative(inf o.Holder());\n";
1766 $code .= " if (wrapper->isReadOnly()) {\n"; 1856 $code .= " if (wrapper->isReadOnly()) {\n";
1767 $code .= " setDOMException(NoModificationAllowedError, info.G etIsolate());\n"; 1857 $code .= " setDOMException(NoModificationAllowedError, info.G etIsolate());\n";
1768 $code .= " return;\n"; 1858 $code .= " return;\n";
1769 $code .= " }\n"; 1859 $code .= " }\n";
1770 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n"; 1860 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n";
1771 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; 1861 $code .= " $svgWrappedNativeType* imp = &impInstance;\n";
1772 } 1862 }
1773 } elsif ($attrExt->{"OnProto"}) { 1863 } elsif ($attrExt->{"OnProto"}) {
1864 ### TODO
1774 $code .= <<END; 1865 $code .= <<END;
1775 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); 1866 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder());
1776 END 1867 END
1777 } else { 1868 } else {
1869 ### main path
1778 my $reflect = $attribute->extendedAttributes->{"Reflect"}; 1870 my $reflect = $attribute->extendedAttributes->{"Reflect"};
1779 if ($reflect && InheritsInterface($interface, "Node") && $attrType eq "D OMString") { 1871 if ($reflect && InheritsInterface($interface, "Node") && $attrType eq "D OMString") {
1780 # Generate super-compact call for regular attribute setter: 1872 # Generate super-compact call for regular attribute setter:
1781 my $contentAttributeName = $reflect eq "VALUE_IS_MISSING" ? lc $attr Name : $reflect; 1873 my $contentAttributeName = $reflect eq "VALUE_IS_MISSING" ? lc $attr Name : $reflect;
1782 my $namespace = NamespaceForAttributeName($interfaceName, $contentAt tributeName); 1874 my $namespace = NamespaceForAttributeName($interfaceName, $contentAt tributeName);
1783 AddToImplIncludes("${namespace}.h"); 1875 AddToImplIncludes("${namespace}.h");
1784 $code .= " Element* imp = V8Element::toNative(info.Holder());\n"; 1876 $code .= " Element* imp = V8Element::toNative(info.Holder());\n";
1785 $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource< WithNullCheck>, stringResource, value);\n"; 1877 $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource< WithNullCheck>, stringResource, value);\n";
1786 $code .= " imp->setAttribute(${namespace}::${contentAttributeName }Attr, stringResource);\n"; 1878 $code .= " imp->setAttribute(${namespace}::${contentAttributeName }Attr, stringResource);\n";
1787 $code .= "}\n\n"; 1879 $code .= "}\n\n";
1788 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; 1880 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString;
1789 $implementation{nameSpaceInternal}->add($code); 1881 $implementation{nameSpaceInternal}->add($code);
1790 return; 1882 return;
1791 # Skip the rest of the function! 1883 # Skip the rest of the function!
1792 } 1884 }
1793 1885
1794 if (!$attribute->isStatic) { 1886 if (!$attribute->isStatic) {
1795 $code .= <<END; 1887 $code .= <<END;
1796 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); 1888 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder());
1797 END 1889 END
1798 } 1890 }
1799 } 1891 }
1800 1892
1801 my $nativeType = GetNativeType($attribute->type, $attribute->extendedAttribu tes, "parameter"); 1893 my $nativeType = GetNativeType($attribute->type, $attribute->extendedAttribu tes, "parameter");
1802 if ($attribute->type eq "EventHandler") { 1894 if ($attribute->type eq "EventHandler") {
1895 ### DONE
1803 if ($interface->name eq "Window") { 1896 if ($interface->name eq "Window") {
1804 $code .= " if (!imp->document())\n"; 1897 $code .= " if (!imp->document())\n";
1805 $code .= " return;\n"; 1898 $code .= " return;\n";
1806 } 1899 }
1807 } else { 1900 } else {
1901 ### DONE
1808 $code .= JSValueToNativeStatement($attribute->type, $attribute->extended Attributes, "value", "v", " ", "info.GetIsolate()"); 1902 $code .= JSValueToNativeStatement($attribute->type, $attribute->extended Attributes, "value", "v", " ", "info.GetIsolate()");
1809 } 1903 }
1810 1904
1905 ### TODO
1811 if (IsEnumType($attrType)) { 1906 if (IsEnumType($attrType)) {
1812 # setter ignores invalid enumeration values 1907 # setter ignores invalid enumeration values
1813 my @enumValues = ValidEnumValues($attrType); 1908 my @enumValues = ValidEnumValues($attrType);
1814 my @validEqualities = (); 1909 my @validEqualities = ();
1815 foreach my $enumValue (@enumValues) { 1910 foreach my $enumValue (@enumValues) {
1816 push(@validEqualities, "string == \"$enumValue\""); 1911 push(@validEqualities, "string == \"$enumValue\"");
1817 } 1912 }
1818 my $enumValidationExpression = join(" || ", @validEqualities); 1913 my $enumValidationExpression = join(" || ", @validEqualities);
1819 $code .= <<END; 1914 $code .= <<END;
1820 String string = v; 1915 String string = v;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 2042
1948 $parameterIndex++; 2043 $parameterIndex++;
1949 } 2044 }
1950 my $res = join(" && ", @andExpression); 2045 my $res = join(" && ", @andExpression);
1951 $res = "($res)" if @andExpression > 1; 2046 $res = "($res)" if @andExpression > 1;
1952 return $res; 2047 return $res;
1953 } 2048 }
1954 2049
1955 # As per Web IDL specification, the length of a function Object is 2050 # As per Web IDL specification, the length of a function Object is
1956 # its number of mandatory parameters. 2051 # its number of mandatory parameters.
2052 ### get_function_mandatory_parameters in python generator
1957 sub GetFunctionLength 2053 sub GetFunctionLength
1958 { 2054 {
1959 my $function = shift; 2055 my $function = shift;
1960 2056
1961 my $numMandatoryParams = 0; 2057 my $numMandatoryParams = 0;
1962 foreach my $parameter (@{$function->parameters}) { 2058 foreach my $parameter (@{$function->parameters}) {
1963 # Abort as soon as we find the first optional parameter as no mandatory 2059 # Abort as soon as we find the first optional parameter as no mandatory
1964 # parameter can follow an optional one. 2060 # parameter can follow an optional one.
1965 last if $parameter->isOptional; 2061 last if $parameter->isOptional;
1966 $numMandatoryParams++; 2062 $numMandatoryParams++;
(...skipping 19 matching lines...) Expand all
1986 last; 2082 last;
1987 } 2083 }
1988 $numParameters++; 2084 $numParameters++;
1989 } 2085 }
1990 if (!$hasVariadic) { 2086 if (!$hasVariadic) {
1991 push(@orExpression, GenerateParametersCheckExpression($numParameters, $f unction)); 2087 push(@orExpression, GenerateParametersCheckExpression($numParameters, $f unction));
1992 } 2088 }
1993 return ($numMandatoryParams, join(" || ", @orExpression)); 2089 return ($numMandatoryParams, join(" || ", @orExpression));
1994 } 2090 }
1995 2091
2092 ### TODO
1996 sub GenerateOverloadedFunction 2093 sub GenerateOverloadedFunction
1997 { 2094 {
1998 my $function = shift; 2095 my $function = shift;
1999 my $interface = shift; 2096 my $interface = shift;
2000 my $forMainWorldSuffix = shift; 2097 my $forMainWorldSuffix = shift;
2001 2098
2002 # Generate code for choosing the correct overload to call. Overloads are 2099 # Generate code for choosing the correct overload to call. Overloads are
2003 # chosen based on the total number of arguments passed and the type of 2100 # chosen based on the total number of arguments passed and the type of
2004 # values passed in non-primitive argument slots. When more than a single 2101 # values passed in non-primitive argument slots. When more than a single
2005 # overload is applicable, precedence is given according to the order of 2102 # overload is applicable, precedence is given according to the order of
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 } 2153 }
2057 2154
2058 my $conditionalString = GenerateConditionalString($function); 2155 my $conditionalString = GenerateConditionalString($function);
2059 my $code = ""; 2156 my $code = "";
2060 $code .= "#if ${conditionalString}\n\n" if $conditionalString; 2157 $code .= "#if ${conditionalString}\n\n" if $conditionalString;
2061 $code .= <<END; 2158 $code .= <<END;
2062 static void ${name}MethodCallback${forMainWorldSuffix}(const v8::FunctionCallbac kInfo<v8::Value>& args) 2159 static void ${name}MethodCallback${forMainWorldSuffix}(const v8::FunctionCallbac kInfo<v8::Value>& args)
2063 { 2160 {
2064 END 2161 END
2065 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMMethod\");\n"; 2162 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMMethod\");\n";
2163 ### DONE
2066 $code .= GenerateFeatureObservation($function->extendedAttributes->{"Measure As"}); 2164 $code .= GenerateFeatureObservation($function->extendedAttributes->{"Measure As"});
2165 ### DONE
2067 $code .= GenerateDeprecationNotification($function->extendedAttributes->{"De precateAs"}); 2166 $code .= GenerateDeprecationNotification($function->extendedAttributes->{"De precateAs"});
2167 ### DONE
2068 if (HasActivityLogging($forMainWorldSuffix, $function->extendedAttributes, " Access")) { 2168 if (HasActivityLogging($forMainWorldSuffix, $function->extendedAttributes, " Access")) {
2069 $code .= GenerateActivityLogging("Method", $interface, "${name}"); 2169 $code .= GenerateActivityLogging("Method", $interface, "${name}");
2070 } 2170 }
2071 if (HasCustomMethod($function->extendedAttributes)) { 2171 if (HasCustomMethod($function->extendedAttributes)) {
2072 $code .= " ${v8ClassName}::${name}MethodCustom(args);\n"; 2172 $code .= " ${v8ClassName}::${name}MethodCustom(args);\n";
2073 } else { 2173 } else {
2074 $code .= " ${implClassName}V8Internal::${name}Method${forMainWorldSuf fix}(args);\n"; 2174 $code .= " ${implClassName}V8Internal::${name}Method${forMainWorldSuf fix}(args);\n";
2075 } 2175 }
2076 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"Execution\");\n"; 2176 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"Execution\");\n";
2077 $code .= "}\n\n"; 2177 $code .= "}\n\n";
2078 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; 2178 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString;
2079 $implementation{nameSpaceInternal}->add($code); 2179 $implementation{nameSpaceInternal}->add($code);
2080 } 2180 }
2081 2181
2182 ### __FUNC__
2082 sub GenerateFunction 2183 sub GenerateFunction
2083 { 2184 {
2185 print " [GenerateFunction]\n";
2084 my $function = shift; 2186 my $function = shift;
2085 my $interface = shift; 2187 my $interface = shift;
2086 my $forMainWorldSuffix = shift; 2188 my $forMainWorldSuffix = shift;
2087 2189
2088 my $interfaceName = $interface->name; 2190 my $interfaceName = $interface->name;
2089 my $implClassName = GetImplName($interface); 2191 my $implClassName = GetImplName($interface);
2090 my $v8ClassName = GetV8ClassName($interface); 2192 my $v8ClassName = GetV8ClassName($interface);
2091 my $name = $function->name; 2193 my $name = $function->name;
2092 my $implName = GetImplName($function); 2194 my $implName = GetImplName($function);
2093 my $funcExt = $function->extendedAttributes; 2195 my $funcExt = $function->extendedAttributes;
2094 2196
2095 if (HasCustomMethod($funcExt) || $name eq "") { 2197 if (HasCustomMethod($funcExt) || $name eq "") {
2096 return; 2198 return;
2097 } 2199 }
2098 2200
2099 if (@{$function->{overloads}} > 1) { 2201 if (@{$function->{overloads}} > 1) {
2100 # Append a number to an overloaded method's name to make it unique: 2202 # Append a number to an overloaded method's name to make it unique:
2101 $name = $name . $function->{overloadIndex}; 2203 $name = $name . $function->{overloadIndex};
2102 } 2204 }
2103 2205
2104 my $conditionalString = GenerateConditionalString($function); 2206 my $conditionalString = GenerateConditionalString($function);
2105 my $code = ""; 2207 my $code = "";
2106 $code .= "#if ${conditionalString}\n\n" if $conditionalString; 2208 $code .= "#if ${conditionalString}\n\n" if $conditionalString;
2107 $code .= "static void ${name}Method${forMainWorldSuffix}(const v8::FunctionC allbackInfo<v8::Value>& args)\n"; 2209 $code .= "static void ${name}Method${forMainWorldSuffix}(const v8::FunctionC allbackInfo<v8::Value>& args)\n";
2108 $code .= "{\n"; 2210 $code .= "{\n";
2109 2211
2110 if ($name eq "addEventListener" || $name eq "removeEventListener") { 2212 if ($name eq "addEventListener" || $name eq "removeEventListener") {
2213 ### TODO
2111 my $lookupType = ($name eq "addEventListener") ? "OrCreate" : "Only"; 2214 my $lookupType = ($name eq "addEventListener") ? "OrCreate" : "Only";
2112 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()"; 2215 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()";
2113 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" : "remove"; 2216 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" : "remove";
2114 2217
2115 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 2218 AddToImplIncludes("bindings/v8/BindingSecurity.h");
2116 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); 2219 AddToImplIncludes("bindings/v8/V8EventListenerList.h");
2117 AddToImplIncludes("core/page/DOMWindow.h"); 2220 AddToImplIncludes("core/page/DOMWindow.h");
2118 $code .= <<END; 2221 $code .= <<END;
2119 EventTarget* impl = ${v8ClassName}::toNative(args.Holder()); 2222 EventTarget* impl = ${v8ClassName}::toNative(args.Holder());
2120 if (DOMWindow* window = impl->toDOMWindow()) { 2223 if (DOMWindow* window = impl->toDOMWindow()) {
(...skipping 12 matching lines...) Expand all
2133 ${hiddenDependencyAction}HiddenDependency(args.Holder(), args[1], ${ v8ClassName}::eventListenerCacheIndex, args.GetIsolate()); 2236 ${hiddenDependencyAction}HiddenDependency(args.Holder(), args[1], ${ v8ClassName}::eventListenerCacheIndex, args.GetIsolate());
2134 } 2237 }
2135 } 2238 }
2136 2239
2137 END 2240 END
2138 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; 2241 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString;
2139 $implementation{nameSpaceInternal}->add($code); 2242 $implementation{nameSpaceInternal}->add($code);
2140 return; 2243 return;
2141 } 2244 }
2142 2245
2246 ### DONE
2143 $code .= GenerateArgumentsCountCheck($function, $interface); 2247 $code .= GenerateArgumentsCountCheck($function, $interface);
2144 2248
2145 if ($name eq "set" and IsConstructorTemplate($interface, "TypedArray")) { 2249 if ($name eq "set" and IsConstructorTemplate($interface, "TypedArray")) {
2250 ### TODO
2146 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferViewCustom.h"); 2251 AddToImplIncludes("bindings/v8/custom/V8ArrayBufferViewCustom.h");
2147 $code .= <<END; 2252 $code .= <<END;
2148 setWebGLArrayHelper<$implClassName, ${v8ClassName}>(args); 2253 setWebGLArrayHelper<$implClassName, ${v8ClassName}>(args);
2149 } 2254 }
2150 2255
2151 END 2256 END
2152 $implementation{nameSpaceInternal}->add($code); 2257 $implementation{nameSpaceInternal}->add($code);
2153 return; 2258 return;
2154 } 2259 }
2155 2260
2261 ### TODO
2156 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName); 2262 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName);
2157 2263
2264 ### TODO
2158 if ($svgNativeType) { 2265 if ($svgNativeType) {
2159 my $nativeClassName = GetNativeType($interfaceName); 2266 my $nativeClassName = GetNativeType($interfaceName);
2160 if ($interfaceName =~ /List$/) { 2267 if ($interfaceName =~ /List$/) {
2161 $code .= " $nativeClassName imp = ${v8ClassName}::toNative(args.H older());\n"; 2268 $code .= " $nativeClassName imp = ${v8ClassName}::toNative(args.H older());\n";
2162 } else { 2269 } else {
2163 AddToImplIncludes("bindings/v8/ExceptionState.h"); 2270 AddToImplIncludes("bindings/v8/ExceptionState.h");
2164 AddToImplIncludes("core/dom/ExceptionCode.h"); 2271 AddToImplIncludes("core/dom/ExceptionCode.h");
2165 $code .= " $nativeClassName wrapper = ${v8ClassName}::toNative(ar gs.Holder());\n"; 2272 $code .= " $nativeClassName wrapper = ${v8ClassName}::toNative(ar gs.Holder());\n";
2166 $code .= " if (wrapper->isReadOnly()) {\n"; 2273 $code .= " if (wrapper->isReadOnly()) {\n";
2167 $code .= " setDOMException(NoModificationAllowedError, args.G etIsolate());\n"; 2274 $code .= " setDOMException(NoModificationAllowedError, args.G etIsolate());\n";
2168 $code .= " return;\n"; 2275 $code .= " return;\n";
2169 $code .= " }\n"; 2276 $code .= " }\n";
2170 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfac eName); 2277 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfac eName);
2171 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n"; 2278 $code .= " $svgWrappedNativeType& impInstance = wrapper->property Reference();\n";
2172 $code .= " $svgWrappedNativeType* imp = &impInstance;\n"; 2279 $code .= " $svgWrappedNativeType* imp = &impInstance;\n";
2173 } 2280 }
2174 } elsif (!$function->isStatic) { 2281 } elsif (!$function->isStatic) {
2282 ### main
2175 $code .= <<END; 2283 $code .= <<END;
2176 ${implClassName}* imp = ${v8ClassName}::toNative(args.Holder()); 2284 ${implClassName}* imp = ${v8ClassName}::toNative(args.Holder());
2177 END 2285 END
2178 } 2286 }
2179 2287
2288 ### TODO
2180 $code .= GenerateCustomElementInvocationScopeIfNeeded($funcExt); 2289 $code .= GenerateCustomElementInvocationScopeIfNeeded($funcExt);
2181 2290
2182 # Check domain security if needed 2291 # Check domain security if needed
2292 ### TODO
2183 if ($interface->extendedAttributes->{"CheckSecurity"} && !$function->extende dAttributes->{"DoNotCheckSecurity"}) { 2293 if ($interface->extendedAttributes->{"CheckSecurity"} && !$function->extende dAttributes->{"DoNotCheckSecurity"}) {
2184 # We have not find real use cases yet. 2294 # We have not find real use cases yet.
2185 AddToImplIncludes("core/page/Frame.h"); 2295 AddToImplIncludes("core/page/Frame.h");
2186 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 2296 AddToImplIncludes("bindings/v8/BindingSecurity.h");
2187 $code .= <<END; 2297 $code .= <<END;
2188 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame())) 2298 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame()))
2189 return; 2299 return;
2190 END 2300 END
2191 } 2301 }
2192 2302
2303 ### DONE
2193 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"}; 2304 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"};
2194 if (!$raisesExceptions) { 2305 if (!$raisesExceptions) {
2195 foreach my $parameter (@{$function->parameters}) { 2306 foreach my $parameter (@{$function->parameters}) {
2196 if ($parameter->extendedAttributes->{"IsIndex"}) { 2307 if ($parameter->extendedAttributes->{"IsIndex"}) {
2197 $raisesExceptions = 1; 2308 $raisesExceptions = 1;
2198 } 2309 }
2199 } 2310 }
2200 } 2311 }
2201 2312
2313 ### DONE
2202 if ($raisesExceptions) { 2314 if ($raisesExceptions) {
2203 AddToImplIncludes("bindings/v8/ExceptionState.h"); 2315 AddToImplIncludes("bindings/v8/ExceptionState.h");
2204 $code .= " ExceptionState es(args.GetIsolate());\n"; 2316 $code .= " ExceptionState es(args.GetIsolate());\n";
2205 } 2317 }
2206 2318
2319 ### TODO
2207 if ($function->extendedAttributes->{"CheckSecurityForNode"}) { 2320 if ($function->extendedAttributes->{"CheckSecurityForNode"}) {
2208 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 2321 AddToImplIncludes("bindings/v8/BindingSecurity.h");
2209 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($function) . "(es))) {\n"; 2322 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($function) . "(es))) {\n";
2210 $code .= " v8SetReturnValueNull(args);\n"; 2323 $code .= " v8SetReturnValueNull(args);\n";
2211 $code .= " return;\n"; 2324 $code .= " return;\n";
2212 $code .= " }\n"; 2325 $code .= " }\n";
2213 END 2326 END
2214 } 2327 }
2215 2328
2329 ### main DONE
2330 print " [GenerateParametersCheck]\n";
2216 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, $forMainWorldSuffix); 2331 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, $forMainWorldSuffix);
2217 $code .= $parameterCheckString; 2332 $code .= $parameterCheckString;
2218 2333
2219 # Build the function call string. 2334 # Build the function call string.
2335 ### TODO
2336 ### main
2337 if($paramIndex != @{$function->parameters}) {
2338 ## Never
2339 }
2220 $code .= GenerateFunctionCallString($function, $paramIndex, " ", $interfa ce, $forMainWorldSuffix, %replacements); 2340 $code .= GenerateFunctionCallString($function, $paramIndex, " ", $interfa ce, $forMainWorldSuffix, %replacements);
2221 $code .= "}\n\n"; 2341 $code .= "}\n\n";
2222 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; 2342 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString;
2223 $implementation{nameSpaceInternal}->add($code); 2343 $implementation{nameSpaceInternal}->add($code);
2224 } 2344 }
2225 2345
2346 ### get_call_with_parameter and call_with_statements macro in python
2347 ### DONE
2226 sub GenerateCallWith 2348 sub GenerateCallWith
2227 { 2349 {
2228 my $callWith = shift; 2350 my $callWith = shift;
2229 return ([], "") unless $callWith; 2351 return ([], "") unless $callWith;
2230 my $indent = shift; 2352 my $indent = shift;
2231 my $returnVoid = shift; 2353 my $returnVoid = shift;
2232 my $function = shift; 2354 my $function = shift;
2233 my $code = ""; 2355 my $code = "";
2234 2356
2235 my @callWithArgs; 2357 my @callWithArgs;
(...skipping 16 matching lines...) Expand all
2252 } 2374 }
2253 if (ExtendedAttributeContains($callWith, "ActiveWindow")) { 2375 if (ExtendedAttributeContains($callWith, "ActiveWindow")) {
2254 push(@callWithArgs, "activeDOMWindow()"); 2376 push(@callWithArgs, "activeDOMWindow()");
2255 } 2377 }
2256 if (ExtendedAttributeContains($callWith, "FirstWindow")) { 2378 if (ExtendedAttributeContains($callWith, "FirstWindow")) {
2257 push(@callWithArgs, "firstDOMWindow()"); 2379 push(@callWithArgs, "firstDOMWindow()");
2258 } 2380 }
2259 return ([@callWithArgs], $code); 2381 return ([@callWithArgs], $code);
2260 } 2382 }
2261 2383
2384 ### no corresponds function in python generator. write in template.
2262 sub GenerateArgumentsCountCheck 2385 sub GenerateArgumentsCountCheck
2263 { 2386 {
2264 my $function = shift; 2387 my $function = shift;
2265 my $interface = shift; 2388 my $interface = shift;
2266 2389
2267 my $numMandatoryParams = 0; 2390 my $numMandatoryParams = 0;
2268 my $allowNonOptional = 1; 2391 my $allowNonOptional = 1;
2269 foreach my $param (@{$function->parameters}) { 2392 foreach my $param (@{$function->parameters}) {
2270 if ($param->isOptional or $param->isVariadic) { 2393 if ($param->isOptional or $param->isVariadic) {
2271 $allowNonOptional = 0; 2394 $allowNonOptional = 0;
2272 } else { 2395 } else {
2273 die "An argument must not be declared to be optional unless all subs equent arguments to the operation are also optional." if !$allowNonOptional; 2396 die "An argument must not be declared to be optional unless all subs equent arguments to the operation are also optional." if !$allowNonOptional;
2274 $numMandatoryParams++; 2397 $numMandatoryParams++;
2275 } 2398 }
2276 } 2399 }
2277 2400
2278 my $argumentsCountCheckString = ""; 2401 my $argumentsCountCheckString = "";
2279 if ($numMandatoryParams >= 1) { 2402 if ($numMandatoryParams >= 1) {
2280 $argumentsCountCheckString .= " if (args.Length() < $numMandatoryPara ms) {\n"; 2403 $argumentsCountCheckString .= " if (args.Length() < $numMandatoryPara ms) {\n";
2281 $argumentsCountCheckString .= " throwNotEnoughArgumentsError(args .GetIsolate());\n"; 2404 $argumentsCountCheckString .= " throwNotEnoughArgumentsError(args .GetIsolate());\n";
2282 $argumentsCountCheckString .= " return;\n"; 2405 $argumentsCountCheckString .= " return;\n";
2283 $argumentsCountCheckString .= " }\n"; 2406 $argumentsCountCheckString .= " }\n";
2284 } 2407 }
2285 return $argumentsCountCheckString; 2408 return $argumentsCountCheckString;
2286 } 2409 }
2287 2410
2411 ### see macro.template
2288 sub GenerateParametersCheck 2412 sub GenerateParametersCheck
2289 { 2413 {
2290 my $function = shift; 2414 my $function = shift;
2291 my $interface = shift; 2415 my $interface = shift;
2292 my $forMainWorldSuffix = shift; 2416 my $forMainWorldSuffix = shift;
2293 my $style = shift || "new"; 2417 my $style = shift || "new";
2294 2418
2295 my $parameterCheckString = ""; 2419 my $parameterCheckString = "";
2296 my $paramIndex = 0; 2420 my $paramIndex = 0;
2297 my %replacements = (); 2421 my %replacements = ();
2298 2422
2299 foreach my $parameter (@{$function->parameters}) { 2423 foreach my $parameter (@{$function->parameters}) {
2300 my $nativeType = GetNativeType($parameter->type, $parameter->extendedAtt ributes, "parameter"); 2424 my $nativeType = GetNativeType($parameter->type, $parameter->extendedAtt ributes, "parameter");
2301 2425
2302 # Optional arguments without [Default=...] should generate an early call with fewer arguments. 2426 # Optional arguments without [Default=...] should generate an early call with fewer arguments.
2303 # Optional arguments with [Optional=...] should not generate the early c all. 2427 # Optional arguments with [Optional=...] should not generate the early c all.
2304 # Optional Dictionary arguments always considered to have default of emp ty dictionary. 2428 # Optional Dictionary arguments always considered to have default of emp ty dictionary.
2429 ### DONE early_call in python
2305 if ($parameter->isOptional && !$parameter->extendedAttributes->{"Default "} && $nativeType ne "Dictionary" && !IsCallbackInterface($parameter->type)) { 2430 if ($parameter->isOptional && !$parameter->extendedAttributes->{"Default "} && $nativeType ne "Dictionary" && !IsCallbackInterface($parameter->type)) {
2306 $parameterCheckString .= " if (args.Length() <= $paramIndex)"; 2431 $parameterCheckString .= " if (args.Length() <= $paramIndex)";
2307 my $functionCall = GenerateFunctionCallString($function, $paramIndex , " " x 2, $interface, $forMainWorldSuffix, %replacements); 2432 my $functionCall = GenerateFunctionCallString($function, $paramIndex , " " x 2, $interface, $forMainWorldSuffix, %replacements);
2308 my $multiLine = ($functionCall =~ tr/\n//) > 1; 2433 my $multiLine = ($functionCall =~ tr/\n//) > 1; # always true
2309 $parameterCheckString .= $multiLine ? " {\n" : "\n"; 2434 $parameterCheckString .= $multiLine ? " {\n" : "\n";
2310 $parameterCheckString .= $functionCall; 2435 $parameterCheckString .= $functionCall;
2311 $parameterCheckString .= $multiLine ? " }\n" : "\n"; 2436 $parameterCheckString .= $multiLine ? " }\n" : "\n";
2312 } 2437 }
2313 2438
2314 my $parameterName = $parameter->name; 2439 my $parameterName = $parameter->name;
2315 AddToImplIncludes("bindings/v8/ExceptionState.h"); 2440 AddToImplIncludes("bindings/v8/ExceptionState.h");
2316 if (IsCallbackInterface($parameter->type)) { 2441 if (IsCallbackInterface($parameter->type)) {
2317 my $v8ClassName = "V8" . $parameter->type; 2442 my $v8ClassName = "V8" . $parameter->type;
2318 AddToImplIncludes("$v8ClassName.h"); 2443 AddToImplIncludes("$v8ClassName.h");
2319 if ($parameter->isOptional) { 2444 if ($parameter->isOptional) {
2445 ### DONE
2320 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName;\n"; 2446 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName;\n";
2321 $parameterCheckString .= " if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n"; 2447 $parameterCheckString .= " if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n";
2322 $parameterCheckString .= " if (!args[$paramIndex]->IsFunc tion()) {\n"; 2448 $parameterCheckString .= " if (!args[$paramIndex]->IsFunc tion()) {\n";
2323 $parameterCheckString .= " throwTypeError(args.GetIso late());\n"; 2449 $parameterCheckString .= " throwTypeError(args.GetIso late());\n";
2324 $parameterCheckString .= " return;\n"; 2450 $parameterCheckString .= " return;\n";
2325 $parameterCheckString .= " }\n"; 2451 $parameterCheckString .= " }\n";
2326 $parameterCheckString .= " $parameterName = ${v8ClassName }::create(args[$paramIndex], getScriptExecutionContext());\n"; 2452 $parameterCheckString .= " $parameterName = ${v8ClassName }::create(args[$paramIndex], getScriptExecutionContext());\n";
2327 $parameterCheckString .= " }\n"; 2453 $parameterCheckString .= " }\n";
2328 } else { 2454 } else {
2455 ### was DONE ?
2329 $parameterCheckString .= " if (args.Length() <= $paramIndex | | "; 2456 $parameterCheckString .= " if (args.Length() <= $paramIndex | | ";
2330 if ($parameter->isNullable) { 2457 if ($parameter->isNullable) {
2331 $parameterCheckString .= "!(args[$paramIndex]->IsFunction() || args[$paramIndex]->IsNull())"; 2458 $parameterCheckString .= "!(args[$paramIndex]->IsFunction() || args[$paramIndex]->IsNull())";
2332 } else { 2459 } else {
2333 $parameterCheckString .= "!args[$paramIndex]->IsFunction()"; 2460 $parameterCheckString .= "!args[$paramIndex]->IsFunction()";
2334 } 2461 }
2335 $parameterCheckString .= ") {\n"; 2462 $parameterCheckString .= ") {\n";
2336 $parameterCheckString .= " throwTypeError(args.GetIsolate ());\n"; 2463 $parameterCheckString .= " throwTypeError(args.GetIsolate ());\n";
2337 $parameterCheckString .= " return;\n"; 2464 $parameterCheckString .= " return;\n";
2338 $parameterCheckString .= " }\n"; 2465 $parameterCheckString .= " }\n";
2339 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName = "; 2466 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName = ";
2340 $parameterCheckString .= "args[$paramIndex]->IsNull() ? 0 : " if $parameter->isNullable; 2467 $parameterCheckString .= "args[$paramIndex]->IsNull() ? 0 : " if $parameter->isNullable;
2341 $parameterCheckString .= "${v8ClassName}::create(args[$paramInde x], getScriptExecutionContext());\n"; 2468 $parameterCheckString .= "${v8ClassName}::create(args[$paramInde x], getScriptExecutionContext());\n";
2342 } 2469 }
2343 } elsif ($parameter->extendedAttributes->{"Clamp"}) { 2470 } elsif ($parameter->extendedAttributes->{"Clamp"}) {
2471 ### DONE
2344 my $nativeValue = "${parameterName}NativeValue"; 2472 my $nativeValue = "${parameterName}NativeValue";
2345 my $paramType = $parameter->type; 2473 my $paramType = $parameter->type;
2346 $parameterCheckString .= " $paramType $parameterName = 0;\n"; 2474 $parameterCheckString .= " $paramType $parameterName = 0;\n";
2347 $parameterCheckString .= " V8TRYCATCH_VOID(double, $nativeVal ue, args[$paramIndex]->NumberValue());\n"; 2475 $parameterCheckString .= " V8TRYCATCH_VOID(double, $nativeVal ue, args[$paramIndex]->NumberValue());\n";
2348 $parameterCheckString .= " if (!std::isnan($nativeValue))\n"; 2476 $parameterCheckString .= " if (!std::isnan($nativeValue))\n";
2349 $parameterCheckString .= " $parameterName = clampTo<$para mType>($nativeValue);\n"; 2477 $parameterCheckString .= " $parameterName = clampTo<$para mType>($nativeValue);\n";
2350 } elsif ($parameter->type eq "SerializedScriptValue") { 2478 } elsif ($parameter->type eq "SerializedScriptValue") {
2479 ### DONE
2351 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); 2480 AddToImplIncludes("bindings/v8/SerializedScriptValue.h");
2352 $parameterCheckString .= " bool ${parameterName}DidThrow = false; \n"; 2481 $parameterCheckString .= " bool ${parameterName}DidThrow = false; \n";
2353 $parameterCheckString .= " $nativeType $parameterName = Serialize dScriptValue::create(args[$paramIndex], 0, 0, ${parameterName}DidThrow, args.Get Isolate());\n"; 2482 $parameterCheckString .= " $nativeType $parameterName = Serialize dScriptValue::create(args[$paramIndex], 0, 0, ${parameterName}DidThrow, args.Get Isolate());\n";
2354 $parameterCheckString .= " if (${parameterName}DidThrow)\n"; 2483 $parameterCheckString .= " if (${parameterName}DidThrow)\n";
2355 $parameterCheckString .= " return;\n"; 2484 $parameterCheckString .= " return;\n";
2356 } elsif ($parameter->isVariadic) { 2485 } elsif ($parameter->isVariadic) {
2486 ### DONE
2357 my $nativeElementType = GetNativeType($parameter->type); 2487 my $nativeElementType = GetNativeType($parameter->type);
2358 if ($nativeElementType =~ />$/) { 2488 if ($nativeElementType =~ />$/) {
2359 $nativeElementType .= " "; 2489 $nativeElementType .= " "; # TODO
2360 } 2490 }
2361 2491
2362 my $argType = $parameter->type; 2492 my $argType = $parameter->type;
2363 if (IsWrapperType($argType)) { 2493 if (IsWrapperType($argType)) {
2364 $parameterCheckString .= " Vector<$nativeElementType> $parame terName;\n"; 2494 $parameterCheckString .= " Vector<$nativeElementType> $parame terName;\n";
2365 $parameterCheckString .= " for (int i = $paramIndex; i < args .Length(); ++i) {\n"; 2495 $parameterCheckString .= " for (int i = $paramIndex; i < args .Length(); ++i) {\n";
2366 $parameterCheckString .= " if (!V8${argType}::HasInstance (args[i], args.GetIsolate(), worldType(args.GetIsolate()))) {\n"; 2496 $parameterCheckString .= " if (!V8${argType}::HasInstance (args[i], args.GetIsolate(), worldType(args.GetIsolate()))) {\n";
2367 $parameterCheckString .= " throwTypeError(args.GetIso late());\n"; 2497 $parameterCheckString .= " throwTypeError(args.GetIso late());\n";
2368 $parameterCheckString .= " return;\n"; 2498 $parameterCheckString .= " return;\n";
2369 $parameterCheckString .= " }\n"; 2499 $parameterCheckString .= " }\n";
2370 $parameterCheckString .= " $parameterName.append(V8${argT ype}::toNative(v8::Handle<v8::Object>::Cast(args[i])));\n"; 2500 $parameterCheckString .= " $parameterName.append(V8${argT ype}::toNative(v8::Handle<v8::Object>::Cast(args[i])));\n";
2371 $parameterCheckString .= " }\n"; 2501 $parameterCheckString .= " }\n";
2372 } else { 2502 } else {
2373 $parameterCheckString .= " V8TRYCATCH_VOID(Vector<$nativeElem entType>, $parameterName, toNativeArguments<$nativeElementType>(args, $paramInde x));\n"; 2503 $parameterCheckString .= " V8TRYCATCH_VOID(Vector<$nativeElem entType>, $parameterName, toNativeArguments<$nativeElementType>(args, $paramInde x));\n";
2374 } 2504 }
2375 } elsif ($nativeType =~ /^V8StringResource/) { 2505 } elsif ($nativeType =~ /^V8StringResource/) {
2506 ### DONE
2376 my $default = defined $parameter->extendedAttributes->{"Default"} ? $parameter->extendedAttributes->{"Default"} : ""; 2507 my $default = defined $parameter->extendedAttributes->{"Default"} ? $parameter->extendedAttributes->{"Default"} : "";
2377 my $jsValue = $parameter->isOptional && $default eq "NullString" ? " argumentOrNull(args, $paramIndex)" : "args[$paramIndex]"; 2508 my $jsValue = $parameter->isOptional && $default eq "NullString" ? " argumentOrNull(args, $paramIndex)" : "args[$paramIndex]";
2378 $parameterCheckString .= JSValueToNativeStatement($parameter->type, $parameter->extendedAttributes, $jsValue, $parameterName, " ", "args.GetIsola te()"); 2509 $parameterCheckString .= JSValueToNativeStatement($parameter->type, $parameter->extendedAttributes, $jsValue, $parameterName, " ", "args.GetIsola te()");
2379 if (IsEnumType($parameter->type)) { 2510 if (IsEnumType($parameter->type)) {
2380 my @enumValues = ValidEnumValues($parameter->type); 2511 my @enumValues = ValidEnumValues($parameter->type);
2381 my @validEqualities = (); 2512 my @validEqualities = ();
2382 foreach my $enumValue (@enumValues) { 2513 foreach my $enumValue (@enumValues) {
2383 push(@validEqualities, "string == \"$enumValue\""); 2514 push(@validEqualities, "string == \"$enumValue\"");
2384 } 2515 }
2385 my $enumValidationExpression = join(" || ", @validEqualities); 2516 my $enumValidationExpression = join(" || ", @validEqualities);
(...skipping 24 matching lines...) Expand all
2410 my $jsValue = $parameter->isOptional && $default eq "NullString" ? " argumentOrNull(args, $paramIndex)" : "args[$paramIndex]"; 2541 my $jsValue = $parameter->isOptional && $default eq "NullString" ? " argumentOrNull(args, $paramIndex)" : "args[$paramIndex]";
2411 $parameterCheckString .= JSValueToNativeStatement($parameter->type, $parameter->extendedAttributes, $jsValue, $parameterName, " ", "args.GetIsola te()"); 2542 $parameterCheckString .= JSValueToNativeStatement($parameter->type, $parameter->extendedAttributes, $jsValue, $parameterName, " ", "args.GetIsola te()");
2412 if ($nativeType eq 'Dictionary') { 2543 if ($nativeType eq 'Dictionary') {
2413 $parameterCheckString .= " if (!$parameterName.isUndefinedOrN ull() && !$parameterName.isObject()) {\n"; 2544 $parameterCheckString .= " if (!$parameterName.isUndefinedOrN ull() && !$parameterName.isObject()) {\n";
2414 $parameterCheckString .= " throwTypeError(\"Not an object .\", args.GetIsolate());\n"; 2545 $parameterCheckString .= " throwTypeError(\"Not an object .\", args.GetIsolate());\n";
2415 $parameterCheckString .= " return;\n"; 2546 $parameterCheckString .= " return;\n";
2416 $parameterCheckString .= " }\n"; 2547 $parameterCheckString .= " }\n";
2417 } 2548 }
2418 } 2549 }
2419 2550
2551 ### DONE
2420 if ($parameter->extendedAttributes->{"IsIndex"}) { 2552 if ($parameter->extendedAttributes->{"IsIndex"}) {
2421 AddToImplIncludes("core/dom/ExceptionCode.h"); 2553 AddToImplIncludes("core/dom/ExceptionCode.h");
2422 $parameterCheckString .= " if (UNLIKELY($parameterName < 0)) {\n" ; 2554 $parameterCheckString .= " if (UNLIKELY($parameterName < 0)) {\n" ;
2423 $parameterCheckString .= " setDOMException(IndexSizeError, ar gs.GetIsolate());\n"; 2555 $parameterCheckString .= " setDOMException(IndexSizeError, ar gs.GetIsolate());\n";
2424 $parameterCheckString .= " return;\n"; 2556 $parameterCheckString .= " return;\n";
2425 $parameterCheckString .= " }\n"; 2557 $parameterCheckString .= " }\n";
2426 } 2558 }
2427 2559
2428 $paramIndex++; 2560 $paramIndex++;
2429 } 2561 }
2562 print "PARAM STRING\n", $parameterCheckString, "\n" if $interface->name eq " CanvasGradient";
2563 # $paramIndex == len(parameters)
2430 return ($parameterCheckString, $paramIndex, %replacements); 2564 return ($parameterCheckString, $paramIndex, %replacements);
2431 } 2565 }
2432 2566
2433 sub GenerateOverloadedConstructorCallback 2567 sub GenerateOverloadedConstructorCallback
2434 { 2568 {
2435 my $interface = shift; 2569 my $interface = shift;
2436 my $implClassName = GetImplName($interface); 2570 my $implClassName = GetImplName($interface);
2437 2571
2438 my $code = ""; 2572 my $code = "";
2439 $code .= <<END; 2573 $code .= <<END;
(...skipping 17 matching lines...) Expand all
2457 $code .= " }\n"; 2591 $code .= " }\n";
2458 } 2592 }
2459 $code .= <<END; 2593 $code .= <<END;
2460 throwTypeError(args.GetIsolate()); 2594 throwTypeError(args.GetIsolate());
2461 return; 2595 return;
2462 END 2596 END
2463 $code .= "}\n\n"; 2597 $code .= "}\n\n";
2464 $implementation{nameSpaceInternal}->add($code); 2598 $implementation{nameSpaceInternal}->add($code);
2465 } 2599 }
2466 2600
2601 ### get_single_constructor_callback_parameter in python code generator
2602 ### DONE
2467 sub GenerateSingleConstructorCallback 2603 sub GenerateSingleConstructorCallback
2468 { 2604 {
2469 my $interface = shift; 2605 my $interface = shift;
2470 my $function = shift; 2606 my $function = shift;
2471 2607
2472 my $implClassName = GetImplName($interface); 2608 my $implClassName = GetImplName($interface);
2473 my $v8ClassName = GetV8ClassName($interface); 2609 my $v8ClassName = GetV8ClassName($interface);
2474 my $overloadedIndexString = ""; 2610 my $overloadedIndexString = "";
2475 if ($function->overloadedIndex > 0) { 2611 if ($function->overloadedIndex > 0) {
2476 $overloadedIndexString .= $function->overloadedIndex; 2612 $overloadedIndexString .= $function->overloadedIndex;
2477 } 2613 }
2478 2614
2479 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"}; 2615 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"}; # ## never be true!
2480 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 2616 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2481 $raisesExceptions = 1; 2617 $raisesExceptions = 1; ### exist
2482 } 2618 }
2483 if (!$raisesExceptions) { 2619 if (!$raisesExceptions) {
2484 foreach my $parameter (@{$function->parameters}) { 2620 foreach my $parameter (@{$function->parameters}) {
2485 if ($parameter->extendedAttributes->{"IsIndex"}) { 2621 if ($parameter->extendedAttributes->{"IsIndex"}) {
2486 $raisesExceptions = 1; 2622 $raisesExceptions = 1;
2623 # Never executed!
2487 } 2624 }
2488 } 2625 }
2489 } 2626 }
2490 2627
2491 my @beforeArgumentList; 2628 my @beforeArgumentList;
2492 my @afterArgumentList; 2629 my @afterArgumentList;
2493 my $code = ""; 2630 my $code = "";
2494 $code .= <<END; 2631 $code .= <<END;
2495 static void constructor${overloadedIndexString}(const v8::FunctionCallbackInfo<v 8::Value>& args) 2632 static void constructor${overloadedIndexString}(const v8::FunctionCallbackInfo<v 8::Value>& args)
2496 { 2633 {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2574 $leastConstructorLength = 255; 2711 $leastConstructorLength = 255;
2575 foreach my $constructor (@constructors, @customConstructors) { 2712 foreach my $constructor (@constructors, @customConstructors) {
2576 my $constructorLength = GetFunctionLength($constructor); 2713 my $constructorLength = GetFunctionLength($constructor);
2577 $leastConstructorLength = $constructorLength if ($constructorLength < $leastConstructorLength); 2714 $leastConstructorLength = $constructorLength if ($constructorLength < $leastConstructorLength);
2578 } 2715 }
2579 } 2716 }
2580 2717
2581 return $leastConstructorLength; 2718 return $leastConstructorLength;
2582 } 2719 }
2583 2720
2721 ### DONE
2584 sub GenerateConstructorCallback 2722 sub GenerateConstructorCallback
2585 { 2723 {
2586 my $interface = shift; 2724 my $interface = shift;
2587 2725
2588 my $implClassName = GetImplName($interface); 2726 my $implClassName = GetImplName($interface);
2589 my $v8ClassName = GetV8ClassName($interface); 2727 my $v8ClassName = GetV8ClassName($interface);
2590 my $code = ""; 2728 my $code = "";
2591 $code .= "void ${v8ClassName}::constructorCallback(const v8::FunctionCallbac kInfo<v8::Value>& args)\n"; 2729 $code .= "void ${v8ClassName}::constructorCallback(const v8::FunctionCallbac kInfo<v8::Value>& args)\n";
2592 $code .= "{\n"; 2730 $code .= "{\n";
2593 $code .= " TRACE_EVENT_SCOPED_SAMPLING_STATE(\"Blink\", \"DOMConstructor\ ");\n"; 2731 $code .= " TRACE_EVENT_SCOPED_SAMPLING_STATE(\"Blink\", \"DOMConstructor\ ");\n";
2732 ### DONE
2594 $code .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur eAs"}); 2733 $code .= GenerateFeatureObservation($interface->extendedAttributes->{"Measur eAs"});
2734 ### DONE
2595 $code .= GenerateDeprecationNotification($interface->extendedAttributes->{"D eprecateAs"}); 2735 $code .= GenerateDeprecationNotification($interface->extendedAttributes->{"D eprecateAs"});
2736 ### DONE
2596 $code .= GenerateConstructorHeader(); 2737 $code .= GenerateConstructorHeader();
2597 if (HasCustomConstructor($interface)) { 2738 if (HasCustomConstructor($interface)) {
2598 $code .= " ${v8ClassName}::constructorCustom(args);\n"; 2739 $code .= " ${v8ClassName}::constructorCustom(args);\n";
2599 } else { 2740 } else {
2600 $code .= " ${implClassName}V8Internal::constructor(args);\n"; 2741 $code .= " ${implClassName}V8Internal::constructor(args);\n";
2601 } 2742 }
2602 $code .= "}\n\n"; 2743 $code .= "}\n\n";
2603 $implementation{nameSpaceWebCore}->add($code); 2744 $implementation{nameSpaceWebCore}->add($code);
2604 } 2745 }
2605 2746
2606 sub GenerateConstructor 2747 sub GenerateConstructor
2607 { 2748 {
2608 my $interface = shift; 2749 my $interface = shift;
2609 2750
2610 if (@{$interface->constructors} == 1) { 2751 if (@{$interface->constructors} == 1) {
2752 ### DONE
2611 GenerateSingleConstructorCallback($interface, @{$interface->constructors }[0]); 2753 GenerateSingleConstructorCallback($interface, @{$interface->constructors }[0]);
2612 } else { 2754 } else {
2755 ### TODO
2613 foreach my $constructor (@{$interface->constructors}) { 2756 foreach my $constructor (@{$interface->constructors}) {
2614 GenerateSingleConstructorCallback($interface, $constructor); 2757 GenerateSingleConstructorCallback($interface, $constructor);
2615 } 2758 }
2616 GenerateOverloadedConstructorCallback($interface); 2759 GenerateOverloadedConstructorCallback($interface);
2617 } 2760 }
2618 } 2761 }
2619 2762
2620 sub GenerateEventConstructor 2763 sub GenerateEventConstructor
2621 { 2764 {
2622 my $interface = shift; 2765 my $interface = shift;
2623 my $implClassName = GetImplName($interface); 2766 my $implClassName = GetImplName($interface);
2624 my $v8ClassName = GetV8ClassName($interface); 2767 my $v8ClassName = GetV8ClassName($interface);
2625 2768
2769 ### TODO MERGE
2626 my @anyAttributeNames; 2770 my @anyAttributeNames;
2627 my @serializableAnyAttributeNames; 2771 my @serializableAnyAttributeNames;
2628 foreach my $attribute (@{$interface->attributes}) { 2772 foreach my $attribute (@{$interface->attributes}) {
2629 if ($attribute->type eq "any") { 2773 if ($attribute->type eq "any") {
2630 push(@anyAttributeNames, $attribute->name); 2774 push(@anyAttributeNames, $attribute->name);
2631 if (!$attribute->extendedAttributes->{"Unserializable"}) { 2775 if (!$attribute->extendedAttributes->{"Unserializable"}) {
2632 push(@serializableAnyAttributeNames, $attribute->name); 2776 push(@serializableAnyAttributeNames, $attribute->name);
2633 } 2777 }
2634 } 2778 }
2635 } 2779 }
2636 2780
2637 AddToImplIncludes("bindings/v8/Dictionary.h"); 2781 AddToImplIncludes("bindings/v8/Dictionary.h");
2782 ### DONE
2638 $implementation{nameSpaceInternal}->add(<<END); 2783 $implementation{nameSpaceInternal}->add(<<END);
2639 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& args) 2784 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& args)
2640 { 2785 {
2641 if (args.Length() < 1) { 2786 if (args.Length() < 1) {
2642 throwNotEnoughArgumentsError(args.GetIsolate()); 2787 throwNotEnoughArgumentsError(args.GetIsolate());
2643 return; 2788 return;
2644 } 2789 }
2645 2790
2646 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, args[0]); 2791 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, args[0]);
2647 END 2792 END
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2688 $implementation{nameSpaceInternal}->add(" }\n\n"); 2833 $implementation{nameSpaceInternal}->add(" }\n\n");
2689 } 2834 }
2690 2835
2691 $implementation{nameSpaceInternal}->add(<<END); 2836 $implementation{nameSpaceInternal}->add(<<END);
2692 v8::Handle<v8::Object> wrapper = args.Holder(); 2837 v8::Handle<v8::Object> wrapper = args.Holder();
2693 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(event.release(), &$ {v8ClassName}::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent ); 2838 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(event.release(), &$ {v8ClassName}::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent );
2694 v8SetReturnValue(args, wrapper); 2839 v8SetReturnValue(args, wrapper);
2695 } 2840 }
2696 END 2841 END
2697 2842
2843 ### DONE
2698 my $code = ""; 2844 my $code = "";
2699 $code .= <<END; 2845 $code .= <<END;
2700 bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary& options) 2846 bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary& options)
2701 { 2847 {
2702 END 2848 END
2703 2849
2704 if ($interface->parent) { 2850 if ($interface->parent) {
2705 my $interfaceBase = $interface->parent; 2851 my $interfaceBase = $interface->parent;
2706 $code .= <<END; 2852 $code .= <<END;
2707 if (!fill${interfaceBase}Init(eventInit, options)) 2853 if (!fill${interfaceBase}Init(eventInit, options))
2708 return false; 2854 return false;
2709 2855
2710 END 2856 END
2711 } 2857 }
2712 2858
2859 ### TODO
2713 foreach my $attribute (@{$interface->attributes}) { 2860 foreach my $attribute (@{$interface->attributes}) {
2714 if ($attribute->extendedAttributes->{"InitializedByEventConstructor"}) { 2861 if ($attribute->extendedAttributes->{"InitializedByEventConstructor"}) {
2715 if ($attribute->type ne "any") { 2862 if ($attribute->type ne "any") {
2716 my $attributeName = $attribute->name; 2863 my $attributeName = $attribute->name;
2717 my $attributeImplName = GetImplName($attribute); 2864 my $attributeImplName = GetImplName($attribute);
2718 my $deprecation = $attribute->extendedAttributes->{"DeprecateAs" }; 2865 my $deprecation = $attribute->extendedAttributes->{"DeprecateAs" };
2719 my $dictionaryGetter = "options.get(\"$attributeName\", eventIni t.$attributeImplName)"; 2866 my $dictionaryGetter = "options.get(\"$attributeName\", eventIni t.$attributeImplName)";
2720 if ($attribute->extendedAttributes->{"DeprecateAs"}) { 2867 if ($attribute->extendedAttributes->{"DeprecateAs"}) {
2721 $code .= " if ($dictionaryGetter)\n"; 2868 $code .= " if ($dictionaryGetter)\n";
2722 $code .= " " . GenerateDeprecationNotification($attribute ->extendedAttributes->{"DeprecateAs"}); 2869 $code .= " " . GenerateDeprecationNotification($attribute ->extendedAttributes->{"DeprecateAs"});
2723 } else { 2870 } else {
2724 $code .= " $dictionaryGetter;\n"; 2871 $code .= " $dictionaryGetter;\n";
2725 } 2872 }
2726 } 2873 }
2727 } 2874 }
2728 } 2875 }
2729 2876
2730 $code .= <<END; 2877 $code .= <<END;
2731 return true; 2878 return true;
2732 } 2879 }
2733 2880
2734 END 2881 END
2735 $implementation{nameSpaceWebCore}->add($code); 2882 $implementation{nameSpaceWebCore}->add($code);
2736 } 2883 }
2737 2884
2885 ### DONE
2738 sub GenerateNamedConstructor 2886 sub GenerateNamedConstructor
2739 { 2887 {
2740 my $function = shift; 2888 my $function = shift;
2741 my $interface = shift; 2889 my $interface = shift;
2742 2890
2743 my $implClassName = GetImplName($interface); 2891 my $implClassName = GetImplName($interface);
2744 my $v8ClassName = GetV8ClassName($interface); 2892 my $v8ClassName = GetV8ClassName($interface);
2893 # thif is always false here
2745 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"}; 2894 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"};
2895 # print "NEVER\n" if $raisesExceptions;
2746 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 2896 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2747 $raisesExceptions = 1; 2897 $raisesExceptions = 1;
2748 } 2898 }
2749 if (!$raisesExceptions) { 2899 if (!$raisesExceptions) {
2750 foreach my $parameter (@{$function->parameters}) { 2900 foreach my $parameter (@{$function->parameters}) {
2751 if ($parameter->extendedAttributes->{"IsIndex"}) { 2901 if ($parameter->extendedAttributes->{"IsIndex"}) {
2902 # NEVER!
2903 # print "NEVER\n";
2752 $raisesExceptions = 1; 2904 $raisesExceptions = 1;
2753 } 2905 }
2754 } 2906 }
2755 } 2907 }
2756 2908
2757 my $maybeObserveFeature = GenerateFeatureObservation($function->extendedAttr ibutes->{"MeasureAs"}); 2909 my $maybeObserveFeature = GenerateFeatureObservation($function->extendedAttr ibutes->{"MeasureAs"});
2758 my $maybeDeprecateFeature = GenerateDeprecationNotification($function->exten dedAttributes->{"DeprecateAs"}); 2910 my $maybeDeprecateFeature = GenerateDeprecationNotification($function->exten dedAttributes->{"DeprecateAs"});
2759 2911
2760 my @beforeArgumentList; 2912 my @beforeArgumentList;
2761 my @afterArgumentList; 2913 my @afterArgumentList;
2762 2914
2763 my $toActiveDOMObject = "0"; 2915 my $toActiveDOMObject = "0";
2764 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { 2916 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) {
2765 $toActiveDOMObject = "${v8ClassName}::toActiveDOMObject"; 2917 $toActiveDOMObject = "${v8ClassName}::toActiveDOMObject";
2766 } 2918 }
2767 2919
2768 my $toEventTarget = "0"; 2920 my $toEventTarget = "0";
2769 if (InheritsInterface($interface, "EventTarget")) { 2921 if (InheritsInterface($interface, "EventTarget")) {
2770 $toEventTarget = "${v8ClassName}::toEventTarget"; 2922 $toEventTarget = "${v8ClassName}::toEventTarget";
2771 } 2923 }
2924 # print "GEHEHE", $interface->name, "\n";
2772 2925
2773 AddToImplIncludes("core/page/Frame.h"); 2926 AddToImplIncludes("core/page/Frame.h");
2774 $implementation{nameSpaceWebCore}->add(<<END); 2927 $implementation{nameSpaceWebCore}->add(<<END);
2775 WrapperTypeInfo ${v8ClassName}Constructor::info = { ${v8ClassName}Constructor::G etTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEventTarget, 0, ${v8ClassName}::installPerContextPrototypeProperties, 0, WrapperTypeObjectProtot ype }; 2928 WrapperTypeInfo ${v8ClassName}Constructor::info = { ${v8ClassName}Constructor::G etTemplate, ${v8ClassName}::derefObject, $toActiveDOMObject, $toEventTarget, 0, ${v8ClassName}::installPerContextPrototypeProperties, 0, WrapperTypeObjectProtot ype };
2776 2929
2777 END 2930 END
2778 2931
2779 my $code = ""; 2932 my $code = "";
2780 $code .= <<END; 2933 $code .= <<END;
2781 static void ${v8ClassName}ConstructorCallback(const v8::FunctionCallbackInfo<v8: :Value>& args) 2934 static void ${v8ClassName}ConstructorCallback(const v8::FunctionCallbackInfo<v8: :Value>& args)
2782 { 2935 {
2783 END 2936 END
2937 ### DONE
2784 $code .= $maybeObserveFeature if $maybeObserveFeature; 2938 $code .= $maybeObserveFeature if $maybeObserveFeature;
2939 ### DONE
2785 $code .= $maybeDeprecateFeature if $maybeDeprecateFeature; 2940 $code .= $maybeDeprecateFeature if $maybeDeprecateFeature;
2941 ### DONE
2786 $code .= GenerateConstructorHeader(); 2942 $code .= GenerateConstructorHeader();
2787 AddToImplIncludes("V8Document.h"); 2943 AddToImplIncludes("V8Document.h");
2944 ### DONE
2788 $code .= <<END; 2945 $code .= <<END;
2789 Document* document = currentDocument(); 2946 Document* document = currentDocument();
2790 2947
2791 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp lClassName} instance 2948 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp lClassName} instance
2792 // may end up being the only node in the map and get garbage-collected prema turely. 2949 // may end up being the only node in the map and get garbage-collected prema turely.
2793 toV8(document, args.Holder(), args.GetIsolate()); 2950 toV8(document, args.Holder(), args.GetIsolate());
2794 2951
2795 END 2952 END
2796 2953
2954 ### DONE
2797 $code .= GenerateArgumentsCountCheck($function, $interface); 2955 $code .= GenerateArgumentsCountCheck($function, $interface);
2798 2956
2957 ### DONE
2799 if ($raisesExceptions) { 2958 if ($raisesExceptions) {
2800 AddToImplIncludes("bindings/v8/ExceptionState.h"); 2959 AddToImplIncludes("bindings/v8/ExceptionState.h");
2801 $code .= " ExceptionState es(args.GetIsolate());\n"; 2960 $code .= " ExceptionState es(args.GetIsolate());\n";
2802 } 2961 }
2803 2962
2963 ### DONE
2804 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface); 2964 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface);
2805 $code .= $parameterCheckString; 2965 $code .= $parameterCheckString;
2806 2966
2967 ### DONE
2807 push(@beforeArgumentList, "document"); 2968 push(@beforeArgumentList, "document");
2808 2969
2970 ### DONE
2809 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 2971 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2810 push(@afterArgumentList, "es"); 2972 push(@afterArgumentList, "es");
2811 } 2973 }
2812 2974
2975 ### DONE
2813 my @argumentList; 2976 my @argumentList;
2814 my $index = 0; 2977 my $index = 0;
2815 foreach my $parameter (@{$function->parameters}) { 2978 foreach my $parameter (@{$function->parameters}) {
2816 last if $index eq $paramIndex; 2979 last if $index eq $paramIndex;
2817 if ($replacements{$parameter->name}) { 2980 if ($replacements{$parameter->name}) {
2818 push(@argumentList, $replacements{$parameter->name}); 2981 push(@argumentList, $replacements{$parameter->name});
2819 } else { 2982 } else {
2820 push(@argumentList, $parameter->name); 2983 push(@argumentList, $parameter->name);
2821 } 2984 }
2822 $index++; 2985 $index++;
2823 } 2986 }
2824 2987
2988 ### DONE
2825 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); 2989 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList);
2990 ### DONE
2826 $code .= "\n"; 2991 $code .= "\n";
2827 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC onstructor(${argumentString});\n"; 2992 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC onstructor(${argumentString});\n";
2828 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; 2993 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n";
2829 2994
2995 ### DONE
2830 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 2996 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2831 $code .= " if (es.throwIfNeeded())\n"; 2997 $code .= " if (es.throwIfNeeded())\n";
2832 $code .= " return;\n"; 2998 $code .= " return;\n";
2833 } 2999 }
2834 3000
3001 ### DONE
2835 $code .= <<END; 3002 $code .= <<END;
2836 3003
2837 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${ v8ClassName}Constructor::info, wrapper, args.GetIsolate(), WrapperConfiguration: :Dependent); 3004 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${ v8ClassName}Constructor::info, wrapper, args.GetIsolate(), WrapperConfiguration: :Dependent);
2838 args.GetReturnValue().Set(wrapper); 3005 args.GetReturnValue().Set(wrapper);
2839 } 3006 }
2840 3007
2841 END 3008 END
2842 $implementation{nameSpaceWebCore}->add($code); 3009 $implementation{nameSpaceWebCore}->add($code);
2843 3010
3011 ### DONE
2844 $code = <<END; 3012 $code = <<END;
2845 v8::Handle<v8::FunctionTemplate> ${v8ClassName}Constructor::GetTemplate(v8::Isol ate* isolate, WrapperWorldType currentWorldType) 3013 v8::Handle<v8::FunctionTemplate> ${v8ClassName}Constructor::GetTemplate(v8::Isol ate* isolate, WrapperWorldType currentWorldType)
2846 { 3014 {
2847 // This is only for getting a unique pointer which we can pass to privateTem plate. 3015 // This is only for getting a unique pointer which we can pass to privateTem plate.
2848 static const char* privateTemplateUniqueKey = "${v8ClassName}Constructor::Ge tTemplatePrivateTemplate"; 3016 static const char* privateTemplateUniqueKey = "${v8ClassName}Constructor::Ge tTemplatePrivateTemplate";
2849 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 3017 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
2850 v8::Handle<v8::FunctionTemplate> result = data->privateTemplateIfExists(curr entWorldType, &privateTemplateUniqueKey); 3018 v8::Handle<v8::FunctionTemplate> result = data->privateTemplateIfExists(curr entWorldType, &privateTemplateUniqueKey);
2851 if (!result.IsEmpty()) 3019 if (!result.IsEmpty())
2852 return result; 3020 return result;
2853 3021
2854 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink\", \"BuildDOMTemplate"); 3022 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink\", \"BuildDOMTemplate");
2855 v8::HandleScope scope(isolate); 3023 v8::HandleScope scope(isolate);
2856 result = v8::FunctionTemplate::New(${v8ClassName}ConstructorCallback); 3024 result = v8::FunctionTemplate::New(${v8ClassName}ConstructorCallback);
2857 3025
2858 v8::Local<v8::ObjectTemplate> instance = result->InstanceTemplate(); 3026 v8::Local<v8::ObjectTemplate> instance = result->InstanceTemplate();
2859 instance->SetInternalFieldCount(${v8ClassName}::internalFieldCount); 3027 instance->SetInternalFieldCount(${v8ClassName}::internalFieldCount);
2860 result->SetClassName(v8::String::NewSymbol("${implClassName}")); 3028 result->SetClassName(v8::String::NewSymbol("${implClassName}"));
2861 result->Inherit(${v8ClassName}::GetTemplate(isolate, currentWorldType)); 3029 result->Inherit(${v8ClassName}::GetTemplate(isolate, currentWorldType));
2862 data->setPrivateTemplate(currentWorldType, &privateTemplateUniqueKey, result ); 3030 data->setPrivateTemplate(currentWorldType, &privateTemplateUniqueKey, result );
2863 3031
2864 return scope.Close(result); 3032 return scope.Close(result);
2865 } 3033 }
2866 3034
2867 END 3035 END
2868 $implementation{nameSpaceWebCore}->add($code); 3036 $implementation{nameSpaceWebCore}->add($code);
2869 } 3037 }
2870 3038
3039 ### DONE
2871 sub GenerateConstructorHeader 3040 sub GenerateConstructorHeader
2872 { 3041 {
2873 AddToImplIncludes("bindings/v8/V8ObjectConstructor.h"); 3042 AddToImplIncludes("bindings/v8/V8ObjectConstructor.h");
2874 my $content = <<END; 3043 my $content = <<END;
2875 if (!args.IsConstructCall()) { 3044 if (!args.IsConstructCall()) {
2876 throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate()); 3045 throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
2877 return; 3046 return;
2878 } 3047 }
2879 3048
2880 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { 3049 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) {
(...skipping 15 matching lines...) Expand all
2896 my $conditionalString = GenerateConditionalString($attribute); 3065 my $conditionalString = GenerateConditionalString($attribute);
2897 my $subCode = ""; 3066 my $subCode = "";
2898 $subCode .= "#if ${conditionalString}\n" if $conditionalString; 3067 $subCode .= "#if ${conditionalString}\n" if $conditionalString;
2899 $subCode .= GenerateSingleBatchedAttribute($interface, $attribute, ",", ""); 3068 $subCode .= GenerateSingleBatchedAttribute($interface, $attribute, ",", "");
2900 $subCode .= "#endif // ${conditionalString}\n" if $conditionalString; 3069 $subCode .= "#endif // ${conditionalString}\n" if $conditionalString;
2901 $code .= $subCode; 3070 $code .= $subCode;
2902 } 3071 }
2903 return $code; 3072 return $code;
2904 } 3073 }
2905 3074
3075 ### get_single_batched_attribute in python
2906 sub GenerateSingleBatchedAttribute 3076 sub GenerateSingleBatchedAttribute
2907 { 3077 {
2908 my $interface = shift; 3078 my $interface = shift;
2909 my $attribute = shift; 3079 my $attribute = shift;
2910 my $delimiter = shift; 3080 my $delimiter = shift;
2911 my $indent = shift; 3081 my $indent = shift;
2912 my $code = ""; 3082 my $code = "";
2913 my $attrName = $attribute->name; 3083 my $attrName = $attribute->name;
2914 my $attrExt = $attribute->extendedAttributes; 3084 my $attrExt = $attribute->extendedAttributes;
2915 my $implClassName = GetImplName($interface); 3085 my $implClassName = GetImplName($interface);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
3111 $code .= " } else {\n"; 3281 $code .= " } else {\n";
3112 $code .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$ name\"), v8::FunctionTemplate::New(${implClassName}V8Internal::${name}MethodCall back, v8Undefined(), ${signature}, $functionLength)$property_attributes);\n"; 3282 $code .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$ name\"), v8::FunctionTemplate::New(${implClassName}V8Internal::${name}MethodCall back, v8Undefined(), ${signature}, $functionLength)$property_attributes);\n";
3113 $code .= " }\n"; 3283 $code .= " }\n";
3114 } else { 3284 } else {
3115 $code .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$name \"), v8::FunctionTemplate::New(${implClassName}V8Internal::${name}MethodCallback , v8Undefined(), ${signature}, $functionLength)$property_attributes);\n"; 3285 $code .= " ${conditional}$template->Set(v8::String::NewSymbol(\"$name \"), v8::FunctionTemplate::New(${implClassName}V8Internal::${name}MethodCallback , v8Undefined(), ${signature}, $functionLength)$property_attributes);\n";
3116 } 3286 }
3117 $code .= "#endif // ${conditionalString}\n" if $conditionalString; 3287 $code .= "#endif // ${conditionalString}\n" if $conditionalString;
3118 return $code; 3288 return $code;
3119 } 3289 }
3120 3290
3291 ### DONE
3292 # get_is_null_expression in python
3121 sub GenerateIsNullExpression 3293 sub GenerateIsNullExpression
3122 { 3294 {
3123 my $type = shift; 3295 my $type = shift;
3124 my $variableName = shift; 3296 my $variableName = shift;
3297 ### DONE
3125 if (IsUnionType($type)) { 3298 if (IsUnionType($type)) {
3126 my $types = $type->unionMemberTypes; 3299 my $types = $type->unionMemberTypes;
3127 my @expression = (); 3300 my @expression = ();
3128 for my $i (0 .. scalar(@$types)-1) { 3301 for my $i (0 .. scalar(@$types)-1) {
3129 my $unionMemberType = $types->[$i]; 3302 my $unionMemberType = $types->[$i];
3130 my $unionMemberVariable = $variableName . $i; 3303 my $unionMemberVariable = $variableName . $i;
3131 my $isNull = GenerateIsNullExpression($unionMemberType, $unionMember Variable); 3304 my $isNull = GenerateIsNullExpression($unionMemberType, $unionMember Variable);
3132 push @expression, $isNull; 3305 push @expression, $isNull;
3133 } 3306 }
3134 return join " && ", @expression; 3307 return join " && ", @expression;
3135 } 3308 }
3309 ### DONE
3136 if (IsRefPtrType($type)) { 3310 if (IsRefPtrType($type)) {
3137 return "!${variableName}"; 3311 return "!${variableName}";
3138 } elsif ($type eq "DOMString") { 3312 } elsif ($type eq "DOMString") {
3139 return "${variableName}.isNull()"; 3313 return "${variableName}.isNull()";
3140 } else { 3314 } else {
3141 return ""; 3315 return "";
3142 } 3316 }
3143 } 3317 }
3144 3318
3145 sub GenerateIfElseStatement 3319 sub GenerateIfElseStatement
(...skipping 25 matching lines...) Expand all
3171 { 3345 {
3172 my $interface = shift; 3346 my $interface = shift;
3173 my $interfaceName = $interface->name; 3347 my $interfaceName = $interface->name;
3174 my $implClassName = GetImplName($interface); 3348 my $implClassName = GetImplName($interface);
3175 my $v8ClassName = GetV8ClassName($interface); 3349 my $v8ClassName = GetV8ClassName($interface);
3176 3350
3177 my $indexedGetterFunction = GetIndexedGetterFunction($interface); 3351 my $indexedGetterFunction = GetIndexedGetterFunction($interface);
3178 if ($indexedGetterFunction) { 3352 if ($indexedGetterFunction) {
3179 my $hasCustomIndexedGetter = $indexedGetterFunction->extendedAttributes- >{"Custom"}; 3353 my $hasCustomIndexedGetter = $indexedGetterFunction->extendedAttributes- >{"Custom"};
3180 if (!$hasCustomIndexedGetter) { 3354 if (!$hasCustomIndexedGetter) {
3355 ### working
3181 GenerateImplementationIndexedPropertyGetter($interface, $indexedGett erFunction); 3356 GenerateImplementationIndexedPropertyGetter($interface, $indexedGett erFunction);
3182 } 3357 }
3358 ### working
3183 GenerateImplementationIndexedPropertyGetterCallback($interface, $hasCust omIndexedGetter); 3359 GenerateImplementationIndexedPropertyGetterCallback($interface, $hasCust omIndexedGetter);
3184 } 3360 }
3185 3361
3362 ### TODO
3186 my $indexedSetterFunction = GetIndexedSetterFunction($interface); 3363 my $indexedSetterFunction = GetIndexedSetterFunction($interface);
3187 if ($indexedSetterFunction) { 3364 if ($indexedSetterFunction) {
3188 my $hasCustomIndexedSetter = $indexedSetterFunction->extendedAttributes- >{"Custom"}; 3365 my $hasCustomIndexedSetter = $indexedSetterFunction->extendedAttributes- >{"Custom"};
3189 if (!$hasCustomIndexedSetter) { 3366 if (!$hasCustomIndexedSetter) {
3190 GenerateImplementationIndexedPropertySetter($interface, $indexedSett erFunction); 3367 GenerateImplementationIndexedPropertySetter($interface, $indexedSett erFunction);
3191 } 3368 }
3192 GenerateImplementationIndexedPropertySetterCallback($interface, $hasCust omIndexedSetter); 3369 GenerateImplementationIndexedPropertySetterCallback($interface, $hasCust omIndexedSetter);
3193 } 3370 }
3194 3371
3372 ### TODO
3195 my $indexedDeleterFunction = GetIndexedDeleterFunction($interface); 3373 my $indexedDeleterFunction = GetIndexedDeleterFunction($interface);
3196 if ($indexedDeleterFunction) { 3374 if ($indexedDeleterFunction) {
3197 my $hasCustomIndexedDeleter = $indexedDeleterFunction->extendedAttribute s->{"Custom"}; 3375 my $hasCustomIndexedDeleter = $indexedDeleterFunction->extendedAttribute s->{"Custom"};
3198 if (!$hasCustomIndexedDeleter) { 3376 if (!$hasCustomIndexedDeleter) {
3199 GenerateImplementationIndexedPropertyDeleter($interface, $indexedDel eterFunction); 3377 GenerateImplementationIndexedPropertyDeleter($interface, $indexedDel eterFunction);
3200 } 3378 }
3201 GenerateImplementationIndexedPropertyDeleterCallback($interface, $hasCus tomIndexedDeleter); 3379 GenerateImplementationIndexedPropertyDeleterCallback($interface, $hasCus tomIndexedDeleter);
3202 } 3380 }
3203 3381
3382 ### DONE
3204 my $indexedEnumeratorFunction = $indexedGetterFunction; 3383 my $indexedEnumeratorFunction = $indexedGetterFunction;
3205 $indexedEnumeratorFunction = 0 if $indexedGetterFunction && $indexedGetterFu nction->extendedAttributes->{"NotEnumerable"}; 3384 $indexedEnumeratorFunction = 0 if $indexedGetterFunction && $indexedGetterFu nction->extendedAttributes->{"NotEnumerable"};
3206 3385
3386 ### DONE
3207 my $indexedQueryFunction = 0; 3387 my $indexedQueryFunction = 0;
3208 # If there is an enumerator, there MUST be a query method to properly commun icate property attributes. 3388 # If there is an enumerator, there MUST be a query method to properly commun icate property attributes.
3209 my $hasQuery = $indexedQueryFunction || $indexedEnumeratorFunction; 3389 my $hasQuery = $indexedQueryFunction || $indexedEnumeratorFunction;
3210 3390
3391 ### DONE
3211 my $setOn = "Instance"; 3392 my $setOn = "Instance";
3212 3393
3213 # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCallba cks) and it's used on Window 3394 # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCallba cks) and it's used on Window
3214 # instead of deleters or enumerators. In addition, the getter should be set on prototype template, to 3395 # instead of deleters or enumerators. In addition, the getter should be set on prototype template, to
3215 # get implementation straight out of the Window prototype regardless of what prototype is actually set 3396 # get implementation straight out of the Window prototype regardless of what prototype is actually set
3216 # on the object. 3397 # on the object.
3217 if ($interfaceName eq "Window") { 3398 if ($interfaceName eq "Window") {
3218 $setOn = "Prototype"; 3399 $setOn = "Prototype";
3219 } 3400 }
3220 3401
3402 ### DONE
3221 my $code = ""; 3403 my $code = "";
3222 if ($indexedGetterFunction || $indexedSetterFunction || $indexedDeleterFunct ion || $indexedEnumeratorFunction || $hasQuery) { 3404 if ($indexedGetterFunction || $indexedSetterFunction || $indexedDeleterFunct ion || $indexedEnumeratorFunction || $hasQuery) {
3223 $code .= " desc->${setOn}Template()->SetIndexedPropertyHandler(${impl ClassName}V8Internal::indexedPropertyGetterCallback"; 3405 $code .= " desc->${setOn}Template()->SetIndexedPropertyHandler(${impl ClassName}V8Internal::indexedPropertyGetterCallback";
3224 $code .= $indexedSetterFunction ? ", ${implClassName}V8Internal::indexed PropertySetterCallback" : ", 0"; 3406 $code .= $indexedSetterFunction ? ", ${implClassName}V8Internal::indexed PropertySetterCallback" : ", 0";
3225 $code .= ", 0"; # IndexedPropertyQuery -- not being used at the moment. 3407 $code .= ", 0"; # IndexedPropertyQuery -- not being used at the moment.
3226 $code .= $indexedDeleterFunction ? ", ${implClassName}V8Internal::indexe dPropertyDeleterCallback" : ", 0"; 3408 $code .= $indexedDeleterFunction ? ", ${implClassName}V8Internal::indexe dPropertyDeleterCallback" : ", 0";
3227 $code .= $indexedEnumeratorFunction ? ", indexedPropertyEnumerator<${imp lClassName}>" : ", 0"; 3409 $code .= $indexedEnumeratorFunction ? ", indexedPropertyEnumerator<${imp lClassName}>" : ", 0";
3228 $code .= ");\n"; 3410 $code .= ");\n";
3229 } 3411 }
3230 3412
3231 return $code; 3413 return $code;
3232 } 3414 }
3233 3415
3234 sub GenerateImplementationIndexedPropertyGetter 3416 sub GenerateImplementationIndexedPropertyGetter
3235 { 3417 {
3236 my $interface = shift; 3418 my $interface = shift;
3237 my $indexedGetterFunction = shift; 3419 my $indexedGetterFunction = shift;
3238 my $implClassName = GetImplName($interface); 3420 my $implClassName = GetImplName($interface);
3239 my $v8ClassName = GetV8ClassName($interface); 3421 my $v8ClassName = GetV8ClassName($interface);
3240 my $methodName = GetImplName($indexedGetterFunction); 3422 my $methodName = GetImplName($indexedGetterFunction);
3241 3423
3242 my $returnType = $indexedGetterFunction->type; 3424 my $returnType = $indexedGetterFunction->type;
3243 my $nativeType = GetNativeType($returnType); 3425 my $nativeType = GetNativeType($returnType);
3244 my $nativeValue = "element"; 3426 my $nativeValue = "element";
3245 $nativeValue .= ".release()" if (IsRefPtrType($returnType)); 3427 $nativeValue .= ".release()" if (IsRefPtrType($returnType));
3428 ### DONE
3246 my $isNull = GenerateIsNullExpression($returnType, "element"); 3429 my $isNull = GenerateIsNullExpression($returnType, "element");
3430 ### DONE
3247 my $returnJSValueCode = NativeToJSValue($indexedGetterFunction->type, $index edGetterFunction->extendedAttributes, $nativeValue, " ", "", "info.Holder()", "info.GetIsolate()", "info", "collection", "", "return"); 3431 my $returnJSValueCode = NativeToJSValue($indexedGetterFunction->type, $index edGetterFunction->extendedAttributes, $nativeValue, " ", "", "info.Holder()", "info.GetIsolate()", "info", "collection", "", "return");
3248 my $raisesExceptions = $indexedGetterFunction->extendedAttributes->{"RaisesE xception"}; 3432 my $raisesExceptions = $indexedGetterFunction->extendedAttributes->{"RaisesE xception"};
3433 ### DONE
3249 my $methodCallCode = GenerateMethodCall($returnType, "element", "collection- >${methodName}", "index", $raisesExceptions); 3434 my $methodCallCode = GenerateMethodCall($returnType, "element", "collection- >${methodName}", "index", $raisesExceptions);
3435 ### DONE
3250 my $getterCode = "static void indexedPropertyGetter(uint32_t index, const v8 ::PropertyCallbackInfo<v8::Value>& info)\n"; 3436 my $getterCode = "static void indexedPropertyGetter(uint32_t index, const v8 ::PropertyCallbackInfo<v8::Value>& info)\n";
3251 $getterCode .= "{\n"; 3437 $getterCode .= "{\n";
3252 $getterCode .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n" ; 3438 $getterCode .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n" ;
3253 $getterCode .= " ${implClassName}* collection = ${v8ClassName}::toNative( info.Holder());\n"; 3439 $getterCode .= " ${implClassName}* collection = ${v8ClassName}::toNative( info.Holder());\n";
3440 ### DONE
3254 if ($raisesExceptions) { 3441 if ($raisesExceptions) {
3255 $getterCode .= " ExceptionState es(info.GetIsolate());\n"; 3442 $getterCode .= " ExceptionState es(info.GetIsolate());\n";
3256 } 3443 }
3444 ### DONE but use function_call later
3257 $getterCode .= $methodCallCode . "\n"; 3445 $getterCode .= $methodCallCode . "\n";
3446 ### DONE
3258 if ($raisesExceptions) { 3447 if ($raisesExceptions) {
3259 $getterCode .= " if (es.throwIfNeeded())\n"; 3448 $getterCode .= " if (es.throwIfNeeded())\n";
3260 $getterCode .= " return;\n"; 3449 $getterCode .= " return;\n";
3261 } 3450 }
3262 if (IsUnionType($returnType)) { 3451 if (IsUnionType($returnType)) {
3452 ### TDOO
3263 $getterCode .= "${returnJSValueCode}\n"; 3453 $getterCode .= "${returnJSValueCode}\n";
3264 $getterCode .= " return;\n"; 3454 $getterCode .= " return;\n";
3265 } else { 3455 } else {
3456 ### DONE
3266 $getterCode .= " if (${isNull})\n"; 3457 $getterCode .= " if (${isNull})\n";
3267 $getterCode .= " return;\n"; 3458 $getterCode .= " return;\n";
3268 $getterCode .= $returnJSValueCode . "\n"; 3459 $getterCode .= $returnJSValueCode . "\n";
3269 } 3460 }
3270 $getterCode .= "}\n\n"; 3461 $getterCode .= "}\n\n";
3271 $implementation{nameSpaceInternal}->add($getterCode); 3462 $implementation{nameSpaceInternal}->add($getterCode);
3272 } 3463 }
3273 3464
3274 sub GenerateImplementationIndexedPropertyGetterCallback 3465 sub GenerateImplementationIndexedPropertyGetterCallback
3275 { 3466 {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
3358 if ($treatNullAs && $treatNullAs ne "NullString") { 3549 if ($treatNullAs && $treatNullAs ne "NullString") {
3359 push @conditions, "value->IsNull()"; 3550 push @conditions, "value->IsNull()";
3360 push @statements, "collection->${treatNullAs}(index$extraArguments);"; 3551 push @statements, "collection->${treatNullAs}(index$extraArguments);";
3361 } 3552 }
3362 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") { 3553 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") {
3363 push @conditions, "value->IsUndefined()"; 3554 push @conditions, "value->IsUndefined()";
3364 push @statements, "collection->${treatUndefinedAs}(index$extraArguments) ;"; 3555 push @statements, "collection->${treatUndefinedAs}(index$extraArguments) ;";
3365 } 3556 }
3366 push @conditions, ""; 3557 push @conditions, "";
3367 push @statements, "collection->${methodName}(index, propertyValue$extraArgum ents);"; 3558 push @statements, "collection->${methodName}(index, propertyValue$extraArgum ents);";
3559 # TODO
3368 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s); 3560 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s);
3369 3561
3370 $code .= " if (!result)\n"; 3562 $code .= " if (!result)\n";
3371 $code .= " return;\n"; 3563 $code .= " return;\n";
3372 if ($raisesExceptions) { 3564 if ($raisesExceptions) {
3373 $code .= " if (es.throwIfNeeded())\n"; 3565 $code .= " if (es.throwIfNeeded())\n";
3374 $code .= " return;\n"; 3566 $code .= " return;\n";
3375 } 3567 }
3376 $code .= " v8SetReturnValue(info, value);\n"; 3568 $code .= " v8SetReturnValue(info, value);\n";
3377 $code .= "}\n\n"; 3569 $code .= "}\n\n";
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
3541 if ($hasCustom) { 3733 if ($hasCustom) {
3542 $code .= " ${v8ClassName}::namedPropertyQueryCustom(name, info);\n"; 3734 $code .= " ${v8ClassName}::namedPropertyQueryCustom(name, info);\n";
3543 } else { 3735 } else {
3544 $code .= " ${implClassName}V8Internal::namedPropertyQuery(name, info) ;\n"; 3736 $code .= " ${implClassName}V8Internal::namedPropertyQuery(name, info) ;\n";
3545 } 3737 }
3546 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"Execution\");\n"; 3738 $code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"Execution\");\n";
3547 $code .= "}\n\n"; 3739 $code .= "}\n\n";
3548 $implementation{nameSpaceInternal}->add($code); 3740 $implementation{nameSpaceInternal}->add($code);
3549 } 3741 }
3550 3742
3743 ### TODO: use js_value_to_native
3744 ### get_function_call_statements in python
3551 sub GenerateMethodCall 3745 sub GenerateMethodCall
3552 { 3746 {
3553 my $returnType = shift; # string or UnionType 3747 my $returnType = shift; # string or UnionType
3554 my $returnName = shift; 3748 my $returnName = shift;
3555 my $functionExpression = shift; 3749 my $functionExpression = shift;
3556 my $firstArgument = shift; 3750 my $firstArgument = shift;
3557 my $raisesExceptions = shift; 3751 my $raisesExceptions = shift;
3558 3752
3559 my @arguments = (); 3753 my @arguments = ();
3560 push @arguments, $firstArgument; 3754 push @arguments, $firstArgument;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
3787 if (es.throwIfNeeded()) 3981 if (es.throwIfNeeded())
3788 return; 3982 return;
3789 if (!result) 3983 if (!result)
3790 return; 3984 return;
3791 v8SetReturnValueInt(info, v8::None); 3985 v8SetReturnValueInt(info, v8::None);
3792 } 3986 }
3793 3987
3794 END 3988 END
3795 } 3989 }
3796 3990
3991 ### TODO 7/16
3797 sub GenerateImplementationLegacyCall 3992 sub GenerateImplementationLegacyCall
3798 { 3993 {
3799 my $interface = shift; 3994 my $interface = shift;
3800 my $code = ""; 3995 my $code = "";
3801 3996
3802 my $v8ClassName = GetV8ClassName($interface); 3997 my $v8ClassName = GetV8ClassName($interface);
3803 3998
3804 if ($interface->extendedAttributes->{"CustomLegacyCall"}) { 3999 if ($interface->extendedAttributes->{"CustomLegacyCall"}) {
3805 $code .= " desc->InstanceTemplate()->SetCallAsFunctionHandler(${v8Cla ssName}::legacyCallCustom);\n"; 4000 $code .= " desc->InstanceTemplate()->SetCallAsFunctionHandler(${v8Cla ssName}::legacyCallCustom);\n";
3806 } 4001 }
3807 return $code; 4002 return $code;
3808 } 4003 }
3809 4004
3810 sub GenerateImplementationMasqueradesAsUndefined 4005 sub GenerateImplementationMasqueradesAsUndefined
3811 { 4006 {
3812 my $interface = shift; 4007 my $interface = shift;
3813 my $code = ""; 4008 my $code = "";
3814 4009
3815 if ($interface->extendedAttributes->{"MasqueradesAsUndefined"}) 4010 if ($interface->extendedAttributes->{"MasqueradesAsUndefined"})
3816 { 4011 {
3817 $code .= " desc->InstanceTemplate()->MarkAsUndetectable();\n"; 4012 $code .= " desc->InstanceTemplate()->MarkAsUndetectable();\n";
3818 } 4013 }
3819 return $code; 4014 return $code;
3820 } 4015 }
3821 4016
4017 # __IMPL__
3822 sub GenerateImplementation 4018 sub GenerateImplementation
3823 { 4019 {
3824 my $object = shift; 4020 my $object = shift;
3825 my $interface = shift; 4021 my $interface = shift;
3826 my $interfaceName = $interface->name; 4022 my $interfaceName = $interface->name;
3827 my $implClassName = GetImplName($interface); 4023 my $implClassName = GetImplName($interface);
3828 my $v8ClassName = GetV8ClassName($interface); 4024 my $v8ClassName = GetV8ClassName($interface);
3829 my $nativeType = GetNativeTypeForConversions($interface); 4025 my $nativeType = GetNativeTypeForConversions($interface);
3830 4026
3831 AddToImplIncludes("bindings/v8/V8Binding.h"); 4027 AddToImplIncludes("bindings/v8/V8Binding.h");
(...skipping 13 matching lines...) Expand all
3845 my $parentClass = ""; 4041 my $parentClass = "";
3846 my $parentClassTemplate = ""; 4042 my $parentClassTemplate = "";
3847 if ($interface->parent) { 4043 if ($interface->parent) {
3848 my $parent = $interface->parent; 4044 my $parent = $interface->parent;
3849 AddToImplIncludes("V8${parent}.h"); 4045 AddToImplIncludes("V8${parent}.h");
3850 $parentClass = "V8" . $parent; 4046 $parentClass = "V8" . $parent;
3851 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor ldType)"; 4047 $parentClassTemplate = $parentClass . "::GetTemplate(isolate, currentWor ldType)";
3852 } 4048 }
3853 4049
3854 my $parentClassInfo = $parentClass ? "&${parentClass}::info" : "0"; 4050 my $parentClassInfo = $parentClass ? "&${parentClass}::info" : "0";
4051 ### only DOMException isException==True
3855 my $WrapperTypePrototype = $interface->isException ? "WrapperTypeErrorProtot ype" : "WrapperTypeObjectPrototype"; 4052 my $WrapperTypePrototype = $interface->isException ? "WrapperTypeErrorProtot ype" : "WrapperTypeObjectPrototype";
3856 4053
3857 if (!IsSVGTypeNeedingTearOff($interfaceName)) { 4054 if (!IsSVGTypeNeedingTearOff($interfaceName)) {
3858 my $code = <<END; 4055 my $code = <<END;
3859 static void initializeScriptWrappableForInterface(${implClassName}* object) 4056 static void initializeScriptWrappableForInterface(${implClassName}* object)
3860 { 4057 {
3861 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) 4058 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
3862 ScriptWrappable::setTypeInfoInObject(object, &${v8ClassName}::info); 4059 ScriptWrappable::setTypeInfoInObject(object, &${v8ClassName}::info);
3863 else 4060 else
3864 ASSERT_NOT_REACHED(); 4061 ASSERT_NOT_REACHED();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3912 } 4109 }
3913 4110
3914 if ($attrType eq "EventHandler" && $interfaceName eq "Window") { 4111 if ($attrType eq "EventHandler" && $interfaceName eq "Window") {
3915 $attrExt->{"OnProto"} = 1; 4112 $attrExt->{"OnProto"} = 1;
3916 } 4113 }
3917 4114
3918 if ($attrType eq "SerializedScriptValue") { 4115 if ($attrType eq "SerializedScriptValue") {
3919 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); 4116 AddToImplIncludes("bindings/v8/SerializedScriptValue.h");
3920 } 4117 }
3921 4118
4119 ### DONE
3922 GenerateNormalAttrGetter($attribute, $interface, ""); 4120 GenerateNormalAttrGetter($attribute, $interface, "");
4121 ### DONE
3923 GenerateNormalAttrGetterCallback($attribute, $interface, ""); 4122 GenerateNormalAttrGetterCallback($attribute, $interface, "");
3924 if ($attrExt->{"PerWorldBindings"}) { 4123 if ($attrExt->{"PerWorldBindings"}) {
4124 ### DONE
3925 GenerateNormalAttrGetter($attribute, $interface, "ForMainWorld"); 4125 GenerateNormalAttrGetter($attribute, $interface, "ForMainWorld");
4126 ### DONE
3926 GenerateNormalAttrGetterCallback($attribute, $interface, "ForMainWor ld"); 4127 GenerateNormalAttrGetterCallback($attribute, $interface, "ForMainWor ld");
3927 } 4128 }
3928 if (!HasCustomSetter($attrExt) && $attrExt->{"Replaceable"}) { 4129 if (!HasCustomSetter($attrExt) && $attrExt->{"Replaceable"}) {
4130 ### TODO
3929 $hasReplaceable = 1; 4131 $hasReplaceable = 1;
3930 } elsif (!IsReadonly($attribute)) { 4132 } elsif (!IsReadonly($attribute)) {
4133 ### DONE(basic)
3931 GenerateNormalAttrSetter($attribute, $interface, ""); 4134 GenerateNormalAttrSetter($attribute, $interface, "");
4135 ### DONE
3932 GenerateNormalAttrSetterCallback($attribute, $interface, ""); 4136 GenerateNormalAttrSetterCallback($attribute, $interface, "");
3933 if ($attrExt->{"PerWorldBindings"}) { 4137 if ($attrExt->{"PerWorldBindings"}) {
4138 ### DONE(basic)
3934 GenerateNormalAttrSetter($attribute, $interface, "ForMainWorld"); 4139 GenerateNormalAttrSetter($attribute, $interface, "ForMainWorld");
4140 ### DONE
3935 GenerateNormalAttrSetterCallback($attribute, $interface, "ForMainW orld"); 4141 GenerateNormalAttrSetterCallback($attribute, $interface, "ForMainW orld");
3936 } 4142 }
3937 } 4143 }
3938 } 4144 }
3939 4145
3940 if ($hasConstructors) { 4146 if ($hasConstructors) {
4147 ### TODO
3941 GenerateConstructorGetter($interface); 4148 GenerateConstructorGetter($interface);
3942 } 4149 }
3943 4150
3944 if ($hasConstructors || $hasReplaceable) { 4151 if ($hasConstructors || $hasReplaceable) {
4152 ### TODO
3945 GenerateReplaceableAttrSetter($interface); 4153 GenerateReplaceableAttrSetter($interface);
4154 ### TODO
3946 GenerateReplaceableAttrSetterCallback($interface); 4155 GenerateReplaceableAttrSetterCallback($interface);
3947 } 4156 }
3948 4157
3949 if (NeedsOpaqueRootForGC($interface)) { 4158 if (NeedsOpaqueRootForGC($interface)) {
4159 ### DONE
3950 GenerateOpaqueRootForGC($interface); 4160 GenerateOpaqueRootForGC($interface);
3951 } 4161 }
3952 4162
3953 if ($interface->extendedAttributes->{"CheckSecurity"} && $interface->name ne "Window") { 4163 if ($interface->extendedAttributes->{"CheckSecurity"} && $interface->name ne "Window") {
4164 ### TODO
3954 GenerateSecurityCheckFunctions($interface); 4165 GenerateSecurityCheckFunctions($interface);
3955 } 4166 }
3956 4167
4168 ### TODO
3957 if (IsConstructorTemplate($interface, "TypedArray")) { 4169 if (IsConstructorTemplate($interface, "TypedArray")) {
3958 my ($nativeType, $arrayType) = GetNativeTypeOfTypedArray($interface); 4170 my ($nativeType, $arrayType) = GetNativeTypeOfTypedArray($interface);
3959 $implementation{nameSpaceWebCore}->add(<<END); 4171 $implementation{nameSpaceWebCore}->add(<<END);
3960 v8::Handle<v8::Object> wrap($implClassName* impl, v8::Handle<v8::Object> creatio nContext, v8::Isolate* isolate) 4172 v8::Handle<v8::Object> wrap($implClassName* impl, v8::Handle<v8::Object> creatio nContext, v8::Isolate* isolate)
3961 { 4173 {
3962 ASSERT(impl); 4174 ASSERT(impl);
3963 v8::Handle<v8::Object> wrapper = ${v8ClassName}::createWrapper(impl, creatio nContext, isolate); 4175 v8::Handle<v8::Object> wrapper = ${v8ClassName}::createWrapper(impl, creatio nContext, isolate);
3964 if (!wrapper.IsEmpty()) 4176 if (!wrapper.IsEmpty())
3965 wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), $a rrayType, impl->length()); 4177 wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), $a rrayType, impl->length());
3966 return wrapper; 4178 return wrapper;
3967 } 4179 }
3968 4180
3969 END 4181 END
3970 } 4182 }
3971 4183
3972 my @enabledPerContextFunctions; 4184 my @enabledPerContextFunctions;
3973 my @normalFunctions; 4185 my @normalFunctions;
3974 my $needsDomainSafeFunctionSetter = 0; 4186 my $needsDomainSafeFunctionSetter = 0;
3975 # Generate methods for functions. 4187 # Generate methods for functions.
3976 foreach my $function (@{$interface->functions}) { 4188 foreach my $function (@{$interface->functions}) {
3977 next if $function->name eq ""; 4189 next if $function->name eq "";
4190 ### DONE (basic)
3978 GenerateFunction($function, $interface, ""); 4191 GenerateFunction($function, $interface, "");
3979 if ($function->extendedAttributes->{"PerWorldBindings"}) { 4192 if ($function->extendedAttributes->{"PerWorldBindings"}) {
4193 ### TODO
3980 GenerateFunction($function, $interface, "ForMainWorld"); 4194 GenerateFunction($function, $interface, "ForMainWorld");
3981 } 4195 }
3982 if ($function->{overloadIndex} == @{$function->{overloads}}) { 4196 if ($function->{overloadIndex} == @{$function->{overloads}}) {
4197 ### TODO
3983 if ($function->{overloadIndex} > 1) { 4198 if ($function->{overloadIndex} > 1) {
3984 GenerateOverloadedFunction($function, $interface, ""); 4199 GenerateOverloadedFunction($function, $interface, "");
3985 if ($function->extendedAttributes->{"PerWorldBindings"}) { 4200 if ($function->extendedAttributes->{"PerWorldBindings"}) {
3986 GenerateOverloadedFunction($function, $interface, "ForMainWo rld"); 4201 GenerateOverloadedFunction($function, $interface, "ForMainWo rld");
3987 } 4202 }
3988 } 4203 }
4204 ### DONE
3989 GenerateFunctionCallback($function, $interface, ""); 4205 GenerateFunctionCallback($function, $interface, "");
3990 if ($function->extendedAttributes->{"PerWorldBindings"}) { 4206 if ($function->extendedAttributes->{"PerWorldBindings"}) {
4207 ### TODO
3991 GenerateFunctionCallback($function, $interface, "ForMainWorld"); 4208 GenerateFunctionCallback($function, $interface, "ForMainWorld");
3992 } 4209 }
3993 } 4210 }
3994 4211
3995 # If the function does not need domain security check, we need to 4212 # If the function does not need domain security check, we need to
3996 # generate an access getter that returns different function objects 4213 # generate an access getter that returns different function objects
3997 # for different calling context. 4214 # for different calling context.
4215 ### TODO
3998 if ($interface->extendedAttributes->{"CheckSecurity"} && $function->exte ndedAttributes->{"DoNotCheckSecurity"}) { 4216 if ($interface->extendedAttributes->{"CheckSecurity"} && $function->exte ndedAttributes->{"DoNotCheckSecurity"}) {
3999 if (!HasCustomMethod($function->extendedAttributes) || $function->{o verloadIndex} == 1) { 4217 if (!HasCustomMethod($function->extendedAttributes) || $function->{o verloadIndex} == 1) {
4000 GenerateDomainSafeFunctionGetter($function, $interface); 4218 GenerateDomainSafeFunctionGetter($function, $interface);
4001 if (!$function->extendedAttributes->{"ReadOnly"}) { 4219 if (!$function->extendedAttributes->{"ReadOnly"}) {
4002 $needsDomainSafeFunctionSetter = 1; 4220 $needsDomainSafeFunctionSetter = 1;
4003 } 4221 }
4004 } 4222 }
4005 } 4223 }
4006 4224
4225 ### TODO
4007 # Separate out functions that are enabled per context so we can process them specially. 4226 # Separate out functions that are enabled per context so we can process them specially.
4008 if ($function->extendedAttributes->{"EnabledPerContext"}) { 4227 if ($function->extendedAttributes->{"EnabledPerContext"}) {
4009 push(@enabledPerContextFunctions, $function); 4228 push(@enabledPerContextFunctions, $function);
4010 } else { 4229 } else {
4011 push(@normalFunctions, $function); 4230 push(@normalFunctions, $function);
4012 } 4231 }
4013 } 4232 }
4014 4233
4015 if ($needsDomainSafeFunctionSetter) { 4234 if ($needsDomainSafeFunctionSetter) {
4235 ### TODO
4016 GenerateDomainSafeFunctionSetter($interface); 4236 GenerateDomainSafeFunctionSetter($interface);
4017 } 4237 }
4018 4238
4019 # Attributes 4239 # Attributes
4020 my $attributes = $interface->attributes; 4240 my $attributes = $interface->attributes;
4021 4241
4022 # For the Window interface we partition the attributes into the 4242 # For the Window interface we partition the attributes into the
4023 # ones that disallows shadowing and the rest. 4243 # ones that disallows shadowing and the rest.
4024 my @disallowsShadowing; 4244 my @disallowsShadowing;
4025 # Also separate out attributes that are enabled at runtime so we can process them specially. 4245 # Also separate out attributes that are enabled at runtime so we can process them specially.
4026 my @enabledAtRuntimeAttributes; 4246 my @enabledAtRuntimeAttributes;
4027 my @enabledPerContextAttributes; 4247 my @enabledPerContextAttributes;
4028 my @normalAttributes; 4248 my @normalAttributes;
4029 foreach my $attribute (@$attributes) { 4249 foreach my $attribute (@$attributes) {
4030 4250
4251 ### TODO
4031 if ($interfaceName eq "Window" && $attribute->extendedAttributes->{"Unfo rgeable"}) { 4252 if ($interfaceName eq "Window" && $attribute->extendedAttributes->{"Unfo rgeable"}) {
4032 push(@disallowsShadowing, $attribute); 4253 push(@disallowsShadowing, $attribute);
4033 } elsif ($attribute->extendedAttributes->{"EnabledAtRuntime"} || $attrib ute->extendedAttributes->{"EnabledPerContext"}) { 4254 } elsif ($attribute->extendedAttributes->{"EnabledAtRuntime"} || $attrib ute->extendedAttributes->{"EnabledPerContext"}) {
4034 if ($attribute->extendedAttributes->{"EnabledPerContext"}) { 4255 if ($attribute->extendedAttributes->{"EnabledPerContext"}) {
4035 push(@enabledPerContextAttributes, $attribute); 4256 push(@enabledPerContextAttributes, $attribute);
4036 } 4257 }
4037 if ($attribute->extendedAttributes->{"EnabledAtRuntime"}) { 4258 if ($attribute->extendedAttributes->{"EnabledAtRuntime"}) {
4038 push(@enabledAtRuntimeAttributes, $attribute); 4259 push(@enabledAtRuntimeAttributes, $attribute);
4039 } 4260 }
4040 } else { 4261 } else {
4041 push(@normalAttributes, $attribute); 4262 push(@normalAttributes, $attribute);
4042 } 4263 }
4043 } 4264 }
4044 AddToImplIncludes("bindings/v8/V8DOMConfiguration.h"); 4265 AddToImplIncludes("bindings/v8/V8DOMConfiguration.h");
4045 $attributes = \@normalAttributes; 4266 $attributes = \@normalAttributes;
4046 # Put the attributes that disallow shadowing on the shadow object. 4267 # Put the attributes that disallow shadowing on the shadow object.
4268 ### DONE
4047 if (@disallowsShadowing) { 4269 if (@disallowsShadowing) {
4048 my $code = ""; 4270 my $code = "";
4049 $code .= "static const V8DOMConfiguration::BatchedAttribute shadowAttrs[ ] = {\n"; 4271 $code .= "static const V8DOMConfiguration::BatchedAttribute shadowAttrs[ ] = {\n";
4050 $code .= GenerateBatchedAttributeData($interface, \@disallowsShadowing); 4272 $code .= GenerateBatchedAttributeData($interface, \@disallowsShadowing);
4051 $code .= "};\n\n"; 4273 $code .= "};\n\n";
4052 $implementation{nameSpaceWebCore}->add($code); 4274 $implementation{nameSpaceWebCore}->add($code);
4053 } 4275 }
4054 4276
4277 # use Data::Dumper;
4278 # print "GEHEHE", Dumper($attributes), "\n" if $interface->name eq "File";
4055 my $has_attributes = 0; 4279 my $has_attributes = 0;
4056 if (@$attributes) { 4280 if (@$attributes) {
4057 $has_attributes = 1; 4281 $has_attributes = 1;
4058 my $code = ""; 4282 my $code = "";
4059 $code .= "static const V8DOMConfiguration::BatchedAttribute ${v8ClassNam e}Attrs[] = {\n"; 4283 $code .= "static const V8DOMConfiguration::BatchedAttribute ${v8ClassNam e}Attrs[] = {\n";
4060 $code .= GenerateBatchedAttributeData($interface, $attributes); 4284 $code .= GenerateBatchedAttributeData($interface, $attributes);
4061 $code .= "};\n\n"; 4285 $code .= "};\n\n";
4062 $implementation{nameSpaceWebCore}->add($code); 4286 $implementation{nameSpaceWebCore}->add($code);
4063 } 4287 }
4064 4288
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
4099 $code = ""; 4323 $code = "";
4100 if (@{$interface->constants}) { 4324 if (@{$interface->constants}) {
4101 $has_constants = 1; 4325 $has_constants = 1;
4102 $code .= "static const V8DOMConfiguration::BatchedConstant ${v8ClassName }Consts[] = {\n"; 4326 $code .= "static const V8DOMConfiguration::BatchedConstant ${v8ClassName }Consts[] = {\n";
4103 } 4327 }
4104 foreach my $constant (@{$interface->constants}) { 4328 foreach my $constant (@{$interface->constants}) {
4105 my $name = $constant->name; 4329 my $name = $constant->name;
4106 my $value = $constant->value; 4330 my $value = $constant->value;
4107 my $attrExt = $constant->extendedAttributes; 4331 my $attrExt = $constant->extendedAttributes;
4108 my $implementedBy = $attrExt->{"ImplementedBy"}; 4332 my $implementedBy = $attrExt->{"ImplementedBy"};
4333 ### DONE
4109 if ($implementedBy) { 4334 if ($implementedBy) {
4110 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy); 4335 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy);
4111 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implement edByImplName)); 4336 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implement edByImplName));
4112 } 4337 }
4113 if ($attrExt->{"EnabledAtRuntime"}) { 4338 if ($attrExt->{"EnabledAtRuntime"}) {
4339 ### TODO
4114 push(@constantsEnabledAtRuntime, $constant); 4340 push(@constantsEnabledAtRuntime, $constant);
4115 } else { 4341 } else {
4342 ### DONE
4116 my $conditionalString = GenerateConditionalString($constant); 4343 my $conditionalString = GenerateConditionalString($constant);
4117 $code .= "#if ${conditionalString}\n" if $conditionalString; 4344 $code .= "#if ${conditionalString}\n" if $conditionalString;
4118 # If the value we're dealing with is a hex number, preprocess it int o a signed integer 4345 # If the value we're dealing with is a hex number, preprocess it int o a signed integer
4119 # here, rather than running static_cast<signed int> in the generated code. 4346 # here, rather than running static_cast<signed int> in the generated code.
4120 if (substr($value, 0, 2) eq "0x") { 4347 if (substr($value, 0, 2) eq "0x") {
4121 $value = unpack('i', pack('I', hex($value))); 4348 $value = unpack('i', pack('I', hex($value)));
4122 } 4349 }
4123 $code .= <<END; 4350 $code .= <<END;
4124 {"${name}", $value}, 4351 {"${name}", $value},
4125 END 4352 END
4126 $code .= "#endif\n" if $conditionalString; 4353 $code .= "#endif\n" if $conditionalString;
4127 } 4354 }
4128 } 4355 }
4129 if ($has_constants) { 4356 if ($has_constants) {
4130 $code .= "};\n\n"; 4357 $code .= "};\n\n";
4131 $code .= join "", GenerateCompileTimeCheckForEnumsIfNeeded($interface); 4358 $code .= join "", GenerateCompileTimeCheckForEnumsIfNeeded($interface);
4132 $implementation{nameSpaceWebCore}->add($code); 4359 $implementation{nameSpaceWebCore}->add($code);
4133 } 4360 }
4134 4361
4362 ### working
4135 if (!HasCustomConstructor($interface)) { 4363 if (!HasCustomConstructor($interface)) {
4136 if ($interface->extendedAttributes->{"NamedConstructor"}) { 4364 if ($interface->extendedAttributes->{"NamedConstructor"}) {
4365 ### DONE
4137 GenerateNamedConstructor(@{$interface->constructors}[0], $interface) ; 4366 GenerateNamedConstructor(@{$interface->constructors}[0], $interface) ;
4138 } elsif ($interface->extendedAttributes->{"Constructor"}) { 4367 } elsif ($interface->extendedAttributes->{"Constructor"}) {
4368 ### DONE
4139 GenerateConstructor($interface); 4369 GenerateConstructor($interface);
4140 } elsif (IsConstructorTemplate($interface, "Event")) { 4370 } elsif (IsConstructorTemplate($interface, "Event")) {
4371 ### TODO
4141 GenerateEventConstructor($interface); 4372 GenerateEventConstructor($interface);
4142 } 4373 }
4143 } 4374 }
4144 if (IsConstructable($interface)) { 4375 if (IsConstructable($interface)) {
4376 ### DONE
4145 GenerateConstructorCallback($interface); 4377 GenerateConstructorCallback($interface);
4146 } 4378 }
4147 4379
4380 ### DONE
4148 my $access_check = ""; 4381 my $access_check = "";
4149 if ($interface->extendedAttributes->{"CheckSecurity"} && $interfaceName ne " Window") { 4382 if ($interface->extendedAttributes->{"CheckSecurity"} && $interfaceName ne " Window") {
4150 $access_check = "instance->SetAccessCheckCallbacks(${implClassName}V8Int ernal::namedSecurityCheck, ${implClassName}V8Internal::indexedSecurityCheck, v8: :External::New(&${v8ClassName}::info));"; 4383 $access_check = "instance->SetAccessCheckCallbacks(${implClassName}V8Int ernal::namedSecurityCheck, ${implClassName}V8Internal::indexedSecurityCheck, v8: :External::New(&${v8ClassName}::info));";
4151 } 4384 }
4152 4385
4386 ### TODO
4153 # For the Window interface, generate the shadow object template 4387 # For the Window interface, generate the shadow object template
4154 # configuration method. 4388 # configuration method.
4155 if ($interfaceName eq "Window") { 4389 if ($interfaceName eq "Window") {
4156 $implementation{nameSpaceWebCore}->add(<<END); 4390 $implementation{nameSpaceWebCore}->add(<<END);
4157 static void ConfigureShadowObjectTemplate(v8::Handle<v8::ObjectTemplate> templ, v8::Isolate* isolate, WrapperWorldType currentWorldType) 4391 static void ConfigureShadowObjectTemplate(v8::Handle<v8::ObjectTemplate> templ, v8::Isolate* isolate, WrapperWorldType currentWorldType)
4158 { 4392 {
4159 V8DOMConfiguration::batchConfigureAttributes(templ, v8::Handle<v8::ObjectTem plate>(), shadowAttrs, WTF_ARRAY_LENGTH(shadowAttrs), isolate, currentWorldType) ; 4393 V8DOMConfiguration::batchConfigureAttributes(templ, v8::Handle<v8::ObjectTem plate>(), shadowAttrs, WTF_ARRAY_LENGTH(shadowAttrs), isolate, currentWorldType) ;
4160 4394
4161 // Install a security handler with V8. 4395 // Install a security handler with V8.
4162 templ->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Window: :indexedSecurityCheckCustom, v8::External::New(&V8Window::info)); 4396 templ->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Window: :indexedSecurityCheckCustom, v8::External::New(&V8Window::info));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
4207 $code .= <<END; 4441 $code .= <<END;
4208 0, 0, isolate, currentWorldType); 4442 0, 0, isolate, currentWorldType);
4209 END 4443 END
4210 } 4444 }
4211 4445
4212 AddToImplIncludes("wtf/UnusedParam.h"); 4446 AddToImplIncludes("wtf/UnusedParam.h");
4213 $code .= <<END; 4447 $code .= <<END;
4214 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. 4448 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
4215 END 4449 END
4216 4450
4451 ### TODO
4217 if (IsConstructable($interface)) { 4452 if (IsConstructable($interface)) {
4218 $code .= " desc->SetCallHandler(${v8ClassName}::constructorCallback); \n"; 4453 $code .= " desc->SetCallHandler(${v8ClassName}::constructorCallback); \n";
4219 my $interfaceLength = GetInterfaceLength($interface); 4454 my $interfaceLength = GetInterfaceLength($interface);
4220 $code .= " desc->SetLength(${interfaceLength});\n"; 4455 $code .= " desc->SetLength(${interfaceLength});\n";
4221 } 4456 }
4222 4457
4458 ### DONE
4223 if ($access_check or @enabledAtRuntimeAttributes or @normalFunctions or $has _constants) { 4459 if ($access_check or @enabledAtRuntimeAttributes or @normalFunctions or $has _constants) {
4224 $code .= <<END; 4460 $code .= <<END;
4225 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); 4461 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
4226 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); 4462 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
4227 UNUSED_PARAM(instance); // In some cases, it will not be used. 4463 UNUSED_PARAM(instance); // In some cases, it will not be used.
4228 UNUSED_PARAM(proto); // In some cases, it will not be used. 4464 UNUSED_PARAM(proto); // In some cases, it will not be used.
4229 END 4465 END
4230 } 4466 }
4231 4467
4468 ### DONE
4232 if ($access_check) { 4469 if ($access_check) {
4233 $code .= " $access_check\n"; 4470 $code .= " $access_check\n";
4234 } 4471 }
4235 4472
4473 ### DONE
4236 # Setup the enable-at-runtime attrs if we have them 4474 # Setup the enable-at-runtime attrs if we have them
4237 foreach my $runtime_attr (@enabledAtRuntimeAttributes) { 4475 foreach my $runtime_attr (@enabledAtRuntimeAttributes) {
4238 next if grep { $_ eq $runtime_attr } @enabledPerContextAttributes; 4476 next if grep { $_ eq $runtime_attr } @enabledPerContextAttributes;
4239 my $enable_function = GetRuntimeEnableFunctionName($runtime_attr); 4477 my $enable_function = GetRuntimeEnableFunctionName($runtime_attr);
4240 my $conditionalString = GenerateConditionalString($runtime_attr); 4478 my $conditionalString = GenerateConditionalString($runtime_attr);
4241 $code .= "\n#if ${conditionalString}\n" if $conditionalString; 4479 $code .= "\n#if ${conditionalString}\n" if $conditionalString;
4242 $code .= " if (${enable_function}()) {\n"; 4480 $code .= " if (${enable_function}()) {\n";
4243 $code .= " static const V8DOMConfiguration::BatchedAttribute attr Data =\\\n"; 4481 $code .= " static const V8DOMConfiguration::BatchedAttribute attr Data =\\\n";
4244 $code .= GenerateSingleBatchedAttribute($interface, $runtime_attr, ";", " "); 4482 $code .= GenerateSingleBatchedAttribute($interface, $runtime_attr, ";", " ");
4245 $code .= <<END; 4483 $code .= <<END;
4246 V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat e, currentWorldType); 4484 V8DOMConfiguration::configureAttribute(instance, proto, attrData, isolat e, currentWorldType);
4247 } 4485 }
4248 END 4486 END
4249 $code .= "\n#endif // ${conditionalString}\n" if $conditionalString; 4487 $code .= "\n#endif // ${conditionalString}\n" if $conditionalString;
4250 } 4488 }
4251 4489
4490 ### DONE
4252 # Setup the enable-at-runtime constants if we have them 4491 # Setup the enable-at-runtime constants if we have them
4253 foreach my $runtime_const (@constantsEnabledAtRuntime) { 4492 foreach my $runtime_const (@constantsEnabledAtRuntime) {
4254 my $enable_function = GetRuntimeEnableFunctionName($runtime_const); 4493 my $enable_function = GetRuntimeEnableFunctionName($runtime_const);
4255 my $conditionalString = GenerateConditionalString($runtime_const); 4494 my $conditionalString = GenerateConditionalString($runtime_const);
4256 my $name = $runtime_const->name; 4495 my $name = $runtime_const->name;
4257 my $value = $runtime_const->value; 4496 my $value = $runtime_const->value;
4258 $code .= "\n#if ${conditionalString}\n" if $conditionalString; 4497 $code .= "\n#if ${conditionalString}\n" if $conditionalString;
4259 $code .= " if (${enable_function}()) {\n"; 4498 $code .= " if (${enable_function}()) {\n";
4260 $code .= <<END; 4499 $code .= <<END;
4261 static const V8DOMConfiguration::BatchedConstant constData = {"${name}", static_cast<signed int>(${value})}; 4500 static const V8DOMConfiguration::BatchedConstant constData = {"${name}", static_cast<signed int>(${value})};
4262 V8DOMConfiguration::batchConfigureConstants(desc, proto, &constData, 1, isolate); 4501 V8DOMConfiguration::batchConfigureConstants(desc, proto, &constData, 1, isolate);
4263 END 4502 END
4264 $code .= " }\n"; 4503 $code .= " }\n";
4265 $code .= "\n#endif // ${conditionalString}\n" if $conditionalString; 4504 $code .= "\n#endif // ${conditionalString}\n" if $conditionalString;
4266 } 4505 }
4267 4506
4507 ### TODO
4268 $code .= GenerateImplementationIndexedPropertyAccessors($interface); 4508 $code .= GenerateImplementationIndexedPropertyAccessors($interface);
4509 ### TODO
4269 $code .= GenerateImplementationNamedPropertyAccessors($interface); 4510 $code .= GenerateImplementationNamedPropertyAccessors($interface);
4511 ### TODO
4270 $code .= GenerateImplementationLegacyCall($interface); 4512 $code .= GenerateImplementationLegacyCall($interface);
4513 ### TODO
4271 $code .= GenerateImplementationMasqueradesAsUndefined($interface); 4514 $code .= GenerateImplementationMasqueradesAsUndefined($interface);
4272 4515
4273 # Define our functions with Set() or SetAccessor() 4516 # Define our functions with Set() or SetAccessor()
4274 my $total_functions = 0; 4517 my $total_functions = 0;
4275 foreach my $function (@normalFunctions) { 4518 foreach my $function (@normalFunctions) {
4276 # Only one accessor is needed for overloaded methods: 4519 # Only one accessor is needed for overloaded methods:
4277 next if $function->{overloadIndex} > 1; 4520 next if $function->{overloadIndex} > 1;
4278 next if $function->name eq ""; 4521 next if $function->name eq "";
4279 4522
4280 $total_functions++; 4523 $total_functions++;
4281 next if IsStandardFunction($interface, $function); 4524 next if IsStandardFunction($interface, $function);
4525 ### DONE
4282 $code .= GenerateNonStandardFunction($interface, $function); 4526 $code .= GenerateNonStandardFunction($interface, $function);
4283 $num_callbacks++; 4527 $num_callbacks++;
4284 } 4528 }
4285 4529
4286 die "Wrong number of callbacks generated for $interfaceName ($num_callbacks, should be $total_functions)" if $num_callbacks != $total_functions; 4530 die "Wrong number of callbacks generated for $interfaceName ($num_callbacks, should be $total_functions)" if $num_callbacks != $total_functions;
4287 4531
4532 ### DONE
4288 if ($has_constants) { 4533 if ($has_constants) {
4289 $code .= <<END; 4534 $code .= <<END;
4290 V8DOMConfiguration::batchConfigureConstants(desc, proto, ${v8ClassName}Const s, WTF_ARRAY_LENGTH(${v8ClassName}Consts), isolate); 4535 V8DOMConfiguration::batchConfigureConstants(desc, proto, ${v8ClassName}Const s, WTF_ARRAY_LENGTH(${v8ClassName}Consts), isolate);
4291 END 4536 END
4292 } 4537 }
4293 4538
4294 # Special cases 4539 # Special cases
4540 ### TODO
4295 if ($interfaceName eq "Window") { 4541 if ($interfaceName eq "Window") {
4296 $code .= <<END; 4542 $code .= <<END;
4297 4543
4298 proto->SetInternalFieldCount(V8Window::internalFieldCount); 4544 proto->SetInternalFieldCount(V8Window::internalFieldCount);
4299 desc->SetHiddenPrototype(true); 4545 desc->SetHiddenPrototype(true);
4300 instance->SetInternalFieldCount(V8Window::internalFieldCount); 4546 instance->SetInternalFieldCount(V8Window::internalFieldCount);
4301 // Set access check callbacks, but turned off initially. 4547 // Set access check callbacks, but turned off initially.
4302 // When a context is detached from a frame, turn on the access check. 4548 // When a context is detached from a frame, turn on the access check.
4303 // Turning on checks also invalidates inline caches of the object. 4549 // Turning on checks also invalidates inline caches of the object.
4304 instance->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Wind ow::indexedSecurityCheckCustom, v8::External::New(&V8Window::info), false); 4550 instance->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Wind ow::indexedSecurityCheckCustom, v8::External::New(&V8Window::info), false);
4305 END 4551 END
4306 } 4552 }
4553 ### TODO
4307 if ($interfaceName eq "HTMLDocument" or $interfaceName eq "DedicatedWorkerGl obalScope" or $interfaceName eq "SharedWorkerGlobalScope") { 4554 if ($interfaceName eq "HTMLDocument" or $interfaceName eq "DedicatedWorkerGl obalScope" or $interfaceName eq "SharedWorkerGlobalScope") {
4308 $code .= <<END; 4555 $code .= <<END;
4309 desc->SetHiddenPrototype(true); 4556 desc->SetHiddenPrototype(true);
4310 END 4557 END
4311 } 4558 }
4312 4559
4560 ### DONE
4313 $code .= <<END; 4561 $code .= <<END;
4314 4562
4315 // Custom toString template 4563 // Custom toString template
4316 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to StringTemplate()); 4564 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to StringTemplate());
4317 return desc; 4565 return desc;
4318 } 4566 }
4319 4567
4320 END 4568 END
4321 $implementation{nameSpaceWebCore}->add($code); 4569 $implementation{nameSpaceWebCore}->add($code);
4322 4570
4323 $implementation{nameSpaceWebCore}->add(<<END); 4571 $implementation{nameSpaceWebCore}->add(<<END);
4324 v8::Handle<v8::FunctionTemplate> ${v8ClassName}::GetTemplate(v8::Isolate* isolat e, WrapperWorldType currentWorldType) 4572 v8::Handle<v8::FunctionTemplate> ${v8ClassName}::GetTemplate(v8::Isolate* isolat e, WrapperWorldType currentWorldType)
4325 { 4573 {
4326 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 4574 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
4327 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&info); 4575 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&info);
4328 if (result != data->templateMap(currentWorldType).end()) 4576 if (result != data->templateMap(currentWorldType).end())
4329 return result->value.newLocal(isolate); 4577 return result->value.newLocal(isolate);
4330 4578
4331 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); 4579 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
4332 v8::HandleScope handleScope(isolate); 4580 v8::HandleScope handleScope(isolate);
4333 v8::Handle<v8::FunctionTemplate> templ = 4581 v8::Handle<v8::FunctionTemplate> templ =
4334 Configure${v8ClassName}Template(data->rawTemplate(&info, currentWorldTyp e), isolate, currentWorldType); 4582 Configure${v8ClassName}Template(data->rawTemplate(&info, currentWorldTyp e), isolate, currentWorldType);
4335 data->templateMap(currentWorldType).add(&info, UnsafePersistent<v8::Function Template>(isolate, templ)); 4583 data->templateMap(currentWorldType).add(&info, UnsafePersistent<v8::Function Template>(isolate, templ));
4336 return handleScope.Close(templ); 4584 return handleScope.Close(templ);
4337 } 4585 }
4338 4586
4339 END 4587 END
4588 ### DONE
4340 $implementation{nameSpaceWebCore}->add(<<END); 4589 $implementation{nameSpaceWebCore}->add(<<END);
4341 bool ${v8ClassName}::HasInstance(v8::Handle<v8::Value> value, v8::Isolate* isola te, WrapperWorldType currentWorldType) 4590 bool ${v8ClassName}::HasInstance(v8::Handle<v8::Value> value, v8::Isolate* isola te, WrapperWorldType currentWorldType)
4342 { 4591 {
4343 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWor ldType); 4592 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWor ldType);
4344 } 4593 }
4345 4594
4346 END 4595 END
4596 ### DONE
4347 $implementation{nameSpaceWebCore}->add(<<END); 4597 $implementation{nameSpaceWebCore}->add(<<END);
4348 bool ${v8ClassName}::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::Isol ate* isolate) 4598 bool ${v8ClassName}::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::Isol ate* isolate)
4349 { 4599 {
4350 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) 4600 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld)
4351 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo rld) 4601 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo rld)
4352 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl d); 4602 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl d);
4353 } 4603 }
4354 4604
4355 END 4605 END
4356 4606
4607 ### TODO
4357 if (@enabledPerContextAttributes) { 4608 if (@enabledPerContextAttributes) {
4358 my $code = ""; 4609 my $code = "";
4359 $code .= <<END; 4610 $code .= <<END;
4360 void ${v8ClassName}::installPerContextProperties(v8::Handle<v8::Object> instance , ${nativeType}* impl, v8::Isolate* isolate) 4611 void ${v8ClassName}::installPerContextProperties(v8::Handle<v8::Object> instance , ${nativeType}* impl, v8::Isolate* isolate)
4361 { 4612 {
4362 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto type()); 4613 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto type());
4363 END 4614 END
4364 4615
4365 # Setup the enable-by-settings attrs if we have them 4616 # Setup the enable-by-settings attrs if we have them
4366 foreach my $runtimeAttr (@enabledPerContextAttributes) { 4617 foreach my $runtimeAttr (@enabledPerContextAttributes) {
(...skipping 15 matching lines...) Expand all
4382 $code .= " }\n"; 4633 $code .= " }\n";
4383 $code .= "#endif // ${conditionalString}\n" if $conditionalString; 4634 $code .= "#endif // ${conditionalString}\n" if $conditionalString;
4384 } 4635 }
4385 $code .= <<END; 4636 $code .= <<END;
4386 } 4637 }
4387 4638
4388 END 4639 END
4389 $implementation{nameSpaceWebCore}->add($code); 4640 $implementation{nameSpaceWebCore}->add($code);
4390 } 4641 }
4391 4642
4643 ### TODO
4392 if (@enabledPerContextFunctions) { 4644 if (@enabledPerContextFunctions) {
4393 my $code = ""; 4645 my $code = "";
4394 $code .= <<END; 4646 $code .= <<END;
4395 void ${v8ClassName}::installPerContextPrototypeProperties(v8::Handle<v8::Object> proto, v8::Isolate* isolate) 4647 void ${v8ClassName}::installPerContextPrototypeProperties(v8::Handle<v8::Object> proto, v8::Isolate* isolate)
4396 { 4648 {
4397 UNUSED_PARAM(proto); 4649 UNUSED_PARAM(proto);
4398 END 4650 END
4399 # Setup the enable-by-settings functions if we have them 4651 # Setup the enable-by-settings functions if we have them
4400 $code .= <<END; 4652 $code .= <<END;
4401 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(i solate, worldType(isolate))); 4653 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(i solate, worldType(isolate)));
(...skipping 15 matching lines...) Expand all
4417 $code .= "#endif // ${conditionalString}\n" if $conditionalString; 4669 $code .= "#endif // ${conditionalString}\n" if $conditionalString;
4418 } 4670 }
4419 4671
4420 $code .= <<END; 4672 $code .= <<END;
4421 } 4673 }
4422 4674
4423 END 4675 END
4424 $implementation{nameSpaceWebCore}->add($code); 4676 $implementation{nameSpaceWebCore}->add($code);
4425 } 4677 }
4426 4678
4679 ### DONE
4427 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { 4680 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) {
4428 # MessagePort is handled like an active dom object even though it doesn' t inherit 4681 # MessagePort is handled like an active dom object even though it doesn' t inherit
4429 # from ActiveDOMObject, so don't try to cast it to ActiveDOMObject. 4682 # from ActiveDOMObject, so don't try to cast it to ActiveDOMObject.
4430 my $returnValue = $interfaceName eq "MessagePort" ? "0" : "toNative(obje ct)"; 4683 my $returnValue = $interfaceName eq "MessagePort" ? "0" : "toNative(obje ct)";
4431 $implementation{nameSpaceWebCore}->add(<<END); 4684 $implementation{nameSpaceWebCore}->add(<<END);
4432 ActiveDOMObject* ${v8ClassName}::toActiveDOMObject(v8::Handle<v8::Object> object ) 4685 ActiveDOMObject* ${v8ClassName}::toActiveDOMObject(v8::Handle<v8::Object> object )
4433 { 4686 {
4434 return $returnValue; 4687 return $returnValue;
4435 } 4688 }
4436 4689
4437 END 4690 END
4438 } 4691 }
4439 4692
4693 ### DONE
4440 if (InheritsInterface($interface, "EventTarget")) { 4694 if (InheritsInterface($interface, "EventTarget")) {
4441 $implementation{nameSpaceWebCore}->add(<<END); 4695 $implementation{nameSpaceWebCore}->add(<<END);
4442 EventTarget* ${v8ClassName}::toEventTarget(v8::Handle<v8::Object> object) 4696 EventTarget* ${v8ClassName}::toEventTarget(v8::Handle<v8::Object> object)
4443 { 4697 {
4444 return toNative(object); 4698 return toNative(object);
4445 } 4699 }
4446 4700
4447 END 4701 END
4448 } 4702 }
4449 4703
4704 ### TODO
4450 if ($interfaceName eq "Window") { 4705 if ($interfaceName eq "Window") {
4451 $implementation{nameSpaceWebCore}->add(<<END); 4706 $implementation{nameSpaceWebCore}->add(<<END);
4452 v8::Handle<v8::ObjectTemplate> V8Window::GetShadowObjectTemplate(v8::Isolate* is olate, WrapperWorldType currentWorldType) 4707 v8::Handle<v8::ObjectTemplate> V8Window::GetShadowObjectTemplate(v8::Isolate* is olate, WrapperWorldType currentWorldType)
4453 { 4708 {
4454 if (currentWorldType == MainWorld) { 4709 if (currentWorldType == MainWorld) {
4455 DEFINE_STATIC_LOCAL(v8::Persistent<v8::ObjectTemplate>, V8WindowShadowOb jectCacheForMainWorld, ()); 4710 DEFINE_STATIC_LOCAL(v8::Persistent<v8::ObjectTemplate>, V8WindowShadowOb jectCacheForMainWorld, ());
4456 if (V8WindowShadowObjectCacheForMainWorld.IsEmpty()) { 4711 if (V8WindowShadowObjectCacheForMainWorld.IsEmpty()) {
4457 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); 4712 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
4458 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); 4713 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New();
4459 ConfigureShadowObjectTemplate(templ, isolate, currentWorldType); 4714 ConfigureShadowObjectTemplate(templ, isolate, currentWorldType);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
4530 { 4785 {
4531 ASSERT(value->IsObject()); 4786 ASSERT(value->IsObject());
4532 ASSERT(context); 4787 ASSERT(context);
4533 return adoptRef(new ${v8ClassName}(v8::Handle<v8::Object>::Cast(value), context)); 4788 return adoptRef(new ${v8ClassName}(v8::Handle<v8::Object>::Cast(value), context));
4534 } 4789 }
4535 4790
4536 virtual ~${v8ClassName}(); 4791 virtual ~${v8ClassName}();
4537 4792
4538 END 4793 END
4539 4794
4795 #print "[CallbackHeader]", $interface->name, "\n";
4796
4540 # Functions 4797 # Functions
4541 my $numFunctions = @{$interface->functions}; 4798 my $numFunctions = @{$interface->functions};
4542 if ($numFunctions > 0) { 4799 if ($numFunctions > 0) {
4543 $header{classPublic}->add(" // Functions\n"); 4800 $header{classPublic}->add(" // Functions\n");
4544 foreach my $function (@{$interface->functions}) { 4801 foreach my $function (@{$interface->functions}) {
4545 my $code = " virtual " . GetNativeTypeForCallbacks($function->typ e) . " " . $function->name . "("; 4802 my $code = " virtual " . GetNativeTypeForCallbacks($function->typ e) . " " . $function->name . "(";
4546 4803
4547 my @args = (); 4804 my @args = ();
4548 if (ExtendedAttributeContains($function->extendedAttributes->{"CallW ith"}, "ThisValue")) { 4805 if (ExtendedAttributeContains($function->extendedAttributes->{"CallW ith"}, "ThisValue")) {
4549 push(@args, GetNativeType("any") . " thisValue"); 4806 push(@args, GetNativeType("any") . " thisValue");
4550 } 4807 }
4551 my @params = @{$function->parameters}; 4808 my @params = @{$function->parameters};
4552 foreach my $param (@params) { 4809 foreach my $param (@params) {
4810 print "[gch]", $param->name, "\n" if $interface->name eq "MIDISu ccessCallback";
4553 push(@args, GetNativeTypeForCallbacks($param->type) . " " . $par am->name); 4811 push(@args, GetNativeTypeForCallbacks($param->type) . " " . $par am->name);
4554 } 4812 }
4555 $code .= join(", ", @args); 4813 $code .= join(", ", @args);
4556 $code .= ");\n"; 4814 $code .= ");\n";
4557 $header{classPublic}->add($code); 4815 $header{classPublic}->add($code);
4558 } 4816 }
4559 } 4817 }
4560 4818
4561 $header{classPublic}->add(<<END); 4819 $header{classPublic}->add(<<END);
4562 4820
(...skipping 29 matching lines...) Expand all
4592 4850
4593 END 4851 END
4594 4852
4595 $implementation{nameSpaceWebCore}->add(<<END); 4853 $implementation{nameSpaceWebCore}->add(<<END);
4596 ${v8ClassName}::~${v8ClassName}() 4854 ${v8ClassName}::~${v8ClassName}()
4597 { 4855 {
4598 } 4856 }
4599 4857
4600 END 4858 END
4601 4859
4860 #print "[CallbackImp]", $interface->name, "\n";
4861
4602 # Functions 4862 # Functions
4603 my $numFunctions = @{$interface->functions}; 4863 my $numFunctions = @{$interface->functions};
4604 if ($numFunctions > 0) { 4864 if ($numFunctions > 0) {
4605 $implementation{nameSpaceWebCore}->add("// Functions\n"); 4865 $implementation{nameSpaceWebCore}->add("// Functions\n");
4606 foreach my $function (@{$interface->functions}) { 4866 foreach my $function (@{$interface->functions}) {
4607 my $code = ""; 4867 my $code = "";
4608 my @params = @{$function->parameters}; 4868 my @params = @{$function->parameters};
4609 next if $function->extendedAttributes->{"Custom"}; 4869 next if $function->extendedAttributes->{"Custom"};
4610 4870
4611 AddIncludesForType($function->type); 4871 AddIncludesForType($function->type);
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
4812 return $implClassName; 5072 return $implClassName;
4813 } 5073 }
4814 5074
4815 sub GetNamespaceForInterface 5075 sub GetNamespaceForInterface
4816 { 5076 {
4817 my $interface = shift; 5077 my $interface = shift;
4818 return "WTF" if IsTypedArrayType($interface->name); 5078 return "WTF" if IsTypedArrayType($interface->name);
4819 return "WebCore"; 5079 return "WebCore";
4820 } 5080 }
4821 5081
5082 # get_function_call_parameter and macro function_call in python
4822 sub GenerateFunctionCallString 5083 sub GenerateFunctionCallString
4823 { 5084 {
4824 my $function = shift; 5085 my $function = shift;
4825 my $numberOfParameters = shift; 5086 my $numberOfParameters = shift;
5087 if ($numberOfParameters != @{$function->parameters}) {
5088 # print "NEVER\n";
5089 }
4826 my $indent = shift; 5090 my $indent = shift;
4827 my $interface = shift; 5091 my $interface = shift;
4828 my $forMainWorldSuffix = shift; 5092 my $forMainWorldSuffix = shift;
4829 my %replacements = @_; 5093 my %replacements = @_;
4830 5094
4831 my $interfaceName = $interface->name; 5095 my $interfaceName = $interface->name;
4832 my $implClassName = GetImplName($interface); 5096 my $implClassName = GetImplName($interface);
4833 my $name = GetImplName($function); 5097 my $name = GetImplName($function);
4834 my $returnType = $function->type; 5098 my $returnType = $function->type;
4835 my $nativeReturnType = GetNativeType($returnType, {}, ""); 5099 my $nativeReturnType = GetNativeType($returnType, {}, "");
4836 my $code = ""; 5100 my $code = "";
4837 5101
4838 my $isSVGTearOffType = (IsSVGTypeNeedingTearOff($returnType) and not $interf aceName =~ /List$/); 5102 my $isSVGTearOffType = (IsSVGTypeNeedingTearOff($returnType) and not $interf aceName =~ /List$/);
4839 $nativeReturnType = GetSVGWrappedTypeNeedingTearOff($returnType) if $isSVGTe arOffType; 5103 $nativeReturnType = GetSVGWrappedTypeNeedingTearOff($returnType) if $isSVGTe arOffType;
4840 5104
4841 my $index = 0; 5105 my $index = 0;
4842 5106
4843 my @arguments; 5107 my @arguments;
4844 my $functionName; 5108 my $functionName;
4845 my $implementedBy = $function->extendedAttributes->{"ImplementedBy"}; 5109 my $implementedBy = $function->extendedAttributes->{"ImplementedBy"};
4846 if ($implementedBy) { 5110 if ($implementedBy) {
5111 ### DONE
4847 my $implementedByImplName = GetImplNameFromImplementedBy($implementedBy) ; 5112 my $implementedByImplName = GetImplNameFromImplementedBy($implementedBy) ;
4848 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implementedBy ImplName)); 5113 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implementedBy ImplName));
4849 unshift(@arguments, "imp") if !$function->isStatic; 5114 unshift(@arguments, "imp") if !$function->isStatic;
4850 $functionName = "${implementedByImplName}::${name}"; 5115 $functionName = "${implementedByImplName}::${name}";
4851 } elsif ($function->isStatic) { 5116 } elsif ($function->isStatic) {
5117 ### DONE
4852 $functionName = "${implClassName}::${name}"; 5118 $functionName = "${implClassName}::${name}";
4853 } else { 5119 } else {
5120 ### DONE
4854 $functionName = "imp->${name}"; 5121 $functionName = "imp->${name}";
4855 } 5122 }
4856 5123
5124 ### DONE
4857 my $callWith = $function->extendedAttributes->{"CallWith"}; 5125 my $callWith = $function->extendedAttributes->{"CallWith"};
4858 my ($callWithArgs, $subCode) = GenerateCallWith($callWith, $indent, 1, $func tion); 5126 my ($callWithArgs, $subCode) = GenerateCallWith($callWith, $indent, 1, $func tion);
4859 $code .= $subCode; 5127 $code .= $subCode;
4860 unshift(@arguments, @$callWithArgs); 5128 unshift(@arguments, @$callWithArgs);
4861 $index += @$callWithArgs; 5129 # $index += @$callWithArgs;
4862 $numberOfParameters += @$callWithArgs; 5130 # $numberOfParameters += @$callWithArgs;
4863 5131
4864 foreach my $parameter (@{$function->parameters}) { 5132 foreach my $parameter (@{$function->parameters}) {
5133 ### DONE
4865 if ($index eq $numberOfParameters) { 5134 if ($index eq $numberOfParameters) {
4866 last; 5135 last;
4867 } 5136 }
4868 my $paramName = $parameter->name; 5137 my $paramName = $parameter->name;
4869 my $paramType = $parameter->type; 5138 my $paramType = $parameter->type;
4870 5139
4871 if ($replacements{$paramName}) { 5140 if ($replacements{$paramName}) {
5141 ### DONE
4872 push @arguments, $replacements{$paramName}; 5142 push @arguments, $replacements{$paramName};
4873 } elsif ($parameter->type eq "NodeFilter" || $parameter->type eq "XPathN SResolver") { 5143 } elsif ($parameter->type eq "NodeFilter" || $parameter->type eq "XPathN SResolver") {
5144 ### DONE
4874 push @arguments, "$paramName.get()"; 5145 push @arguments, "$paramName.get()";
4875 } elsif (IsSVGTypeNeedingTearOff($parameter->type) and not $interfaceNam e =~ /List$/) { 5146 } elsif (IsSVGTypeNeedingTearOff($parameter->type) and not $interfaceNam e =~ /List$/) {
5147 ### DONE
4876 AddToImplIncludes("core/dom/ExceptionCode.h"); 5148 AddToImplIncludes("core/dom/ExceptionCode.h");
4877 push @arguments, "$paramName->propertyReference()"; 5149 push @arguments, "$paramName->propertyReference()";
4878 $code .= $indent . "if (!$paramName) {\n"; 5150 $code .= $indent . "if (!$paramName) {\n";
4879 $code .= $indent . " setDOMException(WebCore::TypeMismatchError, args.GetIsolate());\n"; 5151 $code .= $indent . " setDOMException(WebCore::TypeMismatchError, args.GetIsolate());\n";
4880 $code .= $indent . " return;\n"; 5152 $code .= $indent . " return;\n";
4881 $code .= $indent . "}\n"; 5153 $code .= $indent . "}\n";
4882 } elsif ($parameter->type eq "SVGMatrix" and $interfaceName eq "SVGTrans formList") { 5154 } elsif ($parameter->type eq "SVGMatrix" and $interfaceName eq "SVGTrans formList") {
5155 ### DONE
4883 push @arguments, "$paramName.get()"; 5156 push @arguments, "$paramName.get()";
4884 } else { 5157 } else {
5158 ### main
4885 push @arguments, $paramName; 5159 push @arguments, $paramName;
4886 } 5160 }
4887 $index++; 5161 $index++;
4888 } 5162 }
4889 5163
5164 ### DONE
4890 if ($function->extendedAttributes->{"RaisesException"}) { 5165 if ($function->extendedAttributes->{"RaisesException"}) {
4891 push @arguments, "es"; 5166 push @arguments, "es";
4892 } 5167 }
4893 5168
5169 ### DONE
5170 ### function_call_expression in python
4894 my $functionString = "$functionName(" . join(", ", @arguments) . ")"; 5171 my $functionString = "$functionName(" . join(", ", @arguments) . ")";
4895 5172
5173 ### DONE native_value_expression in python
4896 my $return = "result"; 5174 my $return = "result";
4897 my $returnIsRef = IsRefPtrType($returnType); 5175 my $returnIsRef = IsRefPtrType($returnType);
4898 5176
4899 if ($returnType eq "void") { 5177 if ($returnType eq "void") {
5178 ### DONE
5179 ### function_call_statement in python generator
4900 $code .= $indent . "$functionString;\n"; 5180 $code .= $indent . "$functionString;\n";
4901 } elsif (ExtendedAttributeContains($callWith, "ScriptState") or $function->e xtendedAttributes->{"RaisesException"}) { 5181 } elsif (ExtendedAttributeContains($callWith, "ScriptState") or $function->e xtendedAttributes->{"RaisesException"}) {
5182 ### DONE
5183 ### function_call_statement in python generator
4902 $code .= $indent . $nativeReturnType . " result = $functionString;\n"; 5184 $code .= $indent . $nativeReturnType . " result = $functionString;\n";
4903 } else { 5185 } else {
5186 ### DONE
4904 # Can inline the function call into the return statement to avoid overhe ad of using a Ref<> temporary 5187 # Can inline the function call into the return statement to avoid overhe ad of using a Ref<> temporary
4905 $return = $functionString; 5188 $return = $functionString;
4906 $returnIsRef = 0; 5189 $returnIsRef = 0;
4907 5190
5191 ### TODO
4908 if ($interfaceName eq "SVGTransformList" and IsRefPtrType($returnType)) { 5192 if ($interfaceName eq "SVGTransformList" and IsRefPtrType($returnType)) {
4909 $return = "WTF::getPtr(" . $return . ")"; 5193 $return = "WTF::getPtr(" . $return . ")";
4910 } 5194 }
4911 } 5195 }
4912 5196
5197 ### DONE
4913 if ($function->extendedAttributes->{"RaisesException"}) { 5198 if ($function->extendedAttributes->{"RaisesException"}) {
4914 $code .= $indent . "if (es.throwIfNeeded())\n"; 5199 $code .= $indent . "if (es.throwIfNeeded())\n";
4915 $code .= $indent . " return;\n"; 5200 $code .= $indent . " return;\n";
4916 } 5201 }
4917 5202
5203 ### DONE
4918 if (ExtendedAttributeContains($callWith, "ScriptState")) { 5204 if (ExtendedAttributeContains($callWith, "ScriptState")) {
4919 $code .= $indent . "if (state.hadException()) {\n"; 5205 $code .= $indent . "if (state.hadException()) {\n";
4920 $code .= $indent . " v8::Local<v8::Value> exception = state.exception ();\n"; 5206 $code .= $indent . " v8::Local<v8::Value> exception = state.exception ();\n";
4921 $code .= $indent . " state.clearException();\n"; 5207 $code .= $indent . " state.clearException();\n";
4922 $code .= $indent . " throwError(exception);\n"; 5208 $code .= $indent . " throwError(exception);\n";
4923 $code .= $indent . " return;\n"; 5209 $code .= $indent . " return;\n";
4924 $code .= $indent . "}\n"; 5210 $code .= $indent . "}\n";
4925 } 5211 }
4926 5212
5213 ### TODO
4927 if ($isSVGTearOffType) { 5214 if ($isSVGTearOffType) {
4928 AddToImplIncludes("V8$returnType.h"); 5215 AddToImplIncludes("V8$returnType.h");
4929 AddToImplIncludes("core/svg/properties/SVGPropertyTearOff.h"); 5216 AddToImplIncludes("core/svg/properties/SVGPropertyTearOff.h");
4930 my $svgNativeType = GetSVGTypeNeedingTearOff($returnType); 5217 my $svgNativeType = GetSVGTypeNeedingTearOff($returnType);
4931 # FIXME: Update for all ScriptWrappables. 5218 # FIXME: Update for all ScriptWrappables.
4932 if (IsDOMNodeType($interfaceName)) { 5219 if (IsDOMNodeType($interfaceName)) {
4933 if ($forMainWorldSuffix eq "ForMainWorld") { 5220 if ($forMainWorldSuffix eq "ForMainWorld") {
4934 $code .= $indent . "v8SetReturnValue(args, toV8ForMainWorld(WTF: :getPtr(${svgNativeType}::create($return)), args.Holder(), args.GetIsolate()));\ n"; 5221 $code .= $indent . "v8SetReturnValue(args, toV8ForMainWorld(WTF: :getPtr(${svgNativeType}::create($return)), args.Holder(), args.GetIsolate()));\ n";
4935 } else { 5222 } else {
4936 $code .= $indent . "v8SetReturnValue(args, toV8Fast(WTF::getPtr( ${svgNativeType}::create($return)), args, imp));\n"; 5223 $code .= $indent . "v8SetReturnValue(args, toV8Fast(WTF::getPtr( ${svgNativeType}::create($return)), args, imp));\n";
4937 } 5224 }
4938 } else { 5225 } else {
4939 $code .= $indent . "v8SetReturnValue(args, toV8${forMainWorldSuffix} (WTF::getPtr(${svgNativeType}::create($return)), args.Holder(), args.GetIsolate( )));\n"; 5226 $code .= $indent . "v8SetReturnValue(args, toV8${forMainWorldSuffix} (WTF::getPtr(${svgNativeType}::create($return)), args.Holder(), args.GetIsolate( )));\n";
4940 } 5227 }
4941 $code .= $indent . "return;\n"; 5228 $code .= $indent . "return;\n";
4942 return $code; 5229 return $code;
4943 } 5230 }
4944 5231
5232 ### TODO
4945 # If the implementing class is a POD type, commit changes 5233 # If the implementing class is a POD type, commit changes
4946 if (IsSVGTypeNeedingTearOff($interfaceName) and not $interfaceName =~ /List$ /) { 5234 if (IsSVGTypeNeedingTearOff($interfaceName) and not $interfaceName =~ /List$ /) {
4947 $code .= $indent . "wrapper->commitChange();\n"; 5235 $code .= $indent . "wrapper->commitChange();\n";
4948 } 5236 }
4949 5237
5238 ### DONE
4950 $return .= ".release()" if ($returnIsRef); 5239 $return .= ".release()" if ($returnIsRef);
4951 5240
4952 my $nativeValue; 5241 my $nativeValue;
4953 # FIXME: Update for all ScriptWrappables. 5242 # FIXME: Update for all ScriptWrappables.
4954 if (IsDOMNodeType($interfaceName)) { 5243 if (IsDOMNodeType($interfaceName)) {
5244 ### DONE
4955 $nativeValue = NativeToJSValue($function->type, $function->extendedAttri butes, $return, $indent, "", "args.Holder()", "args.GetIsolate()", "args", "imp" , $forMainWorldSuffix, "return"); 5245 $nativeValue = NativeToJSValue($function->type, $function->extendedAttri butes, $return, $indent, "", "args.Holder()", "args.GetIsolate()", "args", "imp" , $forMainWorldSuffix, "return");
4956 } else { 5246 } else {
5247 ### DONE
4957 $nativeValue = NativeToJSValue($function->type, $function->extendedAttri butes, $return, $indent, "", "args.Holder()", "args.GetIsolate()", "args", 0, $f orMainWorldSuffix, "return"); 5248 $nativeValue = NativeToJSValue($function->type, $function->extendedAttri butes, $return, $indent, "", "args.Holder()", "args.GetIsolate()", "args", 0, $f orMainWorldSuffix, "return");
4958 } 5249 }
4959 5250
5251 ### DONE
4960 $code .= $nativeValue . "\n"; 5252 $code .= $nativeValue . "\n";
4961 $code .= $indent . "return;\n"; 5253 $code .= $indent . "return;\n";
4962 5254
4963 return $code; 5255 return $code;
4964 } 5256 }
4965 5257
4966 sub GetNativeType 5258 sub GetNativeType
4967 { 5259 {
4968 my $type = shift; 5260 my $type = shift;
4969 my $extendedAttributes = shift; 5261 my $extendedAttributes = shift;
4970 my $isParameter = shift; 5262 my $isParameter = shift;
5263 my $isw = IsWrapperType($type) ? "WT":"";
5264 print "[GetNativeType] $type, $isParameter $isw\n";
4971 5265
4972 my $svgNativeType = GetSVGTypeNeedingTearOff($type); 5266 my $svgNativeType = GetSVGTypeNeedingTearOff($type);
4973 if ($svgNativeType) { 5267 if ($svgNativeType) {
4974 if ($svgNativeType =~ /List$/) { 5268 if ($svgNativeType =~ /List$/) {
4975 return "${svgNativeType}*"; 5269 return "${svgNativeType}*";
4976 } else { 5270 } else {
4977 return "RefPtr<${svgNativeType} >"; 5271 return "RefPtr<${svgNativeType} >";
4978 } 5272 }
4979 } 5273 }
4980 5274
(...skipping 19 matching lines...) Expand all
5000 $mode = "WithUndefinedOrNullCheck"; 5294 $mode = "WithUndefinedOrNullCheck";
5001 } elsif (($extendedAttributes->{"TreatNullAs"} and $extendedAttributes-> {"TreatNullAs"} eq "NullString") or $extendedAttributes->{"Reflect"}) { 5295 } elsif (($extendedAttributes->{"TreatNullAs"} and $extendedAttributes-> {"TreatNullAs"} eq "NullString") or $extendedAttributes->{"Reflect"}) {
5002 $mode = "WithNullCheck"; 5296 $mode = "WithNullCheck";
5003 } 5297 }
5004 # FIXME: Add the case for 'elsif ($attributeOrParameter->extendedAttribu tes->{"TreatUndefinedAs"} and $attributeOrParameter->extendedAttributes->{"Treat UndefinedAs"} eq "NullString"))'. 5298 # FIXME: Add the case for 'elsif ($attributeOrParameter->extendedAttribu tes->{"TreatUndefinedAs"} and $attributeOrParameter->extendedAttributes->{"Treat UndefinedAs"} eq "NullString"))'.
5005 return "V8StringResource<$mode>"; 5299 return "V8StringResource<$mode>";
5006 } 5300 }
5007 5301
5008 return "String" if $type eq "DOMString" or IsEnumType($type); 5302 return "String" if $type eq "DOMString" or IsEnumType($type);
5009 5303
5304 ### DONE
5010 return "Range::CompareHow" if $type eq "CompareHow"; 5305 return "Range::CompareHow" if $type eq "CompareHow";
5011 return "DOMTimeStamp" if $type eq "DOMTimeStamp"; 5306 return "DOMTimeStamp" if $type eq "DOMTimeStamp";
5012 return "double" if $type eq "Date"; 5307 return "double" if $type eq "Date";
5013 return "ScriptValue" if $type eq "any" or IsCallbackFunctionType($type); 5308 return "ScriptValue" if $type eq "any" or IsCallbackFunctionType($type);
5014 return "Dictionary" if $type eq "Dictionary"; 5309 return "Dictionary" if $type eq "Dictionary";
5015 5310
5016 return "RefPtr<DOMStringList>" if $type eq "DOMStringList"; 5311 return "RefPtr<DOMStringList>" if $type eq "DOMStringList";
5017 return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener" ; 5312 return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener" ;
5018 return "RefPtr<NodeFilter>" if $type eq "NodeFilter"; 5313 return "RefPtr<NodeFilter>" if $type eq "NodeFilter";
5019 return "RefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue"; 5314 return "RefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue";
5020 return "RefPtr<XPathNSResolver>" if $type eq "XPathNSResolver"; 5315 return "RefPtr<XPathNSResolver>" if $type eq "XPathNSResolver";
5021 5316
5022 die "UnionType is not supported" if IsUnionType($type); 5317 die "UnionType is not supported" if IsUnionType($type);
5023 5318
5024 if (IsTypedArrayType($type)) { 5319 if (IsTypedArrayType($type)) {
5025 return $isParameter ? "${type}*" : "RefPtr<${type}>"; 5320 return $isParameter ? "${type}*" : "RefPtr<${type}>";
5026 } 5321 }
5027 5322
5028 # We need to check [ImplementedAs] extended attribute for wrapper types. 5323 # We need to check [ImplementedAs] extended attribute for wrapper types.
5029 if (IsWrapperType($type)) { 5324 if (IsWrapperType($type)) {
5325 # print "GEHEHE ", $type, "\n";
5326 # use Carp qw(cluck);
5327 # cluck "HEY";
5030 my $interface = ParseInterface($type); 5328 my $interface = ParseInterface($type);
5031 my $implClassName = GetImplName($interface); 5329 my $implClassName = GetImplName($interface);
5032 return $isParameter ? "${implClassName}*" : "RefPtr<${implClassName}>"; 5330 return $isParameter ? "${implClassName}*" : "RefPtr<${implClassName}>";
5033 } 5331 }
5034 return "RefPtr<${type}>" if IsRefPtrType($type) and not $isParameter; 5332 return "RefPtr<${type}>" if IsRefPtrType($type) and not $isParameter;
5035 5333
5036 my $arrayOrSequenceType = GetArrayOrSequenceType($type); 5334 my $arrayOrSequenceType = GetArrayOrSequenceType($type);
5037 5335
5038 if ($arrayOrSequenceType) { 5336 if ($arrayOrSequenceType) {
5039 my $nativeType = GetNativeType($arrayOrSequenceType); 5337 my $nativeType = GetNativeType($arrayOrSequenceType);
5040 $nativeType .= " " if ($nativeType =~ />$/); 5338 $nativeType .= " " if ($nativeType =~ />$/);
5041 return "Vector<${nativeType}>"; 5339 return "Vector<${nativeType}>";
5042 } 5340 }
5043 5341
5044 # Default, assume native type is a pointer with same type name as idl type 5342 # Default, assume native type is a pointer with same type name as idl type
5045 return "${type}*"; 5343 return "${type}*";
5046 } 5344 }
5047 5345
5048 sub GetNativeTypeForCallbacks 5346 sub GetNativeTypeForCallbacks
5049 { 5347 {
5050 my $type = shift; 5348 my $type = shift;
5349 print "#####\n[GetNativeTypeForCallbacks] $type\n" if $type eq "DOMException ";
5350 # print "#####\n[Callback] DOMString\n" if $type eq "DOMString";
5351 # print "#####\n[Callback] SerializedScriptValue\n" if $type eq "SerializedSc riptValue";
5352
5051 return "const String&" if $type eq "DOMString"; 5353 return "const String&" if $type eq "DOMString";
5052 return "PassRefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValu e"; 5354 return "PassRefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValu e";
5053 5355
5054 # Callbacks use raw pointers, so pass isParameter = 1 5356 # Callbacks use raw pointers, so pass isParameter = 1
5055 return GetNativeType($type, {}, "parameter"); 5357 return GetNativeType($type, {}, "parameter");
5056 } 5358 }
5057 5359
5058 sub JSValueToNativeStatement 5360 sub JSValueToNativeStatement
5059 { 5361 {
5060 my $type = shift; 5362 my $type = shift;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
5168 } 5470 }
5169 return "toNativeArray<" . GetNativeType($arrayOrSequenceType) . ">($valu e, $getIsolate)"; 5471 return "toNativeArray<" . GetNativeType($arrayOrSequenceType) . ">($valu e, $getIsolate)";
5170 } 5472 }
5171 5473
5172 AddIncludesForType($type); 5474 AddIncludesForType($type);
5173 5475
5174 AddToImplIncludes("V8${type}.h"); 5476 AddToImplIncludes("V8${type}.h");
5175 return "V8${type}::HasInstance($value, $getIsolate, worldType($getIsolate)) ? V8${type}::toNative(v8::Handle<v8::Object>::Cast($value)) : 0"; 5477 return "V8${type}::HasInstance($value, $getIsolate, worldType($getIsolate)) ? V8${type}::toNative(v8::Handle<v8::Object>::Cast($value)) : 0";
5176 } 5478 }
5177 5479
5480 ### DONE
5178 sub CreateCustomSignature 5481 sub CreateCustomSignature
5179 { 5482 {
5180 my $function = shift; 5483 my $function = shift;
5181 my $count = @{$function->parameters}; 5484 my $count = @{$function->parameters};
5182 my $name = $function->name; 5485 my $name = $function->name;
5183 my $code = " const int ${name}Argc = ${count};\n" . 5486 my $code = " const int ${name}Argc = ${count};\n" .
5184 " v8::Handle<v8::FunctionTemplate> ${name}Argv[${name}Argc] = { "; 5487 " v8::Handle<v8::FunctionTemplate> ${name}Argv[${name}Argc] = { ";
5185 my $first = 1; 5488 my $first = 1;
5186 foreach my $parameter (@{$function->parameters}) { 5489 foreach my $parameter (@{$function->parameters}) {
5187 if ($first) { $first = 0; } 5490 if ($first) { $first = 0; }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
5337 my $getIsolate = shift; 5640 my $getIsolate = shift;
5338 die "An Isolate is mandatory for native value => JS value conversion." unles s $getIsolate; 5641 die "An Isolate is mandatory for native value => JS value conversion." unles s $getIsolate;
5339 my $getCallbackInfo = shift || ""; 5642 my $getCallbackInfo = shift || "";
5340 my $getCallbackInfoArg = $getCallbackInfo ? ", $getCallbackInfo" : ""; 5643 my $getCallbackInfoArg = $getCallbackInfo ? ", $getCallbackInfo" : "";
5341 my $getScriptWrappable = shift || ""; 5644 my $getScriptWrappable = shift || "";
5342 my $getScriptWrappableArg = $getScriptWrappable ? ", $getScriptWrappable" : ""; 5645 my $getScriptWrappableArg = $getScriptWrappable ? ", $getScriptWrappable" : "";
5343 my $forMainWorldSuffix = shift || ""; 5646 my $forMainWorldSuffix = shift || "";
5344 my $returnValueArg = shift || 0; 5647 my $returnValueArg = shift || 0;
5345 my $isReturnValue = $returnValueArg eq "return"; 5648 my $isReturnValue = $returnValueArg eq "return";
5346 5649
5650 print " [NativeToJSValue]", $type, " ", $nativeValue, "\n";
5651 # if $type eq "AudioBuffer";
5652
5347 if (IsUnionType($type)) { 5653 if (IsUnionType($type)) {
5348 my $types = $type->unionMemberTypes; 5654 my $types = $type->unionMemberTypes;
5349 my @codes = (); 5655 my @codes = ();
5350 for my $i (0 .. scalar(@$types)-1) { 5656 for my $i (0 .. scalar(@$types)-1) {
5351 my $unionMemberType = $types->[$i]; 5657 my $unionMemberType = $types->[$i];
5352 my $unionMemberNumber = $i + 1; 5658 my $unionMemberNumber = $i + 1;
5353 my $unionMemberVariable = $nativeValue . $i; 5659 my $unionMemberVariable = $nativeValue . $i;
5354 my $unionMemberEnabledVariable = $nativeValue . $i . "Enabled"; 5660 my $unionMemberEnabledVariable = $nativeValue . $i . "Enabled";
5355 my $unionMemberNativeValue = $unionMemberVariable; 5661 my $unionMemberNativeValue = $unionMemberVariable;
5356 $unionMemberNativeValue .= ".release()" if (IsRefPtrType($unionMembe rType)); 5662 $unionMemberNativeValue .= ".release()" if (IsRefPtrType($unionMembe rType));
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
5458 if ($arrayOrSequenceType) { 5764 if ($arrayOrSequenceType) {
5459 if (IsRefPtrType($arrayOrSequenceType)) { 5765 if (IsRefPtrType($arrayOrSequenceType)) {
5460 AddIncludesForType($arrayOrSequenceType); 5766 AddIncludesForType($arrayOrSequenceType);
5461 } 5767 }
5462 return "${indent}v8SetReturnValue(${getCallbackInfo}, v8Array($nativeVal ue, $getIsolate));" if $isReturnValue; 5768 return "${indent}v8SetReturnValue(${getCallbackInfo}, v8Array($nativeVal ue, $getIsolate));" if $isReturnValue;
5463 return "$indent$receiver v8Array($nativeValue, $getIsolate);"; 5769 return "$indent$receiver v8Array($nativeValue, $getIsolate);";
5464 } 5770 }
5465 5771
5466 AddIncludesForType($type); 5772 AddIncludesForType($type);
5467 5773
5774 ### DONE
5468 if ($type eq "SerializedScriptValue") { 5775 if ($type eq "SerializedScriptValue") {
5469 my $returnValue = "$nativeValue ? $nativeValue->deserialize() : v8::Hand le<v8::Value>(v8::Null($getIsolate))"; 5776 my $returnValue = "$nativeValue ? $nativeValue->deserialize() : v8::Hand le<v8::Value>(v8::Null($getIsolate))";
5470 return "${indent}v8SetReturnValue(${getCallbackInfo}, $returnValue);" if $isReturnValue; 5777 return "${indent}v8SetReturnValue(${getCallbackInfo}, $returnValue);" if $isReturnValue;
5471 return "$indent$receiver $returnValue;"; 5778 return "$indent$receiver $returnValue;";
5472 } 5779 }
5473 5780
5474 AddToImplIncludes("wtf/RefPtr.h"); 5781 AddToImplIncludes("wtf/RefPtr.h");
5475 AddToImplIncludes("wtf/GetPtr.h"); 5782 AddToImplIncludes("wtf/GetPtr.h");
5476 5783
5477 if ($getScriptWrappable) { 5784 if ($getScriptWrappable) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
5582 } 5889 }
5583 open FH, ">", $fileName or die "Couldn't open $fileName: $!\n"; 5890 open FH, ">", $fileName or die "Couldn't open $fileName: $!\n";
5584 print FH $contents; 5891 print FH $contents;
5585 close FH; 5892 close FH;
5586 } 5893 }
5587 5894
5588 sub ForAllParents 5895 sub ForAllParents
5589 { 5896 {
5590 my $interface = shift; 5897 my $interface = shift;
5591 my $beforeRecursion = shift; 5898 my $beforeRecursion = shift;
5592 my $afterRecursion = shift; 5899 my $afterRecursion = shift; # nbarth: ?
5593 5900
5594 my $recurse; 5901 my $recurse;
5595 $recurse = sub { 5902 $recurse = sub {
5596 my $currentInterface = shift; 5903 my $currentInterface = shift;
5597 5904
5598 if ($currentInterface->parent) { 5905 if ($currentInterface->parent) {
5599 my $parentInterface = ParseInterface($currentInterface->parent); 5906 my $parentInterface = ParseInterface($currentInterface->parent);
5600 if ($beforeRecursion) { 5907 if ($beforeRecursion) {
5601 &$beforeRecursion($parentInterface) eq 'prune' and return; 5908 &$beforeRecursion($parentInterface) eq 'prune' and return;
5602 } 5909 }
5603 &$recurse($parentInterface); 5910 &$recurse($parentInterface);
5604 &$afterRecursion($parentInterface) if $afterRecursion; 5911 &$afterRecursion($parentInterface) if $afterRecursion; # nbarth: ?
5605 } 5912 }
5606 }; 5913 };
5607 5914
5608 &$recurse($interface); 5915 &$recurse($interface);
5609 } 5916 }
5610 5917
5611 sub FindSuperMethod 5918 sub FindSuperMethod
5612 { 5919 {
5613 my ($interface, $functionName) = @_; 5920 my ($interface, $functionName) = @_;
5614 my $indexer; 5921 my $indexer;
5615 ForAllParents($interface, undef, sub { 5922 ForAllParents($interface, undef, sub { # nbarth: (undef) ?
5616 my $currentInterface = shift; 5923 my $currentInterface = shift;
5617 foreach my $function (@{$currentInterface->functions}) { 5924 foreach my $function (@{$currentInterface->functions}) {
5618 if ($function->name eq $functionName) { 5925 if ($function->name eq $functionName) {
5619 $indexer = $function; 5926 $indexer = $function;
5620 return 'prune'; 5927 return 'prune';
5621 } 5928 }
5622 } 5929 }
5623 }); 5930 });
5624 return $indexer; 5931 return $indexer;
5625 } 5932 }
(...skipping 30 matching lines...) Expand all
5656 return 0; 5963 return 0;
5657 } 5964 }
5658 5965
5659 sub ValidEnumValues 5966 sub ValidEnumValues
5660 { 5967 {
5661 my $type = shift; 5968 my $type = shift;
5662 5969
5663 return @{$enumTypeHash{$type}}; 5970 return @{$enumTypeHash{$type}};
5664 } 5971 }
5665 5972
5973
5974 # merged with GetSVGTypeNeedingTearOff
5666 sub IsSVGTypeNeedingTearOff 5975 sub IsSVGTypeNeedingTearOff
5667 { 5976 {
5668 my $type = shift; 5977 my $type = shift;
5669 5978
5670 return 1 if $svgTypeNeedingTearOff{$type}; 5979 return 1 if $svgTypeNeedingTearOff{$type};
5671 return 0; 5980 return 0;
5672 } 5981 }
5673 5982
5983 ### DONE
5674 sub IsSVGTypeWithWritablePropertiesNeedingTearOff 5984 sub IsSVGTypeWithWritablePropertiesNeedingTearOff
5675 { 5985 {
5676 my $type = shift; 5986 my $type = shift;
5677 5987
5678 return 1 if $svgTypeWithWritablePropertiesNeedingTearOff{$type}; 5988 return 1 if $svgTypeWithWritablePropertiesNeedingTearOff{$type};
5679 return 0; 5989 return 0;
5680 } 5990 }
5681 5991
5682 sub IsTypedArrayType 5992 sub IsTypedArrayType
5683 { 5993 {
(...skipping 11 matching lines...) Expand all
5695 return 0 if GetArrayType($type); 6005 return 0 if GetArrayType($type);
5696 return 0 if GetSequenceType($type); 6006 return 0 if GetSequenceType($type);
5697 return 0 if $type eq "DOMString"; 6007 return 0 if $type eq "DOMString";
5698 return 0 if IsCallbackFunctionType($type); 6008 return 0 if IsCallbackFunctionType($type);
5699 return 0 if IsEnumType($type); 6009 return 0 if IsEnumType($type);
5700 return 0 if IsUnionType($type); 6010 return 0 if IsUnionType($type);
5701 6011
5702 return 1; 6012 return 1;
5703 } 6013 }
5704 6014
6015 ### DONE
5705 sub GetSVGTypeNeedingTearOff 6016 sub GetSVGTypeNeedingTearOff
5706 { 6017 {
5707 my $type = shift; 6018 my $type = shift;
5708 6019
5709 return $svgTypeNeedingTearOff{$type} if exists $svgTypeNeedingTearOff{$type} ; 6020 return $svgTypeNeedingTearOff{$type} if exists $svgTypeNeedingTearOff{$type} ;
5710 return undef; 6021 return undef;
5711 } 6022 }
5712 6023
6024 ### DONE
5713 sub GetSVGWrappedTypeNeedingTearOff 6025 sub GetSVGWrappedTypeNeedingTearOff
5714 { 6026 {
5715 my $type = shift; 6027 my $type = shift;
5716 6028
5717 my $svgTypeNeedingTearOff = GetSVGTypeNeedingTearOff($type); 6029 my $svgTypeNeedingTearOff = GetSVGTypeNeedingTearOff($type);
5718 return $svgTypeNeedingTearOff if not $svgTypeNeedingTearOff; 6030 return $svgTypeNeedingTearOff if not $svgTypeNeedingTearOff;
5719 6031
5720 if ($svgTypeNeedingTearOff =~ /SVGPropertyTearOff/) { 6032 if ($svgTypeNeedingTearOff =~ /SVGPropertyTearOff/) {
5721 $svgTypeNeedingTearOff =~ s/SVGPropertyTearOff<//; 6033 $svgTypeNeedingTearOff =~ s/SVGPropertyTearOff<//;
5722 } elsif ($svgTypeNeedingTearOff =~ /SVGListPropertyTearOff/) { 6034 } elsif ($svgTypeNeedingTearOff =~ /SVGListPropertyTearOff/) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
5772 my $param = shift; 6084 my $param = shift;
5773 my $ret = ucfirst($param); 6085 my $ret = ucfirst($param);
5774 # xmlEncoding becomes XMLEncoding, but xmlllang becomes Xmllang. 6086 # xmlEncoding becomes XMLEncoding, but xmlllang becomes Xmllang.
5775 $ret =~ s/Xml/XML/ if $ret =~ /^Xml[^a-z]/; 6087 $ret =~ s/Xml/XML/ if $ret =~ /^Xml[^a-z]/;
5776 $ret =~ s/Css/CSS/ if $ret =~ /^Css[^T]/; # css -> setCSS, except setCssTex t. 6088 $ret =~ s/Css/CSS/ if $ret =~ /^Css[^T]/; # css -> setCSS, except setCssTex t.
5777 $ret =~ s/Ime/IME/ if $ret =~ /^Ime/; # ime -> setIME 6089 $ret =~ s/Ime/IME/ if $ret =~ /^Ime/; # ime -> setIME
5778 $ret =~ s/Svg/SVG/ if $ret =~ /^Svg/; # svg -> setSVG 6090 $ret =~ s/Svg/SVG/ if $ret =~ /^Svg/; # svg -> setSVG
5779 return $ret; 6091 return $ret;
5780 } 6092 }
5781 6093
6094 ### DONE
5782 # URL becomes url, but SetURL becomes setURL. 6095 # URL becomes url, but SetURL becomes setURL.
5783 sub ToMethodName 6096 sub ToMethodName
5784 { 6097 {
5785 my $param = shift; 6098 my $param = shift;
5786 my $ret = lcfirst($param); 6099 my $ret = lcfirst($param);
5787 $ret =~ s/hTML/html/ if $ret =~ /^hTML/; 6100 $ret =~ s/hTML/html/ if $ret =~ /^hTML/;
5788 $ret =~ s/uRL/url/ if $ret =~ /^uRL/; 6101 $ret =~ s/uRL/url/ if $ret =~ /^uRL/;
5789 $ret =~ s/jS/js/ if $ret =~ /^jS/; 6102 $ret =~ s/jS/js/ if $ret =~ /^jS/;
5790 $ret =~ s/xML/xml/ if $ret =~ /^xML/; 6103 $ret =~ s/xML/xml/ if $ret =~ /^xML/;
5791 $ret =~ s/xSLT/xslt/ if $ret =~ /^xSLT/; 6104 $ret =~ s/xSLT/xslt/ if $ret =~ /^xSLT/;
(...skipping 23 matching lines...) Expand all
5815 my %nameToFunctionsMap = (); 6128 my %nameToFunctionsMap = ();
5816 foreach my $function (@{$interface->functions}) { 6129 foreach my $function (@{$interface->functions}) {
5817 my $name = $function->name; 6130 my $name = $function->name;
5818 $nameToFunctionsMap{$name} = [] if !exists $nameToFunctionsMap{$name} or !$name; # Nameless functions cannot be overloaded 6131 $nameToFunctionsMap{$name} = [] if !exists $nameToFunctionsMap{$name} or !$name; # Nameless functions cannot be overloaded
5819 push(@{$nameToFunctionsMap{$name}}, $function); 6132 push(@{$nameToFunctionsMap{$name}}, $function);
5820 $function->{overloads} = $nameToFunctionsMap{$name}; 6133 $function->{overloads} = $nameToFunctionsMap{$name};
5821 $function->{overloadIndex} = @{$nameToFunctionsMap{$name}}; 6134 $function->{overloadIndex} = @{$nameToFunctionsMap{$name}};
5822 } 6135 }
5823 } 6136 }
5824 6137
6138 ### DONE
5825 sub AttributeNameForGetterAndSetter 6139 sub AttributeNameForGetterAndSetter
5826 { 6140 {
5827 my $attribute = shift; 6141 my $attribute = shift;
5828 6142
5829 my $attributeName = GetImplName($attribute); 6143 my $attributeName = GetImplName($attribute);
5830 if ($attribute->extendedAttributes->{"ImplementedAs"}) { 6144 if ($attribute->extendedAttributes->{"ImplementedAs"}) {
5831 $attributeName = $attribute->extendedAttributes->{"ImplementedAs"}; 6145 $attributeName = $attribute->extendedAttributes->{"ImplementedAs"};
5832 } 6146 }
5833 my $attributeType = $attribute->type; 6147 my $attributeType = $attribute->type;
5834 6148
5835 return $attributeName; 6149 return $attributeName;
5836 } 6150 }
5837 6151
5838 sub ContentAttributeName 6152 sub ContentAttributeName
5839 { 6153 {
5840 my ($interfaceName, $attribute) = @_; 6154 my ($interfaceName, $attribute) = @_;
5841 6155
5842 my $contentAttributeName = $attribute->extendedAttributes->{"Reflect"}; 6156 my $contentAttributeName = $attribute->extendedAttributes->{"Reflect"};
5843 return undef if !$contentAttributeName; 6157 return undef if !$contentAttributeName;
5844 6158
5845 $contentAttributeName = lc AttributeNameForGetterAndSetter($attribute) if $c ontentAttributeName eq "VALUE_IS_MISSING"; 6159 $contentAttributeName = lc AttributeNameForGetterAndSetter($attribute) if $c ontentAttributeName eq "VALUE_IS_MISSING";
5846 6160
5847 my $namespace = NamespaceForAttributeName($interfaceName, $contentAttributeN ame); 6161 my $namespace = NamespaceForAttributeName($interfaceName, $contentAttributeN ame);
5848 6162
5849 AddToImplIncludes("${namespace}.h"); 6163 AddToImplIncludes("${namespace}.h");
5850 return "WebCore::${namespace}::${contentAttributeName}Attr"; 6164 return "WebCore::${namespace}::${contentAttributeName}Attr";
5851 } 6165 }
5852 6166
6167 ### get_attribute_getter_info in python
6168 ### DONE
5853 sub GetterExpression 6169 sub GetterExpression
5854 { 6170 {
5855 my ($interfaceName, $attribute) = @_; 6171 my ($interfaceName, $attribute) = @_;
5856 6172
5857 my $contentAttributeName = ContentAttributeName($interfaceName, $attribute); 6173 my $contentAttributeName = ContentAttributeName($interfaceName, $attribute);
5858 6174
5859 if (!$contentAttributeName) { 6175 if (!$contentAttributeName) {
5860 return (ToMethodName(AttributeNameForGetterAndSetter($attribute))); 6176 return (ToMethodName(AttributeNameForGetterAndSetter($attribute)));
5861 } 6177 }
5862 6178
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
5961 push(@checks, "COMPILE_ASSERT($value == ${implClassName}::$name, ${implClassName}Enum${name}IsWrongUseDoNotCheckConstants);\n"); 6277 push(@checks, "COMPILE_ASSERT($value == ${implClassName}::$name, ${implClassName}Enum${name}IsWrongUseDoNotCheckConstants);\n");
5962 } 6278 }
5963 6279
5964 push(@checks, "#endif\n") if $conditionalString; 6280 push(@checks, "#endif\n") if $conditionalString;
5965 } 6281 }
5966 push(@checks, "\n"); 6282 push(@checks, "\n");
5967 } 6283 }
5968 return @checks; 6284 return @checks;
5969 } 6285 }
5970 6286
6287 ### call_with_contains in python
5971 sub ExtendedAttributeContains 6288 sub ExtendedAttributeContains
5972 { 6289 {
5973 my $callWith = shift; 6290 my $callWith = shift;
5974 return 0 unless $callWith; 6291 return 0 unless $callWith;
5975 my $keyword = shift; 6292 my $keyword = shift;
5976 6293
5977 my @callWithKeywords = split /\s*\&\s*/, $callWith; 6294 my @callWithKeywords = split /\s*\&\s*/, $callWith;
5978 return grep { $_ eq $keyword } @callWithKeywords; 6295 return grep { $_ eq $keyword } @callWithKeywords;
5979 } 6296 }
5980 6297
(...skipping 27 matching lines...) Expand all
6008 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { 6325 if ($currentInterface->extendedAttributes->{$extendedAttribute}) {
6009 $found = 1; 6326 $found = 1;
6010 } 6327 }
6011 return 1 if $found; 6328 return 1 if $found;
6012 }, 0); 6329 }, 0);
6013 6330
6014 return $found; 6331 return $found;
6015 } 6332 }
6016 6333
6017 1; 6334 1;
OLDNEW
« no previous file with comments | « Source/bindings/scripts/code_generator_v8.py ('k') | Source/bindings/scripts/idl_compiler.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698