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

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

Issue 171533006: V8 Binding: Introduce toNativeWithTypeCheck (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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
« no previous file with comments | « no previous file | Source/bindings/tests/results/V8TestEventTarget.h » ('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 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 $header{class}->addHeader("class $v8ClassName {"); 757 $header{class}->addHeader("class $v8ClassName {");
758 $header{class}->addFooter("};"); 758 $header{class}->addFooter("};");
759 759
760 $header{classPublic}->add(<<END); 760 $header{classPublic}->add(<<END);
761 static bool hasInstance(v8::Handle<v8::Value>, v8::Isolate*); 761 static bool hasInstance(v8::Handle<v8::Value>, v8::Isolate*);
762 static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*, WrapperWor ldType); 762 static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*, WrapperWor ldType);
763 static ${nativeType}* toNative(v8::Handle<v8::Object> object) 763 static ${nativeType}* toNative(v8::Handle<v8::Object> object)
764 { 764 {
765 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8 DOMWrapperObjectIndex)); 765 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8 DOMWrapperObjectIndex));
766 } 766 }
767 static ${nativeType}* toNativeWithTypeCheck(v8::Isolate*, v8::Handle<v8::Val ue>);
767 static const WrapperTypeInfo wrapperTypeInfo; 768 static const WrapperTypeInfo wrapperTypeInfo;
768 END 769 END
769 770
770 $header{classPublic}->add(" static void derefObject(void*);\n"); 771 $header{classPublic}->add(" static void derefObject(void*);\n");
771 772
772 if (NeedsVisitDOMWrapper($interface)) { 773 if (NeedsVisitDOMWrapper($interface)) {
773 $header{classPublic}->add(" static void visitDOMWrapper(void*, const v8::Persistent<v8::Object>&, v8::Isolate*);\n"); 774 $header{classPublic}->add(" static void visitDOMWrapper(void*, const v8::Persistent<v8::Object>&, v8::Isolate*);\n");
774 } 775 }
775 776
776 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { 777 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) {
(...skipping 3985 matching lines...) Expand 10 before | Expand all | Expand 10 after
4762 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ)); 4763 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ));
4763 return handleScope.Escape(templ); 4764 return handleScope.Escape(templ);
4764 } 4765 }
4765 4766
4766 bool ${v8ClassName}::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* iso late) 4767 bool ${v8ClassName}::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* iso late)
4767 { 4768 {
4768 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI nfo, jsValue) 4769 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI nfo, jsValue)
4769 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy peInfo, jsValue); 4770 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy peInfo, jsValue);
4770 } 4771 }
4771 4772
4773 ${nativeType}* ${v8ClassName}::toNativeWithTypeCheck(v8::Isolate* isolate, v8::H andle<v8::Value> value)
4774 {
4775 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Obje ct>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
4776 }
4777
4772 END 4778 END
4773 4779
4774 if (@perContextEnabledAttributes) { 4780 if (@perContextEnabledAttributes) {
4775 my $code = ""; 4781 my $code = "";
4776 $code .= <<END; 4782 $code .= <<END;
4777 void ${v8ClassName}::installPerContextEnabledProperties(v8::Handle<v8::Object> i nstanceTemplate, ${nativeType}* impl, v8::Isolate* isolate) 4783 void ${v8ClassName}::installPerContextEnabledProperties(v8::Handle<v8::Object> i nstanceTemplate, ${nativeType}* impl, v8::Isolate* isolate)
4778 { 4784 {
4779 v8::Local<v8::Object> prototypeTemplate = v8::Local<v8::Object>::Cast(instan ceTemplate->GetPrototype()); 4785 v8::Local<v8::Object> prototypeTemplate = v8::Local<v8::Object>::Cast(instan ceTemplate->GetPrototype());
4780 END 4786 END
4781 4787
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
5630 if (IsRefPtrType($arrayOrSequenceType)) { 5636 if (IsRefPtrType($arrayOrSequenceType)) {
5631 AddToImplIncludes("V8${arrayOrSequenceType}.h"); 5637 AddToImplIncludes("V8${arrayOrSequenceType}.h");
5632 return "(toRefPtrNativeArray<${arrayOrSequenceType}, V8${arrayOrSequ enceType}>($value, $argIndexOrZero, $getIsolate))"; 5638 return "(toRefPtrNativeArray<${arrayOrSequenceType}, V8${arrayOrSequ enceType}>($value, $argIndexOrZero, $getIsolate))";
5633 } 5639 }
5634 return "toNativeArray<" . GetNativeType($arrayOrSequenceType) . ">($valu e, $argIndexOrZero, $getIsolate)"; 5640 return "toNativeArray<" . GetNativeType($arrayOrSequenceType) . ">($valu e, $argIndexOrZero, $getIsolate)";
5635 } 5641 }
5636 5642
5637 AddIncludesForType($type); 5643 AddIncludesForType($type);
5638 5644
5639 AddToImplIncludes("V8${type}.h"); 5645 AddToImplIncludes("V8${type}.h");
5640 return "V8${type}::hasInstance($value, $getIsolate) ? V8${type}::toNative(v8 ::Handle<v8::Object>::Cast($value)) : 0"; 5646 return "V8${type}::toNativeWithTypeCheck(info.GetIsolate(), $value)";
5641 } 5647 }
5642 5648
5643 sub IsUnionType 5649 sub IsUnionType
5644 { 5650 {
5645 my $type = shift; # string or UnionType 5651 my $type = shift; # string or UnionType
5646 if(ref($type) eq "UnionType") { 5652 if(ref($type) eq "UnionType") {
5647 die "Currently only 2 values of non-union type is supported as union typ e.\n" unless @{$type->unionMemberTypes} == 2; 5653 die "Currently only 2 values of non-union type is supported as union typ e.\n" unless @{$type->unionMemberTypes} == 2;
5648 return 1; 5654 return 1;
5649 } 5655 }
5650 return 0; 5656 return 0;
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
6480 if ($parameter->type eq "SerializedScriptValue") { 6486 if ($parameter->type eq "SerializedScriptValue") {
6481 return 1; 6487 return 1;
6482 } elsif (IsIntegerType($parameter->type)) { 6488 } elsif (IsIntegerType($parameter->type)) {
6483 return 1; 6489 return 1;
6484 } 6490 }
6485 } 6491 }
6486 return 0; 6492 return 0;
6487 } 6493 }
6488 6494
6489 1; 6495 1;
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/tests/results/V8TestEventTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698