source: git/Singular/pyobject_setup.cc @ 380a17b

spielwiese
Last change on this file since 380a17b was 16f511, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
Fixed the usage of "config.h" (if defined HAVE_CONFIG_H)
  • Property mode set to 100644
File size: 1.6 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#ifdef HAVE_CONFIG_H
16#include "config.h"
17#endif /* HAVE_CONFIG_H */
18#include <kernel/mod2.h>
19#include <kernel/febase.h>
20#include <Singular/blackbox.h>
21#include <Singular/ipshell.h>
22
23#ifdef EMBED_PYTHON
24#include "pyobject.cc"
25#endif
26
27static BOOLEAN pyobject_load()
28{
29  return jjLOAD("pyobject.so", TRUE);
30}
31
32/// blackbox support - initialization via autoloading
33void* pyobject_autoload(blackbox* bbx)
34{
35  assume(bbx != NULL);
36  return (pyobject_load() || (bbx->blackbox_Init == pyobject_autoload)? 
37          NULL: bbx->blackbox_Init(bbx));
38}
39
40void pyobject_default_destroy(blackbox  */*b*/, void */*d*/)
41{
42  Werror("Python-based functionality not available!");
43}
44
45// Setting up an empty blackbox type, which can be filled with pyobject
46void pyobject_setup() 
47{
48  blackbox *bbx = (blackbox*)omAlloc0(sizeof(blackbox));
49  bbx->blackbox_Init = pyobject_autoload;
50  bbx->blackbox_destroy = pyobject_default_destroy;
51  setBlackboxStuff(bbx, "pyobject");
52}
53
54/// Explicitely load, if not loaded already
55BOOLEAN pyobject_ensure() {
56
57  int tok = -1;
58  blackbox* bbx = (blackboxIsCmd("pyobject", tok) == ROOT_DECL?
59                   getBlackboxStuff(tok): (blackbox*)NULL);
60  if (bbx == NULL) return TRUE;
61  return (bbx->blackbox_Init == pyobject_autoload?  pyobject_load(): FALSE); 
62}
63
64
65
Note: See TracBrowser for help on using the repository browser.