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

Unified Diff: Source/bindings/tests/results/V8TestInterfacePython.cpp

Issue 203193015: Bindings: inherit enums and callbacks from partial interface files. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 months 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
Index: Source/bindings/tests/results/V8TestInterfacePython.cpp
diff --git a/Source/bindings/tests/results/V8TestInterfacePython.cpp b/Source/bindings/tests/results/V8TestInterfacePython.cpp
index c3885db3733b1101634a35c7ce3bba374b02c403..f66ecc9a3d0191ee8e01a2731e9be081a7097d7d 100644
--- a/Source/bindings/tests/results/V8TestInterfacePython.cpp
+++ b/Source/bindings/tests/results/V8TestInterfacePython.cpp
@@ -43,6 +43,7 @@
#include "bindings/tests/idls/TestPartialInterfacePython.h"
#include "bindings/tests/idls/TestPartialInterfacePythonImplementation.h"
#include "bindings/v8/ExceptionState.h"
+#include "bindings/v8/ScriptValue.h"
#include "bindings/v8/V8AbstractEventListener.h"
#include "bindings/v8/V8DOMConfiguration.h"
#include "bindings/v8/V8EventListenerList.h"
@@ -575,6 +576,46 @@ static void partialCallWithExecutionContextLongAttributeAttributeSetterCallback(
}
#endif // ENABLE(PARTIAL_CONDITION)
+#if ENABLE(PARTIAL_CONDITION)
+static void enumAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
+{
+ TestInterfacePythonImplementation* imp = V8TestInterfacePython::toNative(info.Holder());
+ ASSERT(imp);
+ v8SetReturnValueString(info, TestPartialInterfacePython::enumAttribute(*imp), 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* imp = V8TestInterfacePython::toNative(info.Holder());
+ ASSERT(imp);
+ V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, cppValue, jsValue);
+ String string = cppValue;
+ if (!(string == "foo" || string == "bar"))
+ return;
+ TestPartialInterfacePython::setEnumAttribute(*imp, 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)
{
TestInterfacePythonImplementation* imp = V8TestInterfacePython::toNative(info.Holder());
@@ -858,6 +899,29 @@ static void partialCallWithExecutionContextRaisesExceptionVoidMethodMethodCallba
}
#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* imp = V8TestInterfacePython::toNative(info.Holder());
+ V8TRYCATCH_VOID(ScriptValue, callback, ScriptValue(info[0], info.GetIsolate()));
+ ASSERT(imp);
+ TestPartialInterfacePython::methodThatTakesCallback(*imp, 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)
{
TestInterfacePythonImplementation* imp = V8TestInterfacePython::toNative(info.Holder());
@@ -959,6 +1023,13 @@ static void configureV8TestInterfacePythonTemplate(v8::Handle<v8::FunctionTempla
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)
static const V8DOMConfiguration::ConstantConfiguration V8TestInterfacePythonConstants[] = {
{"UNSIGNED_LONG", 0},
{"IMPLEMENTS_CONSTANT_1", 1},
@@ -995,6 +1066,10 @@ static void configureV8TestInterfacePythonTemplate(v8::Handle<v8::FunctionTempla
if (RuntimeEnabledFeatures::partialFeatureNameEnabled())
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)
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, "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));

Powered by Google App Engine
This is Rietveld 408576698