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