| 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 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 { | 1202 { |
| 1203 my $function = shift; | 1203 my $function = shift; |
| 1204 my $interface = shift; | 1204 my $interface = shift; |
| 1205 my $forMainWorldSuffix = shift; | 1205 my $forMainWorldSuffix = shift; |
| 1206 | 1206 |
| 1207 my $implClassName = GetImplName($interface); | 1207 my $implClassName = GetImplName($interface); |
| 1208 my $v8ClassName = GetV8ClassName($interface); | 1208 my $v8ClassName = GetV8ClassName($interface); |
| 1209 my $funcName = $function->name; | 1209 my $funcName = $function->name; |
| 1210 | 1210 |
| 1211 my $functionLength = GetFunctionLength($function); | 1211 my $functionLength = GetFunctionLength($function); |
| 1212 my $signature = "v8::Signature::New(V8PerIsolateData::from(info.GetIsolate()
)->rawTemplate(&" . $v8ClassName . "::wrapperTypeInfo, currentWorldType))"; | 1212 my $signature = "v8::Signature::New(info.GetIsolate(), V8PerIsolateData::fro
m(info.GetIsolate())->rawTemplate(&" . $v8ClassName . "::wrapperTypeInfo, curren
tWorldType))"; |
| 1213 if ($function->extendedAttributes->{"DoNotCheckSignature"}) { | 1213 if ($function->extendedAttributes->{"DoNotCheckSignature"}) { |
| 1214 $signature = "v8::Local<v8::Signature>()"; | 1214 $signature = "v8::Local<v8::Signature>()"; |
| 1215 } | 1215 } |
| 1216 | 1216 |
| 1217 my $newTemplateParams = "${implClassName}V8Internal::${funcName}MethodCallba
ck${forMainWorldSuffix}, v8Undefined(), $signature"; | 1217 my $newTemplateParams = "${implClassName}V8Internal::${funcName}MethodCallba
ck${forMainWorldSuffix}, v8Undefined(), $signature"; |
| 1218 | 1218 |
| 1219 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 1219 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
| 1220 $implementation{nameSpaceInternal}->add(<<END); | 1220 $implementation{nameSpaceInternal}->add(<<END); |
| 1221 static void ${funcName}OriginSafeMethodGetter${forMainWorldSuffix}(const v8::Pro
pertyCallbackInfo<v8::Value>& info) | 1221 static void ${funcName}OriginSafeMethodGetter${forMainWorldSuffix}(const v8::Pro
pertyCallbackInfo<v8::Value>& info) |
| 1222 { | 1222 { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1234 return; | 1234 return; |
| 1235 } | 1235 } |
| 1236 ${implClassName}* imp = ${v8ClassName}::toNative(holder); | 1236 ${implClassName}* imp = ${v8ClassName}::toNative(holder); |
| 1237 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu
rityError)) { | 1237 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu
rityError)) { |
| 1238 static int sharedTemplateUniqueKey; | 1238 static int sharedTemplateUniqueKey; |
| 1239 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate(
currentWorldType, &sharedTemplateUniqueKey, $newTemplateParams, $functionLength)
; | 1239 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate(
currentWorldType, &sharedTemplateUniqueKey, $newTemplateParams, $functionLength)
; |
| 1240 v8SetReturnValue(info, sharedTemplate->GetFunction()); | 1240 v8SetReturnValue(info, sharedTemplate->GetFunction()); |
| 1241 return; | 1241 return; |
| 1242 } | 1242 } |
| 1243 | 1243 |
| 1244 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N
ewSymbol("${funcName}")); | 1244 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N
ewFromUtf8(info.GetIsolate(), "${funcName}", v8::String::kInternalizedString)); |
| 1245 if (!hiddenValue.IsEmpty()) { | 1245 if (!hiddenValue.IsEmpty()) { |
| 1246 v8SetReturnValue(info, hiddenValue); | 1246 v8SetReturnValue(info, hiddenValue); |
| 1247 return; | 1247 return; |
| 1248 } | 1248 } |
| 1249 | 1249 |
| 1250 v8SetReturnValue(info, privateTemplate->GetFunction()); | 1250 v8SetReturnValue(info, privateTemplate->GetFunction()); |
| 1251 } | 1251 } |
| 1252 | 1252 |
| 1253 END | 1253 END |
| 1254 $implementation{nameSpaceInternal}->add(<<END); | 1254 $implementation{nameSpaceInternal}->add(<<END); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1502 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 1502 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 1503 $code .= "\n"; | 1503 $code .= "\n"; |
| 1504 $implementation{nameSpaceInternal}->add($code); | 1504 $implementation{nameSpaceInternal}->add($code); |
| 1505 return; | 1505 return; |
| 1506 # Skip the rest of the function! | 1506 # Skip the rest of the function! |
| 1507 } | 1507 } |
| 1508 my $imp = 0; | 1508 my $imp = 0; |
| 1509 if ($attrCached) { | 1509 if ($attrCached) { |
| 1510 $imp = 1; | 1510 $imp = 1; |
| 1511 $code .= <<END; | 1511 $code .= <<END; |
| 1512 v8::Handle<v8::String> propertyName = v8::String::NewSymbol("${attrName}"); | 1512 v8::Handle<v8::String> propertyName = v8::String::NewFromUtf8(info.GetIsolat
e(), "${attrName}", v8::String::kInternalizedString); |
| 1513 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); | 1513 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); |
| 1514 if (!imp->$attrCached()) { | 1514 if (!imp->$attrCached()) { |
| 1515 v8::Handle<v8::Value> jsValue = info.Holder()->GetHiddenValue(propertyNa
me); | 1515 v8::Handle<v8::Value> jsValue = info.Holder()->GetHiddenValue(propertyNa
me); |
| 1516 if (!jsValue.IsEmpty()) { | 1516 if (!jsValue.IsEmpty()) { |
| 1517 v8SetReturnValue(info, jsValue); | 1517 v8SetReturnValue(info, jsValue); |
| 1518 return; | 1518 return; |
| 1519 } | 1519 } |
| 1520 } | 1520 } |
| 1521 END | 1521 END |
| 1522 } | 1522 } |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2118 if ($useExceptions) { | 2118 if ($useExceptions) { |
| 2119 $code .= " if (!exceptionState.hadException())\n"; | 2119 $code .= " if (!exceptionState.hadException())\n"; |
| 2120 $code .= " wrapper->commitChange();\n"; | 2120 $code .= " wrapper->commitChange();\n"; |
| 2121 } else { | 2121 } else { |
| 2122 $code .= " wrapper->commitChange();\n"; | 2122 $code .= " wrapper->commitChange();\n"; |
| 2123 } | 2123 } |
| 2124 } | 2124 } |
| 2125 | 2125 |
| 2126 if ($attrCached) { | 2126 if ($attrCached) { |
| 2127 $code .= <<END; | 2127 $code .= <<END; |
| 2128 info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("${attrName}")); // I
nvalidate the cached value. | 2128 info.Holder()->DeleteHiddenValue(v8::String::NewFromUtf8(info.GetIsolate(),
"${attrName}", v8::String::kInternalizedString)); // Invalidate the cached value
. |
| 2129 END | 2129 END |
| 2130 } | 2130 } |
| 2131 | 2131 |
| 2132 $code .= "}\n"; # end of setter | 2132 $code .= "}\n"; # end of setter |
| 2133 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 2133 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 2134 $code .= "\n"; | 2134 $code .= "\n"; |
| 2135 $implementation{nameSpaceInternal}->add($code); | 2135 $implementation{nameSpaceInternal}->add($code); |
| 2136 } | 2136 } |
| 2137 | 2137 |
| 2138 sub GenerateParametersCheckExpression | 2138 sub GenerateParametersCheckExpression |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3085 { | 3085 { |
| 3086 // This is only for getting a unique pointer which we can pass to privateTem
plate. | 3086 // This is only for getting a unique pointer which we can pass to privateTem
plate. |
| 3087 static int privateTemplateUniqueKey; | 3087 static int privateTemplateUniqueKey; |
| 3088 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 3088 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 3089 v8::Handle<v8::FunctionTemplate> result = data->privateTemplateIfExists(curr
entWorldType, &privateTemplateUniqueKey); | 3089 v8::Handle<v8::FunctionTemplate> result = data->privateTemplateIfExists(curr
entWorldType, &privateTemplateUniqueKey); |
| 3090 if (!result.IsEmpty()) | 3090 if (!result.IsEmpty()) |
| 3091 return result; | 3091 return result; |
| 3092 | 3092 |
| 3093 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink\", \"BuildDOMTemplate"); | 3093 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink\", \"BuildDOMTemplate"); |
| 3094 v8::HandleScope scope(isolate); | 3094 v8::HandleScope scope(isolate); |
| 3095 result = v8::FunctionTemplate::New(${v8ClassName}ConstructorCallback); | 3095 result = v8::FunctionTemplate::New(isolate, ${v8ClassName}ConstructorCallbac
k); |
| 3096 | 3096 |
| 3097 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); | 3097 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); |
| 3098 instanceTemplate->SetInternalFieldCount(${v8ClassName}::internalFieldCount); | 3098 instanceTemplate->SetInternalFieldCount(${v8ClassName}::internalFieldCount); |
| 3099 result->SetClassName(v8::String::NewSymbol("${implClassName}")); | 3099 result->SetClassName(v8::String::NewFromUtf8(isolate, "${implClassName}", v8
::String::kInternalizedString)); |
| 3100 result->Inherit(${v8ClassName}::GetTemplate(isolate, currentWorldType)); | 3100 result->Inherit(${v8ClassName}::GetTemplate(isolate, currentWorldType)); |
| 3101 data->setPrivateTemplate(currentWorldType, &privateTemplateUniqueKey, result
); | 3101 data->setPrivateTemplate(currentWorldType, &privateTemplateUniqueKey, result
); |
| 3102 | 3102 |
| 3103 return scope.Close(result); | 3103 return scope.Close(result); |
| 3104 } | 3104 } |
| 3105 | 3105 |
| 3106 END | 3106 END |
| 3107 $implementation{nameSpaceWebCore}->add($code); | 3107 $implementation{nameSpaceWebCore}->add($code); |
| 3108 } | 3108 } |
| 3109 | 3109 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3275 my $attrExt = $attribute->extendedAttributes; | 3275 my $attrExt = $attribute->extendedAttributes; |
| 3276 my $code = ""; | 3276 my $code = ""; |
| 3277 | 3277 |
| 3278 my ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorld, $
data, $accessControl, $propAttribute, $onProto) = GenerateAttributeConfiguration
Parameters($interface, $attribute); | 3278 my ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorld, $
data, $accessControl, $propAttribute, $onProto) = GenerateAttributeConfiguration
Parameters($interface, $attribute); |
| 3279 | 3279 |
| 3280 die "Static attributes do not support optimized getters or setters for the m
ain world" if $getterForMainWorld || $setterForMainWorld; | 3280 die "Static attributes do not support optimized getters or setters for the m
ain world" if $getterForMainWorld || $setterForMainWorld; |
| 3281 | 3281 |
| 3282 my $conditionalString = GenerateConditionalString($attribute); | 3282 my $conditionalString = GenerateConditionalString($attribute); |
| 3283 | 3283 |
| 3284 $code .= "#if ${conditionalString}\n" if $conditionalString; | 3284 $code .= "#if ${conditionalString}\n" if $conditionalString; |
| 3285 $code .= " functionTemplate->SetNativeDataProperty(v8::String::NewSymbol(
\"$attrName\"), $getter, $setter, v8::External::New(isolate, $data), $propAttrib
ute, v8::Handle<v8::AccessorSignature>(), $accessControl);\n"; | 3285 $code .= " functionTemplate->SetNativeDataProperty(v8::String::NewFromUtf
8(isolate, \"$attrName\", v8::String::kInternalizedString), $getter, $setter, v8
::External::New(isolate, $data), $propAttribute, v8::Handle<v8::AccessorSignatur
e>(), $accessControl);\n"; |
| 3286 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 3286 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 3287 | 3287 |
| 3288 return $code; | 3288 return $code; |
| 3289 } | 3289 } |
| 3290 | 3290 |
| 3291 sub IsStandardFunction | 3291 sub IsStandardFunction |
| 3292 { | 3292 { |
| 3293 my $interface = shift; | 3293 my $interface = shift; |
| 3294 my $function = shift; | 3294 my $function = shift; |
| 3295 | 3295 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3351 | 3351 |
| 3352 if ($interface->extendedAttributes->{"CheckSecurity"} && $attrExt->{"DoNotCh
eckSecurity"}) { | 3352 if ($interface->extendedAttributes->{"CheckSecurity"} && $attrExt->{"DoNotCh
eckSecurity"}) { |
| 3353 my $setter = $attrExt->{"ReadOnly"} ? "0" : "${implClassName}V8Internal:
:${implClassName}OriginSafeMethodSetterCallback"; | 3353 my $setter = $attrExt->{"ReadOnly"} ? "0" : "${implClassName}V8Internal:
:${implClassName}OriginSafeMethodSetterCallback"; |
| 3354 # Functions that are marked DoNotCheckSecurity are always readable but i
f they are changed | 3354 # Functions that are marked DoNotCheckSecurity are always readable but i
f they are changed |
| 3355 # and then accessed on a different domain we do not return the underlyin
g value but instead | 3355 # and then accessed on a different domain we do not return the underlyin
g value but instead |
| 3356 # return a new copy of the original function. This is achieved by storin
g the changed value | 3356 # return a new copy of the original function. This is achieved by storin
g the changed value |
| 3357 # as hidden property. | 3357 # as hidden property. |
| 3358 if ($function->extendedAttributes->{"PerWorldBindings"}) { | 3358 if ($function->extendedAttributes->{"PerWorldBindings"}) { |
| 3359 $code .= <<END; | 3359 $code .= <<END; |
| 3360 if (currentWorldType == MainWorld) { | 3360 if (currentWorldType == MainWorld) { |
| 3361 ${conditional8}$template->SetAccessor(v8::String::NewSymbol("$name"), ${
implClassName}V8Internal::${name}OriginSafeMethodGetterCallbackForMainWorld, ${s
etter}, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>($pro
perty_attributes)); | 3361 ${conditional8}$template->SetAccessor(v8::String::NewFromUtf8(isolate, "
$name", v8::String::kInternalizedString), ${implClassName}V8Internal::${name}Ori
ginSafeMethodGetterCallbackForMainWorld, ${setter}, v8Undefined(), v8::ALL_CAN_R
EAD, static_cast<v8::PropertyAttribute>($property_attributes)); |
| 3362 } else { | 3362 } else { |
| 3363 ${conditional8}$template->SetAccessor(v8::String::NewSymbol("$name"), ${
implClassName}V8Internal::${name}OriginSafeMethodGetterCallback, ${setter}, v8Un
defined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>($property_attrib
utes)); | 3363 ${conditional8}$template->SetAccessor(v8::String::NewFromUtf8(isolate, "
$name", v8::String::kInternalizedString), ${implClassName}V8Internal::${name}Ori
ginSafeMethodGetterCallback, ${setter}, v8Undefined(), v8::ALL_CAN_READ, static_
cast<v8::PropertyAttribute>($property_attributes)); |
| 3364 } | 3364 } |
| 3365 END | 3365 END |
| 3366 } else { | 3366 } else { |
| 3367 $code .= " ${conditional4}$template->SetAccessor(v8::String::NewS
ymbol(\"$name\"), ${implClassName}V8Internal::${name}OriginSafeMethodGetterCallb
ack, ${setter}, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribu
te>($property_attributes));\n"; | 3367 $code .= " ${conditional4}$template->SetAccessor(v8::String::NewF
romUtf8(isolate, \"$name\", v8::String::kInternalizedString), ${implClassName}V8
Internal::${name}OriginSafeMethodGetterCallback, ${setter}, v8Undefined(), v8::A
LL_CAN_READ, static_cast<v8::PropertyAttribute>($property_attributes));\n"; |
| 3368 } | 3368 } |
| 3369 | 3369 |
| 3370 return $code; | 3370 return $code; |
| 3371 } | 3371 } |
| 3372 | 3372 |
| 3373 my $signature = "defaultSignature"; | 3373 my $signature = "defaultSignature"; |
| 3374 if ($attrExt->{"DoNotCheckSignature"} || $function->isStatic) { | 3374 if ($attrExt->{"DoNotCheckSignature"} || $function->isStatic) { |
| 3375 $signature = "v8::Local<v8::Signature>()"; | 3375 $signature = "v8::Local<v8::Signature>()"; |
| 3376 } | 3376 } |
| 3377 | 3377 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3389 } | 3389 } |
| 3390 | 3390 |
| 3391 if ($template eq "prototypeTemplate" && $conditional4 eq "" && $signature eq
"defaultSignature" && $property_attributes eq "") { | 3391 if ($template eq "prototypeTemplate" && $conditional4 eq "" && $signature eq
"defaultSignature" && $property_attributes eq "") { |
| 3392 die "This shouldn't happen: Class '$implClassName' $commentInfo\n"; | 3392 die "This shouldn't happen: Class '$implClassName' $commentInfo\n"; |
| 3393 } | 3393 } |
| 3394 | 3394 |
| 3395 my $functionLength = GetFunctionLength($function); | 3395 my $functionLength = GetFunctionLength($function); |
| 3396 | 3396 |
| 3397 if ($function->extendedAttributes->{"PerWorldBindings"}) { | 3397 if ($function->extendedAttributes->{"PerWorldBindings"}) { |
| 3398 $code .= " if (currentWorldType == MainWorld) {\n"; | 3398 $code .= " if (currentWorldType == MainWorld) {\n"; |
| 3399 $code .= " ${conditional8}$template->Set(v8::String::NewSymbol(\"
$name\"), v8::FunctionTemplate::New(${implClassName}V8Internal::${name}MethodCal
lbackForMainWorld, v8Undefined(), ${signature}, $functionLength)$property_attrib
utes);\n"; | 3399 $code .= " ${conditional8}$template->Set(v8::String::NewFromUtf8(
isolate, \"$name\", v8::String::kInternalizedString), v8::FunctionTemplate::New(
isolate, ${implClassName}V8Internal::${name}MethodCallbackForMainWorld, v8Undefi
ned(), ${signature}, $functionLength)$property_attributes);\n"; |
| 3400 $code .= " } else {\n"; | 3400 $code .= " } else {\n"; |
| 3401 $code .= " ${conditional8}$template->Set(v8::String::NewSymbol(\"
$name\"), v8::FunctionTemplate::New(${implClassName}V8Internal::${name}MethodCal
lback, v8Undefined(), ${signature}, $functionLength)$property_attributes);\n"; | 3401 $code .= " ${conditional8}$template->Set(v8::String::NewFromUtf8(
isolate, \"$name\", v8::String::kInternalizedString), v8::FunctionTemplate::New(
isolate, ${implClassName}V8Internal::${name}MethodCallback, v8Undefined(), ${sig
nature}, $functionLength)$property_attributes);\n"; |
| 3402 $code .= " }\n"; | 3402 $code .= " }\n"; |
| 3403 } else { | 3403 } else { |
| 3404 $code .= " ${conditional4}$template->Set(v8::String::NewSymbol(\"$nam
e\"), v8::FunctionTemplate::New(${implClassName}V8Internal::${name}MethodCallbac
k, v8Undefined(), ${signature}, $functionLength)$property_attributes);\n"; | 3404 $code .= " ${conditional4}$template->Set(v8::String::NewFromUtf8(isol
ate, \"$name\", v8::String::kInternalizedString), v8::FunctionTemplate::New(isol
ate, ${implClassName}V8Internal::${name}MethodCallback, v8Undefined(), ${signatu
re}, $functionLength)$property_attributes);\n"; |
| 3405 } | 3405 } |
| 3406 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 3406 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 3407 return $code; | 3407 return $code; |
| 3408 } | 3408 } |
| 3409 | 3409 |
| 3410 sub GenerateIsNullExpression | 3410 sub GenerateIsNullExpression |
| 3411 { | 3411 { |
| 3412 my $type = shift; | 3412 my $type = shift; |
| 3413 my $variableName = shift; | 3413 my $variableName = shift; |
| 3414 if (IsUnionType($type)) { | 3414 if (IsUnionType($type)) { |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4049 | 4049 |
| 4050 $implementation{nameSpaceInternal}->add(<<END); | 4050 $implementation{nameSpaceInternal}->add(<<END); |
| 4051 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i
nfo) | 4051 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i
nfo) |
| 4052 { | 4052 { |
| 4053 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | 4053 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); |
| 4054 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder()); | 4054 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder()); |
| 4055 Vector<String> names; | 4055 Vector<String> names; |
| 4056 collection->namedPropertyEnumerator(names, exceptionState); | 4056 collection->namedPropertyEnumerator(names, exceptionState); |
| 4057 if (exceptionState.throwIfNeeded()) | 4057 if (exceptionState.throwIfNeeded()) |
| 4058 return; | 4058 return; |
| 4059 v8::Handle<v8::Array> v8names = v8::Array::New(names.size()); | 4059 v8::Handle<v8::Array> v8names = v8::Array::New(info.GetIsolate(), names.size
()); |
| 4060 for (size_t i = 0; i < names.size(); ++i) | 4060 for (size_t i = 0; i < names.size(); ++i) |
| 4061 v8names->Set(v8::Integer::New(i, info.GetIsolate()), v8String(names[i],
info.GetIsolate())); | 4061 v8names->Set(v8::Integer::New(info.GetIsolate(), i), v8String(names[i],
info.GetIsolate())); |
| 4062 v8SetReturnValue(info, v8names); | 4062 v8SetReturnValue(info, v8names); |
| 4063 } | 4063 } |
| 4064 | 4064 |
| 4065 END | 4065 END |
| 4066 } | 4066 } |
| 4067 | 4067 |
| 4068 sub GenerateImplementationNamedPropertyQuery | 4068 sub GenerateImplementationNamedPropertyQuery |
| 4069 { | 4069 { |
| 4070 my $interface = shift; | 4070 my $interface = shift; |
| 4071 my $implClassName = GetImplName($interface); | 4071 my $implClassName = GetImplName($interface); |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4580 } | 4580 } |
| 4581 if ($interfaceName eq "HTMLDocument" or $interfaceName eq "DedicatedWorkerGl
obalScope" or $interfaceName eq "SharedWorkerGlobalScope" or $interfaceName eq "
ServiceWorkerGlobalScope") { | 4581 if ($interfaceName eq "HTMLDocument" or $interfaceName eq "DedicatedWorkerGl
obalScope" or $interfaceName eq "SharedWorkerGlobalScope" or $interfaceName eq "
ServiceWorkerGlobalScope") { |
| 4582 $code .= <<END; | 4582 $code .= <<END; |
| 4583 functionTemplate->SetHiddenPrototype(true); | 4583 functionTemplate->SetHiddenPrototype(true); |
| 4584 END | 4584 END |
| 4585 } | 4585 } |
| 4586 | 4586 |
| 4587 $code .= <<END; | 4587 $code .= <<END; |
| 4588 | 4588 |
| 4589 // Custom toString template | 4589 // Custom toString template |
| 4590 functionTemplate->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::c
urrent()->toStringTemplate()); | 4590 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin
g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate()); |
| 4591 return functionTemplate; | 4591 return functionTemplate; |
| 4592 } | 4592 } |
| 4593 | 4593 |
| 4594 END | 4594 END |
| 4595 $implementation{nameSpaceWebCore}->add($code); | 4595 $implementation{nameSpaceWebCore}->add($code); |
| 4596 | 4596 |
| 4597 $implementation{nameSpaceWebCore}->add(<<END); | 4597 $implementation{nameSpaceWebCore}->add(<<END); |
| 4598 v8::Handle<v8::FunctionTemplate> ${v8ClassName}::GetTemplate(v8::Isolate* isolat
e, WrapperWorldType currentWorldType) | 4598 v8::Handle<v8::FunctionTemplate> ${v8ClassName}::GetTemplate(v8::Isolate* isolat
e, WrapperWorldType currentWorldType) |
| 4599 { | 4599 { |
| 4600 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 4600 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 4601 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); | 4601 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); |
| 4602 if (result != data->templateMap(currentWorldType).end()) | 4602 if (result != data->templateMap(currentWorldType).end()) |
| 4603 return result->value.newLocal(isolate); | 4603 return result->value.newLocal(isolate); |
| 4604 | 4604 |
| 4605 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 4605 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 4606 v8::HandleScope handleScope(isolate); | 4606 v8::EscapableHandleScope handleScope(isolate); |
| 4607 v8::Handle<v8::FunctionTemplate> templ = | 4607 v8::Local<v8::FunctionTemplate> templ = |
| 4608 Configure${v8ClassName}Template(data->rawTemplate(&wrapperTypeInfo, curr
entWorldType), isolate, currentWorldType); | 4608 Configure${v8ClassName}Template(data->rawTemplate(&wrapperTypeInfo, curr
entWorldType), isolate, currentWorldType); |
| 4609 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | 4609 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); |
| 4610 return handleScope.Close(templ); | 4610 return handleScope.Escape(templ); |
| 4611 } | 4611 } |
| 4612 | 4612 |
| 4613 END | 4613 END |
| 4614 $implementation{nameSpaceWebCore}->add(<<END); | 4614 $implementation{nameSpaceWebCore}->add(<<END); |
| 4615 bool ${v8ClassName}::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* iso
late, WrapperWorldType currentWorldType) | 4615 bool ${v8ClassName}::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* iso
late, WrapperWorldType currentWorldType) |
| 4616 { | 4616 { |
| 4617 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, currentWorldType); | 4617 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, currentWorldType); |
| 4618 } | 4618 } |
| 4619 | 4619 |
| 4620 END | 4620 END |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4657 | 4657 |
| 4658 if (@perContextEnabledFunctions) { | 4658 if (@perContextEnabledFunctions) { |
| 4659 my $code = ""; | 4659 my $code = ""; |
| 4660 $code .= <<END; | 4660 $code .= <<END; |
| 4661 void ${v8ClassName}::installPerContextEnabledMethods(v8::Handle<v8::Object> prot
otypeTemplate, v8::Isolate* isolate) | 4661 void ${v8ClassName}::installPerContextEnabledMethods(v8::Handle<v8::Object> prot
otypeTemplate, v8::Isolate* isolate) |
| 4662 { | 4662 { |
| 4663 UNUSED_PARAM(prototypeTemplate); | 4663 UNUSED_PARAM(prototypeTemplate); |
| 4664 END | 4664 END |
| 4665 # Define per-context enabled operations. | 4665 # Define per-context enabled operations. |
| 4666 $code .= <<END; | 4666 $code .= <<END; |
| 4667 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(i
solate, worldType(isolate))); | 4667 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, GetT
emplate(isolate, worldType(isolate))); |
| 4668 UNUSED_PARAM(defaultSignature); | 4668 UNUSED_PARAM(defaultSignature); |
| 4669 | 4669 |
| 4670 ExecutionContext* context = toExecutionContext(prototypeTemplate->CreationCo
ntext()); | 4670 ExecutionContext* context = toExecutionContext(prototypeTemplate->CreationCo
ntext()); |
| 4671 END | 4671 END |
| 4672 | 4672 |
| 4673 foreach my $perContextEnabledFunction (@perContextEnabledFunctions) { | 4673 foreach my $perContextEnabledFunction (@perContextEnabledFunctions) { |
| 4674 my $contextEnabledFunction = GetContextEnabledFunctionName($perConte
xtEnabledFunction); | 4674 my $contextEnabledFunction = GetContextEnabledFunctionName($perConte
xtEnabledFunction); |
| 4675 my $functionLength = GetFunctionLength($perContextEnabledFunction); | 4675 my $functionLength = GetFunctionLength($perContextEnabledFunction); |
| 4676 my $conditionalString = GenerateConditionalString($perContextEnabled
Function); | 4676 my $conditionalString = GenerateConditionalString($perContextEnabled
Function); |
| 4677 $code .= "\n#if ${conditionalString}\n" if $conditionalString; | 4677 $code .= "\n#if ${conditionalString}\n" if $conditionalString; |
| 4678 $code .= " if (context && context->isDocument() && ${contextEnabl
edFunction}(toDocument(context)))\n"; | 4678 $code .= " if (context && context->isDocument() && ${contextEnabl
edFunction}(toDocument(context)))\n"; |
| 4679 my $name = $perContextEnabledFunction->name; | 4679 my $name = $perContextEnabledFunction->name; |
| 4680 $code .= <<END; | 4680 $code .= <<END; |
| 4681 prototypeTemplate->Set(v8::String::NewSymbol("${name}"), v8::FunctionTem
plate::New(${implClassName}V8Internal::${name}MethodCallback, v8Undefined(), def
aultSignature, $functionLength)->GetFunction()); | 4681 prototypeTemplate->Set(v8::String::NewFromUtf8(isolate, "${name}", v8::S
tring::kInternalizedString), v8::FunctionTemplate::New(isolate, ${implClassName}
V8Internal::${name}MethodCallback, v8Undefined(), defaultSignature, $functionLen
gth)->GetFunction()); |
| 4682 END | 4682 END |
| 4683 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 4683 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 4684 } | 4684 } |
| 4685 | 4685 |
| 4686 $code .= <<END; | 4686 $code .= <<END; |
| 4687 } | 4687 } |
| 4688 | 4688 |
| 4689 END | 4689 END |
| 4690 $implementation{nameSpaceWebCore}->add($code); | 4690 $implementation{nameSpaceWebCore}->add($code); |
| 4691 } | 4691 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4711 } | 4711 } |
| 4712 | 4712 |
| 4713 if ($interfaceName eq "Window") { | 4713 if ($interfaceName eq "Window") { |
| 4714 $implementation{nameSpaceWebCore}->add(<<END); | 4714 $implementation{nameSpaceWebCore}->add(<<END); |
| 4715 v8::Handle<v8::ObjectTemplate> V8Window::GetShadowObjectTemplate(v8::Isolate* is
olate, WrapperWorldType currentWorldType) | 4715 v8::Handle<v8::ObjectTemplate> V8Window::GetShadowObjectTemplate(v8::Isolate* is
olate, WrapperWorldType currentWorldType) |
| 4716 { | 4716 { |
| 4717 if (currentWorldType == MainWorld) { | 4717 if (currentWorldType == MainWorld) { |
| 4718 DEFINE_STATIC_LOCAL(v8::Persistent<v8::ObjectTemplate>, V8WindowShadowOb
jectCacheForMainWorld, ()); | 4718 DEFINE_STATIC_LOCAL(v8::Persistent<v8::ObjectTemplate>, V8WindowShadowOb
jectCacheForMainWorld, ()); |
| 4719 if (V8WindowShadowObjectCacheForMainWorld.IsEmpty()) { | 4719 if (V8WindowShadowObjectCacheForMainWorld.IsEmpty()) { |
| 4720 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 4720 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 4721 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 4721 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isola
te); |
| 4722 ConfigureShadowObjectTemplate(templ, isolate, currentWorldType); | 4722 ConfigureShadowObjectTemplate(templ, isolate, currentWorldType); |
| 4723 V8WindowShadowObjectCacheForMainWorld.Reset(isolate, templ); | 4723 V8WindowShadowObjectCacheForMainWorld.Reset(isolate, templ); |
| 4724 return templ; | 4724 return templ; |
| 4725 } | 4725 } |
| 4726 return v8::Local<v8::ObjectTemplate>::New(isolate, V8WindowShadowObjectC
acheForMainWorld); | 4726 return v8::Local<v8::ObjectTemplate>::New(isolate, V8WindowShadowObjectC
acheForMainWorld); |
| 4727 } else { | 4727 } else { |
| 4728 DEFINE_STATIC_LOCAL(v8::Persistent<v8::ObjectTemplate>, V8WindowShadowOb
jectCacheForNonMainWorld, ()); | 4728 DEFINE_STATIC_LOCAL(v8::Persistent<v8::ObjectTemplate>, V8WindowShadowOb
jectCacheForNonMainWorld, ()); |
| 4729 if (V8WindowShadowObjectCacheForNonMainWorld.IsEmpty()) { | 4729 if (V8WindowShadowObjectCacheForNonMainWorld.IsEmpty()) { |
| 4730 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 4730 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 4731 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 4731 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isola
te); |
| 4732 ConfigureShadowObjectTemplate(templ, isolate, currentWorldType); | 4732 ConfigureShadowObjectTemplate(templ, isolate, currentWorldType); |
| 4733 V8WindowShadowObjectCacheForNonMainWorld.Reset(isolate, templ); | 4733 V8WindowShadowObjectCacheForNonMainWorld.Reset(isolate, templ); |
| 4734 return templ; | 4734 return templ; |
| 4735 } | 4735 } |
| 4736 return v8::Local<v8::ObjectTemplate>::New(isolate, V8WindowShadowObjectC
acheForNonMainWorld); | 4736 return v8::Local<v8::ObjectTemplate>::New(isolate, V8WindowShadowObjectC
acheForNonMainWorld); |
| 4737 } | 4737 } |
| 4738 } | 4738 } |
| 4739 | 4739 |
| 4740 END | 4740 END |
| 4741 } | 4741 } |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5535 } else { | 5535 } else { |
| 5536 AddIncludesForType($type); | 5536 AddIncludesForType($type); |
| 5537 } | 5537 } |
| 5538 $code .= "V8PerIsolateData::from(isolate)->rawTemplate(&V8${type
}::wrapperTypeInfo, currentWorldType)"; | 5538 $code .= "V8PerIsolateData::from(isolate)->rawTemplate(&V8${type
}::wrapperTypeInfo, currentWorldType)"; |
| 5539 } | 5539 } |
| 5540 } else { | 5540 } else { |
| 5541 $code .= "v8::Handle<v8::FunctionTemplate>()"; | 5541 $code .= "v8::Handle<v8::FunctionTemplate>()"; |
| 5542 } | 5542 } |
| 5543 } | 5543 } |
| 5544 $code .= " };\n"; | 5544 $code .= " };\n"; |
| 5545 $code .= " v8::Handle<v8::Signature> ${name}Signature = v8::Signature::Ne
w(functionTemplate, ${name}Argc, ${name}Argv);\n"; | 5545 $code .= " v8::Handle<v8::Signature> ${name}Signature = v8::Signature::Ne
w(isolate, functionTemplate, ${name}Argc, ${name}Argv);\n"; |
| 5546 return $code; | 5546 return $code; |
| 5547 } | 5547 } |
| 5548 | 5548 |
| 5549 | 5549 |
| 5550 sub RequiresCustomSignature | 5550 sub RequiresCustomSignature |
| 5551 { | 5551 { |
| 5552 my $function = shift; | 5552 my $function = shift; |
| 5553 # No signature needed for Custom function | 5553 # No signature needed for Custom function |
| 5554 if (HasCustomMethod($function->extendedAttributes)) { | 5554 if (HasCustomMethod($function->extendedAttributes)) { |
| 5555 return 0; | 5555 return 0; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5707 return "" if $isReturnValue; | 5707 return "" if $isReturnValue; |
| 5708 return "$indent$receiver v8Undefined();" | 5708 return "$indent$receiver v8Undefined();" |
| 5709 } | 5709 } |
| 5710 | 5710 |
| 5711 # HTML5 says that unsigned reflected attributes should be in the range | 5711 # HTML5 says that unsigned reflected attributes should be in the range |
| 5712 # [0, 2^31). When a value isn't in this range, a default value (or 0) | 5712 # [0, 2^31). When a value isn't in this range, a default value (or 0) |
| 5713 # should be returned instead. | 5713 # should be returned instead. |
| 5714 if ($extendedAttributes->{"Reflect"} and ($type eq "unsigned long" or $type
eq "unsigned short")) { | 5714 if ($extendedAttributes->{"Reflect"} and ($type eq "unsigned long" or $type
eq "unsigned short")) { |
| 5715 $nativeValue =~ s/getUnsignedIntegralAttribute/getIntegralAttribute/g; | 5715 $nativeValue =~ s/getUnsignedIntegralAttribute/getIntegralAttribute/g; |
| 5716 return "${indent}v8SetReturnValueUnsigned(${getCallbackInfo}, std::max(0
, ${nativeValue}));" if $isReturnValue; | 5716 return "${indent}v8SetReturnValueUnsigned(${getCallbackInfo}, std::max(0
, ${nativeValue}));" if $isReturnValue; |
| 5717 return "$indent$receiver v8::Integer::NewFromUnsigned(std::max(0, " . $n
ativeValue . "), $getIsolate);"; | 5717 return "$indent$receiver v8::Integer::NewFromUnsigned($getIsolate, std::
max(0, " . $nativeValue . "));"; |
| 5718 } | 5718 } |
| 5719 | 5719 |
| 5720 my $nativeType = GetNativeType($type); | 5720 my $nativeType = GetNativeType($type); |
| 5721 if ($nativeType eq "int") { | 5721 if ($nativeType eq "int") { |
| 5722 return "${indent}v8SetReturnValueInt(${getCallbackInfo}, ${nativeValue})
;" if $isReturnValue; | 5722 return "${indent}v8SetReturnValueInt(${getCallbackInfo}, ${nativeValue})
;" if $isReturnValue; |
| 5723 return "$indent$receiver v8::Integer::New($nativeValue, $getIsolate);"; | 5723 return "$indent$receiver v8::Integer::New($getIsolate, $nativeValue);"; |
| 5724 } | 5724 } |
| 5725 | 5725 |
| 5726 if ($nativeType eq "unsigned") { | 5726 if ($nativeType eq "unsigned") { |
| 5727 return "${indent}v8SetReturnValueUnsigned(${getCallbackInfo}, ${nativeVa
lue});" if $isReturnValue; | 5727 return "${indent}v8SetReturnValueUnsigned(${getCallbackInfo}, ${nativeVa
lue});" if $isReturnValue; |
| 5728 return "$indent$receiver v8::Integer::NewFromUnsigned($nativeValue, $get
Isolate);"; | 5728 return "$indent$receiver v8::Integer::NewFromUnsigned($getIsolate, $nati
veValue);"; |
| 5729 } | 5729 } |
| 5730 | 5730 |
| 5731 if ($type eq "Date") { | 5731 if ($type eq "Date") { |
| 5732 return "${indent}v8SetReturnValue(${getCallbackInfo}, v8DateOrNull($nati
veValue, $getIsolate));" if $isReturnValue; | 5732 return "${indent}v8SetReturnValue(${getCallbackInfo}, v8DateOrNull($nati
veValue, $getIsolate));" if $isReturnValue; |
| 5733 return "$indent$receiver v8DateOrNull($nativeValue, $getIsolate);" | 5733 return "$indent$receiver v8DateOrNull($nativeValue, $getIsolate);" |
| 5734 } | 5734 } |
| 5735 | 5735 |
| 5736 # long long and unsigned long long are not representable in ECMAScript. | 5736 # long long and unsigned long long are not representable in ECMAScript. |
| 5737 if ($type eq "long long" or $type eq "unsigned long long" or $type eq "DOMTi
meStamp") { | 5737 if ($type eq "long long" or $type eq "unsigned long long" or $type eq "DOMTi
meStamp") { |
| 5738 return "${indent}v8SetReturnValue(${getCallbackInfo}, static_cast<double
>($nativeValue));" if $isReturnValue; | 5738 return "${indent}v8SetReturnValue(${getCallbackInfo}, static_cast<double
>($nativeValue));" if $isReturnValue; |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6380 return 1 if $name eq "FileWriterCallback"; | 6380 return 1 if $name eq "FileWriterCallback"; |
| 6381 return 1 if $name eq "MetadataCallback"; | 6381 return 1 if $name eq "MetadataCallback"; |
| 6382 # requestAnimationFrame | 6382 # requestAnimationFrame |
| 6383 return 1 if $name eq "RequestAnimationFrameCallback"; | 6383 return 1 if $name eq "RequestAnimationFrameCallback"; |
| 6384 # Used everywhere | 6384 # Used everywhere |
| 6385 return 1 if $name eq "VoidCallback"; | 6385 return 1 if $name eq "VoidCallback"; |
| 6386 return 0; | 6386 return 0; |
| 6387 } | 6387 } |
| 6388 | 6388 |
| 6389 1; | 6389 1; |
| OLD | NEW |