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
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;
};
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)
{
template<class T>
RuntimeNPClass<T>::~RuntimeNPClass()
{
- delete propertyIdentifiers;
- delete methodIdentifiers;
+ delete[] propertyIdentifiers;
+ delete[] methodIdentifiers;
}
template<class T>