| 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 3118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3129 my @propAttributeList; | 3129 my @propAttributeList; |
| 3130 if ($attrExt->{"NotEnumerable"} || $isConstructor) { | 3130 if ($attrExt->{"NotEnumerable"} || $isConstructor) { |
| 3131 push(@propAttributeList, "v8::DontEnum"); | 3131 push(@propAttributeList, "v8::DontEnum"); |
| 3132 } | 3132 } |
| 3133 if ($attrExt->{"Unforgeable"} && !$isConstructor) { | 3133 if ($attrExt->{"Unforgeable"} && !$isConstructor) { |
| 3134 push(@propAttributeList, "v8::DontDelete"); | 3134 push(@propAttributeList, "v8::DontDelete"); |
| 3135 } | 3135 } |
| 3136 @propAttributeList = ("v8::None") unless @propAttributeList; | 3136 @propAttributeList = ("v8::None") unless @propAttributeList; |
| 3137 my $propAttribute = join(" | ", @propAttributeList); | 3137 my $propAttribute = join(" | ", @propAttributeList); |
| 3138 | 3138 |
| 3139 my $on_proto = "0 /* on instance */"; | 3139 my $onProto = "0 /* on instance */"; |
| 3140 my $data = "0"; # no data | 3140 my $data = "0"; # no data |
| 3141 | 3141 |
| 3142 # Constructor | 3142 # Constructor |
| 3143 if ($isConstructor) { | 3143 if ($isConstructor) { |
| 3144 my $constructorType = $attribute->type; | 3144 my $constructorType = $attribute->type; |
| 3145 $constructorType =~ s/Constructor$//; | 3145 $constructorType =~ s/Constructor$//; |
| 3146 | 3146 |
| 3147 # For NamedConstructors we do not generate a header file. The code for t
he NamedConstructor | 3147 # For NamedConstructors we do not generate a header file. The code for t
he NamedConstructor |
| 3148 # gets generated when we generate the code for its interface. | 3148 # gets generated when we generate the code for its interface. |
| 3149 if ($constructorType !~ /Constructor$/) { | 3149 if ($constructorType !~ /Constructor$/) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3168 } | 3168 } |
| 3169 | 3169 |
| 3170 # Read only attributes | 3170 # Read only attributes |
| 3171 if (IsReadonly($attribute)) { | 3171 if (IsReadonly($attribute)) { |
| 3172 $setter = "0"; | 3172 $setter = "0"; |
| 3173 $setterForMainWorld = "0"; | 3173 $setterForMainWorld = "0"; |
| 3174 } | 3174 } |
| 3175 | 3175 |
| 3176 # An accessor can be installed on the proto | 3176 # An accessor can be installed on the proto |
| 3177 if ($attrExt->{"OnProto"}) { | 3177 if ($attrExt->{"OnProto"}) { |
| 3178 $on_proto = "1 /* on proto */"; | 3178 $onProto = "1 /* on proto */"; |
| 3179 } | 3179 } |
| 3180 | 3180 |
| 3181 if (!$attrExt->{"PerWorldBindings"}) { | 3181 if (!$attrExt->{"PerWorldBindings"}) { |
| 3182 $getterForMainWorld = "0"; | 3182 $getterForMainWorld = "0"; |
| 3183 $setterForMainWorld = "0"; | 3183 $setterForMainWorld = "0"; |
| 3184 } | 3184 } |
| 3185 | 3185 |
| 3186 return ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorl
d, $data, $accessControl, "static_cast<v8::PropertyAttribute>($propAttribute)",
$on_proto); | 3186 return ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorl
d, $data, $accessControl, "static_cast<v8::PropertyAttribute>($propAttribute)",
$onProto); |
| 3187 } | 3187 } |
| 3188 | 3188 |
| 3189 sub GenerateAttributeConfiguration | 3189 sub GenerateAttributeConfiguration |
| 3190 { | 3190 { |
| 3191 my $interface = shift; | 3191 my $interface = shift; |
| 3192 my $attribute = shift; | 3192 my $attribute = shift; |
| 3193 my $delimiter = shift; | 3193 my $delimiter = shift; |
| 3194 my $indent = shift; | 3194 my $indent = shift; |
| 3195 my $code = ""; | 3195 my $code = ""; |
| 3196 | 3196 |
| 3197 my ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorld, $
data, $accessControl, $propAttribute, $on_proto) = GenerateAttributeConfiguratio
nParameters($interface, $attribute); | 3197 my ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorld, $
data, $accessControl, $propAttribute, $onProto) = GenerateAttributeConfiguration
Parameters($interface, $attribute); |
| 3198 | 3198 |
| 3199 $code .= $indent . " {\"$attrName\", $getter, $setter, $getterForMainWorl
d, $setterForMainWorld, $data, $accessControl, $propAttribute, $on_proto}" . $de
limiter . "\n"; | 3199 $code .= $indent . " {\"$attrName\", $getter, $setter, $getterForMainWorl
d, $setterForMainWorld, $data, $accessControl, $propAttribute, $onProto}" . $del
imiter . "\n"; |
| 3200 return $code; | 3200 return $code; |
| 3201 } | 3201 } |
| 3202 | 3202 |
| 3203 sub GenerateStaticAttribute | 3203 sub GenerateStaticAttribute |
| 3204 { | 3204 { |
| 3205 my $interface = shift; | 3205 my $interface = shift; |
| 3206 my $attribute = shift; | 3206 my $attribute = shift; |
| 3207 my $attrExt = $attribute->extendedAttributes; | 3207 my $attrExt = $attribute->extendedAttributes; |
| 3208 my $code = ""; | 3208 my $code = ""; |
| 3209 | 3209 |
| 3210 my ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorld, $
data, $accessControl, $propAttribute, $on_proto) = GenerateAttributeConfiguratio
nParameters($interface, $attribute); | 3210 my ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorld, $
data, $accessControl, $propAttribute, $onProto) = GenerateAttributeConfiguration
Parameters($interface, $attribute); |
| 3211 | 3211 |
| 3212 die "Static attributes do not support optimized getters or setters for the m
ain world" if $getterForMainWorld || $setterForMainWorld; | 3212 die "Static attributes do not support optimized getters or setters for the m
ain world" if $getterForMainWorld || $setterForMainWorld; |
| 3213 | 3213 |
| 3214 my $conditionalString = GenerateConditionalString($attribute); | 3214 my $conditionalString = GenerateConditionalString($attribute); |
| 3215 | 3215 |
| 3216 $code .= "#if ${conditionalString}\n" if $conditionalString; | 3216 $code .= "#if ${conditionalString}\n" if $conditionalString; |
| 3217 $code .= " desc->SetNativeDataProperty(v8::String::NewSymbol(\"$attrName\
"), $getter, $setter, v8::External::New($data), $propAttribute, v8::Handle<v8::A
ccessorSignature>(), $accessControl);\n"; | 3217 $code .= " desc->SetNativeDataProperty(v8::String::NewSymbol(\"$attrName\
"), $getter, $setter, v8::External::New($data), $propAttribute, v8::Handle<v8::A
ccessorSignature>(), $accessControl);\n"; |
| 3218 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 3218 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 3219 | 3219 |
| 3220 return $code; | 3220 return $code; |
| (...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4297 AddToImplIncludes("bindings/v8/V8DOMConfiguration.h"); | 4297 AddToImplIncludes("bindings/v8/V8DOMConfiguration.h"); |
| 4298 # Put the attributes that disallow shadowing on the shadow object. | 4298 # Put the attributes that disallow shadowing on the shadow object. |
| 4299 if (@disallowsShadowing) { | 4299 if (@disallowsShadowing) { |
| 4300 my $code = ""; | 4300 my $code = ""; |
| 4301 $code .= "static const V8DOMConfiguration::AttributeConfiguration shadow
Attributes[] = {\n"; | 4301 $code .= "static const V8DOMConfiguration::AttributeConfiguration shadow
Attributes[] = {\n"; |
| 4302 $code .= GenerateAttributeConfigurationArray($interface, \@disallowsShad
owing); | 4302 $code .= GenerateAttributeConfigurationArray($interface, \@disallowsShad
owing); |
| 4303 $code .= "};\n\n"; | 4303 $code .= "};\n\n"; |
| 4304 $implementation{nameSpaceWebCore}->add($code); | 4304 $implementation{nameSpaceWebCore}->add($code); |
| 4305 } | 4305 } |
| 4306 | 4306 |
| 4307 my $has_attributes = 0; | 4307 my $hasAttributes = 0; |
| 4308 if (@normalAttributes) { | 4308 if (@normalAttributes) { |
| 4309 $has_attributes = 1; | 4309 $hasAttributes = 1; |
| 4310 my $code = ""; | 4310 my $code = ""; |
| 4311 $code .= "static const V8DOMConfiguration::AttributeConfiguration ${v8Cl
assName}Attributes[] = {\n"; | 4311 $code .= "static const V8DOMConfiguration::AttributeConfiguration ${v8Cl
assName}Attributes[] = {\n"; |
| 4312 $code .= GenerateAttributeConfigurationArray($interface, \@normalAttribu
tes); | 4312 $code .= GenerateAttributeConfigurationArray($interface, \@normalAttribu
tes); |
| 4313 $code .= "};\n\n"; | 4313 $code .= "};\n\n"; |
| 4314 $implementation{nameSpaceWebCore}->add($code); | 4314 $implementation{nameSpaceWebCore}->add($code); |
| 4315 } | 4315 } |
| 4316 | 4316 |
| 4317 # Setup table of standard callback functions | 4317 # Setup table of standard callback functions |
| 4318 my $num_callbacks = 0; | 4318 my $hasFunctions = 0; |
| 4319 my $has_callbacks = 0; | |
| 4320 $code = ""; | 4319 $code = ""; |
| 4321 foreach my $function (@normalFunctions) { | 4320 foreach my $function (@normalFunctions) { |
| 4322 # Only one table entry is needed for overloaded methods: | 4321 # Only one table entry is needed for overloaded functions: |
| 4323 next if $function->{overloadIndex} > 1; | 4322 next if $function->{overloadIndex} > 1; |
| 4324 # Don't put any nonstandard functions into this table: | 4323 # Don't put any nonstandard functions into this table: |
| 4325 next if !IsStandardFunction($interface, $function); | 4324 next if !IsStandardFunction($interface, $function); |
| 4326 next if $function->name eq ""; | 4325 next if $function->name eq ""; |
| 4327 if (!$has_callbacks) { | 4326 if (!$hasFunctions) { |
| 4328 $has_callbacks = 1; | 4327 $hasFunctions = 1; |
| 4329 $code .= "static const V8DOMConfiguration::MethodConfiguration ${v8C
lassName}Methods[] = {\n"; | 4328 $code .= "static const V8DOMConfiguration::MethodConfiguration ${v8C
lassName}Methods[] = {\n"; |
| 4330 } | 4329 } |
| 4331 my $name = $function->name; | 4330 my $name = $function->name; |
| 4332 my $methodForMainWorld = "0"; | 4331 my $methodForMainWorld = "0"; |
| 4333 if ($function->extendedAttributes->{"PerWorldBindings"}) { | 4332 if ($function->extendedAttributes->{"PerWorldBindings"}) { |
| 4334 $methodForMainWorld = "${implClassName}V8Internal::${name}MethodCall
backForMainWorld"; | 4333 $methodForMainWorld = "${implClassName}V8Internal::${name}MethodCall
backForMainWorld"; |
| 4335 } | 4334 } |
| 4336 my $functionLength = GetFunctionLength($function); | 4335 my $functionLength = GetFunctionLength($function); |
| 4337 my $conditionalString = GenerateConditionalString($function); | 4336 my $conditionalString = GenerateConditionalString($function); |
| 4338 $code .= "#if ${conditionalString}\n" if $conditionalString; | 4337 $code .= "#if ${conditionalString}\n" if $conditionalString; |
| 4339 $code .= <<END; | 4338 $code .= <<END; |
| 4340 {"$name", ${implClassName}V8Internal::${name}MethodCallback, ${methodForMain
World}, ${functionLength}}, | 4339 {"$name", ${implClassName}V8Internal::${name}MethodCallback, ${methodForMain
World}, ${functionLength}}, |
| 4341 END | 4340 END |
| 4342 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 4341 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 4343 $num_callbacks++; | |
| 4344 } | 4342 } |
| 4345 $code .= "};\n\n" if $has_callbacks; | 4343 $code .= "};\n\n" if $hasFunctions; |
| 4346 $implementation{nameSpaceWebCore}->add($code); | 4344 $implementation{nameSpaceWebCore}->add($code); |
| 4347 | 4345 |
| 4348 my $has_constants = 0; | 4346 my $hasConstants = 0; |
| 4349 if (@{$interface->constants}) { | 4347 if (@{$interface->constants}) { |
| 4350 $has_constants = 1; | 4348 $hasConstants = 1; |
| 4351 } | 4349 } |
| 4352 | 4350 |
| 4353 if (!HasCustomConstructor($interface)) { | 4351 if (!HasCustomConstructor($interface)) { |
| 4354 if ($interface->extendedAttributes->{"NamedConstructor"}) { | 4352 if ($interface->extendedAttributes->{"NamedConstructor"}) { |
| 4355 GenerateNamedConstructor(@{$interface->constructors}[0], $interface)
; | 4353 GenerateNamedConstructor(@{$interface->constructors}[0], $interface)
; |
| 4356 } elsif ($interface->extendedAttributes->{"Constructor"}) { | 4354 } elsif ($interface->extendedAttributes->{"Constructor"}) { |
| 4357 GenerateConstructor($interface); | 4355 GenerateConstructor($interface); |
| 4358 } elsif (IsConstructorTemplate($interface, "Event")) { | 4356 } elsif (IsConstructorTemplate($interface, "Event")) { |
| 4359 GenerateEventConstructor($interface); | 4357 GenerateEventConstructor($interface); |
| 4360 } | 4358 } |
| 4361 } | 4359 } |
| 4362 if (IsConstructable($interface)) { | 4360 if (IsConstructable($interface)) { |
| 4363 GenerateConstructorCallback($interface); | 4361 GenerateConstructorCallback($interface); |
| 4364 } | 4362 } |
| 4365 | 4363 |
| 4366 my $access_check = ""; | 4364 my $accessCheck = ""; |
| 4367 if ($interface->extendedAttributes->{"CheckSecurity"} && $interfaceName ne "
Window") { | 4365 if ($interface->extendedAttributes->{"CheckSecurity"} && $interfaceName ne "
Window") { |
| 4368 $access_check = "instance->SetAccessCheckCallbacks(${implClassName}V8Int
ernal::namedSecurityCheck, ${implClassName}V8Internal::indexedSecurityCheck, v8:
:External::New(const_cast<WrapperTypeInfo*>(&${v8ClassName}::wrapperTypeInfo)));
"; | 4366 $accessCheck = "instance->SetAccessCheckCallbacks(${implClassName}V8Inte
rnal::namedSecurityCheck, ${implClassName}V8Internal::indexedSecurityCheck, v8::
External::New(const_cast<WrapperTypeInfo*>(&${v8ClassName}::wrapperTypeInfo)));"
; |
| 4369 } | 4367 } |
| 4370 | 4368 |
| 4371 # For the Window interface, generate the shadow object template | 4369 # For the Window interface, generate the shadow object template |
| 4372 # configuration method. | 4370 # configuration method. |
| 4373 if ($interfaceName eq "Window") { | 4371 if ($interfaceName eq "Window") { |
| 4374 $implementation{nameSpaceWebCore}->add(<<END); | 4372 $implementation{nameSpaceWebCore}->add(<<END); |
| 4375 static void ConfigureShadowObjectTemplate(v8::Handle<v8::ObjectTemplate> templ,
v8::Isolate* isolate, WrapperWorldType currentWorldType) | 4373 static void ConfigureShadowObjectTemplate(v8::Handle<v8::ObjectTemplate> templ,
v8::Isolate* isolate, WrapperWorldType currentWorldType) |
| 4376 { | 4374 { |
| 4377 V8DOMConfiguration::installAttributes(templ, v8::Handle<v8::ObjectTemplate>(
), shadowAttributes, WTF_ARRAY_LENGTH(shadowAttributes), isolate, currentWorldTy
pe); | 4375 V8DOMConfiguration::installAttributes(templ, v8::Handle<v8::ObjectTemplate>(
), shadowAttributes, WTF_ARRAY_LENGTH(shadowAttributes), isolate, currentWorldTy
pe); |
| 4378 | 4376 |
| 4379 // Install a security handler with V8. | 4377 // Install a security handler with V8. |
| 4380 templ->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Window:
:indexedSecurityCheckCustom, v8::External::New(const_cast<WrapperTypeInfo*>(&V8W
indow::wrapperTypeInfo))); | 4378 templ->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Window:
:indexedSecurityCheckCustom, v8::External::New(const_cast<WrapperTypeInfo*>(&V8W
indow::wrapperTypeInfo))); |
| 4381 templ->SetInternalFieldCount(V8Window::internalFieldCount); | 4379 templ->SetInternalFieldCount(V8Window::internalFieldCount); |
| 4382 } | 4380 } |
| 4383 END | 4381 END |
| 4384 } | 4382 } |
| 4385 | 4383 |
| 4386 if (!$parentClassTemplate) { | 4384 if (!$parentClassTemplate) { |
| 4387 $parentClassTemplate = "v8::Local<v8::FunctionTemplate>()"; | 4385 $parentClassTemplate = "v8::Local<v8::FunctionTemplate>()"; |
| 4388 } | 4386 } |
| 4389 | 4387 |
| 4390 # Generate the template configuration method | 4388 # Generate the template configuration method |
| 4391 $code = <<END; | 4389 $code = <<END; |
| 4392 static v8::Handle<v8::FunctionTemplate> Configure${v8ClassName}Template(v8::Hand
le<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWor
ldType) | 4390 static v8::Handle<v8::FunctionTemplate> Configure${v8ClassName}Template(v8::Hand
le<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWor
ldType) |
| 4393 { | 4391 { |
| 4394 desc->ReadOnlyPrototype(); | 4392 desc->ReadOnlyPrototype(); |
| 4395 | 4393 |
| 4396 v8::Local<v8::Signature> defaultSignature; | 4394 v8::Local<v8::Signature> defaultSignature; |
| 4397 END | 4395 END |
| 4396 |
| 4397 # Define constants, attributes, accessors and operations. |
| 4398 if ($interface->extendedAttributes->{"RuntimeEnabled"}) { | 4398 if ($interface->extendedAttributes->{"RuntimeEnabled"}) { |
| 4399 my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($interface); | 4399 my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($interface); |
| 4400 $code .= <<END; | 4400 $code .= <<END; |
| 4401 if (!${runtimeEnabledFunction}()) | 4401 if (!${runtimeEnabledFunction}()) |
| 4402 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(desc, \"\
", $parentClassTemplate, ${v8ClassName}::internalFieldCount, 0, 0, 0, 0, isolate
, currentWorldType); | 4402 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(desc, \"\
", $parentClassTemplate, ${v8ClassName}::internalFieldCount, 0, 0, 0, 0, isolate
, currentWorldType); |
| 4403 else | 4403 else |
| 4404 END | 4404 END |
| 4405 } | 4405 } |
| 4406 $code .= <<END; | 4406 $code .= " defaultSignature = V8DOMConfiguration::installDOMClassTemplat
e(desc, \"${interfaceName}\", $parentClassTemplate, ${v8ClassName}::internalFiel
dCount, "; |
| 4407 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(desc, \"${int
erfaceName}\", $parentClassTemplate, ${v8ClassName}::internalFieldCount, | 4407 $code .= $hasAttributes ? "${v8ClassName}Attributes, WTF_ARRAY_LENGTH(${v8C
lassName}Attributes), " : "0, 0, "; |
| 4408 END | 4408 $code .= $hasFunctions ? "${v8ClassName}Methods, WTF_ARRAY_LENGTH(${v8ClassN
ame}Methods), isolate, currentWorldType);\n" : "0, 0, isolate, currentWorldType)
;\n"; |
| 4409 # Set up our attributes if we have them | |
| 4410 if ($has_attributes) { | |
| 4411 $code .= <<END; | |
| 4412 ${v8ClassName}Attributes, WTF_ARRAY_LENGTH(${v8ClassName}Attributes), | |
| 4413 END | |
| 4414 } else { | |
| 4415 $code .= <<END; | |
| 4416 0, 0, | |
| 4417 END | |
| 4418 } | |
| 4419 | |
| 4420 if ($has_callbacks) { | |
| 4421 $code .= <<END; | |
| 4422 ${v8ClassName}Methods, WTF_ARRAY_LENGTH(${v8ClassName}Methods), isolate,
currentWorldType); | |
| 4423 END | |
| 4424 } else { | |
| 4425 $code .= <<END; | |
| 4426 0, 0, isolate, currentWorldType); | |
| 4427 END | |
| 4428 } | |
| 4429 | 4409 |
| 4430 AddToImplIncludes("wtf/UnusedParam.h"); | 4410 AddToImplIncludes("wtf/UnusedParam.h"); |
| 4431 $code .= <<END; | 4411 $code .= " UNUSED_PARAM(defaultSignature);\n"; |
| 4432 UNUSED_PARAM(defaultSignature); | |
| 4433 END | |
| 4434 | 4412 |
| 4435 if (IsConstructable($interface)) { | 4413 if (IsConstructable($interface)) { |
| 4436 $code .= " desc->SetCallHandler(${v8ClassName}::constructorCallback);
\n"; | 4414 $code .= " desc->SetCallHandler(${v8ClassName}::constructorCallback);
\n"; |
| 4437 my $interfaceLength = GetInterfaceLength($interface); | 4415 my $interfaceLength = GetInterfaceLength($interface); |
| 4438 $code .= " desc->SetLength(${interfaceLength});\n"; | 4416 $code .= " desc->SetLength(${interfaceLength});\n"; |
| 4439 } | 4417 } |
| 4440 | 4418 |
| 4441 if ($access_check or @runtimeEnabledAttributes or @normalFunctions or $has_c
onstants) { | 4419 if ($accessCheck or @runtimeEnabledAttributes or @normalFunctions or $hasCon
stants) { |
| 4442 $code .= <<END; | 4420 $code .= <<END; |
| 4443 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); | 4421 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); |
| 4444 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); | 4422 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); |
| 4445 UNUSED_PARAM(instance); | 4423 UNUSED_PARAM(instance); |
| 4446 UNUSED_PARAM(proto); | 4424 UNUSED_PARAM(proto); |
| 4447 END | 4425 END |
| 4448 } | 4426 } |
| 4449 | 4427 |
| 4450 if ($access_check) { | 4428 if ($accessCheck) { |
| 4451 $code .= " $access_check\n"; | 4429 $code .= " $accessCheck\n"; |
| 4452 } | 4430 } |
| 4453 | 4431 |
| 4454 # Setup the enable-at-runtime attributes if we have them | 4432 # Define runtime enabled attributes. |
| 4455 foreach my $runtime_attr (@runtimeEnabledAttributes) { | 4433 foreach my $runtimeEnabledAttribute (@runtimeEnabledAttributes) { |
| 4456 my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($runtime_attr
); | 4434 my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($runtimeEnabl
edAttribute); |
| 4457 my $conditionalString = GenerateConditionalString($runtime_attr); | 4435 my $conditionalString = GenerateConditionalString($runtimeEnabledAttribu
te); |
| 4458 $code .= "#if ${conditionalString}\n" if $conditionalString; | 4436 $code .= "#if ${conditionalString}\n" if $conditionalString; |
| 4459 $code .= " if (${runtimeEnabledFunction}()) {\n"; | 4437 $code .= " if (${runtimeEnabledFunction}()) {\n"; |
| 4460 $code .= " static const V8DOMConfiguration::AttributeConfiguratio
n attributeConfiguration =\\\n"; | 4438 $code .= " static const V8DOMConfiguration::AttributeConfiguratio
n attributeConfiguration =\\\n"; |
| 4461 $code .= GenerateAttributeConfiguration($interface, $runtime_attr, ";",
" "); | 4439 $code .= GenerateAttributeConfiguration($interface, $runtimeEnabledAttri
bute, ";", " "); |
| 4462 $code .= <<END; | 4440 $code .= <<END; |
| 4463 V8DOMConfiguration::installAttribute(instance, proto, attributeConfigura
tion, isolate, currentWorldType); | 4441 V8DOMConfiguration::installAttribute(instance, proto, attributeConfigura
tion, isolate, currentWorldType); |
| 4464 } | 4442 } |
| 4465 END | 4443 END |
| 4466 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 4444 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 4467 } | 4445 } |
| 4468 | 4446 |
| 4469 my @constantsEnabledAtRuntime; | 4447 my @runtimeEnabledConstants; |
| 4470 if ($has_constants) { | 4448 if ($hasConstants) { |
| 4449 # Define constants. |
| 4471 $code .= " static const V8DOMConfiguration::ConstantConfiguration ${v
8ClassName}Constants[] = {\n"; | 4450 $code .= " static const V8DOMConfiguration::ConstantConfiguration ${v
8ClassName}Constants[] = {\n"; |
| 4472 foreach my $constant (@{$interface->constants}) { | 4451 foreach my $constant (@{$interface->constants}) { |
| 4473 my $name = $constant->name; | 4452 my $name = $constant->name; |
| 4474 my $value = $constant->value; | 4453 my $value = $constant->value; |
| 4475 my $attrExt = $constant->extendedAttributes; | 4454 my $attrExt = $constant->extendedAttributes; |
| 4476 my $implementedBy = $attrExt->{"ImplementedBy"}; | 4455 my $implementedBy = $attrExt->{"ImplementedBy"}; |
| 4477 if ($implementedBy) { | 4456 if ($implementedBy) { |
| 4478 my $implementedByImplName = GetImplNameFromImplementedBy($implem
entedBy); | 4457 my $implementedByImplName = GetImplNameFromImplementedBy($implem
entedBy); |
| 4479 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $imple
mentedByImplName)); | 4458 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $imple
mentedByImplName)); |
| 4480 } | 4459 } |
| 4481 if ($attrExt->{"RuntimeEnabled"}) { | 4460 if ($attrExt->{"RuntimeEnabled"}) { |
| 4482 push(@constantsEnabledAtRuntime, $constant); | 4461 push(@runtimeEnabledConstants, $constant); |
| 4483 } else { | 4462 } else { |
| 4484 $code .= <<END; | 4463 $code .= <<END; |
| 4485 {"${name}", $value}, | 4464 {"${name}", $value}, |
| 4486 END | 4465 END |
| 4487 } | 4466 } |
| 4488 } | 4467 } |
| 4489 $code .= " };\n"; | 4468 $code .= " };\n"; |
| 4490 $code .= <<END; | 4469 $code .= <<END; |
| 4491 V8DOMConfiguration::installConstants(desc, proto, ${v8ClassName}Constants, W
TF_ARRAY_LENGTH(${v8ClassName}Constants), isolate); | 4470 V8DOMConfiguration::installConstants(desc, proto, ${v8ClassName}Constants, W
TF_ARRAY_LENGTH(${v8ClassName}Constants), isolate); |
| 4492 END | 4471 END |
| 4493 # Setup the enable-at-runtime constants if we have them | 4472 # Define runtime enabled constants. |
| 4494 foreach my $runtime_const (@constantsEnabledAtRuntime) { | 4473 foreach my $runtimeEnabledConstant (@runtimeEnabledConstants) { |
| 4495 my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($runtime_
const); | 4474 my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($runtimeE
nabledConstant); |
| 4496 my $name = $runtime_const->name; | 4475 my $name = $runtimeEnabledConstant->name; |
| 4497 my $value = $runtime_const->value; | 4476 my $value = $runtimeEnabledConstant->value; |
| 4498 $code .= " if (${runtimeEnabledFunction}()) {\n"; | 4477 $code .= " if (${runtimeEnabledFunction}()) {\n"; |
| 4499 $code .= <<END; | 4478 $code .= <<END; |
| 4500 static const V8DOMConfiguration::ConstantConfiguration constantConfigura
tion = {"${name}", static_cast<signed int>(${value})}; | 4479 static const V8DOMConfiguration::ConstantConfiguration constantConfigura
tion = {"${name}", static_cast<signed int>(${value})}; |
| 4501 V8DOMConfiguration::installConstants(desc, proto, &constantConfiguration
, 1, isolate); | 4480 V8DOMConfiguration::installConstants(desc, proto, &constantConfiguration
, 1, isolate); |
| 4502 END | 4481 END |
| 4503 $code .= " }\n"; | 4482 $code .= " }\n"; |
| 4504 } | 4483 } |
| 4505 $code .= join "", GenerateCompileTimeCheckForEnumsIfNeeded($interface); | 4484 $code .= join "", GenerateCompileTimeCheckForEnumsIfNeeded($interface); |
| 4506 } | 4485 } |
| 4507 | 4486 |
| 4508 $code .= GenerateImplementationIndexedPropertyAccessors($interface); | 4487 $code .= GenerateImplementationIndexedPropertyAccessors($interface); |
| 4509 $code .= GenerateImplementationNamedPropertyAccessors($interface); | 4488 $code .= GenerateImplementationNamedPropertyAccessors($interface); |
| 4510 $code .= GenerateImplementationLegacyCall($interface); | 4489 $code .= GenerateImplementationLegacyCall($interface); |
| 4511 $code .= GenerateImplementationMasqueradesAsUndefined($interface); | 4490 $code .= GenerateImplementationMasqueradesAsUndefined($interface); |
| 4512 | 4491 |
| 4513 # Define our functions with Set() or SetAccessor() | 4492 # Define operations. |
| 4514 my $total_functions = 0; | 4493 my $total_functions = 0; |
| 4515 foreach my $function (@normalFunctions) { | 4494 foreach my $function (@normalFunctions) { |
| 4516 # Only one accessor is needed for overloaded methods: | 4495 # Only one accessor is needed for overloaded operations. |
| 4517 next if $function->{overloadIndex} > 1; | 4496 next if $function->{overloadIndex} > 1; |
| 4518 next if $function->name eq ""; | 4497 next if $function->name eq ""; |
| 4519 | 4498 |
| 4520 $total_functions++; | 4499 $total_functions++; |
| 4521 next if IsStandardFunction($interface, $function); | 4500 next if IsStandardFunction($interface, $function); |
| 4522 $code .= GenerateNonStandardFunction($interface, $function); | 4501 $code .= GenerateNonStandardFunction($interface, $function); |
| 4523 $num_callbacks++; | |
| 4524 } | 4502 } |
| 4525 | 4503 |
| 4526 die "Wrong number of callbacks generated for $interfaceName ($num_callbacks,
should be $total_functions)" if $num_callbacks != $total_functions; | |
| 4527 | |
| 4528 # Define static attributes. | 4504 # Define static attributes. |
| 4529 foreach my $attribute (@staticAttributes) { | 4505 foreach my $attribute (@staticAttributes) { |
| 4530 $code .= GenerateStaticAttribute($interface, $attribute); | 4506 $code .= GenerateStaticAttribute($interface, $attribute); |
| 4531 } | 4507 } |
| 4532 | 4508 |
| 4533 # Special cases | 4509 # Special cases |
| 4534 if ($interfaceName eq "Window") { | 4510 if ($interfaceName eq "Window") { |
| 4535 $code .= <<END; | 4511 $code .= <<END; |
| 4536 | 4512 |
| 4537 proto->SetInternalFieldCount(V8Window::internalFieldCount); | 4513 proto->SetInternalFieldCount(V8Window::internalFieldCount); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4594 END | 4570 END |
| 4595 | 4571 |
| 4596 if (@perContextEnabledAttributes) { | 4572 if (@perContextEnabledAttributes) { |
| 4597 my $code = ""; | 4573 my $code = ""; |
| 4598 $code .= <<END; | 4574 $code .= <<END; |
| 4599 void ${v8ClassName}::installPerContextEnabledProperties(v8::Handle<v8::Object> i
nstance, ${nativeType}* impl, v8::Isolate* isolate) | 4575 void ${v8ClassName}::installPerContextEnabledProperties(v8::Handle<v8::Object> i
nstance, ${nativeType}* impl, v8::Isolate* isolate) |
| 4600 { | 4576 { |
| 4601 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto
type()); | 4577 v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetProto
type()); |
| 4602 END | 4578 END |
| 4603 | 4579 |
| 4604 # Setup the enable-by-settings attributes if we have them | 4580 # Define per-context enabled attributes. |
| 4605 foreach my $perContextEnabledAttribute (@perContextEnabledAttributes) { | 4581 foreach my $perContextEnabledAttribute (@perContextEnabledAttributes) { |
| 4606 my $contextEnabledFunction = GetContextEnabledFunctionName($perConte
xtEnabledAttribute); | 4582 my $contextEnabledFunction = GetContextEnabledFunctionName($perConte
xtEnabledAttribute); |
| 4607 $code .= " if (${contextEnabledFunction}(impl->document())) {\n"; | 4583 $code .= " if (${contextEnabledFunction}(impl->document())) {\n"; |
| 4608 | 4584 |
| 4609 $code .= " static const V8DOMConfiguration::AttributeConfigur
ation attributeConfiguration =\\\n"; | 4585 $code .= " static const V8DOMConfiguration::AttributeConfigur
ation attributeConfiguration =\\\n"; |
| 4610 $code .= GenerateAttributeConfiguration($interface, $perContextEnabl
edAttribute, ";", " "); | 4586 $code .= GenerateAttributeConfiguration($interface, $perContextEnabl
edAttribute, ";", " "); |
| 4611 $code .= <<END; | 4587 $code .= <<END; |
| 4612 V8DOMConfiguration::installAttribute(instance, proto, attributeConfigura
tion, isolate); | 4588 V8DOMConfiguration::installAttribute(instance, proto, attributeConfigura
tion, isolate); |
| 4613 END | 4589 END |
| 4614 $code .= " }\n"; | 4590 $code .= " }\n"; |
| 4615 } | 4591 } |
| 4616 $code .= <<END; | 4592 $code .= <<END; |
| 4617 } | 4593 } |
| 4618 | 4594 |
| 4619 END | 4595 END |
| 4620 $implementation{nameSpaceWebCore}->add($code); | 4596 $implementation{nameSpaceWebCore}->add($code); |
| 4621 } | 4597 } |
| 4622 | 4598 |
| 4623 if (@perContextEnabledFunctions) { | 4599 if (@perContextEnabledFunctions) { |
| 4624 my $code = ""; | 4600 my $code = ""; |
| 4625 $code .= <<END; | 4601 $code .= <<END; |
| 4626 void ${v8ClassName}::installPerContextEnabledPrototypeProperties(v8::Handle<v8::
Object> proto, v8::Isolate* isolate) | 4602 void ${v8ClassName}::installPerContextEnabledPrototypeProperties(v8::Handle<v8::
Object> proto, v8::Isolate* isolate) |
| 4627 { | 4603 { |
| 4628 UNUSED_PARAM(proto); | 4604 UNUSED_PARAM(proto); |
| 4629 END | 4605 END |
| 4630 # Setup the enable-by-settings functions if we have them | 4606 # Define per-context enabled operations. |
| 4631 $code .= <<END; | 4607 $code .= <<END; |
| 4632 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(i
solate, worldType(isolate))); | 4608 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(i
solate, worldType(isolate))); |
| 4633 UNUSED_PARAM(defaultSignature); | 4609 UNUSED_PARAM(defaultSignature); |
| 4634 | 4610 |
| 4635 ExecutionContext* context = toExecutionContext(proto->CreationContext()); | 4611 ExecutionContext* context = toExecutionContext(proto->CreationContext()); |
| 4636 END | 4612 END |
| 4637 | 4613 |
| 4638 foreach my $runtimeFunc (@perContextEnabledFunctions) { | 4614 foreach my $perContextEnabledFunction (@perContextEnabledFunctions) { |
| 4639 my $contextEnabledFunction = GetContextEnabledFunctionName($runtimeF
unc); | 4615 my $contextEnabledFunction = GetContextEnabledFunctionName($perConte
xtEnabledFunction); |
| 4640 my $functionLength = GetFunctionLength($runtimeFunc); | 4616 my $functionLength = GetFunctionLength($perContextEnabledFunction); |
| 4641 my $conditionalString = GenerateConditionalString($runtimeFunc); | 4617 my $conditionalString = GenerateConditionalString($perContextEnabled
Function); |
| 4642 $code .= "\n#if ${conditionalString}\n" if $conditionalString; | 4618 $code .= "\n#if ${conditionalString}\n" if $conditionalString; |
| 4643 $code .= " if (context && context->isDocument() && ${contextEnabl
edFunction}(toDocument(context)))\n"; | 4619 $code .= " if (context && context->isDocument() && ${contextEnabl
edFunction}(toDocument(context)))\n"; |
| 4644 my $name = $runtimeFunc->name; | 4620 my $name = $perContextEnabledFunction->name; |
| 4645 $code .= <<END; | 4621 $code .= <<END; |
| 4646 proto->Set(v8::String::NewSymbol("${name}"), v8::FunctionTemplate::New($
{implClassName}V8Internal::${name}MethodCallback, v8Undefined(), defaultSignatur
e, $functionLength)->GetFunction()); | 4622 proto->Set(v8::String::NewSymbol("${name}"), v8::FunctionTemplate::New($
{implClassName}V8Internal::${name}MethodCallback, v8Undefined(), defaultSignatur
e, $functionLength)->GetFunction()); |
| 4647 END | 4623 END |
| 4648 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 4624 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 4649 } | 4625 } |
| 4650 | 4626 |
| 4651 $code .= <<END; | 4627 $code .= <<END; |
| 4652 } | 4628 } |
| 4653 | 4629 |
| 4654 END | 4630 END |
| (...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6297 | 6273 |
| 6298 return 1 if $interface->extendedAttributes->{"CustomToV8"}; | 6274 return 1 if $interface->extendedAttributes->{"CustomToV8"}; |
| 6299 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; | 6275 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; |
| 6300 return 1 if InheritsInterface($interface, "Document"); | 6276 return 1 if InheritsInterface($interface, "Document"); |
| 6301 return 1 if SVGTypeNeedsToHoldContextElement($interface->name); | 6277 return 1 if SVGTypeNeedsToHoldContextElement($interface->name); |
| 6302 | 6278 |
| 6303 return 0; | 6279 return 0; |
| 6304 } | 6280 } |
| 6305 | 6281 |
| 6306 1; | 6282 1; |
| OLD | NEW |