Changeset ec1006 in git
- Timestamp:
- Dec 7, 2012, 4:31:22 PM (10 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '00e2e9c41af3fde1273eb3633f4c0c7c3db2579d')
- Children:
- bf7dfc43347df3010846b62ff38fa0b4e8b30247
- Parents:
- 6554ca42ebe1277c9afe7990970390905a6e1cf02ac2935796fc44d19ee67851bc57153313ee297b
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile.am
r6554ca4 rec1006 37 37 38 38 bin_SCRIPTS = libsingular-config 39 -
Singular/Makefile.am
r6554ca4 rec1006 88 88 links/ssiLink.cc\ 89 89 subexpr.cc\ 90 pyobject_setup.cc\ 90 91 walk.cc\ 91 92 walk_ip.cc\ … … 390 391 MOD: ${top_builddir}/libpolys/polys/.libs 391 392 ln -snf ${top_builddir}/libpolys/polys/.libs/ ${builddir}/MOD 393 394 if PYTHON_USE 395 moduledir = $(bindir)/MOD 396 module_LTLIBRARIES = pyobject.la 397 pyobject_la_SOURCES = pyobject.cc 398 399 pyobject_la_CPPFLAGS = ${AM_CPPFLAGS} ${NODEBUGDEFS} 400 pyobject_g_la_CPPFLAGS = ${AM_CPPFLAGS} 401 402 pyobject_la_CXXFLAGS = ${NODEBUGCXXFLAGS} @PYTHON_CSPEC@ 403 pyobject_g_la_CXXFLAGS = ${DEBUGCXXFLAGS} @PYTHON_CSPEC@ 404 405 pyobject_la_LDFLAGS = -export-dynamic -shared -module -avoid-version \ 406 ${AMLDFLAGS} @PYTHON_LSPEC@ 407 endif -
Singular/blackbox.h
r6554ca4 rec1006 58 58 59 59 /// default procedure blackboxDefaultOp3, to be called as "default:" branch 60 BOOLEAN blackbox DefaultOp3(int op,leftv l, leftv r1,leftv r2, leftv r3);60 BOOLEAN blackbox_default_Op3(int op,leftv l, leftv r1,leftv r2, leftv r3); 61 61 62 62 /// default procedure blackboxDefaultOpM, to be called as "default:" branch … … 70 70 /// return the name to the type given by t (r/o) 71 71 const char * getBlackboxName(const int t); 72 /// used by scanner: returns ROOTDECL for known types (and the type number in t) 72 /// used by scanner: returns ROOT_DECL for known types 73 /// (and the type number in @c tok) 73 74 int blackboxIsCmd(const char *n, int & tok); 74 75 /// define a new type -
Singular/iparith.cc
r6554ca4 rec1006 5206 5206 } 5207 5207 return TRUE; 5208 } 5209 5210 BOOLEAN jjLOADLIB(const char* libname, BOOLEAN autoexport) 5211 { 5212 leftv v = (leftv)omAlloc0Bin(sleftv_bin); 5213 v->data = (char*)libname; 5214 v->rtyp = STRING_CMD; 5215 BOOLEAN res = jjLOAD(NULL, v, autoexport); 5216 omFreeBin(v, sleftv_bin); 5217 5218 return res; 5208 5219 } 5209 5220 -
Singular/ipid.cc
r6554ca4 rec1006 194 194 IDLEV(h) = level; 195 195 IDNEXT(h) = this; 196 BOOLEAN at_start=(this==IDROOT); 196 197 h->id_i=iiS2I(s); 197 198 if (init) … … 221 222 } 222 223 // -------------------------------------------------------- 224 if (at_start) 225 IDNEXT(h) = IDROOT; 223 226 return h; 224 227 } -
Singular/pyobject.cc
r6554ca4 rec1006 15 15 #include "config.h" 16 16 #include <kernel/mod2.h> 17 //#include <misc/auxiliary.h> 18 //#include "newstruct.h" 19 20 #include <Python.h> 21 22 #include <Singular/ipid.h> 23 #include <Singular/blackbox.h> 24 #include <Singular/lists.h> 25 #include <Singular/ipid.h> 26 #include <Singular/ipshell.h> 27 #include <Singular/newstruct.h> 28 29 17 30 #include <misc/auxiliary.h> 18 #include "newstruct.h"19 31 20 32 #include <omalloc/omalloc.h> 21 33 22 34 #include <kernel/febase.h> 23 #include < kernel/intvec.h>35 #include <misc/intvec.h> 24 36 25 37 #include "subexpr.h" … … 27 39 #include "ipid.h" 28 40 #include "blackbox.h" 29 30 #include <Python.h> 41 #include "ipshell.h" 42 43 44 45 46 //#include <Python.h> 31 47 // #include <iterator> // std::distance 32 48 // #include <stdio.h> … … 48 64 /// Initialize unique (singleton) python interpreter instance, 49 65 /// and set Singular type identifier 50 static void init(id_type num 66 static void init(id_type num) { instance().m_id = num; } 51 67 52 68 /// Get Singular type identitfier … … 587 603 return FALSE; 588 604 589 return blackbox DefaultOp3(op, res, arg1, arg2, arg3);605 return blackbox_default_Op3(op, res, arg1, arg2, arg3); 590 606 } 591 607 … … 686 702 687 703 688 // forward declaration 689 int iiAddCproc(char *libname, char *procname, BOOLEAN pstatic, 690 BOOLEAN(*func)(leftv res, leftv v)); 691 692 #define ADD_C_PROC(name) iiAddCproc("", (char*)#name, FALSE, name); 693 694 695 void pyobject_init() 696 { 697 blackbox *b = (blackbox*)omAlloc0(sizeof(blackbox)); 698 b->blackbox_destroy = pyobject_destroy; 699 b->blackbox_String = pyobject_String; 700 b->blackbox_Init = pyobject_Init; 701 b->blackbox_Copy = pyobject_Copy; 702 b->blackbox_Assign = pyobject_Assign; 703 b->blackbox_Op1 = pyobject_Op1; 704 b->blackbox_Op2 = pyobject_Op2; 705 b->blackbox_Op3 = pyobject_Op3; 706 b->blackbox_OpM = pyobject_OpM; 707 b->data = omAlloc0(newstruct_desc_size()); 708 709 PythonInterpreter::init(setBlackboxStuff(b,"pyobject")); 710 711 ADD_C_PROC(python_import); 712 ADD_C_PROC(python_eval); 713 ADD_C_PROC(python_run); 714 } 715 716 extern "C" { void mod_init() { pyobject_init(); } } 717 704 705 blackbox* pyobject_blackbox(int& tok) { 706 if(blackboxIsCmd("pyobject", tok) != ROOT_DECL) 707 { 708 tok = setBlackboxStuff((blackbox*)omAlloc0(sizeof(blackbox)), 709 "pyobject"); 710 } 711 return getBlackboxStuff(tok); 712 } 713 714 715 716 #define PYOBJECT_ADD_C_PROC(name) \ 717 add_C_proc(currPack->libname, (char*)#name, FALSE, name); 718 719 typedef BOOLEAN (*func_type)(leftv, leftv); 720 void pyobject_init(int (*add_C_proc)(const char*, const char*, BOOLEAN, 721 func_type) ) 722 { 723 int tok = -1; 724 blackbox* bbx = pyobject_blackbox(tok); 725 if (bbx->blackbox_Init != pyobject_Init) 726 { 727 bbx->blackbox_destroy = pyobject_destroy; 728 bbx->blackbox_String = pyobject_String; 729 bbx->blackbox_Init = pyobject_Init; 730 bbx->blackbox_Copy = pyobject_Copy; 731 bbx->blackbox_Assign = pyobject_Assign; 732 bbx->blackbox_Op1 = pyobject_Op1; 733 bbx->blackbox_Op2 = pyobject_Op2; 734 bbx->blackbox_Op3 = pyobject_Op3; 735 bbx->blackbox_OpM = pyobject_OpM; 736 bbx->data = omAlloc0(newstruct_desc_size()); 737 738 PythonInterpreter::init(tok); 739 740 PYOBJECT_ADD_C_PROC(python_import); 741 PYOBJECT_ADD_C_PROC(python_eval); 742 PYOBJECT_ADD_C_PROC(python_run); 743 } 744 } 745 #undef PYOBJECT_ADD_C_PROC 746 747 #ifndef EMBED_PYTHON 748 extern "C" { 749 void mod_init(SModulFunctions* psModulFunctions) 750 { 751 pyobject_init(psModulFunctions->iiAddCproc); 752 } 753 } 754 #endif -
Singular/pyobject_setup.cc
r6554ca4 rec1006 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 -
Singular/tesths.cc
r6554ca4 rec1006 43 43 #include "fegetopt.h" 44 44 45 //#include "pyobject_setup.h"45 #include "pyobject_setup.h" 46 46 47 47 #include <unistd.h> -
configure.ac
r6554ca4 rec1006 61 61 LB_CHECK_NTL(5.0,,AC_MSG_WARN([Unable to find NTL (which is strongly recommended) on your machine: please use --with-ntl=PATH_TO_DIR_CONTAINING_LIB_AND_INCLUDE (see also ./configure --help if you do not understand what we are talking about)])) 62 62 LB_CHECK_FLINT(2.3,,AC_MSG_WARN([Unable to find FLINT (which is strongly recommended) on your machine: please use --with-flint=PATH_TO_DIR_CONTAINING_LIB_AND_INCLUDE (see also ./configure --help if you do not understand what we are talking about)])) 63 64 AX_PYTHON_ENABLE() 65 AX_PYTHON_WITH() 66 AX_PYTHON_VERSION_ENSURE( [2.4] ) 67 AX_PYTHON_DEVEL([>= 2.4]) 68 AX_PYTHON_LSPEC() 69 AX_PYTHON_CSPEC() 63 70 64 71 AC_FUNC_ERROR_AT_LINE
Note: See TracChangeset
for help on using the changeset viewer.