]> git.sesse.net Git - vlc/blobdiff - projects/mozilla/control/nporuntime.h
Default to rebase on submodule updates to prevent losing local changes.
[vlc] / projects / mozilla / control / nporuntime.h
old mode 100755 (executable)
new mode 100644 (file)
index 2f6c91b..fe9bfc6
@@ -42,6 +42,9 @@ static bool RuntimeNPClassInvokeDefault(NPObject *npobj,
 class RuntimeNPObject : public NPObject
 {
 public:
+    // Lazy child object cration helper. Doing this avoids
+    // ownership problems with firefox.
+    template<class T> void InstantObj( NPObject *&obj );
 
     /*
     ** utility functions
@@ -127,6 +130,17 @@ protected:
 
     bool returnInvokeResult(InvokeResult result);
 
+    static InvokeResult invokeResultString(const char *,NPVariant &);
+
+    bool isPluginRunning()
+    {
+        return (_instance->pdata != NULL);
+    }
+    template<class T> T *getPrivate()
+    {
+        return reinterpret_cast<T *>(_instance->pdata);
+    }
+
     NPP _instance;
 };
 
@@ -163,6 +177,13 @@ private:
     NPIdentifier *methodIdentifiers;
 };
 
+template<class T>
+inline void RuntimeNPObject::InstantObj( NPObject *&obj )
+{
+    if( !obj )
+        obj = NPN_CreateObject(_instance, RuntimeNPClass<T>::getClass());
+}
+
 template<class T>
 static NPObject *RuntimeNPClassAllocate(NPP instance, NPClass *aClass)
 {
@@ -315,8 +336,8 @@ RuntimeNPClass<T>::RuntimeNPClass()
 template<class T>
 RuntimeNPClass<T>::~RuntimeNPClass()
 {
-    delete propertyIdentifiers;
-    delete methodIdentifiers;
+    delete[] propertyIdentifiers;
+    delete[] methodIdentifiers;
 }
 
 template<class T>