Changeset 2ac2935 in git for Singular/pyobject_setup.cc


Ignore:
Timestamp:
Dec 7, 2012, 3:41:00 PM (11 years ago)
Author:
Alexander Dreyer <adreyer@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
ec1006cbd9971c4271d05aefada775ef29d762a6
Parents:
7e18d198148353f88708cfa20f738ac338cb1f556554ca42ebe1277c9afe7990970390905a6e1cf0
Message:
Merge conflict resolved
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/pyobject_setup.cc

    r6554ca4 r2ac2935  
    1616#include <kernel/mod2.h>
    1717#include <kernel/febase.h>
     18#include <Singular/blackbox.h>
     19#include <Singular/ipshell.h>
    1820
    1921/* whether pyobject module is linked statically or dynamically */
     22
     23#ifdef EMBED_PYTHON // Case: we include the pyobject interface in the binary
     24
    2025#ifdef HAVE_PYTHON
     26#include "pyobject.cc"
     27static BOOLEAN pyobject_load()
     28{
     29   pyobject_init(iiAddCproc);
     30   return FALSE;
     31}
    2132
    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!
     34static BOOLEAN pyobject_load() { return TRUE; }
    3335#endif
    3436
    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.
     40static BOOLEAN pyobject_load()
     41{
     42  BOOLEAN jjLOADLIB(const char* libname, BOOLEAN autoexport);
     43  return jjLOADLIB("pyobject.so", TRUE);
     44}
     45#endif
    3846
    3947
    40 # elif defined(HAVE_DYNAMIC_PYOBJECT) // Case: pyobject is dynamic module (prefered variant)
    4148
    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
     50void* pyobject_autoload(blackbox* bbx)
    4551{
    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);
    4954}
    5055
    51 #else                // Case: no python
    52 void pyobject_setup() { }
     56void pyobject_default_destroy(blackbox  *b, void *d)
     57{
     58  Werror("Python-based functionality not available!");
     59}
    5360
    54 #endif  // HAVE_PYTHON
     61// Setting up an empty blackbox type, which can be filled with pyobject
     62void 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}
    5569
Note: See TracChangeset for help on using the changeset viewer.