Browse Source

unwrap p3d_object

David Rose 16 years ago
parent
commit
9f56a959c2
2 changed files with 12 additions and 1 deletions
  1. 11 1
      direct/src/plugin_npapi/ppInstance.cxx
  2. 1 0
      direct/src/plugin_npapi/ppPandaObject.h

+ 11 - 1
direct/src/plugin_npapi/ppInstance.cxx

@@ -565,7 +565,17 @@ variant_to_p3dobj(const NPVariant *variant) {
     NPString str = NPVARIANT_TO_STRING(*variant);
     return P3D_new_string_object(str.utf8characters, str.utf8length);
   } else if (NPVARIANT_IS_OBJECT(*variant)) {
-    return new PPBrowserObject(this, NPVARIANT_TO_OBJECT(*variant));
+    NPObject *object = NPVARIANT_TO_OBJECT(*variant);
+    if (object->_class == &PPPandaObject::_object_class) {
+      // This is really a PPPandaObject.
+      PPPandaObject *ppobject = (PPPandaObject *)object;
+      P3D_object *obj = ppobject->get_p3d_object();
+      logfile << "Found nested Panda Object " << obj << "\n" << flush;
+      return P3D_OBJECT_COPY(obj);
+    }
+
+    // It's a generic NPObject of some kind.
+    return new PPBrowserObject(this, object);
   }
 
   // Hmm, none of the above?

+ 1 - 0
direct/src/plugin_npapi/ppPandaObject.h

@@ -86,6 +86,7 @@ private:
   PPInstance *_instance;
   P3D_object *_p3d_object;
 
+public:
   static NPClass _object_class;
 };