Fixed the code style in *.c files to two spaces indentation and add a linter named funstx to Fun. (0.39.0)
This commit is contained in:
parent
33001a7ad2
commit
03b2532474
237 changed files with 17550 additions and 13911 deletions
|
|
@ -15,12 +15,12 @@
|
|||
*/
|
||||
case OP_RUST_GET_SP: {
|
||||
#ifdef FUN_WITH_RUST
|
||||
extern int fun_op_rget_sp(VM *vm);
|
||||
int rc = fun_op_rget_sp(vm);
|
||||
(void)rc; /* rc currently unused; 0 means OK */
|
||||
extern int fun_op_rget_sp(VM * vm);
|
||||
int rc = fun_op_rget_sp(vm);
|
||||
(void)rc; /* rc currently unused; 0 means OK */
|
||||
#else
|
||||
vm_raise_error(vm, "RUST_GET_SP requires FUN_WITH_RUST=ON at build time");
|
||||
push_value(vm, make_int(-1));
|
||||
vm_raise_error(vm, "RUST_GET_SP requires FUN_WITH_RUST=ON at build time");
|
||||
push_value(vm, make_int(-1));
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,20 +8,20 @@
|
|||
*
|
||||
* Added: 2026-01-27
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Rust FFI demo opcode: OP_RUST_HELLO
|
||||
* When executed, it pushes a hello string returned by Rust onto the VM stack.
|
||||
*/
|
||||
|
||||
case OP_RUST_HELLO: {
|
||||
#ifdef FUN_WITH_RUST
|
||||
const char *s = fun_rust_get_string();
|
||||
if (!s) s = "";
|
||||
push_value(vm, make_string(s));
|
||||
const char *s = fun_rust_get_string();
|
||||
if (!s) s = "";
|
||||
push_value(vm, make_string(s));
|
||||
#else
|
||||
vm_raise_error(vm, "RUST_HELLO requires FUN_WITH_RUST=ON at build time");
|
||||
push_value(vm, make_nil());
|
||||
vm_raise_error(vm, "RUST_HELLO requires FUN_WITH_RUST=ON at build time");
|
||||
push_value(vm, make_nil());
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,22 +15,22 @@
|
|||
*/
|
||||
case OP_RUST_HELLO_ARGS: {
|
||||
#ifdef FUN_WITH_RUST
|
||||
Value vmsg = pop_value(vm);
|
||||
char *msg = value_to_string_alloc(&vmsg);
|
||||
free_value(vmsg);
|
||||
if (msg) {
|
||||
fun_rust_print_string(msg);
|
||||
free(msg);
|
||||
} else {
|
||||
fun_rust_print_string("");
|
||||
}
|
||||
push_value(vm, make_nil());
|
||||
Value vmsg = pop_value(vm);
|
||||
char *msg = value_to_string_alloc(&vmsg);
|
||||
free_value(vmsg);
|
||||
if (msg) {
|
||||
fun_rust_print_string(msg);
|
||||
free(msg);
|
||||
} else {
|
||||
fun_rust_print_string("");
|
||||
}
|
||||
push_value(vm, make_nil());
|
||||
#else
|
||||
/* Still pop and free the arg to keep stack sane */
|
||||
Value vmsg = pop_value(vm);
|
||||
free_value(vmsg);
|
||||
vm_raise_error(vm, "RUST_HELLO_ARGS requires FUN_WITH_RUST=ON at build time");
|
||||
push_value(vm, make_nil());
|
||||
/* Still pop and free the arg to keep stack sane */
|
||||
Value vmsg = pop_value(vm);
|
||||
free_value(vmsg);
|
||||
vm_raise_error(vm, "RUST_HELLO_ARGS requires FUN_WITH_RUST=ON at build time");
|
||||
push_value(vm, make_nil());
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,33 +16,33 @@
|
|||
*/
|
||||
case OP_RUST_HELLO_ARGS_RETURN: {
|
||||
#ifdef FUN_WITH_RUST
|
||||
Value vmsg = pop_value(vm);
|
||||
char *msg = value_to_string_alloc(&vmsg);
|
||||
free_value(vmsg);
|
||||
if (msg) {
|
||||
char *ret = fun_rust_echo_string(msg);
|
||||
free(msg);
|
||||
if (ret) {
|
||||
push_value(vm, make_string(ret));
|
||||
fun_rust_string_free(ret);
|
||||
} else {
|
||||
push_value(vm, make_nil());
|
||||
}
|
||||
Value vmsg = pop_value(vm);
|
||||
char *msg = value_to_string_alloc(&vmsg);
|
||||
free_value(vmsg);
|
||||
if (msg) {
|
||||
char *ret = fun_rust_echo_string(msg);
|
||||
free(msg);
|
||||
if (ret) {
|
||||
push_value(vm, make_string(ret));
|
||||
fun_rust_string_free(ret);
|
||||
} else {
|
||||
char *ret = fun_rust_echo_string("");
|
||||
if (ret) {
|
||||
push_value(vm, make_string(ret));
|
||||
fun_rust_string_free(ret);
|
||||
} else {
|
||||
push_value(vm, make_nil());
|
||||
}
|
||||
push_value(vm, make_nil());
|
||||
}
|
||||
} else {
|
||||
char *ret = fun_rust_echo_string("");
|
||||
if (ret) {
|
||||
push_value(vm, make_string(ret));
|
||||
fun_rust_string_free(ret);
|
||||
} else {
|
||||
push_value(vm, make_nil());
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* Still pop and free the arg to keep stack sane */
|
||||
Value vmsg = pop_value(vm);
|
||||
free_value(vmsg);
|
||||
vm_raise_error(vm, "RUST_HELLO_ARGS_RETURN requires FUN_WITH_RUST=ON at build time");
|
||||
push_value(vm, make_nil());
|
||||
/* Still pop and free the arg to keep stack sane */
|
||||
Value vmsg = pop_value(vm);
|
||||
free_value(vmsg);
|
||||
vm_raise_error(vm, "RUST_HELLO_ARGS_RETURN requires FUN_WITH_RUST=ON at build time");
|
||||
push_value(vm, make_nil());
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,19 +15,19 @@
|
|||
*/
|
||||
case OP_RUST_SET_EXIT: {
|
||||
#ifdef FUN_WITH_RUST
|
||||
extern int fun_op_rset_exit(VM *vm);
|
||||
/* Expect an integer on the stack already (produced by prior ops) */
|
||||
/* fun_op_rset_exit will pop it and store into vm.exit_code */
|
||||
int rc = fun_op_rset_exit(vm);
|
||||
(void)rc;
|
||||
/* push Nil as a conventional result */
|
||||
push_value(vm, make_nil());
|
||||
extern int fun_op_rset_exit(VM * vm);
|
||||
/* Expect an integer on the stack already (produced by prior ops) */
|
||||
/* fun_op_rset_exit will pop it and store into vm.exit_code */
|
||||
int rc = fun_op_rset_exit(vm);
|
||||
(void)rc;
|
||||
/* push Nil as a conventional result */
|
||||
push_value(vm, make_nil());
|
||||
#else
|
||||
/* pop and ignore to keep stack sane */
|
||||
Value v = pop_value(vm);
|
||||
free_value(v);
|
||||
vm_raise_error(vm, "RUST_SET_EXIT requires FUN_WITH_RUST=ON at build time");
|
||||
push_value(vm, make_nil());
|
||||
/* pop and ignore to keep stack sane */
|
||||
Value v = pop_value(vm);
|
||||
free_value(v);
|
||||
vm_raise_error(vm, "RUST_SET_EXIT requires FUN_WITH_RUST=ON at build time");
|
||||
push_value(vm, make_nil());
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue