Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static NPClass refObject = {
- NP_CLASS_STRUCT_VERSION,
- My_Allocate,
- My_Deallocate,
- NULL,
- My_HasMethod,
- My_Invoke,
- My_InvokeDefault,
- My_HasProperty,
- My_GetProperty,
- NULL,
- NULL,
- };
- class MyImplClass {
- // Implementation goes here
- };
- struct MyNPObject : public NPObject {
- MyImplClass *my_impl_instance;
- };
- // This is just a bit of memory management - Mozilla wants us to allocate our own memory:
- NPObject *My_Allocate(NPP inst, NPClass *)
- {
- // We initialize the structure in NPP_New() below
- return (NPObject *)malloc(sizeof(MyNPObject));
- }
- NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
- char* argn[], char* argv[], NPSavedData* saved )
- {
- NPObject *scriptable_object = npnfuncs->createobject(instance, &refObject);
- npnfuncs->retainobject(scriptable_object);
- MyImplClass *new_player = new MyImplClass();
- instance->pdata = scriptable_object;
- ((MyNPObject*)instance->pdata)->my_impl_instance = new_player;
- return NPERR_NO_ERROR;
Add Comment
Please, Sign In to add comment