Commit 8c1a0fa6 authored by nbarth@chromium.org's avatar nbarth@chromium.org

Add back [ImplementedInBaseClass] IDL extended attribute

Originally [LegacyImplementedInBaseClass] was intended to be short-term,
as the name suggests, for some refactoring.

However, for more complex cases of 'implements' usage,
the requirements that 'implements' puts on C++ implementation
makes it an ugly mess.
Thus allowing implementation in base class seems useful long-term,
so re-introducing.

Per:
WebGLRenderingContextBase
https://codereview.chromium.org/205243013/

Documentation:
http://www.chromium.org/blink/webidl/blink-idl-extended-attributes#TOC-ImplementedInBaseClass-i-

Compare earlier CL removing this:
Remove support for [LegacyImplementedInBaseClass] IDL extended attribute 
https://codereview.chromium.org/169273002/

R=haraken
BUG=344224

Review URL: https://codereview.chromium.org/209663005

git-svn-id: svn://svn.chromium.org/blink/trunk@169830 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 97f46930
......@@ -60,6 +60,7 @@ WillBeGarbageCollected
GlobalContext=Window|WorkerGlobalScope|SharedWorkerGlobalScope|DedicatedWorkerGlobalScope|ServiceWorkerGlobalScope
Immutable
ImplementedAs=*
ImplementedInBaseClass
InitializedByEventConstructor
MeasureAs=*
NamedConstructor=*
......
......@@ -163,7 +163,9 @@ def compute_individual_info(idl_filename):
implemented_as = extended_attributes.get('ImplementedAs')
# FIXME: remove [NoHeader] once switch to Python
this_include_path = (include_path(idl_filename, implemented_as)
if 'NoHeader' not in extended_attributes else None)
if ('ImplementedInBaseClass' not in extended_attributes
and 'NoHeader' not in extended_attributes)
else None)
# Handle partial interfaces
partial_interface_name = get_partial_interface_name_from_idl(idl_file_contents)
......
......@@ -143,15 +143,17 @@ def transfer_extended_attributes(dependency_interface, dependency_interface_base
# C++ class name of the implementation, stored in [ImplementedBy], which
# defaults to the basename of dependency IDL file.
# This can be overridden by [ImplementedAs] on the dependency interface.
# This can be overridden by [ImplementedAs] on the dependency interface,
# and omitted entirely by [ImplementedInBaseClass].
# Note that [ImplementedAs] is used with different meanings on interfaces
# and members:
# for Blink class name and function name (or constant name), respectively.
# Thus we do not want to copy this from the interface to the member, but
# instead extract it and handle it separately.
merged_extended_attributes['ImplementedBy'] = (
dependency_interface.extended_attributes.get(
'ImplementedAs', dependency_interface_basename))
if 'ImplementedInBaseClass' not in dependency_interface.extended_attributes:
merged_extended_attributes['ImplementedBy'] = (
dependency_interface.extended_attributes.get(
'ImplementedAs', dependency_interface_basename))
for attribute in dependency_interface.attributes:
attribute.extended_attributes.update(merged_extended_attributes)
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
[
ImplementedInBaseClass, // Conflicts with default implements class name and [ImplementedAs]
NoInterfaceObject,
] interface TestImplements3 {
attribute DOMString implements3StringAttribute;
static attribute DOMString implements3StaticStringAttribute;
void implements3VoidMethod();
static void implements3StaticVoidMethod();
};
......@@ -50,3 +50,4 @@
TestInterfacePython implements TestImplements;
TestInterfacePython implements TestImplements2;
TestInterfacePython implements TestImplements3;
......@@ -464,6 +464,58 @@ static void implements2StringAttributeAttributeSetterCallback(v8::Local<v8::Stri
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
static void implements3StringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
{
TestInterfacePythonImplementation* impl = V8TestInterfacePython::toNative(info.Holder());
v8SetReturnValueString(info, impl->implements3StringAttribute(), info.GetIsolate());
}
static void implements3StringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
TestInterfacePythonImplementationV8Internal::implements3StringAttributeAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
static void implements3StringAttributeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
TestInterfacePythonImplementation* impl = V8TestInterfacePython::toNative(info.Holder());
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, cppValue, jsValue);
impl->setImplements3StringAttribute(cppValue);
}
static void implements3StringAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
TestInterfacePythonImplementationV8Internal::implements3StringAttributeAttributeSetter(jsValue, info);
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
static void implements3StaticStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
{
v8SetReturnValueString(info, TestInterfacePythonImplementation::implements3StaticStringAttribute(), info.GetIsolate());
}
static void implements3StaticStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
TestInterfacePythonImplementationV8Internal::implements3StaticStringAttributeAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
static void implements3StaticStringAttributeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, cppValue, jsValue);
TestInterfacePythonImplementation::setImplements3StaticStringAttribute(cppValue);
}
static void implements3StaticStringAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
TestInterfacePythonImplementationV8Internal::implements3StaticStringAttributeAttributeSetter(jsValue, info);
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
#if ENABLE(PARTIAL_CONDITION)
static void partialLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
{
......@@ -818,6 +870,31 @@ static void implements2VoidMethodMethodCallback(const v8::FunctionCallbackInfo<v
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
static void implements3VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TestInterfacePythonImplementation* impl = V8TestInterfacePython::toNative(info.Holder());
impl->implements3VoidMethod();
}
static void implements3VoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
TestInterfacePythonImplementationV8Internal::implements3VoidMethodMethod(info);
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
static void implements3StaticVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TestInterfacePythonImplementation::implements3StaticVoidMethod();
}
static void implements3StaticVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
TestInterfacePythonImplementationV8Internal::implements3StaticVoidMethodMethod(info);
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
#if ENABLE(PARTIAL_CONDITION)
static void partialVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
......@@ -972,6 +1049,7 @@ static const V8DOMConfiguration::AttributeConfiguration V8TestInterfacePythonAtt
{"implementsStringAttribute", TestInterfacePythonImplementationV8Internal::implementsStringAttributeAttributeGetterCallback, TestInterfacePythonImplementationV8Internal::implementsStringAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
{"implementsNodeAttribute", TestInterfacePythonImplementationV8Internal::implementsNodeAttributeAttributeGetterCallback, TestInterfacePythonImplementationV8Internal::implementsNodeAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
{"implementsEventHandlerAttribute", TestInterfacePythonImplementationV8Internal::implementsEventHandlerAttributeAttributeGetterCallback, TestInterfacePythonImplementationV8Internal::implementsEventHandlerAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
{"implements3StringAttribute", TestInterfacePythonImplementationV8Internal::implements3StringAttributeAttributeGetterCallback, TestInterfacePythonImplementationV8Internal::implements3StringAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
{"partial2LongAttribute", TestInterfacePythonImplementationV8Internal::partial2LongAttributeAttributeGetterCallback, TestInterfacePythonImplementationV8Internal::partial2LongAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
};
......@@ -981,6 +1059,7 @@ static const V8DOMConfiguration::MethodConfiguration V8TestInterfacePythonMethod
{"implementsVoidMethod", TestInterfacePythonImplementationV8Internal::implementsVoidMethodMethodCallback, 0, 0},
{"implementsComplexMethod", TestInterfacePythonImplementationV8Internal::implementsComplexMethodMethodCallback, 0, 2},
{"implementsCustomVoidMethod", TestInterfacePythonImplementationV8Internal::implementsCustomVoidMethodMethodCallback, 0, 0},
{"implements3VoidMethod", TestInterfacePythonImplementationV8Internal::implements3VoidMethodMethodCallback, 0, 0},
{"partial2VoidMethod", TestInterfacePythonImplementationV8Internal::partial2VoidMethodMethodCallback, 0, 0},
};
......@@ -1050,6 +1129,7 @@ static void configureV8TestInterfacePythonTemplate(v8::Handle<v8::FunctionTempla
functionTemplate->Set(v8AtomicString(isolate, "implementsStaticVoidMethod"), v8::FunctionTemplate::New(isolate, TestInterfacePythonImplementationV8Internal::implementsStaticVoidMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0));
if (RuntimeEnabledFeatures::implements2FeatureNameEnabled())
prototypeTemplate->Set(v8AtomicString(isolate, "implements2VoidMethod"), v8::FunctionTemplate::New(isolate, TestInterfacePythonImplementationV8Internal::implements2VoidMethodMethodCallback, v8Undefined(), defaultSignature, 0));
functionTemplate->Set(v8AtomicString(isolate, "implements3StaticVoidMethod"), v8::FunctionTemplate::New(isolate, TestInterfacePythonImplementationV8Internal::implements3StaticVoidMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0));
#if ENABLE(PARTIAL_CONDITION)
if (RuntimeEnabledFeatures::partialFeatureNameEnabled())
prototypeTemplate->Set(v8AtomicString(isolate, "partialVoidMethod"), v8::FunctionTemplate::New(isolate, TestInterfacePythonImplementationV8Internal::partialVoidMethodMethodCallback, v8Undefined(), defaultSignature, 0));
......@@ -1075,6 +1155,7 @@ static void configureV8TestInterfacePythonTemplate(v8::Handle<v8::FunctionTempla
functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "implementsStaticReadOnlyLongAttribute"), TestInterfacePythonImplementationV8Internal::implementsStaticReadOnlyLongAttributeAttributeGetterCallback, 0, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT));
functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "implementsStaticStringAttribute"), TestInterfacePythonImplementationV8Internal::implementsStaticStringAttributeAttributeGetterCallback, TestInterfacePythonImplementationV8Internal::implementsStaticStringAttributeAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT));
functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "implements2StaticStringAttribute"), TestInterfacePythonImplementationV8Internal::implements2StaticStringAttributeAttributeGetterCallback, TestInterfacePythonImplementationV8Internal::implements2StaticStringAttributeAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT));
functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "implements3StaticStringAttribute"), TestInterfacePythonImplementationV8Internal::implements3StaticStringAttributeAttributeGetterCallback, TestInterfacePythonImplementationV8Internal::implements3StaticStringAttributeAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT));
#if ENABLE(PARTIAL_CONDITION)
functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "partialStaticLongAttribute"), TestInterfacePythonImplementationV8Internal::partialStaticLongAttributeAttributeGetterCallback, TestInterfacePythonImplementationV8Internal::partialStaticLongAttributeAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT));
#endif // ENABLE(PARTIAL_CONDITION)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment