+added an mb_set_import_handler function.
This commit is contained in:
parent
9c791299d6
commit
3794eeb31f
@ -539,6 +539,7 @@ typedef struct mb_interpreter_t {
|
|||||||
mb_error_handler_t error_handler;
|
mb_error_handler_t error_handler;
|
||||||
mb_print_func_t printer;
|
mb_print_func_t printer;
|
||||||
mb_input_func_t inputer;
|
mb_input_func_t inputer;
|
||||||
|
mb_import_handler_t import_handler;
|
||||||
void* userdata;
|
void* userdata;
|
||||||
} mb_interpreter_t;
|
} mb_interpreter_t;
|
||||||
|
|
||||||
@ -3464,6 +3465,7 @@ _data_e _get_symbol_type(mb_interpreter_t* s, char* sym, _raw_t* value) {
|
|||||||
safe_free(buf);
|
safe_free(buf);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if(!s->import_handler || s->import_handler(s, sym + 1) != MB_FUNC_OK) {
|
||||||
_set_current_error(s, SE_PS_FILE_OPEN_FAILED, 0);
|
_set_current_error(s, SE_PS_FILE_OPEN_FAILED, 0);
|
||||||
if(s->error_handler) {
|
if(s->error_handler) {
|
||||||
(s->error_handler)(s, s->last_error, (char*)mb_get_error_desc(s->last_error),
|
(s->error_handler)(s, s->last_error, (char*)mb_get_error_desc(s->last_error),
|
||||||
@ -3474,6 +3476,7 @@ _data_e _get_symbol_type(mb_interpreter_t* s, char* sym, _raw_t* value) {
|
|||||||
result);
|
result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
context->parsing_state = _PS_STRING;
|
context->parsing_state = _PS_STRING;
|
||||||
sym[_sl - 1] = '\"';
|
sym[_sl - 1] = '\"';
|
||||||
context->current_symbol_nonius = n;
|
context->current_symbol_nonius = n;
|
||||||
@ -7933,6 +7936,17 @@ int mb_set_inputer(struct mb_interpreter_t* s, mb_input_func_t p) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mb_set_import_handler(struct mb_interpreter_t* s, mb_import_handler_t h) {
|
||||||
|
/* Set an import handler to an interpreter instance */
|
||||||
|
int result = MB_FUNC_OK;
|
||||||
|
|
||||||
|
mb_assert(s);
|
||||||
|
|
||||||
|
s->import_handler = h;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
int mb_gets(char* buf, int s) {
|
int mb_gets(char* buf, int s) {
|
||||||
/* Safe stdin reader function */
|
/* Safe stdin reader function */
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user