[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
andersca at apple.com
andersca at apple.com
Wed Dec 22 11:38:07 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 53fb9d862234bb41de7ce3a441de0ea4435c64b5
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sun Aug 1 19:39:29 2010 +0000
Add an NPObject class template helper to TestNetscapePlugin
https://bugs.webkit.org/show_bug.cgi?id=43288
Reviewed by Sam Weinig.
* DumpRenderTree/TestNetscapePlugIn/PluginTest.h:
Add some template magic to be able to figure out if a class has a member function of a given type.
(PluginTest::Object::create):
Create an object.
(PluginTest::Object::invokeDefault):
Add dummy function, this should never be called.
(PluginTest::Object::Object):
Initialize m_pluginTest to 0.
(PluginTest::Object::~Object):
Add virtual destructor.
(PluginTest::Object::NP_Allocate):
Create a new object.
(PluginTest::Object::NP_Deallocate):
Delete the object.
(PluginTest::Object::NP_InvokeDefault):
Call invokeDefault.
(PluginTest::Object::npClass):
Initialize the NPClass struct.
* DumpRenderTree/TestNetscapePlugIn/Tests/DocumentOpenInDestroyStream.cpp:
(DocumentOpenInDestroyStream::NPP_DestroyStream):
Move this inline.
* DumpRenderTree/TestNetscapePlugIn/Tests/PluginScriptableNPObjectInvokeDefault.cpp:
(PluginScriptableNPObjectInvokeDefault::NPObjectWithInvokeDefault::invokeDefault):
(PluginScriptableNPObjectInvokeDefault::NPP_GetValue):
Use the PluginTest::Object class template.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64443 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 47f9d9e..6ec6c17 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,46 @@
+2010-07-30 Anders Carlsson <andersca at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Add an NPObject class template helper to TestNetscapePlugin
+ https://bugs.webkit.org/show_bug.cgi?id=43288
+
+ * DumpRenderTree/TestNetscapePlugIn/PluginTest.h:
+ Add some template magic to be able to figure out if a class has a member function of a given type.
+
+ (PluginTest::Object::create):
+ Create an object.
+
+ (PluginTest::Object::invokeDefault):
+ Add dummy function, this should never be called.
+
+ (PluginTest::Object::Object):
+ Initialize m_pluginTest to 0.
+
+ (PluginTest::Object::~Object):
+ Add virtual destructor.
+
+ (PluginTest::Object::NP_Allocate):
+ Create a new object.
+
+ (PluginTest::Object::NP_Deallocate):
+ Delete the object.
+
+ (PluginTest::Object::NP_InvokeDefault):
+ Call invokeDefault.
+
+ (PluginTest::Object::npClass):
+ Initialize the NPClass struct.
+
+ * DumpRenderTree/TestNetscapePlugIn/Tests/DocumentOpenInDestroyStream.cpp:
+ (DocumentOpenInDestroyStream::NPP_DestroyStream):
+ Move this inline.
+
+ * DumpRenderTree/TestNetscapePlugIn/Tests/PluginScriptableNPObjectInvokeDefault.cpp:
+ (PluginScriptableNPObjectInvokeDefault::NPObjectWithInvokeDefault::invokeDefault):
+ (PluginScriptableNPObjectInvokeDefault::NPP_GetValue):
+ Use the PluginTest::Object class template.
+
2010-07-31 Sam Weinig <sam at webkit.org>
Reviewed by Dan Bernstein.
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h
index 234937b..77e0ee5 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h
@@ -27,9 +27,24 @@
#define PluginTest_h
#include <WebKit/npfunctions.h>
+#include <assert.h>
#include <map>
#include <string>
+// Helper classes for implementing has_member
+typedef char (&no_tag)[1];
+typedef char (&yes_tag)[2];
+
+#define DEFINE_HAS_MEMBER_CHECK(member, returnType, argumentTypes) \
+template<typename T, returnType (T::*member) argumentTypes> struct pmf_helper {}; \
+template<typename T> no_tag has_member_##member##_helper(...); \
+template<typename T> yes_tag has_member_##member##_helper(pmf_helper<T, &T::member > *); \
+template<typename T> struct has_member_##member { \
+static const bool value = sizeof(has_member_##member##_helper<T>(0)) == sizeof(yes_tag); \
+};
+
+DEFINE_HAS_MEMBER_CHECK(invokeDefault, bool, (const NPVariant*, uint32_t, NPVariant* result))
+
class PluginTest {
public:
static PluginTest* create(NPP, const std::string& identifier);
@@ -64,6 +79,74 @@ protected:
const std::string& identifier() const { return m_identifier; }
+ // NPObject helper template.
+ template<typename T> struct Object : NPObject {
+ public:
+ static NPObject* create(PluginTest* pluginTest)
+ {
+ Object* object = static_cast<Object*>(pluginTest->NPN_CreateObject(npClass()));
+
+ object->m_pluginTest = pluginTest;
+ return object;
+ }
+
+ // These should never be called.
+ bool invokeDefault(const NPVariant*, uint32_t, NPVariant* result)
+ {
+ assert(false);
+ return false;
+ }
+
+ protected:
+ Object()
+ : m_pluginTest(0)
+ {
+ }
+
+ virtual ~Object()
+ {
+ }
+
+ private:
+ static NPObject* NP_Allocate(NPP npp, NPClass* aClass)
+ {
+ return new T;
+ }
+
+ static void NP_Deallocate(NPObject* npObject)
+ {
+ delete static_cast<T*>(npObject);
+ }
+
+ static bool NP_InvokeDefault(NPObject* npObject, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
+ {
+ return static_cast<T*>(npObject)->invokeDefault(arguments, argumentCount, result);
+ }
+
+ static NPClass* npClass()
+ {
+ static NPClass npClass = {
+ NP_CLASS_STRUCT_VERSION,
+ NP_Allocate,
+ NP_Deallocate,
+ 0, // NPClass::invalidate
+ 0, // NPClass::hasMethod
+ 0, // NPClass::invoke
+ has_member_invokeDefault<T>::value ? NP_InvokeDefault : 0,
+ 0, // NPClass::hasProperty
+ 0, // NPClass::getProperty
+ 0, // NPClass::setProperty
+ 0, // NPClass::removeProperty
+ 0, // NPClass::enumerate
+ 0 // NPClass::construct
+ };
+
+ return &npClass;
+ };
+
+ PluginTest* m_pluginTest;
+ };
+
private:
typedef PluginTest* (*CreateTestFunction)(NPP, const std::string&);
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/DocumentOpenInDestroyStream.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/DocumentOpenInDestroyStream.cpp
index 10ff263..69e706e 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/DocumentOpenInDestroyStream.cpp
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/DocumentOpenInDestroyStream.cpp
@@ -40,19 +40,17 @@ public:
}
private:
- virtual NPError NPP_DestroyStream(NPStream*, NPReason);
+ virtual NPError NPP_DestroyStream(NPStream*, NPReason)
+ {
+ if (m_shouldOpen) {
+ testDocumentOpen(m_npp);
+ m_shouldOpen = false;
+ }
+
+ return NPERR_NO_ERROR;
+ }
bool m_shouldOpen;
};
-NPError DocumentOpenInDestroyStream::NPP_DestroyStream(NPStream*, NPReason)
-{
- if (m_shouldOpen) {
- testDocumentOpen(m_npp);
- m_shouldOpen = false;
- }
-
- return NPERR_NO_ERROR;
-}
-
static PluginTest::Register<DocumentOpenInDestroyStream> documentOpenInDestroyStream("document-open-in-destroy-stream");
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/PluginScriptableNPObjectInvokeDefault.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/PluginScriptableNPObjectInvokeDefault.cpp
index 30c463b..959e182 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/PluginScriptableNPObjectInvokeDefault.cpp
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/PluginScriptableNPObjectInvokeDefault.cpp
@@ -27,44 +27,6 @@
using namespace std;
-static bool invokeDefault(NPObject*, const NPVariant*, uint32_t, NPVariant* result)
-{
- INT32_TO_NPVARIANT(1, *result);
- return true;
-}
-
-static NPClass npClassWithInvokeDefault = {
- NP_CLASS_STRUCT_VERSION,
- 0, // NPClass::allocate
- 0, // NPClass::deallocate
- 0, // NPClass::invalidate
- 0, // NPClass::hasMethod
- 0, // NPClass::invoke
- invokeDefault,
- 0, // NPClass::hasProperty
- 0, // NPClass::getProperty
- 0, // NPClass::setProperty
- 0, // NPClass::removeProperty
- 0, // NPClass::enumerate
- 0 // NPClass::construct
-};
-
-static NPClass npClassWithoutInvokeDefault = {
- NP_CLASS_STRUCT_VERSION,
- 0, // NPClass::allocate
- 0, // NPClass::deallocate
- 0, // NPClass::invalidate
- 0, // NPClass::hasMethod
- 0, // NPClass::invoke
- 0, // NPClass::invokeDefault,
- 0, // NPClass::hasProperty
- 0, // NPClass::getProperty
- 0, // NPClass::setProperty
- 0, // NPClass::removeProperty
- 0, // NPClass::enumerate
- 0 // NPClass::construct
-};
-
// A test where the plug-ins scriptable object either has or doesn't have an invokeDefault function.
class PluginScriptableNPObjectInvokeDefault : public PluginTest {
public:
@@ -74,23 +36,32 @@ public:
}
private:
+ struct NPObjectWithoutInvokeDefault : Object<NPObjectWithoutInvokeDefault> { };
+
+ struct NPObjectWithInvokeDefault : Object<NPObjectWithInvokeDefault> {
+ public:
+ bool invokeDefault(const NPVariant*, uint32_t, NPVariant* result)
+ {
+ INT32_TO_NPVARIANT(1, *result);
+ return true;
+ }
+ };
+
virtual NPError NPP_GetValue(NPPVariable variable, void *value)
{
if (variable != NPPVpluginScriptableNPObject)
return NPERR_GENERIC_ERROR;
- NPClass* npClass;
+ NPObject* object;
if (identifier() == "plugin-scriptable-npobject-invoke-default")
- npClass = &npClassWithInvokeDefault;
+ object = NPObjectWithInvokeDefault::create(this);
else
- npClass = &npClassWithoutInvokeDefault;
+ object = NPObjectWithoutInvokeDefault::create(this);
- *(NPObject**)value = NPN_CreateObject(npClass);
+ *(NPObject**)value = object;
return NPERR_NO_ERROR;
}
-
- NPObject* m_scriptableObject;
};
static PluginTest::Register<PluginScriptableNPObjectInvokeDefault> pluginScriptableNPObjectInvokeDefault("plugin-scriptable-npobject-invoke-default");
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list