Loading...
Searching...
No Matches
pyobject_setup.cc
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
/** @file pyobject_setup.cc
*
* @author Alexander Dreyer
* @date 2010-12-15
*
* This header file defines the @c blackbox setup operations for the pyobject
*
* @par Copyright:
* (c) 2010 by The Singular Team, see LICENSE file
**/
//*****************************************************************************
#include "kernel/mod2.h"
#include "Singular/blackbox.h"
#include "Singular/ipshell.h"
static BOOLEAN pyobject_load()
{
return jjLOAD("pyobject.so", TRUE);
}
/// blackbox support - initialization via autoloading
void* pyobject_autoload(blackbox* bbx)
{
assume(bbx != NULL);
return (pyobject_load() || (bbx->blackbox_Init == pyobject_autoload)?
NULL: bbx->blackbox_Init(bbx));
}
void pyobject_default_destroy(blackbox */*b*/, void */*d*/)
{
WerrorS("Python-based functionality not available!");
}
// Setting up an empty blackbox type, which can be filled with pyobject
void pyobject_setup()
{
blackbox *bbx = (blackbox*)omAlloc0(sizeof(blackbox));
bbx->blackbox_Init = pyobject_autoload;
bbx->blackbox_destroy = pyobject_default_destroy;
setBlackboxStuff(bbx, "pyobject");
}
/// Explicitely load, if not loaded already
BOOLEAN pyobject_ensure()
{
int tok = -1;
blackbox* bbx = (blackboxIsCmd("pyobject", tok) == ROOT_DECL?
getBlackboxStuff(tok): (blackbox*)NULL);
if (bbx == NULL) return TRUE;
return (bbx->blackbox_Init == pyobject_autoload? pyobject_load(): FALSE);
}
BOOLEAN
int BOOLEAN
Definition auxiliary.h:88
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
setBlackboxStuff
int setBlackboxStuff(blackbox *bb, const char *n)
define a new type
Definition blackbox.cc:143
getBlackboxStuff
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition blackbox.cc:17
blackboxIsCmd
int blackboxIsCmd(const char *n, int &tok)
used by scanner: returns ROOT_DECL for known types (and the type number in tok)
Definition blackbox.cc:219
blackbox.h
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
ROOT_DECL
@ ROOT_DECL
Definition grammar.cc:320
jjLOAD
BOOLEAN jjLOAD(const char *s, BOOLEAN autoexport)
load lib/module given in v
Definition iparith.cc:5591
ipshell.h
mod2.h
assume
#define assume(x)
Definition mod2.h:389
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
NULL
#define NULL
Definition omList.c:12
pyobject_setup
void pyobject_setup()
initialize blackbox support for pyobject; functionilty os autoloaded on demand
Definition pyobject_setup.cc:39
pyobject_load
static BOOLEAN pyobject_load()
Definition pyobject_setup.cc:20
pyobject_ensure
BOOLEAN pyobject_ensure()
Explicitely load, if not loaded already.
Definition pyobject_setup.cc:48
pyobject_default_destroy
void pyobject_default_destroy(blackbox *, void *)
Definition pyobject_setup.cc:33
pyobject_autoload
void * pyobject_autoload(blackbox *bbx)
blackbox support - initialization via autoloading
Definition pyobject_setup.cc:26