9 # ifdef EFL_EMBRYO_BUILD
11 # define EAPI __declspec(dllexport)
14 # endif /* ! DLL_EXPORT */
16 # define EAPI __declspec(dllimport)
17 # endif /* ! EFL_EMBRYO_BUILD */
21 # define EAPI __attribute__ ((visibility("default")))
34 /* potentioal error values */
38 /* reserve the first 15 error codes for exit codes of the abstract machine */
39 EMBRYO_ERROR_EXIT, /** Forced exit */
40 EMBRYO_ERROR_ASSERT, /** Assertion failed */
41 EMBRYO_ERROR_STACKERR, /** Stack/heap collision */
42 EMBRYO_ERROR_BOUNDS, /** Index out of bounds */
43 EMBRYO_ERROR_MEMACCESS, /** Invalid memory access */
44 EMBRYO_ERROR_INVINSTR, /** Invalid instruction */
45 EMBRYO_ERROR_STACKLOW, /** Stack underflow */
46 EMBRYO_ERROR_HEAPLOW, /** Heap underflow */
47 EMBRYO_ERROR_CALLBACK, /** No callback, or invalid callback */
48 EMBRYO_ERROR_NATIVE, /** Native function failed */
49 EMBRYO_ERROR_DIVIDE, /** Divide by zero */
50 EMBRYO_ERROR_SLEEP, /** Go into sleepmode - code can be restarted */
52 EMBRYO_ERROR_MEMORY = 16, /** Out of memory */
53 EMBRYO_ERROR_FORMAT, /** Invalid file format */
54 EMBRYO_ERROR_VERSION, /** File is for a newer version of the Embryo_Program */
55 EMBRYO_ERROR_NOTFOUND, /** Function not found */
56 EMBRYO_ERROR_INDEX, /** Invalid index parameter (bad entry point) */
57 EMBRYO_ERROR_DEBUG, /** Debugger cannot run */
58 EMBRYO_ERROR_INIT, /** Embryo_Program not initialized (or doubly initialized) */
59 EMBRYO_ERROR_USERDATA, /** Unable to set user data field (table full) */
60 EMBRYO_ERROR_INIT_JIT, /** Cannot initialize the JIT */
61 EMBRYO_ERROR_PARAMS, /** Parameter error */
62 EMBRYO_ERROR_DOMAIN, /** Domain error, expression result does not fit in range */
65 /* possible function type values that are enumerated */
66 #define EMBRYO_FUNCTION_NONE 0x7fffffff /* An invalid/non existant function */
67 #define EMBRYO_FUNCTION_MAIN -1 /* Start at program entry point */
68 #define EMBRYO_FUNCTION_CONT -2 /* Continue from last address */
69 /** An invalid cell reference */
70 #define EMBRYO_CELL_NONE 0x7fffffff
71 /* program run return values */
72 #define EMBRYO_PROGRAM_OK 1
73 #define EMBRYO_PROGRAM_SLEEP 2
74 #define EMBRYO_PROGRAM_BUSY 3
75 #define EMBRYO_PROGRAM_TOOLONG 4
76 #define EMBRYO_PROGRAM_FAIL 0
78 typedef unsigned int Embryo_UCell;
79 typedef int Embryo_Cell;
80 typedef struct _Embryo_Program Embryo_Program;
81 typedef int Embryo_Function;
89 /** Float to Embryo_Cell */
90 #define EMBRYO_FLOAT_TO_CELL(f) ((Embryo_Float_Cell) f).c
91 /** Embryo_Cell to float */
92 #define EMBRYO_CELL_TO_FLOAT(c) ((Embryo_Float_Cell) c).f
94 EAPI int embryo_init(void);
95 EAPI int embryo_shutdown(void);
97 EAPI Embryo_Program *embryo_program_new(void *data, int size);
98 EAPI Embryo_Program *embryo_program_const_new(void *data, int size);
99 EAPI Embryo_Program *embryo_program_load(char *file);
100 EAPI void embryo_program_free(Embryo_Program *ep);
101 EAPI void embryo_program_native_call_add(Embryo_Program *ep, const char *name, Embryo_Cell (*func) (Embryo_Program *ep, Embryo_Cell *params));
102 EAPI void embryo_program_vm_reset(Embryo_Program *ep);
103 EAPI void embryo_program_vm_push(Embryo_Program *ep);
104 EAPI void embryo_program_vm_pop(Embryo_Program *ep);
105 EAPI void embryo_swap_16(unsigned short *v);
106 EAPI void embryo_swap_32(unsigned int *v);
107 EAPI Embryo_Function embryo_program_function_find(Embryo_Program *ep, const char *name);
108 EAPI Embryo_Cell embryo_program_variable_find(Embryo_Program *ep, const char *name);
109 EAPI int embryo_program_variable_count_get(Embryo_Program *ep);
110 EAPI Embryo_Cell embryo_program_variable_get(Embryo_Program *ep, int num);
111 EAPI void embryo_program_error_set(Embryo_Program *ep, int error);
112 EAPI int embryo_program_error_get(Embryo_Program *ep);
113 EAPI void embryo_program_data_set(Embryo_Program *ep, void *data);
114 EAPI void *embryo_program_data_get(Embryo_Program *ep);
115 EAPI const char *embryo_error_string_get(int error);
116 EAPI int embryo_data_string_length_get(Embryo_Program *ep, Embryo_Cell *str_cell);
117 EAPI void embryo_data_string_get(Embryo_Program *ep, Embryo_Cell *str_cell, char *dst);
118 EAPI void embryo_data_string_set(Embryo_Program *ep, const char *src, Embryo_Cell *str_cell);
119 EAPI Embryo_Cell *embryo_data_address_get(Embryo_Program *ep, Embryo_Cell addr);
120 EAPI Embryo_Cell embryo_data_heap_push(Embryo_Program *ep, int cells);
121 EAPI void embryo_data_heap_pop(Embryo_Program *ep, Embryo_Cell down_to);
122 EAPI int embryo_program_recursion_get(Embryo_Program *ep);
123 EAPI int embryo_program_run(Embryo_Program *ep, Embryo_Function func);
124 EAPI Embryo_Cell embryo_program_return_value_get(Embryo_Program *ep);
125 EAPI void embryo_program_max_cycle_run_set(Embryo_Program *ep, int max);
126 EAPI int embryo_program_max_cycle_run_get(Embryo_Program *ep);
127 EAPI int embryo_parameter_cell_push(Embryo_Program *ep, Embryo_Cell cell);
128 EAPI int embryo_parameter_string_push(Embryo_Program *ep, const char *str);
129 EAPI int embryo_parameter_cell_array_push(Embryo_Program *ep, Embryo_Cell *cells, int num);