#endif
-//---------------------------------------------------------------------------
-
-//wxHashTable* wxPyWindows = NULL;
-
-
-wxPoint wxPyDefaultPosition; //wxDefaultPosition);
-wxSize wxPyDefaultSize; //wxDefaultSize);
-wxString wxPyEmptyStr("");
-
#ifdef __WXMSW__ // If building for win32...
#ifdef WXP_WITH_THREAD
PyThreadState* wxPyEventThreadState = NULL;
#endif
-static char* __nullArgv[1] = { 0 };
// This is where we pick up the first part of the wxEntry functionality...
//---------------------------------------------------------------------------
PyObject* wxPyConstructObject(void* ptr,
- const char* className,
- int setThisOwn) {
+ const char* className,
+ int setThisOwn) {
PyObject* obj;
PyObject* arg;
//---------------------------------------------------------------------------
-static unsigned int _wxPyNestCount = 0;
-
static PyThreadState* myPyThreadState_Get() {
PyThreadState* current;
current = PyThreadState_Swap(NULL);
}
-HELPEREXPORT bool wxPyRestoreThread() {
+bool wxPyRestoreThread() {
// NOTE: The Python API docs state that if a thread already has the
// interpreter lock and calls PyEval_RestoreThread again a deadlock
// occurs, so I put in this code as a guard condition since there are
// already have the lock. (I hope!)
//
#ifdef WXP_WITH_THREAD
- _wxPyNestCount += 1;
if (wxPyEventThreadState != myPyThreadState_Get()) {
PyEval_RestoreThread(wxPyEventThreadState);
return TRUE;
}
-HELPEREXPORT void wxPySaveThread(bool doSave) {
+void wxPySaveThread(bool doSave) {
#ifdef WXP_WITH_THREAD
if (doSave) {
wxPyEventThreadState = PyEval_SaveThread();
}
- _wxPyNestCount -= 1;
#endif
}
//----------------------------------------------------------------------
-wxPyCallbackHelper::wxPyCallbackHelper() {
- m_class = NULL;
- m_self = NULL;
- m_lastFound = NULL;
- m_incRef = FALSE;
-}
-
-
-wxPyCallbackHelper::~wxPyCallbackHelper() {
- bool doSave = wxPyRestoreThread();
- if (m_incRef) {
- Py_XDECREF(m_self);
- Py_XDECREF(m_class);
- }
- wxPySaveThread(doSave);
-}
-
wxPyCallbackHelper::wxPyCallbackHelper(const wxPyCallbackHelper& other) {
m_lastFound = NULL;
m_self = other.m_self;
// Invoke the Python callable object, returning the raw PyObject return
// value. Caller should DECREF the return value and also call PyEval_SaveThread.
PyObject* wxPyCallbackHelper::callCallbackObj(PyObject* argTuple) const {
- wxPyCallbackHelper* self = (wxPyCallbackHelper*)this; // cast away const
PyObject* result;
// Save a copy of the pointer in case the callback generates another
}
+void wxPyCBH_setSelf(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref) {
+ cbh.setSelf(self, klass, incref);
+}
+
+bool wxPyCBH_findCallback(const wxPyCallbackHelper& cbh, const char* name) {
+ return cbh.findCallback(name);
+}
+
+int wxPyCBH_callCallback(const wxPyCallbackHelper& cbh, PyObject* argTuple) {
+ return cbh.callCallback(argTuple);
+}
+
+PyObject* wxPyCBH_callCallbackObj(const wxPyCallbackHelper& cbh, PyObject* argTuple) {
+ return cbh.callCallbackObj(argTuple);
+}
+
+
+void wxPyCBH_delete(wxPyCallbackHelper* cbh) {
+ bool doSave = wxPyRestoreThread();
+ if (cbh->m_incRef) {
+ Py_XDECREF(cbh->m_self);
+ Py_XDECREF(cbh->m_class);
+ }
+ wxPySaveThread(doSave);
+}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------