Name
SPVM::Document::NativeAPI - Native APIs
Description
The native APIs of SPVM are the APIs written by the C language for various operations.
These APIs are used in native modules.
Native APIs
runtime
void* runtime;
The runtime object for this environment.
Examples:
env->runtime;
api
void* api;
Access to other native APIs.
Allocator Native API
env->api->allocator;
SPVM::Document::NativeAPI::Allocator
String Buffer Native API
env->api->string_buffer;
SPVM::Document::NativeAPI::StringBuffer
Compiler Native API
env->api->compiler;
SPVM::Document::NativeAPI::Compiler
Module File Native API
env->api->module_file;
SPVM::Document::NativeAPI::ModuleFile
Runtime Native API
env->api->runtime;
SPVM::Document::NativeAPI::Runtime
Basic Type Native API
env->api->basic_type;
SPVM::Document::NativeAPI::BasicType
Class Variable Native API
env->api->clsas_var;
SPVM::Document::NativeAPI::ClassVariable
Field Native API
env->api->field;
SPVM::Document::NativeAPI::Field
Method Native API
env->api->method;
SPVM::Document::NativeAPI::Method
Argument Native API
env->api->arg;
SPVM::Document::NativeAPI::Argument
allocator
void* allocator;
The memory allocator for this environment.
new_env
SPVM_ENV* (*new_env)();
Creates a new environment.
free_env
void (*free_env)(SPVM_ENV* env);
Frees an environment.
call_init_methods
int32_t (*call_init_methods)(SPVM_ENV* env, SPVM_VALUE* stack);
Calls all INIT
methods defined by INIT
blocks.
If an exception is thrown, returns non-zero value. Otherwise returns 0.
set_command_info_program_name
int32_t (*set_command_info_program_name)(SPVM_ENV* env, SPVM_VALUE* stack, void* obj_program_name);
Sets the CommandInfo-PROGRAM_NAME|SPVM::CommandInfo/"PROGRAM_NAME"> class variable to the program name.
If an exception is thrown, returns non-zero value. Otherwise returns 0.
set_command_info_argv
int32_t (*set_command_info_argv)(SPVM_ENV* env, SPVM_VALUE* stack, void* obj_argv);
Sets the CommandInfo-PROGRAM_NAME|SPVM::CommandInfo/"ARGV"> class variable to the command line arguments.
If an exception is thrown, returns non-zero value. Otherwise returns 0.
set_command_info_base_time
int32_t (*set_command_info_base_time)(SPVM_ENV* env, SPVM_VALUE* stack, int64_t base_time);
Sets the CommandInfo-BASE_TIME|SPVM::CommandInfo/"BASE_TIME"> class variable to the time when the program starts.
If an exception is thrown, returns non-zero value. Otherwise returns 0.
destroy_class_vars
void (*destroy_class_vars)(SPVM_ENV* env, SPVM_VALUE* stack);
Destroys all class variables.
items
int32_t (*items)(SPVM_ENV* env, SPVM_VALUE* stack);
Returns the total width of the arguments given by the caller.
Examples:
int32_t items = env->items(env, stack);
get_object_basic_type
void* (*get_object_basic_type)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
Returns the basic type of the object.
get_object_basic_type_id
int32_t (*get_object_basic_type_id)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
Returns the basic type ID of the object.
get_object_basic_type_name
const char* (*get_object_basic_type_name)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
Returns the basic type name of the object.
get_object_type_dimension
int32_t (*get_object_type_dimension)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
Returns the type dimension of the object.
get_basic_type
void* (*get_basic_type)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name);
Gets a basic type by a basic type name.
get_basic_type_by_name
void* (*get_basic_type_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);
Gets a basic type by a basic type name.
If an exception is thrown, error_id
is set to non-zero value. Otherwise it is set to 0.
get_basic_type_by_id
void* (*get_basic_type_by_id)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t basic_type_id);
Gets a basic type by a basic type ID.
get_basic_type_id
int32_t (*get_basic_type_id)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name);
Gets a basic type ID by a basic type name.
Examples:
int32_t basic_type_id = env->get_basic_type_id(env, stack, "Int");
get_basic_type_id_by_name
int32_t (*get_basic_type_id_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);
Gets a basic type ID by a basic type name.
If an exception is thrown, error_id
is set to non-zero value. Otherwise it is set to 0.
get_field
void* (*get_field_by_index)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, const char* field_name);
Returns a field given an object and field name. If the field does not exist, returns NULL.
Examples:
void* field = env->get_field(env, stack, object, "x");
get_class_var_by_index
void* (*get_class_var_by_index)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, const char* class_var_name);
Returns a class variable given a basic type name and a class variable name. If the class variable does not exist, returns NULL.
Examples:
void* class_var = env->get_class_var(env, stack, "MyClass", "$VAR");
get_class_method
void* (*get_class_method)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, const char* method_name);
Returns a class method given a basic type name and a method name. If the class method does not exists, returns NULL.
Examples:
void* method = env->get_class_method(env, stack, "Foo", "get");
get_instance_method
void* (*get_instance_method)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, const char* method_name);
Gets an instance method address by the object and the method name. If the instance method does not exist, a negative value is returned.
Examples:
void* method = env->get_instance_method(env, stack, object, "get");
new_object_no_mortal
void* (*new_object_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, void* basic_type);
Creates a new object with a basic type. The basic type must be the correct basic type ID return by the "get_basic_type_id" Native API.
new_object
void* (*new_object)(SPVM_ENV* env, SPVM_VALUE* stack, void* basic_type);
The same as new_object_no_mortal
, and add the created object to the mortal stack of the environment. Use this function in normal use instead of new_object_no_mortal
.
Examples:
void* basic_type = env->get_basic_type(env, stack, "Int");
void* object = env->new_object(env, stack, basic_type);
new_byte_array_no_mortal
void* (*new_byte_array_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
Creates a new byte[] type array by specifying the length.
new_byte_array
void* (*new_byte_array)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
The same as new_byte_array_no_mortal
, and add the created array to the mortal stack of the environment. Use this function in normal use instead of new_byte_array_no_mortal
.
Examples:
void* byte_array = env->new_byte_array(env, stack, 100);
new_short_array_no_mortal
void* (*new_short_array_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
Creates a new short[] type array by specifying the length.
new_short_array
void* (*new_short_array)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
The same as new_short_array_no_mortal
, and add the created array to the mortal stack of the environment. Use this function in normal use instead of new_short_array_no_mortal
.
Examples:
void* short_array = env->new_short_array(env, stack, 100);
new_int_array_no_mortal
void* (*new_int_array_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
Creates a new int[] type array by specifying the length.
new_int_array
void* (*new_int_array)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
The same as new_int_array_no_mortal
, and add the created array to the mortal stack of the environment. Use this function in normal use instead of new_int_array_no_mortal
.
Examples:
void* int_array = env->new_int_array(env, stack, 100);
new_long_array_no_mortal
void* (*new_long_array_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
Creates a new long[] type array by specifying the length.
new_long_array
void* (*new_long_array)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
The same as new_long_array_no_mortal
, and add the created array to the mortal stack of the environment. Use this function in normal use instead of new_long_array_no_mortal
.
Examples:
void* long_array = env->new_long_array(env, stack, 100);
new_float_array_no_mortal
void* (*new_float_array_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
Creates a new float[] type array by specifying the length.
new_float_array
void* (*new_float_array)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
The same as new_float_array_no_mortal
, and add the created array to the mortal stack of the environment. Use this function in normal use instead of new_float_array_no_mortal
.
Examples:
void* float_array = env->new_float_array(env, stack, 100);
new_double_array_no_mortal
void* (*new_double_array_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
Creates a new double[] type array by specifying the length.
new_double_array
void* (*new_double_array)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
The same as new_double_array_no_mortal
, and add the created array to the mortal stack of the environment. Use this function in normal use instead of new_double_array_no_mortal
.
Examples:
void* double_array = env->new_double_array(env, stack, 100);
new_object_array_no_mortal
void* (*new_object_array_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, void* basic_type, int32_t length);
Creates a new object type array by specifying the basic type and the array length. The basic type must be the correct basic type got by the "get_basic_type" Native API.
new_object_array
void* (*new_object_array)(SPVM_ENV* env, SPVM_VALUE* stack, void* basic_type, int32_t length);
The same as new_object_array_no_mortal
, and add the created array to the mortal stack of the environment. Use this function in normal use instead of new_object_array_no_mortal
.
Examples:
int32_t basic_type_id = env->get_basic_type_id(env, stack, "Int");
void* object_array = env->new_object_array(env, stack, basic_type_id, 100);
new_muldim_array_no_mortal
void* (*new_muldim_array_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, void* basic_type, int32_t type_dimension, int32_t length);
Creates a new multi-dimensional array by specifying the basic type and the type dimension, and the array length. The basic type must be the correct basic type got bu the "get_basic_type_id" Native API. the type dimension of the element must be less than or equals to 255.
new_muldim_array
void* (*new_muldim_array_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, void* basic_type, int32_t type_dimension, int32_t length);
The same as new_muldim_array_no_mortal
, and add the created array to the mortal stack of the environment. Use this function in normal use instead of new_muldim_array_no_mortal
.
Examples:
// Creates 2-dimensional array - The same as "new Int[][100]".
int32_t basic_type_id = env->get_basic_type_id(env, stack, "Int");
void* multi_array = env->new_muldim_array(env, stack, basic_type_id, 2, 100);
new_mulnum_array_no_mortal
void* (*new_mulnum_array_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, void* basic_type, int32_t length);
Creates a new multi-numeric array by specifying the basic type and the array length. The basic type must be the correct basic type got by the "basic_type_id" Native API.
new_mulnum_array
void* (*new_mulnum_array)(SPVM_ENV* env, SPVM_VALUE* stack, void* basic_type, int32_t length);
The same as new_mulnum_array_no_mortal
, and add the created array to the mortal stack of the environment. Use this function in normal use instead of new_mulnum_array_no_mortal
.
Examples:
int32_t basic_type_id = env->get_basic_type_id(env, stack, "Complex_2d");
void* value_array = env->new_mulnum_array(env, stack, basic_type_id, 100);
new_string_nolen_no_mortal
void* (*new_string_nolen_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, const char* bytes);
Creates a new string object by specifying C language char* type value. this value must end with "\0".
new_string_nolen
void* (*new_string_nolen)(SPVM_ENV* env, SPVM_VALUE* stack, const char* bytes);
The same as new_string_nolen_no_mortal
, and push the created object to the mortal stack. Use this function in normal use instead of new_string_nolen_no_mortal
.
Examples:
void* str_obj = env->new_string_nolen(env, stack, "Hello World");
new_string_no_mortal
void* (*new_string_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, const char* bytes, int32_t length);
Creates a new string object with the bytes and the length.
If the length of bytes is lower than the specified length or the bytes is NULL, The part that longer than the length of bytes will be filled with \0
.
new_string
void* (*new_string)(SPVM_ENV* env, SPVM_VALUE* stack, const char* bytes, int32_t length);
The same as new_string_no_mortal
, and push the created object to the mortal stack. Usually use this function instead of new_string_no_mortal
.
Examples:
void* str_obj = env->new_string(env, stack, "Hello \0World", 11);
concat_no_mortal
void* (*concat_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, void* string1, void* string2);
Concats two strings.
concat
void* (*concat)(SPVM_ENV* env, SPVM_VALUE* stack, void* string1, void* string2);
The same as concat_no_mortal
, and push the created object to the mortal stack. Use this function in normal use instead of concat_no_mortal
.
new_stack_trace_no_mortal
void* (*new_stack_trace_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, void* exception, void* method, int32_t line);
Creates a string object that represents a stack trace by adding the file and line the method is called to the end of the exception message.
new_stack_trace
void* (*new_stack_trace)(SPVM_ENV* env, SPVM_VALUE* stack, void* exception, void* method, int32_t line);
The same as "new_stack_trace_no_mortal", and push the created object to the mortal stack.
length
int32_t (*length)(SPVM_ENV*, void* array);
If you specify an array, the length of the array is returned.
Examples:
int32_t length = env->length(env, stack, array);
get_elems_byte
int8_t* (*get_elems_byte)(SPVM_ENV* env, SPVM_VALUE* stack, void* array);
If you specify a byte[] type array, the pointer at the beginning of the internally stored C language int8_t[] type array is returned.
Examples:
int8_t* values = env->get_elems_byte(env, stack, array);
values[3] = 5;
get_elems_short
int16_t* (*get_elems_short)(SPVM_ENV* env, SPVM_VALUE* stack, void* array);
If a short[] type array is specified, the pointer at the beginning of the internally stored C language int16_t[] type array is returned.
Examples:
int16_t* values = env->get_elems_short(env, stack, array);
values[3] = 5;
get_elems_int
int32_t* (*get_elems_int)(SPVM_ENV* env, SPVM_VALUE* stack, void* array);
When an int[] type array is specified, the pointer at the beginning of the internally stored C language int32_t[] type array is returned.
Examples:
int32_t* values = env->get_elems_int(env, stack, array);
values[3] = 5;
get_elems_long
int64_t* (*get_elems_long)(SPVM_ENV* env, SPVM_VALUE* stack, void* array);
When a long[] type array is specified, the pointer at the beginning of the internally stored C language int64_t[] type array is returned.
Examples:
int64_t* values = env->get_elems_long(env, stack, array);
values[3] = 5;
get_elems_float
float* (*get_elems_float)(SPVM_ENV* env, SPVM_VALUE* stack, void* array);
When a float[] type array is specified, the pointer at the beginning of the C language float[] type array internally held is returned.
Examples:
float* values = env->get_elems_float(env, stack, array);
values[3] = 1.5f;
get_elems_double
double* (*get_elems_double)(SPVM_ENV* env, SPVM_VALUE* stack, void* array);
If a double[] type array is specified, the pointer at the beginning of the internally stored C double[] type array is returned.
Examples:
double* values = env->get_elems_double(env, stack, array);
values[3] = 1.5;
get_elem_object
void* (*get_elem_object)(SPVM_ENV* env, SPVM_VALUE* stack, void* array, int32_t index);
Gets an object of an element given an array of object types and a methodscript. If the element is a weak reference, the weak reference is removed.
Examples:
void* object = env->get_elem_object(env, stack, array, 3);
set_elem_object
void (*set_elem_object)(SPVM_ENV* env, SPVM_VALUE* stack, void* array, int32_t index, void* object);
If you specify an array of object type and methodscript and element objects, the element object is assigned to the corresponding methodscript position. If the element's object has a weak reference, the weak reference is removed. The reference count of the originally assigned object is decremented by 1.
Examples:
env->get_elem_object(env, stack, array, 3, object);
get_field_byte
int8_t (*get_field_byte)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field);
If an object and a field are specified, the byte field value will be returned as a C language int8_t type value. The field must be a valid field obtained with the "get_field_by_index" Native API
get_field_short
int16_t (*get_field_short)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field);
If an object and a field, the value of the short type field will be returned as the int16_t type value of C language. The field must be a valid field obtained with the "get_field_by_index" Native API
get_field_int
int32_t (*get_field_int)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field);
If an object and a field are specified, the value of the int type field will be returned as a C language int32_t type value. The field must be a valid field obtained with the "get_field_by_index" Native API
get_field_long
int64_t (*get_field_long)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field);
If an object and a field, the value of the long type field will be returned as the value of int64_t type of C language. The field must be a valid field obtained with the "get_field_by_index" Native API
get_field_float
float (*get_field_float)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field);
If an object and a field, the value of the float type field will be returned as a C language float type value. The field must be a valid field obtained with the "get_field_by_index" Native API
get_field_double
double (*get_field_double)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field);
If an object and a field, the value of the double type field will be returned as a double type value in C language. The field must be a valid field obtained with the "get_field_by_index" Native API
get_field_object
void* (*get_field_object)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field);
If an object and a field, the value of the object type field is returned as a void* type value in C language. The field must be a valid field obtained with the "get_field_by_index" Native API If the field is a weak reference, it will be removed.
set_field_byte
void (*set_field_byte)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field, int8_t value);
If an object and a field is given, the value is set to the byte type field. The field must be a valid field obtained with the "get_field_by_index" Native API
set_field_short
void (*set_field_short)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field, int16_t value);
If an object and a field is given, the value is set to the short type field. The field must be a valid field obtained with the "get_field_by_index" Native API
set_field_int
void (*set_field_int)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field, int32_t value);
If an object and a field is given, the value is set to the int type field. The field must be a valid field obtained with the "get_field_by_index" Native API
set_field_long
void (*set_field_long)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field, int64_t value);
If an object and a field is given, the value is set to the long type field. The field must be a valid field obtained with the "get_field_by_index" Native API
set_field_float
void (*set_field_float)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field, float value);
If an object and a field is given, the value is set to the float type field. The field must be a valid field obtained with the "get_field_by_index" Native API
set_field_double
void (*set_field_double)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field, double value);
If an object and a field is given, the value is set to the double type field. The field must be a valid field obtained with the "get_field_by_index" Native API
set_field_object
void (*set_field_object)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field, void* value);
An object and a field Specifies the ID and the value of the field and set the value to the object type field. The field must be a valid field obtained with the "get_field_by_index" Native API After setting, the reference count is incremented by 1. The original value has the reference count decremented by 1.
get_class_var_byte
int8_t (*get_class_var_byte)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var);
If a class variable is given, the value of the byte type class variable is returned as a C language int8_t type value. The class variable must be a valid class variable obtained with the "get_class_var_by_index" Native API.
get_class_var_short
int16_t (*get_class_var_short)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var);
If a class variable is given, the value of the short type class variable will be returned as a C language int16_t type value. The class variable must be a valid class variable obtained with the "get_class_var_by_index" Native API.
get_class_var_int
int32_t (*get_class_var_int)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var);
If a class variable is given, the value of the int type class variable will be returned as a C language int32_t type value. The class variable must be a valid class variable obtained with the "get_class_var_by_index" Native API.
get_class_var_long
int64_t (*get_class_var_long)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var);
If a class variable is given, the value of the long type class variable will be returned as a C language int64_t type value. The class variable must be a valid class variable obtained with the "get_class_var_by_index" Native API.
get_class_var_float
float (*get_class_var_float)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var);
If a class variable is given, the value of the float type class variable will be returned as a C language float type value. The class variable must be a valid class variable obtained with the "get_class_var_by_index" Native API.
get_class_var_double
double (*get_class_var_double)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var);
If you specify an object and a class variable, the value of the double type class variable is returned as a C type double type value. The class variable must be a valid class variable obtained with the "get_class_var_by_index" Native API.
get_class_var_object
void* (*get_class_var_object)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var);
When an object and a class variable are specified, the value of the object type class variable is returned as a C language void* type value. The class variable must be a valid class variable obtained with the "get_class_var_by_index" Native API.
set_class_var_byte
void (*set_class_var_byte)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var, int8_t value);
If a class variable is given, the value is set to the byte type class variable.
set_class_var_short
void (*set_class_var_short)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var, int16_t value);
If a class variable is given, the value is set to the short type class variable.
set_class_var_int
void (*set_class_var_int)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var, int32_t value);
If a class variable is given, the value is set to the int type class variable.
set_class_var_long
void (*set_class_var_long)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var, int64_t value);
If a class variable is given, the value is set to the long type class variable.
set_class_var_float
void (*set_class_var_float)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var, float value);
If a class variable is given, the value is set to the float type class variable.
set_class_var_double
void (*set_class_var_double)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var, double value);
If a class variable is given, the value is set to the double type class variable.
set_class_var_object
void (*set_class_var_object)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var, void* value);
If a class variable is given, the value of the class variable and set the value to the object type class variable. The class variable must be a valid class variable obtained with the "get_class_var_by_index" Native API. After setting, the reference count is incremented by 1. The original value has the reference count decremented by 1.
get_pointer
void* (*get_pointer)(SPVM_ENV* env, SPVM_VALUE* stack, void* pointer_object);
Specifies a pointer object and return the C language pointer stored inside the object.
Examples:
strcut tm* tm_ptr = (struct tm*) env->get_pointer(env, stack, tm_obj);
set_pointer
void (*set_pointer)(SPVM_ENV* env, SPVM_VALUE* stack, void* pointer_object, void* pointer);
If you specify a pointer object and a C language pointer, the C language pointer is saved in the internal data of the pointer type object.
call_method_no_mortal
int32_t (*call_method_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, void* method, int32_t items);
Call a method by specifying the method address and the stack length of the argument. If an exception occurs in the method, The return value is 1. If not, return 0.
The return value of the method is set to stack[0].
get_exception
void* (*get_exception)(SPVM_ENV* env, SPVM_VALUE* stack);
Gets a exception message which type is byte[].
set_exception
void (*set_exception)(SPVM_ENV* env, SPVM_VALUE* stack, void* exception);
Sets a exception message which type is byte[].
get_ref_count
int32_t (*get_ref_count)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
Gets the refernce count of the object.
inc_ref_count
void (*inc_ref_count)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
Specifying an object increments the reference count of the object.
Use this method only if you have a specific reason to use it. Normally, the reference count is managed automatically.
dec_ref_count
void (*dec_ref_count)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
Specifying an object decrements the object's reference count by 1. When the reference count reaches 0, the object is released.
Use this method only if you have a specific reason to use it. Normally, the reference count is managed automatically.
enter_scope
int32_t (*enter_scope)(SPVM_ENV* env, SPVM_VALUE* stack);
Creates a new scope and return the scope ID.
push_mortal
int32_t (*push_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
Add an object to the mortal stack.
If this method succeed, return 0.
If this method don't alloc memory for new mortal information, return 1.
leave_scope
void (*leave_scope)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t scope_id);
Specifies a scope ID to exit that scope and decrement the object's reference count stored in the mortal stack. Objects with a reference count of 0 are released. The scope ID must be the ID obtained by the enter_scope function.
remove_mortal
int32_t (*remove_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t scope_id, void* remove_object);
Given a scope ID and an object, delete the specified object from the mortal stack.
isa
int32_t (*isa)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* cast_basic_type, int32_t cast_type_dimension);
Checks if the object object
can be assigned to the type given by the basic type cast_basic_type
and the type dimension cast_type_dimension
.
If it is ok, returns 1. Otherwise returns 0.
elem_isa
int32_t (*elem_isa)(SPVM_ENV* env, SPVM_VALUE* stack, void* array, void* element);
Checks if the element element
can be assigned to the element of the array array
.
If it is ok, returns 1. Otherwise returns 0.
is_type
int32_t (*is_type)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* basic_type, int32_t type_dimension);
Given an object and a basic type and a type dimension, returns a nonzero value if the object matches both the basic type and the type dimension, and 0 otherwise.
is_object_array
int32_t (*is_object_array)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
If the object is a object array, returns 1, otherwise returns 0.
If the object is NULL
, returns 0.
weaken
int32_t (*weaken)(SPVM_ENV* env, SPVM_VALUE* stack, void** object_address);
Creates weak reference to the object which is specified by object address.
The reference count of the object is decrimented by 1 and weaken flag is added to the object address.
If the reference count is 1, "dec_ref_count" is called to the object.
If object_address is NULL, this method do nothing.
If the object is already weaken, this method do nothing.
This method allocate memory internally to add the back reference from the object to the object address.
This method success return 0.
If failing memory allocation of back reference, return 1.
isweak
int32_t (*isweak()SPVM_ENV* env, void** object);
Given the address of an object, returns non-zero if the object is a weak reference, 0 otherwise.
unweaken
void (*unweaken)(SPVM_ENV* env, SPVM_VALUE* stack, void** object_address);
Specifying the address of the object releases the weak reference to the object.
get_type_name_no_mortal
void* (*get_type_name_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
Gets a new string
object that is the type name of the object.
This function does not add the returned object to the mortal stack, so use the get_type_name Native API for normal use to avoid memory leaks.
get_type_name
void* (*get_type_name)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
Gets a new string
object that is the type name of the object.
get_chars
const char* (*get_chars)(SPVM_ENV* env, SPVM_VALUE* stack, void* string_object);
Gets characters in the string object.
Examples:
const char* bytes = env->get_chars(env, stack, string_object);
die
int32_t (*die)(SPVM_ENV* env, SPVM_VALUE* stack, const char* message, ...);
Creates a sprintf
formatted message with file name and line number and set it to the exception.
Last three arguments are the function name, the file name, and the line number.
Returns value is the basic type ID of the Error class.
Examples:
return env->die(env, stack, "Value must be %d", 3, __func__, __FILE__, __LINE__);
new_object_by_name
void* (*new_object_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "new_object" Native API, but you can specify basic type name directly.
If function is succeeded, error
is set to 0. If a exception occurs, error
is set to 1.
Examples:
int32_t error = 0;
void* minimal = env->new_object_by_name(env, stack, "TestCase::Minimal", &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
set_field_byte_by_name
void (*set_field_byte_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
void* object, const char* field_name, int8_t value,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "set_field_byte" Native API, but you can specify field name directly.
If function is succeeded, error
is set to 0. If a exception occurs, error
is set to 1.
Examples:
int32_t error = 0;
env->set_field_byte_by_name(env, stack, object, "byte_value", 13, &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
set_field_short_by_name
void (*set_field_short_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
void* object, const char* field_name, int16_t value,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "set_field_short" Native API, but you can specify field name directly.
If function is succeeded, error
is set to 0. If a exception occurs, error
is set to 1.
Examples:
int32_t error = 0;
env->set_field_short_by_name(env, stack, object, "short_value", 13, &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
set_field_int_by_name
void (*set_field_int_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
void* object, const char* field_name, int32_t value,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "set_field_int" Native API, but you can specify field name directly.
If function is succeeded, error
is set to 0. If a exception occurs, error
is set to 1.
Examples:
int32_t error = 0;
env->set_field_int_by_name(env, stack, object, "int_value", 13, &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
set_field_long_by_name
void (*set_field_long_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
void* object, const char* field_name, int64_t value,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "set_field_long" Native API, but you can specify field name directly.
If function is succeeded, error
is set to 0. If a exception occurs, error
is set to 1.
Examples:
int32_t error = 0;
env->set_field_long_by_name(env, stack, object, "long_value", 13, &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
set_field_float_by_name
void (*set_field_float_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
void* object, const char* field_name, float value,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "set_field_float" Native API, but you can specify field name directly.
If function is succeeded, error
is set to 0. If a exception occurs, error
is set to 1.
Examples:
int32_t error = 0;
env->set_field_float_by_name(env, stack, object, "float_value", 13, &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
set_field_double_by_name
void (*set_field_double_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
void* object, const char* field_name, double value,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "set_field_double" Native API, but you can specify field name directly.
If function is succeeded, error
is set to 0. If a exception occurs, error
is set to 1.
Examples:
int32_t error = 0;
env->set_field_double_by_name(env, stack, object, "double_value", 13, &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
set_field_object_by_name
void (*set_field_object_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
void* object, const char* field_name, void* value,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "set_field_object" Native API, but you can specify field name directly.
If function is succeeded, error
is set to 0. If a exception occurs, error
is set to 1.
Examples:
int32_t error = 0;
env->set_field_object_by_name(env, stack, object_simple, "object_value", object_minimal, &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
get_field_byte_by_name
int8_t (*get_field_byte_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
void* object, const char* field_name,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "get_field_byte" Native API, but you can specify field name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
int8_t byte_value = env->get_field_byte_by_name(env, stack, object, "byte_value", &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
get_field_short_by_name
int16_t (*get_field_short_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
void* object, const char* field_name,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "get_field_short" Native API, but you can specify field name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
int8_t short_value = env->get_field_short_by_name(env, stack, object, "short_value", &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
get_field_int_by_name
int32_t (*get_field_int_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
void* object, const char* field_name,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "get_field_int" Native API, but you can specify field name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
int8_t int_value = env->get_field_int_by_name(env, stack, object, "int_value", &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
get_field_long_by_name
int64_t (*get_field_long_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
void* object, const char* field_name,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "get_field_long" Native API, but you can specify field name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
int8_t long_value = env->get_field_long_by_name(env, stack, object, "long_value", &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
get_field_float_by_name
float (*get_field_float_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
void* object, const char* field_name,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "get_field_float" Native API, but you can specify field name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
int8_t float_value = env->get_field_float_by_name(env, stack, object, "float_value", &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
get_field_double_by_name
double (*get_field_double_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
void* object, const char* field_name,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "get_field_double" Native API, but you can specify field name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
int8_t double_value = env->get_field_double_by_name(env, stack, object, "double_value", &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
get_field_object_by_name
void* (*get_field_object_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
void* object, const char* field_name,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "get_field_object" Native API, but you can specify field name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
void* object_minimal = env->get_field_object_by_name(env, stack, object_simple, "object_value", "TestCase::Minimal", &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
set_class_var_byte_by_name
void (*set_class_var_byte_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
const char* basic_type_name, const char* class_var_name, int8_t value,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "set_class_var_byte" Native API, but you can specify the basic type name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
env->set_class_var_byte_by_name(env, stack, "TestCase::NativeAPI", "$BYTE_VALUE", 15, &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
set_class_var_short_by_name
void (*set_class_var_short_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
const char* basic_type_name, const char* class_var_name, int16_t value,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "set_class_var_short" Native API, but you can specify the basic type name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
env->set_class_var_short_by_name(env, stack, "TestCase::NativeAPI", "$SHORT_VALUE", 15, &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
set_class_var_int_by_name
void (*set_class_var_int_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
const char* basic_type_name, const char* class_var_name, int32_t value,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "set_class_var_int" Native API, but you can specify the basic type name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
env->set_class_var_int_by_name(env, stack, "TestCase::NativeAPI", "$INT_VALUE", 15, &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
set_class_var_long_by_name
void (*set_class_var_long_by_name)(SPVM_ENV* env
const char* basic_type_name, const char* class_var_name, int64_t value,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "set_class_var_long" Native API, but you can specify the basic type name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
env->set_class_var_long_by_name(env, stack, "TestCase::NativeAPI", "$LONG_VALUE", 15, &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
set_class_var_float_by_name
void (*set_class_var_float_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
const char* basic_type_name, const char* class_var_name, float value,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "set_class_var_float" Native API, but you can specify the basic type name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
env->set_class_var_float_by_name(env, stack, "TestCase::NativeAPI", "$FLOAT_VALUE", 15, &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
set_class_var_double_by_name
void (*set_class_var_double_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
const char* basic_type_name, const char* class_var_name, double value,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "set_class_var_double" Native API, but you can specify the basic type name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
env->set_class_var_double_by_name(env, stack, "TestCase::NativeAPI", "$DOUBLE_VALUE", 15, &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
set_class_var_object_by_name
void (*set_class_var_object_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
const char* basic_type_name, const char* class_var_name, void* value,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "set_class_var_object" Native API, but you can specify the basic type name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
env->set_class_var_object_by_name(env, stack, "TestCase::NativeAPI", "$MINIMAL_VALUE", "TestCase::Minimal", minimal, &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
get_class_var_byte_by_name
int8_t (*get_class_var_byte_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
const char* basic_type_name, const char* class_var_name,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "get_class_var_byte" Native API, but you can specify the basic type name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
int8_t value = env->get_class_var_byte_by_name(env, stack, "TestCase::NativeAPI", "$BYTE_VALUE", &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
get_class_var_short_by_name
int16_t (*get_class_var_short_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
const char* basic_type_name, const char* class_var_name,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "get_class_var_short" Native API, but you can specify the basic type name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
int16_t value = env->get_class_var_short_by_name(env, stack, "TestCase::NativeAPI", "$SHORT_VALUE", &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
get_class_var_int_by_name
int32_t (*get_class_var_int_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
const char* basic_type_name, const char* class_var_name,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "get_class_var_int" Native API, but you can specify the basic type name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
int8_t value = env->get_class_var_byte_by_name(env, stack, "TestCase::NativeAPI", "$BYTE_VALUE", &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
get_class_var_long_by_name
int64_t (*get_class_var_long_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
const char* basic_type_name, const char* class_var_name,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "get_class_var_long" Native API, but you can specify the basic type name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
int64_t value = env->get_class_var_long_by_name(env, stack, "TestCase::NativeAPI", "$LONG_VALUE", &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
get_class_var_float_by_name
float (*get_class_var_float_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
const char* basic_type_name, const char* class_var_name,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "get_class_var_float" Native API, but you can specify the basic type name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
float value = env->get_class_var_float_by_name(env, stack, "TestCase::NativeAPI", "$FLOAT_VALUE", &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
get_class_var_double_by_name
double (*get_class_var_double_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
const char* basic_type_name, const char* class_var_name,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "get_class_var_double" Native API, but you can specify the basic type name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
double value = env->get_class_var_double_by_name(env, stack, "TestCase::NativeAPI", "$DOUBLE_VALUE", &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
get_class_var_object_by_name
void* (*get_class_var_object_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
const char* basic_type_name, const char* class_var_name,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as the "get_class_var_object" Native API, but you can specify the basic type name directly.
If function is succeeded, error
is get to 0. If a exception occurs, error
is get to 1.
Examples:
int32_t error = 0;
void* value = env->get_class_var_object_by_name(env, stack, "TestCase::NativeAPI", "$MINIMAL_VALUE", &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
call_class_method_by_name
void (*call_class_method_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, const char* method_name, int32_t items, int32_t* error_id, const char* func_name, const char* file, int32_t line);
Calls a class method given the basic type name and method name.
Examples:
int32_t error = 0;
int32_t output;
{
int32_t items = 1;
stack[0].ival = 5;
env->call_class_method_by_name(env, stack, "TestCase::NativeAPI", "my_value", items, &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
output = stack[0].ival;
}
call_instance_method_by_name
void (*call_instance_method_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, const char* method_name, int32_t items, int32_t* error_id, const char* func_name, const char* file, int32_t line);
Calls an instance method given the method name.
get_field_string_chars_by_name
const char* (*get_field_string_chars_by_name)(SPVM_ENV* env, SPVM_VALUE* stack,
void* object, const char* field_name,
int32_t* error_id, const char* func_name, const char* file, int32_t line);
dump_no_mortal
void* (*dump_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
Gets the string which dump the object. The string is the same as the return value of dump
operator.
dump
void* (*dump)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
The same as dump_no_mortal
, and push the created object to the mortal stack. Use this function in normal use instead of dump_no_mortal
.
get_instance_method_static
void* (*get_instance_method_static)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, const char* method_name);
Returns an instance method given a basic type name and a method name. If the instance method does not exists, returns NULL.
Examples:
void* method = env->get_instance_method_static(env, stack, "Foo", "get");
get_bool_object_value
int32_t (*get_bool_object_value)(SPVM_ENV* env, SPVM_VALUE* stack, void* bool_object);
Gets the value of a Bool object. If the Bool object is true, return 1, otherwise return 0.
Examples:
int32_t bool_value = env->get_bool_object_value(env, stack, bool_object);
make_read_only
void (*make_read_only)(SPVM_ENV* env, SPVM_VALUE* stack, void* string)
Make the string read-only.
is_read_only
void (*make_read_only)(SPVM_ENV* env, SPVM_VALUE* stack, void* string)
If the string is read-only, returns 1, otherwise returns 0.
is_array
int32_t (*is_array)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
If the object is an array, returns 1, otherwise returns 0.
If the object is NULL
, returns 0.
is_string
int32_t (*is_string)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
If the object is a string, returns 1, otherwise returns 0.
If the object is NULL
, returns 0.
is_numeric_array
int32_t (*is_numeric_array)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
If the object is a numeric array, returns 1, otherwise returns 0.
If the object is NULL
, returns 0.
is_mulnum_array
int32_t (*is_mulnum_array)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
If the object is a multi numeric array, returns 1, otherwise returns 0.
If the object is NULL
, returns 0.
get_elem_size
int32_t (*get_elem_size)(SPVM_ENV* env, SPVM_VALUE* stack, void* array);
Gets the byte size of the element of the array.
new_array_proto
void* (*new_array_proto)(SPVM_ENV* env, SPVM_VALUE* stack, void* array, int32_t length);
Creates a new array that have the type of the given array and the given length.
The given array must be the object that is an array type.
If the given array is NULL, returns NULL
.
If the given length is lower than 0, returns NULL
.
copy
void* (*copy)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
Copy the object. The type of the object must be a string type, a numeric array, or a multi numeric array.
If the given object is NULL, returns NULL.
shorten
void (*shorten)(SPVM_ENV* env, SPVM_VALUE* stack, void* string, int32_t new_length);
Shorten the string with the given length.
If the string is null, does nothing.
If the given length is greater than the length of the string, does nothing.
If the given length is lower than 0, the given length become 0.
The charaters of the after the given length are filled with \0
.
void (*print)(SPVM_ENV* env, SPVM_VALUE* stack, void* string);
Prints the characters of the string to stdout.
If the string is NULL
, nothing is printed.
print_stderr
void (*print_stderr)(SPVM_ENV* env, SPVM_VALUE* stack, void* string);
Prints the characters of the string to stderr.
If the string is NULL
, nothing is printed.
new_stack
SPVM_VALUE* (*new_stack)(SPVM_ENV* env);
free_stack
void (*free_stack)(SPVM_ENV* env, SPVM_VALUE* stack);
new_memory_env
void* (*new_memory_env)(SPVM_ENV* env, size_t size);
Creates a new memory block that is managed by the environment with the byte size and return the address. If it fails, return NULL
.
The count of the memory block that is managed by the environment is incremented by 1.
free_memory_env
void (*free_memory_env)(SPVM_ENV* env, void* block);
Frees the memory block that is managed by the environment.
The count of the memory block that is managed by the environment is decremented by 1.
get_memory_blocks_count_env
int32_t (*get_memory_blocks_count_env)(SPVM_ENV* env);
Returns the count of the memory blocks on the environment.
This is the same as "get_memory_blocks_count". This is more understandable name that memories are managed by the environment.
new_memory_stack
void* (*new_memory_stack)(SPVM_ENV* env, SPVM_VALUE* stack, size_t size);
Creates a new memory block that is managed by the stack of the environment with the byte size and return the address. If it fails, return NULL
.
The count of the memory block that is managed by the stack is incremented by 1.
The count of the memory block that is managed by the environment is incremented by 1.
free_memory_stack
void (*free_memory_stack)(SPVM_ENV* env, SPVM_VALUE* stack, void* block);
Frees the memory block that is managed by the environment.
The count of the memory block that is managed by the stack is decremented by 1.
The count of the memory block that is managed by the environment is decremented by 1.
get_memory_blocks_count_stack
int32_t (*get_memory_blocks_count_stack)(SPVM_ENV* env, SPVM_VALUE* stack);
Returns the count of the memory blocks on the stack.
strerror
const char* (*strerror)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t errno_value, int32_t length);
Gets the value of strerror
of the C language on thread-safely.
If the length is 0, the length is set to 64.
new_string_array
void* (*new_string_array)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
Creates a new string array. This is alias for the following code using "new_object_array".
void* obj_string_array = env->new_object_array(env, stack, SPVM_NATIVE_C_BASIC_TYPE_ID_STRING, length);
dumpc
const char* (*dumpc)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
The alias for the following code using "dump".
const char* ret = env->get_chars(env, stack, SPVM_API_dump(env, stack, object));
new_pointer_object_no_mortal
void* (*new_pointer_object_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, void* basic_type, void* pointer);
Creates a pointer object by specifying a basic type and a C language pointer. The basic type must be the correct basic type got by the "get_basic_type" Native API.
new_pointer_object
void* (*new_pointer_object)(SPVM_ENV* env, SPVM_VALUE* stack, void* basic_type, void* pointer);
The same as "new_pointer_no_mortal", and push the created object to the mortal stack. Use this function in normal use instead of new_pointer_no_mortal
.
Examples:
void* basic_type = env->get_basic_type(env, stack, "MyTime");
void* pointer = malloc(sizeof (struct tm));
void* pointer_obj = env->new_pointer(env, stack, basic_type, pointer);
new_pointer_object_by_name
void* (*new_pointer_object_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, void* pointer, int32_t* error_id, const char* func_name, const char* file, int32_t line);
This is the same as "new_pointer" function, but you can specify basic type name directly.
If function is succeeded, error
is set to 0. If a exception occurs, error
is set to 1.
int32_t error = 0;
void* minimal = env->new_pointer_by_name(env, stack, "TestCase::Pointer", pointer, &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
get_elem_string
void* (*get_elem_string)(SPVM_ENV* env, SPVM_VALUE* stack, void* array, int32_t index);
The same as "get_elem_object".
set_elem_string
void (*set_elem_string)(SPVM_ENV* env, SPVM_VALUE* stack, void* array, int32_t index, void* string);
The same as "set_elem_object".
is_class
int32_t (*is_class)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
If the object is an instance of a class, returns 1, otherwise returns 0.
If the object is NULL
, returns 0.
is_pointer_class
int32_t (*is_pointer_class)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
If the object is an instance of a pointer class, returns 1, otherwise returns 0.
If the object is NULL
, returns 0.
strerror_string
void* (*strerror_string)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t errno_value, int32_t length);
The same as the "strerror" function, but return a string
object.
get_field_static
void* (*get_field_static)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, const char* field_name);
Gets the field given an basic type name and field name. If the field does not exist, a value less than 0 is returned.
Examples:
void* field = env->get_field_static(env, stack, "Point", "x");
call_instance_method_static_by_name
void (*call_instance_method_static_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, const char* method_name, int32_t items, int32_t* error_id, const char* func_name, const char* file, int32_t line);
Calls an instance method by the basic type name and the method name.
Examples:
int32_t error = 0;
int32_t output;
{
int32_t items = 1;
stack[0].oval = obj_point;
env->call_instance_method_static_by_name(env, stack, "Point", "x", items, &error, __func__, __FILE__, __LINE__);
if (error) { return error; }
output = stack[0].ival;
}
get_method_by_index
void* (*get_method_by_index)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, const char* method_name);
Returns a method given a basic type name and a method name. If the method does not exists, returns NULL.
Examples:
void* method = env->get_method(env, stack, "Foo", "get");
strerror_nolen
const char* (*strerror_nolen)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t errno_value);
The same as "strerror" given the length to 0.
strerror_string_nolen
void* (*strerror_string_nolen)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t errno_value);
The same as "strerror_string" given the length to 0.
get_compile_type_name_no_mortal
void* (*get_compile_type_name_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, int32_t type_dimension, int32_t type_flag);
Gets a new string
object that is the compile-time type name with a basic type name, a type dimension, a type flag.
This function does not add the returned object to the mortal stack, so use the get_compile_type_name Native API for normal use to avoid memory leaks.
get_compile_type_name
void* (*get_compile_type_name)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, int32_t type_dimension, int32_t type_flag);
Gets a new string
object that is the compile-time type name with a basic type name, a type dimension, a type flag.
get_spvm_version_string
const char* (*get_spvm_version_string)(SPVM_ENV* env, SPVM_VALUE* stack);
Returns the version string of the SPVM language.
get_spvm_version_number
double (*get_spvm_version_number)(SPVM_ENV* env, SPVM_VALUE* stack);
Returns the version number of the SPVM language.
get_version_string
const char* (*get_version_string)(SPVM_ENV* env, SPVM_VALUE* stack, void* basic_type);
Returns the version string of a basic_type. The basic_type_id
must be a valid basic type.
If the version string in the basic_type is not defined, returns NULL.
get_version_number
double (*get_version_number)(SPVM_ENV* env, SPVM_VALUE* stack, void* basic_type);
Returns the version number of a basic_type. The basic_type_id
must be a valid basic type.
If the version string in the basic_type is not defined, returns -1.
call_method
int32_t (*call_method)(SPVM_ENV* env, SPVM_VALUE* stack, void* method, int32_t items);
Call a method by specifying the method address and the stack length of the argument. If an exception occurs in the method, The return value is 1. If not, return 0.
The return value of the method is set to stack[0].
If stack[0] is a value of an object type, the object is pushed to the mortal stack.
isa_by_name
int32_t (*isa_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, const char* basic_type_name, int32_t type_dimension);
The feature is the same as the "isa", but the basic type name can be given. If the basic type name is not found, returns 0.
is_type_by_name
int32_t (*is_type_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, const char* basic_type_name, int32_t type_dimension);
The feature is the same as the "is_type", but the basic type name can be given. If the basic type name is not found, returns 0.
new_stack_trace_raw_by_name
void* (*new_stack_trace_raw_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, void* exception, const char* basic_type_name, const char* method_name, int32_t line);
Creates a string object that represents a stack trace by adding the file and line the method is called to the end of the exception message.
new_stack_trace_by_name
void* (*new_stack_trace_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, void* exception, const char* basic_type_name, const char* method_name, int32_t line);
The same as "new_stack_trace_raw_by_name", and push the created object to the mortal stack.
new_object_array_raw_by_name
void* (*new_object_array_raw_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, int32_t length);
new_object_array_by_name
void* (*new_object_array_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, int32_t length);
new_muldim_array_raw_by_name
void* (*new_muldim_array_raw_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, int32_t element_dimension, int32_t length);
new_muldim_array_by_name
void* (*new_muldim_array_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, int32_t element_dimension, int32_t length);
new_mulnum_array_raw_by_name
void* (*new_mulnum_array_raw_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, int32_t length);
new_mulnum_array_by_name
void* (*new_mulnum_array_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, int32_t length);
get_class_var_object_address
void** (*get_class_var_object_address)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var);
Native API IDs
Native APIs have its IDs. These IDs are permanently same for the binary compatibility after the future release v1.0
.
0 runtime
1 api
2 new_env
3 free_env
4 call_init_methods
5 set_command_info_program_name
6 set_command_info_argv
7 set_command_info_base_time
8 destroy_class_vars
9 items
10 get_object_basic_type
11 get_object_basic_type_id
12 get_object_basic_type_name
13 get_object_type_dimension
14 get_basic_type
15 get_basic_type_by_name
16 get_basic_type_by_id
17 get_basic_type_id
18 get_basic_type_id_by_name
19 get_class_var
20 get_class_var_byte
21 get_class_var_short
22 get_class_var_int
23 get_class_var_long
24 get_class_var_float
25 get_class_var_double
26 get_class_var_object
27 get_class_var_string
28 set_class_var_byte
29 set_class_var_short
30 set_class_var_int
31 set_class_var_long
32 set_class_var_float
33 set_class_var_double
34 set_class_var_object
35 set_class_var_string
36 get_class_var_object_address
37 get_class_var_byte_by_name
38 get_class_var_short_by_name
39 get_class_var_int_by_name
40 get_class_var_long_by_name
41 get_class_var_float_by_name
42 get_class_var_double_by_name
43 get_class_var_object_by_name
44 get_class_var_string_by_name
45 set_class_var_byte_by_name
46 set_class_var_short_by_name
47 set_class_var_int_by_name
48 set_class_var_long_by_name
49 set_class_var_float_by_name
50 set_class_var_double_by_name
51 set_class_var_object_by_name
52 set_class_var_string_by_name
53 get_field
54 get_field_static
55 get_field_byte
56 get_field_short
57 get_field_int
58 get_field_long
59 get_field_float
60 get_field_double
61 get_field_object
62 get_field_string
63 set_field_byte
64 set_field_short
65 set_field_int
66 set_field_long
67 set_field_float
68 set_field_double
69 set_field_object
70 set_field_string
71 get_field_byte_by_name
72 get_field_short_by_name
73 get_field_int_by_name
74 get_field_long_by_name
75 get_field_float_by_name
76 get_field_double_by_name
77 get_field_object_by_name
78 get_field_string_by_name
79 set_field_byte_by_name
80 set_field_short_by_name
81 set_field_int_by_name
82 set_field_long_by_name
83 set_field_float_by_name
84 set_field_double_by_name
85 set_field_object_by_name
86 set_field_string_by_name
87 get_field_string_chars_by_name
88 get_method
89 get_class_method
90 get_instance_method_static
91 get_instance_method
92 call_method_no_mortal
93 call_method
94 call_class_method_by_name
95 call_instance_method_static_by_name
96 call_instance_method_by_name
97 new_object_no_mortal
98 new_object
99 new_object_by_name
100 new_pointer_object_no_mortal
101 new_pointer_object
102 new_pointer_object_by_name
103 get_pointer
104 set_pointer
105 new_string_nolen_no_mortal
106 new_string_nolen
107 new_string_no_mortal
108 new_string
109 new_byte_array_no_mortal
110 new_byte_array
111 new_short_array_no_mortal
112 new_short_array
113 new_int_array_no_mortal
114 new_int_array
115 new_long_array_no_mortal
116 new_long_array
117 new_float_array_no_mortal
118 new_float_array
119 new_double_array_no_mortal
120 new_double_array
121 new_object_array_no_mortal
122 new_object_array
123 new_object_array_by_name
124 new_string_array
125 new_muldim_array_no_mortal
126 new_muldim_array
127 new_muldim_array_by_name
128 new_mulnum_array_no_mortal
129 new_mulnum_array
130 new_mulnum_array_by_name
131 new_array_proto_no_mortal
132 new_array_proto
133 length
134 get_elems_byte
135 get_elems_short
136 get_elems_int
137 get_elems_long
138 get_elems_float
139 get_elems_double
140 get_elem_object
141 get_elem_string
142 set_elem_object
143 set_elem_string
144 get_chars
145 get_bool_object_value
146 concat_no_mortal
147 concat
148 shorten
149 make_read_only
150 is_read_only
151 print
152 print_stderr
153 dump_no_mortal
154 dump
155 dumpc
156 copy_no_mortal
157 copy
158 get_spvm_version_string
159 get_spvm_version_number
160 get_version_string
161 get_version_number
162 die
163 get_exception
164 set_exception
165 new_stack_trace_no_mortal
166 new_stack_trace
167 is_string
168 is_class
169 is_pointer_class
170 is_array
171 is_object_array
172 is_numeric_array
173 is_mulnum_array
174 isa
175 isa_by_name
176 is_type
177 is_type_by_name
178 elem_isa
179 get_elem_size
180 get_type_name_no_mortal
181 get_type_name
182 get_compile_type_name_no_mortal
183 get_compile_type_name
184 enter_scope
185 leave_scope
186 push_mortal
187 remove_mortal
188 weaken
189 isweak
190 unweaken
191 strerror_string
192 strerror_string_nolen
193 strerror
194 strerror_nolen
195 allocator
196 new_memory_env
197 free_memory_env
198 get_memory_blocks_count_env
199 new_memory_stack
200 free_memory_stack
201 get_memory_blocks_count_stack
202 new_stack
203 free_stack
204 get_ref_count
205 inc_ref_count
206 dec_ref_count
Constant Values
Basic Type IDs
0 SPVM_NATIVE_C_BASIC_TYPE_ID_UNKNOWN
1 SPVM_NATIVE_C_BASIC_TYPE_ID_UNDEF
2 SPVM_NATIVE_C_BASIC_TYPE_ID_VOID
3 SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE
4 SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT
5 SPVM_NATIVE_C_BASIC_TYPE_ID_INT
6 SPVM_NATIVE_C_BASIC_TYPE_ID_LONG
7 SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT
8 SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE
9 SPVM_NATIVE_C_BASIC_TYPE_ID_STRING
10 SPVM_NATIVE_C_BASIC_TYPE_ID_ANY_OBJECT
11 SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE_CLASS
12 SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT_CLASS
13 SPVM_NATIVE_C_BASIC_TYPE_ID_INT_CLASS
14 SPVM_NATIVE_C_BASIC_TYPE_ID_LONG_CLASS
15 SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT_CLASS
16 SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE_CLASS
17 SPVM_NATIVE_C_BASIC_TYPE_ID_BOOL_CLASS
18 SPVM_NATIVE_C_BASIC_TYPE_ID_ERROR_CLASS
19 SPVM_NATIVE_C_BASIC_TYPE_ID_ERROR_SYSTEM_CLASS
20 SPVM_NATIVE_C_BASIC_TYPE_ID_ERROR_NOT_SUPPORTED_CLASS
21 SPVM_NATIVE_C_BASIC_TYPE_ID_COMMAND_INFO_CLASS
22 SPVM_NATIVE_C_BASIC_TYPE_ID_ADDRESS_CLASS
These IDs are permanently same for the binary compatibility after the future release v1.0
.
SPVM_NATIVE_C_BASIC_TYPE_ID_UNKNOWN
The basic type is unknown.
SPVM_NATIVE_C_BASIC_TYPE_ID_UNDEF
The basic type ID of undef type.
SPVM_NATIVE_C_BASIC_TYPE_ID_VOID
The basic type ID of void
type.
SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE
The basic type ID of byte
type.
SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT
The basic type ID of short
type.
SPVM_NATIVE_C_BASIC_TYPE_ID_INT
The basic type ID of int
type.
SPVM_NATIVE_C_BASIC_TYPE_ID_LONG
The basic type ID of long
type.
SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT
The basic type ID of float
type.
SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE
The basic type ID of double
type.
SPVM_NATIVE_C_BASIC_TYPE_ID_STRING
The basic type ID of string
type.
SPVM_NATIVE_C_BASIC_TYPE_ID_ANY_OBJECT
The basic type ID of object
type.
SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE_CLASS
The basic type ID of Byte type.
SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT_CLASS
The basic type ID of Short type.
SPVM_NATIVE_C_BASIC_TYPE_ID_INT_CLASS
The basic type ID of Int type.
SPVM_NATIVE_C_BASIC_TYPE_ID_LONG_CLASS
The basic type ID of Long type.
SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT_CLASS
The basic type ID of Float type.
SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE_CLASS
The basic type ID of Double type.
SPVM_NATIVE_C_BASIC_TYPE_ID_BOOL_CLASS
The basic type ID of BOOL type.
SPVM_NATIVE_C_BASIC_TYPE_ID_ERROR_CLASS
The basic type ID of Error type.
SPVM_NATIVE_C_BASIC_TYPE_ID_ERROR_SYSTEM_CLASS
The basic type ID of Error::System type.
SPVM_NATIVE_C_BASIC_TYPE_ID_ERROR_NOT_SUPPORTED_CLASS
The basic type ID of Error::NotSupported type.
SPVM_NATIVE_C_BASIC_TYPE_ID_ADDRESS_CLASS
The basic type ID of Address type.
Constant Values of Basic Type Categories
0 SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_UNKNOWN
1 SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_UNDEF
2 SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_VOID
3 SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_NUMERIC
4 SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_MULNUM
5 SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_STRING
6 SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_CLASS
7 SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_INTERFACE
8 SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_ANY_OBJECT
These IDs are permanently same for the binary compatibility after the future release v1.0
.
SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_UNKNOWN
The basic type category for unknown types.
SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_UNDEF
The basic type category for the undefined type.
SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_VOID
The basic type category for the void type.
SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_NUMERIC
The basic type category for the numeric types.
SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_MULNUM
The basic type category for the multi-numeric types.
SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_STRING
The basic type category for the string type.
SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_CLASS
The basic type category for the class types.
SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_INTERFACE
The basic type category for the interface types.
SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_ANY_OBJECT
The basic type category for the any object type.
Type Flags
1 SPVM_NATIVE_C_TYPE_FLAG_REF
2 SPVM_NATIVE_C_TYPE_FLAG_MUTABLE
The type flags.
Version
SPVM_NATIVE_VERSION_NUMBER
The version number of the SPVM language.
SPVM_NATIVE_VERSION_STRING
The version string of the SPVM language.
Utility Functions
spvm_warn
void spvm_warn(const char* format, ...)
Prints the formatted message to stderr
with a new line.
Examples:
spvm_warn("Hello");
spvm_warn("Hello %s%d", "Foo", 3);
Examples
Copyright & License
Copyright (c) 2023 Yuki Kimoto
MIT License