|
@@ -19,10 +19,7 @@
|
|
|
#include "virtualFileSystem.h"
|
|
#include "virtualFileSystem.h"
|
|
|
#include "nativeWindowHandle.h"
|
|
#include "nativeWindowHandle.h"
|
|
|
|
|
|
|
|
-#ifndef CPPPARSER
|
|
|
|
|
#include "py_panda.h"
|
|
#include "py_panda.h"
|
|
|
-IMPORT_THIS struct Dtool_PyTypedObject Dtool_WindowHandle;
|
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
|
|
// There is only one P3DPythonRun object in any given process space.
|
|
// There is only one P3DPythonRun object in any given process space.
|
|
|
// Makes the statics easier to deal with, and we don't need multiple
|
|
// Makes the statics easier to deal with, and we don't need multiple
|
|
@@ -298,14 +295,12 @@ run_python() {
|
|
|
|
|
|
|
|
// Now pass that func pointer back to our AppRunner instance, so it
|
|
// Now pass that func pointer back to our AppRunner instance, so it
|
|
|
// can call up to us.
|
|
// can call up to us.
|
|
|
- result = PyObject_CallMethod(_runner, (char *)"setRequestFunc", (char *)"O", request_func);
|
|
|
|
|
|
|
+ result = PyObject_CallMethod(_runner, (char *)"setRequestFunc", (char *)"N", request_func);
|
|
|
if (result == NULL) {
|
|
if (result == NULL) {
|
|
|
PyErr_Print();
|
|
PyErr_Print();
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
Py_DECREF(result);
|
|
Py_DECREF(result);
|
|
|
- Py_DECREF(request_func);
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
// Now add check_comm() as a task. It can be a threaded task, but
|
|
// Now add check_comm() as a task. It can be a threaded task, but
|
|
|
// this does mean that application programmers will have to be alert
|
|
// this does mean that application programmers will have to be alert
|
|
@@ -326,14 +321,14 @@ run_python() {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // We have to make it a PythonTask, not just a GenericAsyncTask,
|
|
|
|
|
- // because we need the code in PythonTask that supports calling into
|
|
|
|
|
- // Python from a separate thread.
|
|
|
|
|
- _check_comm_task = new PythonTask(check_comm, "check_comm");
|
|
|
|
|
- _check_comm_task->set_task_chain("JavaScript");
|
|
|
|
|
- task_mgr->add(_check_comm_task);
|
|
|
|
|
-
|
|
|
|
|
- Py_DECREF(check_comm);
|
|
|
|
|
|
|
+ // Add it to the task manager. We do this instead of constructing a
|
|
|
|
|
+ // PythonTask because linking p3dpython with core.pyd is problematic.
|
|
|
|
|
+ result = PyObject_CallMethod(_taskMgr, (char *)"add", (char *)"Ns", check_comm, "check_comm");
|
|
|
|
|
+ if (result == NULL) {
|
|
|
|
|
+ PyErr_Print();
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ Py_DECREF(result);
|
|
|
|
|
|
|
|
// Finally, get lost in AppRunner.run() (which is really a call to
|
|
// Finally, get lost in AppRunner.run() (which is really a call to
|
|
|
// taskMgr.run()).
|
|
// taskMgr.run()).
|
|
@@ -603,10 +598,8 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response,
|
|
|
Py_INCREF(obj);
|
|
Py_INCREF(obj);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- PyObject *result = PyObject_CallMethod
|
|
|
|
|
- (_runner, (char *)"setBrowserScriptObject", (char *)"O", obj);
|
|
|
|
|
- Py_DECREF(obj);
|
|
|
|
|
- Py_XDECREF(result);
|
|
|
|
|
|
|
+ Py_XDECREF(PyObject_CallMethod
|
|
|
|
|
+ (_runner, (char *)"setBrowserScriptObject", (char *)"N", obj));
|
|
|
|
|
|
|
|
} else if (strcmp(op, "call") == 0) {
|
|
} else if (strcmp(op, "call") == 0) {
|
|
|
// Call the named method on the indicated object, or the object
|
|
// Call the named method on the indicated object, or the object
|
|
@@ -1215,9 +1208,8 @@ set_instance_info(P3DCInstance *inst, TiXmlElement *xinstance) {
|
|
|
xinstance->Attribute("respect_per_platform", &respect_per_platform);
|
|
xinstance->Attribute("respect_per_platform", &respect_per_platform);
|
|
|
|
|
|
|
|
PyObject *result = PyObject_CallMethod
|
|
PyObject *result = PyObject_CallMethod
|
|
|
- (_runner, (char *)"setInstanceInfo", (char *)"sssiOi", root_dir,
|
|
|
|
|
|
|
+ (_runner, (char *)"setInstanceInfo", (char *)"sssiNi", root_dir,
|
|
|
log_directory, super_mirror, verify_contents, main, respect_per_platform);
|
|
log_directory, super_mirror, verify_contents, main, respect_per_platform);
|
|
|
- Py_DECREF(main);
|
|
|
|
|
|
|
|
|
|
if (result == NULL) {
|
|
if (result == NULL) {
|
|
|
PyErr_Print();
|
|
PyErr_Print();
|
|
@@ -1331,11 +1323,9 @@ set_p3d_filename(P3DCInstance *inst, TiXmlElement *xfparams) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
PyObject *result = PyObject_CallMethod
|
|
PyObject *result = PyObject_CallMethod
|
|
|
- (_runner, (char *)"setP3DFilename", (char *)"sOOiiis", p3d_filename.c_str(),
|
|
|
|
|
|
|
+ (_runner, (char *)"setP3DFilename", (char *)"sNNiiis", p3d_filename.c_str(),
|
|
|
token_list, arg_list, inst->get_instance_id(), _interactive_console, p3d_offset,
|
|
token_list, arg_list, inst->get_instance_id(), _interactive_console, p3d_offset,
|
|
|
p3d_url.c_str());
|
|
p3d_url.c_str());
|
|
|
- Py_DECREF(token_list);
|
|
|
|
|
- Py_DECREF(arg_list);
|
|
|
|
|
|
|
|
|
|
if (result == NULL) {
|
|
if (result == NULL) {
|
|
|
PyErr_Print();
|
|
PyErr_Print();
|
|
@@ -1425,18 +1415,16 @@ setup_window(P3DCInstance *inst, TiXmlElement *xwparams) {
|
|
|
// setupWindow() call. For this, we need to create a Python
|
|
// setupWindow() call. For this, we need to create a Python
|
|
|
// wrapper objcet.
|
|
// wrapper objcet.
|
|
|
parent_window_handle->ref();
|
|
parent_window_handle->ref();
|
|
|
- py_handle = DTool_CreatePyInstanceTyped(parent_window_handle, Dtool_WindowHandle, true, false, parent_window_handle->get_type_index());
|
|
|
|
|
|
|
+ py_handle = DTool_CreatePyInstanceTyped(parent_window_handle.p(), true);
|
|
|
}
|
|
}
|
|
|
Py_INCREF(py_handle);
|
|
Py_INCREF(py_handle);
|
|
|
|
|
|
|
|
// TODO: direct this into the particular instance. This will
|
|
// TODO: direct this into the particular instance. This will
|
|
|
// require a specialized ShowBase replacement.
|
|
// require a specialized ShowBase replacement.
|
|
|
PyObject *result = PyObject_CallMethod
|
|
PyObject *result = PyObject_CallMethod
|
|
|
- (_runner, (char *)"setupWindow", (char *)"siiiiO", window_type.c_str(),
|
|
|
|
|
|
|
+ (_runner, (char *)"setupWindow", (char *)"siiiiN", window_type.c_str(),
|
|
|
win_x, win_y, win_width, win_height, py_handle);
|
|
win_x, win_y, win_width, win_height, py_handle);
|
|
|
|
|
|
|
|
- Py_DECREF(py_handle);
|
|
|
|
|
-
|
|
|
|
|
if (result == NULL) {
|
|
if (result == NULL) {
|
|
|
PyErr_Print();
|
|
PyErr_Print();
|
|
|
if (_interactive_console) {
|
|
if (_interactive_console) {
|