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 3064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3075 my $interfaceName = $interface->name; | 3075 my $interfaceName = $interface->name; |
3076 my $implClassName = GetImplName($interface); | 3076 my $implClassName = GetImplName($interface); |
3077 my $v8ClassName = GetV8ClassName($interface); | 3077 my $v8ClassName = GetV8ClassName($interface); |
3078 | 3078 |
3079 my $indexedGetterFunction = GetIndexedGetterFunction($interface); | 3079 my $indexedGetterFunction = GetIndexedGetterFunction($interface); |
3080 my $hasCustomIndexedGetter = $indexedGetterFunction ? $indexedGetterFunction ->signature->extendedAttributes->{"Custom"} : 0; | 3080 my $hasCustomIndexedGetter = $indexedGetterFunction ? $indexedGetterFunction ->signature->extendedAttributes->{"Custom"} : 0; |
3081 if ($indexedGetterFunction && !$hasCustomIndexedGetter) { | 3081 if ($indexedGetterFunction && !$hasCustomIndexedGetter) { |
3082 GenerateImplementationIndexedPropertyGetter($interface, $indexedGetterFu nction); | 3082 GenerateImplementationIndexedPropertyGetter($interface, $indexedGetterFu nction); |
3083 } | 3083 } |
3084 | 3084 |
3085 # FIXME: Support generated indexed setter bindings. | |
3086 my $indexedSetterFunction = GetIndexedSetterFunction($interface); | 3085 my $indexedSetterFunction = GetIndexedSetterFunction($interface); |
3087 my $hasCustomIndexedSetter = $indexedSetterFunction ? $indexedSetterFunction ->signature->extendedAttributes->{"Custom"} : 0; | 3086 my $hasCustomIndexedSetter = $indexedSetterFunction ? $indexedSetterFunction ->signature->extendedAttributes->{"Custom"} : 0; |
3087 if ($indexedSetterFunction && !$hasCustomIndexedSetter) { | |
3088 GenerateImplementationIndexedPropertySetter($interface, $indexedSetterFu nction); | |
3089 } | |
3088 | 3090 |
3089 # FIXME: Support generated named deleter bindings. | 3091 # FIXME: Support generated named deleter bindings. |
3090 my $indexedDeleterFunction = GetIndexedDeleterFunction($interface); | 3092 my $indexedDeleterFunction = GetIndexedDeleterFunction($interface); |
3091 my $hasCustomIndexedDeleter = $indexedDeleterFunction ? $indexedDeleterFunct ion->signature->extendedAttributes->{"Custom"} : 0; | 3093 my $hasCustomIndexedDeleter = $indexedDeleterFunction ? $indexedDeleterFunct ion->signature->extendedAttributes->{"Custom"} : 0; |
3092 | 3094 |
3093 # FIXME: Support generated named enumerator bindings. | 3095 # FIXME: Support generated named enumerator bindings. |
3094 my $hasEnumerator = $indexedGetterFunction; | 3096 my $hasEnumerator = $indexedGetterFunction; |
3095 # FIXME: Remove the special cases. Interfaces that have indexedPropertyGette r should have indexedPropertyEnumerator. | 3097 # FIXME: Remove the special cases. Interfaces that have indexedPropertyGette r should have indexedPropertyEnumerator. |
3096 $hasEnumerator = 0 if $interfaceName eq "WebKitCSSKeyframesRule"; | 3098 $hasEnumerator = 0 if $interfaceName eq "WebKitCSSKeyframesRule"; |
3097 $hasEnumerator = 0 if $interfaceName eq "HTMLAppletElement"; | 3099 $hasEnumerator = 0 if $interfaceName eq "HTMLAppletElement"; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3163 $getterCode .= " return v8Undefined();\n"; | 3165 $getterCode .= " return v8Undefined();\n"; |
3164 } else { | 3166 } else { |
3165 $getterCode .= " if (${isNull})\n"; | 3167 $getterCode .= " if (${isNull})\n"; |
3166 $getterCode .= " return v8Undefined();\n"; | 3168 $getterCode .= " return v8Undefined();\n"; |
3167 $getterCode .= $returnJSValueCode . "\n"; | 3169 $getterCode .= $returnJSValueCode . "\n"; |
3168 } | 3170 } |
3169 $getterCode .= "}\n\n"; | 3171 $getterCode .= "}\n\n"; |
3170 $implementation{nameSpaceWebCore}->add($getterCode); | 3172 $implementation{nameSpaceWebCore}->add($getterCode); |
3171 } | 3173 } |
3172 | 3174 |
3175 sub GenerateImplementationIndexedPropertySetter | |
3176 { | |
3177 my $interface = shift; | |
3178 my $indexedSetterFunction = shift; | |
3179 my $implClassName = GetImplName($interface); | |
3180 my $v8ClassName = GetV8ClassName($interface); | |
3181 my $methodName = GetImplName($indexedSetterFunction->signature); | |
3182 | |
3183 AddToImplIncludes("bindings/v8/V8Collection.h"); | |
3184 my $type = $indexedSetterFunction->parameters->[1]->type; | |
3185 my $returnType = $indexedSetterFunction->signature->type; | |
3186 my $nativeType = GetNativeType($returnType); | |
3187 my $nativeValue = JSValueToNative($type, $indexedSetterFunction->signature-> extendedAttributes, "value", "info.GetIsolate()"); | |
3188 my $raisesExceptions = $indexedSetterFunction->signature->extendedAttributes ->{"RaisesException"}; | |
3189 my $code = "v8::Handle<v8::Value> ${v8ClassName}::indexedPropertySetter(uint 32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)\n"; | |
3190 $code .= "{\n"; | |
3191 $code .= " ${implClassName}* collection = toNative(info.Holder());\n"; | |
3192 my $extraArguments = ""; | |
3193 if ($raisesExceptions) { | |
3194 $code .= " ExceptionCode ec = 0;\n"; | |
3195 $extraArguments = ", ec"; | |
3196 } | |
3197 if ($type eq "DOMString") { | |
kojih
2013/05/28 06:51:28
I'd like to remove this branch by modifying JSValu
| |
3198 my $nullCheck = ""; | |
3199 my $treatNullAs = $indexedSetterFunction->parameters->[1]->extendedAttri butes->{"TreatNullAs"}; | |
3200 if ($treatNullAs && $treatNullAs eq "NullString") { | |
3201 $nullCheck = "WithNullCheck"; | |
3202 } | |
3203 $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<${nullChe ck}>, propertyValue, value);\n"; | |
3204 } else { | |
3205 $code .= " $nativeType propertyValue = $nativeValue;\n"; | |
3206 } | |
3207 my $passNativeValue = "propertyValue"; | |
3208 $passNativeValue .= ".release()" if (IsRefPtrType($type)); | |
3209 $code .= " bool result = collection->${methodName}(index, $passNativeValu e, value->IsNull(), value->IsUndefined()$extraArguments);\n"; | |
3210 $code .= " if (!result)\n"; | |
3211 $code .= " return v8Undefined();\n"; | |
3212 if ($raisesExceptions) { | |
3213 $code .= " if (ec)\n"; | |
3214 $code .= " return setDOMException(ec, info.GetIsolate());\n"; | |
3215 } | |
3216 $code .= " return value;\n"; | |
3217 $code .= "}\n\n"; | |
3218 $implementation{nameSpaceWebCore}->add($code); | |
3219 } | |
3220 | |
3173 sub GenerateImplementationNamedPropertyAccessors | 3221 sub GenerateImplementationNamedPropertyAccessors |
3174 { | 3222 { |
3175 my $interface = shift; | 3223 my $interface = shift; |
3176 | 3224 |
3177 my $interfaceName = $interface->name; | 3225 my $interfaceName = $interface->name; |
3178 my $implClassName = GetImplName($interface); | 3226 my $implClassName = GetImplName($interface); |
3179 my $v8ClassName = GetV8ClassName($interface); | 3227 my $v8ClassName = GetV8ClassName($interface); |
3180 | 3228 |
3181 my $namedGetterFunction = GetNamedGetterFunction($interface); | 3229 my $namedGetterFunction = GetNamedGetterFunction($interface); |
3182 my $hasCustomNamedGetter = $namedGetterFunction ? $namedGetterFunction->sign ature->extendedAttributes->{"Custom"} : 0; | 3230 my $hasCustomNamedGetter = $namedGetterFunction ? $namedGetterFunction->sign ature->extendedAttributes->{"Custom"} : 0; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3348 if ($type eq "DOMString") { | 3396 if ($type eq "DOMString") { |
3349 my $nullCheck = ""; | 3397 my $nullCheck = ""; |
3350 my $treatNullAs = $namedSetterFunction->parameters->[1]->extendedAttribu tes->{"TreatNullAs"}; | 3398 my $treatNullAs = $namedSetterFunction->parameters->[1]->extendedAttribu tes->{"TreatNullAs"}; |
3351 if ($treatNullAs && $treatNullAs eq "NullString") { | 3399 if ($treatNullAs && $treatNullAs eq "NullString") { |
3352 $nullCheck = "WithNullCheck"; | 3400 $nullCheck = "WithNullCheck"; |
3353 } | 3401 } |
3354 $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<${nullChe ck}>, propertyValue, value);\n"; | 3402 $code .= " V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<${nullChe ck}>, propertyValue, value);\n"; |
3355 } else { | 3403 } else { |
3356 $code .= " $nativeType propertyValue = $nativeValue;\n"; | 3404 $code .= " $nativeType propertyValue = $nativeValue;\n"; |
3357 } | 3405 } |
3358 $code .= " bool result = collection->${methodName}(propertyName, property Value$extraArguments);\n"; | 3406 $code .= " bool result = collection->${methodName}(propertyName, property Value, value->IsNull(), value->IsUndefined()$extraArguments);\n"; |
3359 $code .= " if (!result)\n"; | 3407 $code .= " if (!result)\n"; |
3360 $code .= " return v8Undefined();\n"; | 3408 $code .= " return v8Undefined();\n"; |
3361 if ($raisesExceptions) { | 3409 if ($raisesExceptions) { |
3362 $code .= " if (ec)\n"; | 3410 $code .= " if (ec)\n"; |
3363 $code .= " return setDOMException(ec, info.GetIsolate());\n"; | 3411 $code .= " return setDOMException(ec, info.GetIsolate());\n"; |
3364 } | 3412 } |
3365 $code .= " return value;\n"; | 3413 $code .= " return value;\n"; |
3366 $code .= "}\n\n"; | 3414 $code .= "}\n\n"; |
3367 $implementation{nameSpaceWebCore}->add($code); | 3415 $implementation{nameSpaceWebCore}->add($code); |
3368 } | 3416 } |
(...skipping 2121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5490 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { | 5538 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { |
5491 $found = 1; | 5539 $found = 1; |
5492 } | 5540 } |
5493 return 1 if $found; | 5541 return 1 if $found; |
5494 }, 0); | 5542 }, 0); |
5495 | 5543 |
5496 return $found; | 5544 return $found; |
5497 } | 5545 } |
5498 | 5546 |
5499 1; | 5547 1; |
OLD | NEW |