Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /*********************************************************************** |
2 | * director.swg | |
3 | * | |
4 | * This file contains support for director classes that proxy | |
5 | * method calls from C++ to Python extensions. | |
6 | * | |
7 | * Author : Mark Rose (mrose@stm.lbl.gov) | |
8 | ************************************************************************/ | |
9 | ||
10 | #ifdef __cplusplus | |
11 | ||
12 | namespace Swig { | |
13 | /* simple thread abstraction for pthreads on win32 */ | |
14 | Director::~Director() { | |
15 | swig_decref(); | |
16 | } | |
17 | ||
18 | bool Director::swig_up = false; | |
19 | ||
20 | #ifdef __PTHREAD__ | |
21 | MUTEX_INIT(Director::swig_mutex_up); | |
22 | pthread_t Director::swig_mutex_thread; | |
23 | bool Director::swig_mutex_active = false; | |
24 | #endif | |
25 | ||
26 | ||
27 | void UnknownExceptionHandler::handler() { | |
28 | try { | |
29 | throw; | |
30 | } catch (DirectorException& e) { | |
31 | std::cerr << "Swig Director exception caught:" << std::endl | |
32 | << e.getMessage() << std::endl; | |
33 | } catch (std::exception& e) { | |
34 | std::cerr << "std::exception caught: "<< e.what() << std::endl; | |
35 | } catch (...) { | |
36 | std::cerr << "Unknown exception caught." << std::endl; | |
37 | } | |
38 | ||
39 | std::cerr << std::endl | |
40 | << "Python interpreter traceback:" << std::endl; | |
41 | PyErr_Print(); | |
42 | std::cerr << std::endl; | |
43 | ||
44 | std::cerr << "This exception was caught by the SWIG unexpected exception handler." << std::endl | |
45 | << "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl | |
46 | << std::endl | |
47 | << "Exception is being re-thrown, program will like abort/terminate." << std::endl; | |
48 | throw; | |
49 | } | |
50 | ||
51 | } | |
52 | ||
53 | #endif /* __cplusplus */ | |
54 |