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

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

Issue 19457002: Make 'any'-typed attributes of events available in isolated worlds (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Properly refactored Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
5 # Copyright (C) 2006 Apple Computer, Inc. 5 # Copyright (C) 2006 Apple Computer, Inc.
6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc.
7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved.
9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 # Copyright (C) 2012 Ericsson AB. All rights reserved. 10 # Copyright (C) 2012 Ericsson AB. All rights reserved.
(...skipping 2632 matching lines...) Expand 10 before | Expand all | Expand 10 after
2643 GenerateOverloadedConstructorCallback($interface); 2643 GenerateOverloadedConstructorCallback($interface);
2644 } 2644 }
2645 } 2645 }
2646 2646
2647 sub GenerateEventConstructor 2647 sub GenerateEventConstructor
2648 { 2648 {
2649 my $interface = shift; 2649 my $interface = shift;
2650 my $implClassName = GetImplName($interface); 2650 my $implClassName = GetImplName($interface);
2651 my $v8ClassName = GetV8ClassName($interface); 2651 my $v8ClassName = GetV8ClassName($interface);
2652 2652
2653 my @anyAttributeNames;
2654 foreach my $attribute (@{$interface->attributes}) {
2655 if ($attribute->type eq "any") {
2656 push(@anyAttributeNames, $attribute->name);
2657 }
2658 }
2659
2653 AddToImplIncludes("bindings/v8/Dictionary.h"); 2660 AddToImplIncludes("bindings/v8/Dictionary.h");
2654 $implementation{nameSpaceInternal}->add(<<END); 2661 $implementation{nameSpaceInternal}->add(<<END);
2655 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& args) 2662 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& args)
2656 { 2663 {
2657 if (args.Length() < 1) { 2664 if (args.Length() < 1) {
2658 throwNotEnoughArgumentsError(args.GetIsolate()); 2665 throwNotEnoughArgumentsError(args.GetIsolate());
2659 return; 2666 return;
2660 } 2667 }
2661 2668
2662 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, args[0]); 2669 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, args[0]);
2670 END
2671
2672 foreach my $attrName (@anyAttributeNames) {
2673 $implementation{nameSpaceInternal}->add(" v8::Local<v8::Value> ${attr Name};\n");
2674 }
2675
2676 $implementation{nameSpaceInternal}->add(<<END);
2663 ${implClassName}Init eventInit; 2677 ${implClassName}Init eventInit;
2664 if (args.Length() >= 2) { 2678 if (args.Length() >= 2) {
2665 V8TRYCATCH_VOID(Dictionary, options, Dictionary(args[1], args.GetIsolate ())); 2679 V8TRYCATCH_VOID(Dictionary, options, Dictionary(args[1], args.GetIsolate ()));
2666 if (!fill${implClassName}Init(eventInit, options)) 2680 if (!fill${implClassName}Init(eventInit, options))
2667 return; 2681 return;
2668 END 2682 END
2669 for (my $index = 0; $index < @{$interface->attributes}; $index++) { 2683
2670 my $attribute = @{$interface->attributes}[$index]; 2684 foreach my $attrName (@anyAttributeNames) {
2671 if ($attribute->type eq "any") { 2685 $implementation{nameSpaceInternal}->add(<<END);
2672 my $attributeName = $attribute->name; 2686 options.get("${attrName}", ${attrName});
2673 $implementation{nameSpaceInternal}->add(<<END); 2687 if (!${attrName}.IsEmpty())
2674 v8::Local<v8::Value> ${attributeName}; 2688 args.Holder()->SetHiddenValue(V8HiddenPropertyName::${attrName}(), $ {attrName});
2675 options.get("${attributeName}", ${attributeName});
2676 if (!${attributeName}.IsEmpty())
2677 args.Holder()->SetHiddenValue(V8HiddenPropertyName::${attributeName} (), ${attributeName});
2678 END 2689 END
2679 } 2690 }
2680 } 2691
2681 $implementation{nameSpaceInternal}->add(<<END); 2692 $implementation{nameSpaceInternal}->add(<<END);
2682 } 2693 }
2683 2694
2684 RefPtr<${implClassName}> event = ${implClassName}::create(type, eventInit); 2695 RefPtr<${implClassName}> event = ${implClassName}::create(type, eventInit);
2696 END
2685 2697
2698 if (@anyAttributeNames) {
2699 $implementation{nameSpaceInternal}->add(" if (isolatedWorldForIsolate (args.GetIsolate())) {\n");
2700 foreach my $attrName (@anyAttributeNames) {
2701 my $setter = "setSerialized" . FirstLetterToUpperCase($attrName);
2702 $implementation{nameSpaceInternal}->add(<<END);
2703 if (!${attrName}.IsEmpty())
2704 event->${setter}(SerializedScriptValue::createSwallowExceptions(${at trName}, args.GetIsolate()));
abarth-chromium 2013/07/17 23:06:44 createSwallowExceptions -> createAndSwallowExcepti
adamk 2013/07/17 23:45:10 Done.
2705 END
2706 }
2707 $implementation{nameSpaceInternal}->add(" }\n\n");
2708 }
2709
2710 $implementation{nameSpaceInternal}->add(<<END);
2686 v8::Handle<v8::Object> wrapper = args.Holder(); 2711 v8::Handle<v8::Object> wrapper = args.Holder();
2687 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(event.release(), &$ {v8ClassName}::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent ); 2712 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(event.release(), &$ {v8ClassName}::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent );
2688 v8SetReturnValue(args, wrapper); 2713 v8SetReturnValue(args, wrapper);
2689 } 2714 }
2690 END 2715 END
2691 2716
2692 my $code = ""; 2717 my $code = "";
2693 $code .= <<END; 2718 $code .= <<END;
2694 bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary& options) 2719 bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary& options)
2695 { 2720 {
2696 END 2721 END
2697 2722
2698 if ($interface->parent) { 2723 if ($interface->parent) {
2699 my $interfaceBase = $interface->parent; 2724 my $interfaceBase = $interface->parent;
2700 $code .= <<END; 2725 $code .= <<END;
2701 if (!fill${interfaceBase}Init(eventInit, options)) 2726 if (!fill${interfaceBase}Init(eventInit, options))
2702 return false; 2727 return false;
2703 2728
2704 END 2729 END
2705 } 2730 }
2706 2731
2707 for (my $index = 0; $index < @{$interface->attributes}; $index++) { 2732 foreach my $attribute (@{$interface->attributes}) {
2708 my $attribute = @{$interface->attributes}[$index];
2709 if ($attribute->extendedAttributes->{"InitializedByEventConstructor"}) { 2733 if ($attribute->extendedAttributes->{"InitializedByEventConstructor"}) {
2710 my $attributeName = $attribute->name; 2734 if ($attribute->type ne "any") {
2711 my $attributeType = $attribute->type; 2735 my $attributeName = $attribute->name;
2712 if (not ($attribute->type eq "any")) {
2713 $code .= " options.get(\"$attributeName\", eventInit.$attribu teName);\n"; 2736 $code .= " options.get(\"$attributeName\", eventInit.$attribu teName);\n";
2714 } 2737 }
2715 } 2738 }
2716 } 2739 }
2717 2740
2718 $code .= <<END; 2741 $code .= <<END;
2719 return true; 2742 return true;
2720 } 2743 }
2721 2744
2722 END 2745 END
(...skipping 3281 matching lines...) Expand 10 before | Expand all | Expand 10 after
6004 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { 6027 if ($currentInterface->extendedAttributes->{$extendedAttribute}) {
6005 $found = 1; 6028 $found = 1;
6006 } 6029 }
6007 return 1 if $found; 6030 return 1 if $found;
6008 }, 0); 6031 }, 0);
6009 6032
6010 return $found; 6033 return $found;
6011 } 6034 }
6012 6035
6013 1; 6036 1;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698