Changeset 2ac2935 in git for Singular/pyobject_setup.cc
- Timestamp:
- Dec 7, 2012, 3:41:00 PM (11 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- ec1006cbd9971c4271d05aefada775ef29d762a6
- Parents:
- 7e18d198148353f88708cfa20f738ac338cb1f556554ca42ebe1277c9afe7990970390905a6e1cf0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/pyobject_setup.cc
r6554ca4 r2ac2935 16 16 #include <kernel/mod2.h> 17 17 #include <kernel/febase.h> 18 #include <Singular/blackbox.h> 19 #include <Singular/ipshell.h> 18 20 19 21 /* whether pyobject module is linked statically or dynamically */ 22 23 #ifdef EMBED_PYTHON // Case: we include the pyobject interface in the binary 24 20 25 #ifdef HAVE_PYTHON 26 #include "pyobject.cc" 27 static BOOLEAN pyobject_load() 28 { 29 pyobject_init(iiAddCproc); 30 return FALSE; 31 } 21 32 22 #if defined(HAVE_STATIC) 23 #ifdef HAVE_STATIC_PYTHON 24 #define HAVE_STATIC_PYOBJECT 25 #endif 26 #else 27 #ifdef EMBED_PYTHON 28 #define HAVE_STATIC_PYOBJECT 29 #else 30 #define HAVE_DYNAMIC_PYOBJECT 31 #endif 32 #endif 33 #else // Forced embedding, but no (development version of) python available! 34 static BOOLEAN pyobject_load() { return TRUE; } 33 35 #endif 34 36 35 # ifdef HAVE_STATIC_PYOBJECT // Case: link pyobject interface statically 36 #include "pyobject.cc" 37 void pyobject_setup() { pyobject_init(); } 37 38 # else // Case: pyobject may be loaded from a dynamic module (prefered variant) 39 // Note: we do not need python at compile time. 40 static BOOLEAN pyobject_load() 41 { 42 BOOLEAN jjLOADLIB(const char* libname, BOOLEAN autoexport); 43 return jjLOADLIB("pyobject.so", TRUE); 44 } 45 #endif 38 46 39 47 40 # elif defined(HAVE_DYNAMIC_PYOBJECT) // Case: pyobject is dynamic module (prefered variant)41 48 42 // forward declaration for Singular/iplib.cc 43 void* binary_module_function(const char* lib, const char* func); 44 void pyobject_setup() 49 /// blackbox support - initialization via autoloading 50 void* pyobject_autoload(blackbox* bbx) 45 51 { 46 void* fktn = binary_module_function("pyobject", "mod_init"); 47 if (fktn) (* reinterpret_cast<void (*)()>(fktn) )(); 48 else Werror("python related functions are not available"); 52 if (pyobject_load()) return NULL; 53 return bbx->blackbox_Init(bbx); 49 54 } 50 55 51 #else // Case: no python 52 void pyobject_setup() { } 56 void pyobject_default_destroy(blackbox *b, void *d) 57 { 58 Werror("Python-based functionality not available!"); 59 } 53 60 54 #endif // HAVE_PYTHON 61 // Setting up an empty blackbox type, which can be filled with pyobject 62 void pyobject_setup() 63 { 64 blackbox *bbx = (blackbox*)omAlloc0(sizeof(blackbox)); 65 bbx->blackbox_Init = pyobject_autoload; 66 bbx->blackbox_destroy = pyobject_default_destroy; 67 setBlackboxStuff(bbx, "pyobject"); 68 } 55 69
Note: See TracChangeset
for help on using the changeset viewer.