OLD | NEW |
---|---|
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 3165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3176 my $interfaceName = $interface->name; | 3176 my $interfaceName = $interface->name; |
3177 my $implClassName = GetImplName($interface); | 3177 my $implClassName = GetImplName($interface); |
3178 my $v8ClassName = GetV8ClassName($interface); | 3178 my $v8ClassName = GetV8ClassName($interface); |
3179 | 3179 |
3180 my $indexedGetterFunction = GetIndexedGetterFunction($interface); | 3180 my $indexedGetterFunction = GetIndexedGetterFunction($interface); |
3181 my $hasCustomIndexedGetter = $indexedGetterFunction ? $indexedGetterFunction ->signature->extendedAttributes->{"Custom"} : 0; | 3181 my $hasCustomIndexedGetter = $indexedGetterFunction ? $indexedGetterFunction ->signature->extendedAttributes->{"Custom"} : 0; |
3182 if ($indexedGetterFunction && !$hasCustomIndexedGetter) { | 3182 if ($indexedGetterFunction && !$hasCustomIndexedGetter) { |
3183 GenerateImplementationIndexedPropertyGetter($interface, $indexedGetterFu nction); | 3183 GenerateImplementationIndexedPropertyGetter($interface, $indexedGetterFu nction); |
3184 } | 3184 } |
3185 | 3185 |
3186 # FIXME: Support generated indexed setter bindings. | |
3187 my $indexedSetterFunction = GetIndexedSetterFunction($interface); | 3186 my $indexedSetterFunction = GetIndexedSetterFunction($interface); |
3188 my $hasCustomIndexedSetter = $indexedSetterFunction ? $indexedSetterFunction ->signature->extendedAttributes->{"Custom"} : 0; | 3187 my $hasCustomIndexedSetter = $indexedSetterFunction ? $indexedSetterFunction ->signature->extendedAttributes->{"Custom"} : 0; |
3188 if ($indexedSetterFunction && !$hasCustomIndexedSetter) { | |
3189 GenerateImplementationIndexedPropertySetter($interface, $indexedSetterFu nction); | |
3190 } | |
3189 | 3191 |
3190 my $indexedDeleterFunction = GetIndexedDeleterFunction($interface); | 3192 my $indexedDeleterFunction = GetIndexedDeleterFunction($interface); |
3191 my $hasCustomIndexedDeleter = $indexedDeleterFunction ? $indexedDeleterFunct ion->signature->extendedAttributes->{"Custom"} : 0; | 3193 my $hasCustomIndexedDeleter = $indexedDeleterFunction ? $indexedDeleterFunct ion->signature->extendedAttributes->{"Custom"} : 0; |
3192 if ($indexedDeleterFunction && !$hasCustomIndexedDeleter) { | 3194 if ($indexedDeleterFunction && !$hasCustomIndexedDeleter) { |
3193 GenerateImplementationIndexedPropertyDeleter($interface, $indexedDeleter Function); | 3195 GenerateImplementationIndexedPropertyDeleter($interface, $indexedDeleter Function); |
3194 } | 3196 } |
3195 | 3197 |
3196 # FIXME: Support generated named enumerator bindings. | 3198 # FIXME: Support generated named enumerator bindings. |
3197 my $hasEnumerator = $indexedGetterFunction; | 3199 my $hasEnumerator = $indexedGetterFunction; |
3198 # FIXME: Remove the special cases. Interfaces that have indexedPropertyGette r should have indexedPropertyEnumerator. | 3200 # FIXME: Remove the special cases. Interfaces that have indexedPropertyGette r should have indexedPropertyEnumerator. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3266 $getterCode .= " return v8Undefined();\n"; | 3268 $getterCode .= " return v8Undefined();\n"; |
3267 } else { | 3269 } else { |
3268 $getterCode .= " if (${isNull})\n"; | 3270 $getterCode .= " if (${isNull})\n"; |
3269 $getterCode .= " return v8Undefined();\n"; | 3271 $getterCode .= " return v8Undefined();\n"; |
3270 $getterCode .= $returnJSValueCode . "\n"; | 3272 $getterCode .= $returnJSValueCode . "\n"; |
3271 } | 3273 } |
3272 $getterCode .= "}\n\n"; | 3274 $getterCode .= "}\n\n"; |
3273 $implementation{nameSpaceWebCore}->add($getterCode); | 3275 $implementation{nameSpaceWebCore}->add($getterCode); |
3274 } | 3276 } |
3275 | 3277 |
3278 sub GenerateImplementationIndexedPropertySetter | |
3279 { | |
3280 my $interface = shift; | |
3281 my $indexedSetterFunction = shift; | |
3282 my $implClassName = GetImplName($interface); | |
3283 my $v8ClassName = GetV8ClassName($interface); | |
3284 my $methodName = GetImplName($indexedSetterFunction->signature); | |
3285 | |
3286 AddToImplIncludes("bindings/v8/V8Collection.h"); | |
3287 my $type = $indexedSetterFunction->parameters->[1]->type; | |
3288 my $returnType = $indexedSetterFunction->signature->type; | |
3289 my $nativeType = GetNativeType($returnType); | |
3290 my $nativeValue = JSValueToNative($type, $indexedSetterFunction->signature-> extendedAttributes, "value", "info.GetIsolate()"); | |
3291 my $raisesExceptions = $indexedSetterFunction->signature->extendedAttributes ->{"RaisesException"}; | |
3292 my $treatNullAs = $indexedSetterFunction->parameters->[1]->extendedAttribute s->{"TreatNullAs"}; | |
3293 my $treatUndefinedAs = $indexedSetterFunction->parameters->[1]->extendedAttr ibutes->{"TreatUndefinedAs"}; | |
3294 my $code = "v8::Handle<v8::Value> ${v8ClassName}::indexedPropertySetter(uint 32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)\n"; | |
3295 $code .= "{\n"; | |
3296 $code .= " ${implClassName}* collection = toNative(info.Holder());\n"; | |
3297 my $extraArguments = ""; | |
3298 if ($raisesExceptions) { | |
3299 $code .= " ExceptionCode ec = 0;\n"; | |
3300 $extraArguments = ", ec"; | |
3301 } | |
3302 if ($type eq "DOMString") { | |
3303 my $nullCheck = ""; | |
3304 if ($treatNullAs && $treatNullAs eq "NullString") { | |
3305 $nullCheck = "WithNullCheck"; | |
3306 } | |
haraken
2013/05/29 06:41:56
You should add a $treatUndefinedAs case as well. H
| |
3307 $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<${nullChe ck}>, propertyValue, value);\n"; | |
3308 } else { | |
3309 $code .= " $nativeType propertyValue = $nativeValue;\n"; | |
3310 } | |
haraken
2013/05/29 06:41:56
I think we duplicate code of line 3302 - 3310 in C
| |
3311 my $passNativeValue = "propertyValue"; | |
3312 $passNativeValue .= ".release()" if (IsRefPtrType($type)); | |
3313 | |
3314 my @conditions = (); | |
3315 my @statements = (); | |
3316 if ($treatNullAs && $treatNullAs ne "NullString") { | |
3317 push @conditions, "value->IsNull()"; | |
3318 push @statements, "result = collection->${treatNullAs}(index$extraArgume nts);"; | |
3319 } | |
3320 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") { | |
3321 push @conditions, "value->IsUndefined()"; | |
3322 push @statements, "result = collection->${treatUndefinedAs}(index$extraA rguments);"; | |
3323 } | |
3324 push @conditions, ""; | |
3325 push @statements, "result = collection->${methodName}(index, $passNativeValu e$extraArguments);"; | |
3326 if (@conditions==1) { | |
haraken
2013/05/29 06:41:56
Nit: Spaces needed around '=='.
| |
3327 $code .= " bool " . $statements[0] . "\n"; | |
3328 } else { | |
3329 $code .= " bool result;\n"; | |
3330 for my $i (0..@conditions-1) { | |
3331 my $token = "else if"; | |
3332 $token = "if" if $i==0; | |
haraken
2013/05/29 06:41:56
Ditto.
| |
3333 $token = "else" if $i==@conditions-1; | |
haraken
2013/05/29 06:41:56
Ditto.
| |
3334 $code .= " ${token}"; | |
3335 $code .= " (" . $conditions[$i] . ")" if $conditions[$i]; | |
3336 $code .= "\n"; | |
3337 $code .= " " . $statements[$i] . "\n"; | |
3338 } | |
3339 } | |
3340 | |
3341 $code .= " if (!result)\n"; | |
3342 $code .= " return v8Undefined();\n"; | |
3343 if ($raisesExceptions) { | |
3344 $code .= " if (ec)\n"; | |
3345 $code .= " return setDOMException(ec, info.GetIsolate());\n"; | |
3346 } | |
3347 $code .= " return value;\n"; | |
3348 $code .= "}\n\n"; | |
3349 $implementation{nameSpaceWebCore}->add($code); | |
3350 } | |
3351 | |
3276 sub GenerateImplementationNamedPropertyAccessors | 3352 sub GenerateImplementationNamedPropertyAccessors |
3277 { | 3353 { |
3278 my $interface = shift; | 3354 my $interface = shift; |
3279 | 3355 |
3280 my $interfaceName = $interface->name; | 3356 my $interfaceName = $interface->name; |
3281 my $implClassName = GetImplName($interface); | 3357 my $implClassName = GetImplName($interface); |
3282 my $v8ClassName = GetV8ClassName($interface); | 3358 my $v8ClassName = GetV8ClassName($interface); |
3283 | 3359 |
3284 my $namedGetterFunction = GetNamedGetterFunction($interface); | 3360 my $namedGetterFunction = GetNamedGetterFunction($interface); |
3285 my $hasCustomNamedGetter = $namedGetterFunction ? $namedGetterFunction->sign ature->extendedAttributes->{"Custom"} : 0; | 3361 my $hasCustomNamedGetter = $namedGetterFunction ? $namedGetterFunction->sign ature->extendedAttributes->{"Custom"} : 0; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3424 my $interface = shift; | 3500 my $interface = shift; |
3425 my $namedSetterFunction = shift; | 3501 my $namedSetterFunction = shift; |
3426 my $implClassName = GetImplName($interface); | 3502 my $implClassName = GetImplName($interface); |
3427 my $v8ClassName = GetV8ClassName($interface); | 3503 my $v8ClassName = GetV8ClassName($interface); |
3428 my $methodName = GetImplName($namedSetterFunction->signature); | 3504 my $methodName = GetImplName($namedSetterFunction->signature); |
3429 | 3505 |
3430 AddToImplIncludes("bindings/v8/V8Collection.h"); | 3506 AddToImplIncludes("bindings/v8/V8Collection.h"); |
3431 my $type = $namedSetterFunction->parameters->[1]->type; | 3507 my $type = $namedSetterFunction->parameters->[1]->type; |
3432 my $nativeType = GetNativeType($type); | 3508 my $nativeType = GetNativeType($type); |
3433 my $raisesExceptions = $namedSetterFunction->signature->extendedAttributes-> {"RaisesException"}; | 3509 my $raisesExceptions = $namedSetterFunction->signature->extendedAttributes-> {"RaisesException"}; |
3510 my $treatNullAs = $namedSetterFunction->parameters->[1]->extendedAttributes- >{"TreatNullAs"}; | |
3511 my $treatUndefinedAs = $namedSetterFunction->parameters->[1]->extendedAttrib utes->{"TreatUndefinedAs"}; | |
3434 my $nativeValue = JSValueToNative($type, $namedSetterFunction->signature->ex tendedAttributes, "value", "info.GetIsolate()"); | 3512 my $nativeValue = JSValueToNative($type, $namedSetterFunction->signature->ex tendedAttributes, "value", "info.GetIsolate()"); |
3435 | 3513 |
3436 my $code = "v8::Handle<v8::Value> ${v8ClassName}::namedPropertySetter(v8::Lo cal<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)\ n"; | 3514 my $code = "v8::Handle<v8::Value> ${v8ClassName}::namedPropertySetter(v8::Lo cal<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)\ n"; |
3437 $code .= "{\n"; | 3515 $code .= "{\n"; |
3438 if (!$namedSetterFunction->signature->extendedAttributes->{"OverrideBuiltins "}) { | 3516 if (!$namedSetterFunction->signature->extendedAttributes->{"OverrideBuiltins "}) { |
3439 $code .= " if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(n ame).IsEmpty())\n"; | 3517 $code .= " if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(n ame).IsEmpty())\n"; |
3440 $code .= " return v8Undefined();\n"; | 3518 $code .= " return v8Undefined();\n"; |
3441 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n"; | 3519 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n"; |
3442 $code .= " return v8Undefined();\n"; | 3520 $code .= " return v8Undefined();\n"; |
3443 } | 3521 } |
3444 $code .= " ${implClassName}* collection = toNative(info.Holder());\n"; | 3522 $code .= " ${implClassName}* collection = toNative(info.Holder());\n"; |
3445 $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, propertyNa me, name);\n"; | 3523 $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, propertyNa me, name);\n"; |
3446 my $extraArguments = ""; | 3524 my $extraArguments = ""; |
3447 if ($raisesExceptions) { | 3525 if ($raisesExceptions) { |
3448 $code .= " ExceptionCode ec = 0;\n"; | 3526 $code .= " ExceptionCode ec = 0;\n"; |
3449 $extraArguments = ", ec"; | 3527 $extraArguments = ", ec"; |
3450 } | 3528 } |
3451 if ($type eq "DOMString") { | 3529 if ($type eq "DOMString") { |
3452 my $nullCheck = ""; | 3530 my $nullCheck = ""; |
3453 my $treatNullAs = $namedSetterFunction->parameters->[1]->extendedAttribu tes->{"TreatNullAs"}; | |
3454 if ($treatNullAs && $treatNullAs eq "NullString") { | 3531 if ($treatNullAs && $treatNullAs eq "NullString") { |
3455 $nullCheck = "WithNullCheck"; | 3532 $nullCheck = "WithNullCheck"; |
3456 } | 3533 } |
3457 $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<${nullChe ck}>, propertyValue, value);\n"; | 3534 $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<${nullChe ck}>, propertyValue, value);\n"; |
3458 } else { | 3535 } else { |
3459 $code .= " $nativeType propertyValue = $nativeValue;\n"; | 3536 $code .= " $nativeType propertyValue = $nativeValue;\n"; |
3460 } | 3537 } |
3461 $code .= " bool result = collection->${methodName}(propertyName, property Value$extraArguments);\n"; | 3538 |
3539 my @conditions = (); | |
3540 my @statements = (); | |
3541 if ($treatNullAs && $treatNullAs ne "NullString") { | |
3542 push @conditions, "value->IsNull()"; | |
3543 push @statements, "result = collection->${treatNullAs}(propertyName$extr aArguments);"; | |
3544 } | |
3545 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") { | |
3546 push @conditions, "value->IsUndefined()"; | |
3547 push @statements, "result = collection->${treatUndefinedAs}(propertyName $extraArguments);"; | |
3548 } | |
3549 push @conditions, ""; | |
3550 push @statements, "result = collection->${methodName}(propertyName, property Value$extraArguments);"; | |
3551 if (@conditions==1) { | |
3552 $code .= " bool " . $statements[0] . "\n"; | |
3553 } else { | |
3554 $code .= " bool result;\n"; | |
3555 for my $i (0..@conditions-1) { | |
3556 my $token = "else if"; | |
3557 $token = "if" if $i==0; | |
3558 $token = "else" if $i==@conditions-1; | |
3559 $code .= " ${token}"; | |
3560 $code .= " (" . $conditions[$i] . ")" if $conditions[$i]; | |
3561 $code .= "\n"; | |
3562 $code .= " " . $statements[$i] . "\n"; | |
3563 } | |
3564 } | |
haraken
2013/05/29 06:41:56
We don't want to duplicate the code to build up if
| |
3565 | |
3462 $code .= " if (!result)\n"; | 3566 $code .= " if (!result)\n"; |
3463 $code .= " return v8Undefined();\n"; | 3567 $code .= " return v8Undefined();\n"; |
3464 if ($raisesExceptions) { | 3568 if ($raisesExceptions) { |
3465 $code .= " if (ec)\n"; | 3569 $code .= " if (ec)\n"; |
3466 $code .= " return setDOMException(ec, info.GetIsolate());\n"; | 3570 $code .= " return setDOMException(ec, info.GetIsolate());\n"; |
3467 } | 3571 } |
3468 $code .= " return value;\n"; | 3572 $code .= " return value;\n"; |
3469 $code .= "}\n\n"; | 3573 $code .= "}\n\n"; |
3470 $implementation{nameSpaceWebCore}->add($code); | 3574 $implementation{nameSpaceWebCore}->add($code); |
3471 } | 3575 } |
(...skipping 2182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5654 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { | 5758 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { |
5655 $found = 1; | 5759 $found = 1; |
5656 } | 5760 } |
5657 return 1 if $found; | 5761 return 1 if $found; |
5658 }, 0); | 5762 }, 0); |
5659 | 5763 |
5660 return $found; | 5764 return $found; |
5661 } | 5765 } |
5662 | 5766 |
5663 1; | 5767 1; |
OLD | NEW |