osx plugin work
This commit is contained in:
parent
af88f97ff2
commit
b64f871ea1
|
|
@ -22,6 +22,7 @@
|
|||
p3dPackage.h p3dPackage.I \
|
||||
p3dProgressWindow.h p3dProgressWindow.I \
|
||||
p3dSession.h p3dSession.I \
|
||||
p3dWindowParams.h p3dWindowParams.I \
|
||||
p3dWinProgressWindow.h p3dWinProgressWindow.I
|
||||
|
||||
#define INCLUDED_SOURCES \
|
||||
|
|
@ -34,6 +35,7 @@
|
|||
p3dPackage.cxx \
|
||||
p3dProgressWindow.cxx \
|
||||
p3dSession.cxx \
|
||||
p3dWindowParams.cxx \
|
||||
p3dWinProgressWindow.cxx
|
||||
|
||||
#define INSTALL_HEADERS \
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@
|
|||
// minimal structural overhead, it is designed to be simply #included
|
||||
// into the different source files.
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
static const string dll_ext = ".dll";
|
||||
#elif defined(__APPLE__)
|
||||
|
|
@ -32,6 +36,7 @@ P3D_initialize_func *P3D_initialize;
|
|||
P3D_free_string_func *P3D_free_string;
|
||||
P3D_create_instance_func *P3D_create_instance;
|
||||
P3D_instance_finish_func *P3D_instance_finish;
|
||||
P3D_instance_setup_window_func *P3D_instance_setup_window;
|
||||
P3D_instance_has_property_func *P3D_instance_has_property;
|
||||
P3D_instance_get_property_func *P3D_instance_get_property;
|
||||
P3D_instance_set_property_func *P3D_instance_set_property;
|
||||
|
|
@ -88,6 +93,7 @@ load_plugin(const string &p3d_plugin_filename) {
|
|||
P3D_free_string = (P3D_free_string_func *)GetProcAddress(module, "P3D_free_string");
|
||||
P3D_create_instance = (P3D_create_instance_func *)GetProcAddress(module, "P3D_create_instance");
|
||||
P3D_instance_finish = (P3D_instance_finish_func *)GetProcAddress(module, "P3D_instance_finish");
|
||||
P3D_instance_setup_window = (P3D_instance_setup_window_func *)GetProcAddress(module, "P3D_instance_setup_window");
|
||||
P3D_instance_has_property = (P3D_instance_has_property_func *)GetProcAddress(module, "P3D_instance_has_property");
|
||||
P3D_instance_get_property = (P3D_instance_get_property_func *)GetProcAddress(module, "P3D_instance_get_property");
|
||||
P3D_instance_set_property = (P3D_instance_set_property_func *)GetProcAddress(module, "P3D_instance_set_property");
|
||||
|
|
@ -109,6 +115,7 @@ load_plugin(const string &p3d_plugin_filename) {
|
|||
P3D_free_string = (P3D_free_string_func *)dlsym(module, "P3D_free_string");
|
||||
P3D_create_instance = (P3D_create_instance_func *)dlsym(module, "P3D_create_instance");
|
||||
P3D_instance_finish = (P3D_instance_finish_func *)dlsym(module, "P3D_instance_finish");
|
||||
P3D_instance_setup_window = (P3D_instance_setup_window_func *)dlsym(module, "P3D_instance_setup_window");
|
||||
P3D_instance_has_property = (P3D_instance_has_property_func *)dlsym(module, "P3D_instance_has_property");
|
||||
P3D_instance_get_property = (P3D_instance_get_property_func *)dlsym(module, "P3D_instance_get_property");
|
||||
P3D_instance_set_property = (P3D_instance_set_property_func *)dlsym(module, "P3D_instance_set_property");
|
||||
|
|
@ -124,6 +131,7 @@ load_plugin(const string &p3d_plugin_filename) {
|
|||
P3D_free_string == NULL ||
|
||||
P3D_create_instance == NULL ||
|
||||
P3D_instance_finish == NULL ||
|
||||
P3D_instance_setup_window == NULL ||
|
||||
P3D_instance_has_property == NULL ||
|
||||
P3D_instance_get_property == NULL ||
|
||||
P3D_instance_set_property == NULL ||
|
||||
|
|
@ -135,7 +143,13 @@ load_plugin(const string &p3d_plugin_filename) {
|
|||
}
|
||||
|
||||
// Successfully loaded.
|
||||
if (!P3D_initialize(P3D_API_VERSION, "c:/cygwin/home/drose/t0.log")) {
|
||||
#ifdef _WIN32
|
||||
string logfilename = "c:/cygwin/home/drose/t0.log";
|
||||
#else
|
||||
string logfilename = "/Users/drose/t0.log";
|
||||
#endif
|
||||
|
||||
if (!P3D_initialize(P3D_API_VERSION, logfilename.c_str())) {
|
||||
// Oops, failure to initialize.
|
||||
unload_plugin();
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ extern P3D_initialize_func *P3D_initialize;
|
|||
extern P3D_free_string_func *P3D_free_string;
|
||||
extern P3D_create_instance_func *P3D_create_instance;
|
||||
extern P3D_instance_finish_func *P3D_instance_finish;
|
||||
extern P3D_instance_setup_window_func *P3D_instance_setup_window;
|
||||
extern P3D_instance_has_property_func *P3D_instance_has_property;
|
||||
extern P3D_instance_get_property_func *P3D_instance_get_property;
|
||||
extern P3D_instance_set_property_func *P3D_instance_set_property;
|
||||
|
|
|
|||
|
|
@ -22,10 +22,7 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
P3DCInstance::
|
||||
P3DCInstance(TiXmlElement *xinstance) :
|
||||
_func(NULL),
|
||||
_window_type(P3D_WT_toplevel),
|
||||
_win_x(0), _win_y(0),
|
||||
_win_width(0), _win_height(0)
|
||||
_func(NULL)
|
||||
{
|
||||
xinstance->Attribute("id", &_instance_id);
|
||||
|
||||
|
|
@ -34,31 +31,6 @@ P3DCInstance(TiXmlElement *xinstance) :
|
|||
_p3d_filename = p3d_filename;
|
||||
}
|
||||
|
||||
const char *window_type = xinstance->Attribute("window_type");
|
||||
if (window_type != NULL) {
|
||||
if (strcmp(window_type, "embedded") == 0) {
|
||||
_window_type = P3D_WT_embedded;
|
||||
} else if (strcmp(window_type, "toplevel") == 0) {
|
||||
_window_type = P3D_WT_toplevel;
|
||||
} else if (strcmp(window_type, "fullscreen") == 0) {
|
||||
_window_type = P3D_WT_fullscreen;
|
||||
} else if (strcmp(window_type, "hidden") == 0) {
|
||||
_window_type = P3D_WT_hidden;
|
||||
}
|
||||
}
|
||||
|
||||
xinstance->Attribute("win_x", &_win_x);
|
||||
xinstance->Attribute("win_y", &_win_y);
|
||||
xinstance->Attribute("win_width", &_win_width);
|
||||
xinstance->Attribute("win_height", &_win_height);
|
||||
|
||||
#ifdef _WIN32
|
||||
int hwnd;
|
||||
if (xinstance->Attribute("parent_hwnd", &hwnd)) {
|
||||
_parent_window._hwnd = (HWND)hwnd;
|
||||
}
|
||||
#endif
|
||||
|
||||
TiXmlElement *xtoken = xinstance->FirstChildElement("token");
|
||||
while (xtoken != NULL) {
|
||||
Token token;
|
||||
|
|
|
|||
|
|
@ -50,10 +50,6 @@ private:
|
|||
|
||||
P3D_request_ready_func *_func;
|
||||
string _p3d_filename;
|
||||
P3D_window_type _window_type;
|
||||
int _win_x, _win_y;
|
||||
int _win_width, _win_height;
|
||||
P3D_window_handle _parent_window;
|
||||
|
||||
Tokens _tokens;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,16 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DInstance::get_wparams
|
||||
// Access: Public
|
||||
// Description: Returns the current window parameters.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline const P3DWindowParams &P3DInstance::
|
||||
get_wparams() const {
|
||||
return _wparams;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DInstance::get_p3d_filename
|
||||
// Access: Public
|
||||
|
|
@ -24,72 +34,6 @@ get_p3d_filename() const {
|
|||
return _p3d_filename;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DInstance::get_window_type
|
||||
// Access: Public
|
||||
// Description: Returns the window_type that was passed to the
|
||||
// constructor.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline P3D_window_type P3DInstance::
|
||||
get_window_type() const {
|
||||
return _window_type;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DInstance::get_window_x
|
||||
// Access: Public
|
||||
// Description: Returns the window origin X coordinate that was
|
||||
// passed to the constructor.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline int P3DInstance::
|
||||
get_win_x() const {
|
||||
return _win_x;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DInstance::get_win_y
|
||||
// Access: Public
|
||||
// Description: Returns the window origin Y coordinate that was
|
||||
// passed to the constructor.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline int P3DInstance::
|
||||
get_win_y() const {
|
||||
return _win_y;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DInstance::get_win_width
|
||||
// Access: Public
|
||||
// Description: Returns the window width that was passed to the
|
||||
// constructor.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline int P3DInstance::
|
||||
get_win_width() const {
|
||||
return _win_width;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DInstance::get_win_height
|
||||
// Access: Public
|
||||
// Description: Returns the window height that was passed to the
|
||||
// constructor.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline int P3DInstance::
|
||||
get_win_height() const {
|
||||
return _win_height;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DInstance::get_parent_window
|
||||
// Access: Public
|
||||
// Description: Returns the parent window handle that was passed to
|
||||
// the constructor.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline P3D_window_handle P3DInstance::
|
||||
get_parent_window() const {
|
||||
return _parent_window;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DInstance::get_instance_id
|
||||
// Access: Public
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include "p3dInstance.h"
|
||||
#include "p3dInstanceManager.h"
|
||||
#include "p3dDownload.h"
|
||||
#include "p3dSession.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
|
@ -28,20 +29,11 @@ int P3DInstance::_next_instance_id = 0;
|
|||
P3DInstance::
|
||||
P3DInstance(P3D_request_ready_func *func,
|
||||
const string &p3d_filename,
|
||||
P3D_window_type window_type,
|
||||
int win_x, int win_y,
|
||||
int win_width, int win_height,
|
||||
P3D_window_handle parent_window,
|
||||
const P3D_token tokens[], size_t num_tokens) :
|
||||
_func(func),
|
||||
_p3d_filename(p3d_filename),
|
||||
_window_type(window_type),
|
||||
_win_x(win_x), _win_y(win_y),
|
||||
_win_width(win_width), _win_height(win_height),
|
||||
_parent_window(parent_window)
|
||||
_p3d_filename(p3d_filename)
|
||||
{
|
||||
fill_tokens(tokens, num_tokens);
|
||||
nout << "instance, size = " << _win_width << " " << _win_height << "\n";
|
||||
|
||||
_instance_id = _next_instance_id;
|
||||
++_next_instance_id;
|
||||
|
|
@ -77,6 +69,31 @@ P3DInstance::
|
|||
// download is still running? Who will crash when this happens?
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DInstance::set_wparams
|
||||
// Access: Public
|
||||
// Description: Changes the window parameters, e.g. to resize or
|
||||
// reposition the window; or sets the parameters for the
|
||||
// first time, creating the initial window.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void P3DInstance::
|
||||
set_wparams(const P3DWindowParams &wparams) {
|
||||
assert(_session != NULL);
|
||||
_wparams = wparams;
|
||||
|
||||
TiXmlDocument *doc = new TiXmlDocument;
|
||||
TiXmlDeclaration *decl = new TiXmlDeclaration("1.0", "", "");
|
||||
TiXmlElement *xcommand = new TiXmlElement("command");
|
||||
xcommand->SetAttribute("cmd", "setup_window");
|
||||
xcommand->SetAttribute("id", get_instance_id());
|
||||
TiXmlElement *xwparams = _wparams.make_xml();
|
||||
|
||||
doc->LinkEndChild(decl);
|
||||
doc->LinkEndChild(xcommand);
|
||||
xcommand->LinkEndChild(xwparams);
|
||||
|
||||
_session->send_command(doc);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DInstance::has_property
|
||||
|
|
@ -306,37 +323,6 @@ make_xml() {
|
|||
xinstance->SetAttribute("id", _instance_id);
|
||||
xinstance->SetAttribute("p3d_filename", _p3d_filename.c_str());
|
||||
|
||||
switch (_window_type) {
|
||||
case P3D_WT_embedded:
|
||||
xinstance->SetAttribute("window_type", "embedded");
|
||||
xinstance->SetAttribute("win_x", _win_x);
|
||||
xinstance->SetAttribute("win_y", _win_y);
|
||||
xinstance->SetAttribute("win_width", _win_width);
|
||||
xinstance->SetAttribute("win_height", _win_height);
|
||||
#ifdef _WIN32
|
||||
xinstance->SetAttribute("parent_hwnd", (int)_parent_window._hwnd);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case P3D_WT_toplevel:
|
||||
xinstance->SetAttribute("window_type", "toplevel");
|
||||
xinstance->SetAttribute("win_x", _win_x);
|
||||
xinstance->SetAttribute("win_y", _win_y);
|
||||
xinstance->SetAttribute("win_width", _win_width);
|
||||
xinstance->SetAttribute("win_height", _win_height);
|
||||
break;
|
||||
|
||||
case P3D_WT_fullscreen:
|
||||
xinstance->SetAttribute("window_type", "fullscreen");
|
||||
xinstance->SetAttribute("win_width", _win_width);
|
||||
xinstance->SetAttribute("win_height", _win_height);
|
||||
break;
|
||||
|
||||
case P3D_WT_hidden:
|
||||
xinstance->SetAttribute("window_type", "hidden");
|
||||
break;
|
||||
}
|
||||
|
||||
Tokens::const_iterator ti;
|
||||
for (ti = _tokens.begin(); ti != _tokens.end(); ++ti) {
|
||||
const Token &token = (*ti);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "p3d_plugin_common.h"
|
||||
#include "p3dFileDownload.h"
|
||||
#include "p3dWindowParams.h"
|
||||
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
|
|
@ -35,13 +36,12 @@ class P3DInstance : public P3D_instance {
|
|||
public:
|
||||
P3DInstance(P3D_request_ready_func *func,
|
||||
const string &p3d_filename,
|
||||
P3D_window_type window_type,
|
||||
int win_x, int win_y,
|
||||
int win_width, int win_height,
|
||||
P3D_window_handle parent_window,
|
||||
const P3D_token tokens[], size_t num_tokens);
|
||||
~P3DInstance();
|
||||
|
||||
void set_wparams(const P3DWindowParams &wparams);
|
||||
inline const P3DWindowParams &get_wparams() const;
|
||||
|
||||
bool has_property(const string &property_name) const;
|
||||
string get_property(const string &property_name) const;
|
||||
void set_property(const string &property_name, const string &value);
|
||||
|
|
@ -59,12 +59,6 @@ public:
|
|||
size_t this_data_size);
|
||||
|
||||
inline const string &get_p3d_filename() const;
|
||||
inline P3D_window_type get_window_type() const;
|
||||
inline int get_win_x() const;
|
||||
inline int get_win_y() const;
|
||||
inline int get_win_width() const;
|
||||
inline int get_win_height() const;
|
||||
inline P3D_window_handle get_parent_window() const;
|
||||
|
||||
inline int get_instance_id() const;
|
||||
inline const string &get_session_key() const;
|
||||
|
|
@ -88,12 +82,10 @@ private:
|
|||
|
||||
P3D_request_ready_func *_func;
|
||||
string _p3d_filename;
|
||||
P3D_window_type _window_type;
|
||||
int _win_x, _win_y;
|
||||
int _win_width, _win_height;
|
||||
P3D_window_handle _parent_window;
|
||||
Tokens _tokens;
|
||||
|
||||
P3DWindowParams _wparams;
|
||||
|
||||
int _instance_id;
|
||||
string _session_key;
|
||||
string _python_version;
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ initialize() {
|
|||
_download_url = "http://10.196.143.118/~drose/p3d/";
|
||||
|
||||
#else
|
||||
_download_url = "http://orpheus.ddrose.com/~drose/p3d/";
|
||||
_download_url = "http://www.ddrose.com/~drose/p3d/";
|
||||
#endif
|
||||
|
||||
if (_root_dir.empty()) {
|
||||
|
|
@ -119,14 +119,8 @@ initialize() {
|
|||
P3DInstance *P3DInstanceManager::
|
||||
create_instance(P3D_request_ready_func *func,
|
||||
const string &p3d_filename,
|
||||
P3D_window_type window_type,
|
||||
int win_x, int win_y,
|
||||
int win_width, int win_height,
|
||||
P3D_window_handle parent_window,
|
||||
const P3D_token tokens[], size_t num_tokens) {
|
||||
P3DInstance *inst = new P3DInstance(func, p3d_filename,
|
||||
window_type, win_x, win_y,
|
||||
win_width, win_height, parent_window,
|
||||
tokens, num_tokens);
|
||||
_instances.insert(inst);
|
||||
|
||||
|
|
@ -375,10 +369,7 @@ get_global_ptr() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void P3DInstanceManager::
|
||||
create_command_instance() {
|
||||
P3D_window_handle dummy_handle;
|
||||
_command_instance =
|
||||
new P3DInstance(NULL, "", P3D_WT_hidden, 0, 0, 0, 0,
|
||||
dummy_handle, NULL, 0);
|
||||
_command_instance = new P3DInstance(NULL, "", NULL, 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -45,10 +45,6 @@ public:
|
|||
P3DInstance *
|
||||
create_instance(P3D_request_ready_func *func,
|
||||
const string &p3d_filename,
|
||||
P3D_window_type window_type,
|
||||
int win_x, int win_y,
|
||||
int win_width, int win_height,
|
||||
P3D_window_handle parent_window,
|
||||
const P3D_token tokens[], size_t num_tokens);
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -26,12 +26,6 @@ P3DProgressWindow(P3DPackage *package, P3DSession *session,
|
|||
_session(session),
|
||||
_inst(inst)
|
||||
{
|
||||
_window_type = inst->get_window_type();
|
||||
_win_x = inst->get_win_x();
|
||||
_win_y = inst->get_win_y();
|
||||
_win_width = inst->get_win_width();
|
||||
_win_height = inst->get_win_height();
|
||||
_parent_window = inst->get_parent_window();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "p3d_plugin_common.h"
|
||||
#include "p3dPackage.h"
|
||||
#include "p3dWindowParams.h"
|
||||
|
||||
class P3DInstance;
|
||||
|
||||
|
|
@ -33,7 +34,8 @@ class P3DInstance;
|
|||
////////////////////////////////////////////////////////////////////
|
||||
class P3DProgressWindow : public P3DPackage::Callback {
|
||||
public:
|
||||
P3DProgressWindow(P3DPackage *package, P3DSession *session, P3DInstance *inst);
|
||||
P3DProgressWindow(P3DPackage *package, P3DSession *session,
|
||||
P3DInstance *inst);
|
||||
|
||||
virtual void package_ready(P3DPackage *package, bool success);
|
||||
|
||||
|
|
@ -42,10 +44,7 @@ protected:
|
|||
P3DSession *_session;
|
||||
P3DInstance *_inst;
|
||||
|
||||
P3D_window_type _window_type;
|
||||
int _win_x, _win_y;
|
||||
int _win_width, _win_height;
|
||||
P3D_window_handle _parent_window;
|
||||
P3DWindowParams _wparams;
|
||||
};
|
||||
|
||||
#include "p3dProgressWindow.I"
|
||||
|
|
|
|||
|
|
@ -162,6 +162,13 @@ handle_command(TiXmlDocument *doc) {
|
|||
if (xcommand->Attribute("id", &id)) {
|
||||
terminate_instance(id);
|
||||
}
|
||||
} else if (strcmp(cmd, "setup_window") == 0) {
|
||||
int id;
|
||||
TiXmlElement *xwparams = xcommand->FirstChildElement("wparams");
|
||||
if (xwparams != (TiXmlElement *)NULL &&
|
||||
xcommand->Attribute("id", &id)) {
|
||||
setup_window(id, xwparams);
|
||||
}
|
||||
} else if (strcmp(cmd, "exit") == 0) {
|
||||
terminate_session();
|
||||
|
||||
|
|
@ -281,41 +288,9 @@ start_instance(P3DCInstance *inst) {
|
|||
nout << "starting instance " << inst->get_p3d_filename() << "\n";
|
||||
_instances[inst->get_instance_id()] = inst;
|
||||
|
||||
string window_type;
|
||||
switch (inst->_window_type) {
|
||||
case P3D_WT_embedded:
|
||||
window_type = "embedded";
|
||||
break;
|
||||
case P3D_WT_toplevel:
|
||||
window_type = "toplevel";
|
||||
break;
|
||||
case P3D_WT_fullscreen:
|
||||
window_type = "fullscreen";
|
||||
break;
|
||||
case P3D_WT_hidden:
|
||||
window_type = "hidden";
|
||||
break;
|
||||
}
|
||||
|
||||
PyObject *result = PyObject_CallFunction
|
||||
(_setupWindow, "siiiii", window_type.c_str(),
|
||||
inst->_win_x, inst->_win_y,
|
||||
inst->_win_width, inst->_win_height,
|
||||
#ifdef _WIN32
|
||||
(long)(inst->_parent_window._hwnd)
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
(long)(inst->_parent_window._nswindow)
|
||||
#endif
|
||||
);
|
||||
if (result == NULL) {
|
||||
PyErr_Print();
|
||||
}
|
||||
Py_XDECREF(result);
|
||||
|
||||
PyObject *tokens = inst->get_py_tokens();
|
||||
|
||||
result = PyObject_CallFunction
|
||||
PyObject *result = PyObject_CallFunction
|
||||
(_runPackedApp, "sO", inst->get_p3d_filename().c_str(), tokens);
|
||||
Py_DECREF(tokens);
|
||||
|
||||
|
|
@ -348,6 +323,55 @@ terminate_instance(int id) {
|
|||
terminate_session();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DPythonRun::setup_window
|
||||
// Access: Private
|
||||
// Description: Sets the window parameters for the indicated instance.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void P3DPythonRun::
|
||||
setup_window(int id, TiXmlElement *xwparams) {
|
||||
Instances::iterator ii = _instances.find(id);
|
||||
if (ii == _instances.end()) {
|
||||
nout << "Can't setup window for " << id << ": not started.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
// P3DCInstance *inst = (*ii).second;
|
||||
|
||||
string window_type;
|
||||
const char *window_type_c = xwparams->Attribute("window_type");
|
||||
if (window_type_c != NULL) {
|
||||
window_type = window_type_c;
|
||||
}
|
||||
|
||||
int win_x, win_y, win_width, win_height;
|
||||
|
||||
xwparams->Attribute("win_x", &win_x);
|
||||
xwparams->Attribute("win_y", &win_y);
|
||||
xwparams->Attribute("win_width", &win_width);
|
||||
xwparams->Attribute("win_height", &win_height);
|
||||
|
||||
long parent_window_handle = 0;
|
||||
|
||||
#ifdef _WIN32
|
||||
int hwnd;
|
||||
if (xwparams->Attribute("parent_hwnd", &hwnd)) {
|
||||
parent_window_handle = (long)hwnd;
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: direct this into the particular instance. Requires
|
||||
// specialized ShowBase replacement.
|
||||
PyObject *result = PyObject_CallFunction
|
||||
(_setupWindow, "siiiii", window_type.c_str(),
|
||||
win_x, win_y, win_width, win_height,
|
||||
parent_window_handle);
|
||||
if (result == NULL) {
|
||||
PyErr_Print();
|
||||
}
|
||||
Py_XDECREF(result);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DPythonRun::terminate_session
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ private:
|
|||
|
||||
void start_instance(P3DCInstance *inst);
|
||||
void terminate_instance(int id);
|
||||
void setup_window(int id, TiXmlElement *xwparams);
|
||||
|
||||
void terminate_session();
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -156,6 +156,9 @@ start_instance(P3DInstance *inst) {
|
|||
// Otherwise, set a callback, so we'll know when it is ready.
|
||||
if (_panda3d_callback == NULL) {
|
||||
|
||||
_panda3d_callback = new P3DProgressWindow(_panda3d, this, inst);
|
||||
|
||||
/*
|
||||
// The callback object will be a ProgressWindow, to show
|
||||
// visual progress to the user while we're downloading.
|
||||
if (inst->get_window_type() == P3D_WT_hidden) {
|
||||
|
|
@ -168,6 +171,7 @@ start_instance(P3DInstance *inst) {
|
|||
// of class that actually does manifest a window.
|
||||
_panda3d_callback = new ProgressWinType(_panda3d, this, inst);
|
||||
}
|
||||
*/
|
||||
_panda3d->set_callback(_panda3d_callback);
|
||||
}
|
||||
}
|
||||
|
|
@ -203,7 +207,7 @@ terminate_instance(P3DInstance *inst) {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DSession::send_command
|
||||
// Access: Private
|
||||
// Access: Public
|
||||
// Description: Sends the indicated command to the running Python
|
||||
// process. If the process has not yet been started,
|
||||
// queues it up until it is ready.
|
||||
|
|
|
|||
|
|
@ -46,8 +46,9 @@ public:
|
|||
|
||||
inline int get_num_instances() const;
|
||||
|
||||
private:
|
||||
void send_command(TiXmlDocument *command);
|
||||
|
||||
private:
|
||||
void start_p3dpython();
|
||||
|
||||
void spawn_read_thread();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,80 @@
|
|||
// Filename: p3dWindowParams.I
|
||||
// Created by: drose (22Jun09)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DWindowParams::get_window_type
|
||||
// Access: Public
|
||||
// Description: Returns the window_type that was passed to the
|
||||
// constructor.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline P3D_window_type P3DWindowParams::
|
||||
get_window_type() const {
|
||||
return _window_type;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DWindowParams::get_window_x
|
||||
// Access: Public
|
||||
// Description: Returns the window origin X coordinate that was
|
||||
// passed to the constructor.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline int P3DWindowParams::
|
||||
get_win_x() const {
|
||||
return _win_x;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DWindowParams::get_win_y
|
||||
// Access: Public
|
||||
// Description: Returns the window origin Y coordinate that was
|
||||
// passed to the constructor.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline int P3DWindowParams::
|
||||
get_win_y() const {
|
||||
return _win_y;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DWindowParams::get_win_width
|
||||
// Access: Public
|
||||
// Description: Returns the window width that was passed to the
|
||||
// constructor.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline int P3DWindowParams::
|
||||
get_win_width() const {
|
||||
return _win_width;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DWindowParams::get_win_height
|
||||
// Access: Public
|
||||
// Description: Returns the window height that was passed to the
|
||||
// constructor.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline int P3DWindowParams::
|
||||
get_win_height() const {
|
||||
return _win_height;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DWindowParams::get_parent_window
|
||||
// Access: Public
|
||||
// Description: Returns the parent window handle that was passed to
|
||||
// the constructor.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline P3D_window_handle P3DWindowParams::
|
||||
get_parent_window() const {
|
||||
return _parent_window;
|
||||
}
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
// Filename: p3dWindowParams.cxx
|
||||
// Created by: drose (22Jun09)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "p3dWindowParams.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DWindowParams::Default Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
P3DWindowParams::
|
||||
P3DWindowParams() :
|
||||
_window_type(P3D_WT_hidden),
|
||||
_win_x(0), _win_y(0),
|
||||
_win_width(0), _win_height(0)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DWindowParams::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
P3DWindowParams::
|
||||
P3DWindowParams(P3D_window_type window_type,
|
||||
int win_x, int win_y,
|
||||
int win_width, int win_height,
|
||||
P3D_window_handle parent_window) :
|
||||
_window_type(window_type),
|
||||
_win_x(win_x), _win_y(win_y),
|
||||
_win_width(win_width), _win_height(win_height),
|
||||
_parent_window(parent_window)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DWindowParams::Copy Assignment
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void P3DWindowParams::
|
||||
operator = (const P3DWindowParams &other) {
|
||||
_window_type = other._window_type;
|
||||
_win_x = other._win_x;
|
||||
_win_y = other._win_y;
|
||||
_win_width = other._win_width;
|
||||
_win_height = other._win_height;
|
||||
_parent_window = other._parent_window;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DWindowParams::make_xml
|
||||
// Access: Public
|
||||
// Description: Returns a newly-allocated XML structure that
|
||||
// corresponds to the window parameter data within this
|
||||
// instance.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
TiXmlElement *P3DWindowParams::
|
||||
make_xml() {
|
||||
TiXmlElement *xwparams = new TiXmlElement("wparams");
|
||||
|
||||
switch (_window_type) {
|
||||
case P3D_WT_embedded:
|
||||
xwparams->SetAttribute("window_type", "embedded");
|
||||
xwparams->SetAttribute("win_x", _win_x);
|
||||
xwparams->SetAttribute("win_y", _win_y);
|
||||
xwparams->SetAttribute("win_width", _win_width);
|
||||
xwparams->SetAttribute("win_height", _win_height);
|
||||
#ifdef _WIN32
|
||||
xwparams->SetAttribute("parent_hwnd", (int)_parent_window._hwnd);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case P3D_WT_toplevel:
|
||||
xwparams->SetAttribute("window_type", "toplevel");
|
||||
xwparams->SetAttribute("win_x", _win_x);
|
||||
xwparams->SetAttribute("win_y", _win_y);
|
||||
xwparams->SetAttribute("win_width", _win_width);
|
||||
xwparams->SetAttribute("win_height", _win_height);
|
||||
break;
|
||||
|
||||
case P3D_WT_fullscreen:
|
||||
xwparams->SetAttribute("window_type", "fullscreen");
|
||||
xwparams->SetAttribute("win_width", _win_width);
|
||||
xwparams->SetAttribute("win_height", _win_height);
|
||||
break;
|
||||
|
||||
case P3D_WT_hidden:
|
||||
xwparams->SetAttribute("window_type", "hidden");
|
||||
break;
|
||||
}
|
||||
|
||||
return xwparams;
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
// Filename: p3dWindowParams.h
|
||||
// Created by: drose (22Jun09)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef P3DWINDOWPARAMS_H
|
||||
#define P3DWINDOWPARAMS_H
|
||||
|
||||
#include "p3d_plugin_common.h"
|
||||
|
||||
#include <tinyxml.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : P3DWindowParams
|
||||
// Description : Encapsulates the window parameters.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class P3DWindowParams {
|
||||
public:
|
||||
P3DWindowParams();
|
||||
P3DWindowParams(P3D_window_type window_type,
|
||||
int win_x, int win_y,
|
||||
int win_width, int win_height,
|
||||
P3D_window_handle parent_window);
|
||||
|
||||
void operator = (const P3DWindowParams &other);
|
||||
|
||||
inline P3D_window_type get_window_type() const;
|
||||
inline int get_win_x() const;
|
||||
inline int get_win_y() const;
|
||||
inline int get_win_width() const;
|
||||
inline int get_win_height() const;
|
||||
inline P3D_window_handle get_parent_window() const;
|
||||
|
||||
TiXmlElement *make_xml();
|
||||
|
||||
private:
|
||||
P3D_window_type _window_type;
|
||||
int _win_x, _win_y;
|
||||
int _win_width, _win_height;
|
||||
P3D_window_handle _parent_window;
|
||||
};
|
||||
|
||||
#include "p3dWindowParams.I"
|
||||
|
||||
#endif
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
#include "p3d_plugin_common.h"
|
||||
#include "p3dInstanceManager.h"
|
||||
#include "p3dInstance.h"
|
||||
#include "p3dWindowParams.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
|
@ -70,10 +71,6 @@ P3D_free_string(char *string) {
|
|||
P3D_instance *
|
||||
P3D_create_instance(P3D_request_ready_func *func,
|
||||
const char *p3d_filename,
|
||||
P3D_window_type window_type,
|
||||
int win_x, int win_y,
|
||||
int win_width, int win_height,
|
||||
P3D_window_handle parent_window,
|
||||
const P3D_token tokens[], size_t num_tokens) {
|
||||
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
|
||||
ACQUIRE_LOCK(_lock);
|
||||
|
|
@ -83,9 +80,7 @@ P3D_create_instance(P3D_request_ready_func *func,
|
|||
}
|
||||
|
||||
P3DInstance *result =
|
||||
inst_mgr->create_instance(func, p3d_filename, window_type,
|
||||
win_x, win_y, win_width, win_height,
|
||||
parent_window, tokens, num_tokens);
|
||||
inst_mgr->create_instance(func, p3d_filename, tokens, num_tokens);
|
||||
RELEASE_LOCK(_lock);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -99,6 +94,21 @@ P3D_instance_finish(P3D_instance *instance) {
|
|||
RELEASE_LOCK(_lock);
|
||||
}
|
||||
|
||||
void
|
||||
P3D_instance_setup_window(P3D_instance *instance,
|
||||
P3D_window_type window_type,
|
||||
int win_x, int win_y,
|
||||
int win_width, int win_height,
|
||||
P3D_window_handle parent_window) {
|
||||
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
|
||||
P3DWindowParams wparams(window_type, win_x, win_y,
|
||||
win_width, win_height, parent_window);
|
||||
|
||||
ACQUIRE_LOCK(_lock);
|
||||
((P3DInstance *)instance)->set_wparams(wparams);
|
||||
RELEASE_LOCK(_lock);
|
||||
}
|
||||
|
||||
bool
|
||||
P3D_instance_has_property(P3D_instance *instance,
|
||||
const char *property_name) {
|
||||
|
|
|
|||
|
|
@ -223,10 +223,6 @@ typedef struct {
|
|||
typedef P3D_instance *
|
||||
P3D_create_instance_func(P3D_request_ready_func *func,
|
||||
const char *p3d_filename,
|
||||
P3D_window_type window_type,
|
||||
int win_x, int win_y,
|
||||
int win_width, int win_height,
|
||||
P3D_window_handle parent_window,
|
||||
const P3D_token tokens[], size_t num_tokens);
|
||||
|
||||
|
||||
|
|
@ -237,6 +233,18 @@ P3D_create_instance_func(P3D_request_ready_func *func,
|
|||
typedef void
|
||||
P3D_instance_finish_func(P3D_instance *instance);
|
||||
|
||||
/* Call this function after creating an instance in order to set its
|
||||
window size and placement. You must call this at least once in
|
||||
order to actually manifest the instance onscreen. This may also be
|
||||
called to reposition a window after its initial placement (e.g. if
|
||||
the browser window has changed width and needs reformatting). */
|
||||
typedef void
|
||||
P3D_instance_setup_window_func(P3D_instance *instance,
|
||||
P3D_window_type window_type,
|
||||
int win_x, int win_y,
|
||||
int win_width, int win_height,
|
||||
P3D_window_handle parent_window);
|
||||
|
||||
|
||||
/********************** SCRIPTING SUPPORT **************************/
|
||||
|
||||
|
|
@ -449,6 +457,7 @@ EXPCL_P3D_PLUGIN P3D_initialize_func P3D_initialize;
|
|||
EXPCL_P3D_PLUGIN P3D_free_string_func P3D_free_string;
|
||||
EXPCL_P3D_PLUGIN P3D_create_instance_func P3D_create_instance;
|
||||
EXPCL_P3D_PLUGIN P3D_instance_finish_func P3D_instance_finish;
|
||||
EXPCL_P3D_PLUGIN P3D_instance_setup_window_func P3D_instance_setup_window;
|
||||
EXPCL_P3D_PLUGIN P3D_instance_has_property_func P3D_instance_has_property;
|
||||
EXPCL_P3D_PLUGIN P3D_instance_get_property_func P3D_instance_get_property;
|
||||
EXPCL_P3D_PLUGIN P3D_instance_set_property_func P3D_instance_set_property;
|
||||
|
|
|
|||
|
|
@ -7,4 +7,5 @@
|
|||
#include "p3dPackage.cxx"
|
||||
#include "p3dProgressWindow.cxx"
|
||||
#include "p3dSession.cxx"
|
||||
#include "p3dWindowParams.cxx"
|
||||
#include "p3dWinProgressWindow.cxx"
|
||||
|
|
|
|||
|
|
@ -15,15 +15,21 @@
|
|||
|
||||
#define SOURCES \
|
||||
nppanda3d_common.h \
|
||||
nppanda3d_startup.h \
|
||||
ppInstance.h ppInstance.I
|
||||
nppanda3d_startup.h
|
||||
|
||||
#define INCLUDED_SOURCES \
|
||||
nppanda3d_startup.cxx \
|
||||
ppInstance.cxx
|
||||
nppanda3d_startup.cxx
|
||||
|
||||
#define WIN_RESOURCE_FILE nppanda3d.rc
|
||||
#define LINKER_DEF_FILE nppanda3d.def
|
||||
// Windows-specific options.
|
||||
#if $[WINDOWS_PLATFORM]
|
||||
#define WIN_RESOURCE_FILE nppanda3d.rc
|
||||
#define LINKER_DEF_FILE nppanda3d.def
|
||||
#endif
|
||||
|
||||
// Mac-specific options.
|
||||
#if $[OSX_PLATFORM]
|
||||
#define LINK_AS_BUNDLE 1
|
||||
#endif
|
||||
|
||||
#define INSTALL_HEADERS
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,147 @@
|
|||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
|
||||
This script constructs the bundle directory structure for the OSX web
|
||||
plugin that is built by the code in this directory. It takes no
|
||||
parameters, and produces the plugin bundle in the same place.
|
||||
|
||||
"""
|
||||
|
||||
# The contents of the Info.plist file.
|
||||
InfoPlist = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en-US</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>nppanda3d</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.panda3d.nppanda3d</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>Panda3D</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BRPL</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>WebPluginName</key>
|
||||
<string>Panda3D Game Engine Plug-In</string>
|
||||
<key>WebPluginDescription</key>
|
||||
<string>Runs 3-D games and interactive applets</string>
|
||||
<key>WebPluginMIMETypes</key>
|
||||
<dict>
|
||||
<key>application/x-panda3d</key>
|
||||
<dict>
|
||||
<key>WebPluginExtensions</key>
|
||||
<array>
|
||||
<string>p3d</string>
|
||||
</array>
|
||||
<key>WebPluginTypeDescription</key>
|
||||
<string>Panda3D applet</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
"""
|
||||
|
||||
# The contents of the source nppanda3d.r file. Apparently Firefox
|
||||
# ignores the Info.plist file, above, and looks only in the .rsrc file
|
||||
# within the bundle, which is compiled from the following source file.
|
||||
ResourceFile = """
|
||||
#include <Carbon/Carbon.r>
|
||||
|
||||
resource 'STR#' (126) {
|
||||
{ "Runs 3-D games and interactive applets",
|
||||
"Panda3D Game Engine Plug-In" }
|
||||
};
|
||||
|
||||
resource 'STR#' (127) {
|
||||
{ "Panda3D applet" }
|
||||
};
|
||||
|
||||
resource 'STR#' (128) {
|
||||
{ "application/x-panda3d", "p3d" }
|
||||
};
|
||||
|
||||
"""
|
||||
|
||||
|
||||
import getopt
|
||||
import sys
|
||||
import os
|
||||
import glob
|
||||
import shutil
|
||||
|
||||
import direct
|
||||
from pandac.PandaModules import Filename
|
||||
|
||||
def usage(code, msg = ''):
|
||||
print >> sys.stderr, __doc__
|
||||
print >> sys.stderr, msg
|
||||
sys.exit(code)
|
||||
|
||||
def makeBundle(startDir):
|
||||
fstartDir = Filename.fromOsSpecific(startDir)
|
||||
|
||||
# First, make sure there is only one Opt?-* directory, to avoid
|
||||
# ambiguity.
|
||||
optDirs = glob.glob(fstartDir.toOsSpecific() + '/Opt?-*')
|
||||
if len(optDirs) == 0:
|
||||
raise StandardError, 'Application has not yet been compiled.'
|
||||
if len(optDirs) > 1:
|
||||
raise StandardError, 'Too many compiled directories; ambiguous.'
|
||||
optDir = optDirs[0]
|
||||
|
||||
# Generate the bundle directory structure
|
||||
bundleFilename = Filename(fstartDir, 'nppanda3d.plugin')
|
||||
plistFilename = Filename(bundleFilename, 'Contents/Info.plist')
|
||||
plistFilename.makeDir()
|
||||
exeFilename = Filename(bundleFilename, 'Contents/MacOS/nppanda3d')
|
||||
exeFilename.makeDir()
|
||||
resourceFilename = Filename(bundleFilename, 'Contents/Resources/nppanda3d.rsrc')
|
||||
resourceFilename.makeDir()
|
||||
|
||||
# Generate the resource file.
|
||||
tfile = Filename.temporary('', 'rsrc')
|
||||
f = open(tfile.toOsSpecific(), 'w')
|
||||
f.write(ResourceFile)
|
||||
f.close()
|
||||
|
||||
os.system('/Developer/usr/bin/Rez -useDF -o %s %s' % (
|
||||
resourceFilename.toOsSpecific(), tfile.toOsSpecific()))
|
||||
tfile.unlink()
|
||||
|
||||
if not resourceFilename.exists():
|
||||
raise IOError, 'Unable to run Rez'
|
||||
|
||||
# Generate the Info.plist file.
|
||||
f = open(plistFilename.toOsSpecific(), 'w')
|
||||
f.write(InfoPlist)
|
||||
f.close()
|
||||
|
||||
# Copy in the compiled executable.
|
||||
shutil.copyfile(optDir + '/nppanda3d', exeFilename.toOsSpecific())
|
||||
|
||||
# All done!
|
||||
bundleFilename.touch()
|
||||
print bundleFilename.toOsSpecific()
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], 'h')
|
||||
except getopt.error, msg:
|
||||
usage(1, msg)
|
||||
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
usage(0)
|
||||
|
||||
if args:
|
||||
usage(1, 'No arguments are expected.')
|
||||
|
||||
startDir = os.path.split(sys.argv[0])[0]
|
||||
makeBundle(startDir)
|
||||
|
||||
|
|
@ -1,320 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Main plugin entry point implementation -- exports from the
|
||||
// plugin library
|
||||
//
|
||||
#include "npplat.h"
|
||||
#include "pluginbase.h"
|
||||
|
||||
NPNetscapeFuncs NPNFuncs;
|
||||
|
||||
NPError OSCALL NP_Shutdown()
|
||||
{
|
||||
NS_PluginShutdown();
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
static NPError fillPluginFunctionTable(NPPluginFuncs* aNPPFuncs)
|
||||
{
|
||||
if(aNPPFuncs == NULL)
|
||||
return NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
|
||||
// Set up the plugin function table that Netscape will use to
|
||||
// call us. Netscape needs to know about our version and size
|
||||
// and have a UniversalProcPointer for every function we implement.
|
||||
|
||||
aNPPFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
|
||||
#ifdef XP_MAC
|
||||
aNPPFuncs->newp = NewNPP_NewProc(Private_New);
|
||||
aNPPFuncs->destroy = NewNPP_DestroyProc(Private_Destroy);
|
||||
aNPPFuncs->setwindow = NewNPP_SetWindowProc(Private_SetWindow);
|
||||
aNPPFuncs->newstream = NewNPP_NewStreamProc(Private_NewStream);
|
||||
aNPPFuncs->destroystream = NewNPP_DestroyStreamProc(Private_DestroyStream);
|
||||
aNPPFuncs->asfile = NewNPP_StreamAsFileProc(Private_StreamAsFile);
|
||||
aNPPFuncs->writeready = NewNPP_WriteReadyProc(Private_WriteReady);
|
||||
aNPPFuncs->write = NewNPP_WriteProc(Private_Write);
|
||||
aNPPFuncs->print = NewNPP_PrintProc(Private_Print);
|
||||
aNPPFuncs->event = NewNPP_HandleEventProc(Private_HandleEvent);
|
||||
aNPPFuncs->urlnotify = NewNPP_URLNotifyProc(Private_URLNotify);
|
||||
aNPPFuncs->getvalue = NewNPP_GetValueProc(Private_GetValue);
|
||||
aNPPFuncs->setvalue = NewNPP_SetValueProc(Private_SetValue);
|
||||
#else
|
||||
aNPPFuncs->newp = NPP_New;
|
||||
aNPPFuncs->destroy = NPP_Destroy;
|
||||
aNPPFuncs->setwindow = NPP_SetWindow;
|
||||
aNPPFuncs->newstream = NPP_NewStream;
|
||||
aNPPFuncs->destroystream = NPP_DestroyStream;
|
||||
aNPPFuncs->asfile = NPP_StreamAsFile;
|
||||
aNPPFuncs->writeready = NPP_WriteReady;
|
||||
aNPPFuncs->write = NPP_Write;
|
||||
aNPPFuncs->print = NPP_Print;
|
||||
aNPPFuncs->event = NPP_HandleEvent;
|
||||
aNPPFuncs->urlnotify = NPP_URLNotify;
|
||||
aNPPFuncs->getvalue = NPP_GetValue;
|
||||
aNPPFuncs->setvalue = NPP_SetValue;
|
||||
#endif
|
||||
#ifdef OJI
|
||||
aNPPFuncs->javaClass = NULL;
|
||||
#endif
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
static NPError fillNetscapeFunctionTable(NPNetscapeFuncs* aNPNFuncs)
|
||||
{
|
||||
if(aNPNFuncs == NULL)
|
||||
return NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
|
||||
if(HIBYTE(aNPNFuncs->version) > NP_VERSION_MAJOR)
|
||||
return NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
|
||||
if(aNPNFuncs->size < sizeof(NPNetscapeFuncs))
|
||||
return NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
|
||||
NPNFuncs.size = aNPNFuncs->size;
|
||||
NPNFuncs.version = aNPNFuncs->version;
|
||||
NPNFuncs.geturlnotify = aNPNFuncs->geturlnotify;
|
||||
NPNFuncs.geturl = aNPNFuncs->geturl;
|
||||
NPNFuncs.posturlnotify = aNPNFuncs->posturlnotify;
|
||||
NPNFuncs.posturl = aNPNFuncs->posturl;
|
||||
NPNFuncs.requestread = aNPNFuncs->requestread;
|
||||
NPNFuncs.newstream = aNPNFuncs->newstream;
|
||||
NPNFuncs.write = aNPNFuncs->write;
|
||||
NPNFuncs.destroystream = aNPNFuncs->destroystream;
|
||||
NPNFuncs.status = aNPNFuncs->status;
|
||||
NPNFuncs.uagent = aNPNFuncs->uagent;
|
||||
NPNFuncs.memalloc = aNPNFuncs->memalloc;
|
||||
NPNFuncs.memfree = aNPNFuncs->memfree;
|
||||
NPNFuncs.memflush = aNPNFuncs->memflush;
|
||||
NPNFuncs.reloadplugins = aNPNFuncs->reloadplugins;
|
||||
#ifdef OJI
|
||||
NPNFuncs.getJavaEnv = aNPNFuncs->getJavaEnv;
|
||||
NPNFuncs.getJavaPeer = aNPNFuncs->getJavaPeer;
|
||||
#endif
|
||||
NPNFuncs.getvalue = aNPNFuncs->getvalue;
|
||||
NPNFuncs.setvalue = aNPNFuncs->setvalue;
|
||||
NPNFuncs.invalidaterect = aNPNFuncs->invalidaterect;
|
||||
NPNFuncs.invalidateregion = aNPNFuncs->invalidateregion;
|
||||
NPNFuncs.forceredraw = aNPNFuncs->forceredraw;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Some exports are different on different platforms
|
||||
//
|
||||
|
||||
/**************************************************/
|
||||
/* */
|
||||
/* Windows */
|
||||
/* */
|
||||
/**************************************************/
|
||||
#ifdef XP_WIN
|
||||
|
||||
NPError OSCALL NP_Initialize(NPNetscapeFuncs* aNPNFuncs)
|
||||
{
|
||||
NPError rv = fillNetscapeFunctionTable(aNPNFuncs);
|
||||
if(rv != NPERR_NO_ERROR)
|
||||
return rv;
|
||||
|
||||
return NS_PluginInitialize();
|
||||
}
|
||||
|
||||
NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* aNPPFuncs)
|
||||
{
|
||||
return fillPluginFunctionTable(aNPPFuncs);
|
||||
}
|
||||
|
||||
#endif //XP_WIN
|
||||
|
||||
/**************************************************/
|
||||
/* */
|
||||
/* Unix */
|
||||
/* */
|
||||
/**************************************************/
|
||||
#ifdef XP_UNIX
|
||||
|
||||
NPError NP_Initialize(NPNetscapeFuncs* aNPNFuncs, NPPluginFuncs* aNPPFuncs)
|
||||
{
|
||||
NPError rv = fillNetscapeFunctionTable(aNPNFuncs);
|
||||
if(rv != NPERR_NO_ERROR)
|
||||
return rv;
|
||||
|
||||
rv = fillPluginFunctionTable(aNPPFuncs);
|
||||
if(rv != NPERR_NO_ERROR)
|
||||
return rv;
|
||||
|
||||
return NS_PluginInitialize();
|
||||
}
|
||||
|
||||
char * NP_GetMIMEDescription(void)
|
||||
{
|
||||
return NPP_GetMIMEDescription();
|
||||
}
|
||||
|
||||
NPError NP_GetValue(void *future, NPPVariable aVariable, void *aValue)
|
||||
{
|
||||
return NS_PluginGetValue(aVariable, aValue);
|
||||
}
|
||||
|
||||
#endif //XP_UNIX
|
||||
|
||||
/**************************************************/
|
||||
/* */
|
||||
/* Mac */
|
||||
/* */
|
||||
/**************************************************/
|
||||
#ifdef XP_MAC
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
QDGlobals* gQDPtr; // Pointer to Netscape's QuickDraw globals
|
||||
#endif
|
||||
|
||||
short gResFile; // Refnum of the plugin's resource file
|
||||
|
||||
NPError Private_Initialize(void)
|
||||
{
|
||||
NPError rv = NS_PluginInitialize();
|
||||
return rv;
|
||||
}
|
||||
|
||||
void Private_Shutdown(void)
|
||||
{
|
||||
NS_PluginShutdown();
|
||||
__destroy_global_chain();
|
||||
}
|
||||
|
||||
void SetUpQD(void);
|
||||
|
||||
void SetUpQD(void)
|
||||
{
|
||||
ProcessSerialNumber PSN;
|
||||
FSSpec myFSSpec;
|
||||
Str63 name;
|
||||
ProcessInfoRec infoRec;
|
||||
OSErr result = noErr;
|
||||
CFragConnectionID connID;
|
||||
Str255 errName;
|
||||
|
||||
// Memorize the plugin¹s resource file refnum for later use.
|
||||
gResFile = CurResFile();
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
// Ask the system if CFM is available.
|
||||
long response;
|
||||
OSErr err = Gestalt(gestaltCFMAttr, &response);
|
||||
Boolean hasCFM = BitTst(&response, 31-gestaltCFMPresent);
|
||||
|
||||
if (hasCFM) {
|
||||
// GetProcessInformation takes a process serial number and
|
||||
// will give us back the name and FSSpec of the application.
|
||||
// See the Process Manager in IM.
|
||||
infoRec.processInfoLength = sizeof(ProcessInfoRec);
|
||||
infoRec.processName = name;
|
||||
infoRec.processAppSpec = &myFSSpec;
|
||||
|
||||
PSN.highLongOfPSN = 0;
|
||||
PSN.lowLongOfPSN = kCurrentProcess;
|
||||
|
||||
result = GetProcessInformation(&PSN, &infoRec);
|
||||
}
|
||||
else
|
||||
// If no CFM installed, assume it must be a 68K app.
|
||||
result = -1;
|
||||
|
||||
if (result == noErr) {
|
||||
// Now that we know the app name and FSSpec, we can call GetDiskFragment
|
||||
// to get a connID to use in a subsequent call to FindSymbol (it will also
|
||||
// return the address of ³main² in app, which we ignore). If GetDiskFragment
|
||||
// returns an error, we assume the app must be 68K.
|
||||
Ptr mainAddr;
|
||||
result = GetDiskFragment(infoRec.processAppSpec, 0L, 0L, infoRec.processName,
|
||||
kReferenceCFrag, &connID, (Ptr*)&mainAddr, errName);
|
||||
}
|
||||
|
||||
if (result == noErr) {
|
||||
// The app is a PPC code fragment, so call FindSymbol
|
||||
// to get the exported ³qd² symbol so we can access its
|
||||
// QuickDraw globals.
|
||||
CFragSymbolClass symClass;
|
||||
result = FindSymbol(connID, "\pqd", (Ptr*)&gQDPtr, &symClass);
|
||||
}
|
||||
else {
|
||||
// The app is 68K, so use its A5 to compute the address
|
||||
// of its QuickDraw globals.
|
||||
gQDPtr = (QDGlobals*)(*((long*)SetCurrentA5()) - (sizeof(QDGlobals) - sizeof(GrafPtr)));
|
||||
}
|
||||
#endif /* !TARGET_API_MAC_CARBON */
|
||||
}
|
||||
|
||||
NPError main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp);
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
#pragma export on
|
||||
#if GENERATINGCFM
|
||||
RoutineDescriptor mainRD = BUILD_ROUTINE_DESCRIPTOR(uppNPP_MainEntryProcInfo, main);
|
||||
#endif
|
||||
#pragma export off
|
||||
#endif /* !TARGET_API_MAC_CARBON */
|
||||
|
||||
|
||||
NPError main(NPNetscapeFuncs* aNPNFuncs, NPPluginFuncs* aNPPFuncs, NPP_ShutdownUPP* aUnloadUpp)
|
||||
{
|
||||
NPError rv = NPERR_NO_ERROR;
|
||||
|
||||
if (aUnloadUpp == NULL)
|
||||
rv = NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
|
||||
if (rv == NPERR_NO_ERROR)
|
||||
rv = fillNetscapeFunctionTable(aNPNFuncs);
|
||||
|
||||
if (rv == NPERR_NO_ERROR) {
|
||||
// defer static constructors until the global functions are initialized.
|
||||
__InitCode__();
|
||||
rv = fillPluginFunctionTable(aNPPFuncs);
|
||||
}
|
||||
|
||||
*aUnloadUpp = NewNPP_ShutdownProc(Private_Shutdown);
|
||||
SetUpQD();
|
||||
rv = Private_Initialize();
|
||||
|
||||
return rv;
|
||||
}
|
||||
#endif //XP_MAC
|
||||
|
|
@ -1,215 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Implementation of Netscape entry points (NPN_*)
|
||||
//
|
||||
#include "npplat.h"
|
||||
|
||||
extern NPNetscapeFuncs NPNFuncs;
|
||||
|
||||
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
|
||||
{
|
||||
*plugin_major = NP_VERSION_MAJOR;
|
||||
*plugin_minor = NP_VERSION_MINOR;
|
||||
*netscape_major = HIBYTE(NPNFuncs.version);
|
||||
*netscape_minor = LOBYTE(NPNFuncs.version);
|
||||
}
|
||||
|
||||
NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
|
||||
{
|
||||
int navMinorVers = NPNFuncs.version & 0xFF;
|
||||
NPError rv = NPERR_NO_ERROR;
|
||||
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
|
||||
rv = CallNPN_GetURLNotifyProc(NPNFuncs.geturlnotify, instance, url, target, notifyData);
|
||||
else
|
||||
rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NPError NPN_GetURL(NPP instance, const char *url, const char *target)
|
||||
{
|
||||
NPError rv = CallNPN_GetURLProc(NPNFuncs.geturl, instance, url, target);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
|
||||
{
|
||||
int navMinorVers = NPNFuncs.version & 0xFF;
|
||||
NPError rv = NPERR_NO_ERROR;
|
||||
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
|
||||
rv = CallNPN_PostURLNotifyProc(NPNFuncs.posturlnotify, instance, url, window, len, buf, file, notifyData);
|
||||
else
|
||||
rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
|
||||
{
|
||||
NPError rv = CallNPN_PostURLProc(NPNFuncs.posturl, instance, url, window, len, buf, file);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
|
||||
{
|
||||
NPError rv = CallNPN_RequestReadProc(NPNFuncs.requestread, stream, rangeList);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
|
||||
{
|
||||
int navMinorVersion = NPNFuncs.version & 0xFF;
|
||||
|
||||
NPError rv = NPERR_NO_ERROR;
|
||||
|
||||
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
|
||||
rv = CallNPN_NewStreamProc(NPNFuncs.newstream, instance, type, target, stream);
|
||||
else
|
||||
rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int32 NPN_Write(NPP instance, NPStream *stream, int32 len, void *buffer)
|
||||
{
|
||||
int navMinorVersion = NPNFuncs.version & 0xFF;
|
||||
int32 rv = 0;
|
||||
|
||||
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
|
||||
rv = CallNPN_WriteProc(NPNFuncs.write, instance, stream, len, buffer);
|
||||
else
|
||||
rv = -1;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
|
||||
{
|
||||
int navMinorVersion = NPNFuncs.version & 0xFF;
|
||||
NPError rv = NPERR_NO_ERROR;
|
||||
|
||||
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
|
||||
rv = CallNPN_DestroyStreamProc(NPNFuncs.destroystream, instance, stream, reason);
|
||||
else
|
||||
rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void NPN_Status(NPP instance, const char *message)
|
||||
{
|
||||
CallNPN_StatusProc(NPNFuncs.status, instance, message);
|
||||
}
|
||||
|
||||
const char* NPN_UserAgent(NPP instance)
|
||||
{
|
||||
const char * rv = NULL;
|
||||
rv = CallNPN_UserAgentProc(NPNFuncs.uagent, instance);
|
||||
return rv;
|
||||
}
|
||||
|
||||
void* NPN_MemAlloc(uint32 size)
|
||||
{
|
||||
void * rv = NULL;
|
||||
rv = CallNPN_MemAllocProc(NPNFuncs.memalloc, size);
|
||||
return rv;
|
||||
}
|
||||
|
||||
void NPN_MemFree(void* ptr)
|
||||
{
|
||||
CallNPN_MemFreeProc(NPNFuncs.memfree, ptr);
|
||||
}
|
||||
|
||||
uint32 NPN_MemFlush(uint32 size)
|
||||
{
|
||||
uint32 rv = CallNPN_MemFlushProc(NPNFuncs.memflush, size);
|
||||
return rv;
|
||||
}
|
||||
|
||||
void NPN_ReloadPlugins(NPBool reloadPages)
|
||||
{
|
||||
CallNPN_ReloadPluginsProc(NPNFuncs.reloadplugins, reloadPages);
|
||||
}
|
||||
|
||||
#ifdef OJI
|
||||
JRIEnv* NPN_GetJavaEnv(void)
|
||||
{
|
||||
JRIEnv * rv = NULL;
|
||||
rv = CallNPN_GetJavaEnvProc(NPNFuncs.getJavaEnv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
jref NPN_GetJavaPeer(NPP instance)
|
||||
{
|
||||
jref rv;
|
||||
rv = CallNPN_GetJavaPeerProc(NPNFuncs.getJavaPeer, instance);
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
|
||||
{
|
||||
NPError rv = CallNPN_GetValueProc(NPNFuncs.getvalue, instance, variable, value);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
|
||||
{
|
||||
NPError rv = CallNPN_SetValueProc(NPNFuncs.setvalue, instance, variable, value);
|
||||
return rv;
|
||||
}
|
||||
|
||||
void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
|
||||
{
|
||||
CallNPN_InvalidateRectProc(NPNFuncs.invalidaterect, instance, invalidRect);
|
||||
}
|
||||
|
||||
void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
|
||||
{
|
||||
CallNPN_InvalidateRegionProc(NPNFuncs.invalidateregion, instance, invalidRegion);
|
||||
}
|
||||
|
||||
void NPN_ForceRedraw(NPP instance)
|
||||
{
|
||||
CallNPN_ForceRedrawProc(NPNFuncs.forceredraw, instance);
|
||||
}
|
||||
|
|
@ -1,358 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Implementation of plugin entry points (NPP_*)
|
||||
//
|
||||
#include "pluginbase.h"
|
||||
|
||||
// here the plugin creates a plugin instance object which
|
||||
// will be associated with this newly created NPP instance and
|
||||
// will do all the neccessary job
|
||||
NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
|
||||
{
|
||||
if(instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
NPError rv = NPERR_NO_ERROR;
|
||||
|
||||
// create a new plugin instance object
|
||||
// initialization will be done when the associated window is ready
|
||||
nsPluginCreateData ds;
|
||||
|
||||
ds.instance = instance;
|
||||
ds.type = pluginType;
|
||||
ds.mode = mode;
|
||||
ds.argc = argc;
|
||||
ds.argn = argn;
|
||||
ds.argv = argv;
|
||||
ds.saved = saved;
|
||||
|
||||
nsPluginInstanceBase * plugin = NS_NewPluginInstance(&ds);
|
||||
if(plugin == NULL)
|
||||
return NPERR_OUT_OF_MEMORY_ERROR;
|
||||
|
||||
// associate the plugin instance object with NPP instance
|
||||
instance->pdata = (void *)plugin;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// here is the place to clean up and destroy the nsPluginInstance object
|
||||
NPError NPP_Destroy (NPP instance, NPSavedData** save)
|
||||
{
|
||||
if(instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
NPError rv = NPERR_NO_ERROR;
|
||||
|
||||
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
|
||||
if(plugin != NULL) {
|
||||
plugin->shut();
|
||||
NS_DestroyPluginInstance(plugin);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// during this call we know when the plugin window is ready or
|
||||
// is about to be destroyed so we can do some gui specific
|
||||
// initialization and shutdown
|
||||
NPError NPP_SetWindow (NPP instance, NPWindow* pNPWindow)
|
||||
{
|
||||
if(instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
NPError rv = NPERR_NO_ERROR;
|
||||
|
||||
if(pNPWindow == NULL)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
|
||||
|
||||
if(plugin == NULL)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
// window just created
|
||||
if(!plugin->isInitialized() && (pNPWindow->window != NULL)) {
|
||||
if(!plugin->init(pNPWindow)) {
|
||||
NS_DestroyPluginInstance(plugin);
|
||||
return NPERR_MODULE_LOAD_FAILED_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// window goes away
|
||||
if((pNPWindow->window == NULL) && plugin->isInitialized())
|
||||
return plugin->SetWindow(pNPWindow);
|
||||
|
||||
// window resized?
|
||||
if(plugin->isInitialized() && (pNPWindow->window != NULL))
|
||||
return plugin->SetWindow(pNPWindow);
|
||||
|
||||
// this should not happen, nothing to do
|
||||
if((pNPWindow->window == NULL) && !plugin->isInitialized())
|
||||
return plugin->SetWindow(pNPWindow);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype)
|
||||
{
|
||||
if(instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
|
||||
if(plugin == NULL)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
NPError rv = plugin->NewStream(type, stream, seekable, stype);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int32 NPP_WriteReady (NPP instance, NPStream *stream)
|
||||
{
|
||||
if(instance == NULL)
|
||||
return 0x0fffffff;
|
||||
|
||||
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
|
||||
if(plugin == NULL)
|
||||
return 0x0fffffff;
|
||||
|
||||
int32 rv = plugin->WriteReady(stream);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int32 NPP_Write (NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
|
||||
{
|
||||
if(instance == NULL)
|
||||
return len;
|
||||
|
||||
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
|
||||
if(plugin == NULL)
|
||||
return len;
|
||||
|
||||
int32 rv = plugin->Write(stream, offset, len, buffer);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NPError NPP_DestroyStream (NPP instance, NPStream *stream, NPError reason)
|
||||
{
|
||||
if(instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
|
||||
if(plugin == NULL)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
NPError rv = plugin->DestroyStream(stream, reason);
|
||||
return rv;
|
||||
}
|
||||
|
||||
void NPP_StreamAsFile (NPP instance, NPStream* stream, const char* fname)
|
||||
{
|
||||
if(instance == NULL)
|
||||
return;
|
||||
|
||||
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
|
||||
if(plugin == NULL)
|
||||
return;
|
||||
|
||||
plugin->StreamAsFile(stream, fname);
|
||||
}
|
||||
|
||||
void NPP_Print (NPP instance, NPPrint* printInfo)
|
||||
{
|
||||
if(instance == NULL)
|
||||
return;
|
||||
|
||||
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
|
||||
if(plugin == NULL)
|
||||
return;
|
||||
|
||||
plugin->Print(printInfo);
|
||||
}
|
||||
|
||||
void NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
|
||||
{
|
||||
if(instance == NULL)
|
||||
return;
|
||||
|
||||
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
|
||||
if(plugin == NULL)
|
||||
return;
|
||||
|
||||
plugin->URLNotify(url, reason, notifyData);
|
||||
}
|
||||
|
||||
NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)
|
||||
{
|
||||
if(instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
|
||||
if(plugin == NULL)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
NPError rv = plugin->GetValue(variable, value);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value)
|
||||
{
|
||||
if(instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
|
||||
if(plugin == NULL)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
NPError rv = plugin->SetValue(variable, value);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int16 NPP_HandleEvent(NPP instance, void* event)
|
||||
{
|
||||
if(instance == NULL)
|
||||
return 0;
|
||||
|
||||
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
|
||||
if(plugin == NULL)
|
||||
return 0;
|
||||
|
||||
uint16 rv = plugin->HandleEvent(event);
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef OJI
|
||||
jref NPP_GetJavaClass (void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**************************************************/
|
||||
/* */
|
||||
/* Mac */
|
||||
/* */
|
||||
/**************************************************/
|
||||
|
||||
// Mac needs these wrappers, see npplat.h for more info
|
||||
|
||||
#ifdef XP_MAC
|
||||
|
||||
NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
|
||||
{
|
||||
NPError rv = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NPError Private_Destroy(NPP instance, NPSavedData** save)
|
||||
{
|
||||
NPError rv = NPP_Destroy(instance, save);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NPError Private_SetWindow(NPP instance, NPWindow* window)
|
||||
{
|
||||
NPError rv = NPP_SetWindow(instance, window);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype)
|
||||
{
|
||||
NPError rv = NPP_NewStream(instance, type, stream, seekable, stype);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int32 Private_WriteReady(NPP instance, NPStream* stream)
|
||||
{
|
||||
int32 rv = NPP_WriteReady(instance, stream);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int32 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer)
|
||||
{
|
||||
int32 rv = NPP_Write(instance, stream, offset, len, buffer);
|
||||
return rv;
|
||||
}
|
||||
|
||||
void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
|
||||
{
|
||||
NPP_StreamAsFile(instance, stream, fname);
|
||||
}
|
||||
|
||||
|
||||
NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
|
||||
{
|
||||
NPError rv = NPP_DestroyStream(instance, stream, reason);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int16 Private_HandleEvent(NPP instance, void* event)
|
||||
{
|
||||
int16 rv = NPP_HandleEvent(instance, event);
|
||||
return rv;
|
||||
}
|
||||
|
||||
void Private_Print(NPP instance, NPPrint* platformPrint)
|
||||
{
|
||||
NPP_Print(instance, platformPrint);
|
||||
}
|
||||
|
||||
void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
|
||||
{
|
||||
NPP_URLNotify(instance, url, reason, notifyData);
|
||||
}
|
||||
|
||||
jref Private_GetJavaClass(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NPError Private_GetValue(NPP instance, NPPVariable variable, void *result)
|
||||
{
|
||||
NPError rv = NPP_GetValue(instance, variable, result);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NPError Private_SetValue(NPP instance, NPNVariable variable, void *value)
|
||||
{
|
||||
NPError rv = NPP_SetValue(instance, variable, value);
|
||||
return rv;
|
||||
}
|
||||
|
||||
#endif //XP_MAC
|
||||
|
|
@ -44,7 +44,7 @@ BEGIN
|
|||
VALUE "MIMEType", "application/x-panda3d\0"
|
||||
VALUE "OriginalFilename", "nppanda3d.dll\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "Panda3D Example Plugin for Mozilla\0"
|
||||
VALUE "ProductName", "Panda3D Game Engine Plug-in\0"
|
||||
VALUE "ProductVersion", "1, 0, 0, 1\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@
|
|||
using namespace std;
|
||||
|
||||
// Appears in nppanda3d_startup.cxx.
|
||||
extern ofstream log;
|
||||
extern ofstream logfile;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
// Gecko requires all these symbols to be defined.
|
||||
// Gecko requires all these symbols to be defined for Windows.
|
||||
#define MOZILLA_STRICT_API
|
||||
#define XP_WIN
|
||||
#define _X86_
|
||||
|
|
@ -46,7 +46,16 @@ extern ofstream log;
|
|||
|
||||
#include <windows.h>
|
||||
|
||||
#endif // _WIN32
|
||||
#else defined(__APPLE__)
|
||||
|
||||
// On Mac, Gecko requires this symbol to be defined.
|
||||
#define XP_MACOSX
|
||||
|
||||
#endif // _WIN32, __APPLE__
|
||||
|
||||
#include "npapi.h"
|
||||
#include "npfunctions.h"
|
||||
//#include "npupp.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
#include "nppanda3d_startup.cxx"
|
||||
#include "ppInstance.cxx"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,53 +13,186 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "nppanda3d_startup.h"
|
||||
#include "ppInstance.h"
|
||||
|
||||
// These source files are part of the Gecko SDK, sort of. They're
|
||||
// distributed with the sample applications. They provide a
|
||||
// higher-level wrapper around some of the NPAPI startup stuff, and
|
||||
// this appears to be the intended way to use the Gecko SDK. It's a
|
||||
// weird system.
|
||||
#include "npplat.h"
|
||||
#include "pluginbase.h"
|
||||
#include "np_entry.cpp"
|
||||
#include "npn_gate.cpp"
|
||||
#include "npp_gate.cpp"
|
||||
|
||||
#include "../plugin/load_plugin_src.cxx"
|
||||
|
||||
ofstream log;
|
||||
ofstream logfile;
|
||||
bool logfile_is_open = false;
|
||||
static void
|
||||
open_logfile() {
|
||||
if (!logfile_is_open) {
|
||||
#ifdef _WIN32
|
||||
logfile.open("c:/cygwin/home/drose/t.log");
|
||||
#else
|
||||
logfile.open("/Users/drose/t.log");
|
||||
#endif
|
||||
logfile_is_open = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// structure containing pointers to functions implemented by the browser
|
||||
static NPNetscapeFuncs *browser;
|
||||
|
||||
// Symbol called once by the browser to initialize the plugin
|
||||
NPError
|
||||
NS_PluginInitialize() {
|
||||
log.open("c:/cygwin/home/drose/t.log");
|
||||
log << "initializing\n" << flush;
|
||||
NP_Initialize(NPNetscapeFuncs *browserFuncs) {
|
||||
// save away browser functions
|
||||
browser = browserFuncs;
|
||||
|
||||
if (!load_plugin("")) {
|
||||
log << "couldn't load plugin\n" << flush;
|
||||
open_logfile();
|
||||
logfile << "initializing\n" << flush;
|
||||
|
||||
logfile << "browserFuncs = " << browserFuncs << "\n" << flush;
|
||||
|
||||
string plugin_location = "/Users/drose/player/direct/built/lib/libp3d_plugin.dylib";
|
||||
|
||||
if (!load_plugin(plugin_location.c_str())) {
|
||||
logfile << "couldn't load plugin\n" << flush;
|
||||
return NPERR_INVALID_PLUGIN_ERROR;
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
void
|
||||
NS_PluginShutdown() {
|
||||
log << "shutdown\n" << flush;
|
||||
// Symbol called by the browser to get the plugin's function list
|
||||
NPError
|
||||
NP_GetEntryPoints(NPPluginFuncs *pluginFuncs) {
|
||||
open_logfile();
|
||||
logfile << "NP_GetEntryPoints, pluginFuncs = " << pluginFuncs << "\n"
|
||||
<< flush;
|
||||
pluginFuncs->version = 11;
|
||||
pluginFuncs->size = sizeof(pluginFuncs);
|
||||
pluginFuncs->newp = NPP_New;
|
||||
pluginFuncs->destroy = NPP_Destroy;
|
||||
pluginFuncs->setwindow = NPP_SetWindow;
|
||||
pluginFuncs->newstream = NPP_NewStream;
|
||||
pluginFuncs->destroystream = NPP_DestroyStream;
|
||||
pluginFuncs->asfile = NPP_StreamAsFile;
|
||||
pluginFuncs->writeready = NPP_WriteReady;
|
||||
pluginFuncs->write = NPP_Write;
|
||||
pluginFuncs->print = NPP_Print;
|
||||
pluginFuncs->event = NPP_HandleEvent;
|
||||
pluginFuncs->urlnotify = NPP_URLNotify;
|
||||
pluginFuncs->getvalue = NPP_GetValue;
|
||||
pluginFuncs->setvalue = NPP_SetValue;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
// Symbol called once by the browser to shut down the plugin
|
||||
NPError
|
||||
NP_Shutdown(void) {
|
||||
logfile << "shutdown\n" << flush;
|
||||
unload_plugin();
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
// Called to create a new instance of the plugin
|
||||
NPError
|
||||
NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode,
|
||||
int16_t argc, char *argn[], char *argv[], NPSavedData *saved) {
|
||||
logfile << "new instance\n" << flush;
|
||||
|
||||
// Copy the tokens into a temporary array of P3D_token objects.
|
||||
P3D_token *tokens = (P3D_token *)alloca(sizeof(P3D_token) * argc);
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
P3D_token &token = tokens[i];
|
||||
token._keyword = argn[i];
|
||||
token._value = argv[i];
|
||||
logfile << " " << i << ": " << token._keyword << " = " << token._value << "\n";
|
||||
}
|
||||
|
||||
instance->pdata = P3D_create_instance(NULL, NULL, tokens, argc);
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
// Called to destroy an instance of the plugin
|
||||
NPError
|
||||
NPP_Destroy(NPP instance, NPSavedData **save) {
|
||||
logfile << "destroy instance\n" << flush;
|
||||
(*save) = NULL;
|
||||
P3D_instance_finish((P3D_instance *)(instance->pdata));
|
||||
instance->pdata = NULL;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
// Called to update a plugin instances's NPWindow
|
||||
NPError
|
||||
NPP_SetWindow(NPP instance, NPWindow *window) {
|
||||
logfile << "SetWindow " << window->x << ", " << window->y
|
||||
<< ", " << window->width << ", " << window->height
|
||||
<< "\n" << flush;
|
||||
|
||||
P3D_instance *inst = (P3D_instance *)(instance->pdata);
|
||||
assert(inst != NULL);
|
||||
|
||||
P3D_window_handle parent_window;
|
||||
#ifdef _WIN32
|
||||
FreeLibrary(module);
|
||||
module = NULL;
|
||||
parent_window._hwnd = (HWND)(window->window);
|
||||
#endif
|
||||
|
||||
P3D_window_type window_type = P3D_WT_embedded;
|
||||
|
||||
P3D_instance_setup_window
|
||||
(inst, window_type,
|
||||
window->x, window->y, window->width, window->height,
|
||||
parent_window);
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
nsPluginInstanceBase *
|
||||
NS_NewPluginInstance(nsPluginCreateData *create_data) {
|
||||
log << "new instance\n" << flush;
|
||||
return new PPInstance(create_data);
|
||||
|
||||
NPError
|
||||
NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream,
|
||||
NPBool seekable, uint16_t *stype) {
|
||||
*stype = NP_ASFILEONLY;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
NPError
|
||||
NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason) {
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t
|
||||
NPP_WriteReady(NPP instance, NPStream *stream) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t
|
||||
NPP_Write(NPP instance, NPStream *stream, int32_t offset,
|
||||
int32_t len, void *buffer) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
NS_DestroyPluginInstance(nsPluginInstanceBase *plugin) {
|
||||
log << "destroy instance\n" << flush;
|
||||
delete (PPInstance *)plugin;
|
||||
NPP_StreamAsFile(NPP instance, NPStream *stream, const char *fname) {
|
||||
}
|
||||
|
||||
void
|
||||
NPP_Print(NPP instance, NPPrint *platformPrint) {
|
||||
}
|
||||
|
||||
int16_t
|
||||
NPP_HandleEvent(NPP instance, void *event) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
NPP_URLNotify(NPP instance, const char *url,
|
||||
NPReason reason, void *notifyData) {
|
||||
}
|
||||
|
||||
NPError
|
||||
NPP_GetValue(NPP instance, NPPVariable variable, void *value) {
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
NPError
|
||||
NPP_SetValue(NPP instance, NPNVariable variable, void *value) {
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,4 +19,10 @@
|
|||
|
||||
#include "../plugin/load_plugin_src.h"
|
||||
|
||||
extern "C" {
|
||||
NPError NP_Initialize(NPNetscapeFuncs *browserFuncs);
|
||||
NPError NP_GetEntryPoints(NPPluginFuncs *pluginFuncs);
|
||||
NPError NP_Shutdown(void);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,150 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _NPPLAT_H_
|
||||
#define _NPPLAT_H_
|
||||
|
||||
#include "npapi.h"
|
||||
#include "npupp.h"
|
||||
|
||||
/**************************************************/
|
||||
/* */
|
||||
/* Windows */
|
||||
/* */
|
||||
/**************************************************/
|
||||
#ifdef XP_WIN
|
||||
#include "windows.h"
|
||||
#endif //XP_WIN
|
||||
|
||||
/**************************************************/
|
||||
/* */
|
||||
/* Unix */
|
||||
/* */
|
||||
/**************************************************/
|
||||
#ifdef XP_UNIX
|
||||
#include <stdio.h>
|
||||
#endif //XP_UNIX
|
||||
|
||||
/**************************************************/
|
||||
/* */
|
||||
/* Mac */
|
||||
/* */
|
||||
/**************************************************/
|
||||
#ifdef XP_MAC
|
||||
|
||||
#include <Processes.h>
|
||||
#include <Gestalt.h>
|
||||
#include <CodeFragments.h>
|
||||
#include <Timer.h>
|
||||
#include <Resources.h>
|
||||
#include <ToolUtils.h>
|
||||
|
||||
#include "jri.h"
|
||||
|
||||
// The Mixed Mode procInfos defined in npupp.h assume Think C-
|
||||
// style calling conventions. These conventions are used by
|
||||
// Metrowerks with the exception of pointer return types, which
|
||||
// in Metrowerks 68K are returned in A0, instead of the standard
|
||||
// D0. Thus, since NPN_MemAlloc and NPN_UserAgent return pointers,
|
||||
// Mixed Mode will return the values to a 68K plugin in D0, but
|
||||
// a 68K plugin compiled by Metrowerks will expect the result in
|
||||
// A0. The following pragma forces Metrowerks to use D0 instead.
|
||||
//
|
||||
#ifdef __MWERKS__
|
||||
#ifndef powerc
|
||||
#pragma pointers_in_D0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#ifndef powerc
|
||||
#pragma pointers_in_A0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// The following fix for static initializers (which fixes a preious
|
||||
// incompatibility with some parts of PowerPlant, was submitted by
|
||||
// Jan Ulbrich.
|
||||
#ifdef __MWERKS__
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifndef powerc
|
||||
extern void __InitCode__(void);
|
||||
#else
|
||||
extern void __sinit(void);
|
||||
#define __InitCode__ __sinit
|
||||
#endif
|
||||
extern void __destroy_global_chain(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
#endif // __MWERKS__
|
||||
|
||||
// Wrapper functions for all calls from Netscape to the plugin.
|
||||
// These functions let the plugin developer just create the APIs
|
||||
// as documented and defined in npapi.h, without needing to
|
||||
// install those functions in the function table or worry about
|
||||
// setting up globals for 68K plugins.
|
||||
NPError Private_Initialize(void);
|
||||
void Private_Shutdown(void);
|
||||
NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
|
||||
NPError Private_Destroy(NPP instance, NPSavedData** save);
|
||||
NPError Private_SetWindow(NPP instance, NPWindow* window);
|
||||
NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
|
||||
NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason);
|
||||
int32 Private_WriteReady(NPP instance, NPStream* stream);
|
||||
int32 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
|
||||
void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
|
||||
void Private_Print(NPP instance, NPPrint* platformPrint);
|
||||
int16 Private_HandleEvent(NPP instance, void* event);
|
||||
void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData);
|
||||
jref Private_GetJavaClass(void);
|
||||
NPError Private_GetValue(NPP instance, NPPVariable variable, void *result);
|
||||
NPError Private_SetValue(NPP instance, NPNVariable variable, void *value);
|
||||
|
||||
#endif //XP_MAC
|
||||
|
||||
#ifndef HIBYTE
|
||||
#define HIBYTE(i) (i >> 8)
|
||||
#endif
|
||||
|
||||
#ifndef LOBYTE
|
||||
#define LOBYTE(i) (i & 0xff)
|
||||
#endif
|
||||
|
||||
#endif //_NPPLAT_H_
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __PLUGININSTANCEBASE_H__
|
||||
#define __PLUGININSTANCEBASE_H__
|
||||
|
||||
#include "npplat.h"
|
||||
|
||||
struct nsPluginCreateData
|
||||
{
|
||||
NPP instance;
|
||||
NPMIMEType type;
|
||||
uint16 mode;
|
||||
int16 argc;
|
||||
char** argn;
|
||||
char** argv;
|
||||
NPSavedData* saved;
|
||||
};
|
||||
|
||||
class nsPluginInstanceBase
|
||||
{
|
||||
public:
|
||||
// these three methods must be implemented in the derived
|
||||
// class platform specific way
|
||||
virtual NPBool init(NPWindow* aWindow) = 0;
|
||||
virtual void shut() = 0;
|
||||
virtual NPBool isInitialized() = 0;
|
||||
|
||||
// implement all or part of those methods in the derived
|
||||
// class as needed
|
||||
virtual NPError SetWindow(NPWindow* pNPWindow) { return NPERR_NO_ERROR; }
|
||||
virtual NPError NewStream(NPMIMEType type, NPStream* stream,
|
||||
NPBool seekable, uint16* stype) { return NPERR_NO_ERROR; }
|
||||
virtual NPError DestroyStream(NPStream *stream, NPError reason) { return NPERR_NO_ERROR; }
|
||||
virtual void StreamAsFile(NPStream* stream, const char* fname) { return; }
|
||||
virtual int32 WriteReady(NPStream *stream) { return 0x0fffffff; }
|
||||
virtual int32 Write(NPStream *stream, int32 offset,
|
||||
int32 len, void *buffer) { return len; }
|
||||
virtual void Print(NPPrint* printInfo) { return; }
|
||||
virtual uint16 HandleEvent(void* event) { return 0; }
|
||||
virtual void URLNotify(const char* url, NPReason reason,
|
||||
void* notifyData) { return; }
|
||||
virtual NPError GetValue(NPPVariable variable, void *value) { return NPERR_NO_ERROR; }
|
||||
virtual NPError SetValue(NPNVariable variable, void *value) { return NPERR_NO_ERROR; }
|
||||
};
|
||||
|
||||
// functions that should be implemented for each specific plugin
|
||||
|
||||
// creation and destruction of the object of the derived class
|
||||
nsPluginInstanceBase * NS_NewPluginInstance(nsPluginCreateData * aCreateDataStruct);
|
||||
void NS_DestroyPluginInstance(nsPluginInstanceBase * aPlugin);
|
||||
|
||||
// global plugin initialization and shutdown
|
||||
NPError NS_PluginInitialize();
|
||||
void NS_PluginShutdown();
|
||||
|
||||
#ifdef XP_UNIX
|
||||
// global to get plugins name & description
|
||||
NPError NS_PluginGetValue(NPPVariable aVariable, void *aValue);
|
||||
#endif
|
||||
|
||||
#endif // __PLUGININSTANCEBASE_H__
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
// Filename: ppInstance.I
|
||||
// Created by: drose (19Jun09)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
@ -1,136 +0,0 @@
|
|||
// Filename: ppInstance.cxx
|
||||
// Created by: drose (19Jun09)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "ppInstance.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PPInstance::Constructor
|
||||
// Access: Public
|
||||
// Description: Creates a new instance of a Panda3D plugin window.
|
||||
// The create_data structure is supplied from NPAPI, and
|
||||
// defines the initial parameters specified in the HTML
|
||||
// document.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PPInstance::
|
||||
PPInstance(nsPluginCreateData *create_data) {
|
||||
log << "constructing " << this << "\n" << flush;
|
||||
_inst = NULL;
|
||||
|
||||
log << " instance = " << create_data->instance
|
||||
<< "\n type = " << create_data->type
|
||||
<< "\n mode = " << create_data->mode << "\n";
|
||||
|
||||
// Copy the tokens from the create_data structure.
|
||||
_tokens.reserve(create_data->argc);
|
||||
for (int i = 0; i < create_data->argc; ++i) {
|
||||
P3D_token token;
|
||||
token._keyword = strdup(create_data->argn[i]);
|
||||
token._value = strdup(create_data->argv[i]);
|
||||
log << " " << i << ": " << token._keyword << " = " << token._value << "\n";
|
||||
_tokens.push_back(token);
|
||||
}
|
||||
|
||||
_npp_mode = create_data->mode;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PPInstance::Destructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PPInstance::
|
||||
~PPInstance() {
|
||||
assert(_inst == NULL);
|
||||
log << "destructing " << this << "\n" << flush;
|
||||
|
||||
Tokens::iterator ti;
|
||||
for (ti = _tokens.begin(); ti != _tokens.end(); ++ti) {
|
||||
free((char *)(*ti)._keyword);
|
||||
free((char *)(*ti)._value);
|
||||
}
|
||||
_tokens.clear();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PPInstance::init
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
NPBool PPInstance::
|
||||
init(NPWindow *window) {
|
||||
assert(_inst == NULL);
|
||||
log << "init, window = " << window << "\n" << flush;
|
||||
log << " x,y = " << window->x << "," << window->y
|
||||
<< " w,h = " << window->width << "," << window->height
|
||||
<< "\n" << flush;
|
||||
|
||||
P3D_window_handle parent_window;
|
||||
#ifdef _WIN32
|
||||
parent_window._hwnd = (HWND)(window->window);
|
||||
#endif
|
||||
|
||||
P3D_window_type window_type = P3D_WT_embedded;
|
||||
|
||||
const P3D_token *tokens = NULL;
|
||||
if (!_tokens.empty()) {
|
||||
tokens = &_tokens[0];
|
||||
}
|
||||
|
||||
_inst = P3D_create_instance
|
||||
(NULL, NULL, window_type,
|
||||
window->x, window->y, window->width, window->height,
|
||||
parent_window, tokens, _tokens.size());
|
||||
|
||||
return (_inst != NULL);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PPInstance::shut
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PPInstance::
|
||||
shut() {
|
||||
assert(_inst != NULL);
|
||||
log << "shut\n";
|
||||
P3D_instance_finish(_inst);
|
||||
_inst = NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PPInstance::isInitialized
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
NPBool PPInstance::
|
||||
isInitialized() {
|
||||
return _inst != NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
virtual NPError SetWindow(NPWindow *pNPWindow);
|
||||
virtual NPError NewStream(NPMIMEType type, NPStream *stream,
|
||||
NPBool seekable, uint16 *stype);
|
||||
virtual NPError DestroyStream(NPStream *stream, NPError reason);
|
||||
virtual void StreamAsFile(NPStream *stream, const char *fname);
|
||||
virtual int32 WriteReady(NPStream *stream);
|
||||
virtual int32 Write(NPStream *stream, int32 offset,
|
||||
int32 len, void *buffer);
|
||||
virtual void Print(NPPrint *printInfo);
|
||||
virtual uint16 HandleEvent(void *event);
|
||||
virtual void URLNotify(const char *url, NPReason reason,
|
||||
void *notifyData);
|
||||
virtual NPError GetValue(NPPVariable variable, void *value);
|
||||
virtual NPError SetValue(NPNVariable variable, void *value);
|
||||
*/
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
// Filename: ppInstance.h
|
||||
// Created by: drose (19Jun09)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PPINSTANCE_H
|
||||
#define PPINSTANCE_H
|
||||
|
||||
#include "nppanda3d_common.h"
|
||||
#include "pluginbase.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : PPInstance
|
||||
// Description : This represents a single instance of the Panda3D
|
||||
// plugin, via the NPAPI interface. This instance
|
||||
// brokers the communication with the P3D Core API, as
|
||||
// defined in the plugin directory.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class PPInstance : public nsPluginInstanceBase {
|
||||
public:
|
||||
PPInstance(nsPluginCreateData *create_data);
|
||||
~PPInstance();
|
||||
|
||||
// Methods inherited from base class
|
||||
|
||||
virtual NPBool init(NPWindow *aWindow);
|
||||
virtual void shut();
|
||||
virtual NPBool isInitialized();
|
||||
|
||||
/*
|
||||
virtual NPError SetWindow(NPWindow *pNPWindow);
|
||||
virtual NPError NewStream(NPMIMEType type, NPStream *stream,
|
||||
NPBool seekable, uint16 *stype);
|
||||
virtual NPError DestroyStream(NPStream *stream, NPError reason);
|
||||
virtual void StreamAsFile(NPStream *stream, const char *fname);
|
||||
virtual int32 WriteReady(NPStream *stream);
|
||||
virtual int32 Write(NPStream *stream, int32 offset,
|
||||
int32 len, void *buffer);
|
||||
virtual void Print(NPPrint *printInfo);
|
||||
virtual uint16 HandleEvent(void *event);
|
||||
virtual void URLNotify(const char *url, NPReason reason,
|
||||
void *notifyData);
|
||||
virtual NPError GetValue(NPPVariable variable, void *value);
|
||||
virtual NPError SetValue(NPNVariable variable, void *value);
|
||||
*/
|
||||
|
||||
private:
|
||||
typedef vector<P3D_token> Tokens;
|
||||
Tokens _tokens;
|
||||
int _npp_mode;
|
||||
|
||||
P3D_instance *_inst;
|
||||
};
|
||||
|
||||
#include "ppInstance.I"
|
||||
|
||||
#endif
|
||||
|
|
@ -263,9 +263,10 @@ create_instance(const string &arg, P3D_window_type window_type,
|
|||
}
|
||||
|
||||
P3D_instance *inst = P3D_create_instance
|
||||
(NULL, os_p3d_filename.c_str(),
|
||||
window_type, win_x, win_y, win_width, win_height, parent_window,
|
||||
tokens, num_tokens);
|
||||
(NULL, os_p3d_filename.c_str(), tokens, num_tokens);
|
||||
|
||||
P3D_instance_setup_window
|
||||
(inst, window_type, win_x, win_y, win_width, win_height, parent_window);
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,6 +91,16 @@ def initPackedAppEnvironment():
|
|||
# we plan to mount there.
|
||||
vfs.chdir(MultifileRoot)
|
||||
|
||||
readyToStart = False
|
||||
started = False
|
||||
def startIfReady():
|
||||
global readyToStart, started
|
||||
if readyToStart:
|
||||
started = True
|
||||
import main
|
||||
if hasattr(main, 'main') and callable(main.main):
|
||||
main.main()
|
||||
|
||||
def runPackedApp(p3dFilename, tokens = []):
|
||||
tokenDict = dict(tokens)
|
||||
fname = Filename.fromOsSpecific(p3dFilename)
|
||||
|
|
@ -146,10 +156,9 @@ def runPackedApp(p3dFilename, tokens = []):
|
|||
data = open(pathname, 'r').read()
|
||||
loadPrcFileData(pathname, data)
|
||||
|
||||
import main
|
||||
if hasattr(main, 'main') and callable(main.main):
|
||||
main.main()
|
||||
startIfReady()
|
||||
|
||||
windowPrc = None
|
||||
def setupWindow(windowType, x, y, width, height, parent):
|
||||
if windowType == 'hidden':
|
||||
data = 'window-type none\n'
|
||||
|
|
@ -171,7 +180,14 @@ def setupWindow(windowType, x, y, width, height, parent):
|
|||
if width or height:
|
||||
data += 'win-size %s %s\n' % (width, height)
|
||||
|
||||
loadPrcFileData("setupWindow", data)
|
||||
global windowPrc
|
||||
if windowPrc:
|
||||
unloadPrcFile(windowPrc)
|
||||
windowPrc = loadPrcFileData("setupWindow", data)
|
||||
|
||||
global readyToStart
|
||||
readyToStart = True
|
||||
startIfReady()
|
||||
|
||||
def parseSysArgs():
|
||||
""" Converts sys.argv into (p3dFilename, tokens). """
|
||||
|
|
@ -200,6 +216,7 @@ def parseSysArgs():
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
readyToStart = True
|
||||
try:
|
||||
runPackedApp(*parseSysArgs())
|
||||
except ArgumentError, e:
|
||||
|
|
|
|||
Loading…
Reference in New Issue