source: git/Singular/pyobject_setup.cc @ 35a0c12

spielwiese
Last change on this file since 35a0c12 was 35a0c12, checked in by Alexander Dreyer <adreyer@…>, 11 years ago
pyobject.so now autoloaded when needed
  • Property mode set to 100644
File size: 1.8 KB
Line 
1// -*- c++ -*-
2//*****************************************************************************
3/** @file pyobject_setup.cc
4 *
5 * @author Alexander Dreyer
6 * @date 2010-12-15
7 *
8 * This header file defines the @c blackbox setup operations for the pyobject
9 *
10 * @par Copyright:
11 *   (c) 2010 by The Singular Team, see LICENSE file
12**/
13//*****************************************************************************
14
15#include "config.h"
16#include <kernel/mod2.h>
17#include <kernel/febase.h>
18#include <Singular/blackbox.h>
19#include <Singular/ipshell.h>
20
21/* whether pyobject module is linked statically or dynamically */
22#ifdef HAVE_PYTHON
23
24  #if defined(HAVE_STATIC)
25    #ifdef HAVE_STATIC_PYTHON
26      #define HAVE_STATIC_PYOBJECT
27    #endif
28  #else
29    #ifdef EMBED_PYTHON
30      #define HAVE_STATIC_PYOBJECT
31    #else
32      #define HAVE_DYNAMIC_PYOBJECT
33    #endif
34  #endif
35#endif
36
37# ifdef HAVE_STATIC_PYOBJECT // Case: link pyobject interface statically
38#include "pyobject.cc"
39void pyobject_setup() { pyobject_init(); }
40
41
42# elif defined(HAVE_DYNAMIC_PYOBJECT) // Case: pyobject is dynamic module (prefered variant)
43
44
45/// blackbox support - initialization via autoloading
46void* pyobject_autoload(blackbox* bbx)
47{
48  BOOLEAN jjLOADLIB(const char* libname, BOOLEAN autoexport);
49  if (jjLOADLIB("pyobject.so", TRUE)) return NULL;
50
51  return bbx->blackbox_Init(bbx);
52}
53
54void pyobject_default_destroy(blackbox  *b, void *d)
55{
56  Werror("Python-based functionality not available!");
57}
58
59// Setting up an empty blackbox type, which can be filled with pyobject
60void pyobject_setup() 
61{
62  blackbox *bbx = (blackbox*)omAlloc0(sizeof(blackbox));
63  bbx->blackbox_Init = pyobject_autoload;
64  bbx->blackbox_destroy = pyobject_default_destroy;
65  setBlackboxStuff(bbx, "pyobject");
66}
67 
68#else                // Case: no python
69void pyobject_setup() { }
70
71#endif  // HAVE_PYTHON
72
Note: See TracBrowser for help on using the repository browser.