123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- #ifndef __NS_EEL_H__
- #define __NS_EEL_H__
- #include <stdlib.h>
- #include <stdio.h>
- #ifndef EEL_F_SIZE
- #define EEL_F_SIZE 8
- #endif
- #define NSEEL_EEL1_COMPAT_MODE
- #include "wdltypes.h"
- #if EEL_F_SIZE == 4
- typedef float EEL_F;
- typedef float *EEL_F_PTR;
- #else
- typedef double EEL_F WDL_FIXALIGN;
- typedef double *EEL_F_PTR;
- #endif
- #ifdef _MSC_VER
- #define NSEEL_CGEN_CALL __cdecl
- #else
- #define NSEEL_CGEN_CALL
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
-
-
-
-
-
- void NSEEL_HOSTSTUB_EnterMutex();
- void NSEEL_HOSTSTUB_LeaveMutex();
- int NSEEL_init();
- void NSEEL_quit();
- #define NSEEL_addfunc_retval(name,np,pproc,fptr) \
- NSEEL_addfunc_ret_type(name,np,1,pproc,(void *)(fptr),NSEEL_ADDFUNC_DESTINATION)
- #define NSEEL_addfunc_retptr(name,np,pproc,fptr) \
- NSEEL_addfunc_ret_type(name,np,0,pproc,(void *)(fptr),NSEEL_ADDFUNC_DESTINATION)
- #define NSEEL_addfunc_retbool(name,np,pproc,fptr) \
- NSEEL_addfunc_ret_type(name,np,-1,pproc,(void *)(fptr),NSEEL_ADDFUNC_DESTINATION)
- #define NSEEL_addfunc_varparm(name, min_np, pproc, fptr) \
- NSEEL_addfunc_varparm_ex(name,min_np,0,pproc,fptr,NSEEL_ADDFUNC_DESTINATION)
- #define NSEEL_addfunc_exparms(name, np, pproc, fptr) \
- NSEEL_addfunc_varparm_ex(name,np,1,pproc,fptr,NSEEL_ADDFUNC_DESTINATION)
- #define NSEEL_addfunction(name,nparms,code,len) NSEEL_addfunctionex((name),(nparms),(code),(len),0,0)
- #define NSEEL_addfunctionex(name,nparms,code,len,pproc,fptr) NSEEL_addfunctionex2((name),(nparms),(code),(len),(pproc),(fptr),0, NSEEL_ADDFUNC_DESTINATION)
- #ifndef NSEEL_ADDFUNC_DESTINATION
- #define NSEEL_ADDFUNC_DESTINATION (NULL)
- #endif
- struct functionType;
- typedef struct
- {
- struct functionType *list;
- int list_size;
- } eel_function_table;
- struct _compileContext;
- typedef void *(*NSEEL_PPPROC)(void *data, int data_size, struct _compileContext *userfunc_data);
- void NSEEL_addfunctionex2(const char *name, int nparms, char *code_startaddr, int code_len, NSEEL_PPPROC pproc, void *fptr, void *fptr2, eel_function_table *destination);
- void NSEEL_addfunc_ret_type(const char *name, int np, int ret_type, NSEEL_PPPROC pproc, void *fptr, eel_function_table *destination);
- void NSEEL_addfunc_varparm_ex(const char *name, int min_np, int want_exact, NSEEL_PPPROC pproc, EEL_F (NSEEL_CGEN_CALL *fptr)(void *, INT_PTR, EEL_F **), eel_function_table *destination);
- int *NSEEL_getstats();
- typedef void *NSEEL_VMCTX;
- typedef void *NSEEL_CODEHANDLE;
- NSEEL_VMCTX NSEEL_VM_alloc();
- void NSEEL_VM_free(NSEEL_VMCTX ctx);
- void NSEEL_VM_SetFunctionTable(NSEEL_VMCTX, eel_function_table *tab);
- void NSEEL_VM_SetFunctionValidator(NSEEL_VMCTX, const char * (*validateFunc)(const char *fn_name, void *user), void *user);
- void NSEEL_VM_remove_unused_vars(NSEEL_VMCTX _ctx);
- void NSEEL_VM_clear_var_refcnts(NSEEL_VMCTX _ctx);
- void NSEEL_VM_remove_all_nonreg_vars(NSEEL_VMCTX _ctx);
- void NSEEL_VM_enumallvars(NSEEL_VMCTX ctx, int (*func)(const char *name, EEL_F *val, void *ctx), void *userctx);
- EEL_F *NSEEL_VM_regvar(NSEEL_VMCTX ctx, const char *name);
- EEL_F *NSEEL_VM_getvar(NSEEL_VMCTX ctx, const char *name);
- int NSEEL_VM_get_var_refcnt(NSEEL_VMCTX _ctx, const char *name);
- void NSEEL_VM_set_var_resolver(NSEEL_VMCTX ctx, EEL_F *(*res)(void *userctx, const char *name), void *userctx);
- void NSEEL_VM_freeRAM(NSEEL_VMCTX ctx);
- void NSEEL_VM_freeRAMIfCodeRequested(NSEEL_VMCTX);
- int NSEEL_VM_wantfreeRAM(NSEEL_VMCTX ctx);
- void NSEEL_VM_SetGRAM(NSEEL_VMCTX ctx, void **gram);
- void NSEEL_VM_FreeGRAM(void **ufd);
- void NSEEL_VM_SetCustomFuncThis(NSEEL_VMCTX ctx, void *thisptr);
- EEL_F *NSEEL_VM_getramptr(NSEEL_VMCTX ctx, unsigned int offs, int *validCount);
- EEL_F *NSEEL_VM_getramptr_noalloc(NSEEL_VMCTX ctx, unsigned int offs, int *validCount);
- int NSEEL_VM_setramsize(NSEEL_VMCTX ctx, int maxent);
- struct eelStringSegmentRec {
- struct eelStringSegmentRec *_next;
- const char *str_start;
- int str_len;
- };
- void NSEEL_VM_SetStringFunc(NSEEL_VMCTX ctx,
- EEL_F (*onString)(void *caller_this, struct eelStringSegmentRec *list),
- EEL_F (*onNamedString)(void *caller_this, const char *name));
- int nseel_stringsegments_tobuf(char *bufOut, int bufout_sz, struct eelStringSegmentRec *list);
- NSEEL_CODEHANDLE NSEEL_code_compile(NSEEL_VMCTX ctx, const char *code, int lineoffs);
- #define NSEEL_CODE_COMPILE_FLAG_COMMONFUNCS 1
- #define NSEEL_CODE_COMPILE_FLAG_COMMONFUNCS_RESET 2
- #define NSEEL_CODE_COMPILE_FLAG_NOFPSTATE 4
- #define NSEEL_CODE_COMPILE_FLAG_ONLY_BUILTIN_FUNCTIONS 8
- NSEEL_CODEHANDLE NSEEL_code_compile_ex(NSEEL_VMCTX ctx, const char *code, int lineoffs, int flags);
- char *NSEEL_code_getcodeerror(NSEEL_VMCTX ctx);
- int NSEEL_code_geterror_flag(NSEEL_VMCTX ctx);
- void NSEEL_code_execute(NSEEL_CODEHANDLE code);
- void NSEEL_code_free(NSEEL_CODEHANDLE code);
- int *NSEEL_code_getstats(NSEEL_CODEHANDLE code);
-
- extern unsigned int NSEEL_RAM_limitmem;
- extern unsigned int NSEEL_RAM_memused;
- extern int NSEEL_RAM_memused_errors;
- #define NSEEL_SUPER_MINIMAL_LEXER
-
- #define NSEEL_MAX_VARIABLE_NAMELEN 128
- #define NSEEL_MAX_EELFUNC_PARAMETERS 40
- #define NSEEL_MAX_FUNCSIG_NAME 2048
- #ifndef NSEEL_LOOPFUNC_SUPPORT_MAXLEN
- #define NSEEL_LOOPFUNC_SUPPORT_MAXLEN 1048576
- #endif
- #define NSEEL_MAX_FUNCTION_SIZE_FOR_INLINE 2048
- #define NSEEL_SHARED_GRAM_SIZE (1<<20)
- #define NSEEL_RAM_BLOCKS_DEFAULTMAX 128
- #define NSEEL_RAM_BLOCKS_LOG2 9
-
- #define NSEEL_RAM_ITEMSPERBLOCK_LOG2 16
- #define NSEEL_RAM_BLOCKS (1 << NSEEL_RAM_BLOCKS_LOG2)
- #define NSEEL_RAM_ITEMSPERBLOCK (1<<NSEEL_RAM_ITEMSPERBLOCK_LOG2)
- #define NSEEL_STACK_SIZE 4096
- #ifdef EEL_TARGET_PORTABLE
- #define EEL_BC_TYPE int
- #endif
- #ifdef NSEEL_EEL1_COMPAT_MODE
- double *NSEEL_getglobalregs();
- #endif
- void eel_setfp_round();
- void eel_setfp_trunc();
- void eel_enterfp(int s[2]);
- void eel_leavefp(int s[2]);
- extern void *(*nseel_gmem_calloc)(size_t,size_t);
- #ifdef __cplusplus
- }
- #endif
- #endif
|