harmony 鸿蒙jsvm_types.h

2025-06-12 浏览 (1)

jsvm_types.h

Overview

JSVM-API type definitions.

Through the APIs, independent, standard, and complete JavaScript engine capabilities are provided, including managing the engine lifecycle, compiling and running JS code, implementing JS/C++ cross-language invoking, and taking snapshots.

Library: libjsvm.so

System capability: SystemCapability.ArkCompiler.JSVM

Since: 11

Related module: JSVM

Summary

Structs

NameDescription
struct  JSVM_CallbackStructPointer to and data of the native callbacks provided by the user. These functions are exposed to JavaScript via JSVM-API.
struct  JSVM_HeapStatisticsHeap statistics struct, which is used to store statistics about JavaScript heap memory usage.
struct  JSVM_InitOptionsOptions for initializing a JavaScript VM.
struct  JSVM_CreateVMOptionsOptions for creating a JavaScript VM.
struct  JSVM_VMInfoJavaScript VM information.
struct  JSVM_PropertyDescriptorProperty descriptor.
struct  JSVM_ExtendedErrorInfoExtended error information.
struct  JSVM_TypeTagType tag, stored as a 128-bit value of two unsigned 64-bit integers. This tag can be used as a UUID, so that JavaScript objects can be tagged, to ensure that their types remain unchanged.
struct  JSVM_PropertyHandlerConfigurationStructStruct for triggering the corresponding function callback in the struct when the getter, setter, deleter, or enumerator of an object is executed.
struct  JSVM_ScriptOriginSource code information.

Types

NameDescription
typedef uint16_t char16_t
typedef struct JSVM_VM__ * JSVM_VMJavaScript VM instance.
typedef struct JSVM_VMScope__ * JSVM_VMScopeJavaScript VM scope.
typedef struct JSVM_EnvScope__ * JSVM_EnvScopeEnvironment scope of the current VM instance. The environment is available to the VM instance of the thread only after the thread enters JSVM_EnvScope of the environment through OH_JSVM_OpenEnvScope.
typedef struct JSVM_Script__ * JSVM_ScriptJavaScript code.
typedef struct JSVM_Env__ * JSVM_EnvContext of a specific VM state. It needs to be passed as a parameter when the native function is called and passed to any subsequent JSVM-API nested invoking.
typedef struct JSVM_CpuProfiler__ * JSVM_CpuProfilerJavaScript CPU profiler.
typedef struct JSVM_Value__ * JSVM_ValueJavaScript value.
typedef struct JSVM_Ref__ * JSVM_RefReference to the JavaScript value.
typedef struct JSVM_HandleScope__ * JSVM_HandleScopeScope of the JavaScript value. It is used to control and modify the lifecycle of an object created in a specific scope. Typically, the JSVM-API value is created in the context of JSVM_HandleScope. When the native method is called from JavaScript, the default JSVM_HandleScope exists. If the user does not explicitly create a new JSVM_HandleScope, the JSVM-API value is created in the default JSVM_HandleScope. For any code call other than native method execution (for example, libuv callback), the module needs to create a scope before calling any function that may cause JavaScript value creation. JSVM_HandleScope is created using OH_JSVM_OpenHandleScope and destroyed using OH_JSVM_CloseHandleScope. Closing the scope represents indicating to the GC that all JSVM_Values created during the lifecycle of JSVM_HandleScope will no longer be referenced from the stack frame of the current heap.
typedef struct JSVM_EscapableHandleScope__ * JSVM_EscapableHandleScopeA special type of handle scope, which is used to return the value created in a specific handle scope to the parent scope.
typedef struct JSVM_CallbackInfo__ * JSVM_CallbackInfoAn opaque data type passed to the callback. It can be used to obtain additional information about the context in which the function is called.
typedef struct JSVM_Deferred__ * JSVM_DeferredPromise deferred object.
typedef JSVM_CallbackStruct * JSVM_CallbackPointer types of the native functions provided by user. These functions are exposed to JavaScript via JSVM-API.
typedef void(JSVM_CDECL * JSVM_Finalize) (JSVM_Env env, void *finalizeData, void *finalizeHint)Function pointer type. It is passed in when a native object or data is associated with a JavaScript object. This function is called when the associated JavaScript object is reclaimed by the GC to execute the native cleanup action.
typedef bool(JSVM_CDECL * JSVM_OutputStream) (const char *data, int size, void *streamData)Pointer to the callback of the ASCII output stream. data indicates the pointer to the output data. size indicates the size of the output data. void points to the end of the stream. streamData indicates the pointer passed to the API function together with the callback. The API function generates data to the output stream. If true is returned, the stream can continue to receive data. Otherwise, it aborts the stream.
typedef JSVM_PropertyHandlerConfigurationStruct * JSVM_PropertyHandlerCfgPointer type of the struct that contains the property listening callback.

Enums

