Index: Source/bindings/templates/interface.cpp |
diff --git a/Source/bindings/templates/interface.cpp b/Source/bindings/templates/interface.cpp |
index 88058e61d3a523442f21377014dfd9626a6c6211..ed95c45121921ada3e6ca072af7eee0d05320aae 100644 |
--- a/Source/bindings/templates/interface.cpp |
+++ b/Source/bindings/templates/interface.cpp |
@@ -18,6 +18,8 @@ |
Boston, MA 02111-1307, USA. |
*/ |
+{% from 'attributes.cpp' import attribute_getter, attribute_getter_callback, batched_attribute with context %} |
+{% from 'constants.cpp' import class_consts, const_data, batch_configure_constants with context %} |
#include "config.h" |
{% if conditional_string %} |
#if {{conditional_string}} |
@@ -25,7 +27,7 @@ |
#include "{{v8_class_name}}.h" |
{% for filename in cpp_includes %} |
-#include "{{ filename }}" |
+#include "{{filename}}" |
{% endfor %} |
namespace WebCore { |
@@ -56,41 +58,20 @@ namespace {{cpp_class_name}}V8Internal { |
template <typename T> void V8_USE(T) { } |
+{# ############################################## Attributes #} |
{% for attribute in attributes %} |
-static void {{attribute.name}}AttrGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) |
-{ |
- {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder()); |
- {{attribute.cpp_type}} result = imp->{{attribute.cpp_method_name}}(); |
- v8::Handle<v8::Value> wrapper = result.get() ? v8::Handle<v8::Value>(DOMDataStore::getWrapper<{{attribute.v8_type}}>(result.get(), info.GetIsolate())) : v8Undefined(); |
- if (wrapper.IsEmpty()) { |
- wrapper = toV8(result.get(), info.Holder(), info.GetIsolate()); |
- if (!wrapper.IsEmpty()) |
- V8HiddenPropertyName::setNamedHiddenReference(info.Holder(), "{{attribute.name}}", wrapper); |
- } |
- v8SetReturnValue(info, wrapper); |
-} |
- |
-static void {{attribute.name}}AttrGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) |
-{ |
- TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
- {{cpp_class_name}}V8Internal::{{attribute.name}}AttrGetter(name, info); |
- TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
-} |
- |
-{% endfor %} |
- |
+{{attribute_getter(attribute) -}} |
+{{attribute_getter_callback(attribute)}}{% endfor %} |
} // namespace {{cpp_class_name}}V8Internal |
+{# FIXME: pass a list of normal_attributes, instead of length and is_normal #} |
{% if attributes %} |
-static const V8DOMConfiguration::BatchedAttribute {{v8_class_name}}Attributes[] = { |
-{% for attribute in attributes %} |
- {"{{attribute.name}}", {{cpp_class_name}}V8Internal::{{attribute.name}}AttrGetterCallback, 0, 0, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, |
-{% endfor %} |
-}; |
- |
+{{batched_attribute()}} |
+{% endif %} |
+{# WIP #} |
+{% if constants %} |
+{{class_consts()}} |
{% endif %} |
- |
- |
static v8::Handle<v8::FunctionTemplate> Configure{{v8_class_name}}Template(v8::Handle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWorldType) |
{ |
desc->ReadOnlyPrototype(); |
@@ -100,6 +81,17 @@ static v8::Handle<v8::FunctionTemplate> Configure{{v8_class_name}}Template(v8::H |
{{attribute_templates}}, {{number_of_attributes}}, |
0, 0, isolate, currentWorldType); |
UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. |
+{# WIP #} |
+{% if constants %} |
+ v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); |
+ v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); |
+ UNUSED_PARAM(instance); // In some cases, it will not be used. |
+ UNUSED_PARAM(proto); // In some cases, it will not be used. |
+{% endif %} |
+{% for constant in constants %}{{const_data(constant)}}{% endfor %} |
+{% if constants %} |
+ {{batch_configure_constants()}} |
+{% endif %} |
// Custom toString template |
desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate()); |
@@ -133,6 +125,7 @@ bool {{v8_class_name}}::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::I |
|| V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorld); |
} |
+ |
v8::Handle<v8::Object> {{v8_class_name}}::createWrapper(PassRefPtr<{{cpp_class_name}}> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
{ |
ASSERT(impl.get()); |
@@ -144,23 +137,22 @@ v8::Handle<v8::Object> {{v8_class_name}}::createWrapper(PassRefPtr<{{cpp_class_n |
RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == info.derefObjectFunction); |
} |
+ |
v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &info, toInternalPointer(impl.get()), isolate); |
if (UNLIKELY(wrapper.IsEmpty())) |
return wrapper; |
- |
installPerContextProperties(wrapper, impl.get(), isolate); |
V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &info, wrapper, isolate, WrapperConfiguration::Independent); |
return wrapper; |
} |
- |
void {{v8_class_name}}::derefObject(void* object) |
{ |
fromInternalPointer(object)->deref(); |
} |
} // namespace WebCore |
- |
{% if conditional_string %} |
+ |
#endif // {{conditional_string}} |
{% endif %} |