From 5008ca2aa85d38360da40cf906ef42cbeae06e55 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 14 Oct 2009 21:46:37 +0000 Subject: [PATCH] mo' better plugin versioning --- direct/src/plugin/p3dInstance.cxx | 13 ++++++++++++ direct/src/plugin_npapi/ppPandaObject.cxx | 10 ++++++++-- dtool/Package.pp | 24 +++++++++++++++-------- dtool/src/dtoolutil/pandaVersion.h.pp | 2 +- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/direct/src/plugin/p3dInstance.cxx b/direct/src/plugin/p3dInstance.cxx index b0031d7c68..8df74f8634 100644 --- a/direct/src/plugin/p3dInstance.cxx +++ b/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(); diff --git a/direct/src/plugin_npapi/ppPandaObject.cxx b/direct/src/plugin_npapi/ppPandaObject.cxx index 70787e21e4..6878fd4649 100644 --- a/direct/src/plugin_npapi/ppPandaObject.cxx +++ b/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. diff --git a/dtool/Package.pp b/dtool/Package.pp index 478652ad5c..a8a42a7e73 100644 --- a/dtool/Package.pp +++ b/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] +#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] -#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]] +// 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],] diff --git a/dtool/src/dtoolutil/pandaVersion.h.pp b/dtool/src/dtoolutil/pandaVersion.h.pp index e19509216c..5a12c230d1 100644 --- a/dtool/src/dtoolutil/pandaVersion.h.pp +++ b/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