blackbox.h
Go to the documentation of this file.
1 #ifndef BLACKBOX_H
2 #define BLACKBOX_H
3 
4 #include <kernel/mod2.h>
5 #include <omalloc/omalloc.h>
6 
7 #include <kernel/structs.h>
8 
9 #include <Singular/lists.h>
10 #include <Singular/links/silink.h>
11 
12 void removeBlackboxStuff(const int rt);
13 
14 struct blackbox_struct;
15 
16 typedef struct blackbox_struct blackbox;
17 
19 {
20  /// destroy the object: b points to blackbox_struct, d to data
21  void (*blackbox_destroy)(blackbox *b, void *d);
22  /// convert the object to a string (which should be freed by omFree)
23  char *(*blackbox_String)(blackbox *b,void *d);
24  /// print the object: default: use string representation
25  void (*blackbox_Print)(blackbox *b,void *d);
26  /// construct the default object
27  void *(*blackbox_Init)(blackbox *b);
28  /// copy the object: b points to blackbox_struct, d to data
29  void *(*blackbox_Copy)(blackbox *b,void *d);
30  /// interpreter assign: l:=r
32  /// interpreter: unary operations op(r), r(), ...
33  // convention for blackbox_Op1..blackbox_OpM:
34  // return FALSE, if op was successfully performed
35  // return TRUE (and an error message) for failure
36  // return TRUE (and no error message) if not defined
38  /// interpreter: binary operations: op(r1,r2), r1 op r2,...
39  BOOLEAN (*blackbox_Op2)(int op,leftv l, leftv r1,leftv r2);
40  /// interpreter: tertiary op: op(r1,r2,r3)
41  BOOLEAN (*blackbox_Op3)(int op,leftv l, leftv r1,leftv r2, leftv r3);
42  /// interpreter: operations with undefined number of operands
44  /// is an assign of r to l (part of b) impossible?
46  /// serialize
47  BOOLEAN (*blackbox_serialize)(blackbox *b,void *d, si_link f);
48  /// deserialize
49  BOOLEAN (*blackbox_deserialize)(blackbox **b,void **d, si_link f);
50  /// additional type info
51  void *data;
52  /// addtinional gneral properties
53  int properties; // bit 0:blackbox is only a wrapper for lists
54 #define BB_LIKE_LIST(B) ((B)->properties &1)
55 } ;
56 /// default procedure blackboxDefaultOp1, to be called as "default:" branch
58 
59 /// default procedure blackboxDefaultOp2, to be called as "default:" branch
61 
62 /// default procedure blackboxDefaultOp3, to be called as "default:" branch
63 BOOLEAN blackboxDefaultOp3(int op,leftv l, leftv r1,leftv r2, leftv r3);
64 
65 /// default procedure blackboxDefaultOpM, to be called as "default:" branch
67 
68 /// default procedure blackbox_default_Print: print the string
69 void blackbox_default_Print(blackbox *b,void *d);
70 
71 /// return the structure to the type given by t
72 blackbox* getBlackboxStuff(const int t);
73 /// return the name to the type given by t (r/o)
74 const char * getBlackboxName(const int t);
75 /// used by scanner: returns ROOT_DECL for known types
76 /// (and the type number in @c tok)
77 int blackboxIsCmd(const char *n, int & tok);
78 /// define a new type
79 int setBlackboxStuff(blackbox *bb,const char *name);
80 
81 /// list all defined type (for debugging)
82 void printBlackboxTypes();
83 
84 #endif
void printBlackboxTypes()
list all defined type (for debugging)
Definition: blackbox.cc:208
void(* blackbox_destroy)(blackbox *b, void *d)
destroy the object: b points to blackbox_struct, d to data
Definition: blackbox.h:21
BOOLEAN(* blackbox_Assign)(leftv l, leftv r)
interpreter assign: l:=r
Definition: blackbox.h:31
int setBlackboxStuff(blackbox *bb, const char *name)
define a new type
Definition: blackbox.cc:126
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
BOOLEAN(* blackbox_Op2)(int op, leftv l, leftv r1, leftv r2)
interpreter: binary operations: op(r1,r2), r1 op r2,...
Definition: blackbox.h:39
void blackbox_default_Print(blackbox *b, void *d)
default procedure blackbox_default_Print: print the string
Definition: blackbox.cc:39
void * data
additional type info
Definition: blackbox.h:51
BOOLEAN(* blackbox_OpM)(int op, leftv l, leftv r)
interpreter: operations with undefined number of operands
Definition: blackbox.h:43
const ring r
Definition: syzextra.cc:208
BOOLEAN blackboxDefaultOp2(int op, leftv l, leftv r1, leftv r2)
default procedure blackboxDefaultOp2, to be called as "default:" branch
Definition: blackbox.cc:81
void removeBlackboxStuff(const int rt)
Definition: blackbox.cc:178
BOOLEAN(* blackbox_deserialize)(blackbox **b, void **d, si_link f)
deserialize
Definition: blackbox.h:49
void(* blackbox_Print)(blackbox *b, void *d)
print the object: default: use string representation
Definition: blackbox.h:25
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:191
BOOLEAN blackboxDefaultOp3(int op, leftv l, leftv r1, leftv r2, leftv r3)
default procedure blackboxDefaultOp3, to be called as "default:" branch
Definition: blackbox.cc:86
FILE * f
Definition: checklibs.c:9
char name(const Variable &v)
Definition: factory.h:178
BOOLEAN(* blackbox_serialize)(blackbox *b, void *d, si_link f)
serialize
Definition: blackbox.h:47
BOOLEAN blackboxDefaultOpM(int op, leftv l, leftv r)
default procedure blackboxDefaultOpM, to be called as "default:" branch
Definition: blackbox.cc:91
int properties
addtinional gneral properties
Definition: blackbox.h:53
const char * getBlackboxName(const int t)
return the name to the type given by t (r/o)
Definition: blackbox.cc:185
BOOLEAN(* blackbox_Op3)(int op, leftv l, leftv r1, leftv r2, leftv r3)
interpreter: tertiary op: op(r1,r2,r3)
Definition: blackbox.h:41
BOOLEAN(* blackbox_Op1)(int op, leftv l, leftv r)
interpreter: unary operations op(r), r(), ...
Definition: blackbox.h:37
BOOLEAN(* blackbox_CheckAssign)(blackbox *b, leftv l, leftv r)
is an assign of r to l (part of b) impossible?
Definition: blackbox.h:45
int BOOLEAN
Definition: auxiliary.h:85
const poly b
Definition: syzextra.cc:213
BOOLEAN blackboxDefaultOp1(int op, leftv l, leftv r)
default procedure blackboxDefaultOp1, to be called as "default:" branch
Definition: blackbox.cc:62
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:16
int l
Definition: cfEzgcd.cc:94