NameDescription
JSVM_PropertyAttributes {
JSVM_DEFAULT = 0, JSVM_WRITABLE = 1 << 0, JSVM_ENUMERABLE = 1 << 1, JSVM_CONFIGURABLE = 1 << 2,
JSVM_STATIC = 1 << 10, JSVM_DEFAULT_METHOD = JSVM_WRITABLE |JSVM_CONFIGURABLE, JSVM_DEFAULT_JSPROPERTY = JSVM_WRITABLE |JSVM_ENUMERABLE |JSVM_CONFIGURABLE
}
Control over the behavior of JavaScript object properties.
JSVM_ValueType {
JSVM_UNDEFINED, JSVM_NULL, JSVM_BOOLEAN, JSVM_NUMBER,
JSVM_STRING, JSVM_SYMBOL, JSVM_OBJECT, JSVM_FUNCTION,
JSVM_EXTERNAL, JSVM_BIGINT
}
JSVM_Value type.
JSVM_TypedarrayType {
JSVM_INT8_ARRAY, JSVM_UINT8_ARRAY, JSVM_UINT8_CLAMPED_ARRAY, JSVM_INT16_ARRAY,
JSVM_UINT16_ARRAY, JSVM_INT32_ARRAY, JSVM_UINT32_ARRAY, JSVM_FLOAT32_ARRAY,
JSVM_FLOAT64_ARRAY, JSVM_BIGINT64_ARRAY, JSVM_BIGUINT64_ARRAY
}
TypedArray type.
JSVM_Status {
JSVM_OK, JSVM_INVALID_ARG, JSVM_OBJECT_EXPECTED, JSVM_STRING_EXPECTED,
JSVM_NAME_EXPECTED, JSVM_FUNCTION_EXPECTED, JSVM_NUMBER_EXPECTED, JSVM_BOOLEAN_EXPECTED,
JSVM_ARRAY_EXPECTED, JSVM_GENERIC_FAILURE, JSVM_PENDING_EXCEPTION, JSVM_CANCELLED,
JSVM_ESCAPE_CALLED_TWICE, JSVM_HANDLE_SCOPE_MISMATCH, JSVM_CALLBACK_SCOPE_MISMATCH, JSVM_QUEUE_FULL,
JSVM_CLOSING, JSVM_BIGINT_EXPECTED, JSVM_DATE_EXPECTED, JSVM_ARRAYBUFFER_EXPECTED,
JSVM_DETACHABLE_ARRAYBUFFER_EXPECTED, JSVM_WOULD_DEADLOCK, JSVM_NO_EXTERNAL_BUFFERS_ALLOWED, JSVM_CANNOT_RUN_JS
}
Complete status code indicating whether the JSVM-API call is successful or fails.
JSVM_KeyCollectionMode { JSVM_KEY_INCLUDE_PROTOTYPES, JSVM_KEY_OWN_ONLY }Limited range of properties to be searched for.
JSVM_KeyFilter {
JSVM_KEY_ALL_PROPERTIES = 0, JSVM_KEY_WRITABLE = 1, JSVM_KEY_ENUMERABLE = 1 << 1, JSVM_KEY_CONFIGURABLE = 1 << 2,
JSVM_KEY_SKIP_STRINGS = 1 << 3, JSVM_KEY_SKIP_SYMBOLS = 1 << 4
}
Property filter. You can use OR to construct a composite filter.
JSVM_KeyConversion { JSVM_KEY_KEEP_NUMBERS, JSVM_KEY_NUMBERS_TO_STRINGS }Key conversion option.
JSVM_MemoryPressureLevel { JSVM_MEMORY_PRESSURE_LEVEL_NONE, JSVM_MEMORY_PRESSURE_LEVEL_MODERATE, JSVM_MEMORY_PRESSURE_LEVEL_CRITICAL }Memory pressure level.
JSVM_RegExpFlags {
JSVM_REGEXP_NONE = 0, JSVM_REGEXP_GLOBAL = 1 << 0, JSVM_REGEXP_IGNORE_CASE = 1 << 1, JSVM_REGEXP_MULTILINE = 1 << 2,
JSVM_REGEXP_STICKY = 1 << 3, JSVM_REGEXP_UNICODE = 1 << 4, JSVM_REGEXP_DOT_ALL = 1 << 5, JSVM_REGEXP_LINEAR = 1 << 6,
JSVM_REGEXP_HAS_INDICES = 1 << 7, JSVM_REGEXP_UNICODE_SETS = 1 << 8
}
Regular expression flags. They can be used to enable a set of flags.
JSVM_InitializedFlag { JSVM_ZERO_INITIALIZED, JSVM_UNINITIALIZED }Initialization flag.
JSVM_WasmOptLevel { JSVM_WASM_OPT_BASELINE = 10, JSVM_WASM_OPT_HIGH = 20 }WebAssembly function optimization level.
JSVM_CacheType { JSVM_CACHE_TYPE_JS, JSVM_CACHE_TYPE_WASM }Cache type.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Common Capabilities

harmony 鸿蒙_j_s_v_m

harmony 鸿蒙JSVM_CallbackStruct

harmony 鸿蒙JSVM_CreateVMOptions

harmony 鸿蒙JSVM_ExtendedErrorInfo

harmony 鸿蒙JSVM_HeapStatistics

harmony 鸿蒙JSVM_InitOptions

harmony 鸿蒙JSVM_PropertyDescriptor

harmony 鸿蒙JSVM_PropertyHandlerConfigurationStruct

harmony 鸿蒙JSVM_ScriptOrigin

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/rxXzSU