Browse Source

Step towards getting the web plugin working on Linux

rdb 16 years ago
parent
commit
1856f17d94

+ 1 - 1
direct/src/plugin/p3dPythonRun.cxx

@@ -957,7 +957,7 @@ pyobj_to_xml(PyObject *value) {
     // general.
     // TODO: pass pointers better.
     xvalue->SetAttribute("type", "python");
-    xvalue->SetAttribute("object_id", (int)value);
+    xvalue->SetAttribute("object_id", (int)(intptr_t)value);
 
     // TODO: fix this hack, properly manage these reference counts.
     Py_INCREF(value);

+ 1 - 1
direct/src/plugin/p3dSession.cxx

@@ -433,7 +433,7 @@ p3dobj_to_xml(const P3D_object *obj) {
       // the Python process knows to call back up to here to query it.
       // TODO: pass pointers better.  Fix this hideous leak.
       P3D_object *dup = P3D_OBJECT_COPY(obj);
-      int object_id = (int)dup;
+      int object_id = (int)(intptr_t)dup;
       xvalue->SetAttribute("type", "browser");
       xvalue->SetAttribute("object_id", object_id);
 

+ 1 - 1
direct/src/plugin/p3d_lock.h

@@ -89,7 +89,7 @@ pthread_join((thread), &return_val); \
 
 // As above, declare this macro within your class declaration.
 #define THREAD_CALLBACK_DECLARATION(class, callback_function) \
-  static void *class::                                               \
+  static void *                                               \
   posix_ ## callback_function(void *data) {        \
     ((class *)data)->callback_function();       \
     return NULL;                                   \

+ 2 - 0
direct/src/plugin/p3d_plugin_config.h.pp

@@ -28,6 +28,8 @@
 #if $[not $[P3D_PLUGIN_PLATFORM]]
   #if $[WINDOWS_PLATFORM]
     #define P3D_PLUGIN_PLATFORM win32
+  #elif $[UNIX_PLATFORM]
+    #define P3D_PLUGIN_PLATFORM linux.$[shell uname -m]
   #else
     #define P3D_PLUGIN_PLATFORM osx.i386
   #endif

+ 40 - 3
direct/src/plugin_npapi/startup.cxx

@@ -69,6 +69,41 @@ request_ready(P3D_instance *instance) {
 #endif
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: NP_GetMIMEDescription
+//  Description: On Unix, this function is called by the browser to
+//               get the mimetypes and extensions this plugin is
+//               supposed to handle.
+////////////////////////////////////////////////////////////////////
+char*
+NP_GetMIMEDescription(void) {
+  return (char*) "application/x-panda3d:p3d;Panda3D applet";
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: NP_GetValue
+//  Description: On Unix, this function is called by the browser to
+//               get some information like the name and description.
+////////////////////////////////////////////////////////////////////
+NPError
+NP_GetValue(void*, NPPVariable variable, void* value) {
+  if (value == NULL) {
+    return NPERR_INVALID_PARAM;
+  }
+  
+  switch (variable) {
+    case NPPVpluginNameString:
+      *(const char **)value = "Panda3D Game Engine Plug-in";
+      break;
+    case NPPVpluginDescriptionString:
+      *(const char **)value = "Runs 3-D games and interactive applets";
+      break;
+    default:
+      return NPERR_INVALID_PARAM;
+  }
+  
+  return NPERR_NO_ERROR;
+}
 
 ////////////////////////////////////////////////////////////////////
 //     Function: NP_Initialize
@@ -81,9 +116,9 @@ request_ready(P3D_instance *instance) {
 NPError OSCALL 
 NP_Initialize(NPNetscapeFuncs *browserFuncs)
 #else
-// On Mac, the API specifies this second parameter is included, but it
-// lies.  We actually don't get a second parameter on Mac, but we have
-// to put it here to make the compiler happy.
+// On Unix/Mac, the API specifies this second parameter is included,
+// but it lies.  We actually don't get a second parameter there,
+// but we have to put it here to make the compiler happy.
 NPError OSCALL
 NP_Initialize(NPNetscapeFuncs *browserFuncs,
               NPPluginFuncs *pluginFuncs)
@@ -357,6 +392,8 @@ NPP_GetValue(NPP instance, NPPVariable variable, void *value) {
       *(NPObject **)value = obj;
       return NPERR_NO_ERROR;
     }
+  } else {
+    return NP_GetValue(NULL, variable, value);
   }
 
   return NPERR_GENERIC_ERROR;

+ 2 - 0
direct/src/plugin_npapi/startup.h

@@ -25,6 +25,8 @@ extern "C" {
                                NPPluginFuncs *pluginFuncs);
 #endif
 
+  char* NP_GetMIMEDescription(void);
+  NPError NP_GetValue(void*, NPPVariable variable, void* value);
   NPError OSCALL NP_GetEntryPoints(NPPluginFuncs *pluginFuncs);
   NPError OSCALL NP_Shutdown(void);
 }