Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(694)

Side by Side Diff: Source/bindings/tests/results/V8TestInterfaceConstructor.cpp

Issue 112303003: IDL compiler: [Constructor] overloading (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Better test case Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 WebCore::initializeScriptWrappableForInterface(object); 65 WebCore::initializeScriptWrappableForInterface(object);
66 } 66 }
67 67
68 namespace WebCore { 68 namespace WebCore {
69 const WrapperTypeInfo V8TestInterfaceConstructor::wrapperTypeInfo = { gin::kEmbe dderBlink, V8TestInterfaceConstructor::domTemplate, V8TestInterfaceConstructor:: derefObject, 0, 0, 0, V8TestInterfaceConstructor::installPerContextEnabledMethod s, 0, WrapperTypeObjectPrototype }; 69 const WrapperTypeInfo V8TestInterfaceConstructor::wrapperTypeInfo = { gin::kEmbe dderBlink, V8TestInterfaceConstructor::domTemplate, V8TestInterfaceConstructor:: derefObject, 0, 0, 0, V8TestInterfaceConstructor::installPerContextEnabledMethod s, 0, WrapperTypeObjectPrototype };
70 70
71 namespace TestInterfaceConstructorV8Internal { 71 namespace TestInterfaceConstructorV8Internal {
72 72
73 template <typename T> void V8_USE(T) { } 73 template <typename T> void V8_USE(T) { }
74 74
75 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) 75 static void constructor1(const v8::FunctionCallbackInfo<v8::Value>& info)
76 { 76 {
77 if (UNLIKELY(info.Length() < 5)) { 77 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInte rfaceConstructor", info.Holder(), info.GetIsolate());
78 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TestIn terfaceConstructor", ExceptionMessages::notEnoughArguments(5, info.Length())), i nfo.GetIsolate()); 78 ExecutionContext* context = getExecutionContext();
79 Document& document = *toDocument(getExecutionContext());
80 RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::create(con text, document, exceptionState);
81 v8::Handle<v8::Object> wrapper = info.Holder();
82 if (exceptionState.throwIfNeeded())
79 return; 83 return;
80 } 84
85 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor>(impl.re lease(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper, info.GetIsolate( ), WrapperConfiguration::Dependent);
86 v8SetReturnValue(info, wrapper);
87 }
88
89 static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info)
90 {
81 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInte rfaceConstructor", info.Holder(), info.GetIsolate()); 91 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInte rfaceConstructor", info.Holder(), info.GetIsolate());
82 V8TRYCATCH_VOID(double, doubleArg, static_cast<double>(info[0]->NumberValue( ))); 92 V8TRYCATCH_VOID(double, doubleArg, static_cast<double>(info[0]->NumberValue( )));
83 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, stringArg, info[1]) ; 93 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, stringArg, info[1]) ;
84 V8TRYCATCH_VOID(TestInterfaceEmpty*, testInterfaceEmptyArg, V8TestInterfaceE mpty::hasInstance(info[2], info.GetIsolate(), worldType(info.GetIsolate())) ? V8 TestInterfaceEmpty::toNative(v8::Handle<v8::Object>::Cast(info[2])) : 0); 94 V8TRYCATCH_VOID(TestInterfaceEmpty*, testInterfaceEmptyArg, V8TestInterfaceE mpty::hasInstance(info[2], info.GetIsolate(), worldType(info.GetIsolate())) ? V8 TestInterfaceEmpty::toNative(v8::Handle<v8::Object>::Cast(info[2])) : 0);
85 V8TRYCATCH_VOID(Dictionary, dictionaryArg, Dictionary(info[3], info.GetIsola te())); 95 V8TRYCATCH_VOID(Dictionary, dictionaryArg, Dictionary(info[3], info.GetIsola te()));
86 if (!dictionaryArg.isUndefinedOrNull() && !dictionaryArg.isObject()) { 96 if (!dictionaryArg.isUndefinedOrNull() && !dictionaryArg.isObject()) {
87 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstr uctor", "parameter 4 ('dictionaryArg') is not an object."), info.GetIsolate()); 97 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstr uctor", "parameter 4 ('dictionaryArg') is not an object."), info.GetIsolate());
88 return; 98 return;
89 } 99 }
90 V8TRYCATCH_VOID(Vector<String>, sequenceStringArg, toNativeArray<String>(inf o[4], 5, info.GetIsolate())); 100 V8TRYCATCH_VOID(Vector<String>, sequenceStringArg, toNativeArray<String>(inf o[4], 5, info.GetIsolate()));
91 V8TRYCATCH_VOID(Dictionary, optionalDictionaryArg, Dictionary(info[5], info. GetIsolate())); 101 V8TRYCATCH_VOID(Dictionary, optionalDictionaryArg, Dictionary(info[5], info. GetIsolate()));
92 if (!optionalDictionaryArg.isUndefinedOrNull() && !optionalDictionaryArg.isO bject()) { 102 if (!optionalDictionaryArg.isUndefinedOrNull() && !optionalDictionaryArg.isO bject()) {
93 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstr uctor", "parameter 6 ('optionalDictionaryArg') is not an object."), info.GetIsol ate()); 103 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstr uctor", "parameter 6 ('optionalDictionaryArg') is not an object."), info.GetIsol ate());
94 return; 104 return;
95 } 105 }
96 ExecutionContext* context = getExecutionContext(); 106 ExecutionContext* context = getExecutionContext();
97 Document& document = *toDocument(getExecutionContext()); 107 Document& document = *toDocument(getExecutionContext());
98 RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::create(con text, document, doubleArg, stringArg, testInterfaceEmptyArg, dictionaryArg, sequ enceStringArg, optionalDictionaryArg, exceptionState); 108 RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::create(con text, document, doubleArg, stringArg, testInterfaceEmptyArg, dictionaryArg, sequ enceStringArg, optionalDictionaryArg, exceptionState);
99 v8::Handle<v8::Object> wrapper = info.Holder(); 109 v8::Handle<v8::Object> wrapper = info.Holder();
100 if (exceptionState.throwIfNeeded()) 110 if (exceptionState.throwIfNeeded())
101 return; 111 return;
102 112
103 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor>(impl.re lease(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper, info.GetIsolate( ), WrapperConfiguration::Dependent); 113 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor>(impl.re lease(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper, info.GetIsolate( ), WrapperConfiguration::Dependent);
104 v8SetReturnValue(info, wrapper); 114 v8SetReturnValue(info, wrapper);
105 } 115 }
106 116
117 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
118 {
119 if (((info.Length() == 0))) {
120 TestInterfaceConstructorV8Internal::constructor1(info);
121 return;
122 }
123 if (((info.Length() == 5) && (V8TestInterfaceEmpty::hasInstance(info[2], inf o.GetIsolate(), worldType(info.GetIsolate()))) && (info[4]->IsArray())) || ((inf o.Length() == 6) && (V8TestInterfaceEmpty::hasInstance(info[2], info.GetIsolate( ), worldType(info.GetIsolate()))) && (info[4]->IsArray()))) {
124 TestInterfaceConstructorV8Internal::constructor2(info);
125 return;
126 }
127 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstructo r", "No matching constructor signature."), info.GetIsolate());
128 }
129
107 } // namespace TestInterfaceConstructorV8Internal 130 } // namespace TestInterfaceConstructorV8Internal
108 131
109 void V8TestInterfaceConstructor::constructorCallback(const v8::FunctionCallbackI nfo<v8::Value>& info) 132 void V8TestInterfaceConstructor::constructorCallback(const v8::FunctionCallbackI nfo<v8::Value>& info)
110 { 133 {
111 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); 134 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor");
112 UseCounter::count(activeDOMWindow(), UseCounter::TestFeature); 135 UseCounter::count(activeDOMWindow(), UseCounter::TestFeature);
113 if (!info.IsConstructCall()) { 136 if (!info.IsConstructCall()) {
114 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstr uctor", "Please use the 'new' operator, this DOM object constructor cannot be ca lled as a function."), info.GetIsolate()); 137 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstr uctor", "Please use the 'new' operator, this DOM object constructor cannot be ca lled as a function."), info.GetIsolate());
115 return; 138 return;
116 } 139 }
(...skipping 10 matching lines...) Expand all
127 { 150 {
128 functionTemplate->ReadOnlyPrototype(); 151 functionTemplate->ReadOnlyPrototype();
129 152
130 v8::Local<v8::Signature> defaultSignature; 153 v8::Local<v8::Signature> defaultSignature;
131 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl ate, "TestInterfaceConstructor", v8::Local<v8::FunctionTemplate>(), V8TestInterf aceConstructor::internalFieldCount, 154 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl ate, "TestInterfaceConstructor", v8::Local<v8::FunctionTemplate>(), V8TestInterf aceConstructor::internalFieldCount,
132 0, 0, 155 0, 0,
133 0, 0, 156 0, 0,
134 0, 0, 157 0, 0,
135 isolate, currentWorldType); 158 isolate, currentWorldType);
136 functionTemplate->SetCallHandler(V8TestInterfaceConstructor::constructorCall back); 159 functionTemplate->SetCallHandler(V8TestInterfaceConstructor::constructorCall back);
137 functionTemplate->SetLength(5); 160 functionTemplate->SetLength(0);
138 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla te->InstanceTemplate(); 161 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla te->InstanceTemplate();
139 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl ate->PrototypeTemplate(); 162 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl ate->PrototypeTemplate();
140 163
141 // Custom toString template 164 // Custom toString template
142 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate()); 165 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate());
143 return functionTemplate; 166 return functionTemplate;
144 } 167 }
145 168
146 v8::Handle<v8::FunctionTemplate> V8TestInterfaceConstructor::domTemplate(v8::Iso late* isolate, WrapperWorldType currentWorldType) 169 v8::Handle<v8::FunctionTemplate> V8TestInterfaceConstructor::domTemplate(v8::Iso late* isolate, WrapperWorldType currentWorldType)
147 { 170 {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 fromInternalPointer(object)->deref(); 218 fromInternalPointer(object)->deref();
196 } 219 }
197 220
198 template<> 221 template<>
199 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor* impl, v8::Handle<v8 ::Object> creationContext, v8::Isolate* isolate) 222 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor* impl, v8::Handle<v8 ::Object> creationContext, v8::Isolate* isolate)
200 { 223 {
201 return toV8(impl, creationContext, isolate); 224 return toV8(impl, creationContext, isolate);
202 } 225 }
203 226
204 } // namespace WebCore 227 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698