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

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

Issue 18677002: [Binding] use V8TRYCATCH_VOID and raw pointer in indexed setter (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: 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
« no previous file with comments | « no previous file | Source/bindings/tests/idls/TestEventTarget.idl » ('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 3333 matching lines...) Expand 10 before | Expand all | Expand 10 after
3344 my $code = "static void indexedPropertySetter(uint32_t index, v8::Local<v8:: Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)\n"; 3344 my $code = "static void indexedPropertySetter(uint32_t index, v8::Local<v8:: Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)\n";
3345 $code .= "{\n"; 3345 $code .= "{\n";
3346 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3346 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3347 $code .= GenerateNativeValueDefinition($indexedSetterFunction, $indexedSette rFunction->parameters->[1], "value", "propertyValue", "info.GetIsolate()"); 3347 $code .= GenerateNativeValueDefinition($indexedSetterFunction, $indexedSette rFunction->parameters->[1], "value", "propertyValue", "info.GetIsolate()");
3348 3348
3349 my $extraArguments = ""; 3349 my $extraArguments = "";
3350 if ($raisesExceptions) { 3350 if ($raisesExceptions) {
3351 $code .= " ExceptionCode ec = 0;\n"; 3351 $code .= " ExceptionCode ec = 0;\n";
3352 $extraArguments = ", ec"; 3352 $extraArguments = ", ec";
3353 } 3353 }
3354 my $passNativeValue = "propertyValue";
3355 $passNativeValue .= ".release()" if (IsRefPtrType($type));
haraken 2013/07/04 08:22:38 Why can you remove this?
kojih 2013/07/04 08:30:42 Since this patch changes propertyValue type from R
3356
3357 my @conditions = (); 3354 my @conditions = ();
3358 my @statements = (); 3355 my @statements = ();
3359 if ($treatNullAs && $treatNullAs ne "NullString") { 3356 if ($treatNullAs && $treatNullAs ne "NullString") {
3360 push @conditions, "value->IsNull()"; 3357 push @conditions, "value->IsNull()";
3361 push @statements, "collection->${treatNullAs}(index$extraArguments);"; 3358 push @statements, "collection->${treatNullAs}(index$extraArguments);";
3362 } 3359 }
3363 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") { 3360 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") {
3364 push @conditions, "value->IsUndefined()"; 3361 push @conditions, "value->IsUndefined()";
3365 push @statements, "collection->${treatUndefinedAs}(index$extraArguments) ;"; 3362 push @statements, "collection->${treatUndefinedAs}(index$extraArguments) ;";
3366 } 3363 }
3367 push @conditions, ""; 3364 push @conditions, "";
3368 push @statements, "collection->${methodName}(index, $passNativeValue$extraAr guments);"; 3365 push @statements, "collection->${methodName}(index, propertyValue$extraArgum ents);";
3369 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s); 3366 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s);
3370 3367
3371 $code .= " if (!result)\n"; 3368 $code .= " if (!result)\n";
3372 $code .= " return;\n"; 3369 $code .= " return;\n";
3373 if ($raisesExceptions) { 3370 if ($raisesExceptions) {
3374 $code .= " if (ec) {\n"; 3371 $code .= " if (ec) {\n";
3375 $code .= " setDOMException(ec, info.GetIsolate());\n"; 3372 $code .= " setDOMException(ec, info.GetIsolate());\n";
3376 $code .= " return;\n"; 3373 $code .= " return;\n";
3377 $code .= " }\n"; 3374 $code .= " }\n";
3378 } 3375 }
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
3643 { 3640 {
3644 my $function = shift; 3641 my $function = shift;
3645 my $parameter = shift; 3642 my $parameter = shift;
3646 my $jsValue = shift; 3643 my $jsValue = shift;
3647 my $nativeValueName = shift; 3644 my $nativeValueName = shift;
3648 my $getIsolate = shift; 3645 my $getIsolate = shift;
3649 3646
3650 my $treatNullAs = $parameter->extendedAttributes->{"TreatNullAs"} || ""; 3647 my $treatNullAs = $parameter->extendedAttributes->{"TreatNullAs"} || "";
3651 my $treatUndefinedAs = $parameter->extendedAttributes->{"TreatUndefinedAs"} || ""; 3648 my $treatUndefinedAs = $parameter->extendedAttributes->{"TreatUndefinedAs"} || "";
3652 my $code = ""; 3649 my $code = "";
3653 my $nativeType = GetNativeType($parameter->type); 3650 my $nativeType = GetNativeType($parameter->type, 1);
haraken 2013/07/04 08:22:38 I hope this could be "parameter" instead of myster
kojih 2013/07/04 08:30:42 OK, in python generator, this will be named parame
3654 my $nativeValue = JSValueToNative($parameter->type, $function->extendedAttri butes, $jsValue, $getIsolate); 3651 my $nativeValue = JSValueToNative($parameter->type, $function->extendedAttri butes, $jsValue, $getIsolate);
3655 if ($parameter->type eq "DOMString") { 3652 if ($parameter->type eq "DOMString") {
3656 my $nullCheck = ""; 3653 my $nullCheck = "";
3657 if ($treatNullAs eq "NullString") { 3654 if ($treatNullAs eq "NullString") {
3658 $nullCheck = "WithUndefinedOrNullCheck"; 3655 $nullCheck = "WithUndefinedOrNullCheck";
3659 if ($treatUndefinedAs eq "NullString") { 3656 if ($treatUndefinedAs eq "NullString") {
3660 $nullCheck = "WithNullCheck"; 3657 $nullCheck = "WithNullCheck";
3661 } 3658 }
3662 } 3659 }
3663 $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<${nu llCheck}>, ${nativeValueName}, ${jsValue});\n"; 3660 $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<${nu llCheck}>, ${nativeValueName}, ${jsValue});\n";
3664 } else { 3661 } else {
3665 $code .= " ${nativeType} ${nativeValueName} = ${nativeValue};\n"; 3662 $code .= " V8TRYCATCH_VOID(${nativeType}, ${nativeValueName}, ${nativ eValue});\n";
haraken 2013/07/04 08:22:38 Looks correct but this might affect performance du
kojih 2013/07/04 08:30:42 OK.
3666 } 3663 }
3667 return $code; 3664 return $code;
3668 } 3665 }
3669 3666
3670 sub GenerateImplementationNamedPropertySetter 3667 sub GenerateImplementationNamedPropertySetter
3671 { 3668 {
3672 my $interface = shift; 3669 my $interface = shift;
3673 my $namedSetterFunction = shift; 3670 my $namedSetterFunction = shift;
3674 my $implClassName = GetImplName($interface); 3671 my $implClassName = GetImplName($interface);
3675 my $v8ClassName = GetV8ClassName($interface); 3672 my $v8ClassName = GetV8ClassName($interface);
(...skipping 2375 matching lines...) Expand 10 before | Expand all | Expand 10 after
6051 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { 6048 if ($currentInterface->extendedAttributes->{$extendedAttribute}) {
6052 $found = 1; 6049 $found = 1;
6053 } 6050 }
6054 return 1 if $found; 6051 return 1 if $found;
6055 }, 0); 6052 }, 0);
6056 6053
6057 return $found; 6054 return $found;
6058 } 6055 }
6059 6056
6060 1; 6057 1;
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/tests/idls/TestEventTarget.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698