Browse Source

mo' better plugin versioning

David Rose 16 years ago
parent
commit
5008ca2aa8

+ 13 - 0
direct/src/plugin/p3dInstance.cxx

@@ -140,11 +140,24 @@ P3DInstance(P3D_request_ready_func *func,
   if (!inst_mgr->get_plugin_official_version()) {
     stream << "c";
   }
+  
+// The plugin version as a single number, with three digits reserved
+// for each component.
+  int numeric_version = 
+    inst_mgr->get_plugin_major_version() * 1000000 + 
+    inst_mgr->get_plugin_minor_version() * 1000 + 
+    inst_mgr->get_plugin_sequence_version();
+  if (!inst_mgr->get_plugin_official_version()) { 
+    // Subtract 1 if we are not an official version.
+    --numeric_version;
+  }
+
   _panda_script_object->set_string_property("pluginVersionString", stream.str());
   _panda_script_object->set_int_property("pluginMajorVersion", inst_mgr->get_plugin_major_version());
   _panda_script_object->set_int_property("pluginMinorVersion", inst_mgr->get_plugin_minor_version());
   _panda_script_object->set_int_property("pluginSequenceVersion", inst_mgr->get_plugin_sequence_version());
   _panda_script_object->set_bool_property("pluginOfficialVersion", inst_mgr->get_plugin_official_version());
+  _panda_script_object->set_int_property("pluginNumericVersion", numeric_version);
   _panda_script_object->set_string_property("pluginDistributor", inst_mgr->get_plugin_distributor());
   _panda_script_object->set_string_property("coreapiHostUrl", inst_mgr->get_coreapi_host_url());
   time_t timestamp = inst_mgr->get_coreapi_timestamp();

+ 8 - 2
direct/src/plugin_npapi/ppPandaObject.cxx

@@ -239,17 +239,23 @@ has_property(NPIdentifier name) {
 ////////////////////////////////////////////////////////////////////
 bool PPPandaObject::
 get_property(NPIdentifier name, NPVariant *result) {
+  // Actually, we never return false.  If the property doesn't exist,
+  // we return undefined, to be consistent with JavaScript (and with
+  // IE).
+
   string property_name = identifier_to_string(name);
   //nout << this << ".get_property(" << property_name << ")\n";
   if (_p3d_object == NULL) {
     // Not powered up yet.
-    return false;
+    VOID_TO_NPVARIANT(*result);
+    return true;
   }
 
   P3D_object *value = P3D_OBJECT_GET_PROPERTY(_p3d_object, property_name.c_str());
   if (value == NULL) {
     // No such property.
-    return false;
+    VOID_TO_NPVARIANT(*result);
+    return true;
   }
 
   // We have the property, and its value is stored in value.

+ 17 - 9
dtool/Package.pp

@@ -19,15 +19,23 @@
 
 // Get the current version info for Panda.
 #include $[THISDIRPREFIX]PandaVersion.pp
-#defer PANDA_MAJOR_VERSION $[word 1,$[PANDA_VERSION]]
-#defer PANDA_MINOR_VERSION $[word 2,$[PANDA_VERSION]]
-#defer PANDA_SEQUENCE_VERSION $[word 3,$[PANDA_VERSION]]
-#defer PANDA_VERSION_STR $[PANDA_MAJOR_VERSION].$[PANDA_MINOR_VERSION].$[PANDA_SEQUENCE_VERSION]$[if $[not $[PANDA_OFFICIAL_VERSION]],c]
-#defer PANDA_VERSION_SYMBOL panda_version_$[PANDA_MAJOR_VERSION]_$[PANDA_MINOR_VERSION]_$[PANDA_SEQUENCE_VERSION]$[if $[not $[PANDA_OFFICIAL_VERSION]],c]
-
-#defer P3D_PLUGIN_MAJOR_VERSION $[word 1,$[P3D_PLUGIN_VERSION]]
-#defer P3D_PLUGIN_MINOR_VERSION $[word 2,$[P3D_PLUGIN_VERSION]]
-#defer P3D_PLUGIN_SEQUENCE_VERSION $[word 3,$[P3D_PLUGIN_VERSION]]
+#define PANDA_MAJOR_VERSION $[word 1,$[PANDA_VERSION]]
+#define PANDA_MINOR_VERSION $[word 2,$[PANDA_VERSION]]
+#define PANDA_SEQUENCE_VERSION $[word 3,$[PANDA_VERSION]]
+#define PANDA_VERSION_STR $[PANDA_MAJOR_VERSION].$[PANDA_MINOR_VERSION].$[PANDA_SEQUENCE_VERSION]$[if $[not $[PANDA_OFFICIAL_VERSION]],c]
+#define PANDA_VERSION_SYMBOL panda_version_$[PANDA_MAJOR_VERSION]_$[PANDA_MINOR_VERSION]_$[PANDA_SEQUENCE_VERSION]$[if $[not $[PANDA_OFFICIAL_VERSION]],c]
+
+// The panda version as a single number, with three digits reserved
+// for each component.
+#define PANDA_NUMERIC_VERSION $[+ $[* $[PANDA_MAJOR_VERSION],1000000],$[* $[PANDA_MINOR_VERSION],1000],$[PANDA_SEQUENCE_VERSION]]
+#if $[not $[PANDA_OFFICIAL_VERSION]]
+  // Subtract 1 if we are not an official version.
+  #define PANDA_NUMERIC_VERSION $[- $[PANDA_NUMERIC_VERSION],1]
+#endif
+
+#define P3D_PLUGIN_MAJOR_VERSION $[word 1,$[P3D_PLUGIN_VERSION]]
+#define P3D_PLUGIN_MINOR_VERSION $[word 2,$[P3D_PLUGIN_VERSION]]
+#define P3D_PLUGIN_SEQUENCE_VERSION $[word 3,$[P3D_PLUGIN_VERSION]]
 
 // What is the name of this source tree?
 #if $[eq $[PACKAGE],]

+ 1 - 1
dtool/src/dtoolutil/pandaVersion.h.pp

@@ -50,7 +50,7 @@ $[cdefine PANDA_OFFICIAL_VERSION]
 
 /* This is the panda numeric version as a single number, with three
    digits reserved for each component. */
-# define PANDA_VERSION $[+ $[* $[PANDA_MAJOR_VERSION],1000000],$[* $[PANDA_MINOR_VERSION],1000],$[PANDA_SEQUENCE_VERSION]]
+$[cdefine PANDA_NUMERIC_VERSION]
 
 /* This is the panda version expressed as a string.  It ends in the
    letter "c" if this is not an "official" version (e.g. it was checked