This repository has been archived by the owner on Feb 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FXPython.cxx
633 lines (591 loc) · 19.2 KB
/
FXPython.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
/********************************************************************************
* *
* Python embedding support *
* *
*********************************************************************************
* Copyright (C) 2003-2006 by Niall Douglas. All Rights Reserved. *
* NOTE THAT I DO NOT PERMIT ANY OF MY CODE TO BE PROMOTED TO THE GPL *
*********************************************************************************
* This code is free software; you can redistribute it and/or modify it under *
* the terms of the GNU Library General Public License v2.1 as published by the *
* Free Software Foundation EXCEPT that clause 3 does not apply ie; you may not *
* "upgrade" this code to the GPL without my prior written permission. *
* Please consult the file "License_Addendum2.txt" accompanying this file. *
* *
* This code is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
*********************************************************************************
* $Id: *
********************************************************************************/
#include "common.h"
#include <boost/python/suite/indexing/iterator_range.hpp>
#include "FXCodeToPythonCode.h"
#ifndef FX_DISABLEGUI
#include "../include/FXGLViewer.h"
#endif
#include "../include/FXMemDbg.h"
#if defined(DEBUG) && defined(FXMEMDBG_H)
static const char *_fxmemdbg_current_file_ = __FILE__;
#endif
// Defines how many sort function vectors there are (per type)
#define SORTFUNCVECTORS 8
namespace FX {
FXString FXPython::interpreterPath()
{
return FXString(Py_GetProgramFullPath());
}
FXString FXPython::version()
{
return FXString(Py_GetVersion());
}
FXString FXPython::platform()
{
return FXString(Py_GetPlatform());
}
FXString FXPython::programName()
{
return FXString(Py_GetProgramName());
}
void FXPython::setProgramName(const FXString &name)
{
static FXPtrHold<char> staticname;
if(staticname) { delete static_cast<char *>(staticname); staticname=0; }
FXERRHM(staticname=new char[name.length()+1]);
memcpy(staticname, name.text(), name.length()+1);
Py_SetProgramName(staticname);
}
void FXPython::setArgv(int argc, char **argv)
{
PySys_SetArgv(argc, argv);
}
boost::python::handle<> FXPython::globals()
{
return boost::python::handle<>(
boost::python::borrowed(PyModule_GetDict(PyImport_AddModule("__main__"))));
}
boost::python::handle<> FXPython::execute(const FXString &code, boost::python::handle<> context)
{
QThread_DTHold dthold;
PyObject *ret;
FXERRHPY(ret=PyRun_String((char *) code.text(), Py_file_input, context.get(), context.get()));
return boost::python::handle<>(ret);
}
boost::python::handle<> FXPython::evaluate(const FXString &code, boost::python::handle<> context)
{
QThread_DTHold dthold;
PyObject *ret;
FXERRHPY(ret=PyRun_String((char *) code.text(), Py_eval_input, context.get(), context.get()));
return boost::python::handle<>(ret);
}
//**************************************************************************************
struct ThreadData
{
FXAtomicInt GILcnt;
Generic::BoundFunctorV *threadcleanupH;
QPtrList<FXPythonInterp> callstack;
QValueList<PyThreadState *> tsstack;
ThreadData() : threadcleanupH(0) { }
};
static QRWMutex indexlock;
static QPtrDict<ThreadData> index(13, true);
static QMutex interplistlock;
static QPtrList<FXPythonInterp> interplist;
static bool amEmbeddedInPython=true;
struct FXPythonInterpPrivate
{
const char *name;
PyThreadState *ts;
bool amMaster, myinterpreter, myts;
FXPythonInterpPrivate(const char *_name, PyThreadState *_ts=0)
: name(_name), ts(_ts), amMaster(false), myinterpreter(false), myts(false) { }
static void informPython();
static void cleanupThread(QThread *cthread);
static ThreadData *addThread(QThread *cthread, PyThreadState *ts, FXPythonInterp *parentinterp=0);
};
void FXPythonInterpPrivate::cleanupThread(QThread *cthread)
{ // Ensure you don't add anything here which also needs to go into the destructor
QMtxHold h(indexlock, true);
QMtxHold h2(interplistlock);
ThreadData *td=index.find(cthread);
if(td)
{
if(td->GILcnt>0)
{
//fxmessage("Thread %d Unsetting %p (GILcnt=%d)\n", cthread->id(), PyThreadState_Get(), td->GILcnt);
PyEval_ReleaseThread(PyThreadState_Get());
td->GILcnt=0;
}
FXPythonInterp *myinterp=td->callstack.getLast();
assert(myinterp);
td->threadcleanupH=0; // Prevent deletion as breaks QThread's iterator
delete myinterp;
index.remove(cthread);
}
}
ThreadData *FXPythonInterpPrivate::addThread(QThread *cthread, PyThreadState *ts, FXPythonInterp *parentinterp)
{
FXERRH(cthread, "QThread uninitialised - did you use QThread to create your thread?", 0, FXERRH_ISDEBUG);
FXPythonInterp *interp;
if(!ts)
{ // Derive a thread state from the primary interpreter
if(!parentinterp) parentinterp=interplist.getFirst();
ts=PyThreadState_New(parentinterp->p->ts->interp);
FXRBOp unts=FXRBFunc(PyThreadState_Delete, ts);
FXERRHM(interp=new FXPythonInterp(ts));
interp->p->myts=true;
FXRBOp uni=FXRBNew(interp);
unts.dismiss();
QMtxHold h(interplistlock);
interplist.append(interp);
uni.dismiss();
}
else
{
for(QPtrListIterator<FXPythonInterp> it(interplist); (interp=it.current()); ++it)
{
if(interp->p->ts==ts) break;
}
if(!interp)
{
QMtxHold h2(interplistlock);
FXERRHM(interp=new FXPythonInterp(ts));
FXRBOp uninterp=FXRBNew(interp);
interplist.append(interp);
uninterp.dismiss();
}
}
ThreadData *td;
if(!(td=index.find(cthread)))
{
FXERRHM(td=new ThreadData);
FXRBOp untd=FXRBNew(td);
index.insert(cthread, td);
untd.dismiss();
td->threadcleanupH=cthread->addCleanupCall(Generic::BindFuncN(&FXPythonInterpPrivate::cleanupThread, cthread));
td->callstack.prepend(interp); // Push base interpreter
}
return td;
}
static void onThreadCreation(QThread *t)
{ // ie; set the new thread's interpreter to what it was when started
if(interplist.isEmpty()) return;
FXPythonInterp *cinterp=FXPythonInterp::current();
if(cinterp)
{
FXPythonInterpPrivate::addThread(t, 0, cinterp);
}
}
class FXPythonInit
{
public:
FXPythonInit()
{
QThread::addCreationUpcall(QThread::CreationUpcallSpec(onThreadCreation));
}
~FXPythonInit()
{
QThread::removeCreationUpcall(QThread::CreationUpcallSpec(onThreadCreation));
}
};
static FXProcess_StaticInit<FXPythonInit> myinit("FXPython");
FXPythonInterp::FXPythonInterp(void *ts) : p(0)
{
FXERRHM(p=new FXPythonInterpPrivate("Auto created interpreter", (PyThreadState *) ts));
}
FXPythonInterp::FXPythonInterp(int argc, char **argv, const char *name) : p(0)
{
QThread *cthread=QThread::current();
PyThreadState *oldts=0;
QMtxHold h(indexlock, true);
QMtxHold h2(interplistlock);
bool addTnFOX=false;
FXRBOp unconstr=FXRBConstruct(this);
FXERRHM(p=new FXPythonInterpPrivate(name));
if(!Py_IsInitialized())
{ // Init overall
amEmbeddedInPython=false;
PyEval_InitThreads();
FXPython::setProgramName(FXProcess::execpath());
Py_Initialize();
p->ts=PyThreadState_Get();
p->amMaster=true;
FXPython::setArgv(argc, argv);
addTnFOX=true;
}
else
{ // Despite what the docs might say, you must have a thread state set
oldts=PyThreadState_Swap(NULL);
{
FXPython_CtxHold ctxhold;
PyThreadState *oldts=PyThreadState_Get();
FXERRHM(p->ts=Py_NewInterpreter());
PyThreadState_Swap(oldts); // Avoid assertion failure
p->myinterpreter=true;
}
addTnFOX=true;
}
interplist.append(this);
ThreadData *td=FXPythonInterpPrivate::addThread(cthread, p->ts, this);
// Push current context
td->callstack.prepend(this);
td->tsstack.prepend(oldts);
if(!td->GILcnt++ && !p->amMaster)
{
PyEval_AcquireThread(p->ts);
}
else PyThreadState_Swap(p->ts);
//fxmessage("Thread %d Setting %p was %p (GILcnt=%d)\n", cthread->id(), p->ts, oldts, td->GILcnt);
if(addTnFOX) py(
"# Thanks to Ralf W. Grosse-Kunstleve for this\n"
"import os, sys\n"
#ifdef USE_POSIX
"previous_dlopenflags=sys.getdlopenflags()\n"
"sys.setdlopenflags(0x102)\n"
"print 'Former flags were',previous_dlopenflags,'now',0x102\n"
"print 'sys.path=',sys.path\n"
#endif
// Hack in current directory to module search path
"sys.path.append(os.getcwd())\n"
"print 'new sys.path=',sys.path\n"
"from TnFOX import *\n"
#ifdef USE_POSIX
"print 'After flags were',sys.getdlopenflags()\n"
//"sys.setdlopenflags(previous_dlopenflags)\n"
"del previous_dlopenflags\n"
#endif
);
unconstr.dismiss();
}
#ifdef USE_POSIX
static struct TestWhere
{
TestWhere()
{
fxmessage("TestWhere constructed at %p\n", this);
}
~TestWhere()
{
fxmessage("TestWhere destroyed at %p\n", this);
}
} testwhere;
#endif
FXPythonInterp::~FXPythonInterp()
{
QThread *cthread=QThread::current();
QMtxHold h(indexlock, true);
QMtxHold h2(interplistlock);
ThreadData *td=index.find(cthread);
if(td)
{
if(td->callstack.getLast()==this)
{
if(td->threadcleanupH) cthread->removeCleanupCall(td->threadcleanupH);
FXDELETE(td->threadcleanupH);
index.remove(cthread);
}
}
// If master is exiting, everything else should already be dead
if(!p->amMaster)
{
FXPython_DoPython ctxhold;
if(p->myinterpreter)
{
PyThreadState *oldts=PyThreadState_Swap(p->ts);
Py_EndInterpreter(p->ts); p->ts=0;
PyThreadState_Swap(oldts);
}
else if(p->myts)
{
PyThreadState_Clear(p->ts);
PyThreadState_Delete(p->ts); p->ts=0;
}
}
PyThreadState *oldts=p->ts;
FXDELETE(p);
interplist.removeRef(this);
if(interplist.isEmpty() && !amEmbeddedInPython)
{ // Destruct overall
PyThreadState_Swap(oldts); // Prevent assertion error
Py_Finalize();
}
}
const char *FXPythonInterp::name() const throw()
{
return p->name;
}
FXPythonInterp *FXPythonInterp::current()
{
QMtxHold h(indexlock, false);
ThreadData *td=index.find(QThread::current());
if(!td) return 0;
if(td->callstack.isEmpty()) return 0;
return td->callstack.getFirst();
}
void FXPythonInterp::setContext()
{
assert(this);
QThread *cthread=QThread::current();
QMtxHold h(indexlock, false);
ThreadData *td=index.find(cthread);
if(!td)
{
QMtxHold h(indexlock, true);
td=FXPythonInterpPrivate::addThread(cthread, p->ts, this);
}
h.unlock();
if(!td->GILcnt++)
{
PyEval_AcquireLock();
}
PyThreadState *oldts=PyThreadState_Swap(p->ts);
td->tsstack.push_front(oldts);
td->callstack.prepend(this);
//fxmessage("Thread %d Setting %p was %p (GILcnt=%d)\n", cthread->id(), p->ts, oldts, td->GILcnt);
}
void FXPythonInterp::unsetContext()
{
QThread *cthread=QThread::current();
QMtxHold h(indexlock, false);
ThreadData *td=index.find(cthread);
assert(td);
h.unlock();
td->callstack.removeFirst();
PyThreadState *oldts=td->tsstack.front();
FXERRH(!td->tsstack.isEmpty(), "unsetContext() called too many times!", 0, FXERRH_ISDEBUG);
td->tsstack.pop_front();
//fxmessage("Thread %d Unsetting %p now %p (GILcnt=%d)\n", cthread->id(), p->ts, oldts, td->GILcnt-1);
PyThreadState_Swap(oldts);
if(!--td->GILcnt)
{
PyEval_ReleaseLock();
}
}
// Called whenever python crosses into C++ land
void FXPythonInterp::int_enterCPP()
{
QThread *cthread=QThread::current();
if(!cthread && !FXProcess::instance())
{ // Seems we're just about to exit - leave the lock alone
return;
}
QMtxHold h(indexlock, false);
ThreadData *td=index.find(cthread);
if(!td)
{
QMtxHold h(indexlock, true);
td=FXPythonInterpPrivate::addThread(cthread, PyThreadState_Get());
}
h.unlock();
cthread->disableTermination();
//fxmessage("Thread %d Unsetting %p (GILcnt=%d)\n", cthread->id(), td->callstack.getFirst()->p->ts, td->GILcnt-1);
if(!--td->GILcnt)
{
PyEval_ReleaseThread(td->callstack.getFirst()->p->ts);
}
assert(td->GILcnt>=0);
}
// Called whenever C++ crosses into Python land
void FXPythonInterp::int_exitCPP()
{
QThread *cthread=QThread::current();
if(!cthread && !FXProcess::instance())
{ // Seems we're just about to exit - the lock will be in the right state
return;
}
QMtxHold h(indexlock, false);
ThreadData *td=index.find(cthread);
if(!td)
{
QMtxHold h(indexlock, true);
td=FXPythonInterpPrivate::addThread(cthread, 0);
}
h.unlock();
if(cthread) cthread->enableTermination();
if(!td->GILcnt++)
{
PyEval_AcquireThread(td->callstack.getFirst()->p->ts);
}
//fxmessage("Thread %d Setting %p (GILcnt=%d)\n", cthread->id(), td->callstack.getFirst()->p->ts, td->GILcnt);
}
//**************************************************************************************
using namespace boost::python;
template<typename fnspec> struct FOXSortFunc
{
template<typename base, int no> struct vector : public base
{
typedef typename Generic::FnInfo<fnspec> functionInfo;
typedef typename functionInfo::asList functionSpec;
typedef typename functionInfo::resultType retType;
typedef typename functionInfo::par1Type itemType;
static retType function(itemType a, itemType b)
{
return call<retType>(base::getParent()->lookupVector(no).ptr(), ptr(a), ptr(b));
}
};
};
#ifndef FX_DISABLEGUI
typedef FXCodeToPythonCode<FOXSortFunc<FXFoldingListSortFunc>::vector, SORTFUNCVECTORS> FXFoldingListVectorsType;
typedef FXCodeToPythonCode<FOXSortFunc<FXIconListSortFunc >::vector, SORTFUNCVECTORS> FXIconListVectorsType;
typedef FXCodeToPythonCode<FOXSortFunc<FXListSortFunc >::vector, SORTFUNCVECTORS> FXListVectorsType;
typedef FXCodeToPythonCode<FOXSortFunc<FXTreeListSortFunc >::vector, SORTFUNCVECTORS> FXTreeListVectorsType;
static FXListVectorsType FXComboBoxVectors;
static FXFoldingListVectorsType FXFoldingListVectors;
static FXIconListVectorsType FXIconListVectors;
static FXListVectorsType FXListVectors;
static FXListVectorsType FXListBoxVectors;
static FXTreeListVectorsType FXTreeListVectors;
static FXTreeListVectorsType FXTreeListBoxVectors;
#endif
static void checkIsPythonFunc(object *code, int pars)
{
assert(code);
FXERRH(PyCallable_Check(code->ptr()), "Python object must be callable", 0, FXERRH_ISDEBUG);
FXERRH(extract<int>((*code).attr("func_code").attr("co_argcount"))==pars, "Python code object has an incorrect number of parameters", 0, FXERRH_ISDEBUG);
}
#ifndef FX_DISABLEGUI
void FXPython::setFXComboBoxSortFunc(FXComboBox &list, boost::python::api::object *code)
{
checkIsPythonFunc(code, 2);
list.setSortFunc(FXComboBoxVectors.allocate(code));
}
void FXPython::setFXFoldingListSortFunc(FXFoldingList &list, boost::python::api::object *code)
{
checkIsPythonFunc(code, 2);
list.setSortFunc(FXFoldingListVectors.allocate(code));
}
void FXPython::setFXIconListSortFunc(FXIconList &list, boost::python::api::object *code)
{
checkIsPythonFunc(code, 2);
list.setSortFunc(FXIconListVectors.allocate(code));
}
void FXPython::setFXListSortFunc(FXList &list, boost::python::api::object *code)
{
checkIsPythonFunc(code, 2);
list.setSortFunc(FXListVectors.allocate(code));
}
void FXPython::setFXListBoxSortFunc(FXListBox &list, boost::python::api::object *code)
{
checkIsPythonFunc(code, 2);
list.setSortFunc(FXListBoxVectors.allocate(code));
}
void FXPython::setFXTreeListSortFunc(FXTreeList &list, boost::python::api::object *code)
{
checkIsPythonFunc(code, 2);
list.setSortFunc(FXTreeListVectors.allocate(code));
}
void FXPython::setFXTreeListBoxSortFunc(FXTreeListBox &list, boost::python::api::object *code)
{
checkIsPythonFunc(code, 2);
list.setSortFunc(FXTreeListBoxVectors.allocate(code));
}
template<typename base, int no> struct FXGLViewerVector : public base
{
typedef typename Generic::FnInfo<FXZSortFunc>::asList functionSpec;
static FXbool function(FXfloat *&buffer, FXint &used, FXint &size)
{ // Convert array of floats into a python container emulation (from CArrays.h)
typedef indexing::iterator_range<FXfloat *> IterPair;
class_<IterPair>("FXGLViewer_sortFuncIndirect", init<FXfloat *, FXfloat *>())
.def(indexing::container_suite<IterPair>());
IterPair pybuffer(buffer, buffer+size);
return call<FXbool>(base::getParent()->lookupVector(no).ptr(), pybuffer, used, size);
}
};
static FXCodeToPythonCode<FXGLViewerVector, SORTFUNCVECTORS> FXGLViewerVectors;
void FXPython::setFXGLViewerSortFunc(FXGLViewer &list, boost::python::api::object *code)
{
checkIsPythonFunc(code, 3);
list.setZSortFunc(FXGLViewerVectors.allocate(code));
}
#endif
void FXPython::int_throwPythonException()
{
assert(PyThreadState_Get());
PyObject *err=PyErr_Occurred();
if(!err) return;
if(PyErr_GivenExceptionMatches(err, PyExc_StopIteration))
{
#ifdef DEBUG
fxmessage("StopIteration exception thrown\n");
#endif
throw FXPythonException();
}
QTransString msg=QTrans::tr("FXPython", "%3,%4 at line %1 in %2");
{
PyObject *_type, *_pvalue, *_ptraceback;
PyErr_Fetch(&_type, &_pvalue, &_ptraceback);
PyErr_NormalizeException(&_type, &_pvalue, &_ptraceback);
if(!_type) return;
if(_ptraceback)
{
handle<> ptraceback(_ptraceback);
object traceback(ptraceback);
int lineno=extract<int>(traceback.attr("tb_lineno"));
str file(traceback.attr("tb_frame").attr("f_code").attr("co_filename"));
msg.arg(lineno).arg(FXString(extract<const char *>(file)));
}
else msg.arg("?").arg("?");
handle<> type(_type), pvalue(_pvalue);
str etype(type), eparam(pvalue);
msg.arg(FXString(extract<const char *>(etype))).arg(FXString(extract<const char *>(eparam)));
}
FXPythonException e(msg, 0);
FXERRH_THROW(e);
}
extern FXPYTHONAPI void *testfunc();
void *testfunc()
{
printf("Typeinfo of FXException in DLL is %p,%p (%s)\n", &typeid(FXException), typeid(FXException).name(), typeid(FXException).name());
printf("Typeinfo of FXPythonException in DLL is %p,%p (%s)\n", &typeid(FXPythonException), typeid(FXPythonException).name(), typeid(FXPythonException).name());
FXERRH_TRY
{
py( "print '\\nThrowing a python exception ...'\n"
"raise IOError, 'A parameter to a python exception'");
}
FXERRH_CATCH(FXException &e)
{
printf("Typeinfo of caught exception in DLL is %p,%p (%s)\n", &typeid(e), typeid(e).name(), typeid(e).name());
fxmessage("C++ exception caught: %s\n", e.report().text());
}
FXERRH_ENDTRY
static FXPythonException foo("Hello", 0);
void *ret=(void *) &foo;
printf("Typeinfo of pointer to be returned from DLL is %p,%p (%s)\n", &typeid(foo), typeid(foo).name(), typeid(foo).name());
return ret;
}
void FXPython::int_initEmbeddedEnv()
{
QThread *cthread=QThread::current();
QMtxHold h(indexlock, false);
ThreadData *td=index.find(cthread);
if(!td)
{
QMtxHold h(indexlock, true);
td=FXPythonInterpPrivate::addThread(cthread, PyThreadState_Get());
FXPythonInterp *myinterp=td->callstack.getLast();
myinterp->p->amMaster=true;
// Push current context
td->callstack.prepend(myinterp);
td->tsstack.prepend(0);
++td->GILcnt;
}
}
void FXPython::int_runPythonThread(PyObject *self, QThread *cthread)
{
FXPython_DoPython ctxhold;
handle<> ret(allow_null(PyEval_CallMethod(self, "run", "()")));
if(!ret)
{
if(PyErr_ExceptionMatches(PyExc_SystemExit))
{
PyErr_Clear();
return;
}
fxerrhpy(ret.get());
}
}
// The following are defined in converters.cpp:
// int_pythonObjectCreated(Generic::BoundFunctorV *detach);
// int_pythonObjectDeleted(Generic::BoundFunctorV *detach);
// long int_FXObjectHandle(FXObject *self, FXObject *sender, FXSelector sel, void_ *ptr);
}