[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> |
---|
[92d684] | 8 | |
---|
| 9 | #include <Singular/lists.h> |
---|
[44ca2f] | 10 | #include <Singular/links/silink.h> |
---|
[295381] | 11 | |
---|
| 12 | void removeBlackboxStuff(const int rt); |
---|
| 13 | |
---|
| 14 | struct blackbox_struct; |
---|
| 15 | |
---|
| 16 | typedef struct blackbox_struct blackbox; |
---|
| 17 | |
---|
| 18 | struct blackbox_struct |
---|
| 19 | { |
---|
[437cb48] | 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) |
---|
[295381] | 23 | char *(*blackbox_String)(blackbox *b,void *d); |
---|
[437cb48] | 24 | /// print the object: default: use string representation |
---|
[295381] | 25 | void (*blackbox_Print)(blackbox *b,void *d); |
---|
[437cb48] | 26 | /// construct the default object |
---|
[2df510] | 27 | void *(*blackbox_Init)(blackbox *b); |
---|
[437cb48] | 28 | /// copy the object: b points to blackbox_struct, d to data |
---|
[295381] | 29 | void *(*blackbox_Copy)(blackbox *b,void *d); |
---|
[437cb48] | 30 | /// interpreter assign: l:=r |
---|
[295381] | 31 | BOOLEAN (*blackbox_Assign)(leftv l, leftv r); |
---|
[437cb48] | 32 | /// interpreter: unary operations op(r), r(), ... |
---|
[83ce22] | 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 |
---|
[295381] | 37 | BOOLEAN (*blackbox_Op1)(int op,leftv l, leftv r); |
---|
[437cb48] | 38 | /// interpreter: binary operations: op(r1,r2), r1 op r2,... |
---|
[295381] | 39 | BOOLEAN (*blackbox_Op2)(int op,leftv l, leftv r1,leftv r2); |
---|
[437cb48] | 40 | /// interpreter: tertiary op: op(r1,r2,r3) |
---|
[295381] | 41 | BOOLEAN (*blackbox_Op3)(int op,leftv l, leftv r1,leftv r2, leftv r3); |
---|
[437cb48] | 42 | /// interpreter: operations with undefined number of operands |
---|
[295381] | 43 | BOOLEAN (*blackbox_OpM)(int op,leftv l, leftv r); |
---|
[8357e21] | 44 | /// is an assign of r to l (part of b) impossible? |
---|
| 45 | BOOLEAN (*blackbox_CheckAssign)(blackbox *b,leftv l, leftv r); |
---|
[9fc2ffd] | 46 | /// serialize |
---|
[f84c3b] | 47 | BOOLEAN (*blackbox_serialize)(blackbox *b,void *d, si_link f); |
---|
[9fc2ffd] | 48 | /// deserialize |
---|
[a088a12] | 49 | BOOLEAN (*blackbox_deserialize)(blackbox **b,void **d, si_link f); |
---|
[2df510] | 50 | /// additional type info |
---|
| 51 | void *data; |
---|
[091193e] | 52 | /// addtinional gneral properties |
---|
[8db6c3] | 53 | int properties; // bit 0:blackbox is only a wrapper for lists |
---|
| 54 | #define BB_LIKE_LIST(B) ((B)->properties &1) |
---|
[295381] | 55 | } ; |
---|
[06fdbe] | 56 | /// default procedure blackboxDefaultOp1, to be called as "default:" branch |
---|
| 57 | BOOLEAN blackboxDefaultOp1(int op,leftv l, leftv r); |
---|
[e6d9a32] | 58 | |
---|
[c728c0] | 59 | /// default procedure blackboxDefaultOp2, to be called as "default:" branch |
---|
| 60 | BOOLEAN blackboxDefaultOp2(int op,leftv l, leftv r1, leftv r2); |
---|
[295381] | 61 | |
---|
[1161a61] | 62 | /// default procedure blackboxDefaultOp3, to be called as "default:" branch |
---|
[97cc98] | 63 | BOOLEAN blackboxDefaultOp3(int op,leftv l, leftv r1,leftv r2, leftv r3); |
---|
[1161a61] | 64 | |
---|
[e6d9a32] | 65 | /// default procedure blackboxDefaultOpM, to be called as "default:" branch |
---|
[97cc98] | 66 | BOOLEAN blackboxDefaultOpM(int op,leftv l, leftv r); |
---|
[e6d9a32] | 67 | |
---|
[d7ad81] | 68 | /// default procedure blackbox_default_Print: print the string |
---|
[06c0b3] | 69 | void blackbox_default_Print(blackbox *b,void *d); |
---|
| 70 | |
---|
[437cb48] | 71 | /// return the structure to the type given by t |
---|
[295381] | 72 | blackbox* getBlackboxStuff(const int t); |
---|
[437cb48] | 73 | /// return the name to the type given by t (r/o) |
---|
[295381] | 74 | const char * getBlackboxName(const int t); |
---|
[a9c298] | 75 | /// used by scanner: returns ROOT_DECL for known types |
---|
[35a0c12] | 76 | /// (and the type number in @c tok) |
---|
[295381] | 77 | int blackboxIsCmd(const char *n, int & tok); |
---|
[437cb48] | 78 | /// define a new type |
---|
[2df510] | 79 | int setBlackboxStuff(blackbox *bb,const char *name); |
---|
[295381] | 80 | |
---|
[437cb48] | 81 | /// list all defined type (for debugging) |
---|
[295381] | 82 | void printBlackboxTypes(); |
---|
| 83 | |
---|
| 84 | #endif |
---|