From fad81481b408bb812c4e540ee6ae85894d84382f Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 5 Jan 2010 00:55:39 +0000 Subject: [PATCH] build p3dembed with ppremake system --- direct/src/ffi/Sources.pp | 1 + direct/src/p3d/DeploymentTools.py | 2 +- direct/src/plugin/Sources.pp | 62 ++- direct/src/plugin/load_plugin.cxx | 447 +++++++++--------- direct/src/plugin/load_plugin.h | 74 +-- direct/src/plugin/p3dWinSplashWindow.cxx | 4 +- direct/src/plugin/p3d_plugin_common.h | 4 +- direct/src/plugin_activex/PPBrowserObject.cpp | 2 +- .../src/plugin_activex/PPDownloadRequest.cpp | 2 +- direct/src/plugin_activex/PPInstance.cpp | 33 +- direct/src/plugin_activex/PPInstance.h | 10 +- direct/src/plugin_activex/PPInterface.cpp | 24 +- direct/src/plugin_npapi/ppBrowserObject.cxx | 2 +- direct/src/plugin_npapi/ppInstance.cxx | 67 +-- direct/src/plugin_standalone/Sources.pp | 30 ++ direct/src/plugin_standalone/p3dEmbed.cxx | 151 +++++- direct/src/plugin_standalone/panda3d.cxx | 16 +- direct/src/plugin_standalone/panda3d.rc.pp | 4 +- direct/src/plugin_standalone/panda3dBase.cxx | 140 +----- direct/src/plugin_standalone/panda3dBase.h | 1 - 20 files changed, 591 insertions(+), 485 deletions(-) diff --git a/direct/src/ffi/Sources.pp b/direct/src/ffi/Sources.pp index f66f402092..bca96a0b76 100644 --- a/direct/src/ffi/Sources.pp +++ b/direct/src/ffi/Sources.pp @@ -1,4 +1,5 @@ #define INSTALL_SCRIPTS genPyCode.py +#define INSTALL_MODULES panda3d.py // If we're on Win32 without Cygwin, install the genPyCode.bat file; // for all other platforms, install the genPyCode sh script. diff --git a/direct/src/p3d/DeploymentTools.py b/direct/src/p3d/DeploymentTools.py index c3c178dbd3..86bfdf6d51 100644 --- a/direct/src/p3d/DeploymentTools.py +++ b/direct/src/p3d/DeploymentTools.py @@ -27,7 +27,7 @@ class Standalone: hostDir = Filename(Filename.getTempDirectory(), 'pdeploy/') hostDir.makeDir() - self.host = HostInfo("http://runtime.panda3d.org/", hostDir = hostDir, asMirror = False, perPlatform = True) + self.host = HostInfo(PandaSystem.getPackageHostUrl(), hostDir = hostDir, asMirror = False, perPlatform = True) self.http = HTTPClient.getGlobalPtr() if not self.host.readContentsFile(): diff --git a/direct/src/plugin/Sources.pp b/direct/src/plugin/Sources.pp index 3a589143cc..06567e957d 100644 --- a/direct/src/plugin/Sources.pp +++ b/direct/src/plugin/Sources.pp @@ -13,24 +13,7 @@ // who are preparing a custom Panda3D package for download by the // plugin will need to build this. -#begin lib_target - -// -// p3d_plugin.dll, the main entry point to the Core API. -// - - #define BUILD_TARGET $[and $[HAVE_P3D_PLUGIN],$[HAVE_TINYXML],$[HAVE_OPENSSL],$[HAVE_ZLIB],$[HAVE_JPEG],$[HAVE_PNG]] - #define USE_PACKAGES tinyxml openssl zlib jpeg png x11 - #define TARGET p3d_plugin - #define LIB_PREFIX - - #define OTHER_LIBS \ - $[if $[OSX_PLATFORM],subprocbuffer] - - #define COMBINED_SOURCES \ - $[TARGET]_composite1.cxx - - #define SOURCES \ +#define COREAPI_SOURCES \ fileSpec.cxx fileSpec.h fileSpec.I \ find_root_dir.cxx find_root_dir.h \ $[if $[IS_OSX],find_root_dir_assist.mm] \ @@ -76,7 +59,7 @@ p3dWindowParams.h p3dWindowParams.I \ run_p3dpython.h - #define INCLUDED_SOURCES \ +#define COREAPI_INCLUDED_SOURCES \ p3d_plugin.cxx \ p3dAuthSession.cxx \ p3dBoolObject.cxx \ @@ -110,6 +93,25 @@ p3dX11SplashWindow.cxx \ p3dWindowParams.cxx +#begin lib_target + +// +// p3d_plugin.dll, the main entry point to the Core API. +// + + #define BUILD_TARGET $[and $[HAVE_P3D_PLUGIN],$[HAVE_TINYXML],$[HAVE_OPENSSL],$[HAVE_ZLIB],$[HAVE_JPEG],$[HAVE_PNG]] + #define USE_PACKAGES tinyxml openssl zlib jpeg png x11 + #define TARGET p3d_plugin + #define LIB_PREFIX + #define BUILDING_DLL BUILDING_P3D_PLUGIN + + #define OTHER_LIBS \ + $[if $[OSX_PLATFORM],subprocbuffer] + + #define COMBINED_SOURCES p3d_plugin_composite1.cxx + #define SOURCES $[COREAPI_SOURCES] + #define INCLUDED_SOURCES $[COREAPI_INCLUDED_SOURCES] + #define INSTALL_HEADERS \ p3d_plugin.h @@ -117,6 +119,28 @@ #end lib_target +#begin static_lib_target + +// +// libp3d_plugin_static.lib, the Core API as a static library (for p3dembed). +// + + #define BUILD_TARGET $[and $[HAVE_P3D_PLUGIN],$[HAVE_TINYXML],$[HAVE_OPENSSL],$[HAVE_ZLIB],$[HAVE_JPEG],$[HAVE_PNG]] + #define USE_PACKAGES tinyxml openssl zlib jpeg png x11 + #define TARGET p3d_plugin_static + #define BUILDING_DLL BUILDING_P3D_PLUGIN + + #define OTHER_LIBS \ + $[if $[OSX_PLATFORM],subprocbuffer] + + #define COMBINED_SOURCES p3d_plugin_composite1.cxx + #define SOURCES $[COREAPI_SOURCES] + #define INCLUDED_SOURCES $[COREAPI_INCLUDED_SOURCES] + + #define WIN_SYS_LIBS user32.lib gdi32.lib shell32.lib comctl32.lib msimg32.lib ole32.lib + +#end static_lib_target + #begin bin_target // diff --git a/direct/src/plugin/load_plugin.cxx b/direct/src/plugin/load_plugin.cxx index 49f450e8f8..34741a6343 100755 --- a/direct/src/plugin/load_plugin.cxx +++ b/direct/src/plugin/load_plugin.cxx @@ -34,45 +34,45 @@ static const string dll_ext = ".so"; static const string default_plugin_filename = "p3d_plugin"; -P3D_initialize_func *P3D_initialize; -P3D_finalize_func *P3D_finalize; -P3D_set_plugin_version_func *P3D_set_plugin_version; -P3D_set_super_mirror_func *P3D_set_super_mirror; -P3D_new_instance_func *P3D_new_instance; -P3D_instance_start_func *P3D_instance_start; -P3D_instance_start_stream_func *P3D_instance_start_stream; -P3D_instance_finish_func *P3D_instance_finish; -P3D_instance_setup_window_func *P3D_instance_setup_window; +P3D_initialize_func *P3D_initialize_ptr; +P3D_finalize_func *P3D_finalize_ptr; +P3D_set_plugin_version_func *P3D_set_plugin_version_ptr; +P3D_set_super_mirror_func *P3D_set_super_mirror_ptr; +P3D_new_instance_func *P3D_new_instance_ptr; +P3D_instance_start_func *P3D_instance_start_ptr; +P3D_instance_start_stream_func *P3D_instance_start_stream_ptr; +P3D_instance_finish_func *P3D_instance_finish_ptr; +P3D_instance_setup_window_func *P3D_instance_setup_window_ptr; -P3D_object_get_type_func *P3D_object_get_type; -P3D_object_get_bool_func *P3D_object_get_bool; -P3D_object_get_int_func *P3D_object_get_int; -P3D_object_get_float_func *P3D_object_get_float; -P3D_object_get_string_func *P3D_object_get_string; -P3D_object_get_repr_func *P3D_object_get_repr; -P3D_object_get_property_func *P3D_object_get_property; -P3D_object_set_property_func *P3D_object_set_property; -P3D_object_has_method_func *P3D_object_has_method; -P3D_object_call_func *P3D_object_call; -P3D_object_eval_func *P3D_object_eval; -P3D_object_incref_func *P3D_object_incref; -P3D_object_decref_func *P3D_object_decref; +P3D_object_get_type_func *P3D_object_get_type_ptr; +P3D_object_get_bool_func *P3D_object_get_bool_ptr; +P3D_object_get_int_func *P3D_object_get_int_ptr; +P3D_object_get_float_func *P3D_object_get_float_ptr; +P3D_object_get_string_func *P3D_object_get_string_ptr; +P3D_object_get_repr_func *P3D_object_get_repr_ptr; +P3D_object_get_property_func *P3D_object_get_property_ptr; +P3D_object_set_property_func *P3D_object_set_property_ptr; +P3D_object_has_method_func *P3D_object_has_method_ptr; +P3D_object_call_func *P3D_object_call_ptr; +P3D_object_eval_func *P3D_object_eval_ptr; +P3D_object_incref_func *P3D_object_incref_ptr; +P3D_object_decref_func *P3D_object_decref_ptr; -P3D_make_class_definition_func *P3D_make_class_definition; -P3D_new_undefined_object_func *P3D_new_undefined_object; -P3D_new_none_object_func *P3D_new_none_object; -P3D_new_bool_object_func *P3D_new_bool_object; -P3D_new_int_object_func *P3D_new_int_object; -P3D_new_float_object_func *P3D_new_float_object; -P3D_new_string_object_func *P3D_new_string_object; -P3D_instance_get_panda_script_object_func *P3D_instance_get_panda_script_object; -P3D_instance_set_browser_script_object_func *P3D_instance_set_browser_script_object; +P3D_make_class_definition_func *P3D_make_class_definition_ptr; +P3D_new_undefined_object_func *P3D_new_undefined_object_ptr; +P3D_new_none_object_func *P3D_new_none_object_ptr; +P3D_new_bool_object_func *P3D_new_bool_object_ptr; +P3D_new_int_object_func *P3D_new_int_object_ptr; +P3D_new_float_object_func *P3D_new_float_object_ptr; +P3D_new_string_object_func *P3D_new_string_object_ptr; +P3D_instance_get_panda_script_object_func *P3D_instance_get_panda_script_object_ptr; +P3D_instance_set_browser_script_object_func *P3D_instance_set_browser_script_object_ptr; -P3D_instance_get_request_func *P3D_instance_get_request; -P3D_check_request_func *P3D_check_request; -P3D_request_finish_func *P3D_request_finish; -P3D_instance_feed_url_stream_func *P3D_instance_feed_url_stream; -P3D_instance_handle_event_func *P3D_instance_handle_event; +P3D_instance_get_request_func *P3D_instance_get_request_ptr; +P3D_check_request_func *P3D_check_request_ptr; +P3D_request_finish_func *P3D_request_finish_ptr; +P3D_instance_feed_url_stream_func *P3D_instance_feed_url_stream_ptr; +P3D_instance_handle_event_func *P3D_instance_handle_event_ptr; #ifdef _WIN32 static HMODULE module = NULL; @@ -81,6 +81,7 @@ static void *module = NULL; #endif static bool plugin_loaded = false; +static bool dso_needs_unload = false; //////////////////////////////////////////////////////////////////// @@ -122,8 +123,14 @@ static void unload_dso(); // Function: load_plugin // Description: Loads the plugin and assigns all of the function // pointers. Returns true on success, false on failure. -// If the filename is empty, it is searched along the -// path. +// If load_plugin() has already been called +// successfully, this returns true immediately, without +// parsing any parameters. +// +// If p3d_plugin_filename is empty, the module is +// assumed to be already loaded (or statically linked +// in), and the symbols are located within the current +// address space. //////////////////////////////////////////////////////////////////// bool load_plugin(const string &p3d_plugin_filename, @@ -131,33 +138,39 @@ load_plugin(const string &p3d_plugin_filename, bool verify_contents, const string &platform, const string &log_directory, const string &log_basename, bool trusted_environment, bool console_environment, - ostream &logfile) { - string filename = p3d_plugin_filename; - if (filename.empty()) { - // Look for the plugin along the path. - filename = get_plugin_basename(); - } - + const string &root_dir, ostream &logfile) { if (plugin_loaded) { return true; } + string filename = p3d_plugin_filename; #ifdef _WIN32 assert(module == NULL); - - // On Windows, the filename passed to LoadLibrary() must have an - // extension, or a default ".DLL" will be implicitly added. If the - // file actually has no extension, we must add "." to avoid this. - // Check whether the filename has an extension. - size_t extension_dot = find_extension_dot(filename); - if (extension_dot == string::npos) { - // No extension. - filename += "."; + if (filename.empty()) { + // If no filename is supplied, look within our existing address space. + module = GetModuleHandle(NULL); + dso_needs_unload = false; + + } else { + // If a filename is supplied, attempt to load it as a dynamic library. + + // On Windows, the filename passed to LoadLibrary() must have an + // extension, or a default ".DLL" will be implicitly added. If the + // file actually has no extension, we must add "." to avoid this. + + // Check whether the filename has an extension. + size_t extension_dot = find_extension_dot(filename); + if (extension_dot == string::npos) { + // No extension. + filename += "."; + } + + SetErrorMode(0); + module = LoadLibrary(filename.c_str()); + dso_needs_unload = true; } - SetErrorMode(0); - module = LoadLibrary(filename.c_str()); if (module == NULL) { // Couldn't load the DLL. logfile @@ -171,7 +184,11 @@ load_plugin(const string &p3d_plugin_filename, #else // _WIN32 // Posix case. assert(module == NULL); - module = dlopen(filename.c_str(), RTLD_LAZY | RTLD_LOCAL); + if (filename.empty()) { + module = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL); + } else { + module = dlopen(filename.c_str(), RTLD_LAZY | RTLD_LOCAL); + } if (module == NULL) { // Couldn't load the .so. const char *message = dlerror(); @@ -182,135 +199,136 @@ load_plugin(const string &p3d_plugin_filename, return false; } + dso_needs_unload = true; #define get_func dlsym #endif // _WIN32 // Now get all of the function pointers. - P3D_initialize = (P3D_initialize_func *)get_func(module, "P3D_initialize"); - P3D_finalize = (P3D_finalize_func *)get_func(module, "P3D_finalize"); - P3D_set_plugin_version = (P3D_set_plugin_version_func *)get_func(module, "P3D_set_plugin_version"); - P3D_set_super_mirror = (P3D_set_super_mirror_func *)get_func(module, "P3D_set_super_mirror"); - P3D_new_instance = (P3D_new_instance_func *)get_func(module, "P3D_new_instance"); - P3D_instance_start = (P3D_instance_start_func *)get_func(module, "P3D_instance_start"); - P3D_instance_start_stream = (P3D_instance_start_stream_func *)get_func(module, "P3D_instance_start_stream"); - P3D_instance_finish = (P3D_instance_finish_func *)get_func(module, "P3D_instance_finish"); - P3D_instance_setup_window = (P3D_instance_setup_window_func *)get_func(module, "P3D_instance_setup_window"); + P3D_initialize_ptr = (P3D_initialize_func *)get_func(module, "P3D_initialize"); + P3D_finalize_ptr = (P3D_finalize_func *)get_func(module, "P3D_finalize"); + P3D_set_plugin_version_ptr = (P3D_set_plugin_version_func *)get_func(module, "P3D_set_plugin_version"); + P3D_set_super_mirror_ptr = (P3D_set_super_mirror_func *)get_func(module, "P3D_set_super_mirror"); + P3D_new_instance_ptr = (P3D_new_instance_func *)get_func(module, "P3D_new_instance"); + P3D_instance_start_ptr = (P3D_instance_start_func *)get_func(module, "P3D_instance_start"); + P3D_instance_start_stream_ptr = (P3D_instance_start_stream_func *)get_func(module, "P3D_instance_start_stream"); + P3D_instance_finish_ptr = (P3D_instance_finish_func *)get_func(module, "P3D_instance_finish"); + P3D_instance_setup_window_ptr = (P3D_instance_setup_window_func *)get_func(module, "P3D_instance_setup_window"); - P3D_object_get_type = (P3D_object_get_type_func *)get_func(module, "P3D_object_get_type"); - P3D_object_get_bool = (P3D_object_get_bool_func *)get_func(module, "P3D_object_get_bool"); - P3D_object_get_int = (P3D_object_get_int_func *)get_func(module, "P3D_object_get_int"); - P3D_object_get_float = (P3D_object_get_float_func *)get_func(module, "P3D_object_get_float"); - P3D_object_get_string = (P3D_object_get_string_func *)get_func(module, "P3D_object_get_string"); - P3D_object_get_repr = (P3D_object_get_repr_func *)get_func(module, "P3D_object_get_repr"); - P3D_object_get_property = (P3D_object_get_property_func *)get_func(module, "P3D_object_get_property"); - P3D_object_set_property = (P3D_object_set_property_func *)get_func(module, "P3D_object_set_property"); - P3D_object_has_method = (P3D_object_has_method_func *)get_func(module, "P3D_object_has_method"); - P3D_object_call = (P3D_object_call_func *)get_func(module, "P3D_object_call"); - P3D_object_eval = (P3D_object_eval_func *)get_func(module, "P3D_object_eval"); - P3D_object_incref = (P3D_object_incref_func *)get_func(module, "P3D_object_incref"); - P3D_object_decref = (P3D_object_decref_func *)get_func(module, "P3D_object_decref"); - P3D_make_class_definition = (P3D_make_class_definition_func *)get_func(module, "P3D_make_class_definition"); - P3D_new_undefined_object = (P3D_new_undefined_object_func *)get_func(module, "P3D_new_undefined_object"); - P3D_new_none_object = (P3D_new_none_object_func *)get_func(module, "P3D_new_none_object"); - P3D_new_bool_object = (P3D_new_bool_object_func *)get_func(module, "P3D_new_bool_object"); - P3D_new_int_object = (P3D_new_int_object_func *)get_func(module, "P3D_new_int_object"); - P3D_new_float_object = (P3D_new_float_object_func *)get_func(module, "P3D_new_float_object"); - P3D_new_string_object = (P3D_new_string_object_func *)get_func(module, "P3D_new_string_object"); - P3D_instance_get_panda_script_object = (P3D_instance_get_panda_script_object_func *)get_func(module, "P3D_instance_get_panda_script_object"); - P3D_instance_set_browser_script_object = (P3D_instance_set_browser_script_object_func *)get_func(module, "P3D_instance_set_browser_script_object"); + P3D_object_get_type_ptr = (P3D_object_get_type_func *)get_func(module, "P3D_object_get_type"); + P3D_object_get_bool_ptr = (P3D_object_get_bool_func *)get_func(module, "P3D_object_get_bool"); + P3D_object_get_int_ptr = (P3D_object_get_int_func *)get_func(module, "P3D_object_get_int"); + P3D_object_get_float_ptr = (P3D_object_get_float_func *)get_func(module, "P3D_object_get_float"); + P3D_object_get_string_ptr = (P3D_object_get_string_func *)get_func(module, "P3D_object_get_string"); + P3D_object_get_repr_ptr = (P3D_object_get_repr_func *)get_func(module, "P3D_object_get_repr"); + P3D_object_get_property_ptr = (P3D_object_get_property_func *)get_func(module, "P3D_object_get_property"); + P3D_object_set_property_ptr = (P3D_object_set_property_func *)get_func(module, "P3D_object_set_property"); + P3D_object_has_method_ptr = (P3D_object_has_method_func *)get_func(module, "P3D_object_has_method"); + P3D_object_call_ptr = (P3D_object_call_func *)get_func(module, "P3D_object_call"); + P3D_object_eval_ptr = (P3D_object_eval_func *)get_func(module, "P3D_object_eval"); + P3D_object_incref_ptr = (P3D_object_incref_func *)get_func(module, "P3D_object_incref"); + P3D_object_decref_ptr = (P3D_object_decref_func *)get_func(module, "P3D_object_decref"); + P3D_make_class_definition_ptr = (P3D_make_class_definition_func *)get_func(module, "P3D_make_class_definition"); + P3D_new_undefined_object_ptr = (P3D_new_undefined_object_func *)get_func(module, "P3D_new_undefined_object"); + P3D_new_none_object_ptr = (P3D_new_none_object_func *)get_func(module, "P3D_new_none_object"); + P3D_new_bool_object_ptr = (P3D_new_bool_object_func *)get_func(module, "P3D_new_bool_object"); + P3D_new_int_object_ptr = (P3D_new_int_object_func *)get_func(module, "P3D_new_int_object"); + P3D_new_float_object_ptr = (P3D_new_float_object_func *)get_func(module, "P3D_new_float_object"); + P3D_new_string_object_ptr = (P3D_new_string_object_func *)get_func(module, "P3D_new_string_object"); + P3D_instance_get_panda_script_object_ptr = (P3D_instance_get_panda_script_object_func *)get_func(module, "P3D_instance_get_panda_script_object"); + P3D_instance_set_browser_script_object_ptr = (P3D_instance_set_browser_script_object_func *)get_func(module, "P3D_instance_set_browser_script_object"); - P3D_instance_get_request = (P3D_instance_get_request_func *)get_func(module, "P3D_instance_get_request"); - P3D_check_request = (P3D_check_request_func *)get_func(module, "P3D_check_request"); - P3D_request_finish = (P3D_request_finish_func *)get_func(module, "P3D_request_finish"); - P3D_instance_feed_url_stream = (P3D_instance_feed_url_stream_func *)get_func(module, "P3D_instance_feed_url_stream"); - P3D_instance_handle_event = (P3D_instance_handle_event_func *)get_func(module, "P3D_instance_handle_event"); + P3D_instance_get_request_ptr = (P3D_instance_get_request_func *)get_func(module, "P3D_instance_get_request"); + P3D_check_request_ptr = (P3D_check_request_func *)get_func(module, "P3D_check_request"); + P3D_request_finish_ptr = (P3D_request_finish_func *)get_func(module, "P3D_request_finish"); + P3D_instance_feed_url_stream_ptr = (P3D_instance_feed_url_stream_func *)get_func(module, "P3D_instance_feed_url_stream"); + P3D_instance_handle_event_ptr = (P3D_instance_handle_event_func *)get_func(module, "P3D_instance_handle_event"); #undef get_func // Ensure that all of the function pointers have been found. - if (P3D_initialize == NULL || - P3D_finalize == NULL || - P3D_set_plugin_version == NULL || - P3D_set_super_mirror == NULL || - P3D_new_instance == NULL || - P3D_instance_start == NULL || - P3D_instance_start_stream == NULL || - P3D_instance_finish == NULL || - P3D_instance_setup_window == NULL || + if (P3D_initialize_ptr == NULL || + P3D_finalize_ptr == NULL || + P3D_set_plugin_version_ptr == NULL || + P3D_set_super_mirror_ptr == NULL || + P3D_new_instance_ptr == NULL || + P3D_instance_start_ptr == NULL || + P3D_instance_start_stream_ptr == NULL || + P3D_instance_finish_ptr == NULL || + P3D_instance_setup_window_ptr == NULL || - P3D_object_get_type == NULL || - P3D_object_get_bool == NULL || - P3D_object_get_int == NULL || - P3D_object_get_float == NULL || - P3D_object_get_string == NULL || - P3D_object_get_repr == NULL || - P3D_object_get_property == NULL || - P3D_object_set_property == NULL || - P3D_object_has_method == NULL || - P3D_object_call == NULL || - P3D_object_eval == NULL || - P3D_object_incref == NULL || - P3D_object_decref == NULL || + P3D_object_get_type_ptr == NULL || + P3D_object_get_bool_ptr == NULL || + P3D_object_get_int_ptr == NULL || + P3D_object_get_float_ptr == NULL || + P3D_object_get_string_ptr == NULL || + P3D_object_get_repr_ptr == NULL || + P3D_object_get_property_ptr == NULL || + P3D_object_set_property_ptr == NULL || + P3D_object_has_method_ptr == NULL || + P3D_object_call_ptr == NULL || + P3D_object_eval_ptr == NULL || + P3D_object_incref_ptr == NULL || + P3D_object_decref_ptr == NULL || - P3D_make_class_definition == NULL || - P3D_new_undefined_object == NULL || - P3D_new_none_object == NULL || - P3D_new_bool_object == NULL || - P3D_new_int_object == NULL || - P3D_new_float_object == NULL || - P3D_new_string_object == NULL || - P3D_instance_get_panda_script_object == NULL || - P3D_instance_set_browser_script_object == NULL || + P3D_make_class_definition_ptr == NULL || + P3D_new_undefined_object_ptr == NULL || + P3D_new_none_object_ptr == NULL || + P3D_new_bool_object_ptr == NULL || + P3D_new_int_object_ptr == NULL || + P3D_new_float_object_ptr == NULL || + P3D_new_string_object_ptr == NULL || + P3D_instance_get_panda_script_object_ptr == NULL || + P3D_instance_set_browser_script_object_ptr == NULL || - P3D_instance_get_request == NULL || - P3D_check_request == NULL || - P3D_request_finish == NULL || - P3D_instance_feed_url_stream == NULL || - P3D_instance_handle_event == NULL) { + P3D_instance_get_request_ptr == NULL || + P3D_check_request_ptr == NULL || + P3D_request_finish_ptr == NULL || + P3D_instance_feed_url_stream_ptr == NULL || + P3D_instance_handle_event_ptr == NULL) { logfile << "Some function pointers not found:" - << "\nP3D_initialize = " << P3D_initialize - << "\nP3D_finalize = " << P3D_finalize - << "\nP3D_set_plugin_version = " << P3D_set_plugin_version - << "\nP3D_set_super_mirror = " << P3D_set_super_mirror - << "\nP3D_new_instance = " << P3D_new_instance - << "\nP3D_instance_start = " << P3D_instance_start - << "\nP3D_instance_start_stream = " << P3D_instance_start_stream - << "\nP3D_instance_finish = " << P3D_instance_finish - << "\nP3D_instance_setup_window = " << P3D_instance_setup_window - - << "\nP3D_object_get_type = " << P3D_object_get_type - << "\nP3D_object_get_bool = " << P3D_object_get_bool - << "\nP3D_object_get_int = " << P3D_object_get_int - << "\nP3D_object_get_float = " << P3D_object_get_float - << "\nP3D_object_get_string = " << P3D_object_get_string - << "\nP3D_object_get_repr = " << P3D_object_get_repr - << "\nP3D_object_get_property = " << P3D_object_get_property - << "\nP3D_object_set_property = " << P3D_object_set_property - << "\nP3D_object_has_method = " << P3D_object_has_method - << "\nP3D_object_call = " << P3D_object_call - << "\nP3D_object_eval = " << P3D_object_eval - << "\nP3D_object_incref = " << P3D_object_incref - << "\nP3D_object_decref = " << P3D_object_decref + << "\nP3D_initialize_ptr = " << P3D_initialize_ptr + << "\nP3D_finalize_ptr = " << P3D_finalize_ptr + << "\nP3D_set_plugin_version_ptr = " << P3D_set_plugin_version_ptr + << "\nP3D_set_super_mirror_ptr = " << P3D_set_super_mirror_ptr + << "\nP3D_new_instance_ptr = " << P3D_new_instance_ptr + << "\nP3D_instance_start_ptr = " << P3D_instance_start_ptr + << "\nP3D_instance_start_stream_ptr = " << P3D_instance_start_stream_ptr + << "\nP3D_instance_finish_ptr = " << P3D_instance_finish_ptr + << "\nP3D_instance_setup_window_ptr = " << P3D_instance_setup_window_ptr - << "\nP3D_make_class_definition = " << P3D_make_class_definition - << "\nP3D_new_undefined_object = " << P3D_new_undefined_object - << "\nP3D_new_none_object = " << P3D_new_none_object - << "\nP3D_new_bool_object = " << P3D_new_bool_object - << "\nP3D_new_int_object = " << P3D_new_int_object - << "\nP3D_new_float_object = " << P3D_new_float_object - << "\nP3D_new_string_object = " << P3D_new_string_object - << "\nP3D_instance_get_panda_script_object = " << P3D_instance_get_panda_script_object - << "\nP3D_instance_set_browser_script_object = " << P3D_instance_set_browser_script_object - - << "\nP3D_instance_get_request = " << P3D_instance_get_request - << "\nP3D_check_request = " << P3D_check_request - << "\nP3D_request_finish = " << P3D_request_finish - << "\nP3D_instance_feed_url_stream = " << P3D_instance_feed_url_stream - << "\nP3D_instance_handle_event = " << P3D_instance_handle_event + << "\nP3D_object_get_type_ptr = " << P3D_object_get_type_ptr + << "\nP3D_object_get_bool_ptr = " << P3D_object_get_bool_ptr + << "\nP3D_object_get_int_ptr = " << P3D_object_get_int_ptr + << "\nP3D_object_get_float_ptr = " << P3D_object_get_float_ptr + << "\nP3D_object_get_string_ptr = " << P3D_object_get_string_ptr + << "\nP3D_object_get_repr_ptr = " << P3D_object_get_repr_ptr + << "\nP3D_object_get_property_ptr = " << P3D_object_get_property_ptr + << "\nP3D_object_set_property_ptr = " << P3D_object_set_property_ptr + << "\nP3D_object_has_method_ptr = " << P3D_object_has_method_ptr + << "\nP3D_object_call_ptr = " << P3D_object_call_ptr + << "\nP3D_object_eval_ptr = " << P3D_object_eval_ptr + << "\nP3D_object_incref_ptr = " << P3D_object_incref_ptr + << "\nP3D_object_decref_ptr = " << P3D_object_decref_ptr + + << "\nP3D_make_class_definition_ptr = " << P3D_make_class_definition_ptr + << "\nP3D_new_undefined_object_ptr = " << P3D_new_undefined_object_ptr + << "\nP3D_new_none_object_ptr = " << P3D_new_none_object_ptr + << "\nP3D_new_bool_object_ptr = " << P3D_new_bool_object_ptr + << "\nP3D_new_int_object_ptr = " << P3D_new_int_object_ptr + << "\nP3D_new_float_object_ptr = " << P3D_new_float_object_ptr + << "\nP3D_new_string_object_ptr = " << P3D_new_string_object_ptr + << "\nP3D_instance_get_panda_script_object_ptr = " << P3D_instance_get_panda_script_object_ptr + << "\nP3D_instance_set_browser_script_object_ptr = " << P3D_instance_set_browser_script_object_ptr + + << "\nP3D_instance_get_request_ptr = " << P3D_instance_get_request_ptr + << "\nP3D_check_request_ptr = " << P3D_check_request_ptr + << "\nP3D_request_finish_ptr = " << P3D_request_finish_ptr + << "\nP3D_instance_feed_url_stream_ptr = " << P3D_instance_feed_url_stream_ptr + << "\nP3D_instance_handle_event_ptr = " << P3D_instance_handle_event_ptr << "\n"; unload_dso(); return false; @@ -319,10 +337,11 @@ load_plugin(const string &p3d_plugin_filename, // Successfully loaded. plugin_loaded = true; - if (!P3D_initialize(P3D_API_VERSION, contents_filename.c_str(), - host_url.c_str(), verify_contents, platform.c_str(), - log_directory.c_str(), log_basename.c_str(), - trusted_environment, console_environment, NULL)) { + if (!P3D_initialize_ptr(P3D_API_VERSION, contents_filename.c_str(), + host_url.c_str(), verify_contents, platform.c_str(), + log_directory.c_str(), log_basename.c_str(), + trusted_environment, console_environment, + root_dir.c_str())) { // Oops, failure to initialize. logfile << "Failed to initialize plugin (passed API version " @@ -345,7 +364,7 @@ unload_plugin() { return; } - P3D_finalize(); + P3D_finalize_ptr(); unload_dso(); } @@ -361,55 +380,55 @@ unload_plugin() { //////////////////////////////////////////////////////////////////// static void unload_dso() { + if (dso_needs_unload) { + assert(module != NULL); #ifdef _WIN32 - assert(module != NULL); - FreeLibrary(module); - module = NULL; + FreeLibrary(module); #else - assert(module != NULL); - dlclose(module); - module = NULL; + dlclose(module); #endif + module = NULL; + } - P3D_initialize = NULL; - P3D_finalize = NULL; - P3D_set_plugin_version = NULL; - P3D_set_super_mirror = NULL; - P3D_new_instance = NULL; - P3D_instance_start = NULL; - P3D_instance_start_stream = NULL; - P3D_instance_finish = NULL; - P3D_instance_setup_window = NULL; + P3D_initialize_ptr = NULL; + P3D_finalize_ptr = NULL; + P3D_set_plugin_version_ptr = NULL; + P3D_set_super_mirror_ptr = NULL; + P3D_new_instance_ptr = NULL; + P3D_instance_start_ptr = NULL; + P3D_instance_start_stream_ptr = NULL; + P3D_instance_finish_ptr = NULL; + P3D_instance_setup_window_ptr = NULL; - P3D_object_get_type = NULL; - P3D_object_get_bool = NULL; - P3D_object_get_int = NULL; - P3D_object_get_float = NULL; - P3D_object_get_string = NULL; - P3D_object_get_repr = NULL; - P3D_object_get_property = NULL; - P3D_object_set_property = NULL; - P3D_object_has_method = NULL; - P3D_object_call = NULL; - P3D_object_eval = NULL; - P3D_object_incref = NULL; - P3D_object_decref = NULL; + P3D_object_get_type_ptr = NULL; + P3D_object_get_bool_ptr = NULL; + P3D_object_get_int_ptr = NULL; + P3D_object_get_float_ptr = NULL; + P3D_object_get_string_ptr = NULL; + P3D_object_get_repr_ptr = NULL; + P3D_object_get_property_ptr = NULL; + P3D_object_set_property_ptr = NULL; + P3D_object_has_method_ptr = NULL; + P3D_object_call_ptr = NULL; + P3D_object_eval_ptr = NULL; + P3D_object_incref_ptr = NULL; + P3D_object_decref_ptr = NULL; - P3D_make_class_definition = NULL; - P3D_new_undefined_object = NULL; - P3D_new_none_object = NULL; - P3D_new_bool_object = NULL; - P3D_new_int_object = NULL; - P3D_new_float_object = NULL; - P3D_new_string_object = NULL; - P3D_instance_get_panda_script_object = NULL; - P3D_instance_set_browser_script_object = NULL; + P3D_make_class_definition_ptr = NULL; + P3D_new_undefined_object_ptr = NULL; + P3D_new_none_object_ptr = NULL; + P3D_new_bool_object_ptr = NULL; + P3D_new_int_object_ptr = NULL; + P3D_new_float_object_ptr = NULL; + P3D_new_string_object_ptr = NULL; + P3D_instance_get_panda_script_object_ptr = NULL; + P3D_instance_set_browser_script_object_ptr = NULL; - P3D_instance_get_request = NULL; - P3D_check_request = NULL; - P3D_request_finish = NULL; - P3D_instance_feed_url_stream = NULL; - P3D_instance_handle_event = NULL; + P3D_instance_get_request_ptr = NULL; + P3D_check_request_ptr = NULL; + P3D_request_finish_ptr = NULL; + P3D_instance_feed_url_stream_ptr = NULL; + P3D_instance_handle_event_ptr = NULL; plugin_loaded = false; } diff --git a/direct/src/plugin/load_plugin.h b/direct/src/plugin/load_plugin.h index 8368687b82..d840753505 100755 --- a/direct/src/plugin/load_plugin.h +++ b/direct/src/plugin/load_plugin.h @@ -20,45 +20,45 @@ #include using namespace std; -extern P3D_initialize_func *P3D_initialize; -extern P3D_finalize_func *P3D_finalize; -extern P3D_set_plugin_version_func *P3D_set_plugin_version; -extern P3D_set_super_mirror_func *P3D_set_super_mirror; -extern P3D_new_instance_func *P3D_new_instance; -extern P3D_instance_start_func *P3D_instance_start; -extern P3D_instance_start_stream_func *P3D_instance_start_stream; -extern P3D_instance_finish_func *P3D_instance_finish; -extern P3D_instance_setup_window_func *P3D_instance_setup_window; +extern P3D_initialize_func *P3D_initialize_ptr; +extern P3D_finalize_func *P3D_finalize_ptr; +extern P3D_set_plugin_version_func *P3D_set_plugin_version_ptr; +extern P3D_set_super_mirror_func *P3D_set_super_mirror_ptr; +extern P3D_new_instance_func *P3D_new_instance_ptr; +extern P3D_instance_start_func *P3D_instance_start_ptr; +extern P3D_instance_start_stream_func *P3D_instance_start_stream_ptr; +extern P3D_instance_finish_func *P3D_instance_finish_ptr; +extern P3D_instance_setup_window_func *P3D_instance_setup_window_ptr; -extern P3D_object_get_type_func *P3D_object_get_type; -extern P3D_object_get_bool_func *P3D_object_get_bool; -extern P3D_object_get_int_func *P3D_object_get_int; -extern P3D_object_get_float_func *P3D_object_get_float; -extern P3D_object_get_string_func *P3D_object_get_string; -extern P3D_object_get_repr_func *P3D_object_get_repr; -extern P3D_object_get_property_func *P3D_object_get_property; -extern P3D_object_set_property_func *P3D_object_set_property; -extern P3D_object_has_method_func *P3D_object_has_method; -extern P3D_object_call_func *P3D_object_call; -extern P3D_object_eval_func *P3D_object_eval; -extern P3D_object_incref_func *P3D_object_incref; -extern P3D_object_decref_func *P3D_object_decref; +extern P3D_object_get_type_func *P3D_object_get_type_ptr; +extern P3D_object_get_bool_func *P3D_object_get_bool_ptr; +extern P3D_object_get_int_func *P3D_object_get_int_ptr; +extern P3D_object_get_float_func *P3D_object_get_float_ptr; +extern P3D_object_get_string_func *P3D_object_get_string_ptr; +extern P3D_object_get_repr_func *P3D_object_get_repr_ptr; +extern P3D_object_get_property_func *P3D_object_get_property_ptr; +extern P3D_object_set_property_func *P3D_object_set_property_ptr; +extern P3D_object_has_method_func *P3D_object_has_method_ptr; +extern P3D_object_call_func *P3D_object_call_ptr; +extern P3D_object_eval_func *P3D_object_eval_ptr; +extern P3D_object_incref_func *P3D_object_incref_ptr; +extern P3D_object_decref_func *P3D_object_decref_ptr; -extern P3D_make_class_definition_func *P3D_make_class_definition; -extern P3D_new_undefined_object_func *P3D_new_undefined_object; -extern P3D_new_none_object_func *P3D_new_none_object; -extern P3D_new_bool_object_func *P3D_new_bool_object; -extern P3D_new_int_object_func *P3D_new_int_object; -extern P3D_new_float_object_func *P3D_new_float_object; -extern P3D_new_string_object_func *P3D_new_string_object; -extern P3D_instance_get_panda_script_object_func *P3D_instance_get_panda_script_object; -extern P3D_instance_set_browser_script_object_func *P3D_instance_set_browser_script_object; +extern P3D_make_class_definition_func *P3D_make_class_definition_ptr; +extern P3D_new_undefined_object_func *P3D_new_undefined_object_ptr; +extern P3D_new_none_object_func *P3D_new_none_object_ptr; +extern P3D_new_bool_object_func *P3D_new_bool_object_ptr; +extern P3D_new_int_object_func *P3D_new_int_object_ptr; +extern P3D_new_float_object_func *P3D_new_float_object_ptr; +extern P3D_new_string_object_func *P3D_new_string_object_ptr; +extern P3D_instance_get_panda_script_object_func *P3D_instance_get_panda_script_object_ptr; +extern P3D_instance_set_browser_script_object_func *P3D_instance_set_browser_script_object_ptr; -extern P3D_instance_get_request_func *P3D_instance_get_request; -extern P3D_check_request_func *P3D_check_request; -extern P3D_request_finish_func *P3D_request_finish; -extern P3D_instance_feed_url_stream_func *P3D_instance_feed_url_stream; -extern P3D_instance_handle_event_func *P3D_instance_handle_event; +extern P3D_instance_get_request_func *P3D_instance_get_request_ptr; +extern P3D_check_request_func *P3D_check_request_ptr; +extern P3D_request_finish_func *P3D_request_finish_ptr; +extern P3D_instance_feed_url_stream_func *P3D_instance_feed_url_stream_ptr; +extern P3D_instance_handle_event_func *P3D_instance_handle_event_ptr; string get_plugin_basename(); bool @@ -67,7 +67,7 @@ load_plugin(const string &p3d_plugin_filename, bool verify_contents, const string &platform, const string &log_directory, const string &log_basename, bool trusted_environment, bool console_environment, - ostream &logfile); + const string &root_dir, ostream &logfile); void unload_plugin(); bool is_plugin_loaded(); diff --git a/direct/src/plugin/p3dWinSplashWindow.cxx b/direct/src/plugin/p3dWinSplashWindow.cxx index 5acdb39331..359b63f4ea 100755 --- a/direct/src/plugin/p3dWinSplashWindow.cxx +++ b/direct/src/plugin/p3dWinSplashWindow.cxx @@ -445,8 +445,8 @@ make_window() { int y = _wparams.get_win_y(); if (x == -1) x = CW_USEDEFAULT; if (y == -1) y = CW_USEDEFAULT; - if (x == -2) x = (int)(0.5 * (GetSystemMetrics(SM_CXBORDER) - width)); - if (y == -2) y = (int)(0.5 * (GetSystemMetrics(SM_CYBORDER) - height)); + if (x == -2) x = (int)(0.5 * (GetSystemMetrics(SM_CXSCREEN) - width)); + if (y == -2) y = (int)(0.5 * (GetSystemMetrics(SM_CYSCREEN) - height)); if (_wparams.get_window_type() == P3D_WT_embedded) { // Create an embedded window. diff --git a/direct/src/plugin/p3d_plugin_common.h b/direct/src/plugin/p3d_plugin_common.h index f7219aa4b1..f05c346ae4 100644 --- a/direct/src/plugin/p3d_plugin_common.h +++ b/direct/src/plugin/p3d_plugin_common.h @@ -16,11 +16,11 @@ #define P3D_PLUGIN_COMMON // This header file is included by all C++ files in this directory -// that contribute to p3d_plugin; provides some common symbol +// that contribute to p3d_plugin; it provides some common symbol // declarations. #define P3D_FUNCTION_PROTOTYPES -#define BUILDING_P3D_PLUGIN +//#define BUILDING_P3D_PLUGIN #define TIXML_USE_STL // It's a good idea to pick up this header file, even though we don't diff --git a/direct/src/plugin_activex/PPBrowserObject.cpp b/direct/src/plugin_activex/PPBrowserObject.cpp index 53afc8dfac..f2ac8f8a4e 100644 --- a/direct/src/plugin_activex/PPBrowserObject.cpp +++ b/direct/src/plugin_activex/PPBrowserObject.cpp @@ -195,7 +195,7 @@ P3D_class_definition* PPBrowserObject::get_class_definition() { // Create a default class_definition object, and fill in the // appropriate pointers. - _browser_object_class = P3D_make_class_definition(); + _browser_object_class = P3D_make_class_definition_ptr(); _browser_object_class->_finish = &object_finish; _browser_object_class->_get_repr = &object_get_repr; diff --git a/direct/src/plugin_activex/PPDownloadRequest.cpp b/direct/src/plugin_activex/PPDownloadRequest.cpp index e5166b4a50..12fafe5751 100644 --- a/direct/src/plugin_activex/PPDownloadRequest.cpp +++ b/direct/src/plugin_activex/PPDownloadRequest.cpp @@ -38,7 +38,7 @@ bool PPDownloadRequest::DataNotify( size_t expectedDataSize, const void* data, s { if ( m_p3dRequest ) { - ret = P3D_instance_feed_url_stream( m_p3dRequest->_instance, + ret = P3D_instance_feed_url_stream_ptr( m_p3dRequest->_instance, m_p3dRequest->_request._get_url._unique_id, P3D_RC_in_progress, 0, diff --git a/direct/src/plugin_activex/PPInstance.cpp b/direct/src/plugin_activex/PPInstance.cpp index 06e0a565d3..843d7dd436 100644 --- a/direct/src/plugin_activex/PPInstance.cpp +++ b/direct/src/plugin_activex/PPInstance.cpp @@ -50,7 +50,7 @@ static int s_instanceCount = 0; -void P3D_NofificationSync(P3D_instance *instance) +void P3D_NotificationSync(P3D_instance *instance) { static bool handleRequestOnUIThread = true; if ( instance ) @@ -91,7 +91,7 @@ PPInstance::~PPInstance( ) { if ( m_p3dInstance ) { - P3D_instance_finish( m_p3dInstance ); + P3D_instance_finish_ptr( m_p3dInstance ); m_p3dInstance = NULL; } if ( m_p3dObject ) @@ -449,7 +449,8 @@ int PPInstance::LoadPlugin( const std::string& dllFilename ) #endif // P3D_PLUGIN_P3D_PLUGIN nout << "Attempting to load core API from " << pathname << "\n"; - if (!load_plugin(pathname, "", "", true, "", "", "", false, false, nout)) { + if (!load_plugin(pathname, "", "", true, "", "", "", false, false, + m_rootDir, nout)) { nout << "Unable to launch core API in " << pathname << "\n"; error = 1; } else { @@ -458,7 +459,7 @@ int PPInstance::LoadPlugin( const std::string& dllFilename ) #else static const bool official = false; #endif - P3D_set_plugin_version(P3D_PLUGIN_MAJOR_VERSION, P3D_PLUGIN_MINOR_VERSION, + P3D_set_plugin_version_ptr(P3D_PLUGIN_MAJOR_VERSION, P3D_PLUGIN_MINOR_VERSION, P3D_PLUGIN_SEQUENCE_VERSION, official, PANDA_DISTRIBUTOR, PANDA_PACKAGE_HOST_URL, _core_api_dll.get_timestamp()); @@ -530,7 +531,7 @@ int PPInstance::Start( const std::string& p3dFilename ) p3dTokens[i]._value = strdup( m_parentCtrl.m_parameters[ i ].second ); } nout << "Creating new P3D instance object \n"; - m_p3dInstance = P3D_new_instance( &P3D_NofificationSync, p3dTokens, m_parentCtrl.m_parameters.size(), 0, NULL, (void*)&m_parentCtrl ); + m_p3dInstance = P3D_new_instance_ptr( &P3D_NotificationSync, p3dTokens, m_parentCtrl.m_parameters.size(), 0, NULL, (void*)&m_parentCtrl ); for ( UINT j = 0; j < m_parentCtrl.m_parameters.size(); j++ ) { @@ -546,17 +547,17 @@ int PPInstance::Start( const std::string& p3dFilename ) } CComPtr pDispatch; PPBrowserObject *pobj = new PPBrowserObject( &m_parentCtrl, pDispatch ); - P3D_instance_set_browser_script_object( m_p3dInstance, pobj ); + P3D_instance_set_browser_script_object_ptr( m_p3dInstance, pobj ); P3D_OBJECT_DECREF( pobj ); - m_p3dObject = P3D_instance_get_panda_script_object( m_p3dInstance ); + m_p3dObject = P3D_instance_get_panda_script_object_ptr( m_p3dInstance ); P3D_OBJECT_INCREF( m_p3dObject ); - P3D_instance_setup_window( m_p3dInstance, P3D_WT_embedded, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, &parent_window ); + P3D_instance_setup_window_ptr( m_p3dInstance, P3D_WT_embedded, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, &parent_window ); nout << "Starting new P3D instance " << p3dFilename << "\n"; - if ( !P3D_instance_start( m_p3dInstance, false, p3dFilename.c_str(), 0 ) ) + if ( !P3D_instance_start_ptr( m_p3dInstance, false, p3dFilename.c_str(), 0 ) ) { nout << "Error starting P3D instance: " << GetLastError() << "\n"; return 1; @@ -591,10 +592,10 @@ std::string PPInstance::GetP3DFilename( ) void PPInstance::HandleRequestLoop() { - P3D_instance *p3d_inst = P3D_check_request(0.0); + P3D_instance *p3d_inst = P3D_check_request_ptr(0.0); while ( p3d_inst != NULL ) { - P3D_request *request = P3D_instance_get_request(p3d_inst); + P3D_request *request = P3D_instance_get_request_ptr(p3d_inst); if ( request != NULL ) { CP3DActiveXCtrl* parent = ( CP3DActiveXCtrl* )(p3d_inst->_user_data); @@ -607,7 +608,7 @@ void PPInstance::HandleRequestLoop() nout << "Error handling P3D request. Instance's user data is not a Control \n"; } } - p3d_inst = P3D_check_request(0.0); + p3d_inst = P3D_check_request_ptr(0.0); } } @@ -639,7 +640,7 @@ void PPInstance::HandleRequestGetUrl( void* data ) result_code = P3D_RC_generic_error; } - P3D_instance_feed_url_stream( + P3D_instance_feed_url_stream_ptr( request->_instance, request->_request._get_url._unique_id, result_code, @@ -648,7 +649,7 @@ void PPInstance::HandleRequestGetUrl( void* data ) (const void*)NULL, 0 ); - P3D_request_finish( request, true ); + P3D_request_finish_ptr( request, true ); } void PPInstance::HandleRequest( P3D_request *request ) @@ -663,7 +664,7 @@ void PPInstance::HandleRequest( P3D_request *request ) { case P3D_RT_stop: { - P3D_instance_finish( request->_instance ); + P3D_instance_finish_ptr( request->_instance ); handled = true; break; } @@ -701,7 +702,7 @@ void PPInstance::HandleRequest( P3D_request *request ) break; } }; - P3D_request_finish( request, handled ); + P3D_request_finish_ptr( request, handled ); } //////////////////////////////////////////////////////////////////// diff --git a/direct/src/plugin_activex/PPInstance.h b/direct/src/plugin_activex/PPInstance.h index 7bc1405234..ccd825e231 100644 --- a/direct/src/plugin_activex/PPInstance.h +++ b/direct/src/plugin_activex/PPInstance.h @@ -23,6 +23,7 @@ #include "PPDownloadCallback.h" #include "PPLogger.h" #include "fileSpec.h" +#include "load_plugin.h" #define WM_PY_LAUNCHED (WM_USER + 1) #define WM_PROGRESS (WM_USER + 2) @@ -30,15 +31,6 @@ class CP3DActiveXCtrl; -extern P3D_instance_feed_url_stream_func *P3D_instance_feed_url_stream; -extern P3D_make_class_definition_func *P3D_make_class_definition; -extern P3D_new_undefined_object_func *P3D_new_undefined_object; -extern P3D_new_none_object_func *P3D_new_none_object; -extern P3D_new_bool_object_func *P3D_new_bool_object; -extern P3D_new_int_object_func *P3D_new_int_object; -extern P3D_new_float_object_func *P3D_new_float_object; -extern P3D_new_string_object_func *P3D_new_string_object; - class PPInstance { public: diff --git a/direct/src/plugin_activex/PPInterface.cpp b/direct/src/plugin_activex/PPInterface.cpp index 99464e0b2b..91ccbb3d06 100644 --- a/direct/src/plugin_activex/PPInterface.cpp +++ b/direct/src/plugin_activex/PPInterface.cpp @@ -406,50 +406,50 @@ P3D_object* PPInterface::variant_to_p3dobj(COleVariant* variant) { if ( !variant ) { - return P3D_new_none_object(); + return P3D_new_none_object_ptr(); } switch( variant->vt ) { case VT_VOID: { - return P3D_new_undefined_object(); + return P3D_new_undefined_object_ptr(); break; } case VT_EMPTY: { - // return P3D_new_none_object(); + // return P3D_new_none_object_ptr(); // A.T. Panda really expect undefined object here - return P3D_new_undefined_object(); + return P3D_new_undefined_object_ptr(); break; } case VT_BOOL: { - return P3D_new_bool_object( variant->bVal ); + return P3D_new_bool_object_ptr( variant->bVal ); break; } case VT_I2: { - return P3D_new_int_object( variant->iVal ); + return P3D_new_int_object_ptr( variant->iVal ); break; } case VT_I4: { - return P3D_new_int_object( variant->lVal ); + return P3D_new_int_object_ptr( variant->lVal ); break; } case VT_I8: { - return P3D_new_int_object( variant->llVal ); + return P3D_new_int_object_ptr( variant->llVal ); break; } case VT_R4: { - return P3D_new_float_object( variant->fltVal ); + return P3D_new_float_object_ptr( variant->fltVal ); break; } case VT_R8: { - return P3D_new_float_object( variant->dblVal ); + return P3D_new_float_object_ptr( variant->dblVal ); break; } case VT_BSTR: @@ -463,7 +463,7 @@ P3D_object* PPInterface::variant_to_p3dobj(COleVariant* variant) WideCharToMultiByte(CP_UTF8, 0, bstr, blen, sbuffer, slen, NULL, NULL); - P3D_object *object = P3D_new_string_object(sbuffer, slen); + P3D_object *object = P3D_new_string_object_ptr(sbuffer, slen); delete[] sbuffer; return object; break; @@ -488,7 +488,7 @@ P3D_object* PPInterface::variant_to_p3dobj(COleVariant* variant) } default: { - return P3D_new_undefined_object(); + return P3D_new_undefined_object_ptr(); break; } } diff --git a/direct/src/plugin_npapi/ppBrowserObject.cxx b/direct/src/plugin_npapi/ppBrowserObject.cxx index 597f9befb1..467a7b50eb 100644 --- a/direct/src/plugin_npapi/ppBrowserObject.cxx +++ b/direct/src/plugin_npapi/ppBrowserObject.cxx @@ -268,7 +268,7 @@ get_class_definition() { if (_browser_object_class == NULL) { // Create a default class_definition object, and fill in the // appropriate pointers. - _browser_object_class = P3D_make_class_definition(); + _browser_object_class = P3D_make_class_definition_ptr(); _browser_object_class->_finish = &object_finish; _browser_object_class->_get_repr = &object_get_repr; diff --git a/direct/src/plugin_npapi/ppInstance.cxx b/direct/src/plugin_npapi/ppInstance.cxx index 14d4d8d63c..92570a02aa 100644 --- a/direct/src/plugin_npapi/ppInstance.cxx +++ b/direct/src/plugin_npapi/ppInstance.cxx @@ -122,7 +122,7 @@ PPInstance:: #endif // __APPLE__ if (_p3d_inst != NULL) { - P3D_instance_finish(_p3d_inst); + P3D_instance_finish_ptr(_p3d_inst); _p3d_inst = NULL; } @@ -274,7 +274,7 @@ new_stream(NPMIMEType type, NPStream *stream, bool seekable, uint16_t *stype) { // If we already have an instance by the time we get this // stream, start sending the data to the instance (instead of // having to mess around with a temporary file). - _p3d_instance_id = P3D_instance_start_stream(_p3d_inst, _instance_url.c_str()); + _p3d_instance_id = P3D_instance_start_stream_ptr(_p3d_inst, _instance_url.c_str()); nout << "p3d instance to stream " << _p3d_instance_id << "\n"; } @@ -387,7 +387,7 @@ write_stream(NPStream *stream, int offset, int len, void *buffer) { PPDownloadRequest *req = (PPDownloadRequest *)(stream->notifyData); switch (req->_rtype) { case PPDownloadRequest::RT_user: - P3D_instance_feed_url_stream(_p3d_inst, req->_user_id, + P3D_instance_feed_url_stream_ptr(_p3d_inst, req->_user_id, P3D_RC_in_progress, 0, stream->end, buffer, len); return len; @@ -425,7 +425,7 @@ write_stream(NPStream *stream, int offset, int len, void *buffer) { assert(!_opened_p3d_temp_file); req->_rtype = PPDownloadRequest::RT_user; req->_user_id = _p3d_instance_id; - P3D_instance_feed_url_stream(_p3d_inst, req->_user_id, + P3D_instance_feed_url_stream_ptr(_p3d_inst, req->_user_id, P3D_RC_in_progress, 0, stream->end, buffer, len); return len; @@ -475,7 +475,7 @@ destroy_stream(NPStream *stream, NPReason reason) { case PPDownloadRequest::RT_user: { assert(!req->_notified_done); - P3D_instance_feed_url_stream(_p3d_inst, req->_user_id, + P3D_instance_feed_url_stream_ptr(_p3d_inst, req->_user_id, result_code, 0, stream->end, NULL, 0); req->_notified_done = true; } @@ -494,7 +494,7 @@ destroy_stream(NPStream *stream, NPReason reason) { } else { // The instance has (only just) been created. Tell it we've // sent it all the data it will get. - P3D_instance_feed_url_stream(_p3d_inst, _p3d_instance_id, + P3D_instance_feed_url_stream_ptr(_p3d_inst, _p3d_instance_id, result_code, 0, stream->end, NULL, 0); } assert(!req->_notified_done); @@ -545,7 +545,7 @@ url_notify(const char *url, NPReason reason, void *notifyData) { nout << "Failure starting stream\n"; assert(reason != NPRES_DONE); - P3D_instance_feed_url_stream(_p3d_inst, req->_user_id, + P3D_instance_feed_url_stream_ptr(_p3d_inst, req->_user_id, P3D_RC_generic_error, 0, 0, NULL, 0); req->_notified_done = true; } @@ -680,7 +680,7 @@ handle_request(P3D_request *request) { switch (request->_request_type) { case P3D_RT_stop: if (_p3d_inst != NULL) { - P3D_instance_finish(_p3d_inst); + P3D_instance_finish_ptr(_p3d_inst); _p3d_inst = NULL; } cleanup_window(); @@ -723,7 +723,7 @@ handle_request(P3D_request *request) { break; }; - P3D_request_finish(request, handled); + P3D_request_finish_ptr(request, handled); } //////////////////////////////////////////////////////////////////// @@ -783,7 +783,7 @@ handle_event(void *event) { } - if (P3D_instance_handle_event(_p3d_inst, &edata)) { + if (P3D_instance_handle_event_ptr(_p3d_inst, &edata)) { retval = true; } @@ -807,7 +807,7 @@ get_panda_script_object() { P3D_object *main = NULL; if (_p3d_inst != NULL) { - main = P3D_instance_get_panda_script_object(_p3d_inst); + main = P3D_instance_get_panda_script_object_ptr(_p3d_inst); } nout << "get_panda_script_object, main = " << main << "\n"; @@ -876,19 +876,19 @@ p3dobj_to_variant(NPVariant *result, P3D_object *object) { P3D_object *PPInstance:: variant_to_p3dobj(const NPVariant *variant) { if (NPVARIANT_IS_VOID(*variant)) { - return P3D_new_undefined_object(); + return P3D_new_undefined_object_ptr(); } else if (NPVARIANT_IS_NULL(*variant)) { - return P3D_new_none_object(); + return P3D_new_none_object_ptr(); } else if (NPVARIANT_IS_BOOLEAN(*variant)) { - return P3D_new_bool_object(NPVARIANT_TO_BOOLEAN(*variant)); + return P3D_new_bool_object_ptr(NPVARIANT_TO_BOOLEAN(*variant)); } else if (NPVARIANT_IS_INT32(*variant)) { - return P3D_new_int_object(NPVARIANT_TO_INT32(*variant)); + return P3D_new_int_object_ptr(NPVARIANT_TO_INT32(*variant)); } else if (NPVARIANT_IS_DOUBLE(*variant)) { - return P3D_new_float_object(NPVARIANT_TO_DOUBLE(*variant)); + return P3D_new_float_object_ptr(NPVARIANT_TO_DOUBLE(*variant)); } else if (NPVARIANT_IS_STRING(*variant)) { NPString str = NPVARIANT_TO_STRING(*variant); const UC_NPString &uc_str = *(UC_NPString *)(&str); - return P3D_new_string_object(uc_str.UTF8Characters, uc_str.UTF8Length); + return P3D_new_string_object_ptr(uc_str.UTF8Characters, uc_str.UTF8Length); } else if (NPVARIANT_IS_OBJECT(*variant)) { NPObject *object = NPVARIANT_TO_OBJECT(*variant); if (object->_class == &PPPandaObject::_object_class) { @@ -903,7 +903,7 @@ variant_to_p3dobj(const NPVariant *variant) { } // Hmm, none of the above? - return P3D_new_none_object(); + return P3D_new_none_object_ptr(); } //////////////////////////////////////////////////////////////////// @@ -1311,7 +1311,7 @@ send_p3d_temp_file_data() { size_t total = 0; size_t count = in.gcount(); while (count != 0) { - P3D_instance_feed_url_stream(_p3d_inst, _p3d_instance_id, + P3D_instance_feed_url_stream_ptr(_p3d_inst, _p3d_instance_id, P3D_RC_in_progress, 0, _p3d_temp_file_total_size, buffer, count); total += count; @@ -1328,7 +1328,7 @@ send_p3d_temp_file_data() { if (_finished_p3d_temp_file) { // If we'd already finished the stream earlier, tell the plugin. - P3D_instance_feed_url_stream(_p3d_inst, _p3d_instance_id, + P3D_instance_feed_url_stream_ptr(_p3d_inst, _p3d_instance_id, P3D_RC_done, 0, _p3d_temp_file_total_size, NULL, 0); } @@ -1469,7 +1469,8 @@ do_load_plugin() { #endif // P3D_PLUGIN_P3D_PLUGIN nout << "Attempting to load core API from " << pathname << "\n"; - if (!load_plugin(pathname, "", "", true, "", "", "", false, false, nout)) { + if (!load_plugin(pathname, "", "", true, "", "", "", false, false, + _root_dir, nout)) { nout << "Unable to launch core API in " << pathname << "\n"; set_failed(); return; @@ -1480,7 +1481,7 @@ do_load_plugin() { #else static const bool official = false; #endif - P3D_set_plugin_version(P3D_PLUGIN_MAJOR_VERSION, P3D_PLUGIN_MINOR_VERSION, + P3D_set_plugin_version_ptr(P3D_PLUGIN_MAJOR_VERSION, P3D_PLUGIN_MINOR_VERSION, P3D_PLUGIN_SEQUENCE_VERSION, official, PANDA_DISTRIBUTOR, PANDA_PACKAGE_HOST_URL, _core_api_dll.get_timestamp()); @@ -1511,7 +1512,7 @@ create_instance() { tokens = &_tokens[0]; } _started = true; - _p3d_inst = P3D_new_instance(request_ready, tokens, _tokens.size(), + _p3d_inst = P3D_new_instance_ptr(request_ready, tokens, _tokens.size(), 0, NULL, this); if (_p3d_inst == NULL) { set_failed(); @@ -1524,7 +1525,7 @@ create_instance() { if (browser->getvalue(_npp_instance, NPNVWindowNPObject, &window_object) == NPERR_NO_ERROR) { PPBrowserObject *pobj = new PPBrowserObject(this, window_object); - P3D_instance_set_browser_script_object(_p3d_inst, pobj); + P3D_instance_set_browser_script_object_ptr(_p3d_inst, pobj); browser->releaseobject(window_object); } else { nout << "Couldn't get window_object\n"; @@ -1533,14 +1534,14 @@ create_instance() { if (_script_object != NULL) { // Now that we have a true instance, initialize our // script_object with the proper P3D_object pointer. - P3D_object *main = P3D_instance_get_panda_script_object(_p3d_inst); + P3D_object *main = P3D_instance_get_panda_script_object_ptr(_p3d_inst); nout << "new instance, setting main = " << main << "\n"; _script_object->set_main(main); } if (_got_instance_url) { // Create the user_id for streaming the p3d data into the instance. - _p3d_instance_id = P3D_instance_start_stream(_p3d_inst, _instance_url.c_str()); + _p3d_instance_id = P3D_instance_start_stream_ptr(_p3d_inst, _instance_url.c_str()); nout << "p3d instance to stream " << _p3d_instance_id << "\n"; // If we have already started to receive any instance data, send it @@ -1659,7 +1660,7 @@ send_window() { window_type = P3D_WT_hidden; } - P3D_instance_setup_window + P3D_instance_setup_window_ptr (_p3d_inst, window_type, x, y, _window.width, _window.height, &parent_window); @@ -1770,7 +1771,7 @@ set_failed() { } if (_p3d_inst != NULL) { - P3D_instance_finish(_p3d_inst); + P3D_instance_finish_ptr(_p3d_inst); _p3d_inst = NULL; } cleanup_window(); @@ -1790,9 +1791,9 @@ handle_request_loop() { return; } - P3D_instance *p3d_inst = P3D_check_request(0.0); + P3D_instance *p3d_inst = P3D_check_request_ptr(0.0); while (p3d_inst != (P3D_instance *)NULL) { - P3D_request *request = P3D_instance_get_request(p3d_inst); + P3D_request *request = P3D_instance_get_request_ptr(p3d_inst); if (request != (P3D_request *)NULL) { PPInstance *inst = (PPInstance *)(p3d_inst->_user_data); assert(inst != NULL); @@ -1803,7 +1804,7 @@ handle_request_loop() { return; } } - p3d_inst = P3D_check_request(0.0); + p3d_inst = P3D_check_request_ptr(0.0); } // Also check to see if we have any file_data objects that have @@ -2098,7 +2099,7 @@ thread_run() { size_t count = _file.gcount(); while (count != 0) { _total_count += count; - bool download_ok = P3D_instance_feed_url_stream + bool download_ok = P3D_instance_feed_url_stream_ptr (_p3d_inst, _user_id, P3D_RC_in_progress, 0, _file_size, (const unsigned char *)buffer, count); @@ -2138,7 +2139,7 @@ thread_run() { result = P3D_RC_generic_error; } - P3D_instance_feed_url_stream + P3D_instance_feed_url_stream_ptr (_p3d_inst, _user_id, result, 0, _total_count, NULL, 0); // All done. diff --git a/direct/src/plugin_standalone/Sources.pp b/direct/src/plugin_standalone/Sources.pp index ca8299f7aa..80a9155f48 100644 --- a/direct/src/plugin_standalone/Sources.pp +++ b/direct/src/plugin_standalone/Sources.pp @@ -19,6 +19,7 @@ #define OSX_SYS_FRAMEWORKS Foundation AppKit Carbon #define SOURCES \ + panda3dBase.cxx panda3dBase.h panda3dBase.I \ panda3d.cxx panda3d.h panda3d.I \ panda3dMain.cxx @@ -46,6 +47,7 @@ #define OSX_SYS_FRAMEWORKS Foundation AppKit Carbon #define SOURCES \ + panda3dBase.cxx panda3dBase.h panda3dBase.I \ panda3d.cxx panda3d.h panda3d.I \ panda3dWinMain.cxx @@ -74,9 +76,37 @@ #define OSX_SYS_FRAMEWORKS Foundation AppKit Carbon #define SOURCES \ + panda3dBase.cxx panda3dBase.h panda3dBase.I \ panda3d.cxx panda3d.h panda3d.I \ panda3dMac.cxx panda3dMac.h panda3dMac.I #end bin_target +#begin bin_target + #define USE_PACKAGES openssl zlib + #define TARGET p3dembed + #define LOCAL_LIBS plugin_common p3d_plugin_static + + // We need to define this, even though we are not creating a DLL, + // because we need the symbols to be "exported" so we can find them in + // our own address space. + #define EXTRA_CDEFS BUILDING_P3D_PLUGIN + + #define OTHER_LIBS \ + prc:c dtoolutil:c dtoolbase:c dtool:m \ + interrogatedb:c dconfig:c dtoolconfig:m \ + pandabase:c downloader:c express:c pandaexpress:m \ + pystub + + #define OSX_SYS_FRAMEWORKS Foundation AppKit Carbon + + #define SOURCES \ + panda3dBase.cxx panda3dBase.h panda3dBase.I \ + p3dEmbed.cxx + + #define WIN_RESOURCE_FILE panda3d.rc + #define WIN_SYS_LIBS user32.lib gdi32.lib shell32.lib comctl32.lib msimg32.lib ole32.lib + +#end bin_target + #include $[THISDIRPREFIX]panda3d.rc.pp diff --git a/direct/src/plugin_standalone/p3dEmbed.cxx b/direct/src/plugin_standalone/p3dEmbed.cxx index c06b6217b4..3552487252 100644 --- a/direct/src/plugin_standalone/p3dEmbed.cxx +++ b/direct/src/plugin_standalone/p3dEmbed.cxx @@ -12,19 +12,160 @@ // //////////////////////////////////////////////////////////////////// -#include "p3d_plugin_composite1.cxx" -#include "panda3dBase.cxx" +#define P3D_FUNCTION_PROTOTYPES + +#include "p3dEmbed.h" +#include "load_plugin.h" #ifdef _WIN32 -const unsigned long p3d_offset = 0xFF3D3D00; +unsigned long p3d_offset = 0xFF3D3D00; #else #include -const uint32_t p3d_offset = 0xFF3D3D00; +uint32_t p3d_offset = 0xFF3D3D00; #endif +//////////////////////////////////////////////////////////////////// +// Function: P3DEmbed::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +P3DEmbed:: +P3DEmbed(bool console_environment) : Panda3DBase(console_environment) { +} + +//////////////////////////////////////////////////////////////////// +// Function: P3DEmbed::run_embedded +// Access: Public +// Description: Runs with the data embedded in the current +// executable, at the specified offset. +//////////////////////////////////////////////////////////////////// +int P3DEmbed:: +run_embedded(streampos read_offset, int argc, char *argv[]) { + // Make sure the splash window will be put in the center of the screen + _win_x = -2; + _win_y = -2; + + // Read out some parameters from the binary + pifstream read; + Filename f = ExecutionEnvironment::get_binary_name(); + f.make_absolute(); + f.set_binary(); + if (!f.open_read(read)) { + cerr << "Failed to read from stream. Maybe the binary is corrupt?\n"; + return 1; + } + read.seekg(read_offset); + int curchr = read.get(); + if (curchr == EOF) { + cerr << "Couldn't seek to " << read_offset << "\n"; + return 1; + } + + string curstr; + bool havenull = false; + P3D_token token; + token._keyword = NULL; + token._value = NULL; + string keyword; + string value; + string root_dir; + while (true) { + if (curchr == EOF) { + cerr << "Truncated stream\n"; + return(1); + + } else if (curchr == 0) { + // Two null bytes in a row means we've reached the end of the data. + if (havenull) { + break; + } + + // This means we haven't seen an '=' character yet. + if (keyword == "") { + if (curstr != "") { + cerr << "Ignoring token '" << curstr << "' without value\n"; + } + } else { + value.assign(curstr); + P3D_token token; + token._keyword = strdup(keyword.c_str()); + token._value = strdup(value.c_str()); + _tokens.push_back(token); + + // Read out the tokens that may interest us + if (keyword == "width") { + _win_width = atoi(value.c_str()); + } else if (keyword == "height") { + _win_height = atoi(value.c_str()); + } else if (keyword == "root_dir") { + root_dir = value; + } + } + curstr = ""; + havenull = true; + } else if (curchr == '=') { + keyword.assign(curstr); + curstr = ""; + havenull = false; + } else { + curstr += curchr; + havenull = false; + } + curchr = read.get(); + } + + // Update the offset to the current read pointer. + // This is where the multifile really starts. + read_offset = read.tellg(); + read.close(); + + // Make the root directory absolute + Filename root_dir_f(root_dir); + root_dir_f.make_absolute(f.get_dirname()); + + // Initialize the plugin. Since we are linked with the core API + // statically, we pass the empty string as the plugin filename, and + // pull the required symbols out of the local address space. + if (!load_plugin("", "", + _host_url, _verify_contents, _this_platform, _log_dirname, + _log_basename, true, _console_environment, + root_dir_f.to_os_specific(), cerr)) { + cerr << "Unable to launch core API\n"; + return 1; + } + + // Create a plugin instance and run the program + P3D_instance *inst = create_instance + (f, true, _win_x, _win_y, _win_width, _win_height, + argv, argc, read_offset); + _instances.insert(inst); + + run_main_loop(); + + // Though it's not strictly necessary to call P3D_finalize() here + // (because unload_plugin() will call it), we have to do it anyway, + // to force the contents of libp3d_plugin_static.lib to be linked + // in. If we don't appear to make any calls to these functions, + // then the linker may decide to omit all of them. + P3D_finalize(); + + unload_plugin(); + return 0; +} + int main(int argc, char *argv[]) { - Panda3DBase program(true); + // Check to see if we've actually got an application embedded. If + // we do, p3d_offset will have been modified to contain a different + // value than the one we compiled in, above. We test against + // p3d_offset + 1, because any appearances of this exact number + // within the binary will be replaced (including this one). + if (p3d_offset + 1 == 0xFF3D3D01) { + cerr << "This program is not intended to be run directly.\nIt is used by pdeploy to construct an embedded Panda3D application.\n"; + return 1; + } + + P3DEmbed program(true); return program.run_embedded(p3d_offset, argc, argv); } diff --git a/direct/src/plugin_standalone/panda3d.cxx b/direct/src/plugin_standalone/panda3d.cxx index 65a911afcf..d634c3c0ff 100644 --- a/direct/src/plugin_standalone/panda3d.cxx +++ b/direct/src/plugin_standalone/panda3d.cxx @@ -16,7 +16,7 @@ #include "load_plugin.h" #include "p3d_plugin_config.h" -#include "panda3dBase.cxx" +//#include "panda3dBase.cxx" // We can include this header file to get the DTOOL_PLATFORM // definition, even though we don't link with dtool. @@ -317,7 +317,7 @@ post_arg_processing() { // Set up the "super mirror" URL, if specified. if (!_super_mirror_url.empty()) { - P3D_set_super_mirror(_super_mirror_url.c_str()); + P3D_set_super_mirror_ptr(_super_mirror_url.c_str()); } return true; @@ -673,8 +673,8 @@ get_core_api(const Filename &contents_filename, TiXmlElement *xpackage) { if (!load_plugin(pathname, contents_filename.to_os_specific(), _host_url, _verify_contents, _this_platform, _log_dirname, _log_basename, trusted_environment, _console_environment, - cerr)) { - cerr << "Unable to launch core API in " << pathname << "\n" << flush; + _root_dir, cerr)) { + cerr << "Unable to launch core API in " << pathname << "\n"; return false; } @@ -684,10 +684,10 @@ get_core_api(const Filename &contents_filename, TiXmlElement *xpackage) { #else static const bool official = false; #endif - P3D_set_plugin_version(P3D_PLUGIN_MAJOR_VERSION, P3D_PLUGIN_MINOR_VERSION, - P3D_PLUGIN_SEQUENCE_VERSION, official, - PANDA_DISTRIBUTOR, - PANDA_PACKAGE_HOST_URL, _core_api_dll.get_timestamp()); + P3D_set_plugin_version_ptr(P3D_PLUGIN_MAJOR_VERSION, P3D_PLUGIN_MINOR_VERSION, + P3D_PLUGIN_SEQUENCE_VERSION, official, + PANDA_DISTRIBUTOR, + PANDA_PACKAGE_HOST_URL, _core_api_dll.get_timestamp()); return true; } diff --git a/direct/src/plugin_standalone/panda3d.rc.pp b/direct/src/plugin_standalone/panda3d.rc.pp index ece24eec2a..b01c3bf0fc 100644 --- a/direct/src/plugin_standalone/panda3d.rc.pp +++ b/direct/src/plugin_standalone/panda3d.rc.pp @@ -31,13 +31,13 @@ BEGIN BEGIN BLOCK "040904e4" BEGIN - VALUE "FileDescription", "Runs 3-D games and interactive applets\0" + VALUE "FileDescription", "Panda3D Game Engine Runtime $[P3D_PLUGIN_VERSION_STR]\0" VALUE "FileVersion", "$[P3D_PLUGIN_DLL_DOT_VERSION]" VALUE "LegalTrademarks", "\0" VALUE "MIMEType", "application/x-panda3d\0" VALUE "FileExtents", "p3d\0" VALUE "FileOpenName", "Panda3D applet\0" - VALUE "ProductName", "Panda3D Game Engine Plug-in $[P3D_PLUGIN_VERSION_STR]\0" + VALUE "ProductName", "Panda3D Game Engine Runtime $[P3D_PLUGIN_VERSION_STR]\0" VALUE "ProductVersion", "$[P3D_PLUGIN_DLL_DOT_VERSION]" END END diff --git a/direct/src/plugin_standalone/panda3dBase.cxx b/direct/src/plugin_standalone/panda3dBase.cxx index adb227403a..c6921ce115 100644 --- a/direct/src/plugin_standalone/panda3dBase.cxx +++ b/direct/src/plugin_standalone/panda3dBase.cxx @@ -15,7 +15,7 @@ #include "panda3dBase.h" #include "httpClient.h" #include "find_root_dir.h" -#include "p3d_plugin_config.h" +#include "load_plugin.h" #include "executionEnvironment.h" // We can include this header file to get the DTOOL_PLATFORM @@ -65,108 +65,6 @@ Panda3DBase(bool console_environment) { srand((unsigned int)time(NULL)); } -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::run_embedded -// Access: Public -// Description: Runs with the data embedded in the current -// executable, at the specified offset. -//////////////////////////////////////////////////////////////////// -int Panda3DBase:: -run_embedded(int read_offset, int argc, char *argv[]) { - // Make sure the splash window will be put in the center of the screen - _win_x = -2; - _win_y = -2; - - // Read out some parameters from the binary - pifstream read; - Filename f = ExecutionEnvironment::get_binary_name(); - f.make_absolute(); - f.set_binary(); - if (!f.open_read(read)) { - cerr << "Failed to read from stream. Maybe the binary is corrupt?\n"; - return 1; - } - read.seekg(read_offset); - char curchr = 1; - string curstr; - bool havenull = false; - P3D_token token; - token._keyword = NULL; - token._value = NULL; - string keyword; - string value; - string root_dir; - while (true) { - curchr = read.get(); - if (curchr == 0) { - // Two null bytes in a row means we've reached the end of the data. - if (havenull) { - break; - } - - // This means we haven't seen an '=' character yet. - if (keyword == "") { - if (curstr != "") { - cerr << "Ignoring token '" << curstr << "' without value\n"; - } - } else { - value.assign(curstr); - P3D_token token; - token._keyword = keyword.c_str(); - token._value = value.c_str(); - _tokens.push_back(token); - - // Read out the tokens that may interest us - if (keyword == "width") { - _win_width = atoi(value.c_str()); - } else if (keyword == "height") { - _win_height = atoi(value.c_str()); - } else if (keyword == "root_dir") { - root_dir = value; - } - } - curstr = ""; - havenull = true; - } else if (curchr == '=') { - keyword.assign(curstr); - curstr = ""; - havenull = false; - } else { - curstr += curchr; - havenull = false; - } - } - // Update the offset to the current read pointer. - // This is where the multifile really starts. - read_offset = read.tellg(); - read.close(); - - // Make the root directory absolute - Filename root_dir_f (root_dir); - root_dir_f.make_absolute(f.get_dirname()); - - // Initialize the plugin - if (!P3D_initialize(P3D_API_VERSION, NULL, - _host_url.c_str(), _verify_contents, _this_platform.c_str(), - _log_dirname.c_str(), _log_basename.c_str(), - !_enable_security, _console_environment, - root_dir_f.c_str())) { - // Oops, failure to initialize. - cerr << "Failed to initialize plugin (wrong API version?)\n"; - return 1; - } - - // Create a plugin instance and run the program - P3D_instance *inst = create_instance - (f, true, _win_x, _win_y, _win_width, _win_height, - argv, argc, read_offset); - _instances.insert(inst); - - run_main_loop(); - P3D_finalize(); - return 0; -} - //////////////////////////////////////////////////////////////////// // Function: Panda3DBase::run_main_loop // Access: Public @@ -192,13 +90,13 @@ run_main_loop() { DispatchMessage(&msg); // Check for new requests from the Panda3D plugin. - P3D_instance *inst = P3D_check_request(wait_cycle); + P3D_instance *inst = P3D_check_request_ptr(wait_cycle); while (inst != (P3D_instance *)NULL) { - P3D_request *request = P3D_instance_get_request(inst); + P3D_request *request = P3D_instance_get_request_ptr(inst); if (request != (P3D_request *)NULL) { handle_request(request); } - inst = P3D_check_request(wait_cycle); + inst = P3D_check_request_ptr(wait_cycle); } while (!_url_getters.empty() && @@ -220,9 +118,9 @@ run_main_loop() { // Not an embedded window, so we don't have our own window to // generate Windows events. Instead, just wait for requests. while (!time_to_exit()) { - P3D_instance *inst = P3D_check_request(wait_cycle); + P3D_instance *inst = P3D_check_request_ptr(wait_cycle); if (inst != (P3D_instance *)NULL) { - P3D_request *request = P3D_instance_get_request(inst); + P3D_request *request = P3D_instance_get_request_ptr(inst); if (request != (P3D_request *)NULL) { handle_request(request); } @@ -337,7 +235,7 @@ handle_request(P3D_request *request) { break; }; - P3D_request_finish(request, handled); + P3D_request_finish_ptr(request, handled); } #ifdef _WIN32 @@ -477,18 +375,18 @@ create_instance(const string &p3d, bool start_instance, argv.push_back(args[i]); } - P3D_instance *inst = P3D_new_instance(NULL, tokens_p, num_tokens, - argv.size(), &argv[0], NULL); + P3D_instance *inst = P3D_new_instance_ptr(NULL, tokens_p, num_tokens, + argv.size(), &argv[0], NULL); if (inst != NULL) { if (start_instance) { // We call start() first, to give the core API a chance to // notice the "hidden" attrib before we set the window // parameters. - P3D_instance_start(inst, is_local, os_p3d_filename.c_str(), p3d_offset); + P3D_instance_start_ptr(inst, is_local, os_p3d_filename.c_str(), p3d_offset); } - P3D_instance_setup_window + P3D_instance_setup_window_ptr (inst, _window_type, win_x, win_y, win_width, win_height, &_parent_window); } @@ -503,7 +401,7 @@ create_instance(const string &p3d, bool start_instance, //////////////////////////////////////////////////////////////////// void Panda3DBase:: delete_instance(P3D_instance *inst) { - P3D_instance_finish(inst); + P3D_instance_finish_ptr(inst); _instances.erase(inst); // Make sure we also terminate any pending URLGetters associated @@ -609,22 +507,22 @@ is_url(const string ¶m) { //////////////////////////////////////////////////////////////////// void Panda3DBase:: report_downloading_package(P3D_instance *instance) { - P3D_object *obj = P3D_instance_get_panda_script_object(instance); + P3D_object *obj = P3D_instance_get_panda_script_object_ptr(instance); - P3D_object *display_name = P3D_object_get_property(obj, "downloadPackageDisplayName"); + P3D_object *display_name = P3D_object_get_property_ptr(obj, "downloadPackageDisplayName"); if (display_name == NULL) { cerr << "Installing package.\n"; return; } - int name_length = P3D_object_get_string(display_name, NULL, 0); + int name_length = P3D_object_get_string_ptr(display_name, NULL, 0); char *name = new char[name_length + 1]; - P3D_object_get_string(display_name, name, name_length + 1); + P3D_object_get_string_ptr(display_name, name, name_length + 1); cerr << "Installing " << name << "\n"; delete[] name; - P3D_object_decref(display_name); + P3D_object_decref_ptr(display_name); _reporting_download = true; } @@ -723,7 +621,7 @@ run() { if (_channel->run() || _rf.get_data_size() != 0) { if (_rf.get_data_size() != 0) { // Got some new data. - bool download_ok = P3D_instance_feed_url_stream + bool download_ok = P3D_instance_feed_url_stream_ptr (_instance, _unique_id, P3D_RC_in_progress, _channel->get_status_code(), _channel->get_file_size(), @@ -755,7 +653,7 @@ run() { cerr << "Error getting URL " << _url << "\n"; } - P3D_instance_feed_url_stream + P3D_instance_feed_url_stream_ptr (_instance, _unique_id, status, _channel->get_status_code(), _bytes_sent, NULL, 0); diff --git a/direct/src/plugin_standalone/panda3dBase.h b/direct/src/plugin_standalone/panda3dBase.h index b529bed1d8..68e2a20cb4 100755 --- a/direct/src/plugin_standalone/panda3dBase.h +++ b/direct/src/plugin_standalone/panda3dBase.h @@ -40,7 +40,6 @@ class Panda3DBase { public: Panda3DBase(bool console_environment); - int run_embedded(int read_offset, int argc, char *argv[]); void run_main_loop(); protected: