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

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

Issue 116153002: IDL compiler: [NamedConstructor] (basic) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Revised Created 7 years 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
« no previous file with comments | « no previous file | Source/bindings/scripts/unstable/idl_definitions_builder.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 3054 matching lines...) Expand 10 before | Expand all | Expand 10 after
3065 END 3065 END
3066 3066
3067 my $code = ""; 3067 my $code = "";
3068 $code .= <<END; 3068 $code .= <<END;
3069 static void ${v8ClassName}ConstructorCallback(const v8::FunctionCallbackInfo<v8: :Value>& info) 3069 static void ${v8ClassName}ConstructorCallback(const v8::FunctionCallbackInfo<v8: :Value>& info)
3070 { 3070 {
3071 END 3071 END
3072 $code .= $maybeObserveFeature if $maybeObserveFeature; 3072 $code .= $maybeObserveFeature if $maybeObserveFeature;
3073 $code .= $maybeDeprecateFeature if $maybeDeprecateFeature; 3073 $code .= $maybeDeprecateFeature if $maybeDeprecateFeature;
3074 $code .= GenerateConstructorHeader($function->extendedAttributes->{"NamedCon structor"}); 3074 $code .= GenerateConstructorHeader($function->extendedAttributes->{"NamedCon structor"});
3075 AddToImplIncludes("V8Document.h");
3076 $code .= <<END; 3075 $code .= <<END;
3077 Document* document = currentDocument(); 3076 Document* document = currentDocument();
3078 ASSERT(document); 3077 ASSERT(document);
3079 3078
3080 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp lClassName} instance 3079 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp lClassName} instance
3081 // may end up being the only node in the map and get garbage-collected prema turely. 3080 // may end up being the only node in the map and get garbage-collected prema turely.
3082 toV8(document, info.Holder(), info.GetIsolate()); 3081 toV8(document, info.Holder(), info.GetIsolate());
3083 3082
3084 END 3083 END
3085 3084
(...skipping 19 matching lines...) Expand all
3105 last if $index eq $paramIndex; 3104 last if $index eq $paramIndex;
3106 if ($replacements{$parameter->name}) { 3105 if ($replacements{$parameter->name}) {
3107 push(@argumentList, $replacements{$parameter->name}); 3106 push(@argumentList, $replacements{$parameter->name});
3108 } else { 3107 } else {
3109 push(@argumentList, $parameter->name); 3108 push(@argumentList, $parameter->name);
3110 } 3109 }
3111 $index++; 3110 $index++;
3112 } 3111 }
3113 3112
3114 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); 3113 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList);
3115 $code .= "\n";
3116 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC onstructor(${argumentString});\n"; 3114 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC onstructor(${argumentString});\n";
3117 $code .= " v8::Handle<v8::Object> wrapper = info.Holder();\n"; 3115 $code .= " v8::Handle<v8::Object> wrapper = info.Holder();\n";
3118 3116
3119 if ($constructorRaisesException) { 3117 if ($constructorRaisesException) {
3120 $code .= " if (exceptionState.throwIfNeeded())\n"; 3118 $code .= " if (exceptionState.throwIfNeeded())\n";
3121 $code .= " return;\n"; 3119 $code .= " return;\n";
3122 } 3120 }
3123 3121
3124 $code .= <<END; 3122 $code .= <<END;
3125 3123
3126 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${ v8ClassName}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperCon figuration::Dependent); 3124 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${ v8ClassName}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperCon figuration::Dependent);
3127 v8SetReturnValue(info, wrapper); 3125 v8SetReturnValue(info, wrapper);
3128 } 3126 }
3129 3127
3130 END 3128 END
3131 $implementation{nameSpaceWebCore}->add($code); 3129 $implementation{nameSpaceWebCore}->add($code);
3132 3130
3133 $code = <<END; 3131 $code = <<END;
3134 v8::Handle<v8::FunctionTemplate> ${v8ClassName}Constructor::domTemplate(v8::Isol ate* isolate, WrapperWorldType currentWorldType) 3132 v8::Handle<v8::FunctionTemplate> ${v8ClassName}Constructor::domTemplate(v8::Isol ate* isolate, WrapperWorldType currentWorldType)
3135 { 3133 {
3136 // This is only for getting a unique pointer which we can pass to privateTem plate. 3134 // This is only for getting a unique pointer which we can pass to privateTem plate.
3137 static int privateTemplateUniqueKey; 3135 static int privateTemplateUniqueKey;
3138 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 3136 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
3139 v8::Local<v8::FunctionTemplate> result = data->privateTemplateIfExists(curre ntWorldType, &privateTemplateUniqueKey); 3137 v8::Local<v8::FunctionTemplate> result = data->privateTemplateIfExists(curre ntWorldType, &privateTemplateUniqueKey);
3140 if (!result.IsEmpty()) 3138 if (!result.IsEmpty())
3141 return result; 3139 return result;
3142 3140
3143 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink\", \"BuildDOMTemplate"); 3141 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
3144 v8::EscapableHandleScope scope(isolate); 3142 v8::EscapableHandleScope scope(isolate);
3145 result = v8::FunctionTemplate::New(isolate, ${v8ClassName}ConstructorCallbac k); 3143 result = v8::FunctionTemplate::New(isolate, ${v8ClassName}ConstructorCallbac k);
3146 3144
3147 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); 3145 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate();
3148 instanceTemplate->SetInternalFieldCount(${v8ClassName}::internalFieldCount); 3146 instanceTemplate->SetInternalFieldCount(${v8ClassName}::internalFieldCount);
3149 result->SetClassName(v8::String::NewFromUtf8(isolate, "${implClassName}", v8 ::String::kInternalizedString)); 3147 result->SetClassName(v8::String::NewFromUtf8(isolate, "${implClassName}", v8 ::String::kInternalizedString));
3150 result->Inherit(${v8ClassName}::domTemplate(isolate, currentWorldType)); 3148 result->Inherit(${v8ClassName}::domTemplate(isolate, currentWorldType));
3151 data->setPrivateTemplate(currentWorldType, &privateTemplateUniqueKey, result ); 3149 data->setPrivateTemplate(currentWorldType, &privateTemplateUniqueKey, result );
3152 3150
3153 return scope.Escape(result); 3151 return scope.Escape(result);
(...skipping 3185 matching lines...) Expand 10 before | Expand all | Expand 10 after
6339 6337
6340 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust om"}, "ToV8"); 6338 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust om"}, "ToV8");
6341 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust om"}, "Wrap"); 6339 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust om"}, "Wrap");
6342 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; 6340 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"};
6343 return 1 if InheritsInterface($interface, "Document"); 6341 return 1 if InheritsInterface($interface, "Document");
6344 6342
6345 return 0; 6343 return 0;
6346 } 6344 }
6347 6345
6348 1; 6346 1;
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/scripts/unstable/idl_definitions_builder.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698