Name
SPVM::Document::NativeAPI - Native APIs
Description
The native APIs in SPVM are the APIs written by the C language for SPVM operations.
These APIs are available in native classes.
Native APIs
runtime
The runtime for this runtime environment.
Examples:
void* runtime = env->runtime;
api
SPVM_ENV_API* api;
Returns the SPVM_ENV_API
object. This object have the following member variables for other native APIs.
Examples:
SPVM_API_BASIC_TYPE* api_basic_type = env->api->basic_type;
new_env
SPVM_ENV* (*new_env)();
Creates a new runtime environment.
free_env
void (*free_env)(SPVM_ENV* env);
Frees an runtime environment.
call_init_methods
int32_t (*call_init_methods)(SPVM_ENV* env, SPVM_VALUE* stack);
Calls the INIT
blocks of all classes.
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 PROGRAM_NAME class variable in the CommandInfo class 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 ARGV class variable in the CommandInfo class 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 BASE_TIME class variable in the CommandInfo class to the base time.
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 the class variables of all classes.
args_width
int32_t (*args_width)(SPVM_ENV* env, SPVM_VALUE* stack);
Returns the width of the arguments given by the caller.
Examples:
int32_t args_width = env->args_width(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 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 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 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 object.
get_basic_type
void* (*get_basic_type)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name);
Searches a basic type given the basic type name basic_type_name.
If it is found, returns it, otherwise returns NULL
.
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);
Searches a basic type given the basic type name basic_type_name.
If it is found, returns it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an exception is thrown, error_id
is set to a 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);
Searches a basic type given the basic type ID basic_type_id.
If it is found, returns it, otherwise returns NULL
.
get_basic_type_id
int32_t (*get_basic_type_id)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name);
Searches a basic type given the basic type name basic_type_name.
If it is found, returns the basic type id of it, otherwise returns a negative value.
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);
Searches a basic type ID given the basic type name basic_type_name.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an exception is thrown, error_id
is set to a non-zero value. Otherwise it is set to 0.
get_class_var
void* (*get_class_var)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, const char* class_var_name);
Searches a class variable given the basic type name basic_type_name and the class variable name class_var_name.
If it is found, returns it, otherwise returns NULL
.
Examples:
void* class_var = env->get_class_var(env, stack, "MyClass", "$VAR");
get_class_var_byte
int8_t (*get_class_var_byte)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var);
Returns the value of the class variable class_var of the byte type.
get_class_var_short
int16_t (*get_class_var_short)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var);
Returns the value of the class variable class_var of the short type.
get_class_var_int
int32_t (*get_class_var_int)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var);
Returns the value of the class variable class_var of the int type.
get_class_var_long
int64_t (*get_class_var_long)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var);
Returns the value of the class variable class_var of the long type.
get_class_var_float
float (*get_class_var_float)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var);
Returns the value of the class variable class_var of the float type.
get_class_var_double
double (*get_class_var_double)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var);
Returns the value of the class variable class_var of the double type.
get_class_var_object
void* (*get_class_var_object)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var);
Returns the value of the class variable class_var of the object type.
get_class_var_strig
void* (*get_class_var_strig)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var);
Returns the value of the class variable class_var of the string type.
get_class_var_object_ref
void** (*get_class_var_object_ref)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var);
Returns the address of the value of the class variable class_var of the object type.
set_class_var_byte
void (*set_class_var_byte)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var, int8_t value);
Sets value to the class variable class_var of the byte type.
set_class_var_short
void (*set_class_var_short)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var, int16_t value);
Sets value to the class variable class_var of the short type.
set_class_var_int
void (*set_class_var_int)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var, int32_t value);
Sets value to the class variable class_var of the int type.
set_class_var_long
void (*set_class_var_long)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var, int64_t value);
Sets value to the class variable class_var of the long type.
set_class_var_float
void (*set_class_var_float)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var, float value);
Sets value to the class variable class_var of the float type.
set_class_var_double
void (*set_class_var_double)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var, double value);
Sets value to the class variable class_var of the double type.
set_class_var_object
void (*set_class_var_object)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var, void* value);
Sets value to the class variable class_var of the object type.
set_class_var_string
void (*set_class_var_string)(SPVM_ENV* env, SPVM_VALUE* stack, void* class_var, void* value);
Sets value to the class variable class_var of the string type.
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);
Searches a class variable given the basic type name basic_type_name and the class variable name class_var_name.
If it is found, interprets it as the byte type and returns its value, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
int8_t value = env->get_class_var_byte_by_name(env, stack, "TestCase::NativeAPI", "$BYTE_VALUE", &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a class variable given the basic type name basic_type_name and the class variable name class_var_name.
If it is found, interprets it as the short type and returns its value, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
int16_t value = env->get_class_var_short_by_name(env, stack, "TestCase::NativeAPI", "$SHORT_VALUE", &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a class variable given the basic type name basic_type_name and the class variable name class_var_name.
If it is found, interprets it as the int type and returns its value, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
int8_t value = env->get_class_var_int_by_name(env, stack, "TestCase::NativeAPI", "$BYTE_VALUE", &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a class variable given the basic type name basic_type_name and the class variable name class_var_name.
If it is found, interprets it as the long type and returns its value, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
int64_t value = env->get_class_var_long_by_name(env, stack, "TestCase::NativeAPI", "$LONG_VALUE", &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a class variable given the basic type name basic_type_name and the class variable name class_var_name.
If it is found, interprets it as the float type and returns its value, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
float value = env->get_class_var_float_by_name(env, stack, "TestCase::NativeAPI", "$FLOAT_VALUE", &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a class variable given the basic type name basic_type_name and the class variable name class_var_name.
If it is found, interprets it as the double type and returns its value, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
double value = env->get_class_var_double_by_name(env, stack, "TestCase::NativeAPI", "$DOUBLE_VALUE", &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a class variable given the basic type name basic_type_name and the class variable name class_var_name.
If it is found, interprets it as an object type and returns its value, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
void* value = env->get_class_var_object_by_name(env, stack, "TestCase::NativeAPI", "$MINIMAL_VALUE", &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
get_class_var_string_by_name
void* (*get_class_var_string_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);
Searches a class variable given the basic type name basic_type_name and the class variable name class_var_name.
If it is found, interprets it as the string type and returns its value, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
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);
Searches a class variable given the basic type name basic_type_name and the class variable name class_var_name.
If it is found, interprets it as the byte type and sets value to it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
env->set_class_var_byte_by_name(env, stack, "TestCase::NativeAPI", "$BYTE_VALUE", 15, &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a class variable class_var given the basic type name basic_type_name and the class variable name class_var_name.
If it is found, interprets it as the short type and sets value to it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
env->set_class_var_short_by_name(env, stack, "TestCase::NativeAPI", "$SHORT_VALUE", 15, &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a class variable class_var given the basic type name basic_type_name and the class variable name class_var_name.
If it is found, interprets it as the int type and sets value to it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
env->set_class_var_int_by_name(env, stack, "TestCase::NativeAPI", "$INT_VALUE", 15, &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
set_class_var_long_by_name
void (*set_class_var_long_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, 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);
Searches a class variable class_var given the basic type name basic_type_name and the class variable name class_var_name.
If it is found, interprets it as the long type and sets value to it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
env->set_class_var_long_by_name(env, stack, "TestCase::NativeAPI", "$LONG_VALUE", 15, &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a class variable class_var given the basic type name basic_type_name and the class variable name class_var_name.
If it is found, interprets it as the float type and sets value to it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
env->set_class_var_float_by_name(env, stack, "TestCase::NativeAPI", "$FLOAT_VALUE", 15, &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a class variable class_var given the basic type name basic_type_name and the class variable name class_var_name.
If it is found, interprets it as the double type and sets value to it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
env->set_class_var_double_by_name(env, stack, "TestCase::NativeAPI", "$DOUBLE_VALUE", 15, &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a class variable class_var given the basic type name basic_type_name and the class variable name class_var_name.
If it is found, interprets it as an object type and sets value to it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
env->set_class_var_object_by_name(env, stack, "TestCase::NativeAPI", "$MINIMAL_VALUE", minimal, &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
set_class_var_string_by_name
void (*set_class_var_string_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);
Searches a class variable class_var given the basic type name basic_type_name and the class variable name class_var_name.
If it is found, interprets it as the string type and sets value to it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
get_field
void* (*get_field_by_index)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, const char* field_name);
Searches a field object given the object object and the field name field_name.
If it is found, returns it, otherwise returns NULL
.
Examples:
void* field = env->get_field(env, stack, object, "x");
get_field_static
void* (*get_field_static)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, const char* field_name);
Searches a field object given the basic type name basic_type_name and the field name field_name.
If it is found, returns it, otherwise returns NULL
.
Examples:
void* field = env->get_field_static(env, stack, "Point", "x");
get_field_byte
int8_t (*get_field_byte)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field);
Returns the value of the field field of the byte type.
get_field_short
int16_t (*get_field_short)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field);
Returns the value of the field field of the short type.
get_field_int
int32_t (*get_field_int)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field);
Returns the value of the field field of the int type.
get_field_long
int64_t (*get_field_long)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field);
Returns the value of the field field of the long type.
get_field_float
float (*get_field_float)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field);
Returns the value of the field field of the float type.
get_field_double
double (*get_field_double)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field);
Returns the value of the field field of the double type.
get_field_object
void* (*get_field_object)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field);
Returns the value of the field field of the object type.
get_field_string
void* (*get_field_string)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field);
Returns the value of the field field of the string type.
set_field_byte
void (*set_field_byte)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field, int8_t value);
Sets value to the field field of the byte type.
set_field_short
void (*set_field_short)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field, int16_t value);
Sets value to the field field of the short type.
set_field_int
void (*set_field_int)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field, int32_t value);
Sets value to the field field of the int type.
set_field_long
void (*set_field_long)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field, int64_t value);
Sets value to the field field of the long type.
set_field_float
void (*set_field_float)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field, float value);
Sets value to the field field of the float type.
set_field_double
void (*set_field_double)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field, double value);
Sets value to the field field of the double type.
set_field_object
void (*set_field_object)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field, void* value);
Sets value to the field field of the object type.
set_field_string
void (*set_field_string)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field, void* value);
Sets value to the field field of the string type.
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);
Searches a field field given the object object and the field name field_name.
If it is found, interprets it as the byte type and returns the value of it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
int8_t byte_value = env->get_field_byte_by_name(env, stack, object, "byte_value", &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a field field given the object object and the field name field_name.
If it is found, interprets it as the short type and returns the value of it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
int8_t short_value = env->get_field_short_by_name(env, stack, object, "short_value", &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a field field given the object object and the field name field_name.
If it is found, interprets it as the int type and returns the value of it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
int8_t int_value = env->get_field_int_by_name(env, stack, object, "int_value", &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a field field given the object object and the field name field_name.
If it is found, interprets it as the long type and returns the value of it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
int8_t long_value = env->get_field_long_by_name(env, stack, object, "long_value", &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a field field given the object object and the field name field_name.
If it is found, interprets it as the float type and returns the value of it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
int8_t float_value = env->get_field_float_by_name(env, stack, object, "float_value", &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a field field given the object object and the field name field_name.
If it is found, interprets it as the double type and returns the value of it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
int8_t double_value = env->get_field_double_by_name(env, stack, object, "double_value", &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a field field given the object object and the field name field_name.
If it is found, interprets it as an object type and returns the value of it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
void* object_minimal = env->get_field_object_by_name(env, stack, object_simple, "object_value", &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
get_field_string_by_name
void* (*get_field_string_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);
Searches a field field given the object object and the field name field_name.
If it is found, interprets it as the string type and returns the value of it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
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);
Searches a field field given the object object and the field name field_name.
If it is found, interprets it as the byte type and sets value to it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
env->set_field_byte_by_name(env, stack, object, "byte_value", 13, &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a field field given the object object and the field name field_name.
If it is found, interprets it as the short type and sets value to it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
env->set_field_short_by_name(env, stack, object, "short_value", 13, &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a field field given the object object and the field name field_name.
If it is found, interprets it as the int type and sets value to it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
env->set_field_int_by_name(env, stack, object, "int_value", 13, &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a field field given the object object and the field name field_name.
If it is found, interprets it as the long type and sets value to it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
env->set_field_long_by_name(env, stack, object, "long_value", 13, &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a field field given the object object and the field name field_name.
If it is found, interprets it as the float type and sets value to it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
env->set_field_float_by_name(env, stack, object, "float_value", 13, &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a field field given the object object and the field name field_name.
If it is found, interprets it as the double type and sets value to it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
env->set_field_double_by_name(env, stack, object, "double_value", 13, &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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);
Searches a field field given the object object and the field name field_name.
If it is found, interprets it as an object type and sets value to it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
Examples:
int32_t error_id = 0;
env->set_field_object_by_name(env, stack, object_simple, "object_value", object_minimal, &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
set_field_string_by_name
void (*set_field_string_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);
Searches a field field given the object object and the field name field_name.
If it is found, interprets it as the string type and sets value to it, otherwise an exception is thrown.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
get_method
void* (*get_method)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, const char* method_name);
Searches a method given the basic type name basic_type_name and the method name method_name.
If it is found, returns it, otherwise returns NULL
.
Examples:
void* method = env->get_method(env, stack, "Foo", "get");
get_class_method
void* (*get_class_method)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, const char* method_name);
Searches a class method given the basic type name basic_type_name and the method name method_name.
If it is found, returns it, otherwise 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);
Searches an instance method given the object object and the method name method_name.
If it is found, returns it, otherwise returns NULL
.
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 given the basic type basic_type.
If its memory allocation failed, returns NULL
.
This native API should not be used unless special purposes are intended. Use "new_object" instead.
new_object
void* (*new_object)(SPVM_ENV* env, SPVM_VALUE* stack, void* basic_type);
Calls new_object_no_mortal
and add its return value to the mortal stack, and returns it.
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 given the length length.
If its memory allocation failed, returns NULL
.
This native API should not be used unless special purposes are intended. Use "new_byte_array" instead.
new_byte_array
void* (*new_byte_array)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
Calls "new_byte_array_no_mortal" and add its return value to the mortal stack, and returns it.
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 given the length length.
If its memory allocation failed, returns NULL
.
This native API should not be used unless special purposes are intended. Use "new_short_array" instead.
new_short_array
void* (*new_short_array)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
Calls "new_short_array_no_mortal" and add its return value to the mortal stack, and returns it.
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 given the length length.
If its memory allocation failed, returns NULL
.
This native API should not be used unless special purposes are intended. Use "new_int_array" instead.
new_int_array
void* (*new_int_array)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
Calls "new_int_array_no_mortal" and add its return value to the mortal stack, and returns it.
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 given the length length.
If its memory allocation failed, returns NULL
.
This native API should not be used unless special purposes are intended. Use "new_long_array" instead.
new_long_array
void* (*new_long_array)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
Calls "new_long_array_no_mortal" and add its return value to the mortal stack, and returns it.
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 given the length length.
If its memory allocation failed, returns NULL
.
This native API should not be used unless special purposes are intended. Use "new_float_array" instead.
new_float_array
void* (*new_float_array)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
Calls "new_float_array_no_mortal" and add its return value to the mortal stack, and returns it.
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 given the length length.
If its memory allocation failed, returns NULL
.
This native API should not be used unless special purposes are intended. Use "new_double_array" instead.
new_double_array
void* (*new_double_array)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
Calls "new_double_array_no_mortal" and add its return value to the mortal stack, and returns it.
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 given the basic type basic_type and the array length length.
If its memory allocation failed, returns NULL
.
This native API should not be used unless special purposes are intended. Use "new_object_array" instead.
new_object_array
void* (*new_object_array)(SPVM_ENV* env, SPVM_VALUE* stack, void* basic_type, int32_t length);
Calls "new_object_array_no_mortal" and add its return value to the mortal stack, and returns it.
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 given the basic type basic_type, the type dimension type_dimension, and the array length length.
If its memory allocation failed, returns NULL
.
type_dimension must be less than or equals to 255.
This native API should not be used unless special purposes are intended. Use "new_muldim_array" instead.
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);
Calls "new_muldim_array_no_mortal" and add its return value to the mortal stack, and returns it.
Examples:
// Creates 2-dimensional array - 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 given the basic type basic_type and the array length length.
If its memory allocation failed, returns NULL
.
This native API should not be used unless special purposes are intended. Use "new_mulnum_array" instead.
new_mulnum_array
void* (*new_mulnum_array)(SPVM_ENV* env, SPVM_VALUE* stack, void* basic_type, int32_t length);
Calls "new_mulnum_array_no_mortal" and add its return value to the mortal stack, and returns it.
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 given a C string bytes. bytes must end with "\0".
If its memory allocation failed, returns NULL
.
This native API should not be used unless special purposes are intended. Use "new_string_nolen" instead.
new_string_nolen
void* (*new_string_nolen)(SPVM_ENV* env, SPVM_VALUE* stack, const char* bytes);
Calls "new_string_nolen_no_mortal" and add its return value to the mortal stack, and returns it.
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 given the C string bytes and the length length.
If its memory allocation failed, returns NULL
.
If the length of bytes is lower than length or bytes is NULL, The part that longer than the length of bytes is filled with \0
.
This native API should not be used unless special purposes are intended. Use "new_string" instead.
new_string
void* (*new_string)(SPVM_ENV* env, SPVM_VALUE* stack, const char* bytes, int32_t length);
Calls "new_string_no_mortal" and add its return value to the mortal stack, and returns it.
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);
Creates a new string concating two strings string1 and string2, and returns it.
If its memory allocation failed, returns NULL
.
This native API should not be used unless special purposes are intended. Use "concat" instead.
concat
void* (*concat)(SPVM_ENV* env, SPVM_VALUE* stack, void* string1, void* string2);
Calls "concat_no_mortal" and add its return value to the mortal stack, and returns it.
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 new string adding a string line of a stack trace given the file file and the line line to the end of the exception exception, and returns it.
If its memory allocation failed, returns NULL
.
exception is a SPVM string. The return value is a SPVM string.
This native API should not be used unless special purposes are intended. Use "new_stack_trace" instead.
new_stack_trace
void* (*new_stack_trace)(SPVM_ENV* env, SPVM_VALUE* stack, void* exception, void* method, int32_t line);
Calls "new_stack_trace_no_mortal" and add its return value to the mortal stack, and returns it.
length
int32_t (*length)(SPVM_ENV*, void* array);
Returns the length of the array array.
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);
Returns the pointer to the array elements for a byte array.
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);
Returns the pointer to the array elements for a short array.
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);
Returns the pointer to the array elements for an int array.
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);
Returns the pointer to the array elements for a long array.
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);
Returns the pointer to the array elements for a float array.
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);
Returns the pointer to the array elements for a double array.
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);
Returns the element given the array array and the index index.
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);
Sets object to the element given the array array and the index index.
If this element is a weak reference, the weak reference is removed.
Examples:
env->get_elem_object(env, stack, array, 3, object);
get_pointer
void* (*get_pointer)(SPVM_ENV* env, SPVM_VALUE* stack, void* pointer_object);
Returns the pointer to a native data stored in the object pointer_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);
Set pointer to the pointer to a native data stored in the object pointer_object.
call_method_no_mortal
int32_t (*call_method_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, void* method, int32_t args_width);
Calls the method method given the width of the argument args_width.
If the method throws an exception, returns a basic type ID of an error class, otherwise returns 0.
The return value of the method is set to stack[0].
This native API should not be used unless special purposes are intended. Use "call_method" instead.
get_exception
void* (*get_exception)(SPVM_ENV* env, SPVM_VALUE* stack);
Returns the current exception message.
The return value is a SVPM string.
set_exception
void (*set_exception)(SPVM_ENV* env, SPVM_VALUE* stack, void* exception);
Sets exception to the current exception message.
exception is a SPVM string.
enter_scope
int32_t (*enter_scope)(SPVM_ENV* env, SPVM_VALUE* stack);
Performs an enterring scope operation and returns the top position of the mortal stack. This value is used as an argument to the "leave_scope" native API.
push_mortal
int32_t (*push_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
Pushes the object object to the mortal stack.
If object is NULL, nothing is performed.
If successful, returns 0, otherwise returns a non-zero value.
leave_scope
void (*leave_scope)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t mortal_stack_top);
Performs a leaving scope operation given the top position of the mortal stack mortal_stack_top.
mortal_stack_top is the return value of the "enter_scope" native API.
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 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 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 object is a object array, returns 1, otherwise returns 0.
If the object object is NULL
, returns 0.
weaken
int32_t (*weaken)(SPVM_ENV* env, SPVM_VALUE* stack, void** ref);
Weakens the reference ref
.
isweak
int32_t (*isweak()SPVM_ENV* env, void** ref);
Checks if the reference ref
is weakend. If so, returns 1, otherwise, returns 0.
unweaken
void (*unweaken)(SPVM_ENV* env, SPVM_VALUE* stack, void** ref);
Unweakens the reference ref
.
get_type_name_no_mortal
void* (*get_type_name_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
Creates a new string that is the type name of the object object.
If its memory allocation failed, returns NULL
.
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);
Returns a new string
object that is the type name of the object object.
get_chars
const char* (*get_chars)(SPVM_ENV* env, SPVM_VALUE* stack, void* string_object);
Returns 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.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an exception is thrown, error_id
is set to a non-zero value. Otherwise it is set to 0.
Examples:
int32_t error_id = 0;
void* minimal = env->new_object_by_name(env, stack, "TestCase::Minimal", &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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 args_width, 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.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
Examples:
int32_t error_id = 0;
int32_t output;
{
int32_t args_width = 1;
stack[0].ival = 5;
env->call_class_method_by_name(env, stack, "TestCase::NativeAPI", "my_value", args_width, &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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 args_width, int32_t* error_id, const char* func_name, const char* file, int32_t line);
Calls an instance method given the method name.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an exception is thrown, error_id
is set to a non-zero value. Otherwise it is set to 0.
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);
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an exception is thrown, error_id
is set to a non-zero value. Otherwise it is set to 0.
dump_no_mortal
void* (*dump_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
Returns the string which dump the object object. The string is the same as the return value of dump
operator.
dump
void* (*dump)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
Calls "dump_no_mortal" and add its return value to the mortal stack, and returns it.
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 the basic type name basic_type_name and the method name 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);
Returns 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 object is an array, returns 1, otherwise returns 0.
If the object object is NULL
, returns 0.
is_string
int32_t (*is_string)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
If the object object is a string, returns 1, otherwise returns 0.
If the object object is NULL
, returns 0.
is_numeric_array
int32_t (*is_numeric_array)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
If the object object is a numeric array, returns 1, otherwise returns 0.
If the object object is NULL
, returns 0.
is_mulnum_array
int32_t (*is_mulnum_array)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
If the object object is a multi numeric array, returns 1, otherwise returns 0.
If the object object is NULL
, returns 0.
get_elem_size
int32_t (*get_elem_size)(SPVM_ENV* env, SPVM_VALUE* stack, void* array);
Returns 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 object. The type of the object 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 to the length 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 a string to stdout. This is the same operator as the print operator.
print_stderr
void (*print_stderr)(SPVM_ENV* env, SPVM_VALUE* stack, void* string);
Prints a string to stderr. This is the same operator as the print operator except for the destination of the output.
new_stack
SPVM_VALUE* (*new_stack)(SPVM_ENV* env);
free_stack
void (*free_stack)(SPVM_ENV* env, SPVM_VALUE* stack);
new_memory_block
void* (*new_memory_block)(SPVM_ENV* env, SPVM_VALUE* stack, size_t size);
Creates a new memory block given the byte size size and returns its address.
If size is 0, retunrs NULL
.
If size is greater than SIZE_MAX
defined in the sysmte, returns NULL
.
If the system memory allocation function returns NULL
, this native API returns NULL
.
The count of the memory blocks managed by this runtime is incremented by 1.
free_memory_block
void (*free_memory_block)(SPVM_ENV* env, SPVM_VALUE* stack, void* block);
Frees the memory block block.
If block is NULL
, nothing is performed.
The count of the memory blocks managed by this runtime is decremented by 1.
get_memory_blocks_count
int32_t (*get_memory_blocks_count)(SPVM_ENV* env, SPVM_VALUE* stack);
Returns the count of the memory blocks managed by this runtime.
strerror_string
void* (*strerror_string)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t errno_value, int32_t length);
Calls the "strerror" function and add its return value to the mortal stack, and returns it.
strerror_string_nolen
void* (*strerror_string_nolen)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t errno_value);
Calls the "strerror_string" function given length 0, and returns its return value.
strerror
const char* (*strerror)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t errno_value, int32_t length);
Returns the return value of the strerror function in the C language.
If the length is 0, the length is set to 128.
If the strerror
function failed, errno
is set to the an appropriate positive value.
This function is thread-safe.
This function actually is implemented by the following functions:
Windows:
errno_t strerror_s(char *buffer, size_t sizeInBytes, int errnum);
Other OSs:
int strerror_r(int errnum, char *buf, size_t buflen); /* XSI-compliant */
strerror_nolen
const char* (*strerror_nolen)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t errno_value);
Calls the "strerror" function given length 0, and returns its return value.
new_string_array
void* (*new_string_array)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
Calls the "new_string_array_no_mortal" native API and calls the "push_mortal/" native API given the return value.
new_string_array_no_mortal
void* (*new_string_array_no_mortal)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t length);
Creates a new string array.
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, env->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 given the basic type basic_type and a C language pointer pointer.
new_pointer_object
void* (*new_pointer_object)(SPVM_ENV* env, SPVM_VALUE* stack, void* basic_type, void* pointer);
Calls "new_pointer_no_mortal" and add its return value to the mortal stack, and returns it.
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.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an exception is thrown, error_id
is set to a non-zero value. Otherwise it is set to 0.
int32_t error_id = 0;
void* minimal = env->new_pointer_by_name(env, stack, "TestCase::Pointer", pointer, &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
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 object is an instance of a class, returns 1, otherwise returns 0.
If the object object is NULL
, returns 0.
is_pointer_class
int32_t (*is_pointer_class)(SPVM_ENV* env, SPVM_VALUE* stack, void* object);
If the object object is an instance of a pointer class, returns 1, otherwise returns 0.
If the object object is NULL
, returns 0.
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 args_width, int32_t* error_id, const char* func_name, const char* file, int32_t line);
Calls an instance method by the basic type name basic_type_name and the method name method_name.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an exception is thrown, error_id
is set to a non-zero value. Otherwise it is set to 0.
Examples:
int32_t error_id = 0;
int32_t output;
{
int32_t args_width = 1;
stack[0].oval = obj_point;
env->call_instance_method_static_by_name(env, stack, "Point", "x", args_width, &error_id, __func__, __FILE__, __LINE__);
if (error_id) { return error_id; }
output = stack[0].ival;
}
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);
Returns a new string
object that is the compile-time type name given the basic type name 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);
Returns a new string
object that is the compile-time type name given the basic type name basic_type_name, a type dimension, a type flag.
get_spvm_version_string
const char* (*get_spvm_version_string)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime 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)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<void* basic_type|SPVM::Document::NativeAPI::BasicType>);
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 args_width);
Calls "call_method_no_mortal" and if the type of the its return value is an object type, it is added to the mortal stack, and returns it.
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_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_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_by_name
void* (*new_mulnum_array_by_name)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name, int32_t length);
get_field_object_defined_and_has_pointer_by_name
void* (*get_field_object_defined_and_has_pointer_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);
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an exception is thrown, error_id
is set to a non-zero value. Otherwise it is set to 0.
get_field_object_ref
void** (*get_field_object_ref)(SPVM_ENV* env, SPVM_VALUE* stack, void* object, void* field);
Returns the address of the value of the field field of the object type.
get_field_object_ref_by_name
void** (*get_field_object_ref_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);
Returns the address of the value of the field field of the object type given the object object and the field name field_name.
The function name func_name, the file path file, and the line number line must be given for the information of the exception stack trace.
If an excetpion is thrown, the value referenced by error_id
is set to a non-zero value, otherwise set to 0.
check_stack_env
int32_t (*check_stack_env)(SPVM_ENV* env, SPVM_VALUE* stack);
If the env of the stack is equal to the env, returns 1. Otherwise returns 0.
assign_object
void (*assign_object)(SPVM_ENV* env, SPVM_VALUE* stack, void** ref, void* object);
Assigns an object object
to the place referred by the reference ref
.
say
void (*say)(SPVM_ENV* env, SPVM_VALUE* stack, void* string);
Prints a string and \n
to stdout. This is the same operator as the say operator.
warn
void (*warn)(SPVM_ENV* env, SPVM_VALUE* stack, void* string, const char* file, int32_t line);
Operates the warn operator.
spvm_stdin
FILE* (*spvm_stdin)(SPVM_ENV* env, SPVM_VALUE* stack);
Returns the standard input opened for SPVM.
spvm_stdout
FILE* (*spvm_stdout)(SPVM_ENV* env, SPVM_VALUE* stack);
Returns the standard output opened for SPVM.
spvm_stderr
FILE* (*spvm_stderr)(SPVM_ENV* env, SPVM_VALUE* stack);
Returns the standard error opened for SPVM.
check_bootstrap_method
int32_t (*check_bootstrap_method)(SPVM_ENV* env, SPVM_VALUE* stack, const char* basic_type_name);
Checks the definition of the bootstrap method.
If it is invalid, return non-zero, otherwise return 0.
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 args_width,
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_ref,
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 weaken,
188 isweak,
189 unweaken,
190 strerror_string,
191 strerror_string_nolen,
192 strerror,
193 strerror_nolen,
194 reserved194,
195 reserved195,
196 new_stack,
197 free_stack,
198 get_field_object_defined_and_has_pointer_by_name,
199 get_field_object_ref,
200 get_field_object_ref_by_name,
201 check_stack_env,
202 assign_object,
203 new_string_array_no_mortal,
204 new_memory_block,
205 free_memory_block,
206 get_memory_blocks_count,
207 say,
208 warn,
209 spvm_stdin,
210 spvm_stdout,
211 spvm_stderr,
212 check_bootstrap_method
Constant Values
Basic Type IDs
ID | Name | Description |
---|---|---|
0 | SPVM_NATIVE_C_BASIC_TYPE_ID_UNKNOWN | The basic type ID for unknown types |
1 | SPVM_NATIVE_C_BASIC_TYPE_ID_UNDEF | The basic type ID of the undef type |
2 | SPVM_NATIVE_C_BASIC_TYPE_ID_VOID | The basic type ID of the void type |
3 | SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE | The basic type ID of the byte type |
4 | SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT | The basic type ID of the short type |
5 | SPVM_NATIVE_C_BASIC_TYPE_ID_INT | The basic type ID of the int type |
6 | SPVM_NATIVE_C_BASIC_TYPE_ID_LONG | The basic type ID of the long type |
7 | SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT | The basic type ID of the float type |
8 | SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE | The basic type ID of the double type |
9 | SPVM_NATIVE_C_BASIC_TYPE_ID_STRING | The basic type ID of the string type |
10 | SPVM_NATIVE_C_BASIC_TYPE_ID_ANY_OBJECT | The basic type ID of the any object type |
11 | SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE_CLASS | The basic type ID of the Byte class |
12 | SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT_CLASS | The basic type ID of the Short class |
13 | SPVM_NATIVE_C_BASIC_TYPE_ID_INT_CLASS | The basic type ID of the Int class |
14 | SPVM_NATIVE_C_BASIC_TYPE_ID_LONG_CLASS | The basic type ID of the Long class |
15 | SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT_CLASS | The basic type ID of the Float class |
16 | SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE_CLASS | The basic type ID of the Double class |
17 | SPVM_NATIVE_C_BASIC_TYPE_ID_BOOL_CLASS | The basic type ID of the Bool class |
18 | SPVM_NATIVE_C_BASIC_TYPE_ID_ERROR_CLASS | The basic type ID of the Error class |
19 | SPVM_NATIVE_C_BASIC_TYPE_ID_ERROR_SYSTEM_CLASS | The basic type ID of the Error::System class |
20 | SPVM_NATIVE_C_BASIC_TYPE_ID_ERROR_NOT_SUPPORTED_CLASS | The basic type ID of the Error::NotSupported class |
21 | SPVM_NATIVE_C_BASIC_TYPE_ID_COMMAND_INFO_CLASS | The basic type ID of the CommandInfo class |
22 | SPVM_NATIVE_C_BASIC_TYPE_ID_ADDRESS_CLASS | The basic type ID of the Address class |
23 | SPVM_NATIVE_C_BASIC_TYPE_ID_ERROR_COMPILE_CLASS | The basic type ID of the Error::Compile class |
Basic Type Category IDs
ID | Name | Description |
---|---|---|
0 | SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_UNKNOWN | The basic type category for unknown types |
1 | SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_UNDEF | The basic type category for the undef type |
2 | SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_VOID | The basic type category for the void type |
3 | SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_NUMERIC | The basic type category for numeric types |
4 | SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_MULNUM | The basic type category for multi-numeric types |
5 | SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_STRING | The basic type category for the string type |
6 | SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_CLASS | The basic type category for class types |
7 | SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_INTERFACE | The basic type category for interface types |
8 | SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_ANY_OBJECT | The basic type category for the any object type |
Type Flag IDs
ID | Name | Description |
---|---|---|
1 | SPVM_NATIVE_C_TYPE_FLAG_REF | A flag indicating that it is a reference type |
2 | SPVM_NATIVE_C_TYPE_FLAG_MUTABLE | A flag indicating that a mutable modifier is present |
SPVM_NATIVE_VERSION_NUMBER
The version number of the SPVM language.
Examples:
// 0.989062
double spvm_version_number = SPVM_NATIVE_VERSION_NUMBER;
SPVM_NATIVE_VERSION_STRING
The version string of the SPVM language. This is a string constant.
Examples:
// "0.989062"
const char* spvm_version_string = SPVM_NATIVE_VERSION_STRING;
Macro Functions
spvm_warn
#define spvm_warn(format, ...)
Prints the formatted message format to stderr
with a new line.
format must be the char*
type.
Examples:
spvm_warn("Hello");
spvm_warn("Hello %s%d", "Foo", 3);
spvm_warnf
#define spvm_warnf(stream, format, ...)
Prints the formatted message format to the stream stream with a new line.
format must be the char*
type.
stream must be the FILE
type.
Examples:
spvm_warnf(env->spvm_stderr(env, stack), "Hello");
spvm_warnf(env->spvm_stderr(env, stack), "Hello %s%d", "Foo", 3);
SPVM_NATIVE_GET_POINTER
#define SPVM_NATIVE_GET_POINTER(object)
Returns the pointer stored in the object object and returns it. The return type is the void* type.
SPVM_NATIVE_SET_POINTER
#define SPVM_NATIVE_SET_POINTER(object, pointer)
Sets the pointer pointer in the object object.
Examples
See Also
Copyright & License
Copyright (c) 2023 Yuki Kimoto
MIT License