[295381] | 1 | #ifndef BLACKBOX_H |
---|
| 2 | #define BLACKBOX_H |
---|
[92d684] | 3 | |
---|
| 4 | #include <misc/auxiliary.h> |
---|
[b5f5444] | 5 | #include <omalloc/omalloc.h> |
---|
[92d684] | 6 | |
---|
[295381] | 7 | #include <kernel/structs.h> |
---|
| 8 | #include <kernel/febase.h> |
---|
[92d684] | 9 | |
---|
| 10 | #include <Singular/lists.h> |
---|
[f84c3b] | 11 | #include <Singular/silink.h> |
---|
[295381] | 12 | |
---|
| 13 | void removeBlackboxStuff(const int rt); |
---|
| 14 | |
---|
| 15 | struct blackbox_struct; |
---|
| 16 | |
---|
| 17 | typedef struct blackbox_struct blackbox; |
---|
| 18 | |
---|
| 19 | struct blackbox_struct |
---|
| 20 | { |
---|
[437cb48] | 21 | /// destroy the object: b points to blackbox_struct, d to data |
---|
| 22 | void (*blackbox_destroy)(blackbox *b, void *d); |
---|
| 23 | /// convert the object to a string (which should be freed by omFree) |
---|
[295381] | 24 | char *(*blackbox_String)(blackbox *b,void *d); |
---|
[437cb48] | 25 | /// print the object: default: use string representation |
---|
[295381] | 26 | void (*blackbox_Print)(blackbox *b,void *d); |
---|
[437cb48] | 27 | /// construct the default object |
---|
[2df510] | 28 | void *(*blackbox_Init)(blackbox *b); |
---|
[437cb48] | 29 | /// copy the object: b points to blackbox_struct, d to data |
---|
[295381] | 30 | void *(*blackbox_Copy)(blackbox *b,void *d); |
---|
[437cb48] | 31 | /// interpreter assign: l:=r |
---|
[295381] | 32 | BOOLEAN (*blackbox_Assign)(leftv l, leftv r); |
---|
[437cb48] | 33 | /// interpreter: unary operations op(r), r(), ... |
---|
[295381] | 34 | BOOLEAN (*blackbox_Op1)(int op,leftv l, leftv r); |
---|
[437cb48] | 35 | /// interpreter: binary operations: op(r1,r2), r1 op r2,... |
---|
[295381] | 36 | BOOLEAN (*blackbox_Op2)(int op,leftv l, leftv r1,leftv r2); |
---|
[437cb48] | 37 | /// interpreter: tertiary op: op(r1,r2,r3) |
---|
[295381] | 38 | BOOLEAN (*blackbox_Op3)(int op,leftv l, leftv r1,leftv r2, leftv r3); |
---|
[437cb48] | 39 | /// interpreter: operations with undefined number of operands |
---|
[295381] | 40 | BOOLEAN (*blackbox_OpM)(int op,leftv l, leftv r); |
---|
[c728c0] | 41 | /// check internal structure |
---|
| 42 | BOOLEAN (*blackbox_Check)(blackbox *b,void *d); |
---|
[9fc2ffd] | 43 | /// serialize |
---|
[f84c3b] | 44 | BOOLEAN (*blackbox_serialize)(blackbox *b,void *d, si_link f); |
---|
[9fc2ffd] | 45 | /// deserialize |
---|
[a088a12] | 46 | BOOLEAN (*blackbox_deserialize)(blackbox **b,void **d, si_link f); |
---|
[2df510] | 47 | /// additional type info |
---|
| 48 | void *data; |
---|
[091193e] | 49 | /// addtinional gneral properties |
---|
[8db6c3] | 50 | int properties; // bit 0:blackbox is only a wrapper for lists |
---|
| 51 | #define BB_LIKE_LIST(B) ((B)->properties &1) |
---|
[295381] | 52 | } ; |
---|
[06fdbe] | 53 | /// default procedure blackboxDefaultOp1, to be called as "default:" branch |
---|
| 54 | BOOLEAN blackboxDefaultOp1(int op,leftv l, leftv r); |
---|
[e6d9a32] | 55 | |
---|
[c728c0] | 56 | /// default procedure blackboxDefaultOp2, to be called as "default:" branch |
---|
| 57 | BOOLEAN blackboxDefaultOp2(int op,leftv l, leftv r1, leftv r2); |
---|
[295381] | 58 | |
---|
[e6d9a32] | 59 | /// default procedure blackboxDefaultOpM, to be called as "default:" branch |
---|
| 60 | BOOLEAN blackbox_default_OpM(int op,leftv l, leftv r); |
---|
| 61 | |
---|
[06c0b3] | 62 | /// default procedure to print this blackbox |
---|
| 63 | void blackbox_default_Print(blackbox *b,void *d); |
---|
| 64 | |
---|
[437cb48] | 65 | /// return the structure to the type given by t |
---|
[295381] | 66 | blackbox* getBlackboxStuff(const int t); |
---|
[437cb48] | 67 | /// return the name to the type given by t (r/o) |
---|
[295381] | 68 | const char * getBlackboxName(const int t); |
---|
[437cb48] | 69 | /// used by scanner: returns ROOTDECL for known types (and the type number in t) |
---|
[295381] | 70 | int blackboxIsCmd(const char *n, int & tok); |
---|
[437cb48] | 71 | /// define a new type |
---|
[2df510] | 72 | int setBlackboxStuff(blackbox *bb,const char *name); |
---|
[295381] | 73 | |
---|
[437cb48] | 74 | /// list all defined type (for debugging) |
---|
[295381] | 75 | void printBlackboxTypes(); |
---|
| 76 | |
---|
[f24733] | 77 | /// Emit an "op not implemented" error message and return TRUE |
---|
| 78 | BOOLEAN WrongOp(const char* cmd, int op, leftv bb); |
---|
| 79 | |
---|
[295381] | 80 | #endif |
---|