source: git/Singular/pyobject_setup.cc @ ba5e9e

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