source: git/Singular/pyobject_setup.cc @ 97dcf5

spielwiese
Last change on this file since 97dcf5 was 2e4ec14, checked in by Yue Ren <ren@…>, 11 years ago
fix: -Wunused-parameter warnings
  • 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#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#ifdef EMBED_PYTHON
22#include "pyobject.cc"
23#endif
24
25static BOOLEAN pyobject_load()
26{
27  return jjLOAD("pyobject.so", TRUE);
28}
29
30/// blackbox support - initialization via autoloading
31void* pyobject_autoload(blackbox* bbx)
32{
33  assume(bbx != NULL);
34  return (pyobject_load() || (bbx->blackbox_Init == pyobject_autoload)? 
35          NULL: bbx->blackbox_Init(bbx));
36}
37
38void pyobject_default_destroy(blackbox  */*b*/, void */*d*/)
39{
40  Werror("Python-based functionality not available!");
41}
42
43// Setting up an empty blackbox type, which can be filled with pyobject
44void pyobject_setup() 
45{
46  blackbox *bbx = (blackbox*)omAlloc0(sizeof(blackbox));
47  bbx->blackbox_Init = pyobject_autoload;
48  bbx->blackbox_destroy = pyobject_default_destroy;
49  setBlackboxStuff(bbx, "pyobject");
50}
51
52/// Explicitely load, if not loaded already
53BOOLEAN pyobject_ensure() {
54
55  int tok = -1;
56  blackbox* bbx = (blackboxIsCmd("pyobject", tok) == ROOT_DECL?
57                   getBlackboxStuff(tok): (blackbox*)NULL);
58  if (bbx == NULL) return TRUE;
59  return (bbx->blackbox_Init == pyobject_autoload?  pyobject_load(): FALSE); 
60}
61
62
63
Note: See TracBrowser for help on using the repository browser.