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

Unified Diff: Source/bindings/templates/interface.cpp

Issue 100473006: IDL compiler: [Constructor] w/o arguments (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Synced to changes 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/templates/interface.h ('k') | Source/bindings/templates/interface_base.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/templates/interface.cpp
diff --git a/Source/bindings/templates/interface.cpp b/Source/bindings/templates/interface.cpp
index a25df2f939223d0975221785fe17997212bcefac..cfa97977b98aa13218b17a3569e4ba3ffe96c952 100644
--- a/Source/bindings/templates/interface.cpp
+++ b/Source/bindings/templates/interface.cpp
@@ -129,6 +129,46 @@ static void {{cpp_class}}OriginSafeMethodSetterCallback(v8::Local<v8::String> na
{##############################################################################}
+{% block constructor %}
+{% if has_constructor %}
+{# FIXME: support overloading #}
+static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ {# FIXME: support arguments #}
+ RefPtr<{{cpp_class}}> impl = {{cpp_class}}::create();
+ v8::Handle<v8::Object> wrapper = info.Holder();
+
+ V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8_class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
+ v8SetReturnValue(info, wrapper);
+}
+
+{% endif %}
+{% endblock %}
+
+
+{##############################################################################}
+{% block constructor_callback %}
+{% if has_constructor %}
+void {{v8_class}}::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor");
+ if (!info.IsConstructCall()) {
+ throwTypeError(ExceptionMessages::failedToConstruct("{{interface_name}}", "Please use the 'new' operator, this DOM object constructor cannot be called as a function."), info.GetIsolate());
+ return;
+ }
+
+ if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) {
+ v8SetReturnValue(info, info.Holder());
+ return;
+ }
+
+ {{cpp_class}}V8Internal::constructor(info);
+}
+
+{% endif %}
+{% endblock %}
+
+{##############################################################################}
{% block visit_dom_wrapper %}
{% if generate_visit_dom_wrapper_function %}
void {{v8_class}}::visitDOMWrapper(void* object, const v8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate)
@@ -232,6 +272,11 @@ static v8::Handle<v8::FunctionTemplate> Configure{{v8_class}}Template(v8::Handle
{% endfilter %}
UNUSED_PARAM(defaultSignature);
+ {% if has_constructor %}
+ functionTemplate->SetCallHandler({{v8_class}}::constructorCallback);
+ {# FIXME: compute length #}
+ functionTemplate->SetLength(0);
+ {% endif %}
v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceTemplate();
v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->PrototypeTemplate();
UNUSED_PARAM(instanceTemplate);
« no previous file with comments | « Source/bindings/templates/interface.h ('k') | Source/bindings/templates/interface_base.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698