| 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 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*, WrapperWor
ldType); | 737 static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*, WrapperWor
ldType); |
| 738 static const WrapperTypeInfo wrapperTypeInfo; | 738 static const WrapperTypeInfo wrapperTypeInfo; |
| 739 }; | 739 }; |
| 740 END | 740 END |
| 741 } | 741 } |
| 742 | 742 |
| 743 $header{class}->addHeader("class $v8ClassName {"); | 743 $header{class}->addHeader("class $v8ClassName {"); |
| 744 $header{class}->addFooter("};"); | 744 $header{class}->addFooter("};"); |
| 745 | 745 |
| 746 $header{classPublic}->add(<<END); | 746 $header{classPublic}->add(<<END); |
| 747 static bool hasInstance(v8::Handle<v8::Value>, v8::Isolate*, WrapperWorldTyp
e); | 747 static bool hasInstance(v8::Handle<v8::Value>, v8::Isolate*); |
| 748 static bool hasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); | |
| 749 static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*, WrapperWor
ldType); | 748 static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*, WrapperWor
ldType); |
| 750 static ${nativeType}* toNative(v8::Handle<v8::Object> object) | 749 static ${nativeType}* toNative(v8::Handle<v8::Object> object) |
| 751 { | 750 { |
| 752 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8
DOMWrapperObjectIndex)); | 751 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8
DOMWrapperObjectIndex)); |
| 753 } | 752 } |
| 754 static void derefObject(void*); | 753 static void derefObject(void*); |
| 755 static const WrapperTypeInfo wrapperTypeInfo; | 754 static const WrapperTypeInfo wrapperTypeInfo; |
| 756 END | 755 END |
| 757 | 756 |
| 758 if (NeedsVisitDOMWrapper($interface)) { | 757 if (NeedsVisitDOMWrapper($interface)) { |
| (...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1963 } | 1962 } |
| 1964 | 1963 |
| 1965 # If the "StrictTypeChecking" extended attribute is present, and the | 1964 # If the "StrictTypeChecking" extended attribute is present, and the |
| 1966 # attribute's type is an interface type, then if the incoming value does not | 1965 # attribute's type is an interface type, then if the incoming value does not |
| 1967 # implement that interface, a TypeError is thrown rather than silently | 1966 # implement that interface, a TypeError is thrown rather than silently |
| 1968 # passing NULL to the C++ code. | 1967 # passing NULL to the C++ code. |
| 1969 # Per the Web IDL and ECMAScript specifications, incoming values can always | 1968 # Per the Web IDL and ECMAScript specifications, incoming values can always |
| 1970 # be converted to both strings and numbers, so do not throw TypeError if the | 1969 # be converted to both strings and numbers, so do not throw TypeError if the |
| 1971 # attribute is of these types. | 1970 # attribute is of these types. |
| 1972 if ($hasStrictTypeChecking) { | 1971 if ($hasStrictTypeChecking) { |
| 1973 $code .= " if (!isUndefinedOrNull(jsValue) && !V8${attrType}::hasInst
ance(jsValue, info.GetIsolate(), worldType(info.GetIsolate()))) {\n"; | 1972 $code .= " if (!isUndefinedOrNull(jsValue) && !V8${attrType}::hasInst
ance(jsValue, info.GetIsolate())) {\n"; |
| 1974 $code .= " exceptionState.throwTypeError(\"The provided value is
not of type '${attrType}'.\");\n"; | 1973 $code .= " exceptionState.throwTypeError(\"The provided value is
not of type '${attrType}'.\");\n"; |
| 1975 $code .= " exceptionState.throwIfNeeded();\n"; | 1974 $code .= " exceptionState.throwIfNeeded();\n"; |
| 1976 $code .= " return;\n"; | 1975 $code .= " return;\n"; |
| 1977 $code .= " }\n"; | 1976 $code .= " }\n"; |
| 1978 } | 1977 } |
| 1979 | 1978 |
| 1980 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); | 1979 my $svgNativeType = GetSVGTypeNeedingTearOff($interfaceName); |
| 1981 if ($svgNativeType) { | 1980 if ($svgNativeType) { |
| 1982 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam
e); | 1981 my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceNam
e); |
| 1983 if ($svgWrappedNativeType =~ /List$/) { | 1982 if ($svgWrappedNativeType =~ /List$/) { |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2210 # For Callbacks only checks if the value is null or function. | 2209 # For Callbacks only checks if the value is null or function. |
| 2211 push(@andExpression, "${value}->IsNull() || ${value}->IsFunction()")
; | 2210 push(@andExpression, "${value}->IsNull() || ${value}->IsFunction()")
; |
| 2212 } elsif (GetArrayOrSequenceType($type)) { | 2211 } elsif (GetArrayOrSequenceType($type)) { |
| 2213 if ($parameter->isNullable) { | 2212 if ($parameter->isNullable) { |
| 2214 push(@andExpression, "${value}->IsNull() || ${value}->IsArray()"
); | 2213 push(@andExpression, "${value}->IsNull() || ${value}->IsArray()"
); |
| 2215 } else { | 2214 } else { |
| 2216 push(@andExpression, "${value}->IsArray()"); | 2215 push(@andExpression, "${value}->IsArray()"); |
| 2217 } | 2216 } |
| 2218 } elsif (IsWrapperType($type)) { | 2217 } elsif (IsWrapperType($type)) { |
| 2219 if ($parameter->isNullable) { | 2218 if ($parameter->isNullable) { |
| 2220 push(@andExpression, "${value}->IsNull() || V8${type}::hasInstan
ce($value, info.GetIsolate(), worldType(info.GetIsolate()))"); | 2219 push(@andExpression, "${value}->IsNull() || V8${type}::hasInstan
ce($value, info.GetIsolate())"); |
| 2221 } else { | 2220 } else { |
| 2222 push(@andExpression, "V8${type}::hasInstance($value, info.GetIso
late(), worldType(info.GetIsolate()))"); | 2221 push(@andExpression, "V8${type}::hasInstance($value, info.GetIso
late())"); |
| 2223 } | 2222 } |
| 2224 } elsif ($nonWrapperTypes{$type}) { | 2223 } elsif ($nonWrapperTypes{$type}) { |
| 2225 # Non-wrapper types are just objects: we don't distinguish type | 2224 # Non-wrapper types are just objects: we don't distinguish type |
| 2226 if ($parameter->isNullable) { | 2225 if ($parameter->isNullable) { |
| 2227 push(@andExpression, "${value}->IsNull() || ${value}->IsObject()
"); | 2226 push(@andExpression, "${value}->IsNull() || ${value}->IsObject()
"); |
| 2228 } else { | 2227 } else { |
| 2229 push(@andExpression, "${value}->IsObject()"); | 2228 push(@andExpression, "${value}->IsObject()"); |
| 2230 } | 2229 } |
| 2231 } | 2230 } |
| 2232 | 2231 |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2675 } elsif ($parameter->isVariadic) { | 2674 } elsif ($parameter->isVariadic) { |
| 2676 my $nativeElementType = GetNativeType($parameter->type); | 2675 my $nativeElementType = GetNativeType($parameter->type); |
| 2677 if ($nativeElementType =~ />$/) { | 2676 if ($nativeElementType =~ />$/) { |
| 2678 $nativeElementType .= " "; | 2677 $nativeElementType .= " "; |
| 2679 } | 2678 } |
| 2680 | 2679 |
| 2681 my $argType = $parameter->type; | 2680 my $argType = $parameter->type; |
| 2682 if (IsWrapperType($argType)) { | 2681 if (IsWrapperType($argType)) { |
| 2683 $parameterCheckString .= " Vector<$nativeElementType> $parame
terName;\n"; | 2682 $parameterCheckString .= " Vector<$nativeElementType> $parame
terName;\n"; |
| 2684 $parameterCheckString .= " for (int i = $paramIndex; i < info
.Length(); ++i) {\n"; | 2683 $parameterCheckString .= " for (int i = $paramIndex; i < info
.Length(); ++i) {\n"; |
| 2685 $parameterCheckString .= " if (!V8${argType}::hasInstance
(info[i], info.GetIsolate(), worldType(info.GetIsolate()))) {\n"; | 2684 $parameterCheckString .= " if (!V8${argType}::hasInstance
(info[i], info.GetIsolate())) {\n"; |
| 2686 if ($hasExceptionState) { | 2685 if ($hasExceptionState) { |
| 2687 $parameterCheckString .= " exceptionState.throwTy
peError(\"parameter $humanFriendlyIndex is not of type \'$argType\'.\");\n"; | 2686 $parameterCheckString .= " exceptionState.throwTy
peError(\"parameter $humanFriendlyIndex is not of type \'$argType\'.\");\n"; |
| 2688 $parameterCheckString .= " exceptionState.throwIf
Needed();\n"; | 2687 $parameterCheckString .= " exceptionState.throwIf
Needed();\n"; |
| 2689 } else { | 2688 } else { |
| 2690 $parameterCheckString .= " throwTypeError(Excepti
onMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $
humanFriendlyIndex is not of type \'$argType\'.\"), info.GetIsolate());\n"; | 2689 $parameterCheckString .= " throwTypeError(Excepti
onMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $
humanFriendlyIndex is not of type \'$argType\'.\"), info.GetIsolate());\n"; |
| 2691 } | 2690 } |
| 2692 $parameterCheckString .= " return;\n"; | 2691 $parameterCheckString .= " return;\n"; |
| 2693 $parameterCheckString .= " }\n"; | 2692 $parameterCheckString .= " }\n"; |
| 2694 $parameterCheckString .= " $parameterName.append(V8${argT
ype}::toNative(v8::Handle<v8::Object>::Cast(info[i])));\n"; | 2693 $parameterCheckString .= " $parameterName.append(V8${argT
ype}::toNative(v8::Handle<v8::Object>::Cast(info[i])));\n"; |
| 2695 $parameterCheckString .= " }\n"; | 2694 $parameterCheckString .= " }\n"; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2730 # interface type, then if the incoming value does not implement that
interface, a TypeError | 2729 # interface type, then if the incoming value does not implement that
interface, a TypeError |
| 2731 # is thrown rather than silently passing NULL to the C++ code. | 2730 # is thrown rather than silently passing NULL to the C++ code. |
| 2732 # Per the Web IDL and ECMAScript specifications, incoming values can
always be converted | 2731 # Per the Web IDL and ECMAScript specifications, incoming values can
always be converted |
| 2733 # to both strings and numbers, so do not throw TypeError if the argu
ment is of these | 2732 # to both strings and numbers, so do not throw TypeError if the argu
ment is of these |
| 2734 # types. | 2733 # types. |
| 2735 if ($function->extendedAttributes->{"StrictTypeChecking"}) { | 2734 if ($function->extendedAttributes->{"StrictTypeChecking"}) { |
| 2736 my $argValue = "info[$paramIndex]"; | 2735 my $argValue = "info[$paramIndex]"; |
| 2737 my $argType = $parameter->type; | 2736 my $argType = $parameter->type; |
| 2738 if (IsWrapperType($argType)) { | 2737 if (IsWrapperType($argType)) { |
| 2739 my $undefinedNullCheck = $parameter->isNullable ? "isUndefin
edOrNull($argValue)" : "${argValue}->IsUndefined()"; | 2738 my $undefinedNullCheck = $parameter->isNullable ? "isUndefin
edOrNull($argValue)" : "${argValue}->IsUndefined()"; |
| 2740 $parameterCheckString .= " if (info.Length() > $paramInde
x && !$undefinedNullCheck && !V8${argType}::hasInstance($argValue, info.GetIsola
te(), worldType(info.GetIsolate()))) {\n"; | 2739 $parameterCheckString .= " if (info.Length() > $paramInde
x && !$undefinedNullCheck && !V8${argType}::hasInstance($argValue, info.GetIsola
te())) {\n"; |
| 2741 if ($hasExceptionState) { | 2740 if ($hasExceptionState) { |
| 2742 $parameterCheckString .= " exceptionState.throwTy
peError(\"parameter $humanFriendlyIndex is not of type \'$argType\'.\");\n"; | 2741 $parameterCheckString .= " exceptionState.throwTy
peError(\"parameter $humanFriendlyIndex is not of type \'$argType\'.\");\n"; |
| 2743 $parameterCheckString .= " exceptionState.throwIf
Needed();\n"; | 2742 $parameterCheckString .= " exceptionState.throwIf
Needed();\n"; |
| 2744 }else { | 2743 }else { |
| 2745 $parameterCheckString .= " throwTypeError(Excepti
onMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $
humanFriendlyIndex is not of type \'$argType\'.\"), info.GetIsolate());\n"; | 2744 $parameterCheckString .= " throwTypeError(Excepti
onMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"parameter $
humanFriendlyIndex is not of type \'$argType\'.\"), info.GetIsolate());\n"; |
| 2746 } | 2745 } |
| 2747 $parameterCheckString .= " return;\n"; | 2746 $parameterCheckString .= " return;\n"; |
| 2748 $parameterCheckString .= " }\n"; | 2747 $parameterCheckString .= " }\n"; |
| 2749 } | 2748 } |
| 2750 } | 2749 } |
| (...skipping 1963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4714 return result->value.newLocal(isolate); | 4713 return result->value.newLocal(isolate); |
| 4715 | 4714 |
| 4716 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 4715 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 4717 v8::EscapableHandleScope handleScope(isolate); | 4716 v8::EscapableHandleScope handleScope(isolate); |
| 4718 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); | 4717 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); |
| 4719 configure${v8ClassName}Template(templ, isolate, currentWorldType); | 4718 configure${v8ClassName}Template(templ, isolate, currentWorldType); |
| 4720 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | 4719 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); |
| 4721 return handleScope.Escape(templ); | 4720 return handleScope.Escape(templ); |
| 4722 } | 4721 } |
| 4723 | 4722 |
| 4724 END | 4723 bool ${v8ClassName}::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* iso
late) |
| 4725 $implementation{nameSpaceWebCore}->add(<<END); | |
| 4726 bool ${v8ClassName}::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* iso
late, WrapperWorldType currentWorldType) | |
| 4727 { | 4724 { |
| 4728 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, currentWorldType); | 4725 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI
nfo, jsValue) |
| 4726 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy
peInfo, jsValue); |
| 4729 } | 4727 } |
| 4730 | 4728 |
| 4731 END | 4729 END |
| 4732 $implementation{nameSpaceWebCore}->add(<<END); | |
| 4733 bool ${v8ClassName}::hasInstanceInAnyWorld(v8::Handle<v8::Value> jsValue, v8::Is
olate* isolate) | |
| 4734 { | |
| 4735 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, MainWorld) | |
| 4736 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, IsolatedWorld) | |
| 4737 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, WorkerWorld); | |
| 4738 } | |
| 4739 | |
| 4740 END | |
| 4741 | 4730 |
| 4742 if (@perContextEnabledAttributes) { | 4731 if (@perContextEnabledAttributes) { |
| 4743 my $code = ""; | 4732 my $code = ""; |
| 4744 $code .= <<END; | 4733 $code .= <<END; |
| 4745 void ${v8ClassName}::installPerContextEnabledProperties(v8::Handle<v8::Object> i
nstanceTemplate, ${nativeType}* impl, v8::Isolate* isolate) | 4734 void ${v8ClassName}::installPerContextEnabledProperties(v8::Handle<v8::Object> i
nstanceTemplate, ${nativeType}* impl, v8::Isolate* isolate) |
| 4746 { | 4735 { |
| 4747 v8::Local<v8::Object> prototypeTemplate = v8::Local<v8::Object>::Cast(instan
ceTemplate->GetPrototype()); | 4736 v8::Local<v8::Object> prototypeTemplate = v8::Local<v8::Object>::Cast(instan
ceTemplate->GetPrototype()); |
| 4748 END | 4737 END |
| 4749 | 4738 |
| 4750 # Define per-context enabled attributes. | 4739 # Define per-context enabled attributes. |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5574 if (IsRefPtrType($arrayOrSequenceType)) { | 5563 if (IsRefPtrType($arrayOrSequenceType)) { |
| 5575 AddToImplIncludes("V8${arrayOrSequenceType}.h"); | 5564 AddToImplIncludes("V8${arrayOrSequenceType}.h"); |
| 5576 return "(toRefPtrNativeArray<${arrayOrSequenceType}, V8${arrayOrSequ
enceType}>($value, $argIndexOrZero, $getIsolate))"; | 5565 return "(toRefPtrNativeArray<${arrayOrSequenceType}, V8${arrayOrSequ
enceType}>($value, $argIndexOrZero, $getIsolate))"; |
| 5577 } | 5566 } |
| 5578 return "toNativeArray<" . GetNativeType($arrayOrSequenceType) . ">($valu
e, $argIndexOrZero, $getIsolate)"; | 5567 return "toNativeArray<" . GetNativeType($arrayOrSequenceType) . ">($valu
e, $argIndexOrZero, $getIsolate)"; |
| 5579 } | 5568 } |
| 5580 | 5569 |
| 5581 AddIncludesForType($type); | 5570 AddIncludesForType($type); |
| 5582 | 5571 |
| 5583 AddToImplIncludes("V8${type}.h"); | 5572 AddToImplIncludes("V8${type}.h"); |
| 5584 return "V8${type}::hasInstance($value, $getIsolate, worldType($getIsolate))
? V8${type}::toNative(v8::Handle<v8::Object>::Cast($value)) : 0"; | 5573 return "V8${type}::hasInstance($value, $getIsolate) ? V8${type}::toNative(v8
::Handle<v8::Object>::Cast($value)) : 0"; |
| 5585 } | 5574 } |
| 5586 | 5575 |
| 5587 sub IsUnionType | 5576 sub IsUnionType |
| 5588 { | 5577 { |
| 5589 my $type = shift; # string or UnionType | 5578 my $type = shift; # string or UnionType |
| 5590 if(ref($type) eq "UnionType") { | 5579 if(ref($type) eq "UnionType") { |
| 5591 die "Currently only 2 values of non-union type is supported as union typ
e.\n" unless @{$type->unionMemberTypes} == 2; | 5580 die "Currently only 2 values of non-union type is supported as union typ
e.\n" unless @{$type->unionMemberTypes} == 2; |
| 5592 return 1; | 5581 return 1; |
| 5593 } | 5582 } |
| 5594 return 0; | 5583 return 0; |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6413 if ($parameter->type eq "SerializedScriptValue") { | 6402 if ($parameter->type eq "SerializedScriptValue") { |
| 6414 return 1; | 6403 return 1; |
| 6415 } elsif (IsIntegerType($parameter->type)) { | 6404 } elsif (IsIntegerType($parameter->type)) { |
| 6416 return 1; | 6405 return 1; |
| 6417 } | 6406 } |
| 6418 } | 6407 } |
| 6419 return 0; | 6408 return 0; |
| 6420 } | 6409 } |
| 6421 | 6410 |
| 6422 1; | 6411 1; |
| OLD | NEW |