Commit c818e648 authored by mlamouri@chromium.org's avatar mlamouri@chromium.org

Bindings: inherit enums and callbacks from partial interface files.

BUG=353997

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

git-svn-id: svn://svn.chromium.org/blink/trunk@169749 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 50a18494
...@@ -164,6 +164,10 @@ class IdlDefinitions(object): ...@@ -164,6 +164,10 @@ class IdlDefinitions(object):
'but no existing interface by that name' 'but no existing interface by that name'
.format(interface_name)) .format(interface_name))
# Merge callbacks and enumerations
self.enumerations.update(other.enumerations)
self.callback_functions.update(other.callback_functions)
################################################################################ ################################################################################
# Callback Functions # Callback Functions
......
...@@ -28,6 +28,15 @@ ...@@ -28,6 +28,15 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
enum PartialEnumType {
"foo",
"bar"
};
typedef DOMString String;
callback PartialCallbackType = void (String value);
[ [
Conditional=PARTIAL_CONDITION, Conditional=PARTIAL_CONDITION,
RuntimeEnabled=PartialFeatureName, RuntimeEnabled=PartialFeatureName,
...@@ -42,4 +51,7 @@ ...@@ -42,4 +51,7 @@
static void partialStaticVoidMethod(); static void partialStaticVoidMethod();
void partialVoidMethodLongArg(long longArg); void partialVoidMethodLongArg(long longArg);
[CallWith=ExecutionContext, RaisesException] void partialCallWithExecutionContextRaisesExceptionVoidMethod(); [CallWith=ExecutionContext, RaisesException] void partialCallWithExecutionContextRaisesExceptionVoidMethod();
attribute PartialEnumType enumAttribute;
void methodThatTakesCallback(PartialCallbackType callback);
}; };
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "bindings/tests/idls/TestPartialInterfacePython.h" #include "bindings/tests/idls/TestPartialInterfacePython.h"
#include "bindings/tests/idls/TestPartialInterfacePythonImplementation.h" #include "bindings/tests/idls/TestPartialInterfacePythonImplementation.h"
#include "bindings/v8/ExceptionState.h" #include "bindings/v8/ExceptionState.h"
#include "bindings/v8/ScriptValue.h"
#include "bindings/v8/V8AbstractEventListener.h" #include "bindings/v8/V8AbstractEventListener.h"
#include "bindings/v8/V8DOMConfiguration.h" #include "bindings/v8/V8DOMConfiguration.h"
#include "bindings/v8/V8EventListenerList.h" #include "bindings/v8/V8EventListenerList.h"
...@@ -575,6 +576,46 @@ static void partialCallWithExecutionContextLongAttributeAttributeSetterCallback( ...@@ -575,6 +576,46 @@ static void partialCallWithExecutionContextLongAttributeAttributeSetterCallback(
} }
#endif // ENABLE(PARTIAL_CONDITION) #endif // ENABLE(PARTIAL_CONDITION)
#if ENABLE(PARTIAL_CONDITION)
static void enumAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
{
TestInterfacePythonImplementation* impl = V8TestInterfacePython::toNative(info.Holder());
ASSERT(impl);
v8SetReturnValueString(info, TestPartialInterfacePython::enumAttribute(*impl), info.GetIsolate());
}
#endif // ENABLE(PARTIAL_CONDITION)
#if ENABLE(PARTIAL_CONDITION)
static void enumAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
TestInterfacePythonImplementationV8Internal::enumAttributeAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
#endif // ENABLE(PARTIAL_CONDITION)
#if ENABLE(PARTIAL_CONDITION)
static void enumAttributeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
TestInterfacePythonImplementation* impl = V8TestInterfacePython::toNative(info.Holder());
ASSERT(impl);
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, cppValue, jsValue);
String string = cppValue;
if (!(string == "foo" || string == "bar"))
return;
TestPartialInterfacePython::setEnumAttribute(*impl, cppValue);
}
#endif // ENABLE(PARTIAL_CONDITION)
#if ENABLE(PARTIAL_CONDITION)
static void enumAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
TestInterfacePythonImplementationV8Internal::enumAttributeAttributeSetter(jsValue, info);
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
#endif // ENABLE(PARTIAL_CONDITION)
static void partial2LongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) static void partial2LongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
{ {
TestInterfacePythonImplementation* impl = V8TestInterfacePython::toNative(info.Holder()); TestInterfacePythonImplementation* impl = V8TestInterfacePython::toNative(info.Holder());
...@@ -858,6 +899,29 @@ static void partialCallWithExecutionContextRaisesExceptionVoidMethodMethodCallba ...@@ -858,6 +899,29 @@ static void partialCallWithExecutionContextRaisesExceptionVoidMethodMethodCallba
} }
#endif // ENABLE(PARTIAL_CONDITION) #endif // ENABLE(PARTIAL_CONDITION)
#if ENABLE(PARTIAL_CONDITION)
static void methodThatTakesCallbackMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
if (UNLIKELY(info.Length() < 1)) {
throwTypeError(ExceptionMessages::failedToExecute("methodThatTakesCallback", "TestInterfacePython", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate());
return;
}
TestInterfacePythonImplementation* impl = V8TestInterfacePython::toNative(info.Holder());
V8TRYCATCH_VOID(ScriptValue, callback, ScriptValue(info[0], info.GetIsolate()));
ASSERT(impl);
TestPartialInterfacePython::methodThatTakesCallback(*impl, callback);
}
#endif // ENABLE(PARTIAL_CONDITION)
#if ENABLE(PARTIAL_CONDITION)
static void methodThatTakesCallbackMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
TestInterfacePythonImplementationV8Internal::methodThatTakesCallbackMethod(info);
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
#endif // ENABLE(PARTIAL_CONDITION)
static void partial2VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) static void partial2VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{ {
TestInterfacePythonImplementation* impl = V8TestInterfacePython::toNative(info.Holder()); TestInterfacePythonImplementation* impl = V8TestInterfacePython::toNative(info.Holder());
...@@ -958,6 +1022,13 @@ static void configureV8TestInterfacePythonTemplate(v8::Handle<v8::FunctionTempla ...@@ -958,6 +1022,13 @@ static void configureV8TestInterfacePythonTemplate(v8::Handle<v8::FunctionTempla
{"partialCallWithExecutionContextLongAttribute", TestInterfacePythonImplementationV8Internal::partialCallWithExecutionContextLongAttributeAttributeGetterCallback, TestInterfacePythonImplementationV8Internal::partialCallWithExecutionContextLongAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; {"partialCallWithExecutionContextLongAttribute", TestInterfacePythonImplementationV8Internal::partialCallWithExecutionContextLongAttributeAttributeGetterCallback, TestInterfacePythonImplementationV8Internal::partialCallWithExecutionContextLongAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */};
V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate); V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate);
} }
#endif // ENABLE(PARTIAL_CONDITION)
#if ENABLE(PARTIAL_CONDITION)
if (RuntimeEnabledFeatures::partialFeatureNameEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"enumAttribute", TestInterfacePythonImplementationV8Internal::enumAttributeAttributeGetterCallback, TestInterfacePythonImplementationV8Internal::enumAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */};
V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate);
}
#endif // ENABLE(PARTIAL_CONDITION) #endif // ENABLE(PARTIAL_CONDITION)
static const V8DOMConfiguration::ConstantConfiguration V8TestInterfacePythonConstants[] = { static const V8DOMConfiguration::ConstantConfiguration V8TestInterfacePythonConstants[] = {
{"UNSIGNED_LONG", 0}, {"UNSIGNED_LONG", 0},
...@@ -994,6 +1065,10 @@ static void configureV8TestInterfacePythonTemplate(v8::Handle<v8::FunctionTempla ...@@ -994,6 +1065,10 @@ static void configureV8TestInterfacePythonTemplate(v8::Handle<v8::FunctionTempla
#if ENABLE(PARTIAL_CONDITION) #if ENABLE(PARTIAL_CONDITION)
if (RuntimeEnabledFeatures::partialFeatureNameEnabled()) if (RuntimeEnabledFeatures::partialFeatureNameEnabled())
prototypeTemplate->Set(v8AtomicString(isolate, "partialCallWithExecutionContextRaisesExceptionVoidMethod"), v8::FunctionTemplate::New(isolate, TestInterfacePythonImplementationV8Internal::partialCallWithExecutionContextRaisesExceptionVoidMethodMethodCallback, v8Undefined(), defaultSignature, 0)); prototypeTemplate->Set(v8AtomicString(isolate, "partialCallWithExecutionContextRaisesExceptionVoidMethod"), v8::FunctionTemplate::New(isolate, TestInterfacePythonImplementationV8Internal::partialCallWithExecutionContextRaisesExceptionVoidMethodMethodCallback, v8Undefined(), defaultSignature, 0));
#endif // ENABLE(PARTIAL_CONDITION)
#if ENABLE(PARTIAL_CONDITION)
if (RuntimeEnabledFeatures::partialFeatureNameEnabled())
prototypeTemplate->Set(v8AtomicString(isolate, "methodThatTakesCallback"), v8::FunctionTemplate::New(isolate, TestInterfacePythonImplementationV8Internal::methodThatTakesCallbackMethodCallback, v8Undefined(), defaultSignature, 1));
#endif // ENABLE(PARTIAL_CONDITION) #endif // ENABLE(PARTIAL_CONDITION)
functionTemplate->Set(v8AtomicString(isolate, "partial2StaticVoidMethod"), v8::FunctionTemplate::New(isolate, TestInterfacePythonImplementationV8Internal::partial2StaticVoidMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0)); functionTemplate->Set(v8AtomicString(isolate, "partial2StaticVoidMethod"), v8::FunctionTemplate::New(isolate, TestInterfacePythonImplementationV8Internal::partial2StaticVoidMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0));
functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "staticStringAttribute"), TestInterfacePythonImplementationV8Internal::staticStringAttributeAttributeGetterCallback, TestInterfacePythonImplementationV8Internal::staticStringAttributeAttributeSetterCallback, 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, "staticStringAttribute"), TestInterfacePythonImplementationV8Internal::staticStringAttributeAttributeGetterCallback, TestInterfacePythonImplementationV8Internal::staticStringAttributeAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT));
......
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