With the latest version, the API has changed a little. Here is the upgraded FreeBasic header:
Code: Select all
#define MB_CODES
#define MB_FUNC_OK 0
#define MB_FUNC_IGNORE 1
#define MB_FUNC_WARNING 2
#define MB_FUNC_ERR 3
#define MB_FUNC_BYE 4
#define MB_FUNC_SUSPEND 5
#define MB_FUNC_END 6
#define MB_LOOP_BREAK 101
#define MB_LOOP_CONTINUE 102
#define MB_SUB_RETURN 103
#define MB_EXTENDED_ABORT 201
enum mb_error_e
SE_NO_ERR = 0,
' Common
SE_CM_FUNC_EXISTS,
SE_CM_FUNC_NOT_EXISTS,
SE_CM_NOT_SUPPORTED,
' Parsing
SE_PS_OPEN_FILE_FAILED,
SE_PS_SYMBOL_TOO_LONG,
SE_PS_INVALID_CHAR,
SE_PS_INVALID_MODULE,
SE_PS_DUPLICATE_IMPORT,
' Running
SE_RN_EMPTY_PROGRAM,
SE_RN_PROGRAM_TOO_LONG,
SE_RN_SYNTAX_ERROR,
SE_RN_OUT_OF_MEMORY,
SE_RN_OVERFLOW,
SE_RN_UNEXPECTED_TYPE,
SE_RN_INVALID_STRING,
SE_RN_INTEGER_EXPECTED,
SE_RN_NUMBER_EXPECTED,
SE_RN_STRING_EXPECTED,
SE_RN_VAR_EXPECTED,
SE_RN_INDEX_OUT_OF_BOUND,
SE_RN_CANNOT_FIND_WITH_GIVEN_INDEX,
SE_RN_TOO_MANY_DIMENSIONS,
SE_RN_RANK_OUT_OF_BOUND,
SE_RN_INVALID_ID_USAGE,
SE_RN_CANNOT_ASSIGN_TO_RESERVED_WORD,
SE_RN_DUPLICATE_ID,
SE_RN_INCOMPLETE_STRUCTURE,
SE_RN_LABEL_NOT_EXISTS,
SE_RN_NO_RETURN_POINT,
SE_RN_COLON_EXPECTED,
SE_RN_COMMA_EXPECTED,
SE_RN_COMMA_OR_SEMICOLON_EXPECTED,
SE_RN_OPEN_BRACKET_EXPECTED,
SE_RN_CLOSE_BRACKET_EXPECTED,
SE_RN_NESTED_TOO_MUCH,
SE_RN_OPERATION_FAILED,
SE_RN_OPERATOR_EXPECTED,
SE_RN_ASSIGN_OPERATOR_EXPECTED,
SE_RN_THEN_EXPECTED,
SE_RN_ELSE_EXPECTED,
SE_RN_ENDIF_EXPECTED,
SE_RN_TO_EXPECTED,
SE_RN_NEXT_EXPECTED,
SE_RN_UNTIL_EXPECTED,
SE_RN_LOOP_VAR_EXPECTED,
SE_RN_JUMP_LABEL_EXPECTED,
SE_RN_CALCULATION_ERROR,
SE_RN_INVALID_EXPRESSION,
SE_RN_DIVIDE_BY_ZERO,
SE_RN_REACHED_TO_WRONG_FUNCTION,
SE_RN_CANNOT_SUSPEND_HERE,
SE_RN_CANNOT_MIX_INSTRUCTIONAL_AND_STRUCTURED,
SE_RN_INVALID_ROUTINE,
SE_RN_ROUTINE_EXPECTED,
SE_RN_DUPLICATE_ROUTINE,
SE_RN_INVALID_CLASS,
SE_RN_CLASS_EXPECTED,
SE_RN_DUPLICATE_CLASS,
SE_RN_HASH_AND_COMPARE_MUST_BE_PROVIDED_TOGETHER,
SE_RN_INVALID_LAMBDA,
SE_RN_EMPTY_COLLECTION,
SE_RN_LIST_EXPECTED,
SE_RN_INVALID_ITERATOR,
SE_RN_ITERABLE_EXPECTED,
SE_RN_COLLECTION_EXPECTED,
SE_RN_COLLECTION_OR_ITERATOR_EXPECTED,
SE_RN_REFERENCED_TYPE_EXPECTED,
' Extended abort
SE_EA_EXTENDED_ABORT,
' Extra
SE_COUNT
end enum
enum mb_data_e
MB_DT_NIL = 0,
MB_DT_UNKNOWN = 1 shl 0,
MB_DT_INT = 1 shl 1,
MB_DT_REAL = 1 shl 2,
MB_DT_NUM = MB_DT_INT or MB_DT_REAL,
MB_DT_STRING = 1 shl 3,
MB_DT_TYPE = 1 shl 4,
MB_DT_USERTYPE = 1 shl 5,
MB_DT_ARRAY = 1 shl 7,
MB_DT_ROUTINE = 1 shl 13
end enum
enum mb_meta_func_e
MB_MF_IS = 1 shl 0,
MB_MF_ADD = 1 shl 1,
MB_MF_SUB = 1 shl 2,
MB_MF_MUL = 1 shl 3,
MB_MF_DIV = 1 shl 4,
MB_MF_NEG = 1 shl 5,
MB_MF_CALC = MB_MF_IS or MB_MF_ADD or MB_MF_SUB or MB_MF_MUL or MB_MF_DIV or MB_MF_NEG,
MB_MF_COLL = 1 shl 6,
MB_MF_FUNC = 1 shl 7
end enum
enum mb_meta_status_e
MB_MS_NONE = 0,
MB_MS_DONE = 1 shl 0,
MB_MS_RETURNED = 1 shl 1
end enum
enum mb_routine_type_e
MB_RT_NONE,
MB_RT_SCRIPT,
MB_RT_LAMBDA,
MB_RT_NATIVE
end enum
union mb_value_u field = 1
integer_ as integer
float_point as single
string_ as zstring ptr
type_ as long'mb_data_e
usertype as any ptr
array as any ptr
routine as any ptr
bytes as unsigned byte
end union
type mb_value_t field = 1
type_ as long'mb_data_e
value as mb_value_u
end type
extern "C"
declare function mb_init() as integer
declare function mb_dispose() as integer
declare function mb_open(byref s as any ptr) as integer
declare function mb_close(byref s as any ptr) as integer
declare function mb_reset(byref s as any ptr, clear_funcs as unsigned byte, clear_vars as unsigned byte) as integer
declare function mb_fork(byref s as any ptr, r as any ptr, clear_forked as unsigned byte) as integer
declare function mb_join(byref s as any ptr) as integer
declare function mb_get_forked_from(s as any ptr, byref src as any ptr) as integer
declare function mb_register_func(s as any ptr, n as zstring ptr, f as function cdecl (as any ptr, byref as any ptr) as integer) as integer
declare function mb_remove_func(s as any ptr, n as zstring ptr) as integer
declare function mb_remove_reserved_func(s as any ptr, n as zstring ptr) as integer
declare function mb_begin_module(s as any ptr, n as zstring ptr) as integer
declare function mb_end_module(s as any ptr) as integer
declare function mb_attempt_func_begin(s as any ptr, byref l as any ptr) as integer
declare function mb_attempt_func_end(s as any ptr, byref l as any ptr) as integer
declare function mb_attempt_open_bracket(s as any ptr, byref l as any ptr) as integer
declare function mb_attempt_close_bracket(s as any ptr, byref l as any ptr) as integer
declare function mb_has_arg(s as any ptr, byref l as any ptr) as integer
declare function mb_pop_int(s as any ptr, byref l as any ptr, byref val_ as integer) as integer
declare function mb_pop_real(s as any ptr, byref l as any ptr, byref val_ as single) as integer
declare function mb_pop_string(s as any ptr, byref l as any ptr, byref val_ as zstring ptr) as integer
declare function mb_pop_usertype(s as any ptr, byref l as any ptr, byref val_ as any ptr) as integer
declare function mb_pop_value(s as any ptr, byref l as any ptr, byref val_ as mb_value_t) as integer
declare function mb_push_int(s as any ptr, byref l as any ptr, val_ as integer) as integer
declare function mb_push_real(s as any ptr, byref l as any ptr, val_ as single) as integer
declare function mb_push_string(s as any ptr, byref l as any ptr, val_ as zstring ptr) as integer
declare function mb_push_usertype(s as any ptr, byref l as any ptr, val_ as any ptr) as integer
declare function mb_push_value(s as any ptr, byref l as any ptr, val_ as mb_value_t) as integer
declare function mb_begin_class(s as any ptr, byref l as any ptr, n as zstring ptr, byref meta as mb_value_t ptr, c as integer, byref out_ as mb_value_t) as integer
declare function mb_end_class(s as any ptr, byref l as any ptr) as integer
declare function mb_get_class_userdata(s as any ptr, byref l as any ptr, byref d as any ptr) as integer
declare function mb_set_class_userdata(s as any ptr, byref l as any ptr, byref d as any ptr) as integer
declare function mb_get_value_by_name(s as any ptr, byref l as any ptr, n as zstring ptr, byref val_ as mb_value_t) as integer
declare function mb_get_vars(s as any ptr, byref l as any ptr, r as sub cdecl(as any ptr, as zstring ptr, as integer) , stack_offset as integer) as integer
declare function mb_add_var(s as any ptr, byref l as any ptr, n as zstring ptr, val_ as mb_value_t, force as unsigned byte) as integer
declare function mb_get_var(s as any ptr, byref l as any ptr, byref v as any ptr, redir as unsigned byte) as integer
declare function mb_get_var_name(s as any ptr, v as any ptr, byref n as zstring ptr) as integer
declare function mb_get_var_value(s as any ptr, v as any ptr, byref val_ as mb_value_t) as integer
declare function mb_set_var_value(s as any ptr, v as any ptr, val as mb_value_t) as integer
declare function mb_init_array(s as any ptr, byref l as any ptr, t as mb_data_e, byref d as integer, c as integer, byref a as any ptr) as integer
declare function mb_get_array_len(s as any ptr, byref l as any ptr, a as any ptr, r as integer, byref i as integer) as integer
declare function mb_get_array_elem(s as any ptr, byref l as any ptr, a as any ptr, byref d as integer, c as integer, byref val_ as mb_value_t) as integer
declare function mb_set_array_elem(s as any ptr, byref l as any ptr, a as any ptr, byref d as integer, c as integer, val_ as mb_value_t) as integer
declare function mb_init_coll(s as any ptr, byref l as any ptr, byref coll as mb_value_t) as integer
declare function mb_get_coll(s as any ptr, byref l as any ptr, coll as mb_value_t, idx as mb_value_t, byref val_ as mb_value_t) as integer
declare function mb_set_coll(s as any ptr, byref l as any ptr, coll as mb_value_t, idx as mb_value_t, val_ as mb_value_t) as integer
declare function mb_remove_coll(s as any ptr, byref l as any ptr, coll as mb_value_t, idx as mb_value_t) as integer
declare function mb_count_coll(s as any ptr, byref l as any ptr, coll as mb_value_t, byref c as integer) as integer
declare function mb_keys_of_coll(s as any ptr, byref l as any ptr, coll as mb_value_t, byref keys as mb_value_t, c as integer) as integer
declare function mb_make_ref_value(s as any ptr, val_ as any ptr, byref out_ as mb_value_t, un as sub cdecl (as any ptr, as any ptr), cl as function cdecl (as any ptr, as any ptr) as any ptr, hs as function cdecl (as any ptr, as any ptr) as unsigned integer, cp as function cdecl (as any ptr, as any ptr, as any ptr) as integer, ft as function cdecl (as any ptr, as any ptr, as zstring ptr, as unsigned integer) as integer) as integer
declare function mb_get_ref_value(s as any ptr, byref l as any ptr, val_ as mb_value_t, byref out_ as any ptr) as integer
declare function mb_ref_value(s as any ptr, byref l as any ptr, val_ as mb_value_t) as integer
declare function mb_unref_value(s as any ptr, byref l as any ptr, val_ as mb_value_t) as integer
declare function mb_set_alive_checker(s as any ptr, f as sub cdecl (as any ptr, as any ptr, as sub cdecl (as any ptr, as any ptr, as mb_value_t))) as integer
declare function mb_set_alive_checker_of_value(s as any ptr, byref l as any ptr, val as mb_value_t, f as sub cdecl (as any ptr, as any ptr, as mb_value_t, as sub cdecl (as any ptr, as any ptr, as mb_value_t))) as integer
declare function mb_override_value(s as any ptr, byref l as any ptr, val_ as mb_value_t, m as mb_meta_func_e, f as any ptr) as integer
declare function mb_dispose_value(s as any ptr, val_ as mb_value_t) as integer
declare function mb_get_routine(s as any ptr, byref l as any ptr, n as zstring ptr, byref val_ as mb_value_t) as integer
declare function mb_set_routine(s as any ptr, byref l as any ptr, n as zstring ptr, f as function cdecl(as any ptr, byref as any ptr, byref as mb_value_t, as unsigned integer, as any ptr, as function cdecl (as any ptr, byref as any ptr, byref as mb_value_t, as unsigned integer, byref as unsigned integer, as any ptr) as integer, as function cdecl (as any ptr, byref as any ptr, byref as mb_value_t, as unsigned integer, byref as unsigned integer, as any ptr, byref as mb_value_t) as integer) as integer, force as unsigned byte) as integer
declare function mb_eval_routine(s as any ptr, byref l as any ptr, val_ as mb_value_t, args as mb_value_t, argc as unsigned integer, byref ret_ as mb_value_t) as integer
declare function mb_get_routine_type(s as any ptr, val_ as mb_value_t, byref y as mb_routine_type_e) as integer
declare function mb_load_string(s as any ptr, l as zstring ptr, reset as unsigned byte) as integer
declare function mb_load_file(s as any ptr, f as zstring ptr) as integer
declare function mb_run(s as any ptr, clear_parser as unsigned byte) as integer
declare function mb_suspend(ss as any ptr, byref l as any ptr) as integer
declare function mb_schedule_suspend(s as any ptr, t as integer) as integer
declare function mb_debug_get(s as any ptr, n as zstring ptr, byref val_ as mb_value_t) as integer
declare function mb_debug_set(s as any ptr, n as zstring ptr, val_ as mb_value_t) as integer
declare function mb_debug_count_stack_frames(s as any ptr) as integer
declare function mb_debug_get_stack_trace(s as any ptr, byref fs as zstring ptr, fc as unsigned integer) as integer
declare function mb_debug_set_stepped_handler(s as any ptr, prev as function cdecl (as any ptr, byref as any ptr, as zstring ptr, as integer, as unsigned short, as unsigned short) as integer, post as function cdecl (as any ptr, byref as any ptr, as zstring ptr, as integer, as unsigned short, as unsigned short) as integer) as integer
declare function mb_get_type_string(t as mb_data_e) as zstring ptr
declare function mb_raise_error(s as any ptr, byref l as any ptr, err_ as mb_error_e, ret_ as integer) as integer
declare function mb_get_last_error(s as any ptr, byref file as zstring ptr, byref pos_ as integer, byref row_ as unsigned short, byref col_ as unsigned short) as mb_error_e
declare function mb_get_error_desc(err_ as mb_error_e) as zstring ptr
declare function mb_set_error_handler(s as any ptr, h as sub cdecl (as any ptr, as mb_error_e, as zstring ptr, as zstring ptr, as integer, as unsigned short, as unsigned short, as integer)) as integer
declare function mb_set_printer(s as any ptr, p as function cdecl(as any ptr, as zstring ptr, ...) as integer) as integer
declare function mb_set_inputer(s as any ptr, p as function cdecl(as any ptr, as zstring ptr, as zstring ptr, as integer) as integer) as integer
declare function mb_set_import_handler(s as any ptr, h as function cdecl(as any ptr, as zstring ptr) as integer) as integer
declare function mb_set_memory_manager(a as function cdecl (as unsigned integer) as ubyte ptr, f as sub cdecl (as ubyte ptr)) as integer
declare function mb_get_gc_enabled(s as any ptr) as unsigned byte
declare function mb_set_gc_enabled(s as any ptr, gc as unsigned byte) as integer
declare function mb_gc(s as any ptr, byref collected as integer) as integer
declare function mb_get_userdata(s as any ptr, byref d as any ptr) as integer
declare function mb_set_userdata(s as any ptr, d as any ptr) as integer
declare function mb_gets(s as any ptr, pmt as zstring ptr, buf as ubyte ptr, n as integer) as integer
declare function mb_memdup(val_ as zstring ptr, size as unsigned integer) as zstring ptr
end extern