Name

SPVM::Document::NativeAPI::Internal - Internal Native APIs

Description

The internal native APIs in SPVM are the APIs for internal operations.

These APIs are used for the implementation of the SPVM language, so they should not be used.

Usage

SPVM_API_INTERNAL* api_internal = env->api->internal;

Native APIs

get_ref_count

int32_t (*get_ref_count)(SPVM_ENV* env, SPVM_VALUE* stack, SPVM_OBJ* object);

Returns the reference count of the object object.

inc_ref_count

void (*inc_ref_count)(SPVM_ENV* env, SPVM_VALUE* stack, SPVM_OBJ* object);

Increments the reference count of the object object.

dec_ref_count

void (*dec_ref_count)(SPVM_ENV* env, SPVM_VALUE* stack, SPVM_OBJ* object);

Decrements the reference count of the object object.

get_stack_tmp_buffer

char* (*get_stack_tmp_buffer)(SPVM_ENV* env, SPVM_VALUE* stack);

Returns the temporary buffer on the runtime stack stack.

The byte size of the temporary buffer is SPVM_NATIVE_C_STACK_TMP_BUFFER_SIZE.

Currently, this internal native API is the same as get_stack_tmp_buffer native API.

leave_scope_local

void (*leave_scope_local)(SPVM_ENV* env, SPVM_VALUE* stack, SPVM_OBJ** object_vars, int32_t* mortal_stack_typed_var_index, int32_t* mortal_stack_top_ptr, int32_t* mortal_stack_tops, int32_t mortal_stack_tops_index);

Performs a leaving scope operation for local variables given object variables object_vars, the mortal stack mortal_stack, the address of the top of the mortal stack mortal_stack_top_ptr, and the mortal stack tops mortal_stack_tops, and the index of the top of the mortal stack mortal_stack_tops_index.

The value referenced by mortal_stack_top_ptr is updated.

c_strlen

size_t (*c_strlen)(SPVM_ENV* env, SPVM_VALUE* stack, const char* str);

A wrapper for the C standard function strlen.

c_memcpy

void* (*c_memcpy)(SPVM_ENV* env, SPVM_VALUE* stack, void* dest, const void* src, size_t n);

A wrapper for the C standard function memcpy.

c_memset

void* (*c_memset)(SPVM_ENV* env, SPVM_VALUE* stack, void* s, int c, size_t n);

A wrapper for the C standard function memset.

c_memcmp

int (*c_memcmp)(SPVM_ENV* env, SPVM_VALUE* stack, const void* s1, const void* s2, size_t n);

A wrapper for the C standard function memcmp.

c_strtoll

long long (*c_strtoll)(SPVM_ENV* env, SPVM_VALUE* stack, const char* str, char** endptr, int base);

A wrapper for the C standard function strtoll.

c_strtof

float (*c_strtof)(SPVM_ENV* env, SPVM_VALUE* stack, const char* str, char** endptr);

A wrapper for the C standard function strtof.

c_strtod

double (*c_strtod)(SPVM_ENV* env, SPVM_VALUE* stack, const char* str, char** endptr);

A wrapper for the C standard function strtod.

c_fputs

int (*c_fputs)(SPVM_ENV* env, SPVM_VALUE* stack, const char* s, void* stream);

A wrapper for the C standard function fputs.

c_fgetc

int (*c_fgetc)(SPVM_ENV* env, SPVM_VALUE* stack, void* stream);

A wrapper for the C standard function fgetc.

c_snprintf_len

int32_t (*c_snprintf_len)(SPVM_ENV* env, SPVM_VALUE* stack, char* s, size_t n, const char* format, SPVM_VALUE* args, int32_t args_length);

A wrapper for the C standard function snprintf.

This function receives arguments as an array of SPVM_VALUE instead of variadic arguments.

The format specifiers in the format string must match the types of the values stored in args.

For example: * %d, %x: Expects an ival (int32_t). * %ld, %lld (or PRId64): Expects a lval (int64_t). * %f, %g: Expects a dval (double). * %s, %p: Expects an address (void*).

Returns the number of characters that would have been written if n had been sufficiently large, not counting the terminating null character.

Native Internal API IDs

0 get_ref_count
1 inc_ref_count
2 dec_ref_count
3 get_stack_tmp_buffer
4 leave_scope_local
5 c_strlen
6 c_memcpy
7 c_memset
8 c_memcmp
9 c_strtoll
10 c_strtof
11 c_strtod
12 c_fputs
13 c_fgetc
14 c_snprintf_len

See Also

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License