| 1 | =head1 Name | ||
| 2 | |||
| 3 | SPVM::Document::NativeAPI - Native APIs | ||
| 4 | |||
| 5 | =head1 Description | ||
| 6 | |||
| 7 | The native APIs in L<SPVM> are the APIs written by the C language for SPVM operations. | ||
| 8 | |||
| 9 | These APIs are available in L<native classes|SPVM::Document::NativeClass>. | ||
| 10 | |||
| 11 | =head1 Native APIs | ||
| 12 | |||
| 13 | =head2 runtime | ||
| 14 | |||
| 15 | L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>; | ||
| 16 | |||
| 17 | The runtime for this L<runtime environment|SPVM::Document::NativeClass/"Runtime Environment">. | ||
| 18 | |||
| 19 | Examples: | ||
| 20 | |||
| 21 | SPVM_NATIVE_RUNTIME* runtime = env->runtime; | ||
| 22 | |||
| 23 | =head2 api | ||
| 24 | |||
| 25 | C<SPVM_ENV_API* api;> | ||
| 26 | |||
| 27 | Returns C<SPVM_ENV_API> object. This object have the following fields for other native APIs. | ||
| 28 | |||
| 29 | =over 2 | ||
| 30 | |||
| 31 | =item * L<SPVM_API_ALLOCATOR* allocator|SPVM::Document::NativeAPI::Allocator> | ||
| 32 | |||
| 33 | =item * L<SPVM_API_STRING_BUFFER* string_buffer|SPVM::Document::NativeAPI::StringBuffer> | ||
| 34 | |||
| 35 | =item * L<SPVM_API_COMPILER* compiler|SPVM::Document::NativeAPI::Compiler> | ||
| 36 | |||
| 37 | =item * L<SPVM_API_CLASS_FILE* class_file|SPVM::Document::NativeAPI::ClassFile> | ||
| 38 | |||
| 39 | =item * L<SPVM_API_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime> | ||
| 40 | |||
| 41 | =item * L<SPVM_API_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType> | ||
| 42 | |||
| 43 | =item * L<SPVM_API_CLASS_VAR* class_var|SPVM::Document::NativeAPI::ClassVariable> | ||
| 44 | |||
| 45 | =item * L<SPVM_API_FIELD* field|SPVM::Document::NativeAPI::Field> | ||
| 46 | |||
| 47 | =item * L<SPVM_API_METHOD* method|SPVM::Document::NativeAPI::Method> | ||
| 48 | |||
| 49 | =item * L<SPVM_API_ARG* arg|SPVM::Document::NativeAPI::Argument> | ||
| 50 | |||
| 51 | =item * L<SPVM_API_TYPE* type|SPVM::Document::NativeAPI::Type> | ||
| 52 | |||
| 53 | =item * L<SPVM_API_MUTEX* mutex|SPVM::Document::NativeAPI::Mutex> | ||
| 54 | |||
| 55 | =item * L<SPVM_API_CFUNC* internal|SPVM::Document::NativeAPI::CFunction.> | ||
| 56 | |||
| 57 | =item * L<SPVM_API_INTERNAL* internal|SPVM::Document::NativeAPI::Internal> | ||
| 58 | |||
| 59 | =back | ||
| 60 | |||
| 61 | Examples: | ||
| 62 | |||
| 63 | SPVM_API_BASIC_TYPE* api_basic_type = env->api->basic_type; | ||
| 64 | |||
| 65 | =head2 new_env | ||
| 66 | |||
| 67 | C<SPVM_ENV* (*new_env)();> | ||
| 68 | |||
| 69 | Creates a new L<runtime environment|SPVM::Document::NativeClass/"Runtime Environment">. | ||
| 70 | |||
| 71 | This native API should not be used unless special purposes are intended. | ||
| 72 | |||
| 73 | =head2 free_env | ||
| 74 | |||
| 75 | C<void (*free_env)(SPVM_ENV* env);> | ||
| 76 | |||
| 77 | Frees the L<runtime environment|SPVM::Document::NativeClass/"Runtime Environment"> I<env>. | ||
| 78 | |||
| 79 | This native API should not be used unless special purposes are intended. | ||
| 80 | |||
| 81 | =head2 call_init_methods | ||
| 82 | |||
| 83 | C<int32_t (*call_init_methods)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 84 | |||
| 85 | Calls the consolidated C<INIT> method for each class. | ||
| 86 | |||
| 87 | All C<INIT> blocks in a class are merged into a single C<INIT> method at compile time. This native API calls these methods for all classes that have them. | ||
| 88 | |||
| 89 | If an exception is thrown, returns a non-zero value. Otherwise, returns 0. | ||
| 90 | |||
| 91 | This native API should not be used unless special purposes are intended. | ||
| 92 | |||
| 93 | =head2 set_command_info_program_name | ||
| 94 | |||
| 95 | C<int32_t (*set_command_info_program_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* obj_program_name);> | ||
| 96 | |||
| 97 | Sets the program name I<obj_program_name> to L<CommandInfo#PROGRAM_NAME|SPVM::CommandInfo/"PROGRAM_NAME"> class variable. | ||
| 98 | |||
| 99 | If an exception is thrown, returns a non-zero value. Otherwise, returns 0. | ||
| 100 | |||
| 101 | This native API should not be used unless special purposes are intended. | ||
| 102 | |||
| 103 | =head2 call_end_methods | ||
| 104 | |||
| 105 | C<int32_t (*call_end_methods)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 106 | |||
| 107 | Calls the consolidated C<END> method for each class. | ||
| 108 | |||
| 109 | All C<END> blocks in a class are merged into a single C<END> method in reverse order (LIFO) at compile time. This native API calls these methods for all classes that have them. | ||
| 110 | |||
| 111 | If an exception is thrown in an C<END> method, it is converted to a warning message and printed to C<stderr>, and the execution continues for the remaining classes. | ||
| 112 | |||
| 113 | This method always returns 0 because all exceptions are caught internally. | ||
| 114 | |||
| 115 | This native API should not be used unless special purposes are intended. | ||
| 116 | |||
| 117 | =head2 set_command_info_argv | ||
| 118 | |||
| 119 | C<int32_t (*set_command_info_argv)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* obj_argv);> | ||
| 120 | |||
| 121 | Sets the command line arguments I<obj_argv> to L<CommandInfo#ARGV|SPVM::CommandInfo/"ARGV"> class variable. | ||
| 122 | |||
| 123 | If an exception is thrown, returns a non-zero value. Otherwise, returns 0. | ||
| 124 | |||
| 125 | This native API should not be used unless special purposes are intended. | ||
| 126 | |||
| 127 | =head2 set_command_info_basetime | ||
| 128 | |||
| 129 | C<int32_t (*set_command_info_basetime)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int64_t base_time);> | ||
| 130 | |||
| 131 | Sets the base time I<base_time> to L<CommandInfo#BASE_TIME|SPVM::CommandInfo/"BASE_TIME"> class variable. | ||
| 132 | |||
| 133 | If an exception is thrown, returns a non-zero value. Otherwise, returns 0. | ||
| 134 | |||
| 135 | This native API should not be used unless special purposes are intended. | ||
| 136 | |||
| 137 | =head2 destroy_class_vars | ||
| 138 | |||
| 139 | C<void (*destroy_class_vars)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 140 | |||
| 141 | Sets all class variables of all classes that is a object type to undef. | ||
| 142 | |||
| 143 | This native API should not be used unless special purposes are intended. | ||
| 144 | |||
| 145 | =head2 args_width | ||
| 146 | |||
| 147 | C<int32_t (*args_width)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 148 | |||
| 149 | Returns the L<width of the arguments|SPVM::Document::NativeClass/"Arguments Width"> given by the caller. | ||
| 150 | |||
| 151 | Examples: | ||
| 152 | |||
| 153 | int32_t args_width = env->args_width(env, stack); | ||
| 154 | |||
| 155 | =head2 get_object_basic_type | ||
| 156 | |||
| 157 | C<SPVM_NATIVE_BASIC_TYPE* (*get_object_basic_type)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 158 | |||
| 159 | Returns the L<basic type|SPVM::Document::NativeAPI::BasicType> of the object I<object>. | ||
| 160 | |||
| 161 | =head2 get_object_basic_type_id | ||
| 162 | |||
| 163 | C<int32_t (*get_object_basic_type_id)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 164 | |||
| 165 | Returns the basic type ID of the object I<object>. | ||
| 166 | |||
| 167 | =head2 get_object_basic_type_name | ||
| 168 | |||
| 169 | C<const char* (*get_object_basic_type_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 170 | |||
| 171 | Returns the basic type name of the object I<object>. | ||
| 172 | |||
| 173 | =head2 get_object_type_dimension | ||
| 174 | |||
| 175 | C<int32_t (*get_object_type_dimension)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 176 | |||
| 177 | Returns the type dimension of the object I<object>. | ||
| 178 | |||
| 179 | =head2 get_basic_type | ||
| 180 | |||
| 181 | C<SPVM_NATIVE_BASIC_TYPE* (*get_basic_type)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name);> | ||
| 182 | |||
| 183 | Searches a L<basic type|SPVM::Document::NativeAPI::BasicType> given the basic type name I<basic_type_name>. | ||
| 184 | |||
| 185 | If it is found, returns it. Otherwise, returns C<NULL>. | ||
| 186 | |||
| 187 | =head2 get_basic_type_by_name | ||
| 188 | |||
| 189 | C<SPVM_NATIVE_BASIC_TYPE* (*get_basic_type_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 190 | |||
| 191 | Searches a L<basic type|SPVM::Document::NativeAPI::BasicType> given the basic type name I<basic_type_name>. | ||
| 192 | |||
| 193 | If it is found, returns it. Otherwise, an exception is thrown. | ||
| 194 | |||
| 195 | The function name I<func_name>, the file path I<file>, and the line number I<line> must be given for the exception stack trace. | ||
| 196 | |||
| 197 | If the basic type given by I<basic_type_name> is not found, an exception is thrown. | ||
| 198 | |||
| 199 | If an exception is thrown, C<error_id> is set to a non-zero value. Otherwise, it is set to 0. | ||
| 200 | |||
| 201 | =head2 get_basic_type_by_id | ||
| 202 | |||
| 203 | C<SPVM_NATIVE_BASIC_TYPE* (*get_basic_type_by_id)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t basic_type_id);> | ||
| 204 | |||
| 205 | Searches a L<basic type|SPVM::Document::NativeAPI::BasicType> given the basic type ID I<basic_type_id>. | ||
| 206 | |||
| 207 | If it is found, returns it. Otherwise, returns C<NULL>. | ||
| 208 | |||
| 209 | =head2 get_basic_type_id | ||
| 210 | |||
| 211 | C<int32_t (*get_basic_type_id)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name);> | ||
| 212 | |||
| 213 | Searches a basic type given the basic type name I<basic_type_name>. | ||
| 214 | |||
| 215 | If it is found, returns the basic type id of it. Otherwise, returns a negative value. | ||
| 216 | |||
| 217 | Examples: | ||
| 218 | |||
| 219 | int32_t basic_type_id = env->get_basic_type_id(env, stack, "Int"); | ||
| 220 | |||
| 221 | =head2 get_basic_type_id_by_name | ||
| 222 | |||
| 223 | C<int32_t (*get_basic_type_id_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 224 | |||
| 225 | Searches a basic type ID given the basic type name I<basic_type_name>. | ||
| 226 | |||
| 227 | The function name I<func_name>, the file path I<file>, and the line number I<line> must be given for the exception stack trace. | ||
| 228 | |||
| 229 | If the basic type given by I<basic_type_name> is not found, an exception is thrown. | ||
| 230 | |||
| 231 | If an exception is thrown, C<error_id> is set to a non-zero value. Otherwise, it is set to 0. | ||
| 232 | |||
| 233 | =head2 get_class_var | ||
| 234 | |||
| 235 | C<SPVM_NATIVE_CLASS_VAR* (*get_class_var)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name, const char* class_var_name);> | ||
| 236 | |||
| 237 | Searches a L<class variable|SPVM::Document::NativeAPI::ClassVariable> given the basic type name I<basic_type_name> and the class variable name I<class_var_name>. | ||
| 238 | |||
| 239 | If it is found, returns it. Otherwise, returns C<NULL>. | ||
| 240 | |||
| 241 | Examples: | ||
| 242 | |||
| 243 | SPVM_NATIVE_CLASS_VAR* class_var = env->get_class_var(env, stack, "MyClass", "$VAR"); | ||
| 244 | |||
| 245 | =head2 get_class_var_byte | ||
| 246 | |||
| 247 | C<int8_t (*get_class_var_byte)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_CLASS_VAR* class_var|SPVM::Document::NativeAPI::ClassVariable>);> | ||
| 248 | |||
| 249 | Returns the value of the class variable I<class_var> interpreting its type is byte type. | ||
| 250 | |||
| 251 | =head2 get_class_var_short | ||
| 252 | |||
| 253 | C<int16_t (*get_class_var_short)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_CLASS_VAR* class_var|SPVM::Document::NativeAPI::ClassVariable>);> | ||
| 254 | |||
| 255 | Returns the value of the class variable I<class_var> interpreting its type is short type. | ||
| 256 | |||
| 257 | =head2 get_class_var_int | ||
| 258 | |||
| 259 | C<int32_t (*get_class_var_int)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_CLASS_VAR* class_var|SPVM::Document::NativeAPI::ClassVariable>);> | ||
| 260 | |||
| 261 | Returns the value of the class variable I<class_var> interpreting its type is int type. | ||
| 262 | |||
| 263 | =head2 get_class_var_long | ||
| 264 | |||
| 265 | C<int64_t (*get_class_var_long)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_CLASS_VAR* class_var|SPVM::Document::NativeAPI::ClassVariable>);> | ||
| 266 | |||
| 267 | Returns the value of the class variable I<class_var> interpreting its type is long type. | ||
| 268 | |||
| 269 | =head2 get_class_var_float | ||
| 270 | |||
| 271 | C<float (*get_class_var_float)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_CLASS_VAR* class_var|SPVM::Document::NativeAPI::ClassVariable>);> | ||
| 272 | |||
| 273 | Returns the value of the class variable I<class_var> interpreting its type is float type. | ||
| 274 | |||
| 275 | =head2 get_class_var_double | ||
| 276 | |||
| 277 | C<double (*get_class_var_double)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_CLASS_VAR* class_var|SPVM::Document::NativeAPI::ClassVariable>);> | ||
| 278 | |||
| 279 | Returns the value of the class variable I<class_var> interpreting its type is double type. | ||
| 280 | |||
| 281 | =head2 get_class_var_object | ||
| 282 | |||
| 283 | C<SPVM_OBJ* (*get_class_var_object)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_CLASS_VAR* class_var|SPVM::Document::NativeAPI::ClassVariable>);> | ||
| 284 | |||
| 285 | Returns the value of the class variable I<class_var> interpreting its type is an object type. | ||
| 286 | |||
| 287 | =head2 get_class_var_string | ||
| 288 | |||
| 289 | C<SPVM_OBJ* (*get_class_var_string)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_CLASS_VAR* class_var|SPVM::Document::NativeAPI::ClassVariable>);> | ||
| 290 | |||
| 291 | Returns the value of the class variable I<class_var> interpreting its type is string type. | ||
| 292 | |||
| 293 | =head2 set_class_var_byte | ||
| 294 | |||
| 295 | C<void (*set_class_var_byte)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_CLASS_VAR* class_var|SPVM::Document::NativeAPI::ClassVariable>, int8_t value);> | ||
| 296 | |||
| 297 | Sets I<value> to the class variable I<class_var> interpreting its type is byte type. | ||
| 298 | |||
| 299 | =head2 set_class_var_short | ||
| 300 | |||
| 301 | C<void (*set_class_var_short)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_CLASS_VAR* class_var|SPVM::Document::NativeAPI::ClassVariable>, int16_t value);> | ||
| 302 | |||
| 303 | Sets I<value> to the class variable I<class_var> interpreting its type is short type. | ||
| 304 | |||
| 305 | =head2 set_class_var_int | ||
| 306 | |||
| 307 | C<void (*set_class_var_int)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_CLASS_VAR* class_var|SPVM::Document::NativeAPI::ClassVariable>, int32_t value);> | ||
| 308 | |||
| 309 | Sets I<value> to the class variable I<class_var> interpreting its type is int type. | ||
| 310 | |||
| 311 | =head2 set_class_var_long | ||
| 312 | |||
| 313 | C<void (*set_class_var_long)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_CLASS_VAR* class_var|SPVM::Document::NativeAPI::ClassVariable>, int64_t value);> | ||
| 314 | |||
| 315 | Sets I<value> to the class variable I<class_var> interpreting its type is long type. | ||
| 316 | |||
| 317 | =head2 set_class_var_float | ||
| 318 | |||
| 319 | C<void (*set_class_var_float)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_CLASS_VAR* class_var|SPVM::Document::NativeAPI::ClassVariable>, float value);> | ||
| 320 | |||
| 321 | Sets I<value> to the class variable I<class_var> interpreting its type is float type. | ||
| 322 | |||
| 323 | =head2 set_class_var_double | ||
| 324 | |||
| 325 | C<void (*set_class_var_double)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_CLASS_VAR* class_var|SPVM::Document::NativeAPI::ClassVariable>, double value);> | ||
| 326 | |||
| 327 | Sets I<value> to the class variable I<class_var> interpreting its type is double type. | ||
| 328 | |||
| 329 | =head2 set_class_var_object | ||
| 330 | |||
| 331 | C<void (*set_class_var_object)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_CLASS_VAR* class_var|SPVM::Document::NativeAPI::ClassVariable>, SPVM_OBJ* value);> | ||
| 332 | |||
| 333 | Sets I<value> to the class variable I<class_var> interpreting its type is an object type. | ||
| 334 | |||
| 335 | =head2 set_class_var_string | ||
| 336 | |||
| 337 | C<void (*set_class_var_string)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_CLASS_VAR* class_var|SPVM::Document::NativeAPI::ClassVariable>, SPVM_OBJ* value);> | ||
| 338 | |||
| 339 | Sets I<value> to the class variable I<class_var> interpreting its type is string type. | ||
| 340 | |||
| 341 | =head2 get_class_var_object_ref | ||
| 342 | |||
| 343 | C<SPVM_OBJ** (*get_class_var_object_ref)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_CLASS_VAR* class_var|SPVM::Document::NativeAPI::ClassVariable>);> | ||
| 344 | |||
| 345 | Returns the address where the value of the class variable I<class_var> is stored. | ||
| 346 | |||
| 347 | =head2 get_class_var_byte_by_name | ||
| 348 | |||
| 349 | C<int8_t (*get_class_var_byte_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime 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);> | ||
| 350 | |||
| 351 | Gets the value of the class variable specified by the basic type name I<basic_type_name> and the class variable name I<class_var_name>, and returns the value. | ||
| 352 | |||
| 353 | The type of the field must be C<byte> type. | ||
| 354 | |||
| 355 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 356 | |||
| 357 | If this function succeeds, I<error_id> is set to 0. | ||
| 358 | |||
| 359 | Exceptions: | ||
| 360 | |||
| 361 | If I<basic_type_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 362 | |||
| 363 | If I<class_var_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 364 | |||
| 365 | If the class variable type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 366 | |||
| 367 | Examples: | ||
| 368 | |||
| 369 | int32_t error_id = 0; | ||
| 370 | int8_t value = env->get_class_var_byte_by_name(env, stack, "TestCase::NativeAPI", "$BYTE_VALUE", &error_id, __func__, FILE_NAME, __LINE__); | ||
| 371 | if (error_id) { return error_id; } | ||
| 372 | |||
| 373 | =head2 get_class_var_short_by_name | ||
| 374 | |||
| 375 | C<int16_t (*get_class_var_short_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime 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);> | ||
| 376 | |||
| 377 | Gets the value of the class variable specified by the basic type name I<basic_type_name> and the class variable name I<class_var_name>, and returns the value casting to C<short> type. | ||
| 378 | |||
| 379 | The type of the field must be C<short> type or smaller numeric type. | ||
| 380 | |||
| 381 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 382 | |||
| 383 | If this function succeeds, I<error_id> is set to 0. | ||
| 384 | |||
| 385 | Exceptions: | ||
| 386 | |||
| 387 | If I<basic_type_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 388 | |||
| 389 | If I<class_var_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 390 | |||
| 391 | If the class variable type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 392 | |||
| 393 | Examples: | ||
| 394 | |||
| 395 | int32_t error_id = 0; | ||
| 396 | int16_t value = env->get_class_var_short_by_name(env, stack, "TestCase::NativeAPI", "$SHORT_VALUE", &error_id, __func__, FILE_NAME, __LINE__); | ||
| 397 | if (error_id) { return error_id; } | ||
| 398 | |||
| 399 | =head2 get_class_var_int_by_name | ||
| 400 | |||
| 401 | C<int32_t (*get_class_var_int_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime 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);> | ||
| 402 | |||
| 403 | Gets the value of the class variable specified by the basic type name I<basic_type_name> and the class variable name I<class_var_name>, and returns the value casting to C<int> type. | ||
| 404 | |||
| 405 | The type of the field must be C<int> type or smaller numeric type. | ||
| 406 | |||
| 407 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 408 | |||
| 409 | If this function succeeds, I<error_id> is set to 0. | ||
| 410 | |||
| 411 | Exceptions: | ||
| 412 | |||
| 413 | If I<basic_type_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 414 | |||
| 415 | If I<class_var_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 416 | |||
| 417 | If the class variable type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 418 | |||
| 419 | Examples: | ||
| 420 | |||
| 421 | int32_t error_id = 0; | ||
| 422 | int8_t value = env->get_class_var_int_by_name(env, stack, "TestCase::NativeAPI", "$BYTE_VALUE", &error_id, __func__, FILE_NAME, __LINE__); | ||
| 423 | if (error_id) { return error_id; } | ||
| 424 | |||
| 425 | =head2 get_class_var_long_by_name | ||
| 426 | |||
| 427 | C<int64_t (*get_class_var_long_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime 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);> | ||
| 428 | |||
| 429 | Gets the value of the class variable specified by the basic type name I<basic_type_name> and the class variable name I<class_var_name>, and returns the value casting to C<long> type. | ||
| 430 | |||
| 431 | The type of the field must be C<long> type or smaller numeric type. | ||
| 432 | |||
| 433 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 434 | |||
| 435 | If this function succeeds, I<error_id> is set to 0. | ||
| 436 | |||
| 437 | Exceptions: | ||
| 438 | |||
| 439 | If I<basic_type_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 440 | |||
| 441 | If I<class_var_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 442 | |||
| 443 | If the class variable type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 444 | |||
| 445 | Examples: | ||
| 446 | |||
| 447 | int32_t error_id = 0; | ||
| 448 | int64_t value = env->get_class_var_long_by_name(env, stack, "TestCase::NativeAPI", "$LONG_VALUE", &error_id, __func__, FILE_NAME, __LINE__); | ||
| 449 | if (error_id) { return error_id; } | ||
| 450 | |||
| 451 | =head2 get_class_var_float_by_name | ||
| 452 | |||
| 453 | C<float (*get_class_var_float_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime 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);> | ||
| 454 | |||
| 455 | Gets the value of the class variable specified by the basic type name I<basic_type_name> and the class variable name I<class_var_name>, and returns the value casting to C<float> type. | ||
| 456 | |||
| 457 | The type of the field must be C<float> type or smaller numeric type. | ||
| 458 | |||
| 459 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 460 | |||
| 461 | If this function succeeds, I<error_id> is set to 0. | ||
| 462 | |||
| 463 | Exceptions: | ||
| 464 | |||
| 465 | If I<basic_type_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 466 | |||
| 467 | If I<class_var_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 468 | |||
| 469 | If the class variable type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 470 | |||
| 471 | Examples: | ||
| 472 | |||
| 473 | int32_t error_id = 0; | ||
| 474 | float value = env->get_class_var_float_by_name(env, stack, "TestCase::NativeAPI", "$FLOAT_VALUE", &error_id, __func__, FILE_NAME, __LINE__); | ||
| 475 | if (error_id) { return error_id; } | ||
| 476 | |||
| 477 | =head2 get_class_var_double_by_name | ||
| 478 | |||
| 479 | C<double (*get_class_var_double_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime 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);> | ||
| 480 | |||
| 481 | Gets the value of the class variable specified by the basic type name I<basic_type_name> and the class variable name I<class_var_name>, and returns the value casting to C<double> type. | ||
| 482 | |||
| 483 | The type of the field must be C<double> type or smaller numeric type. | ||
| 484 | |||
| 485 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 486 | |||
| 487 | If this function succeeds, I<error_id> is set to 0. | ||
| 488 | |||
| 489 | Exceptions: | ||
| 490 | |||
| 491 | If I<basic_type_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 492 | |||
| 493 | If I<class_var_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 494 | |||
| 495 | If the class variable type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 496 | |||
| 497 | Examples: | ||
| 498 | |||
| 499 | int32_t error_id = 0; | ||
| 500 | double value = env->get_class_var_double_by_name(env, stack, "TestCase::NativeAPI", "$DOUBLE_VALUE", &error_id, __func__, FILE_NAME, __LINE__); | ||
| 501 | if (error_id) { return error_id; } | ||
| 502 | |||
| 503 | =head2 get_class_var_object_by_name | ||
| 504 | |||
| 505 | C<SPVM_OBJ* (*get_class_var_object_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime 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);> | ||
| 506 | |||
| 507 | Gets the value of the class variable specified by the basic type name I<basic_type_name> and the class variable name I<class_var_name>, and returns the value. | ||
| 508 | |||
| 509 | The type of the field must be an object type. | ||
| 510 | |||
| 511 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 512 | |||
| 513 | If this function succeeds, I<error_id> is set to 0. | ||
| 514 | |||
| 515 | Exceptions: | ||
| 516 | |||
| 517 | If I<basic_type_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 518 | |||
| 519 | If I<class_var_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 520 | |||
| 521 | If the class variable type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 522 | |||
| 523 | Examples: | ||
| 524 | |||
| 525 | int32_t error_id = 0; | ||
| 526 | SPVM_OBJ* value = env->get_class_var_object_by_name(env, stack, "TestCase::NativeAPI", "$MINIMAL_VALUE", &error_id, __func__, FILE_NAME, __LINE__); | ||
| 527 | if (error_id) { return error_id; } | ||
| 528 | |||
| 529 | =head2 get_class_var_string_by_name | ||
| 530 | |||
| 531 | C<SPVM_OBJ* (*get_class_var_string_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime 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);> | ||
| 532 | |||
| 533 | The same as L</"get_class_var_object_by_name"> native API. | ||
| 534 | |||
| 535 | =head2 set_class_var_byte_by_name | ||
| 536 | |||
| 537 | C<void (*set_class_var_byte_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime 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);> | ||
| 538 | |||
| 539 | Sets the class variable specified by the basic type name I<basic_type_name> and the class variable name I<class_var_name> to the value I<value> casting to the field type. | ||
| 540 | |||
| 541 | The type of the field must be C<byte> type or larger numeric type. | ||
| 542 | |||
| 543 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 544 | |||
| 545 | If this function succeeds, I<error_id> is set to 0. | ||
| 546 | |||
| 547 | Exceptions: | ||
| 548 | |||
| 549 | If I<basic_type_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 550 | |||
| 551 | If I<class_var_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 552 | |||
| 553 | If the class variable type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 554 | |||
| 555 | Examples: | ||
| 556 | |||
| 557 | int32_t error_id = 0; | ||
| 558 | env->set_class_var_byte_by_name(env, stack, "TestCase::NativeAPI", "$BYTE_VALUE", 15, &error_id, __func__, FILE_NAME, __LINE__); | ||
| 559 | if (error_id) { return error_id; } | ||
| 560 | |||
| 561 | =head2 set_class_var_short_by_name | ||
| 562 | |||
| 563 | C<void (*set_class_var_short_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime 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);> | ||
| 564 | |||
| 565 | Sets the class variable specified by the basic type name I<basic_type_name> and the class variable name I<class_var_name> to the value I<value> casting to the field type. | ||
| 566 | |||
| 567 | The type of the field must be C<short> type or larger numeric type. | ||
| 568 | |||
| 569 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 570 | |||
| 571 | If this function succeeds, I<error_id> is set to 0. | ||
| 572 | |||
| 573 | Exceptions: | ||
| 574 | |||
| 575 | If I<basic_type_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 576 | |||
| 577 | If I<class_var_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 578 | |||
| 579 | If the class variable type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 580 | |||
| 581 | Examples: | ||
| 582 | |||
| 583 | int32_t error_id = 0; | ||
| 584 | env->set_class_var_short_by_name(env, stack, "TestCase::NativeAPI", "$SHORT_VALUE", 15, &error_id, __func__, FILE_NAME, __LINE__); | ||
| 585 | if (error_id) { return error_id; } | ||
| 586 | |||
| 587 | =head2 set_class_var_int_by_name | ||
| 588 | |||
| 589 | C<void (*set_class_var_int_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime 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);> | ||
| 590 | |||
| 591 | Sets the class variable specified by the basic type name I<basic_type_name> and the class variable name I<class_var_name> to the value I<value> casting to the field type. | ||
| 592 | |||
| 593 | The type of the field must be C<int> type or larger numeric type. | ||
| 594 | |||
| 595 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 596 | |||
| 597 | If this function succeeds, I<error_id> is set to 0. | ||
| 598 | |||
| 599 | Exceptions: | ||
| 600 | |||
| 601 | If I<basic_type_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 602 | |||
| 603 | If I<class_var_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 604 | |||
| 605 | If the class variable type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 606 | |||
| 607 | Examples: | ||
| 608 | |||
| 609 | int32_t error_id = 0; | ||
| 610 | env->set_class_var_int_by_name(env, stack, "TestCase::NativeAPI", "$INT_VALUE", 15, &error_id, __func__, FILE_NAME, __LINE__); | ||
| 611 | if (error_id) { return error_id; } | ||
| 612 | |||
| 613 | =head2 set_class_var_long_by_name | ||
| 614 | |||
| 615 | C<void (*set_class_var_long_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime 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);> | ||
| 616 | |||
| 617 | Sets the class variable specified by the basic type name I<basic_type_name> and the class variable name I<class_var_name> to the value I<value> casting to the field type. | ||
| 618 | |||
| 619 | The type of the field must be C<long> type or larger numeric type. | ||
| 620 | |||
| 621 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 622 | |||
| 623 | If this function succeeds, I<error_id> is set to 0. | ||
| 624 | |||
| 625 | Exceptions: | ||
| 626 | |||
| 627 | If I<basic_type_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 628 | |||
| 629 | If I<class_var_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 630 | |||
| 631 | If the class variable type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 632 | |||
| 633 | Examples: | ||
| 634 | |||
| 635 | int32_t error_id = 0; | ||
| 636 | env->set_class_var_long_by_name(env, stack, "TestCase::NativeAPI", "$LONG_VALUE", 15, &error_id, __func__, FILE_NAME, __LINE__); | ||
| 637 | if (error_id) { return error_id; } | ||
| 638 | |||
| 639 | =head2 set_class_var_float_by_name | ||
| 640 | |||
| 641 | C<void (*set_class_var_float_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime 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);> | ||
| 642 | |||
| 643 | Sets the class variable specified by the basic type name I<basic_type_name> and the class variable name I<class_var_name> to the value I<value> casting to the field type. | ||
| 644 | |||
| 645 | The type of the field must be C<float> type or larger numeric type. | ||
| 646 | |||
| 647 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 648 | |||
| 649 | If this function succeeds, I<error_id> is set to 0. | ||
| 650 | |||
| 651 | Exceptions: | ||
| 652 | |||
| 653 | If I<basic_type_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 654 | |||
| 655 | If I<class_var_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 656 | |||
| 657 | If the class variable type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 658 | |||
| 659 | Examples: | ||
| 660 | |||
| 661 | int32_t error_id = 0; | ||
| 662 | env->set_class_var_float_by_name(env, stack, "TestCase::NativeAPI", "$FLOAT_VALUE", 15, &error_id, __func__, FILE_NAME, __LINE__); | ||
| 663 | if (error_id) { return error_id; } | ||
| 664 | |||
| 665 | =head2 set_class_var_double_by_name | ||
| 666 | |||
| 667 | C<void (*set_class_var_double_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime 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);> | ||
| 668 | |||
| 669 | Sets the class variable specified by the basic type name I<basic_type_name> and the class variable name I<class_var_name> to the value I<value>. | ||
| 670 | |||
| 671 | The type of the field must be C<double> type. | ||
| 672 | |||
| 673 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 674 | |||
| 675 | If this function succeeds, I<error_id> is set to 0. | ||
| 676 | |||
| 677 | Exceptions: | ||
| 678 | |||
| 679 | If I<basic_type_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 680 | |||
| 681 | If I<class_var_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 682 | |||
| 683 | If the class variable type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 684 | |||
| 685 | Examples: | ||
| 686 | |||
| 687 | int32_t error_id = 0; | ||
| 688 | env->set_class_var_double_by_name(env, stack, "TestCase::NativeAPI", "$DOUBLE_VALUE", 15, &error_id, __func__, FILE_NAME, __LINE__); | ||
| 689 | if (error_id) { return error_id; } | ||
| 690 | |||
| 691 | =head2 set_class_var_object_by_name | ||
| 692 | |||
| 693 | C<void (*set_class_var_object_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name, const char* class_var_name, SPVM_OBJ* value, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 694 | |||
| 695 | Sets the class variable specified by the basic type name I<basic_type_name> and the class variable name I<class_var_name> to the value I<value>. | ||
| 696 | |||
| 697 | The type of the field must be an object type. | ||
| 698 | |||
| 699 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 700 | |||
| 701 | If this function succeeds, I<error_id> is set to 0. | ||
| 702 | |||
| 703 | Exceptions: | ||
| 704 | |||
| 705 | If I<basic_type_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 706 | |||
| 707 | If I<class_var_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 708 | |||
| 709 | If the class variable type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 710 | |||
| 711 | Examples: | ||
| 712 | |||
| 713 | int32_t error_id = 0; | ||
| 714 | env->set_class_var_object_by_name(env, stack, "TestCase::NativeAPI", "$MINIMAL_VALUE", minimal, &error_id, __func__, FILE_NAME, __LINE__); | ||
| 715 | if (error_id) { return error_id; } | ||
| 716 | |||
| 717 | =head2 set_class_var_string_by_name | ||
| 718 | |||
| 719 | C<void (*set_class_var_string_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name, const char* class_var_name, SPVM_OBJ* value, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 720 | |||
| 721 | The same as L</"set_class_var_object_by_name"> native API. | ||
| 722 | |||
| 723 | =head2 get_field | ||
| 724 | |||
| 725 | C<SPVM_NATIVE_FIELD* (*get_field)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name);> | ||
| 726 | |||
| 727 | Searches a L<field|SPVM::Document::NativeAPI::Field> object given the object I<object> and the field name I<field_name>. | ||
| 728 | |||
| 729 | If it is found, returns it. Otherwise, returns C<NULL>. | ||
| 730 | |||
| 731 | Examples: | ||
| 732 | |||
| 733 | SPVM_NATIVE_FIELD* field = env->get_field(env, stack, object, "x"); | ||
| 734 | |||
| 735 | =head2 get_field_static | ||
| 736 | |||
| 737 | C<SPVM_NATIVE_FIELD* (*get_field_static)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name, const char* field_name);> | ||
| 738 | |||
| 739 | Searches a L<field|SPVM::Document::NativeAPI::Field> object given the basic type name I<basic_type_name> and the field name I<field_name>. | ||
| 740 | |||
| 741 | If it is found, returns it. Otherwise, returns C<NULL>. | ||
| 742 | |||
| 743 | Examples: | ||
| 744 | |||
| 745 | SPVM_NATIVE_FIELD* field = env->get_field_static(env, stack, "Point", "x"); | ||
| 746 | |||
| 747 | =head2 get_field_byte | ||
| 748 | |||
| 749 | C<int8_t (*get_field_byte)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>);> | ||
| 750 | |||
| 751 | Returns the value of the field I<field> of the object I<object> interpreting its type is byte type. | ||
| 752 | |||
| 753 | =head2 get_field_short | ||
| 754 | |||
| 755 | C<int16_t (*get_field_short)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>);> | ||
| 756 | |||
| 757 | Returns the value of the field I<field> of the object I<object> interpreting its type is short type. | ||
| 758 | |||
| 759 | =head2 get_field_int | ||
| 760 | |||
| 761 | C<int32_t (*get_field_int)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>);> | ||
| 762 | |||
| 763 | Returns the value of the field I<field> of the object I<object> interpreting its type is int type. | ||
| 764 | |||
| 765 | =head2 get_field_long | ||
| 766 | |||
| 767 | C<int64_t (*get_field_long)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>);> | ||
| 768 | |||
| 769 | Returns the value of the field I<field> of the object I<object> interpreting its type is long type. | ||
| 770 | |||
| 771 | =head2 get_field_float | ||
| 772 | |||
| 773 | C<float (*get_field_float)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>);> | ||
| 774 | |||
| 775 | Returns the value of the field I<field> of the object I<object> interpreting its type is float type. | ||
| 776 | |||
| 777 | =head2 get_field_double | ||
| 778 | |||
| 779 | C<double (*get_field_double)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>);> | ||
| 780 | |||
| 781 | Returns the value of the field I<field> of the object I<object> interpreting its type is double type. | ||
| 782 | |||
| 783 | =head2 get_field_object | ||
| 784 | |||
| 785 | C<SPVM_OBJ* (*get_field_object)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>);> | ||
| 786 | |||
| 787 | Returns the value of the field I<field> of the object I<object> interpreting its type is an object type. | ||
| 788 | |||
| 789 | =head2 get_field_string | ||
| 790 | |||
| 791 | C<SPVM_OBJ* (*get_field_string)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>);> | ||
| 792 | |||
| 793 | Returns the value of the field I<field> of the object I<object> interpreting its type is string type. | ||
| 794 | |||
| 795 | =head2 set_field_byte | ||
| 796 | |||
| 797 | C<void (*set_field_byte)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>, int8_t value);> | ||
| 798 | |||
| 799 | Sets I<value> to the field I<field> of the object I<object>. | ||
| 800 | |||
| 801 | I<value> must be a numeric type. It is cast to byte type. | ||
| 802 | |||
| 803 | And the field existence flag is set to 1. | ||
| 804 | |||
| 805 | =head2 set_field_short | ||
| 806 | |||
| 807 | C<void (*set_field_short)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>, int16_t value);> | ||
| 808 | |||
| 809 | Sets I<value> to the field I<field> of the object I<object>. | ||
| 810 | |||
| 811 | I<value> must be a numeric type. It is cast to short type. | ||
| 812 | |||
| 813 | And the field existence flag is set to 1. | ||
| 814 | |||
| 815 | =head2 set_field_int | ||
| 816 | |||
| 817 | C<void (*set_field_int)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>, int32_t value);> | ||
| 818 | |||
| 819 | Sets I<value> to the field I<field> of the object I<object>. | ||
| 820 | |||
| 821 | I<value> must be a numeric type. It is cast to int type. | ||
| 822 | |||
| 823 | And the field existence flag is set to 1. | ||
| 824 | |||
| 825 | =head2 set_field_long | ||
| 826 | |||
| 827 | C<void (*set_field_long)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>, int64_t value);> | ||
| 828 | |||
| 829 | Sets I<value> to the field I<field> of the object I<object>. | ||
| 830 | |||
| 831 | I<value> must be a numeric type. It is cast to long type. | ||
| 832 | |||
| 833 | And the field existence flag is set to 1. | ||
| 834 | |||
| 835 | =head2 set_field_float | ||
| 836 | |||
| 837 | C<void (*set_field_float)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>, float value);> | ||
| 838 | |||
| 839 | Sets I<value> to the field I<field> of the object I<object>. | ||
| 840 | |||
| 841 | I<value> must be a numeric type. It is cast to float type. | ||
| 842 | |||
| 843 | And the field existence flag is set to 1. | ||
| 844 | |||
| 845 | =head2 set_field_double | ||
| 846 | |||
| 847 | C<void (*set_field_double)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>, double value);> | ||
| 848 | |||
| 849 | Sets I<value> to the field I<field> of the object I<object>. | ||
| 850 | |||
| 851 | I<value> must be a numeric type. It is cast to double type. | ||
| 852 | |||
| 853 | And the field existence flag is set to 1. | ||
| 854 | |||
| 855 | =head2 set_field_object | ||
| 856 | |||
| 857 | C<void (*set_field_object)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>, SPVM_OBJ* value);> | ||
| 858 | |||
| 859 | Sets I<value> to the field I<field> of the object I<object> interpreting its type is an object type. | ||
| 860 | |||
| 861 | And the field existence flag is set to 1. | ||
| 862 | |||
| 863 | =head2 set_field_string | ||
| 864 | |||
| 865 | C<void (*set_field_string)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>, SPVM_OBJ* value);> | ||
| 866 | |||
| 867 | Alias for L</"set_field_object"> | ||
| 868 | |||
| 869 | =head2 get_field_byte_by_name | ||
| 870 | |||
| 871 | C<int8_t (*get_field_byte_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 872 | |||
| 873 | Returns the value of the field specified by the invocant I<object> and the field name I<field_name>. | ||
| 874 | |||
| 875 | The type of the field must be a numeric type. The value is cast to byte type. | ||
| 876 | |||
| 877 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 878 | |||
| 879 | If this function succeeds, I<error_id> is set to 0. | ||
| 880 | |||
| 881 | Exceptions: | ||
| 882 | |||
| 883 | If I<object> is not a class type, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 884 | |||
| 885 | If I<field_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 886 | |||
| 887 | If the field type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 888 | |||
| 889 | Examples: | ||
| 890 | |||
| 891 | int32_t error_id = 0; | ||
| 892 | int8_t byte_value = env->get_field_byte_by_name(env, stack, object, "byte_value", &error_id, __func__, FILE_NAME, __LINE__); | ||
| 893 | if (error_id) { return error_id; } | ||
| 894 | |||
| 895 | =head2 get_field_short_by_name | ||
| 896 | |||
| 897 | C<int16_t (*get_field_short_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 898 | |||
| 899 | Gets the value of the field specified by the invocant I<object> and the field name I<field_name>, and returns the value casting to C<short> type. | ||
| 900 | |||
| 901 | The type of the field must be a numeric type. The value is cast to short type. | ||
| 902 | |||
| 903 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 904 | |||
| 905 | If this function succeeds, I<error_id> is set to 0. | ||
| 906 | |||
| 907 | Exceptions: | ||
| 908 | |||
| 909 | If I<object> is not a class type, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 910 | |||
| 911 | If I<field_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 912 | |||
| 913 | If the field type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 914 | |||
| 915 | Examples: | ||
| 916 | |||
| 917 | int32_t error_id = 0; | ||
| 918 | int16_t short_value = env->get_field_short_by_name(env, stack, object, "short_value", &error_id, __func__, FILE_NAME, __LINE__); | ||
| 919 | if (error_id) { return error_id; } | ||
| 920 | |||
| 921 | =head2 get_field_int_by_name | ||
| 922 | |||
| 923 | C<int32_t (*get_field_int_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 924 | |||
| 925 | Gets the value of the field specified by the invocant I<object> and the field name I<field_name>, and returns the value casting to C<int> type. | ||
| 926 | |||
| 927 | The type of the field must be a numeric type. The value is cast to int type. | ||
| 928 | |||
| 929 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 930 | |||
| 931 | If this function succeeds, I<error_id> is set to 0. | ||
| 932 | |||
| 933 | Exceptions: | ||
| 934 | |||
| 935 | If I<object> is not a class type, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 936 | |||
| 937 | If I<field_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 938 | |||
| 939 | If the field type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 940 | |||
| 941 | Examples: | ||
| 942 | |||
| 943 | int32_t error_id = 0; | ||
| 944 | int32_t int_value = env->get_field_int_by_name(env, stack, object, "int_value", &error_id, __func__, FILE_NAME, __LINE__); | ||
| 945 | if (error_id) { return error_id; } | ||
| 946 | |||
| 947 | =head2 get_field_long_by_name | ||
| 948 | |||
| 949 | C<int64_t (*get_field_long_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 950 | |||
| 951 | Gets the value of the field specified by the invocant I<object> and the field name I<field_name>, and returns the value casting to C<long> type. | ||
| 952 | |||
| 953 | The type of the field must be a numeric type. The value is cast to long type. | ||
| 954 | |||
| 955 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 956 | |||
| 957 | If this function succeeds, I<error_id> is set to 0. | ||
| 958 | |||
| 959 | Exceptions: | ||
| 960 | |||
| 961 | If I<object> is not a class type, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 962 | |||
| 963 | If I<field_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 964 | |||
| 965 | If the field type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 966 | |||
| 967 | Examples: | ||
| 968 | |||
| 969 | int32_t error_id = 0; | ||
| 970 | int64_t long_value = env->get_field_long_by_name(env, stack, object, "long_value", &error_id, __func__, FILE_NAME, __LINE__); | ||
| 971 | if (error_id) { return error_id; } | ||
| 972 | |||
| 973 | =head2 get_field_float_by_name | ||
| 974 | |||
| 975 | C<float (*get_field_float_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 976 | |||
| 977 | Gets the value of the field specified by the invocant I<object> and the field name I<field_name>, and returns the value casting to C<float> type. | ||
| 978 | |||
| 979 | The type of the field must be a numeric type. The value is cast to float type. | ||
| 980 | |||
| 981 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 982 | |||
| 983 | If this function succeeds, I<error_id> is set to 0. | ||
| 984 | |||
| 985 | Exceptions: | ||
| 986 | |||
| 987 | If I<object> is not a class type, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 988 | |||
| 989 | If I<field_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 990 | |||
| 991 | If the field type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 992 | |||
| 993 | Examples: | ||
| 994 | |||
| 995 | int32_t error_id = 0; | ||
| 996 | float float_value = env->get_field_float_by_name(env, stack, object, "float_value", &error_id, __func__, FILE_NAME, __LINE__); | ||
| 997 | if (error_id) { return error_id; } | ||
| 998 | |||
| 999 | =head2 get_field_double_by_name | ||
| 1000 | |||
| 1001 | C<double (*get_field_double_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 1002 | |||
| 1003 | Gets the value of the field specified by the invocant I<object> and the field name I<field_name>, and returns the value casting to C<double> type. | ||
| 1004 | |||
| 1005 | The type of the field must be a numeric type. The value is cast to double type. | ||
| 1006 | |||
| 1007 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 1008 | |||
| 1009 | If this function succeeds, I<error_id> is set to 0. | ||
| 1010 | |||
| 1011 | Exceptions: | ||
| 1012 | |||
| 1013 | If I<object> is not a class type, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1014 | |||
| 1015 | If I<field_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1016 | |||
| 1017 | If the field type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1018 | |||
| 1019 | Examples: | ||
| 1020 | |||
| 1021 | int32_t error_id = 0; | ||
| 1022 | double double_value = env->get_field_double_by_name(env, stack, object, "double_value", &error_id, __func__, FILE_NAME, __LINE__); | ||
| 1023 | if (error_id) { return error_id; } | ||
| 1024 | |||
| 1025 | =head2 get_field_object_by_name | ||
| 1026 | |||
| 1027 | C<SPVM_OBJ* (*get_field_object_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 1028 | |||
| 1029 | Gets the value of the field specified by the invocant I<object> and the field name I<field_name>. | ||
| 1030 | |||
| 1031 | The type of the field must be an object type. | ||
| 1032 | |||
| 1033 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 1034 | |||
| 1035 | If this function succeeds, I<error_id> is set to 0. | ||
| 1036 | |||
| 1037 | Exceptions: | ||
| 1038 | |||
| 1039 | If I<object> is not a class type, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1040 | |||
| 1041 | If I<field_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1042 | |||
| 1043 | If the field type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1044 | |||
| 1045 | Examples: | ||
| 1046 | |||
| 1047 | int32_t error_id = 0; | ||
| 1048 | SPVM_OBJ* object_minimal = env->get_field_object_by_name(env, stack, object_simple, "object_value", &error_id, __func__, FILE_NAME, __LINE__); | ||
| 1049 | if (error_id) { return error_id; } | ||
| 1050 | |||
| 1051 | =head2 get_field_string_by_name | ||
| 1052 | |||
| 1053 | C<SPVM_OBJ* (*get_field_string_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 1054 | |||
| 1055 | The same as L</"get_field_object_by_name"> native API. | ||
| 1056 | |||
| 1057 | =head2 set_field_byte_by_name | ||
| 1058 | |||
| 1059 | C<void (*set_field_byte_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, int8_t value, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 1060 | |||
| 1061 | Sets the field specified by the invocant I<object> and the field name I<field_name> to the value I<value> casting to the field type. | ||
| 1062 | |||
| 1063 | The type of the field must be C<byte> type or larger numeric type. | ||
| 1064 | |||
| 1065 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 1066 | |||
| 1067 | If this function succeeds, I<error_id> is set to 0. | ||
| 1068 | |||
| 1069 | Exceptions: | ||
| 1070 | |||
| 1071 | If I<object> is not a class type, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1072 | |||
| 1073 | If I<field_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1074 | |||
| 1075 | If the field type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1076 | |||
| 1077 | Examples: | ||
| 1078 | |||
| 1079 | int32_t error_id = 0; | ||
| 1080 | env->set_field_byte_by_name(env, stack, object, "byte_value", 13, &error_id, __func__, FILE_NAME, __LINE__); | ||
| 1081 | if (error_id) { return error_id; } | ||
| 1082 | |||
| 1083 | =head2 set_field_short_by_name | ||
| 1084 | |||
| 1085 | C<void (*set_field_short_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, int16_t value, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 1086 | |||
| 1087 | Sets the field specified by the invocant I<object> and the field name I<field_name> to the value I<value> casting to the field type. | ||
| 1088 | |||
| 1089 | The type of the field must be C<short> type or larger numeric type. | ||
| 1090 | |||
| 1091 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 1092 | |||
| 1093 | If this function succeeds, I<error_id> is set to 0. | ||
| 1094 | |||
| 1095 | Exceptions: | ||
| 1096 | |||
| 1097 | If I<object> is not a class type, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1098 | |||
| 1099 | If I<field_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1100 | |||
| 1101 | If the field type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1102 | |||
| 1103 | Examples: | ||
| 1104 | |||
| 1105 | int32_t error_id = 0; | ||
| 1106 | env->set_field_short_by_name(env, stack, object, "short_value", 13, &error_id, __func__, FILE_NAME, __LINE__); | ||
| 1107 | if (error_id) { return error_id; } | ||
| 1108 | |||
| 1109 | =head2 set_field_int_by_name | ||
| 1110 | |||
| 1111 | C<void (*set_field_int_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, int32_t value, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 1112 | |||
| 1113 | Sets the field specified by the invocant I<object> and the field name I<field_name> to the value I<value> casting to the field type. | ||
| 1114 | |||
| 1115 | The type of the field must be C<int> type or larger numeric type. | ||
| 1116 | |||
| 1117 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 1118 | |||
| 1119 | If this function succeeds, I<error_id> is set to 0. | ||
| 1120 | |||
| 1121 | Exceptions: | ||
| 1122 | |||
| 1123 | If I<object> is not a class type, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1124 | |||
| 1125 | If I<field_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1126 | |||
| 1127 | If the field type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1128 | |||
| 1129 | Examples: | ||
| 1130 | |||
| 1131 | int32_t error_id = 0; | ||
| 1132 | env->set_field_int_by_name(env, stack, object, "int_value", 13, &error_id, __func__, FILE_NAME, __LINE__); | ||
| 1133 | if (error_id) { return error_id; } | ||
| 1134 | |||
| 1135 | =head2 set_field_long_by_name | ||
| 1136 | |||
| 1137 | C<void (*set_field_long_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, int64_t value, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 1138 | |||
| 1139 | Sets the field specified by the invocant I<object> and the field name I<field_name> to the value I<value> casting to the field type. | ||
| 1140 | |||
| 1141 | The type of the field must be C<long> type or larger numeric type. | ||
| 1142 | |||
| 1143 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 1144 | |||
| 1145 | If this function succeeds, I<error_id> is set to 0. | ||
| 1146 | |||
| 1147 | Exceptions: | ||
| 1148 | |||
| 1149 | If I<object> is not a class type, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1150 | |||
| 1151 | If I<field_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1152 | |||
| 1153 | If the field type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1154 | |||
| 1155 | Examples: | ||
| 1156 | |||
| 1157 | int32_t error_id = 0; | ||
| 1158 | env->set_field_long_by_name(env, stack, object, "long_value", 13, &error_id, __func__, FILE_NAME, __LINE__); | ||
| 1159 | if (error_id) { return error_id; } | ||
| 1160 | |||
| 1161 | =head2 set_field_float_by_name | ||
| 1162 | |||
| 1163 | C<void (*set_field_float_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, float value, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 1164 | |||
| 1165 | Sets the field specified by the invocant I<object> and the field name I<field_name> to the value I<value> casting to the field type. | ||
| 1166 | |||
| 1167 | The type of the field must be C<float> type or larger numeric type. | ||
| 1168 | |||
| 1169 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 1170 | |||
| 1171 | If this function succeeds, I<error_id> is set to 0. | ||
| 1172 | |||
| 1173 | Exceptions: | ||
| 1174 | |||
| 1175 | If I<object> is not a class type, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1176 | |||
| 1177 | If I<field_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1178 | |||
| 1179 | If the field type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1180 | |||
| 1181 | Examples: | ||
| 1182 | |||
| 1183 | int32_t error_id = 0; | ||
| 1184 | env->set_field_float_by_name(env, stack, object, "float_value", 13.0f, &error_id, __func__, FILE_NAME, __LINE__); | ||
| 1185 | if (error_id) { return error_id; } | ||
| 1186 | |||
| 1187 | =head2 set_field_double_by_name | ||
| 1188 | |||
| 1189 | C<void (*set_field_double_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, double value, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 1190 | |||
| 1191 | Sets the field specified by the invocant I<object> and the field name I<field_name> to the value I<value>. | ||
| 1192 | |||
| 1193 | The type of the field must be C<double> type. | ||
| 1194 | |||
| 1195 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 1196 | |||
| 1197 | If this function succeeds, I<error_id> is set to 0. | ||
| 1198 | |||
| 1199 | Exceptions: | ||
| 1200 | |||
| 1201 | If I<object> is not a class type, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1202 | |||
| 1203 | If I<field_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1204 | |||
| 1205 | If the field type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1206 | |||
| 1207 | Examples: | ||
| 1208 | |||
| 1209 | int32_t error_id = 0; | ||
| 1210 | env->set_field_double_by_name(env, stack, object, "double_value", 13.0, &error_id, __func__, FILE_NAME, __LINE__); | ||
| 1211 | if (error_id) { return error_id; } | ||
| 1212 | |||
| 1213 | =head2 set_field_object_by_name | ||
| 1214 | |||
| 1215 | C<void (*set_field_object_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, SPVM_OBJ* value, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 1216 | |||
| 1217 | Sets the field specified by the invocant I<object> and the field name I<field_name> to the value I<value>. | ||
| 1218 | |||
| 1219 | The type of the field must be an object type. | ||
| 1220 | |||
| 1221 | The function name I<func_name>, the file path I<file>, and the line number I<line> are needed for the exception stack trace. | ||
| 1222 | |||
| 1223 | If this function succeeds, I<error_id> is set to 0. | ||
| 1224 | |||
| 1225 | Exceptions: | ||
| 1226 | |||
| 1227 | If I<object> is not a class type, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1228 | |||
| 1229 | If I<field_name> is not found, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1230 | |||
| 1231 | If the field type is invalid, an exception is set and I<error_id> is set to the basic type id of L<Error|SPVM::Error> class. | ||
| 1232 | |||
| 1233 | Examples: | ||
| 1234 | |||
| 1235 | int32_t error_id = 0; | ||
| 1236 | env->set_field_object_by_name(env, stack, object_simple, "object_value", object_minimal, &error_id, __func__, FILE_NAME, __LINE__); | ||
| 1237 | if (error_id) { return error_id; } | ||
| 1238 | |||
| 1239 | =head2 set_field_string_by_name | ||
| 1240 | |||
| 1241 | C<void (*set_field_string_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, SPVM_OBJ* value, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 1242 | |||
| 1243 | The same as L</"set_field_object_by_name"> native API. | ||
| 1244 | |||
| 1245 | =head2 get_field_string_chars_by_name | ||
| 1246 | |||
| 1247 | C<const char* (*get_field_string_chars_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 1248 | |||
| 1249 | Calls the L</"get_field_string_by_name">. If the return value is C<NULL>, returns C<NULL>. Otherwise, calls the L</"get_chars"> given the return value, and returns the return value of L</"get_chars"> native API. | ||
| 1250 | |||
| 1251 | =head2 get_method | ||
| 1252 | |||
| 1253 | C<SPVM_NATIVE_METHOD* (*get_method)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name, const char* method_name);> | ||
| 1254 | |||
| 1255 | Searches a L<method|SPVM::Document::NativeAPI::Method> given the basic type name I<basic_type_name> and the method name I<method_name>. | ||
| 1256 | |||
| 1257 | If it is found, returns it. Otherwise, returns C<NULL>. | ||
| 1258 | |||
| 1259 | Examples: | ||
| 1260 | |||
| 1261 | SPVM_NATIVE_METHOD* method = env->get_method(env, stack, "Foo", "get"); | ||
| 1262 | |||
| 1263 | =head2 get_class_method | ||
| 1264 | |||
| 1265 | C<SPVM_NATIVE_METHOD* (*get_class_method)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name, const char* method_name);> | ||
| 1266 | |||
| 1267 | Searches a class L<method|SPVM::Document::NativeAPI::Method> given the basic type name I<basic_type_name> and the method name I<method_name>. | ||
| 1268 | |||
| 1269 | If it is found, returns it. Otherwise, returns C<NULL>. | ||
| 1270 | |||
| 1271 | Examples: | ||
| 1272 | |||
| 1273 | SPVM_NATIVE_METHOD* method = env->get_class_method(env, stack, "Foo", "get"); | ||
| 1274 | |||
| 1275 | =head2 get_instance_method_static | ||
| 1276 | |||
| 1277 | C<SPVM_NATIVE_METHOD* (*get_instance_method_static)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name, const char* method_name);> | ||
| 1278 | |||
| 1279 | Searches an instance method given the basic type name I<basic_type_name> and the method name I<method_name>. | ||
| 1280 | |||
| 1281 | If found, returns it. Otherwise, returns C<NULL>. | ||
| 1282 | |||
| 1283 | Examples: | ||
| 1284 | |||
| 1285 | SPVM_NATIVE_METHOD* method = env->get_instance_method_static(env, stack, "Foo", "get"); | ||
| 1286 | |||
| 1287 | =head2 get_instance_method | ||
| 1288 | |||
| 1289 | C<SPVM_NATIVE_METHOD* (*get_instance_method)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* method_name);> | ||
| 1290 | |||
| 1291 | Searches an instance L<method|SPVM::Document::NativeAPI::Method> given the object I<object> and the method name I<method_name>. | ||
| 1292 | |||
| 1293 | If it is found, returns it. Otherwise, returns C<NULL>. | ||
| 1294 | |||
| 1295 | Examples: | ||
| 1296 | |||
| 1297 | SPVM_NATIVE_METHOD* method = env->get_instance_method(env, stack, object, "get"); | ||
| 1298 | |||
| 1299 | =head2 call_method_no_mortal | ||
| 1300 | |||
| 1301 | C<int32_t (*call_method_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>, int32_t args_width, const char* func_name, const char* file, int32_t line);> | ||
| 1302 | |||
| 1303 | Calls the method I<method> given the L<width of the argument|SPVM::Document::NativeClass/"Arguments Width"> I<args_width>. | ||
| 1304 | |||
| 1305 | The func_name, file, and line arguments are used to store the caller information of this method call. These are used by the C<caller> operator. | ||
| 1306 | |||
| 1307 | If the method throws an exception, returns a basic type ID of an error class. Otherwise, returns 0. | ||
| 1308 | |||
| 1309 | C<stack[0]> is set to the return value of the method. | ||
| 1310 | |||
| 1311 | This native API should not be used unless special purposes are intended. Normally, use L</"call_method"> native API. | ||
| 1312 | |||
| 1313 | =head2 call_method | ||
| 1314 | |||
| 1315 | C<int32_t (*call_method)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>, int32_t args_width, const char* func_name, const char* file, int32_t line);> | ||
| 1316 | |||
| 1317 | Calls L</"call_method_no_mortal"> native API and if the type of its return value is an object type, it is pushed to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">. | ||
| 1318 | |||
| 1319 | Returns the return value of L</"call_method_no_mortal">. | ||
| 1320 | |||
| 1321 | =head2 call_class_method_by_name | ||
| 1322 | |||
| 1323 | C<void (*call_class_method_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime 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);> | ||
| 1324 | |||
| 1325 | Calls a class method given the basic type name I<basic_type_name> and the method name I<method_name>. | ||
| 1326 | |||
| 1327 | The function name I<func_name>, the file path I<file>, and the line number I<line> must be given for the exception stack trace. | ||
| 1328 | |||
| 1329 | If the basic type given by I<basic_type_name> is not found, an exception is thrown. | ||
| 1330 | |||
| 1331 | If the method given by I<method_name> is not found, an exception is thrown. | ||
| 1332 | |||
| 1333 | If the found method is not a class method, an exception is thrown. | ||
| 1334 | |||
| 1335 | If an exception is thrown, C<error_id> is set to a non-zero value. Otherwise, it is set to 0. | ||
| 1336 | |||
| 1337 | Examples: | ||
| 1338 | |||
| 1339 | // Call a class method | ||
| 1340 | int32_t error_id = 0; | ||
| 1341 | int32_t total; | ||
| 1342 | { | ||
| 1343 | int32_t args_width = 2; | ||
| 1344 | stack[0].ival = 5; | ||
| 1345 | stack[1].ival = 10; | ||
| 1346 | env->call_class_method_by_name(env, stack, "MyClass", "sum", args_width, &error_id, __func__, FILE_NAME, __LINE__); | ||
| 1347 | if (error_id) { return error_id; } | ||
| 1348 | |||
| 1349 | total = stack[0].ival; | ||
| 1350 | } | ||
| 1351 | |||
| 1352 | =head2 call_instance_method_static_by_name | ||
| 1353 | |||
| 1354 | C<void (*call_instance_method_static_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime 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);> | ||
| 1355 | |||
| 1356 | Calls an instance method by the basic type name I<basic_type_name> and the method name I<method_name>. | ||
| 1357 | |||
| 1358 | The function name I<func_name>, the file path I<file>, and the line number I<line> must be given for the exception stack trace. | ||
| 1359 | |||
| 1360 | If the basic type given by I<basic_type_name> is not found, an exception is thrown. | ||
| 1361 | |||
| 1362 | If the method given by I<method_name> is not found, an exception is thrown. | ||
| 1363 | |||
| 1364 | If the found method is not an instance method, an exception is thrown. | ||
| 1365 | |||
| 1366 | If C<stack[0].oval> is C<NULL>, an exception is thrown. | ||
| 1367 | |||
| 1368 | If C<stack[0].oval> cannot be assigned to the class given by I<basic_type_name>, an exception is thrown. | ||
| 1369 | |||
| 1370 | If an exception is thrown, C<error_id> is set to a non-zero value. Otherwise, it is set to 0. | ||
| 1371 | |||
| 1372 | Examples: | ||
| 1373 | |||
| 1374 | int32_t error_id = 0; | ||
| 1375 | int32_t output; | ||
| 1376 | { | ||
| 1377 | int32_t args_width = 1; | ||
| 1378 | stack[0].oval = obj_point; | ||
| 1379 | env->call_instance_method_static_by_name(env, stack, "Point", "x", args_width, &error_id, __func__, FILE_NAME, __LINE__); | ||
| 1380 | if (error_id) { return error_id; } | ||
| 1381 | output = stack[0].ival; | ||
| 1382 | } | ||
| 1383 | |||
| 1384 | =head2 call_instance_method_by_name | ||
| 1385 | |||
| 1386 | C<void (*call_instance_method_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* method_name, int32_t args_width, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 1387 | |||
| 1388 | Calls an instance method given the method name I<method_name>. | ||
| 1389 | |||
| 1390 | The function name I<func_name>, the file path I<file>, and the line number I<line> must be given for the exception stack trace. | ||
| 1391 | |||
| 1392 | If C<stack[0].oval> is C<NULL>, an exception is thrown. | ||
| 1393 | |||
| 1394 | The type dimension of C<stack[0].oval> must be 0. Otherwise, an exception is thrown. | ||
| 1395 | |||
| 1396 | If the instance method given by I<method_name> is not found in the class of the object or its superclasses, an exception is thrown. | ||
| 1397 | |||
| 1398 | If an exception is thrown, C<error_id> is set to a non-zero value. Otherwise, it is set to 0. | ||
| 1399 | |||
| 1400 | =head2 new_object_no_mortal | ||
| 1401 | |||
| 1402 | C<SPVM_OBJ* (*new_object_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);> | ||
| 1403 | |||
| 1404 | Creates a new object given the basic type I<basic_type>. | ||
| 1405 | |||
| 1406 | I<basic_type> must not be C<NULL>. | ||
| 1407 | |||
| 1408 | I<basic_type> must be a class type. | ||
| 1409 | |||
| 1410 | If its memory allocation failed, returns C<NULL>. | ||
| 1411 | |||
| 1412 | This native API should not be used unless special purposes are intended. Normally, use L</"new_object"> native API. | ||
| 1413 | |||
| 1414 | =head2 new_object | ||
| 1415 | |||
| 1416 | C<SPVM_OBJ* (*new_object)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);> | ||
| 1417 | |||
| 1418 | Calls L</"new_object_no_mortal"> and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 1419 | |||
| 1420 | Examples: | ||
| 1421 | |||
| 1422 | SPVM_NATIVE_BASIC_TYPE* basic_type = env->get_basic_type(env, stack, "Int"); | ||
| 1423 | SPVM_OBJ* object = env->new_object(env, stack, basic_type); | ||
| 1424 | |||
| 1425 | =head2 new_object_by_name | ||
| 1426 | |||
| 1427 | C<SPVM_OBJ* (*new_object_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 1428 | |||
| 1429 | Creates a new object given the basic type name I<basic_type_name>, and returns it. | ||
| 1430 | |||
| 1431 | The created object is pushed to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">. | ||
| 1432 | |||
| 1433 | The function name I<func_name>, the file path I<file>, and the line number I<line> must be given for the exception stack trace. | ||
| 1434 | |||
| 1435 | If the basic type given by I<basic_type_name> is not found, an exception is thrown. | ||
| 1436 | |||
| 1437 | If the creation of the object failed, an exception is thrown. | ||
| 1438 | |||
| 1439 | If an exception is thrown, I<error_id> is set to a non-zero value. Otherwise, it is set to 0. | ||
| 1440 | |||
| 1441 | Examples: | ||
| 1442 | |||
| 1443 | int32_t error_id = 0; | ||
| 1444 | SPVM_OBJ* obj_point = env->new_object_by_name(env, stack, "Point", &error_id, __func__, FILE_NAME, __LINE__); | ||
| 1445 | if (error_id) { return error_id; } | ||
| 1446 | |||
| 1447 | =head2 new_pointer_object_no_mortal | ||
| 1448 | |||
| 1449 | C<SPVM_OBJ* (*new_pointer_object_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, void* pointer);> | ||
| 1450 | |||
| 1451 | Calls L</"new_object_no_mortal"> native API and sets the pointer I<pointer> to a native data to the created object, and returns it. | ||
| 1452 | |||
| 1453 | This native API should not be used unless special purposes are intended. Normally, use L</"new_pointer_object"> native API. | ||
| 1454 | |||
| 1455 | =head2 new_pointer_object | ||
| 1456 | |||
| 1457 | C<SPVM_OBJ* (*new_pointer_object)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, void* pointer);> | ||
| 1458 | |||
| 1459 | Calls L</"new_pointer_object_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 1460 | |||
| 1461 | Examples: | ||
| 1462 | |||
| 1463 | SPVM_NATIVE_BASIC_TYPE* basic_type = env->get_basic_type(env, stack, "MyTm"); | ||
| 1464 | void* native_ptr = env->new_memory_block(env, stack, sizeof(struct tm)); | ||
| 1465 | SPVM_OBJ* obj_tm = env->new_pointer_object(env, stack, basic_type, native_ptr); | ||
| 1466 | |||
| 1467 | =head2 new_pointer_object_by_name | ||
| 1468 | |||
| 1469 | C<SPVM_OBJ* (*new_pointer_object_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name, void* pointer, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 1470 | |||
| 1471 | Calls L</"new_object_by_name"> native API and sets the pointer I<pointer> to a native data to the created object, and returns it. | ||
| 1472 | |||
| 1473 | Examples: | ||
| 1474 | |||
| 1475 | int32_t error_id = 0; | ||
| 1476 | void* native_ptr = env->new_memory_block(env, stack, 16); | ||
| 1477 | SPVM_OBJ* obj = env->new_pointer_object_by_name(env, stack, "TestCase::Pointer", native_ptr, &error_id, __func__, FILE_NAME, __LINE__); | ||
| 1478 | if (error_id) { return error_id; } | ||
| 1479 | |||
| 1480 | =head2 get_pointer | ||
| 1481 | |||
| 1482 | C<void* (*get_pointer)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 1483 | |||
| 1484 | Returns L<pointer value|SPVM::Document::NativeClass/"Pointer Value"> of the object I<object>. | ||
| 1485 | |||
| 1486 | Examples: | ||
| 1487 | |||
| 1488 | struct tm* tm = (struct tm*)env->get_pointer(env, stack, obj_tm); | ||
| 1489 | |||
| 1490 | =head2 set_pointer | ||
| 1491 | |||
| 1492 | C<void (*set_pointer)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, void* pointer);> | ||
| 1493 | |||
| 1494 | Sets the L<pointer value|SPVM::Document::NativeClass/"Pointer Value"> of the object I<object> to the pointer I<pointer>. | ||
| 1495 | |||
| 1496 | =head2 new_string_nolen_no_mortal | ||
| 1497 | |||
| 1498 | C<SPVM_OBJ* (*new_string_nolen_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* bytes);> | ||
| 1499 | |||
| 1500 | Creates a new string object given a C string I<bytes>. I<bytes> must end with C<\0>. | ||
| 1501 | |||
| 1502 | If its memory allocation failed, returns C<NULL>. | ||
| 1503 | |||
| 1504 | This native API should not be used unless special purposes are intended. Normally, use L</"new_string_nolen"> native API. | ||
| 1505 | |||
| 1506 | =head2 new_string_nolen | ||
| 1507 | |||
| 1508 | C<SPVM_OBJ* (*new_string_nolen)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* bytes);> | ||
| 1509 | |||
| 1510 | Calls L</"new_string_nolen_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 1511 | |||
| 1512 | Examples: | ||
| 1513 | |||
| 1514 | SPVM_OBJ* str_obj = env->new_string_nolen(env, stack, "Hello World"); | ||
| 1515 | |||
| 1516 | =head2 new_string_no_mortal | ||
| 1517 | |||
| 1518 | C<SPVM_OBJ* (*new_string_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* bytes, int32_t length);> | ||
| 1519 | |||
| 1520 | Creates a new string object given the C string I<bytes> and the length I<length>, and returns it. | ||
| 1521 | |||
| 1522 | If its memory allocation failed, returns C<NULL>. | ||
| 1523 | |||
| 1524 | If the actual length of I<bytes> is less than I<length>, or if I<bytes> is C<NULL>, the remaining part up to I<length> is filled with C<\0>. | ||
| 1525 | |||
| 1526 | This native API should not be used unless special purposes are intended. Normally, use L</"new_string"> native API. | ||
| 1527 | |||
| 1528 | =head2 new_string | ||
| 1529 | |||
| 1530 | C<SPVM_OBJ* (*new_string)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* bytes, int32_t length);> | ||
| 1531 | |||
| 1532 | Calls L</"new_string_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 1533 | |||
| 1534 | Examples: | ||
| 1535 | |||
| 1536 | SPVM_OBJ* str_obj = env->new_string(env, stack, "Hello \0World", 11); | ||
| 1537 | |||
| 1538 | =head2 new_byte_array_no_mortal | ||
| 1539 | |||
| 1540 | C<SPVM_OBJ* (*new_byte_array_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t length);> | ||
| 1541 | |||
| 1542 | Creates a new array of the C<byte[]> type given the length I<length>, and returns it. | ||
| 1543 | |||
| 1544 | If its memory allocation failed, returns C<NULL>. | ||
| 1545 | |||
| 1546 | This native API should not be used unless special purposes are intended. Normally, use L</"new_byte_array"> native API. | ||
| 1547 | |||
| 1548 | =head2 new_byte_array | ||
| 1549 | |||
| 1550 | C<SPVM_OBJ* (*new_byte_array)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t length);> | ||
| 1551 | |||
| 1552 | Calls L</"new_byte_array_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 1553 | |||
| 1554 | Examples: | ||
| 1555 | |||
| 1556 | SPVM_OBJ* byte_array = env->new_byte_array(env, stack, 100); | ||
| 1557 | |||
| 1558 | =head2 new_short_array_no_mortal | ||
| 1559 | |||
| 1560 | C<SPVM_OBJ* (*new_short_array_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t length);> | ||
| 1561 | |||
| 1562 | Creates a new array of the C<short[]> type given the length I<length>, and returns it. | ||
| 1563 | |||
| 1564 | If its memory allocation failed, returns C<NULL>. | ||
| 1565 | |||
| 1566 | This native API should not be used unless special purposes are intended. Normally, use L</"new_short_array"> native API. | ||
| 1567 | |||
| 1568 | =head2 new_short_array | ||
| 1569 | |||
| 1570 | C<SPVM_OBJ* (*new_short_array)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t length);> | ||
| 1571 | |||
| 1572 | Calls L</"new_short_array_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 1573 | |||
| 1574 | Examples: | ||
| 1575 | |||
| 1576 | SPVM_OBJ* short_array = env->new_short_array(env, stack, 100); | ||
| 1577 | |||
| 1578 | =head2 new_int_array_no_mortal | ||
| 1579 | |||
| 1580 | C<SPVM_OBJ* (*new_int_array_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t length);> | ||
| 1581 | |||
| 1582 | Creates a new array of the C<int[]> type given the length I<length>, and returns it. | ||
| 1583 | |||
| 1584 | If its memory allocation failed, returns C<NULL>. | ||
| 1585 | |||
| 1586 | This native API should not be used unless special purposes are intended. Normally, use L</"new_int_array"> native API. | ||
| 1587 | |||
| 1588 | =head2 new_int_array | ||
| 1589 | |||
| 1590 | C<SPVM_OBJ* (*new_int_array)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t length);> | ||
| 1591 | |||
| 1592 | Calls L</"new_int_array_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 1593 | |||
| 1594 | Examples: | ||
| 1595 | |||
| 1596 | SPVM_OBJ* int_array = env->new_int_array(env, stack, 100); | ||
| 1597 | |||
| 1598 | =head2 new_long_array_no_mortal | ||
| 1599 | |||
| 1600 | C<SPVM_OBJ* (*new_long_array_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t length);> | ||
| 1601 | |||
| 1602 | Creates a new array of the C<long[]> type given the length I<length>, and returns it. | ||
| 1603 | |||
| 1604 | If its memory allocation failed, returns C<NULL>. | ||
| 1605 | |||
| 1606 | This native API should not be used unless special purposes are intended. Normally, use L</"new_long_array"> native API. | ||
| 1607 | |||
| 1608 | =head2 new_long_array | ||
| 1609 | |||
| 1610 | C<SPVM_OBJ* (*new_long_array)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t length);> | ||
| 1611 | |||
| 1612 | Calls L</"new_long_array_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 1613 | |||
| 1614 | Examples: | ||
| 1615 | |||
| 1616 | SPVM_OBJ* long_array = env->new_long_array(env, stack, 100); | ||
| 1617 | |||
| 1618 | =head2 new_float_array_no_mortal | ||
| 1619 | |||
| 1620 | C<SPVM_OBJ* (*new_float_array_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t length);> | ||
| 1621 | |||
| 1622 | Creates a new array of the C<float[]> type given the length I<length>, and returns it. | ||
| 1623 | |||
| 1624 | If its memory allocation failed, returns C<NULL>. | ||
| 1625 | |||
| 1626 | This native API should not be used unless special purposes are intended. Normally, use L</"new_float_array"> native API. | ||
| 1627 | |||
| 1628 | =head2 new_float_array | ||
| 1629 | |||
| 1630 | C<SPVM_OBJ* (*new_float_array)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t length);> | ||
| 1631 | |||
| 1632 | Calls L</"new_float_array_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 1633 | |||
| 1634 | Examples: | ||
| 1635 | |||
| 1636 | SPVM_OBJ* float_array = env->new_float_array(env, stack, 100); | ||
| 1637 | |||
| 1638 | =head2 new_double_array_no_mortal | ||
| 1639 | |||
| 1640 | C<SPVM_OBJ* (*new_double_array_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t length);> | ||
| 1641 | |||
| 1642 | Creates a new array of the C<double[]> type given the length I<length>, and returns it. | ||
| 1643 | |||
| 1644 | If its memory allocation failed, returns C<NULL>. | ||
| 1645 | |||
| 1646 | This native API should not be used unless special purposes are intended. Normally, use L</"new_double_array"> native API. | ||
| 1647 | |||
| 1648 | =head2 new_double_array | ||
| 1649 | |||
| 1650 | C<SPVM_OBJ* (*new_double_array)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t length);> | ||
| 1651 | |||
| 1652 | Calls L</"new_double_array_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 1653 | |||
| 1654 | Examples: | ||
| 1655 | |||
| 1656 | SPVM_OBJ* double_array = env->new_double_array(env, stack, 100); | ||
| 1657 | |||
| 1658 | =head2 new_object_array_no_mortal | ||
| 1659 | |||
| 1660 | C<SPVM_OBJ* (*new_object_array_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, int32_t length);> | ||
| 1661 | |||
| 1662 | Creates a new array of an object type given the basic type I<basic_type> and the array length I<length>, and returns it. | ||
| 1663 | |||
| 1664 | If its memory allocation failed, returns C<NULL>. | ||
| 1665 | |||
| 1666 | This native API should not be used unless special purposes are intended. Normally, use L</"new_object_array"> native API. | ||
| 1667 | |||
| 1668 | =head2 new_object_array | ||
| 1669 | |||
| 1670 | C<SPVM_OBJ* (*new_object_array)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, int32_t length);> | ||
| 1671 | |||
| 1672 | Calls L</"new_object_array_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 1673 | |||
| 1674 | Examples: | ||
| 1675 | |||
| 1676 | SPVM_NATIVE_BASIC_TYPE* basic_type = env->get_basic_type(env, stack, "Int"); | ||
| 1677 | SPVM_OBJ* object_array = env->new_object_array(env, stack, basic_type, 100); | ||
| 1678 | |||
| 1679 | =head2 new_object_array_by_name | ||
| 1680 | |||
| 1681 | C<SPVM_OBJ* (*new_object_array_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name, int32_t length, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 1682 | |||
| 1683 | Creates a new object array given the basic type name I<basic_type_name> and the array length I<length>, and returns it. | ||
| 1684 | |||
| 1685 | The created array is pushed to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">. | ||
| 1686 | |||
| 1687 | The function name I<func_name>, the file path I<file>, and the line number I<line> must be given for the exception stack trace. | ||
| 1688 | |||
| 1689 | If the basic type given by I<basic_type_name> is not found, an exception is thrown. | ||
| 1690 | |||
| 1691 | If the creation of the array failed, an exception is thrown. | ||
| 1692 | |||
| 1693 | If an exception is thrown, I<error_id> is set to a non-zero value. Otherwise, it is set to 0. | ||
| 1694 | |||
| 1695 | =head2 new_string_array | ||
| 1696 | |||
| 1697 | C<SPVM_OBJ* (*new_string_array)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t length);> | ||
| 1698 | |||
| 1699 | Calls L</"new_string_array_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 1700 | |||
| 1701 | =head2 new_muldim_array_no_mortal | ||
| 1702 | |||
| 1703 | C<SPVM_OBJ* (*new_muldim_array_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, int32_t type_dimension, int32_t length);> | ||
| 1704 | |||
| 1705 | Creates a new multi-dimensional array given the basic type I<basic_type>, the type dimension I<type_dimension>, and the array length I<length>, and returns it. | ||
| 1706 | |||
| 1707 | If its memory allocation failed, returns C<NULL>. | ||
| 1708 | |||
| 1709 | I<type_dimension> must be less than or equal to 255. | ||
| 1710 | |||
| 1711 | This native API should not be used unless special purposes are intended. Normally, use L</"new_muldim_array"> native API. | ||
| 1712 | |||
| 1713 | =head2 new_muldim_array | ||
| 1714 | |||
| 1715 | C<SPVM_OBJ* (*new_muldim_array)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, int32_t type_dimension, int32_t length);> | ||
| 1716 | |||
| 1717 | Calls L</"new_muldim_array_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 1718 | |||
| 1719 | Examples: | ||
| 1720 | |||
| 1721 | // Creates 2-dimensional array - new Int[][100]. | ||
| 1722 | SPVM_NATIVE_BASIC_TYPE* basic_type = env->get_basic_type(env, stack, "Int"); | ||
| 1723 | SPVM_OBJ* multi_array = env->new_muldim_array(env, stack, basic_type, 2, 100); | ||
| 1724 | |||
| 1725 | =head2 new_muldim_array_by_name | ||
| 1726 | |||
| 1727 | C<SPVM_OBJ* (*new_muldim_array_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name, int32_t type_dimension, int32_t length, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 1728 | |||
| 1729 | Creates a new multi-dimensional array given the basic type name I<basic_type_name>, the type dimension I<type_dimension>, and the array length I<length>, and returns it. | ||
| 1730 | |||
| 1731 | The created array is pushed to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">. | ||
| 1732 | |||
| 1733 | The function name I<func_name>, the file path I<file>, and the line number I<line> must be given for the exception stack trace. | ||
| 1734 | |||
| 1735 | If the basic type given by I<basic_type_name> is not found, an exception is thrown. | ||
| 1736 | |||
| 1737 | If the creation of the array failed, an exception is thrown. | ||
| 1738 | |||
| 1739 | If an exception is thrown, I<error_id> is set to a non-zero value. Otherwise, it is set to 0. | ||
| 1740 | |||
| 1741 | =head2 new_mulnum_array_no_mortal | ||
| 1742 | |||
| 1743 | C<SPVM_OBJ* (*new_mulnum_array_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, int32_t length);> | ||
| 1744 | |||
| 1745 | Creates a new multi-numeric array given the basic type I<basic_type> and the array length I<length>, and returns it. | ||
| 1746 | |||
| 1747 | If its memory allocation failed, returns C<NULL>. | ||
| 1748 | |||
| 1749 | This native API should not be used unless special purposes are intended. Normally, use L</"new_mulnum_array"> native API. | ||
| 1750 | |||
| 1751 | =head2 new_mulnum_array | ||
| 1752 | |||
| 1753 | C<SPVM_OBJ* (*new_mulnum_array)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, int32_t length);> | ||
| 1754 | |||
| 1755 | Calls L</"new_mulnum_array_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 1756 | |||
| 1757 | Examples: | ||
| 1758 | |||
| 1759 | SPVM_NATIVE_BASIC_TYPE* basic_type = env->get_basic_type(env, stack, "Complex_2d"); | ||
| 1760 | SPVM_OBJ* value_array = env->new_mulnum_array(env, stack, basic_type, 100); | ||
| 1761 | |||
| 1762 | =head2 new_mulnum_array_by_name | ||
| 1763 | |||
| 1764 | C<SPVM_OBJ* (*new_mulnum_array_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name, int32_t length, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 1765 | |||
| 1766 | Creates a new multi-numeric array given the basic type name I<basic_type_name> and the array length I<length>, and returns it. | ||
| 1767 | |||
| 1768 | The created array is pushed to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">. | ||
| 1769 | |||
| 1770 | The function name I<func_name>, the file path I<file>, and the line number I<line> must be given for the exception stack trace. | ||
| 1771 | |||
| 1772 | If the basic type given by I<basic_type_name> is not found, an exception is thrown. | ||
| 1773 | |||
| 1774 | If the creation of the array failed, an exception is thrown. | ||
| 1775 | |||
| 1776 | If an exception is thrown, I<error_id> is set to a non-zero value. Otherwise, it is set to 0. | ||
| 1777 | |||
| 1778 | =head2 new_array_proto_no_mortal | ||
| 1779 | |||
| 1780 | C<SPVM_OBJ* (*new_array_proto_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* array, int32_t length);> | ||
| 1781 | |||
| 1782 | Creates a new array given the prototype array I<array> and the length I<length>, and returns it. | ||
| 1783 | |||
| 1784 | If I<array> is C<NULL>, returns C<NULL>. | ||
| 1785 | |||
| 1786 | If the type of I<array> is not an array type, returns C<NULL>. | ||
| 1787 | |||
| 1788 | If I<length> is less than 0, returns C<NULL>. | ||
| 1789 | |||
| 1790 | This native API should not be used unless special purposes are intended. Normally, use L</"new_array_proto"> native API. | ||
| 1791 | |||
| 1792 | =head2 new_array_proto | ||
| 1793 | |||
| 1794 | C<SPVM_OBJ* (*new_array_proto)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* array, int32_t length);> | ||
| 1795 | |||
| 1796 | Calls L</"new_array_proto_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 1797 | |||
| 1798 | =head2 length | ||
| 1799 | |||
| 1800 | C<int32_t (*length)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 1801 | |||
| 1802 | Returns the length of the object I<object>. | ||
| 1803 | |||
| 1804 | I<object> must be defined. | ||
| 1805 | |||
| 1806 | If I<object> is an array, its array length is returned. | ||
| 1807 | |||
| 1808 | If I<object> is a string, its string length is returned. | ||
| 1809 | |||
| 1810 | Otherwise 0 is returned. | ||
| 1811 | |||
| 1812 | Examples: | ||
| 1813 | |||
| 1814 | int32_t length = env->length(env, stack, object); | ||
| 1815 | |||
| 1816 | =head2 get_elems_byte | ||
| 1817 | |||
| 1818 | C<int8_t* (*get_elems_byte)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* array);> | ||
| 1819 | |||
| 1820 | Returns the pointer to the elements of the byte array I<array>. | ||
| 1821 | |||
| 1822 | Examples: | ||
| 1823 | |||
| 1824 | int8_t* values = env->get_elems_byte(env, stack, array); | ||
| 1825 | values[3] = 5; | ||
| 1826 | |||
| 1827 | =head2 get_elems_short | ||
| 1828 | |||
| 1829 | C<int16_t* (*get_elems_short)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* array);> | ||
| 1830 | |||
| 1831 | Returns the pointer to the elements of the short array I<array>. | ||
| 1832 | |||
| 1833 | Examples: | ||
| 1834 | |||
| 1835 | int16_t* values = env->get_elems_short(env, stack, array); | ||
| 1836 | values[3] = 5; | ||
| 1837 | |||
| 1838 | =head2 get_elems_int | ||
| 1839 | |||
| 1840 | C<int32_t* (*get_elems_int)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* array);> | ||
| 1841 | |||
| 1842 | Returns the pointer to the elements of the int array I<array>. | ||
| 1843 | |||
| 1844 | Examples: | ||
| 1845 | |||
| 1846 | int32_t* values = env->get_elems_int(env, stack, array); | ||
| 1847 | values[3] = 5; | ||
| 1848 | |||
| 1849 | =head2 get_elems_long | ||
| 1850 | |||
| 1851 | C<int64_t* (*get_elems_long)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* array);> | ||
| 1852 | |||
| 1853 | Returns the pointer to the elements of the long array I<array>. | ||
| 1854 | |||
| 1855 | Examples: | ||
| 1856 | |||
| 1857 | int64_t* values = env->get_elems_long(env, stack, array); | ||
| 1858 | values[3] = 5; | ||
| 1859 | |||
| 1860 | =head2 get_elems_float | ||
| 1861 | |||
| 1862 | C<float* (*get_elems_float)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* array);> | ||
| 1863 | |||
| 1864 | Returns the pointer to the elements of the float array I<array>. | ||
| 1865 | |||
| 1866 | Examples: | ||
| 1867 | |||
| 1868 | float* values = env->get_elems_float(env, stack, array); | ||
| 1869 | values[3] = 1.5f; | ||
| 1870 | |||
| 1871 | =head2 get_elems_double | ||
| 1872 | |||
| 1873 | C<double* (*get_elems_double)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* array);> | ||
| 1874 | |||
| 1875 | Returns the pointer to the elements of the double array I<array>. | ||
| 1876 | |||
| 1877 | Examples: | ||
| 1878 | |||
| 1879 | double* values = env->get_elems_double(env, stack, array); | ||
| 1880 | values[3] = 1.5; | ||
| 1881 | |||
| 1882 | =head2 get_elem_object | ||
| 1883 | |||
| 1884 | C<SPVM_OBJ* (*get_elem_object)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* array, int32_t index);> | ||
| 1885 | |||
| 1886 | Returns the element of the array I<array> at the index I<index>. | ||
| 1887 | |||
| 1888 | Examples: | ||
| 1889 | |||
| 1890 | SPVM_OBJ* object = env->get_elem_object(env, stack, array, 3); | ||
| 1891 | |||
| 1892 | =head2 get_elem_string | ||
| 1893 | |||
| 1894 | C<SPVM_OBJ* (*get_elem_string)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* array, int32_t index);> | ||
| 1895 | |||
| 1896 | Calls L</"get_elem_object"> native API, and returns its return value. | ||
| 1897 | |||
| 1898 | =head2 set_elem_object | ||
| 1899 | |||
| 1900 | C<void (*set_elem_object)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* array, int32_t index, SPVM_OBJ* object);> | ||
| 1901 | |||
| 1902 | Sets I<object> to the element of the array I<array> at the index I<index>. | ||
| 1903 | |||
| 1904 | Examples: | ||
| 1905 | |||
| 1906 | env->set_elem_object(env, stack, array, 3, object); | ||
| 1907 | |||
| 1908 | =head2 set_elem_string | ||
| 1909 | |||
| 1910 | C<void (*set_elem_string)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* array, int32_t index, SPVM_OBJ* string);> | ||
| 1911 | |||
| 1912 | Calls L</"set_elem_object"> native API. | ||
| 1913 | |||
| 1914 | =head2 get_chars | ||
| 1915 | |||
| 1916 | C<const char* (*get_chars)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* string_object);> | ||
| 1917 | |||
| 1918 | Returns the pointer to the characters stored in the string C<string_object>. | ||
| 1919 | |||
| 1920 | Examples: | ||
| 1921 | |||
| 1922 | const char* chars = env->get_chars(env, stack, obj_string); | ||
| 1923 | |||
| 1924 | =head2 get_bool_object_value | ||
| 1925 | |||
| 1926 | C<int32_t (*get_bool_object_value)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* bool_object);> | ||
| 1927 | |||
| 1928 | Returns the value stored in L<Bool|SPVM::Bool> object I<bool_object>. | ||
| 1929 | |||
| 1930 | I<bool_object> must not be C<NULL>. | ||
| 1931 | |||
| 1932 | Examples: | ||
| 1933 | |||
| 1934 | int32_t bool_value = env->get_bool_object_value(env, stack, bool_object); | ||
| 1935 | |||
| 1936 | =head2 concat_no_mortal | ||
| 1937 | |||
| 1938 | C<SPVM_OBJ* (*concat_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* string1, SPVM_OBJ* string2);> | ||
| 1939 | |||
| 1940 | Creates a new string by concatenating two strings I<string1> and I<string2>, and returns it. | ||
| 1941 | |||
| 1942 | If its memory allocation failed, returns C<NULL>. | ||
| 1943 | |||
| 1944 | This native API should not be used unless special purposes are intended. Normally, use L</"concat"> native API. | ||
| 1945 | |||
| 1946 | =head2 concat | ||
| 1947 | |||
| 1948 | C<SPVM_OBJ* (*concat)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* string1, SPVM_OBJ* string2);> | ||
| 1949 | |||
| 1950 | Calls L</"concat_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 1951 | |||
| 1952 | =head2 shorten | ||
| 1953 | |||
| 1954 | C<void (*shorten)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* string, int32_t new_length);> | ||
| 1955 | |||
| 1956 | Shortens the string C<string> to the length I<new_length>. | ||
| 1957 | |||
| 1958 | Characters whose index is greater than or equal to I<new_length> are filled with C<\0>. | ||
| 1959 | |||
| 1960 | If the string C<string> is C<NULL>, nothing is performed. | ||
| 1961 | |||
| 1962 | If the type of C<string> is not the string type, nothing is performed. | ||
| 1963 | |||
| 1964 | If C<string> is read-only, nothing is performed. | ||
| 1965 | |||
| 1966 | If I<new_length> is not greater than or equal to 0, nothing is performed. | ||
| 1967 | |||
| 1968 | If I<new_length> is greater than the current length of I<string>, nothing is performed. | ||
| 1969 | |||
| 1970 | =head2 make_read_only | ||
| 1971 | |||
| 1972 | C<void (*make_read_only)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* string);> | ||
| 1973 | |||
| 1974 | Makes the string I<string> read-only. | ||
| 1975 | |||
| 1976 | If I<string> is C<NULL>, no operation is performed. | ||
| 1977 | |||
| 1978 | =head2 is_read_only | ||
| 1979 | |||
| 1980 | C<int32_t (*is_read_only)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* string);> | ||
| 1981 | |||
| 1982 | If the string I<string> is not C<NULL> and it is read-only, returns 1, otherwise returns 0. | ||
| 1983 | |||
| 1984 | =head2 print | ||
| 1985 | |||
| 1986 | C<void (*print)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* string);> | ||
| 1987 | |||
| 1988 | Prints the string I<string> to L<SPVM's standard output|SPVM::Document::Language::System/"Standard Streams">. | ||
| 1989 | |||
| 1990 | =head2 print_stderr | ||
| 1991 | |||
| 1992 | C<void (*print_stderr)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* string);> | ||
| 1993 | |||
| 1994 | Prints the string I<string> to L<SPVM's standard error|SPVM::Document::Language::System/"Standard Streams">. | ||
| 1995 | |||
| 1996 | If I<string> is C<NULL>, no output is produced. | ||
| 1997 | |||
| 1998 | =head2 dump_no_mortal | ||
| 1999 | |||
| 2000 | C<SPVM_OBJ* (*dump_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2001 | |||
| 2002 | Performs the L<dump|SPVM::Document::Language::Operators/"dump"> operation, and returns its return value. | ||
| 2003 | |||
| 2004 | This native API should not be used unless special purposes are intended. Normally, use L</"dump"> native API. | ||
| 2005 | |||
| 2006 | =head2 dump | ||
| 2007 | |||
| 2008 | C<SPVM_OBJ* (*dump)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2009 | |||
| 2010 | Calls L</"dump_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 2011 | |||
| 2012 | =head2 dumpc | ||
| 2013 | |||
| 2014 | C<const char* (*dumpc)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2015 | |||
| 2016 | Calls L</"dump"> native API, then calls L</"get_chars"> native API with the returned string object, and returns the character pointer. | ||
| 2017 | |||
| 2018 | =head2 copy_no_mortal | ||
| 2019 | |||
| 2020 | C<SPVM_OBJ* (*copy_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2021 | |||
| 2022 | The type of the object I<object> must be a string type, a numeric array type, or a multi-numeric array type. | ||
| 2023 | |||
| 2024 | If the type of the object I<object> is the string type, creates a new string and copies the characters stored in I<object> to it, and returns the new string object. | ||
| 2025 | |||
| 2026 | If the type of the object I<object> is a numeric array type or a multi-numeric array type, creates a new array using the type of I<object> as a prototype and copies the elements stored in I<object> to it, and returns the new array object. | ||
| 2027 | |||
| 2028 | If I<object> is C<NULL>, returns C<NULL>. | ||
| 2029 | |||
| 2030 | This native API should not be used unless special purposes are intended. Normally, use L</"copy"> native API. | ||
| 2031 | |||
| 2032 | =head2 copy | ||
| 2033 | |||
| 2034 | C<SPVM_OBJ* (*copy)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2035 | |||
| 2036 | Calls L</"copy_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 2037 | |||
| 2038 | =head2 get_spvm_version_string | ||
| 2039 | |||
| 2040 | C<const char* (*get_spvm_version_string)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2041 | |||
| 2042 | Returns the L<version string|SPVM::Document::Language::Class/"Version String"> of the SPVM language. | ||
| 2043 | |||
| 2044 | =head2 get_spvm_version_number | ||
| 2045 | |||
| 2046 | C<double (*get_spvm_version_number)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2047 | |||
| 2048 | Calls L</"get_spvm_version_string"> native API and converts its return value to a C<double> value. | ||
| 2049 | |||
| 2050 | =head2 get_version_string | ||
| 2051 | |||
| 2052 | C<const char* (*get_version_string)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);> | ||
| 2053 | |||
| 2054 | Returns the L<version string|SPVM::Document::Language::Class/"Version String"> of the basic type I<basic_type>. | ||
| 2055 | |||
| 2056 | If the version string is not defined, returns C<NULL>. | ||
| 2057 | |||
| 2058 | =head2 get_version_number | ||
| 2059 | |||
| 2060 | C<double (*get_version_number)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);> | ||
| 2061 | |||
| 2062 | Calls L</"get_version_string"> native API and converts its return value to a C<double> value. | ||
| 2063 | |||
| 2064 | If the version string is not defined, returns -1. | ||
| 2065 | |||
| 2066 | =head2 die | ||
| 2067 | |||
| 2068 | C<int32_t (*die)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* exception_format, const char* func_name, const char* file, int32_t line, ...);> | ||
| 2069 | |||
| 2070 | Sets an exception message using a format string and its metadata, then returns the basic type ID of the error class. | ||
| 2071 | |||
| 2072 | I<exception_format> is a format string in the style of C<printf>. | ||
| 2073 | |||
| 2074 | I<func_name>, I<file>, and I<line> are metadata that indicate where the exception occurred. | ||
| 2075 | |||
| 2076 | The subsequent arguments are values to be formatted according to I<exception_format>. | ||
| 2077 | |||
| 2078 | Examples: | ||
| 2079 | |||
| 2080 | return env->die(env, stack, "Error: %s", __func__, FILE_NAME, __LINE__, "Something went wrong"); | ||
| 2081 | |||
| 2082 | int32_t id = 10; | ||
| 2083 | return env->die(env, stack, "Invalid ID %d", __func__, FILE_NAME, __LINE__, id); | ||
| 2084 | |||
| 2085 | =head2 get_exception | ||
| 2086 | |||
| 2087 | C<SPVM_OBJ* (*get_exception)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2088 | |||
| 2089 | Returns the value of the L<exception variable|SPVM::Document::Language::ExceptionHandling/"Exception Variable">. | ||
| 2090 | |||
| 2091 | The return value is an SPVM string object. | ||
| 2092 | |||
| 2093 | =head2 get_exception_chars | ||
| 2094 | |||
| 2095 | C<const char* (*get_exception_chars)(SPVM_ENV* env, SPVM_VALUE* stack);> | ||
| 2096 | |||
| 2097 | =head2 get_exception_chars | ||
| 2098 | |||
| 2099 | C<const char* (*get_exception_chars)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2100 | |||
| 2101 | Returns the C-style string of the L<exception variable|SPVM::Document::Language::ExceptionHandling/"Exception Variable">. | ||
| 2102 | |||
| 2103 | This native API calls L<get_exception|/"get_exception"> native API. If its return value is NULL, returns NULL. | ||
| 2104 | |||
| 2105 | Otherwise, returns the C-style string obtained by calling L<get_chars|/"get_chars"> native API on the return value of L<get_exception|/"get_exception">. | ||
| 2106 | |||
| 2107 | =head2 set_exception | ||
| 2108 | |||
| 2109 | C<void (*set_exception)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* exception);> | ||
| 2110 | |||
| 2111 | Sets I<exception> to the L<exception variable|SPVM::Document::Language::ExceptionHandling/"Exception Variable">. | ||
| 2112 | |||
| 2113 | I<exception> must be an SPVM string object or C<NULL>. | ||
| 2114 | |||
| 2115 | =head2 is_string | ||
| 2116 | |||
| 2117 | C<int32_t (*is_string)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2118 | |||
| 2119 | If the object I<object> is not C<NULL> and its type is the string type, returns 1, otherwise returns 0. | ||
| 2120 | |||
| 2121 | =head2 is_class | ||
| 2122 | |||
| 2123 | C<int32_t (*is_class)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2124 | |||
| 2125 | If the object I<object> is not C<NULL> and its type is a class type, returns 1, otherwise returns 0. | ||
| 2126 | |||
| 2127 | =head2 is_pointer_class | ||
| 2128 | |||
| 2129 | C<int32_t (*is_pointer_class)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2130 | |||
| 2131 | If the object I<object> is not C<NULL> and its class has the C<pointer> attribute, returns 1, otherwise returns 0. | ||
| 2132 | |||
| 2133 | =head2 is_array | ||
| 2134 | |||
| 2135 | C<int32_t (*is_array)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2136 | |||
| 2137 | If the object I<object> is not C<NULL> and its type is an array type, returns 1, otherwise returns 0. | ||
| 2138 | |||
| 2139 | =head2 is_object_array | ||
| 2140 | |||
| 2141 | C<int32_t (*is_object_array)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2142 | |||
| 2143 | If the object I<object> is not C<NULL> and its type is an object array type, returns 1, otherwise returns 0. | ||
| 2144 | |||
| 2145 | =head2 is_numeric_array | ||
| 2146 | |||
| 2147 | C<int32_t (*is_numeric_array)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2148 | |||
| 2149 | If the object I<object> is not C<NULL> and its type is a numeric array type, returns 1, otherwise returns 0. | ||
| 2150 | |||
| 2151 | =head2 is_mulnum_array | ||
| 2152 | |||
| 2153 | C<int32_t (*is_mulnum_array)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2154 | |||
| 2155 | If the object I<object> is not C<NULL> and its type is a multi-numeric array type, returns 1, otherwise returns 0. | ||
| 2156 | |||
| 2157 | =head2 isa | ||
| 2158 | |||
| 2159 | C<int32_t (*isa)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, int32_t type_dimension);> | ||
| 2160 | |||
| 2161 | If the object I<object> satisfies the L<assignment requirement|SPVM::Document::Language::Types/"Assignment Requirement"> without data conversion to the type given by the basic type I<basic_type> and the type dimension I<type_dimension>, returns 1, otherwise returns 0. | ||
| 2162 | |||
| 2163 | =head2 isa_by_name | ||
| 2164 | |||
| 2165 | C<int32_t (*isa_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* basic_type_name, int32_t type_dimension);> | ||
| 2166 | |||
| 2167 | If the basic type given by I<basic_type_name> is not found, returns 0. | ||
| 2168 | |||
| 2169 | If the object I<object> satisfies the L<assignment requirement|SPVM::Document::Language::Types/"Assignment Requirement"> without data conversion to the type given by I<basic_type_name> and the type dimension I<type_dimension>, returns 1, otherwise returns 0. | ||
| 2170 | |||
| 2171 | =head2 is_type | ||
| 2172 | |||
| 2173 | C<int32_t (*is_type)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, int32_t type_dimension);> | ||
| 2174 | |||
| 2175 | If the type of the object I<object> is equal to the type given by the basic type I<basic_type> and the type dimension I<type_dimension>, returns 1, otherwise returns 0. | ||
| 2176 | |||
| 2177 | I<object> must not be C<NULL>. | ||
| 2178 | |||
| 2179 | =head2 is_type_by_name | ||
| 2180 | |||
| 2181 | C<int32_t (*is_type_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* basic_type_name, int32_t type_dimension);> | ||
| 2182 | |||
| 2183 | If the basic type given by I<basic_type_name> is not found, returns 0. | ||
| 2184 | |||
| 2185 | If the object I<object> is not C<NULL> and its type is equal to the type given by I<basic_type_name> and the type dimension I<type_dimension>, returns 1, otherwise returns 0. | ||
| 2186 | |||
| 2187 | =head2 elem_isa | ||
| 2188 | |||
| 2189 | C<int32_t (*elem_isa)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* array, SPVM_OBJ* element);> | ||
| 2190 | |||
| 2191 | If the element I<element> satisfies the L<assignment requirement|SPVM::Document::Language::Types/"Assignment Requirement"> without data conversion to the element type of the array I<array>, returns 1, otherwise returns 0. | ||
| 2192 | |||
| 2193 | =head2 get_elem_size | ||
| 2194 | |||
| 2195 | C<int32_t (*get_elem_size)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* array);> | ||
| 2196 | |||
| 2197 | Returns the byte size of an element of the array I<array>. | ||
| 2198 | |||
| 2199 | =head2 get_type_name_no_mortal | ||
| 2200 | |||
| 2201 | C<SPVM_OBJ* (*get_type_name_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2202 | |||
| 2203 | Creates a new string object that represents the type name of the object I<object>, and returns it. | ||
| 2204 | |||
| 2205 | If its memory allocation failed, returns C<NULL>. | ||
| 2206 | |||
| 2207 | This native API should not be used unless special purposes are intended. Normally, use L</"get_type_name"> native API. | ||
| 2208 | |||
| 2209 | =head2 get_type_name | ||
| 2210 | |||
| 2211 | C<SPVM_OBJ* (*get_type_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2212 | |||
| 2213 | Calls L</"get_type_name_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 2214 | |||
| 2215 | =head2 get_compile_type_name_no_mortal | ||
| 2216 | |||
| 2217 | C<SPVM_OBJ* (*get_compile_type_name_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name, int32_t type_dimension, int32_t type_flag);> | ||
| 2218 | |||
| 2219 | Creates a new string object that represents the compile-time type name of the type given by I<basic_type_name>, I<type_dimension>, and I<type_flag>, and returns it. | ||
| 2220 | |||
| 2221 | If its memory allocation failed, returns C<NULL>. | ||
| 2222 | |||
| 2223 | This native API should not be used unless special purposes are intended. Normally, use L</"get_compile_type_name"> native API. | ||
| 2224 | |||
| 2225 | =head2 get_compile_type_name | ||
| 2226 | |||
| 2227 | C<SPVM_OBJ* (*get_compile_type_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name, int32_t type_dimension, int32_t type_flag);> | ||
| 2228 | |||
| 2229 | Calls L</"get_compile_type_name_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 2230 | |||
| 2231 | =head2 enter_scope | ||
| 2232 | |||
| 2233 | C<int32_t (*enter_scope)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2234 | |||
| 2235 | Performs an L<entering scope|SPVM::Document::Language::GarbageCollection/"Entering Scope"> operation and returns the current top position of the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">. This value is used as an argument to L</"leave_scope"> native API. | ||
| 2236 | |||
| 2237 | =head2 leave_scope | ||
| 2238 | |||
| 2239 | C<void (*leave_scope)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t mortal_stack_top);> | ||
| 2240 | |||
| 2241 | Performs a L<leaving scope operation|SPVM::Document::Language::GarbageCollection/"Leaving Scope"> given the top position of the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack"> I<mortal_stack_top>. | ||
| 2242 | |||
| 2243 | Normally, I<mortal_stack_top> is the return value from L</"enter_scope"> native API. | ||
| 2244 | |||
| 2245 | =head2 push_mortal | ||
| 2246 | |||
| 2247 | C<int32_t (*push_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2248 | |||
| 2249 | Pushes the object I<object> to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">. | ||
| 2250 | |||
| 2251 | If I<object> is C<NULL>, no operation is performed. | ||
| 2252 | |||
| 2253 | If successful, returns 0. Otherwise, returns a non-zero value. | ||
| 2254 | |||
| 2255 | =head2 weaken | ||
| 2256 | |||
| 2257 | C<int32_t (*weaken)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ** ref);> | ||
| 2258 | |||
| 2259 | Weakens the reference I<ref>. | ||
| 2260 | |||
| 2261 | I<ref> must not be C<NULL>. | ||
| 2262 | |||
| 2263 | If the object referenced by I<ref> is C<NULL>, no operation is performed. | ||
| 2264 | |||
| 2265 | If I<ref> is already weakened, no operation is performed. | ||
| 2266 | |||
| 2267 | See the documentation of L<weak reference|SPVM::Document::Language::GarbageCollection/"Weak Reference"> for more details. | ||
| 2268 | |||
| 2269 | =head2 isweak | ||
| 2270 | |||
| 2271 | C<int32_t (*isweak)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ** ref);> | ||
| 2272 | |||
| 2273 | If the reference I<ref> is weakened, returns 1, otherwise returns 0. | ||
| 2274 | |||
| 2275 | I<ref> must not be C<NULL>. | ||
| 2276 | |||
| 2277 | If the object referenced by I<ref> is C<NULL>, returns 0. | ||
| 2278 | |||
| 2279 | =head2 unweaken | ||
| 2280 | |||
| 2281 | C<void (*unweaken)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ** ref);> | ||
| 2282 | |||
| 2283 | Unweakens the reference I<ref>. | ||
| 2284 | |||
| 2285 | I<ref> must not be C<NULL>. | ||
| 2286 | |||
| 2287 | If the object referenced by I<ref> is C<NULL>, no operation is performed. | ||
| 2288 | |||
| 2289 | If I<ref> is not weakened, no operation is performed. | ||
| 2290 | |||
| 2291 | =head2 strerror_string | ||
| 2292 | |||
| 2293 | C<SPVM_OBJ* (*strerror_string)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t errno_value, int32_t length);> | ||
| 2294 | |||
| 2295 | Calls L</"strerror"> and creates an SPVM string object from its return value, pushes it to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 2296 | |||
| 2297 | =head2 strerror_string_nolen | ||
| 2298 | |||
| 2299 | C<SPVM_OBJ* (*strerror_string_nolen)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t errno_value);> | ||
| 2300 | |||
| 2301 | Calls L</"strerror_string"> with I<length> set to 0, and returns its return value. | ||
| 2302 | |||
| 2303 | =head2 strerror | ||
| 2304 | |||
| 2305 | C<const char* (*strerror)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t errno_value, int32_t length);> | ||
| 2306 | |||
| 2307 | Returns the error string corresponding to I<errno_value>, similar to the L<strerror|https://linux.die.net/man/3/strerror> function in C. | ||
| 2308 | |||
| 2309 | If I<length> is 0, the internal buffer length is set to 128. | ||
| 2310 | |||
| 2311 | If the operation fails, C<errno> is set to a positive value. | ||
| 2312 | |||
| 2313 | This native API is thread-safe. | ||
| 2314 | |||
| 2315 | =head2 strerror_nolen | ||
| 2316 | |||
| 2317 | C<const char* (*strerror_nolen)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t errno_value);> | ||
| 2318 | |||
| 2319 | Calls L</"strerror"> with I<length> set to 0, and returns its return value. | ||
| 2320 | |||
| 2321 | =head2 is_binary_compatible_object | ||
| 2322 | |||
| 2323 | C<int32_t (*is_binary_compatible_object)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2324 | |||
| 2325 | If the object I<object> is binary compatible with the current runtime environment, returns 1, otherwise returns 0. | ||
| 2326 | |||
| 2327 | =head2 new_stack | ||
| 2328 | |||
| 2329 | C<SPVM_VALUE* (*new_stack)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">);> | ||
| 2330 | |||
| 2331 | Creates a new L<runtime stack|SPVM::Document::NativeClass/"Runtime Stack">, and returns it. | ||
| 2332 | |||
| 2333 | =head2 free_stack | ||
| 2334 | |||
| 2335 | C<void (*free_stack)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2336 | |||
| 2337 | Frees the L<runtime stack|SPVM::Document::NativeClass/"Runtime Stack"> I<stack>. | ||
| 2338 | |||
| 2339 | =head2 get_field_object_defined_and_has_pointer_by_name | ||
| 2340 | |||
| 2341 | C<SPVM_OBJ* (*get_field_object_defined_and_has_pointer_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 2342 | |||
| 2343 | Calls L</"get_field_object_by_name"> native API, and returns its return value. | ||
| 2344 | |||
| 2345 | If the return value is C<NULL>, an exception is thrown. | ||
| 2346 | |||
| 2347 | If the pointer stored in the return value is C<NULL>, an exception is thrown. | ||
| 2348 | |||
| 2349 | =head2 get_field_object_ref | ||
| 2350 | |||
| 2351 | C<SPVM_OBJ** (*get_field_object_ref)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>);> | ||
| 2352 | |||
| 2353 | Returns the address where the value of the field I<field> is stored. | ||
| 2354 | |||
| 2355 | =head2 get_field_object_ref_by_name | ||
| 2356 | |||
| 2357 | C<SPVM_OBJ** (*get_field_object_ref_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 2358 | |||
| 2359 | Searches for a field given the object I<object> and the field name I<field_name>. | ||
| 2360 | |||
| 2361 | If it is found, returns the address where the value of the field is stored. Otherwise, an exception is thrown. | ||
| 2362 | |||
| 2363 | The function name I<func_name>, the file path I<file>, and the line number I<line> must be given for the exception stack trace. | ||
| 2364 | |||
| 2365 | If an exception is thrown, the value referenced by I<error_id> is set to a non-zero value. Otherwise, it is set to 0. | ||
| 2366 | |||
| 2367 | =head2 is_binary_compatible_stack | ||
| 2368 | |||
| 2369 | C<int32_t (*is_binary_compatible_stack)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2370 | |||
| 2371 | If the runtime stack I<stack> is binary compatible with the runtime environment I<env>, returns 1, otherwise returns 0. | ||
| 2372 | |||
| 2373 | =head2 assign_object | ||
| 2374 | |||
| 2375 | C<void (*assign_object)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ** ref, SPVM_OBJ* object);> | ||
| 2376 | |||
| 2377 | Assigns the object I<object> to the place referenced by the reference I<ref>. | ||
| 2378 | |||
| 2379 | This native API should not be used unless special purposes are intended. | ||
| 2380 | |||
| 2381 | =head2 new_string_array_no_mortal | ||
| 2382 | |||
| 2383 | C<SPVM_OBJ* (*new_string_array_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t length);> | ||
| 2384 | |||
| 2385 | Creates a new string array given the length I<length>, and returns it. | ||
| 2386 | |||
| 2387 | This native API should not be used unless special purposes are intended. Normally, use L</"new_string_array"> native API. | ||
| 2388 | |||
| 2389 | =head2 new_memory_block | ||
| 2390 | |||
| 2391 | C<void* (*new_memory_block)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, size_t size);> | ||
| 2392 | |||
| 2393 | Creates a new memory block given the byte size I<size> and returns its address. | ||
| 2394 | |||
| 2395 | If I<size> is 0, returns C<NULL>. | ||
| 2396 | |||
| 2397 | If I<size> is greater than C<SIZE_MAX> defined in the system, returns C<NULL>. | ||
| 2398 | |||
| 2399 | If the system memory allocation function returns C<NULL>, this native API returns C<NULL>. | ||
| 2400 | |||
| 2401 | The count of the memory blocks managed by this runtime is incremented by 1. | ||
| 2402 | |||
| 2403 | =head2 free_memory_block | ||
| 2404 | |||
| 2405 | C<void (*free_memory_block)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, void* block);> | ||
| 2406 | |||
| 2407 | Frees the memory block I<block>. | ||
| 2408 | |||
| 2409 | If I<block> is C<NULL>, no operation is performed. | ||
| 2410 | |||
| 2411 | The count of the memory blocks managed by this runtime is decremented by 1. | ||
| 2412 | |||
| 2413 | =head2 get_memory_blocks_count | ||
| 2414 | |||
| 2415 | C<int32_t (*get_memory_blocks_count)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2416 | |||
| 2417 | Returns the count of the memory blocks managed by this runtime. | ||
| 2418 | |||
| 2419 | =head2 say | ||
| 2420 | |||
| 2421 | C<void (*say)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* string);> | ||
| 2422 | |||
| 2423 | Prints the string I<string> followed by a newline (C<\n>) to L<SPVM's standard output|SPVM::Document::Language::System/"Standard Streams">. | ||
| 2424 | |||
| 2425 | =head2 warn | ||
| 2426 | |||
| 2427 | C<void (*warn)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* string, const char* func_name, const char* file, int32_t line);> | ||
| 2428 | |||
| 2429 | Performs the L<warn|SPVM::Document::Language::Operators/"warn"> operation given the string I<string>, the function name I<func_name>, the file path I<file>, and the line number I<line>. | ||
| 2430 | |||
| 2431 | =head2 spvm_stdin | ||
| 2432 | |||
| 2433 | C<FILE* (*spvm_stdin)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2434 | |||
| 2435 | Returns L<SPVM's standard input|SPVM::Document::Language::System/"Standard Streams">. | ||
| 2436 | |||
| 2437 | =head2 spvm_stdout | ||
| 2438 | |||
| 2439 | C<FILE* (*spvm_stdout)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2440 | |||
| 2441 | Returns L<SPVM's standard output|SPVM::Document::Language::System/"Standard Streams">. | ||
| 2442 | |||
| 2443 | =head2 spvm_stderr | ||
| 2444 | |||
| 2445 | C<FILE* (*spvm_stderr)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2446 | |||
| 2447 | Returns L<SPVM's standard error|SPVM::Document::Language::System/"Standard Streams">. | ||
| 2448 | |||
| 2449 | =head2 check_bootstrap_method | ||
| 2450 | |||
| 2451 | C<int32_t (*check_bootstrap_method)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* basic_type_name);> | ||
| 2452 | |||
| 2453 | Checks the definition of the L<bootstrap method|SPVM::Document::Language::Class/"Bootstrap Method">. | ||
| 2454 | |||
| 2455 | If it is invalid, an exception is thrown. | ||
| 2456 | |||
| 2457 | If an exception is thrown, returns a non-zero value. Otherwise, returns 0. | ||
| 2458 | |||
| 2459 | =head2 new_array_proto_element_no_mortal | ||
| 2460 | |||
| 2461 | C<SPVM_OBJ* (*new_array_proto_element_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* element, int32_t length);> | ||
| 2462 | |||
| 2463 | Creates a new array given the prototype element I<element> and the length I<length>, and returns it. | ||
| 2464 | |||
| 2465 | If I<element> is C<NULL>, returns C<NULL>. | ||
| 2466 | |||
| 2467 | The type of I<element> must be an object type. | ||
| 2468 | |||
| 2469 | If I<length> is less than 0, returns C<NULL>. | ||
| 2470 | |||
| 2471 | This native API should not be used unless special purposes are intended. Normally, use L</"new_array_proto_element"> native API. | ||
| 2472 | |||
| 2473 | =head2 new_array_proto_element | ||
| 2474 | |||
| 2475 | C<SPVM_OBJ* (*new_array_proto_element)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* element, int32_t length);> | ||
| 2476 | |||
| 2477 | Calls L</"new_array_proto_element_no_mortal"> native API and pushes its return value to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">, and returns it. | ||
| 2478 | |||
| 2479 | =head2 get_byte_object_value | ||
| 2480 | |||
| 2481 | C<int8_t (*get_byte_object_value)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* byte_object);> | ||
| 2482 | |||
| 2483 | Returns the value of the C<value> field of L<Byte|SPVM::Byte> object I<byte_object>. | ||
| 2484 | |||
| 2485 | I<byte_object> must be a L<Byte|SPVM::Byte> object. | ||
| 2486 | |||
| 2487 | =head2 get_short_object_value | ||
| 2488 | |||
| 2489 | C<int16_t (*get_short_object_value)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* short_object);> | ||
| 2490 | |||
| 2491 | Returns the value of the C<value> field of L<Short|SPVM::Short> object I<short_object>. | ||
| 2492 | |||
| 2493 | I<short_object> must be a L<Short|SPVM::Short> object. | ||
| 2494 | |||
| 2495 | =head2 get_int_object_value | ||
| 2496 | |||
| 2497 | C<int32_t (*get_int_object_value)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* int_object);> | ||
| 2498 | |||
| 2499 | Returns the value of the C<value> field of L<Int|SPVM::Int> object I<int_object>. | ||
| 2500 | |||
| 2501 | I<int_object> must be an L<Int|SPVM::Int> object. | ||
| 2502 | |||
| 2503 | =head2 get_long_object_value | ||
| 2504 | |||
| 2505 | C<int64_t (*get_long_object_value)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* long_object);> | ||
| 2506 | |||
| 2507 | Returns the value of the C<value> field of L<Long|SPVM::Long> object I<long_object>. | ||
| 2508 | |||
| 2509 | I<long_object> must be a L<Long|SPVM::Long> object. | ||
| 2510 | |||
| 2511 | =head2 get_float_object_value | ||
| 2512 | |||
| 2513 | C<float (*get_float_object_value)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* float_object);> | ||
| 2514 | |||
| 2515 | Returns the value of the C<value> field of L<Float|SPVM::Float> object I<float_object>. | ||
| 2516 | |||
| 2517 | I<float_object> must be a L<Float|SPVM::Float> object. | ||
| 2518 | |||
| 2519 | =head2 get_double_object_value | ||
| 2520 | |||
| 2521 | C<double (*get_double_object_value)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* double_object);> | ||
| 2522 | |||
| 2523 | Returns the value of the C<value> field of L<Double|SPVM::Double> object I<double_object>. | ||
| 2524 | |||
| 2525 | I<double_object> must be a L<Double|SPVM::Double> object. | ||
| 2526 | |||
| 2527 | =head2 no_free | ||
| 2528 | |||
| 2529 | C<int32_t (*no_free)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2530 | |||
| 2531 | If the C<no_free> flag of the object I<object> is enabled, returns 1, otherwise returns 0. | ||
| 2532 | |||
| 2533 | =head2 set_no_free | ||
| 2534 | |||
| 2535 | C<void (*set_no_free)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, int32_t no_free);> | ||
| 2536 | |||
| 2537 | If I<no_free> is a true value, enables the C<no_free> flag of the object I<object>, otherwise disables it. | ||
| 2538 | |||
| 2539 | =head2 get_stack_tmp_buffer | ||
| 2540 | |||
| 2541 | C<char* (*get_stack_tmp_buffer)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2542 | |||
| 2543 | Returns the temporary buffer on the runtime stack I<stack>. | ||
| 2544 | |||
| 2545 | The byte size of the temporary buffer is L</"SPVM_NATIVE_C_STACK_TMP_BUFFER_SIZE">. | ||
| 2546 | |||
| 2547 | =head2 print_exception_to_stderr | ||
| 2548 | |||
| 2549 | C<void (*print_exception_to_stderr)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2550 | |||
| 2551 | Prints C<"[An exception is converted to a warning]\n">, the current exception, and C<"\n"> to L<SPVM's standard error|SPVM::Document::Language::System/"Standard Streams">. | ||
| 2552 | |||
| 2553 | =head2 dump_object_internal | ||
| 2554 | |||
| 2555 | C<SPVM_OBJ* (*dump_object_internal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2556 | |||
| 2557 | Dumps the internal information of the object I<object>, creates a new SPVM string from the information, and returns it. | ||
| 2558 | |||
| 2559 | The dumped internal information looks like the following: | ||
| 2560 | |||
| 2561 | [Object Internal:0x55dd87806090] | ||
| 2562 | pointer:(nil) | ||
| 2563 | weaken_backrefs_length:0 | ||
| 2564 | ref_count:1 | ||
| 2565 | basic_type_name:Point | ||
| 2566 | type_dimension:0 | ||
| 2567 | flag: | ||
| 2568 | length:2 | ||
| 2569 | |||
| 2570 | If I<object> is C<NULL>, returns a string C<"undef">. | ||
| 2571 | |||
| 2572 | =head2 get_seed | ||
| 2573 | |||
| 2574 | C<int32_t (*get_seed)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2575 | |||
| 2576 | Returns the value of the C<seed> stack variable on the runtime stack I<stack>. | ||
| 2577 | |||
| 2578 | =head2 set_seed | ||
| 2579 | |||
| 2580 | C<void (*set_seed)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t seed);> | ||
| 2581 | |||
| 2582 | Sets the value of the C<seed> stack variable on the runtime stack I<stack> to I<seed>. | ||
| 2583 | |||
| 2584 | If the value of the C<seed_initialized> stack variable on the runtime stack I<stack> is 0, it is set to 1. | ||
| 2585 | |||
| 2586 | =head2 seed_initialized | ||
| 2587 | |||
| 2588 | C<int32_t (*seed_initialized)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2589 | |||
| 2590 | Returns the value of the C<seed_initialized> stack variable on the runtime stack I<stack>. | ||
| 2591 | |||
| 2592 | =head2 get_basic_type_name_in_version_from | ||
| 2593 | |||
| 2594 | C<const char* (*get_basic_type_name_in_version_from)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);> | ||
| 2595 | |||
| 2596 | Returns the basic type name specified by the C<version_from> statement. If it is not specified, returns C<NULL>. | ||
| 2597 | |||
| 2598 | =head2 set_command_info_warning | ||
| 2599 | |||
| 2600 | C<int32_t (*set_command_info_warning)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t warning);> | ||
| 2601 | |||
| 2602 | Sets the L<CommandInfo#WARNING|SPVM::CommandInfo/"WARNING"> class variable to I<warning>. | ||
| 2603 | |||
| 2604 | If an exception is thrown, returns the basic type ID of the L<Error|SPVM::Error> class, otherwise returns 0. | ||
| 2605 | |||
| 2606 | This native API should not be used unless special purposes are intended. | ||
| 2607 | |||
| 2608 | =head2 destroy_cache_class_vars | ||
| 2609 | |||
| 2610 | C<void (*destroy_cache_class_vars)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2611 | |||
| 2612 | Sets all class variables that have the C<cache> attribute and are of an object type to C<undef>. | ||
| 2613 | |||
| 2614 | =head2 call_instance_method_no_mortal | ||
| 2615 | |||
| 2616 | C<int32_t (*call_instance_method_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* method_name, int32_t args_width);> | ||
| 2617 | |||
| 2618 | Calls an instance method by its name I<method_name> with the specified L<argument width|SPVM::Document::NativeClass/"Arguments Width"> I<args_width>. | ||
| 2619 | |||
| 2620 | C<stack[0].oval> must contain the invocant object. | ||
| 2621 | |||
| 2622 | If the method throws an exception, returns the basic type ID of the error class. Otherwise, returns 0. | ||
| 2623 | |||
| 2624 | The return value of the method is set to C<stack[0]>. | ||
| 2625 | |||
| 2626 | This native API should not be used unless special purposes are intended. Normally, use L</"call_instance_method"> native API. | ||
| 2627 | |||
| 2628 | =head2 call_instance_method | ||
| 2629 | |||
| 2630 | C<int32_t (*call_instance_method)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* method_name, int32_t args_width);> | ||
| 2631 | |||
| 2632 | Calls L</"call_instance_method_no_mortal">. If the return value is an object type, it is pushed to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">. | ||
| 2633 | |||
| 2634 | =head2 call_method_no_mortal_no_check_args | ||
| 2635 | |||
| 2636 | C<int32_t (*call_method_no_mortal_no_check_args)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_NATIVE_METHOD* method|SPVM::Document::NativeAPI::Method>, int32_t args_width, const char* func_name, const char* file_name, int32_t line);> | ||
| 2637 | |||
| 2638 | Same as L</"call_method_no_mortal">, but performs no type checking on arguments. | ||
| 2639 | |||
| 2640 | =head2 call_instance_method_no_mortal_less_check_args | ||
| 2641 | |||
| 2642 | C<int32_t (*call_instance_method_no_mortal_less_check_args)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* method_name, int32_t args_width, const char* decl_args_signature, const char* func_name, const char* file_name, int32_t line);> | ||
| 2643 | |||
| 2644 | Same as L</"call_instance_method_no_mortal">, but performs reduced type checking using the hint I<decl_args_signature>. | ||
| 2645 | |||
| 2646 | =head2 enable_options | ||
| 2647 | |||
| 2648 | C<void (*enable_options)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2649 | |||
| 2650 | Turns on the C<options> flag if the type of I<object> is an object array (C<object[]>). | ||
| 2651 | |||
| 2652 | =head2 disable_options | ||
| 2653 | |||
| 2654 | C<void (*disable_options)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2655 | |||
| 2656 | Turns off the C<options> flag of the object I<object>. | ||
| 2657 | |||
| 2658 | =head2 is_options | ||
| 2659 | |||
| 2660 | C<int32_t (*is_options)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2661 | |||
| 2662 | If the C<options> flag of the object I<object> is set, returns 1; otherwise returns 0. | ||
| 2663 | |||
| 2664 | =head2 is_any_object_array | ||
| 2665 | |||
| 2666 | C<int32_t (*is_any_object_array)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2667 | |||
| 2668 | If the object I<object> is not C<NULL> and its type is an object array type (C<object[]>), returns 1; otherwise returns 0. | ||
| 2669 | |||
| 2670 | =head2 exists_field | ||
| 2671 | |||
| 2672 | C<int32_t (*exists_field)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>);> | ||
| 2673 | |||
| 2674 | Returns 1 if the field existence flag of the field I<field> in I<object> is true, otherwise returns 0. | ||
| 2675 | |||
| 2676 | =head2 exists_field_by_name | ||
| 2677 | |||
| 2678 | C<int32_t (*exists_field_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 2679 | |||
| 2680 | Same as L</"exists_field">, but the field is specified by its name I<field_name>. | ||
| 2681 | |||
| 2682 | =head2 delete_field | ||
| 2683 | |||
| 2684 | C<void (*delete_field)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, L<SPVM_NATIVE_FIELD* field|SPVM::Document::NativeAPI::Field>);> | ||
| 2685 | |||
| 2686 | Deletes the field I<field> from I<object>. | ||
| 2687 | |||
| 2688 | The field existence flag is set to 0. The value of the field is reset to 0 (for numeric types) or C<undef> (for object types). | ||
| 2689 | |||
| 2690 | =head2 delete_field_by_name | ||
| 2691 | |||
| 2692 | C<void (*delete_field_by_name)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, const char* field_name, int32_t* error_id, const char* func_name, const char* file, int32_t line);> | ||
| 2693 | |||
| 2694 | Same as L</"delete_field">, but the field is specified by its name I<field_name>. | ||
| 2695 | |||
| 2696 | =head2 make_fixed_length | ||
| 2697 | |||
| 2698 | C<void (*make_fixed_length)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2699 | |||
| 2700 | Sets the fixed-length flag of the object I<object>. | ||
| 2701 | |||
| 2702 | =head2 is_fixed_length | ||
| 2703 | |||
| 2704 | C<int32_t (*is_fixed_length)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2705 | |||
| 2706 | Returns 1 if the fixed-length flag of the object I<object> is set, otherwise returns 0. | ||
| 2707 | |||
| 2708 | =head2 set_length | ||
| 2709 | |||
| 2710 | C<int32_t (*set_length)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, int32_t length);> | ||
| 2711 | |||
| 2712 | Sets the length of the object I<object>. I<object> must be a string or an array. | ||
| 2713 | |||
| 2714 | If the length is extended, L</"set_capacity"> is called automatically if needed. If shortened, unused elements are destroyed. | ||
| 2715 | |||
| 2716 | If successful, returns 0. Otherwise, sets an exception and returns a basic type ID of an error class. | ||
| 2717 | |||
| 2718 | =head2 capacity | ||
| 2719 | |||
| 2720 | C<int32_t (*capacity)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2721 | |||
| 2722 | Returns the value of the C<capacity> member in the C<SPVM_OBJECT> structure. | ||
| 2723 | |||
| 2724 | =head2 set_capacity | ||
| 2725 | |||
| 2726 | C<int32_t (*set_capacity)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, int32_t capacity);> | ||
| 2727 | |||
| 2728 | Sets the capacity of the object I<object>. I<object> must be a string or an array. | ||
| 2729 | |||
| 2730 | A new memory area is allocated, and existing elements are copied to it. | ||
| 2731 | |||
| 2732 | If successful, returns 0. Otherwise, sets an exception and returns a basic type ID of an error class. | ||
| 2733 | |||
| 2734 | =head2 numeric_object_to_byte | ||
| 2735 | |||
| 2736 | C<int8_t (*numeric_object_to_byte)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, int32_t* error_id);> | ||
| 2737 | |||
| 2738 | Converts a numeric object (Box object) to an C<int8_t> value. | ||
| 2739 | |||
| 2740 | If successful, I<error_id> is set to 0. Otherwise, it is set to a non-zero value. | ||
| 2741 | |||
| 2742 | =head2 numeric_object_to_short | ||
| 2743 | |||
| 2744 | C<int16_t (*numeric_object_to_short)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, int32_t* error_id);> | ||
| 2745 | |||
| 2746 | Converts a numeric object to an C<int16_t> value. | ||
| 2747 | |||
| 2748 | =head2 numeric_object_to_int | ||
| 2749 | |||
| 2750 | C<int32_t (*numeric_object_to_int)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, int32_t* error_id);> | ||
| 2751 | |||
| 2752 | Converts a numeric object to an C<int32_t> value. | ||
| 2753 | |||
| 2754 | =head2 numeric_object_to_long | ||
| 2755 | |||
| 2756 | C<int64_t (*numeric_object_to_long)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, int32_t* error_id);> | ||
| 2757 | |||
| 2758 | Converts a numeric object to an C<int64_t> value. | ||
| 2759 | |||
| 2760 | =head2 numeric_object_to_float | ||
| 2761 | |||
| 2762 | C<float (*numeric_object_to_float)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, int32_t* error_id);> | ||
| 2763 | |||
| 2764 | Converts a numeric object to a C<float> value. | ||
| 2765 | |||
| 2766 | =head2 numeric_object_to_double | ||
| 2767 | |||
| 2768 | C<double (*numeric_object_to_double)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, int32_t* error_id);> | ||
| 2769 | |||
| 2770 | Converts a numeric object to a C<double> value. | ||
| 2771 | |||
| 2772 | =head2 numeric_object_to_string_no_mortal | ||
| 2773 | |||
| 2774 | C<SPVM_OBJ* (*numeric_object_to_string_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, int32_t* error_id);> | ||
| 2775 | |||
| 2776 | Converts a numeric object to an SPVM string object. | ||
| 2777 | |||
| 2778 | If successful, I<error_id> is set to 0. Otherwise, it is set to a non-zero value. | ||
| 2779 | |||
| 2780 | =head2 numeric_object_to_string | ||
| 2781 | |||
| 2782 | C<SPVM_OBJ* (*numeric_object_to_string)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, int32_t* error_id);> | ||
| 2783 | |||
| 2784 | Same as L</"numeric_object_to_string_no_mortal">, but the return value is pushed to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">. | ||
| 2785 | |||
| 2786 | =head2 is_numeric_object | ||
| 2787 | |||
| 2788 | C<int32_t (*is_numeric_object)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2789 | |||
| 2790 | Returns 1 if I<object> is not C<NULL> and is a numeric object (Box object), otherwise returns 0. | ||
| 2791 | |||
| 2792 | =head2 say_stderr | ||
| 2793 | |||
| 2794 | C<void (*say_stderr)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* string);> | ||
| 2795 | |||
| 2796 | Same as L</"say">, but prints the output to L<SPVM's standard error|SPVM::Document::Language::System/"Standard Streams">. | ||
| 2797 | |||
| 2798 | =head2 get_call_depth | ||
| 2799 | |||
| 2800 | C<int32_t (*get_call_depth)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2801 | |||
| 2802 | Returns the current call depth on the runtime stack L<stack|SPVM::Document::NativeClass/"Runtime Stack">. | ||
| 2803 | |||
| 2804 | =head2 get_caller_info_stack | ||
| 2805 | |||
| 2806 | C<SPVM_VALUE* (*get_caller_info_stack)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2807 | |||
| 2808 | Returns the address of the C<caller_info_stack> internal variable on the runtime stack I<stack>. | ||
| 2809 | |||
| 2810 | Note: String fields in the records (e.g., method name or file name) may not be null-terminated. Perform C<NULL> checks and use C<strncpy> for safe copying. | ||
| 2811 | |||
| 2812 | =head2 get_caller_info_stack_record_size | ||
| 2813 | |||
| 2814 | C<int32_t (*get_caller_info_stack_record_size)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2815 | |||
| 2816 | Returns the size of a single record in the caller info stack. | ||
| 2817 | |||
| 2818 | =head2 get_current_method | ||
| 2819 | |||
| 2820 | C<SPVM_OBJ* (*get_current_method)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t level, int32_t* error_id);> | ||
| 2821 | |||
| 2822 | Returns the method object at the specified I<level> on the runtime stack I<stack>. | ||
| 2823 | |||
| 2824 | I<level> 0 is the current method, 1 is its caller, and so on. | ||
| 2825 | |||
| 2826 | If I<level> is out of range or an internal error occurs, returns C<NULL> and sets I<error_id> to a non-zero value. | ||
| 2827 | |||
| 2828 | =head2 caller | ||
| 2829 | |||
| 2830 | C<SPVM_OBJ* (*caller)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t level, int32_t* error_id);> | ||
| 2831 | |||
| 2832 | Returns a C<CallerInfo> object containing information about the caller at the specified I<level>. | ||
| 2833 | |||
| 2834 | The object is automatically pushed to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">. | ||
| 2835 | |||
| 2836 | * 0 represents the caller of the current method. | ||
| 2837 | * 1 represents the caller of the caller. | ||
| 2838 | |||
| 2839 | If successful, returns the C<CallerInfo> object and sets I<error_id> to 0. Otherwise, returns C<NULL> and sets I<error_id> to a non-zero value. | ||
| 2840 | |||
| 2841 | =head2 caller_no_mortal | ||
| 2842 | |||
| 2843 | C<SPVM_OBJ* (*caller_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t level, int32_t* error_id);> | ||
| 2844 | |||
| 2845 | This is the same as L</"caller">, but the returned object is not pushed to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">. | ||
| 2846 | |||
| 2847 | =head2 die_with_string | ||
| 2848 | |||
| 2849 | C<int32_t (*die_with_string)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* obj_exception, const char* func_name, const char* file, int32_t line);> | ||
| 2850 | |||
| 2851 | Sets an exception with an existing string object I<obj_exception> and its metadata, then returns the basic type ID of an error class. | ||
| 2852 | |||
| 2853 | This is the same as L</"die">, but it takes an SPVM string object instead of a format string. | ||
| 2854 | |||
| 2855 | Examples: | ||
| 2856 | |||
| 2857 | SPVM_OBJ* obj_exception = env->new_string_nolen(env, stack, "Custom error message"); | ||
| 2858 | return env->die_with_string(env, stack, obj_exception, __func__, __FILE__, __LINE__); | ||
| 2859 | |||
| 2860 | =head2 build_exception_message_no_mortal | ||
| 2861 | |||
| 2862 | C<SPVM_OBJ* (*build_exception_message_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t start_call_depth);> | ||
| 2863 | |||
| 2864 | This is the same as L</"build_exception_message">, but the returned object is not pushed to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">. | ||
| 2865 | |||
| 2866 | =head2 build_exception_message | ||
| 2867 | |||
| 2868 | C<SPVM_OBJ* (*build_exception_message)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, int32_t start_call_depth);> | ||
| 2869 | |||
| 2870 | Reconstructs a full exception message including a stack trace with the current exception object stored in the runtime stack. | ||
| 2871 | |||
| 2872 | Returns the newly created string object. This object is automatically pushed to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">. | ||
| 2873 | |||
| 2874 | Examples: | ||
| 2875 | |||
| 2876 | SPVM_OBJ* obj_full_message = env->build_exception_message(env, stack, 0); | ||
| 2877 | |||
| 2878 | =head2 is_utf8 | ||
| 2879 | |||
| 2880 | C<int32_t (*is_utf8)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* obj_string, int32_t* error_id);> | ||
| 2881 | |||
| 2882 | Checks if the given string I<obj_string> is a valid UTF-8 sequence. | ||
| 2883 | |||
| 2884 | If it is a valid UTF-8 sequence, returns 1, otherwise returns 0. | ||
| 2885 | |||
| 2886 | If I<obj_string> is C<NULL>, I<error_id> is set to a non-zero value and returns 0. Otherwise, I<error_id> is set to 0. | ||
| 2887 | |||
| 2888 | =head2 set_byte_object_value | ||
| 2889 | |||
| 2890 | C<void (*set_byte_object_value)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* byte_object, int8_t value);> | ||
| 2891 | |||
| 2892 | Sets the value of the C<value> field of the L<Byte|SPVM::Byte> object I<byte_object>. | ||
| 2893 | |||
| 2894 | B<Note:> This method sets the value even if the object is marked as read-only. | ||
| 2895 | |||
| 2896 | =head2 set_short_object_value | ||
| 2897 | |||
| 2898 | C<void (*set_short_object_value)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* short_object, int16_t value);> | ||
| 2899 | |||
| 2900 | Sets the value of the C<value> field of the L<Short|SPVM::Short> object I<short_object>. | ||
| 2901 | |||
| 2902 | B<Note:> This method sets the value even if the object is marked as read-only. | ||
| 2903 | |||
| 2904 | =head2 set_int_object_value | ||
| 2905 | |||
| 2906 | C<void (*set_int_object_value)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* int_object, int32_t value);> | ||
| 2907 | |||
| 2908 | Sets the value of the C<value> field of the L<Int|SPVM::Int> object I<int_object>. | ||
| 2909 | |||
| 2910 | B<Note:> This method sets the value even if the object is marked as read-only. | ||
| 2911 | |||
| 2912 | =head2 set_long_object_value | ||
| 2913 | |||
| 2914 | C<void (*set_long_object_value)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* long_object, int64_t value);> | ||
| 2915 | |||
| 2916 | Sets the value of the C<value> field of the L<Long|SPVM::Long> object I<long_object>. | ||
| 2917 | |||
| 2918 | B<Note:> This method sets the value even if the object is marked as read-only. | ||
| 2919 | |||
| 2920 | =head2 set_float_object_value | ||
| 2921 | |||
| 2922 | C<void (*set_float_object_value)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* float_object, float value);> | ||
| 2923 | |||
| 2924 | Sets the value of the C<value> field of the L<Float|SPVM::Float> object I<float_object>. | ||
| 2925 | |||
| 2926 | B<Note:> This method sets the value even if the object is marked as read-only. | ||
| 2927 | |||
| 2928 | =head2 set_double_object_value | ||
| 2929 | |||
| 2930 | C<void (*set_double_object_value)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* double_object, double value);> | ||
| 2931 | |||
| 2932 | Sets the value of the C<value> field of the L<Double|SPVM::Double> object I<double_object>. | ||
| 2933 | |||
| 2934 | B<Note:> This method sets the value even if the object is marked as read-only. | ||
| 2935 | |||
| 2936 | Examples: | ||
| 2937 | |||
| 2938 | int32_t error_id = 0; | ||
| 2939 | SPVM_OBJ* obj_int = env->new_object_by_name(env, stack, "Int", &error_id); | ||
| 2940 | env->set_int_object_value(env, stack, obj_int, 10); | ||
| 2941 | |||
| 2942 | =head2 push_caller_stack | ||
| 2943 | |||
| 2944 | C<void (*push_caller_stack)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, const char* func_name, const char* file, int32_t line);> | ||
| 2945 | |||
| 2946 | Pushes the caller info (function name, file name, and line number) onto the caller info stack. | ||
| 2947 | |||
| 2948 | This information is used to generate a stack trace when an exception occurs. | ||
| 2949 | |||
| 2950 | Every call to L</"push_caller_stack"> native API must be followed by a call to L</"pop_caller_stack"> after the function call. | ||
| 2951 | |||
| 2952 | Examples: | ||
| 2953 | |||
| 2954 | /* Push the current location info */ | ||
| 2955 | env->push_caller_stack(env, stack, __func__, __FILE__, __LINE__); | ||
| 2956 | |||
| 2957 | my_func(env, stack, 1); | ||
| 2958 | |||
| 2959 | /* Pop the last location info */ | ||
| 2960 | env->pop_caller_stack(env, stack); | ||
| 2961 | |||
| 2962 | =head2 pop_caller_stack | ||
| 2963 | |||
| 2964 | C<void (*pop_caller_stack)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 2965 | |||
| 2966 | Pops the last caller info from the caller info stack. | ||
| 2967 | |||
| 2968 | =head2 get_error_id | ||
| 2969 | |||
| 2970 | int32_t (*get_error_id)(SPVM_ENV* env, SPVM_VALUE* stack); | ||
| 2971 | |||
| 2972 | Returns the current error ID on the runtime stack L<stack|SPVM::Document::NativeClass/"Runtime Stack">. | ||
| 2973 | |||
| 2974 | Note that the error ID is not automatically set by the runtime unless explicitly mentioned in the documentation. | ||
| 2975 | |||
| 2976 | =head2 set_error_id | ||
| 2977 | |||
| 2978 | void (*set_error_id)(SPVM_ENV* env, SPVM_VALUE* stack, int32_t error_id); | ||
| 2979 | |||
| 2980 | Sets the error ID on the runtime stack L<stack|SPVM::Document::NativeClass/"Runtime Stack">. | ||
| 2981 | |||
| 2982 | Note that the error ID is not automatically set by the runtime unless explicitly mentioned in the documentation. | ||
| 2983 | |||
| 2984 | Examples: | ||
| 2985 | |||
| 2986 | // Get error ID | ||
| 2987 | int32_t error_id = env->get_error_id(env, stack); | ||
| 2988 | |||
| 2989 | // Set error ID | ||
| 2990 | env->set_error_id(env, stack, error_id); | ||
| 2991 | |||
| 2992 | =head2 no_close | ||
| 2993 | |||
| 2994 | C<int32_t (*no_close)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object);> | ||
| 2995 | |||
| 2996 | If the C<no_close> flag of the object I<object> is enabled, returns 1, otherwise returns 0. | ||
| 2997 | |||
| 2998 | =head2 set_no_close | ||
| 2999 | |||
| 3000 | C<void (*set_no_close)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* object, int32_t no_close);> | ||
| 3001 | |||
| 3002 | If I<no_close> is a true value, enables the C<no_close> flag of the object I<object>, otherwise disables it. | ||
| 3003 | |||
| 3004 | =head2 longmess_no_mortal | ||
| 3005 | |||
| 3006 | C<SPVM_OBJ* (*longmess_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_OBJ* obj_message|SPVM::Document::NativeClass/"Native Object">, const char* func_name, const char* file, int32_t line, int32_t start_call_depth, int32_t end_call_depth);> | ||
| 3007 | |||
| 3008 | This is the same as L</"longmess">, but the returned object is not pushed to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">. | ||
| 3009 | |||
| 3010 | =head2 longmess | ||
| 3011 | |||
| 3012 | C<SPVM_OBJ* (*longmess)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, L<SPVM_OBJ* obj_message|SPVM::Document::NativeClass/"Native Object">, const char* func_name, const char* file, int32_t line, int32_t start_call_depth, int32_t end_call_depth);> | ||
| 3013 | |||
| 3014 | Reconstructs a full message including a stack trace by using the metadata stored in the runtime stack. | ||
| 3015 | |||
| 3016 | This function creates a new SPVM string object by combining the specified message object (I<obj_message>) with caller information retrieved from the metadata slots. | ||
| 3017 | |||
| 3018 | The I<start_call_depth> argument specifies the starting call depth of the caller information stack to include in the trace. Normally, you specify C<0>. | ||
| 3019 | |||
| 3020 | The I<end_call_depth> argument specifies the ending call depth of the caller information stack to include in the trace. If I<end_call_depth> is less than 0 or greater than the value obtained by L</"get_call_depth">, the value obtained by L</"get_call_depth"> is set. | ||
| 3021 | |||
| 3022 | This is useful for formatting messages with a stack trace. | ||
| 3023 | |||
| 3024 | The metadata used for reconstruction includes the function name, file path, line number, and the caller information stack. | ||
| 3025 | |||
| 3026 | Returns the newly created string object. This object is automatically pushed to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">. | ||
| 3027 | |||
| 3028 | =head2 diag | ||
| 3029 | |||
| 3030 | C<void (*diag)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">, SPVM_OBJ* string, const char* func_name, const char* file, int32_t line);> | ||
| 3031 | |||
| 3032 | Same as L</"warn">. | ||
| 3033 | |||
| 3034 | =head2 dump_recorded_objects | ||
| 3035 | |||
| 3036 | C<SPVM_OBJ* (*dump_recorded_objects)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 3037 | |||
| 3038 | Dumps all recorded objects currently tracked for memory leak detection along with their allocation stack traces. | ||
| 3039 | |||
| 3040 | Returns the newly created string object containing the dump. This object is automatically pushed to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">. | ||
| 3041 | |||
| 3042 | =head2 dump_recorded_objects_no_mortal | ||
| 3043 | |||
| 3044 | C<SPVM_OBJ* (*dump_recorded_objects_no_mortal)(L<SPVM_ENV* env|SPVM::Document::NativeClass/"Runtime Environment">, L<SPVM_VALUE* stack|SPVM::Document::NativeClass/"Runtime Stack">);> | ||
| 3045 | |||
| 3046 | This is the same as L</"dump_recorded_objects">, but the returned object is not pushed to the L<native mortal stack|SPVM::Document::NativeClass/"Native Mortal Stack">. | ||
| 3047 | |||
| 3048 | =head1 Native API IDs | ||
| 3049 | |||
| 3050 | Native APIs have its IDs. | ||
| 3051 | |||
| 3052 | 0 runtime | ||
| 3053 | 1 api | ||
| 3054 | 2 new_env | ||
| 3055 | 3 free_env | ||
| 3056 | 4 call_init_methods | ||
| 3057 | 5 set_command_info_program_name | ||
| 3058 | 6 set_command_info_argv | ||
| 3059 | 7 set_command_info_basetime | ||
| 3060 | 8 destroy_class_vars | ||
| 3061 | 9 args_width | ||
| 3062 | 10 get_object_basic_type | ||
| 3063 | 11 get_object_basic_type_id | ||
| 3064 | 12 get_object_basic_type_name | ||
| 3065 | 13 get_object_type_dimension | ||
| 3066 | 14 get_basic_type | ||
| 3067 | 15 get_basic_type_by_name | ||
| 3068 | 16 get_basic_type_by_id | ||
| 3069 | 17 get_basic_type_id | ||
| 3070 | 18 get_basic_type_id_by_name | ||
| 3071 | 19 get_class_var | ||
| 3072 | 20 get_class_var_byte | ||
| 3073 | 21 get_class_var_short | ||
| 3074 | 22 get_class_var_int | ||
| 3075 | 23 get_class_var_long | ||
| 3076 | 24 get_class_var_float | ||
| 3077 | 25 get_class_var_double | ||
| 3078 | 26 get_class_var_object | ||
| 3079 | 27 get_class_var_string | ||
| 3080 | 28 set_class_var_byte | ||
| 3081 | 29 set_class_var_short | ||
| 3082 | 30 set_class_var_int | ||
| 3083 | 31 set_class_var_long | ||
| 3084 | 32 set_class_var_float | ||
| 3085 | 33 set_class_var_double | ||
| 3086 | 34 set_class_var_object | ||
| 3087 | 35 set_class_var_string | ||
| 3088 | 36 get_class_var_object_ref | ||
| 3089 | 37 get_class_var_byte_by_name | ||
| 3090 | 38 get_class_var_short_by_name | ||
| 3091 | 39 get_class_var_int_by_name | ||
| 3092 | 40 get_class_var_long_by_name | ||
| 3093 | 41 get_class_var_float_by_name | ||
| 3094 | 42 get_class_var_double_by_name | ||
| 3095 | 43 get_class_var_object_by_name | ||
| 3096 | 44 get_class_var_string_by_name | ||
| 3097 | 45 set_class_var_byte_by_name | ||
| 3098 | 46 set_class_var_short_by_name | ||
| 3099 | 47 set_class_var_int_by_name | ||
| 3100 | 48 set_class_var_long_by_name | ||
| 3101 | 49 set_class_var_float_by_name | ||
| 3102 | 50 set_class_var_double_by_name | ||
| 3103 | 51 set_class_var_object_by_name | ||
| 3104 | 52 set_class_var_string_by_name | ||
| 3105 | 53 get_field | ||
| 3106 | 54 get_field_static | ||
| 3107 | 55 get_field_byte | ||
| 3108 | 56 get_field_short | ||
| 3109 | 57 get_field_int | ||
| 3110 | 58 get_field_long | ||
| 3111 | 59 get_field_float | ||
| 3112 | 60 get_field_double | ||
| 3113 | 61 get_field_object | ||
| 3114 | 62 get_field_string | ||
| 3115 | 63 set_field_byte | ||
| 3116 | 64 set_field_short | ||
| 3117 | 65 set_field_int | ||
| 3118 | 66 set_field_long | ||
| 3119 | 67 set_field_float | ||
| 3120 | 68 set_field_double | ||
| 3121 | 69 set_field_object | ||
| 3122 | 70 set_field_string | ||
| 3123 | 71 get_field_byte_by_name | ||
| 3124 | 72 get_field_short_by_name | ||
| 3125 | 73 get_field_int_by_name | ||
| 3126 | 74 get_field_long_by_name | ||
| 3127 | 75 get_field_float_by_name | ||
| 3128 | 76 get_field_double_by_name | ||
| 3129 | 77 get_field_object_by_name | ||
| 3130 | 78 get_field_string_by_name | ||
| 3131 | 79 set_field_byte_by_name | ||
| 3132 | 80 set_field_short_by_name | ||
| 3133 | 81 set_field_int_by_name | ||
| 3134 | 82 set_field_long_by_name | ||
| 3135 | 83 set_field_float_by_name | ||
| 3136 | 84 set_field_double_by_name | ||
| 3137 | 85 set_field_object_by_name | ||
| 3138 | 86 set_field_string_by_name | ||
| 3139 | 87 get_field_string_chars_by_name | ||
| 3140 | 88 get_method | ||
| 3141 | 89 get_class_method | ||
| 3142 | 90 get_instance_method_static | ||
| 3143 | 91 get_instance_method | ||
| 3144 | 92 call_method_no_mortal | ||
| 3145 | 93 call_method | ||
| 3146 | 94 call_class_method_by_name | ||
| 3147 | 95 call_instance_method_static_by_name | ||
| 3148 | 96 call_instance_method_by_name | ||
| 3149 | 97 new_object_no_mortal | ||
| 3150 | 98 new_object | ||
| 3151 | 99 new_object_by_name | ||
| 3152 | 100 new_pointer_object_no_mortal | ||
| 3153 | 101 new_pointer_object | ||
| 3154 | 102 new_pointer_object_by_name | ||
| 3155 | 103 get_pointer | ||
| 3156 | 104 set_pointer | ||
| 3157 | 105 new_string_nolen_no_mortal | ||
| 3158 | 106 new_string_nolen | ||
| 3159 | 107 new_string_no_mortal | ||
| 3160 | 108 new_string | ||
| 3161 | 109 new_byte_array_no_mortal | ||
| 3162 | 110 new_byte_array | ||
| 3163 | 111 new_short_array_no_mortal | ||
| 3164 | 112 new_short_array | ||
| 3165 | 113 new_int_array_no_mortal | ||
| 3166 | 114 new_int_array | ||
| 3167 | 115 new_long_array_no_mortal | ||
| 3168 | 116 new_long_array | ||
| 3169 | 117 new_float_array_no_mortal | ||
| 3170 | 118 new_float_array | ||
| 3171 | 119 new_double_array_no_mortal | ||
| 3172 | 120 new_double_array | ||
| 3173 | 121 new_object_array_no_mortal | ||
| 3174 | 122 new_object_array | ||
| 3175 | 123 new_object_array_by_name | ||
| 3176 | 124 new_string_array | ||
| 3177 | 125 new_muldim_array_no_mortal | ||
| 3178 | 126 new_muldim_array | ||
| 3179 | 127 new_muldim_array_by_name | ||
| 3180 | 128 new_mulnum_array_no_mortal | ||
| 3181 | 129 new_mulnum_array | ||
| 3182 | 130 new_mulnum_array_by_name | ||
| 3183 | 131 new_array_proto_no_mortal | ||
| 3184 | 132 new_array_proto | ||
| 3185 | 133 length | ||
| 3186 | 134 get_elems_byte | ||
| 3187 | 135 get_elems_short | ||
| 3188 | 136 get_elems_int | ||
| 3189 | 137 get_elems_long | ||
| 3190 | 138 get_elems_float | ||
| 3191 | 139 get_elems_double | ||
| 3192 | 140 get_elem_object | ||
| 3193 | 141 get_elem_string | ||
| 3194 | 142 set_elem_object | ||
| 3195 | 143 set_elem_string | ||
| 3196 | 144 get_chars | ||
| 3197 | 145 get_bool_object_value | ||
| 3198 | 146 concat_no_mortal | ||
| 3199 | 147 concat | ||
| 3200 | 148 shorten | ||
| 3201 | 149 make_read_only | ||
| 3202 | 150 is_read_only | ||
| 3203 | 151 print | ||
| 3204 | 152 print_stderr | ||
| 3205 | 153 dump_no_mortal | ||
| 3206 | 154 dump | ||
| 3207 | 155 dumpc | ||
| 3208 | 156 copy_no_mortal | ||
| 3209 | 157 copy | ||
| 3210 | 158 get_spvm_version_string | ||
| 3211 | 159 get_spvm_version_number | ||
| 3212 | 160 get_version_string | ||
| 3213 | 161 get_version_number | ||
| 3214 | 162 die | ||
| 3215 | 163 get_exception | ||
| 3216 | 164 set_exception | ||
| 3217 | 165 push_caller_stack | ||
| 3218 | 166 pop_caller_stack | ||
| 3219 | 167 is_string | ||
| 3220 | 168 is_class | ||
| 3221 | 169 is_pointer_class | ||
| 3222 | 170 is_array | ||
| 3223 | 171 is_object_array | ||
| 3224 | 172 is_numeric_array | ||
| 3225 | 173 is_mulnum_array | ||
| 3226 | 174 isa | ||
| 3227 | 175 isa_by_name | ||
| 3228 | 176 is_type | ||
| 3229 | 177 is_type_by_name | ||
| 3230 | 178 elem_isa | ||
| 3231 | 179 get_elem_size | ||
| 3232 | 180 get_type_name_no_mortal | ||
| 3233 | 181 get_type_name | ||
| 3234 | 182 get_compile_type_name_no_mortal | ||
| 3235 | 183 get_compile_type_name | ||
| 3236 | 184 enter_scope | ||
| 3237 | 185 leave_scope | ||
| 3238 | 186 push_mortal | ||
| 3239 | 187 weaken | ||
| 3240 | 188 isweak | ||
| 3241 | 189 unweaken | ||
| 3242 | 190 strerror_string | ||
| 3243 | 191 strerror_string_nolen | ||
| 3244 | 192 strerror | ||
| 3245 | 193 strerror_nolen | ||
| 3246 | 194 is_binary_compatible_object | ||
| 3247 | 195 is_binary_compatible_stack | ||
| 3248 | 196 new_stack | ||
| 3249 | 197 free_stack | ||
| 3250 | 198 get_field_object_defined_and_has_pointer_by_name | ||
| 3251 | 199 get_field_object_ref | ||
| 3252 | 200 get_field_object_ref_by_name | ||
| 3253 | 201 check_bootstrap_method | ||
| 3254 | 202 assign_object | ||
| 3255 | 203 new_string_array_no_mortal | ||
| 3256 | 204 new_memory_block | ||
| 3257 | 205 free_memory_block | ||
| 3258 | 206 get_memory_blocks_count | ||
| 3259 | 207 say | ||
| 3260 | 208 warn | ||
| 3261 | 209 spvm_stdin | ||
| 3262 | 210 spvm_stdout | ||
| 3263 | 211 spvm_stderr | ||
| 3264 | 212 new_array_proto_element_no_mortal | ||
| 3265 | 213 new_array_proto_element | ||
| 3266 | 214 get_byte_object_value | ||
| 3267 | 215 get_short_object_value | ||
| 3268 | 216 get_int_object_value | ||
| 3269 | 217 get_long_object_value | ||
| 3270 | 218 get_float_object_value | ||
| 3271 | 219 get_double_object_value | ||
| 3272 | 220 no_free | ||
| 3273 | 221 set_no_free | ||
| 3274 | 222 get_stack_tmp_buffer | ||
| 3275 | 223 print_exception_to_stderr | ||
| 3276 | 224 dump_object_internal | ||
| 3277 | 225 get_seed | ||
| 3278 | 226 set_seed | ||
| 3279 | 227 seed_initialized | ||
| 3280 | 228 get_basic_type_name_in_version_from | ||
| 3281 | 229 set_command_info_warning | ||
| 3282 | 230 destroy_cache_class_vars | ||
| 3283 | 231 reserved231 | ||
| 3284 | 232 call_instance_method_no_mortal | ||
| 3285 | 233 call_instance_method | ||
| 3286 | 234 call_method_no_mortal_no_check_args | ||
| 3287 | 235 call_instance_method_no_mortal_less_check_args | ||
| 3288 | 236 enable_options | ||
| 3289 | 237 disable_options | ||
| 3290 | 238 is_options | ||
| 3291 | 239 is_any_object_array | ||
| 3292 | 240 exists_field | ||
| 3293 | 241 exists_field_by_name | ||
| 3294 | 242 delete_field | ||
| 3295 | 243 delete_field_by_name | ||
| 3296 | 244 make_fixed_length | ||
| 3297 | 245 is_fixed_length | ||
| 3298 | 246 set_length | ||
| 3299 | 247 capacity | ||
| 3300 | 248 set_capacity | ||
| 3301 | 249 numeric_object_to_byte | ||
| 3302 | 250 numeric_object_to_short | ||
| 3303 | 251 numeric_object_to_int | ||
| 3304 | 252 numeric_object_to_long | ||
| 3305 | 253 numeric_object_to_float | ||
| 3306 | 254 numeric_object_to_double | ||
| 3307 | 255 numeric_object_to_string_no_mortal | ||
| 3308 | 256 numeric_object_to_string | ||
| 3309 | 257 is_numeric_object | ||
| 3310 | 258 say_stderr | ||
| 3311 | 259 get_call_depth | ||
| 3312 | 260 get_caller_info_stack | ||
| 3313 | 261 get_caller_info_stack_record_size | ||
| 3314 | 262 get_current_method | ||
| 3315 | 263 caller_no_mortal | ||
| 3316 | 264 caller | ||
| 3317 | 265 die_with_string | ||
| 3318 | 266 build_exception_message_no_mortal | ||
| 3319 | 267 build_exception_message | ||
| 3320 | 268 call_end_methods | ||
| 3321 | 269 is_utf8 | ||
| 3322 | 270 set_byte_object_value | ||
| 3323 | 271 set_short_object_value | ||
| 3324 | 272 set_int_object_value | ||
| 3325 | 273 set_long_object_value | ||
| 3326 | 274 set_float_object_value | ||
| 3327 | 275 set_double_object_value | ||
| 3328 | 276 get_exception_chars | ||
| 3329 | 277 get_error_id | ||
| 3330 | 278 set_error_id | ||
| 3331 | 279 no_close | ||
| 3332 | 280 set_no_close | ||
| 3333 | 281 longmess_no_mortal | ||
| 3334 | 282 longmess | ||
| 3335 | 283 diag | ||
| 3336 | 284 dump_recorded_objects | ||
| 3337 | 285 dump_recorded_objects_no_mortal | ||
| 3338 | |||
| 3339 | =head1 Constant Values | ||
| 3340 | |||
| 3341 | =head2 Basic Type IDs | ||
| 3342 | |||
| 3343 | =begin html | ||
| 3344 | |||
| 3345 | <table> | ||
| 3346 | <tr> | ||
| 3347 | <th>ID</th><th>Name</th><th>Description</th> | ||
| 3348 | </tr> | ||
| 3349 | <tr> | ||
| 3350 | <td>0</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_UNKNOWN</td><td>The basic type ID for unknown types</td> | ||
| 3351 | </tr> | ||
| 3352 | <tr> | ||
| 3353 | <td>1</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_UNDEF</td><td>The basic type ID of the undef type</td> | ||
| 3354 | </tr> | ||
| 3355 | <tr> | ||
| 3356 | <td>2</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_VOID</td><td>The basic type ID of the void type</td> | ||
| 3357 | </tr> | ||
| 3358 | <tr> | ||
| 3359 | <td>3</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE</td><td>The basic type ID of byte type</td> | ||
| 3360 | </tr> | ||
| 3361 | <tr> | ||
| 3362 | <td>4</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT</td><td>The basic type ID of short type</td> | ||
| 3363 | </tr> | ||
| 3364 | <tr> | ||
| 3365 | <td>5</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_INT</td><td>The basic type ID of int type</td> | ||
| 3366 | </tr> | ||
| 3367 | <tr> | ||
| 3368 | <td>6</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_LONG</td><td>The basic type ID of long type</td> | ||
| 3369 | </tr> | ||
| 3370 | <tr> | ||
| 3371 | <td>7</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT</td><td>The basic type ID of float type</td> | ||
| 3372 | </tr> | ||
| 3373 | <tr> | ||
| 3374 | <td>8</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE</td><td>The basic type ID of double type</td> | ||
| 3375 | </tr> | ||
| 3376 | <tr> | ||
| 3377 | <td>9</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_STRING</td><td>The basic type ID of string type</td> | ||
| 3378 | </tr> | ||
| 3379 | <tr> | ||
| 3380 | <td>10</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_ANY_OBJECT</td><td>The basic type ID of the any object type</td> | ||
| 3381 | </tr> | ||
| 3382 | <tr> | ||
| 3383 | <td>11</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_BYTE_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::Byte">Byte</a> class</td> | ||
| 3384 | </tr> | ||
| 3385 | <tr> | ||
| 3386 | <td>12</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_SHORT_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::Short">Short</a> class</td> | ||
| 3387 | </tr> | ||
| 3388 | <tr> | ||
| 3389 | <td>13</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_INT_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::Int">Int</a> class</td> | ||
| 3390 | </tr> | ||
| 3391 | <tr> | ||
| 3392 | <td>14</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_LONG_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::Long">Long</a> class</td> | ||
| 3393 | </tr> | ||
| 3394 | <tr> | ||
| 3395 | <td>15</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_FLOAT_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::Float">Float</a> class</td> | ||
| 3396 | </tr> | ||
| 3397 | <tr> | ||
| 3398 | <td>16</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_DOUBLE_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::Double">Double</a> class</td> | ||
| 3399 | </tr> | ||
| 3400 | <tr> | ||
| 3401 | <td>17</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_BOOL_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::Bool">Bool</a> class</td> | ||
| 3402 | </tr> | ||
| 3403 | <tr> | ||
| 3404 | <td>18</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_ERROR_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::Error">Error</a> class</td> | ||
| 3405 | </tr> | ||
| 3406 | <tr> | ||
| 3407 | <td>19</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_ERROR_SYSTEM_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::Error::System">Error::System</a> class</td> | ||
| 3408 | </tr> | ||
| 3409 | <tr> | ||
| 3410 | <td>20</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_ERROR_NOT_SUPPORTED_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::Error::NotSupported">Error::NotSupported</a> class</td> | ||
| 3411 | </tr> | ||
| 3412 | <tr> | ||
| 3413 | <td>21</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_COMMAND_INFO_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::CommandInfo">CommandInfo</a> class</td> | ||
| 3414 | </tr> | ||
| 3415 | <tr> | ||
| 3416 | <td>22</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_ADDRESS_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::Address">Address</a> class</td> | ||
| 3417 | </tr> | ||
| 3418 | <tr> | ||
| 3419 | <td>23</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_ERROR_COMPILE_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::Error::Compile">Error::Compile</a> class</td> | ||
| 3420 | </tr> | ||
| 3421 | <tr> | ||
| 3422 | <td>24</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_SPVM_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::Error::Compile">Error::Compile</a> class</td> | ||
| 3423 | </tr> | ||
| 3424 | <tr> | ||
| 3425 | <td>25</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_ERROR_METHOD_CALL_NOT_PERMITTED_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::Error::MethodCallNotPermitted">Error::MethodCallNotPermitted</a> class</td> | ||
| 3426 | </tr> | ||
| 3427 | <tr> | ||
| 3428 | <td>26</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_STRINGABLE_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::Stringable">Stringable</a> class</td> | ||
| 3429 | </tr> | ||
| 3430 | <tr> | ||
| 3431 | <td>27</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_COUNTABLE_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::Countable">Countable</a> class</td> | ||
| 3432 | </tr> | ||
| 3433 | <tr> | ||
| 3434 | <td>28</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_CALLER_INFO_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::CallerInfo">CallerInfo</a> class</td> | ||
| 3435 | </tr> | ||
| 3436 | <tr> | ||
| 3437 | <td>29</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_CLONEABLE_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::Cloneable">Cloneable</a> class</td> | ||
| 3438 | </tr> | ||
| 3439 | <tr> | ||
| 3440 | <td>30</td><td>SPVM_NATIVE_C_BASIC_TYPE_ID_ERROR_FIELD_NOT_SPECIFIED_CLASS</td><td>The basic type ID of the <a href="https://metacpan.org/pod/SPVM::Error::FieldNotSpecified">Error::FieldNotSpecified</a> class</td> | ||
| 3441 | </tr> | ||
| 3442 | </table> | ||
| 3443 | |||
| 3444 | =end html | ||
| 3445 | |||
| 3446 | =head2 Basic Type Category IDs | ||
| 3447 | |||
| 3448 | =begin html | ||
| 3449 | |||
| 3450 | <table> | ||
| 3451 | <tr> | ||
| 3452 | <th>ID</th><th>Name</th><th>Description</th> | ||
| 3453 | </tr> | ||
| 3454 | <tr> | ||
| 3455 | <td>0</td><td>SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_UNKNOWN</td><td>The basic type category for unknown types</td> | ||
| 3456 | </tr> | ||
| 3457 | <tr> | ||
| 3458 | <td>1</td><td>SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_UNDEF</td><td>The basic type category for the undef type</td> | ||
| 3459 | </tr> | ||
| 3460 | <tr> | ||
| 3461 | <td>2</td><td>SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_VOID</td><td>The basic type category for the void type</td> | ||
| 3462 | </tr> | ||
| 3463 | <tr> | ||
| 3464 | <td>3</td><td>SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_NUMERIC</td><td>The basic type category for numeric types</td> | ||
| 3465 | </tr> | ||
| 3466 | <tr> | ||
| 3467 | <td>4</td><td>SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_MULNUM</td><td>The basic type category for multi-numeric types</td> | ||
| 3468 | </tr> | ||
| 3469 | <tr> | ||
| 3470 | <td>5</td><td>SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_STRING</td><td>The basic type category for string type</td> | ||
| 3471 | </tr> | ||
| 3472 | <tr> | ||
| 3473 | <td>6</td><td>SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_CLASS</td><td>The basic type category for class types</td> | ||
| 3474 | </tr> | ||
| 3475 | <tr> | ||
| 3476 | <td>7</td><td>SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_INTERFACE</td><td>The basic type category for interface types</td> | ||
| 3477 | </tr> | ||
| 3478 | <tr> | ||
| 3479 | <td>8</td><td>SPVM_NATIVE_C_BASIC_TYPE_CATEGORY_ANY_OBJECT</td><td>The basic type category for the any object type</td> | ||
| 3480 | </tr> | ||
| 3481 | </table> | ||
| 3482 | |||
| 3483 | =end html | ||
| 3484 | |||
| 3485 | =head2 Type Flag IDs | ||
| 3486 | |||
| 3487 | =begin html | ||
| 3488 | |||
| 3489 | <table> | ||
| 3490 | <tr> | ||
| 3491 | <th>ID</th><th>Name</th><th>Description</th> | ||
| 3492 | </tr> | ||
| 3493 | <tr> | ||
| 3494 | <td>1</td><td>SPVM_NATIVE_C_TYPE_FLAG_REF</td><td>A flag indicating that it is a reference type</td> | ||
| 3495 | </tr> | ||
| 3496 | <tr> | ||
| 3497 | <td>2</td><td>SPVM_NATIVE_C_TYPE_FLAG_MUTABLE</td><td>A flag indicating that a mutable modifier is present</td> | ||
| 3498 | </tr> | ||
| 3499 | <tr> | ||
| 3500 | <td>4</td><td>SPVM_NATIVE_C_TYPE_FLAG_VARARGS</td><td>A flag indicating that a variable length type</td> | ||
| 3501 | </tr> | ||
| 3502 | </table> | ||
| 3503 | |||
| 3504 | =end html | ||
| 3505 | |||
| 3506 | =head2 SPVM_NATIVE_VERSION_NUMBER | ||
| 3507 | |||
| 3508 | C<SPVM_NATIVE_VERSION_NUMBER> | ||
| 3509 | |||
| 3510 | The version number of the SPVM language. | ||
| 3511 | |||
| 3512 | Examples: | ||
| 3513 | |||
| 3514 | // 0.989062 | ||
| 3515 | double spvm_version_number = SPVM_NATIVE_VERSION_NUMBER; | ||
| 3516 | |||
| 3517 | =head2 SPVM_NATIVE_VERSION_STRING | ||
| 3518 | |||
| 3519 | C<SPVM_NATIVE_VERSION_STRING> | ||
| 3520 | |||
| 3521 | The version string of the SPVM language. This is a constant string. | ||
| 3522 | |||
| 3523 | Examples: | ||
| 3524 | |||
| 3525 | // "0.989062" | ||
| 3526 | const char* spvm_version_string = SPVM_NATIVE_VERSION_STRING; | ||
| 3527 | |||
| 3528 | =head2 SPVM_NATIVE_C_STACK_TMP_BUFFER_SIZE | ||
| 3529 | |||
| 3530 | C<SPVM_NATIVE_C_STACK_TMP_BUFFER_SIZE> | ||
| 3531 | |||
| 3532 | The byte size of the temporary buffer in a runtime stack. This value is 512. | ||
| 3533 | |||
| 3534 | =head1 Macro Functions | ||
| 3535 | |||
| 3536 | =head2 spvm_warn | ||
| 3537 | |||
| 3538 | C<#define spvm_warn(format, ...)> | ||
| 3539 | |||
| 3540 | Prints the formatted message I<format> to C<stderr> with the current function name, the current file name, and the current line number. | ||
| 3541 | |||
| 3542 | I<format> must be the C<char*> type. | ||
| 3543 | |||
| 3544 | Examples: | ||
| 3545 | |||
| 3546 | spvm_warn("Hello"); | ||
| 3547 | spvm_warn("Hello %s%d", "Foo", 3); | ||
| 3548 | |||
| 3549 | =head2 spvm_warnf | ||
| 3550 | |||
| 3551 | C<#define spvm_warnf(stream, format, ...)> | ||
| 3552 | |||
| 3553 | Prints the formatted message I<format> to the stream I<stream> with the current function name, the current file name, and the current line number. | ||
| 3554 | |||
| 3555 | I<format> must be the C<char*> type. | ||
| 3556 | |||
| 3557 | I<stream> must be C<FILE> type. | ||
| 3558 | |||
| 3559 | Examples: | ||
| 3560 | |||
| 3561 | spvm_warnf(env->spvm_stderr(env, stack), "Hello"); | ||
| 3562 | spvm_warnf(env->spvm_stderr(env, stack), "Hello %s%d", "Foo", 3); | ||
| 3563 | |||
| 3564 | =head2 SPVM_NATIVE_GET_POINTER | ||
| 3565 | |||
| 3566 | C<#define SPVM_NATIVE_GET_POINTER(object)> | ||
| 3567 | |||
| 3568 | Returns the pointer stored in the object I<object> and returns it. | ||
| 3569 | |||
| 3570 | The return type is the C<SPVM_OBJ*> type. | ||
| 3571 | |||
| 3572 | =head2 SPVM_NATIVE_SET_POINTER | ||
| 3573 | |||
| 3574 | C<#define SPVM_NATIVE_SET_POINTER(object, pointer)> | ||
| 3575 | |||
| 3576 | Sets the pointer I<pointer> of the object I<object>. | ||
| 3577 | |||
| 3578 | =head1 Data Structures | ||
| 3579 | |||
| 3580 | =head2 SPVM_OBJECT | ||
| 3581 | |||
| 3582 | C<SPVM_OBJECT> is an internal data structure for an SPVM object. | ||
| 3583 | |||
| 3584 | typedef struct spvm_object SPVM_OBJECT | ||
| 3585 | struct spvm_object { | ||
| 3586 | void* pointer; | ||
| 3587 | SPVM_WEAKEN_BACKREF* weaken_backref_head; | ||
| 3588 | SPVM_RUNTIME_BASIC_TYPE* basic_type; | ||
| 3589 | int32_t ref_count; | ||
| 3590 | uint8_t type_dimension; | ||
| 3591 | uint8_t flag; | ||
| 3592 | int32_t length; | ||
| 3593 | }; | ||
| 3594 | |||
| 3595 | =head1 See Also | ||
| 3596 | |||
| 3597 | =over 2 | ||
| 3598 | |||
| 3599 | =item * L<SPVM::Document::NativeAPI::Allocator> | ||
| 3600 | |||
| 3601 | =item * L<SPVM::Document::NativeAPI::StringBuffer> | ||
| 3602 | |||
| 3603 | =item * L<SPVM::Document::NativeAPI::Compiler> | ||
| 3604 | |||
| 3605 | =item * L<SPVM::Document::NativeAPI::ClassFile> | ||
| 3606 | |||
| 3607 | =item * L<SPVM::Document::NativeAPI::Runtime> | ||
| 3608 | |||
| 3609 | =item * L<SPVM::Document::NativeAPI::BasicType> | ||
| 3610 | |||
| 3611 | =item * L<SPVM::Document::NativeAPI::ClassVariable> | ||
| 3612 | |||
| 3613 | =item * L<SPVM::Document::NativeAPI::Field> | ||
| 3614 | |||
| 3615 | =item * L<SPVM::Document::NativeAPI::Method> | ||
| 3616 | |||
| 3617 | =item * L<SPVM::Document::NativeAPI::Argument> | ||
| 3618 | |||
| 3619 | =item * L<SPVM::Document::NativeAPI::Type> | ||
| 3620 | |||
| 3621 | =item * L<SPVM::Document::NativeAPI::Internal> | ||
| 3622 | |||
| 3623 | =item * L<SPVM::Document::NativeAPI::Mutex> | ||
| 3624 | |||
| 3625 | =item * L<SPVM::Document::NativeClass> | ||
| 3626 | |||
| 3627 | =item * L<SPVM::Document> | ||
| 3628 | |||
| 3629 | =item * L<Examples using SPVM native APIs|https://github.com/yuki-kimoto/SPVM/tree/master/examples/native> | ||
| 3630 | |||
| 3631 | =back | ||
| 3632 | |||
| 3633 | =head1 Copyright & License | ||
| 3634 | |||
| 3635 | Copyright (c) 2023 Yuki Kimoto | ||
| 3636 | |||
| 3637 | MIT License |