1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_ACE_NAPI_NATIVE_ENGINE_IMPL_QUICKJS_QUICKJS_HEADERS_H 17 #define FOUNDATION_ACE_NAPI_NATIVE_ENGINE_IMPL_QUICKJS_QUICKJS_HEADERS_H 18 19 extern "C" { 20 #include "cutils.h" 21 #include "libbf.h" 22 #include "quickjs-libc.h" 23 } 24 25 typedef void (*JSFinalizer)(JSContext* context, void* data, void* hint); 26 27 JSClassID GetBaseClassID(); 28 29 void AddIntrinsicBaseClass(JSContext* context); 30 void AddIntrinsicExternal(JSContext* context); 31 32 JSValue JS_NewExternal(JSContext* context, void* value, JSFinalizer finalizer, void* hint); 33 void* JS_ExternalToNativeObject(JSContext* context, JSValue value); 34 bool JS_IsExternal(JSContext* context, JSValue value); 35 36 void JS_AddFinalizer(JSContext* context, JSValue value, void* pointer, JSFinalizer finalizer, void* hint); 37 void JS_FreeFinalizer(JSValue value); 38 void JS_SetNativePointer(JSContext* context, JSValue value, void* pointer, JSFinalizer finalizer, void* hint); 39 void* JS_GetNativePointer(JSContext* context, JSValue value); 40 41 bool JS_IsPromise(JSContext* context, JSValue value); 42 bool JS_IsMapIterator(JSContext* context, JSValue value); 43 bool JS_IsSetIterator(JSContext* context, JSValue value); 44 bool JS_IsGeneratorObject(JSContext* context, JSValue value); 45 bool JS_IsModuleNamespaceObject(JSContext* context, JSValue value); 46 bool JS_IsProxy(JSContext* context, JSValue value); 47 bool JS_IsRegExp(JSContext* context, JSValue value); 48 bool JS_IsNumberObject(JSContext* context, JSValue value); 49 bool JS_IsMap(JSContext* context, JSValue value); 50 bool JS_IsSet(JSContext* context, JSValue value); 51 bool JS_IsKeyObject(JSContext* context, JSValue value); 52 53 bool JS_IsArrayBuffer(JSContext* context, JSValue value); 54 bool JS_IsBuffer(JSContext* context, JSValue value); 55 bool JS_IsDate(JSContext* context, JSValue value); 56 bool JS_IsDataView(JSContext* context, JSValue value); 57 bool JS_IsTypedArray(JSContext* context, JSValue value); 58 bool JS_StrictEquals(JSContext* context, JSValue v1, JSValue v2); 59 60 JSValue JS_Seal(JSContext* context, JSValue value); 61 JSValue JS_Freeze(JSContext* context, JSValue value); 62 JSValue JS_StrictDate(JSContext* context, double time); 63 JSValue JS_CreateBigIntWords(JSContext* context, int signBit, size_t wordCount, const uint64_t* words); 64 bool JS_GetBigIntWords(JSContext* context, JSValue value, int* signBit, size_t* wordCount, uint64_t* words); 65 bool JS_ToInt64WithBigInt(JSContext* context, JSValueConst value, int64_t* pres, bool* lossless); 66 bool JS_ToUInt64WithBigInt(JSContext* context, JSValueConst value, uint64_t* pres, bool* lossless); 67 #endif /* FOUNDATION_ACE_NAPI_NATIVE_ENGINE_IMPL_QUICKJS_QUICKJS_HEADERS_H */ 68