|
|
@@ -4,7 +4,7 @@
|
|
|
#define MixInteger SQInteger
|
|
|
#include "code_mix_prep.c"
|
|
|
|
|
|
-/* Generic loader function. Load the data found in the state in the lua engine
|
|
|
+/* Generic loader function. Load the data found in the state in the squilu engine
|
|
|
*/
|
|
|
static SQRESULT mix_loadbuffer(HSQUIRRELVM sqvm, mix_state_t *S, const SQChar *name, int isParseOnly) {
|
|
|
SQRESULT res;
|
|
|
@@ -31,7 +31,7 @@ static SQRESULT mix_loadbuffer(HSQUIRRELVM sqvm, mix_state_t *S, const SQChar *n
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- res = sq_compile(sqvm, sq_mix_reader_char, S, name, SQTrue, SQTrue);
|
|
|
+ res = sq_compile(sqvm, sq_mix_reader_char, S, name, SQTrue, SQTrue, SQ_MAX_INCLUDE_FILES);
|
|
|
if (S->error != NULL) {
|
|
|
return sq_throwerror(sqvm, S->error);
|
|
|
} else if (res != 0) {
|
|
|
@@ -66,14 +66,14 @@ static SQRESULT mix_stateopt(HSQUIRRELVM sqvm, mix_state_t *S) {
|
|
|
S->exprsize = expr_code_size;
|
|
|
if (S->exprsize == 0)
|
|
|
return sq_throwerror(sqvm, _SC("expr separator cannot be empty"));
|
|
|
-
|
|
|
+
|
|
|
SQ_OPT_STRING(sqvm, 6, print_code, "mix_write");
|
|
|
if (print_code_size == 0)
|
|
|
return sq_throwerror(sqvm, _SC("mix_write function name cannot be empty"));
|
|
|
-
|
|
|
+
|
|
|
|
|
|
snprintf(S->print_out, sizeof(S->print_out), "%s(\"", print_code);
|
|
|
- S->print_outsize = strlen(S->print_out);
|
|
|
+ S->print_outsize = strlen(S->print_out);
|
|
|
S->result_size = 0;
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -90,7 +90,7 @@ static SQRESULT mix_load_parse_file(HSQUIRRELVM sqvm, int isParse) {
|
|
|
|
|
|
file = fopen(filename, _SC("r"));
|
|
|
if (file == NULL) {
|
|
|
- return sq_throwerror(sqvm, _SC("cannot open file <%s>"), filename);
|
|
|
+ return sq_throwerror(sqvm, _SC("cannot open file <%s>"), filename);
|
|
|
}
|
|
|
|
|
|
fseek(file, 0, SEEK_END);
|
|
|
@@ -100,9 +100,9 @@ static SQRESULT mix_load_parse_file(HSQUIRRELVM sqvm, int isParse) {
|
|
|
SQBlob buffer(0, S.size);
|
|
|
if (fread(buffer.GetBuf(), S.size, 1, file) != 1) {
|
|
|
fclose(file);
|
|
|
- return sq_throwerror(sqvm, _SC("cannot read file <%s>"), filename);
|
|
|
+ return sq_throwerror(sqvm, _SC("cannot read file <%s>"), filename);
|
|
|
}
|
|
|
- S.buffer = (const char*)buffer.GetBuf();
|
|
|
+ S.buffer = (const char*)buffer.GetBuf();
|
|
|
fclose(file);
|
|
|
|
|
|
return mix_loadbuffer(sqvm, &S, filename, isParse);
|
|
|
@@ -120,7 +120,7 @@ static SQRESULT mix_load_parse_string(HSQUIRRELVM sqvm, int isParse) {
|
|
|
mix_state_t S;
|
|
|
sq_mix_init(&S, 0, 0, 0,0,0,0);
|
|
|
|
|
|
- sq_getstring(sqvm, 2, &S.buffer);
|
|
|
+ sq_getstring(sqvm, 2, &S.buffer);
|
|
|
S.size = sq_getsize(sqvm, 2);
|
|
|
mix_stateopt(sqvm, &S);
|
|
|
|
|
|
@@ -136,27 +136,27 @@ static SQRESULT mix_parsestring(HSQUIRRELVM sqvm) {
|
|
|
}
|
|
|
|
|
|
const SQChar validate_format_mask[] = _SC(".s s|o s|o s|o s");
|
|
|
-#define _DECL_MIX_FUNC(name,nparams,pmask) {_SC(#name), mix_##name,nparams,pmask}
|
|
|
-static SQRegFunction mix_obj_funcs[]={
|
|
|
- _DECL_MIX_FUNC(parsefile,-2,validate_format_mask),
|
|
|
- _DECL_MIX_FUNC(parsestring,-2,validate_format_mask),
|
|
|
- _DECL_MIX_FUNC(loadfile,-2,validate_format_mask),
|
|
|
- _DECL_MIX_FUNC(loadstring,-2,validate_format_mask),
|
|
|
- {0,0}
|
|
|
-};
|
|
|
-#undef _DECL_MIX_FUNC
|
|
|
+#define _DECL_MIX_FUNC(name,nparams,pmask) {_SC(#name), mix_##name,nparams,pmask}
|
|
|
+static SQRegFunction mix_obj_funcs[]={
|
|
|
+ _DECL_MIX_FUNC(parsefile,-2,validate_format_mask),
|
|
|
+ _DECL_MIX_FUNC(parsestring,-2,validate_format_mask),
|
|
|
+ _DECL_MIX_FUNC(loadfile,-2,validate_format_mask),
|
|
|
+ _DECL_MIX_FUNC(loadstring,-2,validate_format_mask),
|
|
|
+ {0,0}
|
|
|
+};
|
|
|
+#undef _DECL_MIX_FUNC
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
extern "C" {
|
|
|
#endif
|
|
|
/* This defines a function that opens up your library. */
|
|
|
SQRESULT sqext_register_mix (HSQUIRRELVM sqvm) {
|
|
|
- //add a namespace sqmix
|
|
|
- sq_pushstring(sqvm,_SC("sqmix"),-1);
|
|
|
- sq_newclass(sqvm,SQFalse);
|
|
|
- sq_insert_reg_funcs(sqvm, mix_obj_funcs);
|
|
|
- sq_newslot(sqvm,-3,SQTrue); //add sqmix table to the root table
|
|
|
-
|
|
|
+ //add a namespace sqmix
|
|
|
+ sq_pushstring(sqvm,_SC("sqmix"),-1);
|
|
|
+ sq_newclass(sqvm,SQFalse);
|
|
|
+ sq_insert_reg_funcs(sqvm, mix_obj_funcs);
|
|
|
+ sq_newslot(sqvm,-3,SQTrue); //add sqmix table to the root table
|
|
|
+
|
|
|
return SQ_OK;
|
|
|
}
|
|
|
|