mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
!7784 Modify params for JSValueRef (ets runtime)
Merge pull request !7784 from xiongluo/JSValueRef
This commit is contained in:
commit
53b83f4e88
@ -320,7 +320,7 @@ int32_t DebuggerApi::GetObjectHash(const EcmaVM *ecmaVM, const JSHandle<JSTagged
|
||||
|
||||
void DebuggerApi::GetObjectClassName(const EcmaVM *ecmaVM, Local<JSValueRef> &tagged, std::string &className)
|
||||
{
|
||||
if (!tagged->IsObject()) {
|
||||
if (!tagged->IsObject(ecmaVM)) {
|
||||
return;
|
||||
}
|
||||
Local<JSValueRef> prototype = Local<ObjectRef>(tagged)->GetPrototype(ecmaVM);
|
||||
|
@ -301,7 +301,7 @@ bool JSDebugger::IsBreakpointCondSatisfied(std::optional<JSBreakpoint> breakpoin
|
||||
}
|
||||
JSThread *thread = ecmaVm_->GetJSThread();
|
||||
auto condFuncRef = breakpoint.value().GetConditionFunction();
|
||||
if (condFuncRef->IsFunction()) {
|
||||
if (condFuncRef->IsFunction(ecmaVm_)) {
|
||||
LOG_DEBUGGER(INFO) << "BreakpointCondition: evaluating condition";
|
||||
auto handlerPtr = std::make_shared<FrameHandler>(ecmaVm_->GetJSThread());
|
||||
auto evalResult = DebuggerApi::EvaluateViaFuncCall(const_cast<EcmaVM *>(ecmaVm_),
|
||||
|
@ -437,7 +437,7 @@ bool SourceTextModule::LoadNativeModule(JSThread *thread, const JSHandle<SourceT
|
||||
}
|
||||
auto maybeFuncRef = GetRequireNativeModuleFunc(vm, moduleType);
|
||||
// some function(s) may not registered in global object for non-main thread
|
||||
if (!maybeFuncRef->IsFunction()) {
|
||||
if (!maybeFuncRef->IsFunction(vm)) {
|
||||
LOG_FULL(WARN) << "Not found require func";
|
||||
return false;
|
||||
}
|
||||
@ -448,7 +448,7 @@ bool SourceTextModule::LoadNativeModule(JSThread *thread, const JSHandle<SourceT
|
||||
LOG_FULL(ERROR) << "export objects of native so is undefined, so name is " << moduleName;
|
||||
return false;
|
||||
}
|
||||
if (UNLIKELY(exportObject->IsNativeModuleErrorObject())) {
|
||||
if (UNLIKELY(exportObject->IsNativeModuleErrorObject(vm))) {
|
||||
requiredModule->StoreModuleValue(thread, 0, JSNApiHelper::ToJSHandle(exportObject));
|
||||
LOG_FULL(ERROR) << "loading fails, NativeModuleErrorObject is returned";
|
||||
return false;
|
||||
|
@ -94,7 +94,7 @@ static constexpr size_t DEFAULT_LONG_PAUSE_TIME = 40;
|
||||
class ECMA_PUBLIC_API RegExpRef : public ObjectRef {
|
||||
public:
|
||||
Local<StringRef> GetOriginalSource(const EcmaVM *vm);
|
||||
std::string GetOriginalFlags();
|
||||
std::string GetOriginalFlags(const EcmaVM *vm);
|
||||
Local<JSValueRef> IsGlobal(const EcmaVM *vm);
|
||||
Local<JSValueRef> IsIgnoreCase(const EcmaVM *vm);
|
||||
Local<JSValueRef> IsMultiline(const EcmaVM *vm);
|
||||
@ -105,7 +105,7 @@ public:
|
||||
|
||||
class ECMA_PUBLIC_API GeneratorFunctionRef : public ObjectRef {
|
||||
public:
|
||||
bool IsGenerator();
|
||||
bool IsGenerator(const EcmaVM *vm);
|
||||
};
|
||||
|
||||
class ECMA_PUBLIC_API GeneratorObjectRef : public ObjectRef {
|
||||
|
@ -412,113 +412,114 @@ public:
|
||||
bool IsTrue();
|
||||
bool IsFalse();
|
||||
bool IsNumber();
|
||||
bool IsBigInt();
|
||||
bool IsBigInt(const EcmaVM *vm);
|
||||
bool IsInt();
|
||||
bool WithinInt32();
|
||||
bool IsBoolean();
|
||||
bool IsString();
|
||||
bool IsSymbol();
|
||||
bool IsObject();
|
||||
bool IsString(const EcmaVM *vm);
|
||||
bool IsSymbol(const EcmaVM *vm);
|
||||
bool IsObject(const EcmaVM *vm);
|
||||
bool IsArray(const EcmaVM *vm);
|
||||
bool IsJSArray(const EcmaVM *vm);
|
||||
bool IsConstructor();
|
||||
bool IsFunction();
|
||||
bool IsJSFunction();
|
||||
bool IsProxy();
|
||||
bool IsPromise();
|
||||
bool IsDataView();
|
||||
bool IsTypedArray();
|
||||
bool IsNativePointer();
|
||||
bool IsDate();
|
||||
bool IsError();
|
||||
bool IsMap();
|
||||
bool IsSet();
|
||||
bool IsWeakRef();
|
||||
bool IsWeakMap();
|
||||
bool IsWeakSet();
|
||||
bool IsRegExp();
|
||||
bool IsArrayIterator();
|
||||
bool IsStringIterator();
|
||||
bool IsSetIterator();
|
||||
bool IsMapIterator();
|
||||
bool IsArrayBuffer();
|
||||
bool IsBuffer();
|
||||
bool IsUint8Array();
|
||||
bool IsInt8Array();
|
||||
bool IsUint8ClampedArray();
|
||||
bool IsInt16Array();
|
||||
bool IsUint16Array();
|
||||
bool IsInt32Array();
|
||||
bool IsUint32Array();
|
||||
bool IsFloat32Array();
|
||||
bool IsFloat64Array();
|
||||
bool IsBigInt64Array();
|
||||
bool IsBigUint64Array();
|
||||
bool IsJSPrimitiveRef();
|
||||
bool IsJSPrimitiveNumber();
|
||||
bool IsJSPrimitiveInt();
|
||||
bool IsJSPrimitiveBoolean();
|
||||
bool IsJSPrimitiveString();
|
||||
bool IsConstructor(const EcmaVM *vm);
|
||||
bool IsFunction(const EcmaVM *vm);
|
||||
|
||||
bool IsJSSharedInt8Array();
|
||||
bool IsJSSharedUint8Array();
|
||||
bool IsJSSharedUint8ClampedArray();
|
||||
bool IsJSSharedInt16Array();
|
||||
bool IsJSSharedUint16Array();
|
||||
bool IsJSSharedInt32Array();
|
||||
bool IsJSSharedUint32Array();
|
||||
bool IsJSFunction(const EcmaVM *vm);
|
||||
bool IsProxy(const EcmaVM *vm);
|
||||
bool IsPromise(const EcmaVM *vm);
|
||||
bool IsDataView(const EcmaVM *vm);
|
||||
bool IsTypedArray(const EcmaVM *vm);
|
||||
bool IsNativePointer(const EcmaVM *vm);
|
||||
bool IsDate(const EcmaVM *vm);
|
||||
bool IsError(const EcmaVM *vm);
|
||||
bool IsMap(const EcmaVM *vm);
|
||||
bool IsSet(const EcmaVM *vm);
|
||||
bool IsWeakRef(const EcmaVM *vm);
|
||||
bool IsWeakMap(const EcmaVM *vm);
|
||||
bool IsWeakSet(const EcmaVM *vm);
|
||||
bool IsRegExp(const EcmaVM *vm);
|
||||
bool IsArrayIterator(const EcmaVM *vm);
|
||||
bool IsStringIterator(const EcmaVM *vm);
|
||||
bool IsSetIterator(const EcmaVM *vm);
|
||||
bool IsMapIterator(const EcmaVM *vm);
|
||||
bool IsArrayBuffer(const EcmaVM *vm);
|
||||
bool IsBuffer(const EcmaVM *vm);
|
||||
bool IsUint8Array(const EcmaVM *vm);
|
||||
bool IsInt8Array(const EcmaVM *vm);
|
||||
bool IsUint8ClampedArray(const EcmaVM *vm);
|
||||
bool IsInt16Array(const EcmaVM *vm);
|
||||
bool IsUint16Array(const EcmaVM *vm);
|
||||
bool IsInt32Array(const EcmaVM *vm);
|
||||
bool IsUint32Array(const EcmaVM *vm);
|
||||
bool IsFloat32Array(const EcmaVM *vm);
|
||||
bool IsFloat64Array(const EcmaVM *vm);
|
||||
bool IsBigInt64Array(const EcmaVM *vm);
|
||||
bool IsBigUint64Array(const EcmaVM *vm);
|
||||
bool IsJSPrimitiveRef(const EcmaVM *vm);
|
||||
bool IsJSPrimitiveNumber(const EcmaVM *vm);
|
||||
bool IsJSPrimitiveInt(const EcmaVM *vm);
|
||||
bool IsJSPrimitiveBoolean(const EcmaVM *vm);
|
||||
bool IsJSPrimitiveString(const EcmaVM *vm);
|
||||
|
||||
bool IsGeneratorObject();
|
||||
bool IsJSPrimitiveSymbol();
|
||||
bool IsJSSharedInt8Array(const EcmaVM *vm);
|
||||
bool IsJSSharedUint8Array(const EcmaVM *vm);
|
||||
bool IsJSSharedUint8ClampedArray(const EcmaVM *vm);
|
||||
bool IsJSSharedInt16Array(const EcmaVM *vm);
|
||||
bool IsJSSharedUint16Array(const EcmaVM *vm);
|
||||
bool IsJSSharedInt32Array(const EcmaVM *vm);
|
||||
bool IsJSSharedUint32Array(const EcmaVM *vm);
|
||||
|
||||
bool IsArgumentsObject();
|
||||
bool IsGeneratorFunction();
|
||||
bool IsAsyncFunction();
|
||||
bool IsConcurrentFunction();
|
||||
bool IsJSLocale();
|
||||
bool IsJSDateTimeFormat();
|
||||
bool IsJSRelativeTimeFormat();
|
||||
bool IsJSIntl();
|
||||
bool IsJSNumberFormat();
|
||||
bool IsJSCollator();
|
||||
bool IsJSPluralRules();
|
||||
bool IsJSListFormat();
|
||||
bool IsAsyncGeneratorFunction();
|
||||
bool IsAsyncGeneratorObject();
|
||||
bool IsGeneratorObject(const EcmaVM *vm);
|
||||
bool IsJSPrimitiveSymbol(const EcmaVM *vm);
|
||||
|
||||
bool IsModuleNamespaceObject();
|
||||
bool IsNativeModuleErrorObject();
|
||||
bool IsSharedArrayBuffer();
|
||||
bool IsSendableArrayBuffer();
|
||||
bool IsArgumentsObject(const EcmaVM *vm);
|
||||
bool IsGeneratorFunction(const EcmaVM *vm);
|
||||
bool IsAsyncFunction(const EcmaVM *vm);
|
||||
bool IsConcurrentFunction(const EcmaVM *vm);
|
||||
bool IsJSLocale(const EcmaVM *vm);
|
||||
bool IsJSDateTimeFormat(const EcmaVM *vm);
|
||||
bool IsJSRelativeTimeFormat(const EcmaVM *vm);
|
||||
bool IsJSIntl(const EcmaVM *vm);
|
||||
bool IsJSNumberFormat(const EcmaVM *vm);
|
||||
bool IsJSCollator(const EcmaVM *vm);
|
||||
bool IsJSPluralRules(const EcmaVM *vm);
|
||||
bool IsJSListFormat(const EcmaVM *vm);
|
||||
bool IsAsyncGeneratorFunction(const EcmaVM *vm);
|
||||
bool IsAsyncGeneratorObject(const EcmaVM *vm);
|
||||
|
||||
bool IsModuleNamespaceObject(const EcmaVM *vm);
|
||||
bool IsNativeModuleErrorObject(const EcmaVM *vm);
|
||||
bool IsSharedArrayBuffer(const EcmaVM *vm);
|
||||
bool IsSendableArrayBuffer(const EcmaVM *vm);
|
||||
|
||||
bool IsStrictEquals(const EcmaVM *vm, Local<JSValueRef> value);
|
||||
Local<StringRef> Typeof(const EcmaVM *vm);
|
||||
bool InstanceOf(const EcmaVM *vm, Local<JSValueRef> value);
|
||||
|
||||
bool IsArrayList();
|
||||
bool IsDeque();
|
||||
bool IsHashMap();
|
||||
bool IsHashSet();
|
||||
bool IsLightWeightMap();
|
||||
bool IsLightWeightSet();
|
||||
bool IsLinkedList();
|
||||
bool IsLinkedListIterator();
|
||||
bool IsList();
|
||||
bool IsPlainArray();
|
||||
bool IsQueue();
|
||||
bool IsStack();
|
||||
bool IsTreeMap();
|
||||
bool IsTreeSet();
|
||||
bool IsVector();
|
||||
bool IsSendableObject();
|
||||
bool IsJSShared();
|
||||
bool IsSharedArray();
|
||||
bool IsSharedTypedArray();
|
||||
bool IsSharedSet();
|
||||
bool IsSharedMap();
|
||||
bool IsArrayList(const EcmaVM *vm);
|
||||
bool IsDeque(const EcmaVM *vm);
|
||||
bool IsHashMap(const EcmaVM *vm);
|
||||
bool IsHashSet(const EcmaVM *vm);
|
||||
bool IsLightWeightMap(const EcmaVM *vm);
|
||||
bool IsLightWeightSet(const EcmaVM *vm);
|
||||
bool IsLinkedList(const EcmaVM *vm);
|
||||
bool IsLinkedListIterator(const EcmaVM *vm);
|
||||
bool IsList(const EcmaVM *vm);
|
||||
bool IsPlainArray(const EcmaVM *vm);
|
||||
bool IsQueue(const EcmaVM *vm);
|
||||
bool IsStack(const EcmaVM *vm);
|
||||
bool IsTreeMap(const EcmaVM *vm);
|
||||
bool IsTreeSet(const EcmaVM *vm);
|
||||
bool IsVector(const EcmaVM *vm);
|
||||
bool IsSendableObject(const EcmaVM *vm);
|
||||
bool IsJSShared(const EcmaVM *vm);
|
||||
bool IsSharedArray(const EcmaVM *vm);
|
||||
bool IsSharedTypedArray(const EcmaVM *vm);
|
||||
bool IsSharedSet(const EcmaVM *vm);
|
||||
bool IsSharedMap(const EcmaVM *vm);
|
||||
bool IsHeapObject();
|
||||
void *GetNativePointerValue(const EcmaVM *vm, bool &isNativePointer);
|
||||
bool IsDetachedArraybuffer(bool &isArrayBuffer);
|
||||
bool IsDetachedArraybuffer(const EcmaVM *vm, bool &isArrayBuffer);
|
||||
void DetachedArraybuffer(const EcmaVM *vm, bool &isArrayBuffer);
|
||||
void GetDataViewInfo(const EcmaVM *vm,
|
||||
bool &isDataView,
|
||||
@ -847,9 +848,9 @@ public:
|
||||
std::string DebuggerToString();
|
||||
uint32_t Length();
|
||||
int32_t Utf8Length(const EcmaVM *vm);
|
||||
int WriteUtf8(char *buffer, int length, bool isWriteBuffer = false);
|
||||
int WriteUtf16(char16_t *buffer, int length);
|
||||
int WriteLatin1(char *buffer, int length);
|
||||
int WriteUtf8(const EcmaVM *vm, char *buffer, int length, bool isWriteBuffer = false);
|
||||
int WriteUtf16(const EcmaVM *vm, char16_t *buffer, int length);
|
||||
int WriteLatin1(const EcmaVM *vm, char *buffer, int length);
|
||||
static Local<StringRef> GetNapiWrapperString(const EcmaVM *vm);
|
||||
};
|
||||
|
||||
@ -974,10 +975,10 @@ public:
|
||||
const NativePointerCallback &deleter, void *data);
|
||||
|
||||
int32_t ByteLength(const EcmaVM *vm);
|
||||
void *GetBuffer();
|
||||
void *GetBuffer(const EcmaVM *vm);
|
||||
|
||||
void Detach(const EcmaVM *vm);
|
||||
bool IsDetach();
|
||||
bool IsDetach(const EcmaVM *vm);
|
||||
};
|
||||
|
||||
class ECMA_PUBLIC_API SendableArrayBufferRef : public ObjectRef {
|
||||
@ -987,10 +988,10 @@ public:
|
||||
const NativePointerCallback &deleter, void *data);
|
||||
|
||||
int32_t ByteLength(const EcmaVM *vm);
|
||||
void *GetBuffer();
|
||||
void *GetBuffer(const EcmaVM *vm);
|
||||
|
||||
void Detach(const EcmaVM *vm);
|
||||
bool IsDetach();
|
||||
bool IsDetach(const EcmaVM *vm);
|
||||
};
|
||||
|
||||
class ECMA_PUBLIC_API DateRef : public ObjectRef {
|
||||
@ -1282,7 +1283,7 @@ public:
|
||||
void *data);
|
||||
|
||||
int32_t ByteLength(const EcmaVM *vm);
|
||||
void *GetBuffer();
|
||||
void *GetBuffer(const EcmaVM *vm);
|
||||
static ecmascript::JSTaggedValue BufferToStringCallback(ecmascript::EcmaRuntimeCallInfo *ecmaRuntimeCallInfo);
|
||||
};
|
||||
|
||||
|
@ -300,7 +300,7 @@ Local<StringRef> RegExpRef::GetOriginalSource(const EcmaVM *vm)
|
||||
return JSNApiHelper::ToLocal<StringRef>(sourceHandle);
|
||||
}
|
||||
|
||||
std::string RegExpRef::GetOriginalFlags()
|
||||
std::string RegExpRef::GetOriginalFlags([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
DCHECK_SPECIAL_VALUE_WITH_RETURN(this, "");
|
||||
JSHandle<JSRegExp> regExp(JSNApiHelper::ToJSHandle(this));
|
||||
@ -395,11 +395,11 @@ Local<JSValueRef> RegExpRef::IsStick(const EcmaVM *vm)
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
bool GeneratorFunctionRef::IsGenerator()
|
||||
bool GeneratorFunctionRef::IsGenerator(const EcmaVM *vm)
|
||||
{
|
||||
// Omit exception check because ark calls here may not
|
||||
// cause side effect even pending exception exists.
|
||||
return IsGeneratorFunction();
|
||||
return IsGeneratorFunction(vm);
|
||||
}
|
||||
|
||||
Local<JSValueRef> GeneratorObjectRef::GetGeneratorState(const EcmaVM *vm)
|
||||
|
@ -511,7 +511,7 @@ bool JSValueRef::IsNumber()
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsNumber();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsBigInt()
|
||||
bool JSValueRef::IsBigInt([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsBigInt();
|
||||
}
|
||||
@ -531,22 +531,22 @@ bool JSValueRef::IsBoolean()
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsBoolean();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsString()
|
||||
bool JSValueRef::IsString([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsString();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsSymbol()
|
||||
bool JSValueRef::IsSymbol([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsSymbol();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsObject()
|
||||
bool JSValueRef::IsObject([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsECMAObject();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsArray(const EcmaVM *vm)
|
||||
bool JSValueRef::IsArray([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
CROSS_THREAD_CHECK(vm);
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsArray(thread);
|
||||
@ -557,447 +557,448 @@ bool JSValueRef::IsJSArray([[maybe_unused]] const EcmaVM *vm)
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSArray();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsConstructor()
|
||||
bool JSValueRef::IsConstructor([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
JSTaggedValue value = JSNApiHelper::ToJSTaggedValue(this);
|
||||
return value.IsHeapObject() && value.IsConstructor();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsFunction()
|
||||
bool JSValueRef::IsFunction([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
JSTaggedValue value = JSNApiHelper::ToJSTaggedValue(this);
|
||||
return value.IsCallable();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSFunction()
|
||||
bool JSValueRef::IsJSFunction([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
JSTaggedValue value = JSNApiHelper::ToJSTaggedValue(this);
|
||||
return value.IsJSFunction();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsProxy()
|
||||
bool JSValueRef::IsProxy([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSProxy();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsPromise()
|
||||
bool JSValueRef::IsPromise([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSPromise();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsDataView()
|
||||
bool JSValueRef::IsDataView([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsDataView();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsTypedArray()
|
||||
bool JSValueRef::IsTypedArray([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsTypedArray();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsNativePointer()
|
||||
bool JSValueRef::IsNativePointer([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSNativePointer();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsDate()
|
||||
bool JSValueRef::IsDate([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsDate();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsError()
|
||||
bool JSValueRef::IsError([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSError();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsMap()
|
||||
bool JSValueRef::IsMap([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSMap();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsSet()
|
||||
bool JSValueRef::IsSet([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSSet();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsWeakRef()
|
||||
bool JSValueRef::IsWeakRef([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSWeakRef();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsWeakMap()
|
||||
bool JSValueRef::IsWeakMap([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSWeakMap();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsWeakSet()
|
||||
bool JSValueRef::IsWeakSet([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSWeakSet();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsRegExp()
|
||||
bool JSValueRef::IsRegExp([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSRegExp();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsArrayIterator()
|
||||
bool JSValueRef::IsArrayIterator([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSArrayIterator();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsStringIterator()
|
||||
bool JSValueRef::IsStringIterator([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsStringIterator();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsSetIterator()
|
||||
bool JSValueRef::IsSetIterator([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSSetIterator();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsMapIterator()
|
||||
bool JSValueRef::IsMapIterator([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSMapIterator();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsArrayBuffer()
|
||||
bool JSValueRef::IsArrayBuffer([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsArrayBuffer();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsBuffer()
|
||||
bool JSValueRef::IsBuffer([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsArrayBuffer();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsUint8Array()
|
||||
bool JSValueRef::IsUint8Array([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSUint8Array();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsInt8Array()
|
||||
bool JSValueRef::IsInt8Array([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSInt8Array();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsUint8ClampedArray()
|
||||
bool JSValueRef::IsUint8ClampedArray([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSUint8ClampedArray();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsInt16Array()
|
||||
bool JSValueRef::IsInt16Array([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSInt16Array();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsUint16Array()
|
||||
bool JSValueRef::IsUint16Array([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSUint16Array();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsInt32Array()
|
||||
bool JSValueRef::IsInt32Array([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSInt32Array();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsUint32Array()
|
||||
bool JSValueRef::IsUint32Array([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSUint32Array();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsFloat32Array()
|
||||
bool JSValueRef::IsFloat32Array([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSFloat32Array();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsFloat64Array()
|
||||
bool JSValueRef::IsFloat64Array([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSFloat64Array();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsBigInt64Array()
|
||||
bool JSValueRef::IsBigInt64Array([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSBigInt64Array();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsBigUint64Array()
|
||||
bool JSValueRef::IsBigUint64Array([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSBigUint64Array();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSSharedInt8Array()
|
||||
bool JSValueRef::IsJSSharedInt8Array([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSSharedInt8Array();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSSharedUint8Array()
|
||||
bool JSValueRef::IsJSSharedUint8Array([[maybe_unused]]const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSSharedUint8Array();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSSharedUint8ClampedArray()
|
||||
bool JSValueRef::IsJSSharedUint8ClampedArray([[maybe_unused]]const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSSharedUint8ClampedArray();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSSharedInt16Array()
|
||||
bool JSValueRef::IsJSSharedInt16Array([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSSharedInt16Array();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSSharedUint16Array()
|
||||
bool JSValueRef::IsJSSharedUint16Array([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSSharedUint16Array();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSSharedInt32Array()
|
||||
bool JSValueRef::IsJSSharedInt32Array([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSSharedInt32Array();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSSharedUint32Array()
|
||||
bool JSValueRef::IsJSSharedUint32Array([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSSharedUint32Array();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSPrimitiveRef()
|
||||
bool JSValueRef::IsJSPrimitiveRef([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSPrimitiveRef();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSPrimitiveNumber()
|
||||
bool JSValueRef::IsJSPrimitiveNumber([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
JSHandle<JSTaggedValue> obj = JSNApiHelper::ToJSHandle(this);
|
||||
LOG_IF_SPECIAL(obj, FATAL);
|
||||
return JSPrimitiveRef::Cast(obj->GetTaggedObject())->IsNumber();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSPrimitiveInt()
|
||||
bool JSValueRef::IsJSPrimitiveInt([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
JSHandle<JSTaggedValue> obj = JSNApiHelper::ToJSHandle(this);
|
||||
LOG_IF_SPECIAL(obj, FATAL);
|
||||
return JSPrimitiveRef::Cast(obj->GetTaggedObject())->IsInt();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSPrimitiveBoolean()
|
||||
bool JSValueRef::IsJSPrimitiveBoolean([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
JSHandle<JSTaggedValue> obj = JSNApiHelper::ToJSHandle(this);
|
||||
LOG_IF_SPECIAL(obj, FATAL);
|
||||
return JSPrimitiveRef::Cast(obj->GetTaggedObject())->IsBoolean();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSPrimitiveString()
|
||||
bool JSValueRef::IsJSPrimitiveString([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
JSHandle<JSTaggedValue> obj = JSNApiHelper::ToJSHandle(this);
|
||||
LOG_IF_SPECIAL(obj, FATAL);
|
||||
return JSPrimitiveRef::Cast(obj->GetTaggedObject())->IsString();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSPrimitiveSymbol()
|
||||
bool JSValueRef::IsJSPrimitiveSymbol([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
JSHandle<JSTaggedValue> obj = JSNApiHelper::ToJSHandle(this);
|
||||
LOG_IF_SPECIAL(obj, FATAL);
|
||||
return JSPrimitiveRef::Cast(obj->GetTaggedObject())->IsSymbol();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsGeneratorObject()
|
||||
bool JSValueRef::IsGeneratorObject([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsGeneratorObject();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsModuleNamespaceObject()
|
||||
bool JSValueRef::IsModuleNamespaceObject([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsModuleNamespace();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsNativeModuleErrorObject()
|
||||
bool JSValueRef::IsNativeModuleErrorObject([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsNativeModuleError();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsSharedArrayBuffer()
|
||||
bool JSValueRef::IsSharedArrayBuffer([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsSharedArrayBuffer();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsSendableArrayBuffer()
|
||||
bool JSValueRef::IsSendableArrayBuffer([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsSendableArrayBuffer();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSLocale()
|
||||
bool JSValueRef::IsJSLocale([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSLocale();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSDateTimeFormat()
|
||||
bool JSValueRef::IsJSDateTimeFormat([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSDateTimeFormat();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSRelativeTimeFormat()
|
||||
bool JSValueRef::IsJSRelativeTimeFormat([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSRelativeTimeFormat();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSIntl()
|
||||
bool JSValueRef::IsJSIntl([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSIntl();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSNumberFormat()
|
||||
bool JSValueRef::IsJSNumberFormat([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSNumberFormat();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSCollator()
|
||||
bool JSValueRef::IsJSCollator([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSCollator();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSPluralRules()
|
||||
bool JSValueRef::IsJSPluralRules([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSPluralRules();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSListFormat()
|
||||
bool JSValueRef::IsJSListFormat([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSListFormat();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsAsyncGeneratorObject()
|
||||
bool JSValueRef::IsAsyncGeneratorObject([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsAsyncGeneratorObject();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsAsyncFunction()
|
||||
bool JSValueRef::IsAsyncFunction([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSAsyncFunction();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsConcurrentFunction()
|
||||
bool JSValueRef::IsConcurrentFunction([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
JSHandle<JSTaggedValue> funcVal = JSNApiHelper::ToJSHandle(this);
|
||||
JSHandle<JSFunction> transFunc = JSHandle<JSFunction>::Cast(funcVal);
|
||||
return transFunc->GetFunctionKind() == ecmascript::FunctionKind::CONCURRENT_FUNCTION;
|
||||
}
|
||||
|
||||
bool JSValueRef::IsArgumentsObject()
|
||||
bool JSValueRef::IsArgumentsObject([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsArguments();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsGeneratorFunction()
|
||||
bool JSValueRef::IsGeneratorFunction([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsGeneratorFunction();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsAsyncGeneratorFunction()
|
||||
bool JSValueRef::IsAsyncGeneratorFunction([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsAsyncGeneratorFunction();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsArrayList()
|
||||
bool JSValueRef::IsArrayList([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSAPIArrayList();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsDeque()
|
||||
bool JSValueRef::IsDeque([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSAPIDeque();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsHashMap()
|
||||
bool JSValueRef::IsHashMap([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSAPIHashMap();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsHashSet()
|
||||
bool JSValueRef::IsHashSet([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSAPIHashSet();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsLightWeightMap()
|
||||
bool JSValueRef::IsLightWeightMap([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSAPILightWeightMap();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsLightWeightSet()
|
||||
bool JSValueRef::IsLightWeightSet([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSAPILightWeightSet();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsLinkedList()
|
||||
bool JSValueRef::IsLinkedList([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSAPILinkedList();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsLinkedListIterator()
|
||||
bool JSValueRef::IsLinkedListIterator([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSAPILinkedListIterator();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsList()
|
||||
bool JSValueRef::IsList([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSAPIList();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsPlainArray()
|
||||
bool JSValueRef::IsPlainArray([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSAPIPlainArray();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsQueue()
|
||||
bool JSValueRef::IsQueue([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSAPIQueue();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsStack()
|
||||
bool JSValueRef::IsStack([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSAPIStack();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsTreeMap()
|
||||
bool JSValueRef::IsTreeMap([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSAPITreeMap();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsTreeSet()
|
||||
bool JSValueRef::IsTreeSet([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSAPITreeSet();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsVector()
|
||||
bool JSValueRef::IsVector([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSAPIVector();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsSendableObject()
|
||||
bool JSValueRef::IsSendableObject([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return IsJSShared() && IsObject();
|
||||
return IsJSShared(vm) && IsObject(vm);
|
||||
}
|
||||
|
||||
bool JSValueRef::IsJSShared()
|
||||
bool JSValueRef::IsJSShared([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSShared();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsSharedArray()
|
||||
bool JSValueRef::IsSharedArray([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSSharedArray();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsSharedTypedArray()
|
||||
bool JSValueRef::IsSharedTypedArray([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsSharedTypedArray();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsSharedSet()
|
||||
bool JSValueRef::IsSharedSet([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSSharedSet();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsSharedMap()
|
||||
bool JSValueRef::IsSharedMap([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSSharedMap();
|
||||
}
|
||||
@ -1009,7 +1010,7 @@ bool JSValueRef::IsHeapObject()
|
||||
|
||||
void *JSValueRef::GetNativePointerValue(const EcmaVM* vm, bool &isNativePointer)
|
||||
{
|
||||
if (IsJSShared()) {
|
||||
if (IsJSShared(vm)) {
|
||||
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
||||
return GetNativePointerValueImpl(vm, isNativePointer);
|
||||
} else {
|
||||
@ -1020,7 +1021,7 @@ void *JSValueRef::GetNativePointerValue(const EcmaVM* vm, bool &isNativePointer)
|
||||
// private
|
||||
void *JSValueRef::GetNativePointerValueImpl(const EcmaVM* vm, bool &isNativePointer)
|
||||
{
|
||||
if (!IsNativePointer()) {
|
||||
if (!IsNativePointer(vm)) {
|
||||
isNativePointer = false;
|
||||
return nullptr;
|
||||
}
|
||||
@ -1030,10 +1031,10 @@ void *JSValueRef::GetNativePointerValueImpl(const EcmaVM* vm, bool &isNativePoin
|
||||
return JSHandle<JSNativePointer>(nativePointer)->GetExternalPointer();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsDetachedArraybuffer(bool &isArrayBuffer)
|
||||
bool JSValueRef::IsDetachedArraybuffer([[maybe_unused]] const EcmaVM *vm, bool &isArrayBuffer)
|
||||
{
|
||||
// arraybuffer is not shared. Do not need to switch state
|
||||
if (!IsArrayBuffer()) {
|
||||
if (!IsArrayBuffer(vm)) {
|
||||
isArrayBuffer = false;
|
||||
return false;
|
||||
}
|
||||
@ -1044,14 +1045,14 @@ bool JSValueRef::IsDetachedArraybuffer(bool &isArrayBuffer)
|
||||
|
||||
void JSValueRef::DetachedArraybuffer(const EcmaVM *vm, bool &isArrayBuffer)
|
||||
{
|
||||
if (IsArrayBuffer()) {
|
||||
if (IsArrayBuffer(vm)) {
|
||||
JSHandle<JSArrayBuffer> arrayBuffer(JSNApiHelper::ToJSHandle(this));
|
||||
if (arrayBuffer->IsDetach()) {
|
||||
return;
|
||||
}
|
||||
arrayBuffer->Detach(vm->GetJSThread());
|
||||
isArrayBuffer = true;
|
||||
} else if (IsSendableArrayBuffer()) {
|
||||
} else if (IsSendableArrayBuffer(vm)) {
|
||||
JSHandle<ecmascript::JSSendableArrayBuffer> arrayBuffer(JSNApiHelper::ToJSHandle(this));
|
||||
if (arrayBuffer->IsDetach()) {
|
||||
return;
|
||||
@ -1070,7 +1071,7 @@ void JSValueRef::GetDataViewInfo(const EcmaVM *vm,
|
||||
JSValueRef **arrayBuffer,
|
||||
size_t *byteOffset)
|
||||
{
|
||||
if (!IsDataView()) {
|
||||
if (!IsDataView(vm)) {
|
||||
isDataView = false;
|
||||
return;
|
||||
}
|
||||
@ -1450,7 +1451,7 @@ int32_t BufferRef::ByteLength([[maybe_unused]] const EcmaVM *vm)
|
||||
return arrayBuffer->GetArrayBufferByteLength();
|
||||
}
|
||||
|
||||
void *BufferRef::GetBuffer()
|
||||
void *BufferRef::GetBuffer([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
DCHECK_SPECIAL_VALUE_WITH_RETURN(this, nullptr);
|
||||
JSHandle<JSArrayBuffer> arrayBuffer(JSNApiHelper::ToJSHandle(this));
|
||||
@ -1750,21 +1751,21 @@ int32_t StringRef::Utf8Length(const EcmaVM *vm)
|
||||
return EcmaStringAccessor(EcmaStringAccessor::Flatten(vm, strHandle)).GetUtf8Length();
|
||||
}
|
||||
|
||||
int StringRef::WriteUtf8(char *buffer, int length, bool isWriteBuffer)
|
||||
int StringRef::WriteUtf8([[maybe_unused]] const EcmaVM *vm, char *buffer, int length, bool isWriteBuffer)
|
||||
{
|
||||
DCHECK_SPECIAL_VALUE_WITH_RETURN(this, 0);
|
||||
return EcmaStringAccessor(JSNApiHelper::ToJSTaggedValue(this))
|
||||
.WriteToFlatUtf8(reinterpret_cast<uint8_t *>(buffer), length, isWriteBuffer);
|
||||
}
|
||||
|
||||
int StringRef::WriteUtf16(char16_t *buffer, int length)
|
||||
int StringRef::WriteUtf16([[maybe_unused]] const EcmaVM *vm, char16_t *buffer, int length)
|
||||
{
|
||||
DCHECK_SPECIAL_VALUE_WITH_RETURN(this, 0);
|
||||
return EcmaStringAccessor(JSNApiHelper::ToJSTaggedValue(this))
|
||||
.WriteToUtf16(reinterpret_cast<uint16_t *>(buffer), length);
|
||||
}
|
||||
|
||||
int StringRef::WriteLatin1(char *buffer, int length)
|
||||
int StringRef::WriteLatin1([[maybe_unused]] const EcmaVM *vm, char *buffer, int length)
|
||||
{
|
||||
DCHECK_SPECIAL_VALUE_WITH_RETURN(this, 0);
|
||||
return EcmaStringAccessor(JSNApiHelper::ToJSTaggedValue(this))
|
||||
@ -2607,7 +2608,7 @@ int32_t ArrayBufferRef::ByteLength([[maybe_unused]] const EcmaVM *vm)
|
||||
return arrayBuffer->GetArrayBufferByteLength();
|
||||
}
|
||||
|
||||
void *ArrayBufferRef::GetBuffer()
|
||||
void *ArrayBufferRef::GetBuffer([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
DCHECK_SPECIAL_VALUE_WITH_RETURN(this, nullptr);
|
||||
JSHandle<JSArrayBuffer> arrayBuffer(JSNApiHelper::ToJSHandle(this));
|
||||
@ -2626,7 +2627,7 @@ void ArrayBufferRef::Detach(const EcmaVM *vm)
|
||||
arrayBuffer->Detach(thread);
|
||||
}
|
||||
|
||||
bool ArrayBufferRef::IsDetach()
|
||||
bool ArrayBufferRef::IsDetach([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
DCHECK_SPECIAL_VALUE_WITH_RETURN(this, false);
|
||||
JSHandle<JSArrayBuffer> arrayBuffer(JSNApiHelper::ToJSHandle(this));
|
||||
@ -2670,14 +2671,14 @@ void SendableArrayBufferRef::Detach(const EcmaVM *vm)
|
||||
arrayBuffer->Detach(thread);
|
||||
}
|
||||
|
||||
bool SendableArrayBufferRef::IsDetach()
|
||||
bool SendableArrayBufferRef::IsDetach([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
DCHECK_SPECIAL_VALUE_WITH_RETURN(this, false);
|
||||
JSHandle<ecmascript::JSSendableArrayBuffer> arrayBuffer(JSNApiHelper::ToJSHandle(this));
|
||||
return arrayBuffer->IsDetach();
|
||||
}
|
||||
|
||||
void *SendableArrayBufferRef::GetBuffer()
|
||||
void *SendableArrayBufferRef::GetBuffer([[maybe_unused]] const EcmaVM *vm)
|
||||
{
|
||||
DCHECK_SPECIAL_VALUE_WITH_RETURN(this, nullptr);
|
||||
JSHandle<ecmascript::JSSendableArrayBuffer> arrayBuffer(JSNApiHelper::ToJSHandle(this));
|
||||
@ -3003,7 +3004,7 @@ Local<JSValueRef> FunctionRef::Call(const EcmaVM *vm, Local<JSValueRef> thisObj,
|
||||
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
||||
EscapeLocalScope scope(vm);
|
||||
FunctionCallScope callScope(EcmaVM::ConstCast(vm));
|
||||
if (!IsFunction()) {
|
||||
if (!IsFunction(vm)) {
|
||||
return JSValueRef::Undefined(vm);
|
||||
}
|
||||
vm->GetJsDebuggerManager()->ClearSingleStepper();
|
||||
@ -3038,7 +3039,7 @@ JSValueRef* FunctionRef::CallForNapi(const EcmaVM *vm, JSValueRef *thisObj,
|
||||
ecmascript::ThreadManagedScope managedScope(thread);
|
||||
JSTaggedValue result;
|
||||
FunctionCallScope callScope(EcmaVM::ConstCast(vm));
|
||||
ASSERT(IsFunction()); // IsFunction check has been done in napi.
|
||||
ASSERT(IsFunction(vm)); // IsFunction check has been done in napi.
|
||||
{
|
||||
LocalScope scope(vm);
|
||||
ecmascript::tooling::JsDebuggerManager *dm = vm->GetJsDebuggerManager();
|
||||
@ -3092,7 +3093,7 @@ Local<JSValueRef> FunctionRef::Constructor(const EcmaVM *vm,
|
||||
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm));
|
||||
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
||||
FunctionCallScope callScope(EcmaVM::ConstCast(vm));
|
||||
if (!IsFunction()) {
|
||||
if (!IsFunction(vm)) {
|
||||
return JSValueRef::Undefined(vm);
|
||||
}
|
||||
JSHandle<JSTaggedValue> func = JSNApiHelper::ToJSHandle(this);
|
||||
@ -3121,7 +3122,7 @@ JSValueRef* FunctionRef::ConstructorOptimize(const EcmaVM *vm,
|
||||
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
||||
JSTaggedValue result;
|
||||
FunctionCallScope callScope(EcmaVM::ConstCast(vm));
|
||||
ASSERT(IsFunction()); // IsFunction check has been done in napi.
|
||||
ASSERT(IsFunction(vm)); // IsFunction check has been done in napi.
|
||||
{
|
||||
LocalScope scope(vm);
|
||||
JSTaggedValue func = *reinterpret_cast<JSTaggedValue*>(this);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -160,7 +160,7 @@ HWTEST_F_L0(JSNApiTests, GetGlobalObject)
|
||||
LocalScope scope(vm_);
|
||||
Local<ObjectRef> globalObject = JSNApi::GetGlobalObject(vm_);
|
||||
ASSERT_FALSE(globalObject.IsEmpty());
|
||||
ASSERT_TRUE(globalObject->IsObject());
|
||||
ASSERT_TRUE(globalObject->IsObject(vm_));
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSNApiTests, ThreadIdCheck)
|
||||
@ -196,11 +196,11 @@ HWTEST_F_L0(JSNApiTests, GetProperty)
|
||||
LocalScope scope(vm_);
|
||||
Local<ObjectRef> globalObject = JSNApi::GetGlobalObject(vm_);
|
||||
ASSERT_FALSE(globalObject.IsEmpty());
|
||||
ASSERT_TRUE(globalObject->IsObject());
|
||||
ASSERT_TRUE(globalObject->IsObject(vm_));
|
||||
|
||||
Local<ObjectRef> key = StringRef::NewFromUtf8(vm_, "Number");
|
||||
Local<ObjectRef> property = globalObject->Get(vm_, key);
|
||||
ASSERT_TRUE(property->IsFunction());
|
||||
ASSERT_TRUE(property->IsFunction(vm_));
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSNApiTests, SetProperty)
|
||||
@ -208,7 +208,7 @@ HWTEST_F_L0(JSNApiTests, SetProperty)
|
||||
LocalScope scope(vm_);
|
||||
Local<ObjectRef> globalObject = JSNApi::GetGlobalObject(vm_);
|
||||
ASSERT_FALSE(globalObject.IsEmpty());
|
||||
ASSERT_TRUE(globalObject->IsObject());
|
||||
ASSERT_TRUE(globalObject->IsObject(vm_));
|
||||
|
||||
Local<ArrayRef> property = ArrayRef::New(vm_, 3); // 3 : length
|
||||
ASSERT_TRUE(property->IsArray(vm_));
|
||||
@ -235,17 +235,17 @@ HWTEST_F_L0(JSNApiTests, JsonParser)
|
||||
LocalScope scope(vm_);
|
||||
Local<ObjectRef> globalObject = JSNApi::GetGlobalObject(vm_);
|
||||
ASSERT_FALSE(globalObject.IsEmpty());
|
||||
ASSERT_TRUE(globalObject->IsObject());
|
||||
ASSERT_TRUE(globalObject->IsObject(vm_));
|
||||
|
||||
const char * const test { R"({"orientation": "portrait"})" };
|
||||
Local<ObjectRef> jsonString = StringRef::NewFromUtf8(vm_, test);
|
||||
|
||||
Local<JSValueRef> result = JSON::Parse(vm_, jsonString);
|
||||
ASSERT_TRUE(result->IsObject());
|
||||
ASSERT_TRUE(result->IsObject(vm_));
|
||||
|
||||
Local<ObjectRef> keyString = StringRef::NewFromUtf8(vm_, "orientation");
|
||||
Local<JSValueRef> property = Local<ObjectRef>(result)->Get(vm_, keyString);
|
||||
ASSERT_TRUE(property->IsString());
|
||||
ASSERT_TRUE(property->IsString(vm_));
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSNApiTests, StrictEqual)
|
||||
@ -301,8 +301,8 @@ HWTEST_F_L0(JSNApiTests, Symbol)
|
||||
Local<StringRef> description = StringRef::NewFromUtf8(vm_, "test");
|
||||
Local<SymbolRef> symbol = SymbolRef::New(vm_, description);
|
||||
|
||||
ASSERT_FALSE(description->IsSymbol());
|
||||
ASSERT_TRUE(symbol->IsSymbol());
|
||||
ASSERT_FALSE(description->IsSymbol(vm_));
|
||||
ASSERT_TRUE(symbol->IsSymbol(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -322,7 +322,7 @@ HWTEST_F_L0(JSNApiTests, StringUtf8_001)
|
||||
|
||||
EXPECT_EQ(testString->Utf8Length(vm_), 12); // 12 : length of testString("Hello World")
|
||||
char buffer[12]; // 12 : length of testString
|
||||
EXPECT_EQ(testString->WriteUtf8(buffer, 12), 12); // 12 : length of testString("Hello World")
|
||||
EXPECT_EQ(testString->WriteUtf8(vm_, buffer, 12), 12); // 12 : length of testString("Hello World")
|
||||
std::string res(buffer);
|
||||
ASSERT_EQ(res, test);
|
||||
}
|
||||
@ -344,7 +344,7 @@ HWTEST_F_L0(JSNApiTests, StringUtf8_002)
|
||||
|
||||
EXPECT_EQ(testString->Utf8Length(vm_), 4); // 4 : length of testString("年")
|
||||
char buffer[4]; // 4 : length of testString
|
||||
EXPECT_EQ(testString->WriteUtf8(buffer, 4), 4); // 4 : length of testString("年")
|
||||
EXPECT_EQ(testString->WriteUtf8(vm_, buffer, 4), 4); // 4 : length of testString("年")
|
||||
std::string res(buffer);
|
||||
ASSERT_EQ(res, test);
|
||||
}
|
||||
@ -360,7 +360,7 @@ HWTEST_F_L0(JSNApiTests, StringUtf8_003)
|
||||
Local<StringRef> testString1 = StringRef::NewFromUtf8(vm_, test.c_str(), test.length());
|
||||
EXPECT_EQ(testString1->Utf8Length(vm_), 5);
|
||||
char buffer1[4];
|
||||
testString1->WriteUtf8(buffer1, 4, false);
|
||||
testString1->WriteUtf8(vm_, buffer1, 4, false);
|
||||
EXPECT_EQ(buffer1[0], 'a');
|
||||
EXPECT_EQ(buffer1[1], '\xC0');
|
||||
EXPECT_EQ(buffer1[2], '\x80');
|
||||
@ -370,7 +370,7 @@ HWTEST_F_L0(JSNApiTests, StringUtf8_003)
|
||||
Local<StringRef> testString2 = StringRef::NewFromUtf8(vm_, test.c_str(), test.length());
|
||||
EXPECT_EQ(testString2->Utf8Length(vm_), 5);
|
||||
char buffer2[4];
|
||||
testString2->WriteUtf8(buffer2, 4, true);
|
||||
testString2->WriteUtf8(vm_, buffer2, 4, true);
|
||||
EXPECT_EQ(buffer2[0], 'a');
|
||||
EXPECT_EQ(buffer2[1], '\0');
|
||||
EXPECT_EQ(buffer2[2], 'b');
|
||||
@ -393,7 +393,7 @@ HWTEST_F_L0(JSNApiTests, StringLatin1_001)
|
||||
|
||||
EXPECT_EQ(testString->Length(), 1U);
|
||||
char buffer[1];
|
||||
EXPECT_EQ(testString->WriteLatin1(buffer, 1), 1);
|
||||
EXPECT_EQ(testString->WriteLatin1(vm_, buffer, 1), 1);
|
||||
|
||||
EXPECT_EQ(buffer[0], '-'); // '-' == 0x2D
|
||||
}
|
||||
@ -415,7 +415,7 @@ HWTEST_F_L0(JSNApiTests, StringLatin1_002)
|
||||
|
||||
EXPECT_EQ(testString->Length(), 5U);
|
||||
char buffer[5];
|
||||
EXPECT_EQ(testString->WriteLatin1(buffer, 5), 5);
|
||||
EXPECT_EQ(testString->WriteLatin1(vm_, buffer, 5), 5);
|
||||
|
||||
EXPECT_EQ(buffer[0], 'E');
|
||||
EXPECT_EQ(buffer[1], 'n');
|
||||
@ -441,7 +441,7 @@ HWTEST_F_L0(JSNApiTests, ToType)
|
||||
ASSERT_EQ(toString->ToNumber(vm_)->Value(), -123.3); // -123 : test case of input
|
||||
ASSERT_EQ(toString->ToBoolean(vm_)->Value(), true);
|
||||
ASSERT_EQ(toValue->ToString(vm_)->ToString(), "-123.3");
|
||||
ASSERT_TRUE(toValue->ToObject(vm_)->IsObject());
|
||||
ASSERT_TRUE(toValue->ToObject(vm_)->IsObject(vm_));
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSNApiTests, TypeValue)
|
||||
@ -561,11 +561,11 @@ HWTEST_F_L0(JSNApiTests, GetProtoType)
|
||||
LocalScope scope(vm_);
|
||||
Local<FunctionRef> function = FunctionRef::New(vm_, nullptr);
|
||||
Local<JSValueRef> protoType = function->GetPrototype(vm_);
|
||||
ASSERT_TRUE(protoType->IsObject());
|
||||
ASSERT_TRUE(protoType->IsObject(vm_));
|
||||
|
||||
Local<FunctionRef> object = ObjectRef::New(vm_);
|
||||
protoType = object->GetPrototype(vm_);
|
||||
ASSERT_TRUE(protoType->IsObject());
|
||||
ASSERT_TRUE(protoType->IsObject(vm_));
|
||||
|
||||
auto info = CreateNativeBindingInfo(reinterpret_cast<void *>(Attach), reinterpret_cast<void *>(Detach));
|
||||
size_t nativeBindingSize = 7 * sizeof(void *); // 7 : params num
|
||||
@ -579,7 +579,7 @@ HWTEST_F_L0(JSNApiTests, GetProtoType)
|
||||
bool result = object->ConvertToNativeBindingObject(vm_, nativeInfo);
|
||||
ASSERT_TRUE(result);
|
||||
protoType = object->GetPrototype(vm_);
|
||||
ASSERT_TRUE(protoType->IsObject());
|
||||
ASSERT_TRUE(protoType->IsObject(vm_));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -596,7 +596,7 @@ void CheckReject(JsiRuntimeCallInfo *info)
|
||||
{
|
||||
ASSERT_EQ(info->GetArgsNumber(), 1U);
|
||||
Local<JSValueRef> reason = info->GetCallArgRef(0);
|
||||
ASSERT_TRUE(reason->IsString());
|
||||
ASSERT_TRUE(reason->IsString(info->GetVM()));
|
||||
ASSERT_EQ(Local<StringRef>(reason)->ToString(), "Reject");
|
||||
}
|
||||
|
||||
@ -615,8 +615,8 @@ HWTEST_F_L0(JSNApiTests, PromiseCatch)
|
||||
Local<PromiseRef> promise = capability->GetPromise(vm_);
|
||||
Local<FunctionRef> reject = FunctionRef::New(vm_, RejectCallback);
|
||||
Local<PromiseRef> catchPromise = promise->Catch(vm_, reject);
|
||||
ASSERT_TRUE(promise->IsPromise());
|
||||
ASSERT_TRUE(catchPromise->IsPromise());
|
||||
ASSERT_TRUE(promise->IsPromise(vm_));
|
||||
ASSERT_TRUE(catchPromise->IsPromise(vm_));
|
||||
|
||||
Local<StringRef> reason = StringRef::NewFromUtf8(vm_, "Reject");
|
||||
ASSERT_TRUE(capability->Reject(vm_, reason));
|
||||
@ -632,8 +632,8 @@ HWTEST_F_L0(JSNApiTests, PromiseCatchUintPtr)
|
||||
Local<PromiseRef> promise = capability->GetPromise(vm_);
|
||||
Local<FunctionRef> reject = FunctionRef::New(vm_, RejectCallback);
|
||||
Local<PromiseRef> catchPromise = promise->Catch(vm_, reject);
|
||||
ASSERT_TRUE(promise->IsPromise());
|
||||
ASSERT_TRUE(catchPromise->IsPromise());
|
||||
ASSERT_TRUE(promise->IsPromise(vm_));
|
||||
ASSERT_TRUE(catchPromise->IsPromise(vm_));
|
||||
|
||||
Local<StringRef> reason = StringRef::NewFromUtf8(vm_, "Reject");
|
||||
ASSERT_TRUE(capability->Reject(vm_, reinterpret_cast<uintptr_t>(*reason)));
|
||||
@ -675,8 +675,8 @@ HWTEST_F_L0(JSNApiTests, PromiseThen)
|
||||
Local<FunctionRef> resolve = FunctionRef::New(vm_, ResolvedCallback);
|
||||
Local<FunctionRef> reject = FunctionRef::New(vm_, RejectCallback);
|
||||
Local<PromiseRef> thenPromise = promise->Then(vm_, resolve, reject);
|
||||
ASSERT_TRUE(promise->IsPromise());
|
||||
ASSERT_TRUE(thenPromise->IsPromise());
|
||||
ASSERT_TRUE(promise->IsPromise(vm_));
|
||||
ASSERT_TRUE(thenPromise->IsPromise(vm_));
|
||||
|
||||
Local<StringRef> value = NumberRef::New(vm_, 300.3); // 300.3 : test case of input
|
||||
ASSERT_TRUE(capability->Resolve(vm_, value));
|
||||
@ -692,8 +692,8 @@ HWTEST_F_L0(JSNApiTests, PromiseThenUintPtr)
|
||||
Local<FunctionRef> resolve = FunctionRef::New(vm_, ResolvedCallback);
|
||||
Local<FunctionRef> reject = FunctionRef::New(vm_, RejectCallback);
|
||||
Local<PromiseRef> thenPromise = promise->Then(vm_, resolve, reject);
|
||||
ASSERT_TRUE(promise->IsPromise());
|
||||
ASSERT_TRUE(thenPromise->IsPromise());
|
||||
ASSERT_TRUE(promise->IsPromise(vm_));
|
||||
ASSERT_TRUE(thenPromise->IsPromise(vm_));
|
||||
|
||||
Local<StringRef> value = NumberRef::New(vm_, 300.3); // 300.3 : test case of input
|
||||
ASSERT_TRUE(capability->Resolve(vm_, reinterpret_cast<uintptr_t>(*value)));
|
||||
@ -718,7 +718,7 @@ HWTEST_F_L0(JSNApiTests, Constructor_IsObject)
|
||||
Local<JSValueRef> argv[1];
|
||||
argv[0] = NumberRef::New(vm_, 1.3); // 1.3 : test case of input
|
||||
Local<JSValueRef> result = numberConstructor->Constructor(vm_, argv, 1);
|
||||
ASSERT_TRUE(result->IsObject());
|
||||
ASSERT_TRUE(result->IsObject(vm_));
|
||||
ASSERT_EQ(result->ToNumber(vm_)->Value(), 1.3); // 1.3 : size of arguments
|
||||
}
|
||||
|
||||
@ -735,9 +735,9 @@ HWTEST_F_L0(JSNApiTests, ArrayBuffer)
|
||||
LocalScope scope(vm_);
|
||||
const int32_t length = 15;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer());
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer(vm_));
|
||||
ASSERT_EQ(arrayBuffer->ByteLength(vm_), length);
|
||||
ASSERT_NE(arrayBuffer->GetBuffer(), nullptr);
|
||||
ASSERT_NE(arrayBuffer->GetBuffer(vm_), nullptr);
|
||||
JSNApi::TriggerGC(vm_);
|
||||
}
|
||||
|
||||
@ -761,9 +761,9 @@ HWTEST_F_L0(JSNApiTests, ArrayBufferWithBuffer)
|
||||
LocalScope scope(vm_);
|
||||
uint8_t *buffer = new uint8_t[length]();
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, buffer, length, deleter, data);
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer());
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer(vm_));
|
||||
ASSERT_EQ(arrayBuffer->ByteLength(vm_), length);
|
||||
ASSERT_EQ(arrayBuffer->GetBuffer(), buffer);
|
||||
ASSERT_EQ(arrayBuffer->GetBuffer(vm_), buffer);
|
||||
}
|
||||
JSNApi::TriggerGC(vm_, JSNApi::TRIGGER_GC_TYPE::FULL_GC);
|
||||
ASSERT_TRUE(isFree);
|
||||
@ -775,12 +775,12 @@ HWTEST_F_L0(JSNApiTests, DataView)
|
||||
const int32_t length = 15;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
JSNApi::TriggerGC(vm_);
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer());
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer(vm_));
|
||||
|
||||
// 5 : offset of byte, 7 : length
|
||||
Local<DataViewRef> dataView = DataViewRef::New(vm_, arrayBuffer, 5, 7);
|
||||
ASSERT_TRUE(dataView->IsDataView());
|
||||
ASSERT_EQ(dataView->GetArrayBuffer(vm_)->GetBuffer(), arrayBuffer->GetBuffer());
|
||||
ASSERT_TRUE(dataView->IsDataView(vm_));
|
||||
ASSERT_EQ(dataView->GetArrayBuffer(vm_)->GetBuffer(vm_), arrayBuffer->GetBuffer(vm_));
|
||||
ASSERT_EQ(dataView->ByteLength(), 7U); // 7 : size of arguments
|
||||
ASSERT_EQ(dataView->ByteOffset(), 5U); // 5 : size of arguments
|
||||
|
||||
@ -803,15 +803,15 @@ HWTEST_F_L0(JSNApiTests, Int8Array)
|
||||
LocalScope scope(vm_);
|
||||
const int32_t length = 15;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer());
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer(vm_));
|
||||
|
||||
// 5 : offset of byte, 6 : length
|
||||
Local<Int8ArrayRef> typedArray = Int8ArrayRef::New(vm_, arrayBuffer, 5, 6);
|
||||
ASSERT_TRUE(typedArray->IsInt8Array());
|
||||
ASSERT_TRUE(typedArray->IsInt8Array(vm_));
|
||||
ASSERT_EQ(typedArray->ByteLength(vm_), 6U); // 6 : length of bytes
|
||||
ASSERT_EQ(typedArray->ByteOffset(vm_), 5U); // 5 : offset of byte
|
||||
ASSERT_EQ(typedArray->ArrayLength(vm_), 6U); // 6 : length of array
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(), arrayBuffer->GetBuffer());
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_), arrayBuffer->GetBuffer(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -828,15 +828,15 @@ HWTEST_F_L0(JSNApiTests, Uint8Array)
|
||||
LocalScope scope(vm_);
|
||||
const int32_t length = 15;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer());
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer(vm_));
|
||||
|
||||
// 5 : offset of byte, 6 : length
|
||||
Local<Uint8ArrayRef> typedArray = Uint8ArrayRef::New(vm_, arrayBuffer, 5, 6);
|
||||
ASSERT_TRUE(typedArray->IsUint8Array());
|
||||
ASSERT_TRUE(typedArray->IsUint8Array(vm_));
|
||||
ASSERT_EQ(typedArray->ByteLength(vm_), 6U); // 6 : length of bytes
|
||||
ASSERT_EQ(typedArray->ByteOffset(vm_), 5U); // 5 : offset of byte
|
||||
ASSERT_EQ(typedArray->ArrayLength(vm_), 6U); // 6 : length of array
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(), arrayBuffer->GetBuffer());
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_), arrayBuffer->GetBuffer(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -851,15 +851,15 @@ HWTEST_F_L0(JSNApiTests, Uint8ClampedArray)
|
||||
LocalScope scope(vm_);
|
||||
const int32_t length = 15;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer());
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer(vm_));
|
||||
|
||||
// 5 : offset of byte, 6 : length
|
||||
Local<Uint8ClampedArrayRef> typedArray = Uint8ClampedArrayRef::New(vm_, arrayBuffer, 5, 6);
|
||||
ASSERT_TRUE(typedArray->IsUint8ClampedArray());
|
||||
ASSERT_TRUE(typedArray->IsUint8ClampedArray(vm_));
|
||||
ASSERT_EQ(typedArray->ByteLength(vm_), 6U); // 6 : length of bytes
|
||||
ASSERT_EQ(typedArray->ByteOffset(vm_), 5U); // 5 : offset of byte
|
||||
ASSERT_EQ(typedArray->ArrayLength(vm_), 6U); // 6 : length of array
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(), arrayBuffer->GetBuffer());
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_), arrayBuffer->GetBuffer(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -874,15 +874,15 @@ HWTEST_F_L0(JSNApiTests, Int16Array)
|
||||
LocalScope scope(vm_);
|
||||
const int32_t length = 30;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer());
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer(vm_));
|
||||
|
||||
// 4 : offset of byte, 6 : length
|
||||
Local<Int16ArrayRef> typedArray = Int16ArrayRef::New(vm_, arrayBuffer, 4, 6);
|
||||
ASSERT_TRUE(typedArray->IsInt16Array());
|
||||
ASSERT_TRUE(typedArray->IsInt16Array(vm_));
|
||||
ASSERT_EQ(typedArray->ByteLength(vm_), 12U); // 12 : length of bytes
|
||||
ASSERT_EQ(typedArray->ByteOffset(vm_), 4U); // 4 : offset of byte
|
||||
ASSERT_EQ(typedArray->ArrayLength(vm_), 6U); // 6 : length of array
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(), arrayBuffer->GetBuffer());
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_), arrayBuffer->GetBuffer(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -897,15 +897,15 @@ HWTEST_F_L0(JSNApiTests, Uint16Array)
|
||||
LocalScope scope(vm_);
|
||||
const int32_t length = 30;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer());
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer(vm_));
|
||||
|
||||
// 4 : offset of byte, 6 : length
|
||||
Local<Uint16ArrayRef> typedArray = Uint16ArrayRef::New(vm_, arrayBuffer, 4, 6);
|
||||
ASSERT_TRUE(typedArray->IsUint16Array());
|
||||
ASSERT_TRUE(typedArray->IsUint16Array(vm_));
|
||||
ASSERT_EQ(typedArray->ByteLength(vm_), 12U); // 12 : length of bytes
|
||||
ASSERT_EQ(typedArray->ByteOffset(vm_), 4U); // 4 : offset of byte
|
||||
ASSERT_EQ(typedArray->ArrayLength(vm_), 6U); // 6 : length of array
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(), arrayBuffer->GetBuffer());
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_), arrayBuffer->GetBuffer(vm_));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -921,15 +921,15 @@ HWTEST_F_L0(JSNApiTests, Uint32Array)
|
||||
LocalScope scope(vm_);
|
||||
const int32_t length = 30;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer());
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer(vm_));
|
||||
|
||||
// 4 : offset of byte, 6 : length
|
||||
Local<Uint32ArrayRef> typedArray = Uint32ArrayRef::New(vm_, arrayBuffer, 4, 6);
|
||||
ASSERT_TRUE(typedArray->IsUint32Array());
|
||||
ASSERT_TRUE(typedArray->IsUint32Array(vm_));
|
||||
ASSERT_EQ(typedArray->ByteLength(vm_), 24U); // 24 : length of bytes
|
||||
ASSERT_EQ(typedArray->ByteOffset(vm_), 4U); // 4 : offset of byte
|
||||
ASSERT_EQ(typedArray->ArrayLength(vm_), 6U); // 6 : length of array
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(), arrayBuffer->GetBuffer());
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_), arrayBuffer->GetBuffer(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -944,15 +944,15 @@ HWTEST_F_L0(JSNApiTests, Int32Array)
|
||||
LocalScope scope(vm_);
|
||||
const int32_t length = 30;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer());
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer(vm_));
|
||||
|
||||
// 4 : offset of byte, 6 : length
|
||||
Local<Int32ArrayRef> typedArray = Int32ArrayRef::New(vm_, arrayBuffer, 4, 6);
|
||||
ASSERT_TRUE(typedArray->IsInt32Array());
|
||||
ASSERT_TRUE(typedArray->IsInt32Array(vm_));
|
||||
ASSERT_EQ(typedArray->ByteLength(vm_), 24U); // 24 : length of bytes
|
||||
ASSERT_EQ(typedArray->ByteOffset(vm_), 4U); // 4 : offset of byte
|
||||
ASSERT_EQ(typedArray->ArrayLength(vm_), 6U); // 6 : length of array
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(), arrayBuffer->GetBuffer());
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_), arrayBuffer->GetBuffer(vm_));
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSNApiTests, Float32Array)
|
||||
@ -960,15 +960,15 @@ HWTEST_F_L0(JSNApiTests, Float32Array)
|
||||
LocalScope scope(vm_);
|
||||
const int32_t length = 30;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer());
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer(vm_));
|
||||
|
||||
// 4 : offset of byte, 6 : length
|
||||
Local<Float32ArrayRef> typedArray = Float32ArrayRef::New(vm_, arrayBuffer, 4, 6);
|
||||
ASSERT_TRUE(typedArray->IsFloat32Array());
|
||||
ASSERT_TRUE(typedArray->IsFloat32Array(vm_));
|
||||
ASSERT_EQ(typedArray->ByteLength(vm_), 24U); // 24 : length of bytes
|
||||
ASSERT_EQ(typedArray->ByteOffset(vm_), 4U); // 4 : offset of byte
|
||||
ASSERT_EQ(typedArray->ArrayLength(vm_), 6U); // 6 : length of array
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(), arrayBuffer->GetBuffer());
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_), arrayBuffer->GetBuffer(vm_));
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSNApiTests, Float64Array)
|
||||
@ -976,15 +976,15 @@ HWTEST_F_L0(JSNApiTests, Float64Array)
|
||||
LocalScope scope(vm_);
|
||||
const int32_t length = 57;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer());
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer(vm_));
|
||||
|
||||
// 8 : offset of byte, 6 : length
|
||||
Local<Float64ArrayRef> typedArray = Float64ArrayRef::New(vm_, arrayBuffer, 8, 6);
|
||||
ASSERT_TRUE(typedArray->IsFloat64Array());
|
||||
ASSERT_TRUE(typedArray->IsFloat64Array(vm_));
|
||||
ASSERT_EQ(typedArray->ByteLength(vm_), 48U); // 48 : length of bytes
|
||||
ASSERT_EQ(typedArray->ByteOffset(vm_), 8U); // 8 : offset of byte
|
||||
ASSERT_EQ(typedArray->ArrayLength(vm_), 6U); // 6 : length of array
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(), arrayBuffer->GetBuffer());
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_), arrayBuffer->GetBuffer(vm_));
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSNApiTests, BigInt64Array)
|
||||
@ -992,15 +992,15 @@ HWTEST_F_L0(JSNApiTests, BigInt64Array)
|
||||
LocalScope scope(vm_);
|
||||
const int32_t length = 57;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer());
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer(vm_));
|
||||
|
||||
// 8 : offset of byte, 6 : length
|
||||
Local<BigInt64ArrayRef> typedArray = BigInt64ArrayRef::New(vm_, arrayBuffer, 8, 6);
|
||||
ASSERT_TRUE(typedArray->IsBigInt64Array());
|
||||
ASSERT_TRUE(typedArray->IsBigInt64Array(vm_));
|
||||
ASSERT_EQ(typedArray->ByteLength(vm_), 48U); // 48 : length of bytes
|
||||
ASSERT_EQ(typedArray->ByteOffset(vm_), 8U); // 8 : offset of byte
|
||||
ASSERT_EQ(typedArray->ArrayLength(vm_), 6U); // 6 : length of array
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(), arrayBuffer->GetBuffer());
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_), arrayBuffer->GetBuffer(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1015,15 +1015,15 @@ HWTEST_F_L0(JSNApiTests, BigUint64Array)
|
||||
LocalScope scope(vm_);
|
||||
const int32_t length = 57;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer());
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer(vm_));
|
||||
|
||||
// 8 : offset of byte, 6 : length
|
||||
Local<BigUint64ArrayRef> typedArray = BigUint64ArrayRef::New(vm_, arrayBuffer, 8, 6);
|
||||
ASSERT_TRUE(typedArray->IsBigUint64Array());
|
||||
ASSERT_TRUE(typedArray->IsBigUint64Array(vm_));
|
||||
ASSERT_EQ(typedArray->ByteLength(vm_), 48U); // 48 : length of bytes
|
||||
ASSERT_EQ(typedArray->ByteOffset(vm_), 8U); // 8 : offset of byte
|
||||
ASSERT_EQ(typedArray->ArrayLength(vm_), 6U); // 6 : length of array
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(), arrayBuffer->GetBuffer());
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_), arrayBuffer->GetBuffer(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1041,7 +1041,7 @@ HWTEST_F_L0(JSNApiTests, Error_ThrowException_HasPendingException)
|
||||
LocalScope scope(vm_);
|
||||
Local<StringRef> message = StringRef::NewFromUtf8(vm_, "ErrorTest");
|
||||
Local<JSValueRef> error = Exception::Error(vm_, message);
|
||||
ASSERT_TRUE(error->IsError());
|
||||
ASSERT_TRUE(error->IsError(vm_));
|
||||
|
||||
JSNApi::ThrowException(vm_, error);
|
||||
ASSERT_TRUE(thread_->HasPendingException());
|
||||
@ -1052,7 +1052,7 @@ HWTEST_F_L0(JSNApiTests, RangeError)
|
||||
LocalScope scope(vm_);
|
||||
Local<StringRef> message = StringRef::NewFromUtf8(vm_, "ErrorTest");
|
||||
Local<JSValueRef> error = Exception::RangeError(vm_, message);
|
||||
ASSERT_TRUE(error->IsError());
|
||||
ASSERT_TRUE(error->IsError(vm_));
|
||||
|
||||
JSNApi::ThrowException(vm_, error);
|
||||
ASSERT_TRUE(thread_->HasPendingException());
|
||||
@ -1071,7 +1071,7 @@ HWTEST_F_L0(JSNApiTests, TypeError)
|
||||
LocalScope scope(vm_);
|
||||
Local<StringRef> message = StringRef::NewFromUtf8(vm_, "ErrorTest");
|
||||
Local<JSValueRef> error = Exception::TypeError(vm_, message);
|
||||
ASSERT_TRUE(error->IsError());
|
||||
ASSERT_TRUE(error->IsError(vm_));
|
||||
|
||||
JSNApi::ThrowException(vm_, error);
|
||||
ASSERT_TRUE(thread_->HasPendingException());
|
||||
@ -1082,7 +1082,7 @@ HWTEST_F_L0(JSNApiTests, ReferenceError)
|
||||
LocalScope scope(vm_);
|
||||
Local<StringRef> message = StringRef::NewFromUtf8(vm_, "ErrorTest");
|
||||
Local<JSValueRef> error = Exception::ReferenceError(vm_, message);
|
||||
ASSERT_TRUE(error->IsError());
|
||||
ASSERT_TRUE(error->IsError(vm_));
|
||||
|
||||
JSNApi::ThrowException(vm_, error);
|
||||
ASSERT_TRUE(thread_->HasPendingException());
|
||||
@ -1093,7 +1093,7 @@ HWTEST_F_L0(JSNApiTests, SyntaxError)
|
||||
LocalScope scope(vm_);
|
||||
Local<StringRef> message = StringRef::NewFromUtf8(vm_, "ErrorTest");
|
||||
Local<JSValueRef> error = Exception::SyntaxError(vm_, message);
|
||||
ASSERT_TRUE(error->IsError());
|
||||
ASSERT_TRUE(error->IsError(vm_));
|
||||
|
||||
JSNApi::ThrowException(vm_, error);
|
||||
ASSERT_TRUE(thread_->HasPendingException());
|
||||
@ -1112,7 +1112,7 @@ HWTEST_F_L0(JSNApiTests, OOMError)
|
||||
LocalScope scope(vm_);
|
||||
Local<StringRef> message = StringRef::NewFromUtf8(vm_, "ErrorTest");
|
||||
Local<JSValueRef> error = Exception::OOMError(vm_, message);
|
||||
ASSERT_TRUE(error->IsError());
|
||||
ASSERT_TRUE(error->IsError(vm_));
|
||||
|
||||
JSNApi::ThrowException(vm_, error);
|
||||
ASSERT_TRUE(thread_->HasPendingException());
|
||||
@ -1457,7 +1457,7 @@ HWTEST_F_L0(JSNApiTests, BigIntRef_New_Uint64)
|
||||
{
|
||||
uint64_t maxUint64 = std::numeric_limits<uint64_t>::max();
|
||||
Local<BigIntRef> maxBigintUint64 = BigIntRef::New(vm_, maxUint64);
|
||||
EXPECT_TRUE(maxBigintUint64->IsBigInt());
|
||||
EXPECT_TRUE(maxBigintUint64->IsBigInt(vm_));
|
||||
|
||||
JSHandle<BigInt> maxBigintUint64Val(thread_, JSNApiHelper::ToJSTaggedValue(*maxBigintUint64));
|
||||
EXPECT_EQ(maxBigintUint64Val->GetDigit(0), static_cast<uint32_t>(maxUint64 & 0xffffffff));
|
||||
@ -1465,7 +1465,7 @@ HWTEST_F_L0(JSNApiTests, BigIntRef_New_Uint64)
|
||||
|
||||
uint64_t minUint64 = std::numeric_limits<uint64_t>::min();
|
||||
Local<BigIntRef> minBigintUint64 = BigIntRef::New(vm_, minUint64);
|
||||
EXPECT_TRUE(minBigintUint64->IsBigInt());
|
||||
EXPECT_TRUE(minBigintUint64->IsBigInt(vm_));
|
||||
|
||||
JSHandle<BigInt> minBigintUint64Val(thread_, JSNApiHelper::ToJSTaggedValue(*minBigintUint64));
|
||||
EXPECT_EQ(minBigintUint64Val->GetDigit(0), static_cast<uint32_t>(minUint64 & 0xffffffff));
|
||||
@ -1476,7 +1476,7 @@ HWTEST_F_L0(JSNApiTests, BigIntRef_New_Int64)
|
||||
{
|
||||
int64_t maxInt64 = std::numeric_limits<int64_t>::max();
|
||||
Local<BigIntRef> maxBigintInt64 = BigIntRef::New(vm_, maxInt64);
|
||||
EXPECT_TRUE(maxBigintInt64->IsBigInt());
|
||||
EXPECT_TRUE(maxBigintInt64->IsBigInt(vm_));
|
||||
|
||||
JSHandle<BigInt> maxBigintInt64Val(thread_, JSNApiHelper::ToJSTaggedValue(*maxBigintInt64));
|
||||
EXPECT_EQ(maxBigintInt64Val->GetDigit(0), static_cast<uint32_t>(maxInt64 & 0xffffffff));
|
||||
@ -1484,7 +1484,7 @@ HWTEST_F_L0(JSNApiTests, BigIntRef_New_Int64)
|
||||
|
||||
int64_t minInt64 = std::numeric_limits<int64_t>::min();
|
||||
Local<BigIntRef> minBigintInt64 = BigIntRef::New(vm_, minInt64);
|
||||
EXPECT_TRUE(minBigintInt64->IsBigInt());
|
||||
EXPECT_TRUE(minBigintInt64->IsBigInt(vm_));
|
||||
|
||||
JSHandle<BigInt> minBigintInt64Val(thread_, JSNApiHelper::ToJSTaggedValue(*minBigintInt64));
|
||||
EXPECT_EQ(minBigintInt64Val->GetSign(), true);
|
||||
@ -1511,7 +1511,7 @@ HWTEST_F_L0(JSNApiTests, BigIntRef_CreateBigWords_GetWordsArray_GetWordsArraySiz
|
||||
std::numeric_limits<uint64_t>::max(),
|
||||
};
|
||||
Local<JSValueRef> bigWords = BigIntRef::CreateBigWords(vm_, sign, size, words);
|
||||
EXPECT_TRUE(bigWords->IsBigInt());
|
||||
EXPECT_TRUE(bigWords->IsBigInt(vm_));
|
||||
|
||||
Local<BigIntRef> bigWordsRef(bigWords);
|
||||
EXPECT_EQ(bigWordsRef->GetWordsArraySize(), size);
|
||||
@ -1544,11 +1544,11 @@ HWTEST_F_L0(JSNApiTests, DateRef_New_ToString_GetTime)
|
||||
{
|
||||
double time = 1.1;
|
||||
Local<DateRef> data = DateRef::New(vm_, time);
|
||||
EXPECT_TRUE(data->IsDate());
|
||||
EXPECT_TRUE(data->IsDate(vm_));
|
||||
|
||||
Local<StringRef> tostring = data->ToString(vm_);
|
||||
Local<JSValueRef> toValue(tostring);
|
||||
EXPECT_TRUE(tostring->IsString());
|
||||
EXPECT_TRUE(tostring->IsString(vm_));
|
||||
double dou = data->GetTime();
|
||||
EXPECT_EQ(dou, 1.1);
|
||||
}
|
||||
@ -1561,14 +1561,14 @@ HWTEST_F_L0(JSNApiTests, PromiseRef_Finally)
|
||||
Local<PromiseRef> promise = capability->GetPromise(vm_);
|
||||
Local<FunctionRef> reject = FunctionRef::New(vm_, RejectCallback);
|
||||
Local<PromiseRef> catchPromise = promise->Finally(vm_, reject);
|
||||
ASSERT_TRUE(promise->IsPromise());
|
||||
ASSERT_TRUE(catchPromise->IsPromise());
|
||||
ASSERT_TRUE(promise->IsPromise(vm_));
|
||||
ASSERT_TRUE(catchPromise->IsPromise(vm_));
|
||||
Local<PromiseRef> catchPromise1 = promise->Then(vm_, reject, reject);
|
||||
ASSERT_TRUE(catchPromise1->IsPromise());
|
||||
ASSERT_TRUE(catchPromise1->IsPromise(vm_));
|
||||
Local<FunctionRef> callback = FunctionRef::New(vm_, FunctionCallback);
|
||||
ASSERT_TRUE(!callback.IsEmpty());
|
||||
Local<PromiseRef> catchPromise2 = promise->Then(vm_, callback);
|
||||
ASSERT_TRUE(catchPromise2->IsPromise());
|
||||
ASSERT_TRUE(catchPromise2->IsPromise(vm_));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1695,9 +1695,9 @@ HWTEST_F_L0(JSNApiTests, FunctionRef_GetFunctionPrototype_SetName_GetName)
|
||||
size_t nativeBindingsize = 15;
|
||||
Local<FunctionRef> res =
|
||||
FunctionRef::NewClassFunction(vm_, FunctionCallback, deleter, cb, callNative, nativeBindingsize);
|
||||
ASSERT_TRUE(res->IsFunction());
|
||||
ASSERT_TRUE(res->IsFunction(vm_));
|
||||
Local<JSValueRef> res1 = res->GetFunctionPrototype(vm_);
|
||||
ASSERT_TRUE(res->IsFunction());
|
||||
ASSERT_TRUE(res->IsFunction(vm_));
|
||||
ASSERT_TRUE(!res1->IsArray(vm_));
|
||||
Local<StringRef> origin = StringRef::NewFromUtf8(vm_, "1");
|
||||
res->SetName(vm_, origin);
|
||||
@ -1735,9 +1735,9 @@ HWTEST_F_L0(JSNApiTests, JSValueRef_ToNativePointer)
|
||||
ASSERT_EQ(toString->ToNumber(vm_)->Value(), -123.3); // -123 : test case of input
|
||||
ASSERT_EQ(toString->ToBoolean(vm_)->Value(), true);
|
||||
ASSERT_EQ(toValue->ToString(vm_)->ToString(), "-123.3");
|
||||
ASSERT_TRUE(toValue->ToObject(vm_)->IsObject());
|
||||
ASSERT_TRUE(toValue->ToObject(vm_)->IsObject(vm_));
|
||||
Local<NativePointerRef> res = toValue->ToNativePointer(vm_);
|
||||
ASSERT_TRUE(res->IsString());
|
||||
ASSERT_TRUE(res->IsString(vm_));
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSNApiTests, GeneratorObjectRef_IsGenerator)
|
||||
@ -1761,7 +1761,7 @@ HWTEST_F_L0(JSNApiTests, GeneratorObjectRef_IsGenerator)
|
||||
JSHandle<JSTaggedValue> genObjTagHandleVal = JSHandle<JSTaggedValue>::Cast(genObjHandleVal);
|
||||
Local<GeneratorObjectRef> genObjectRef = JSNApiHelper::ToLocal<GeneratorObjectRef>(genObjTagHandleVal);
|
||||
Local<JSValueRef> res = genObjectRef->GetGeneratorFunction(vm_);
|
||||
ASSERT_TRUE(res->IsGeneratorFunction());
|
||||
ASSERT_TRUE(res->IsGeneratorFunction(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1777,7 +1777,7 @@ HWTEST_F_L0(JSNApiTests, BigIntToInt64)
|
||||
LocalScope scope(vm_);
|
||||
uint64_t maxUint64 = std::numeric_limits<uint64_t>::max();
|
||||
Local<BigIntRef> maxBigintUint64 = BigIntRef::New(vm_, maxUint64);
|
||||
EXPECT_TRUE(maxBigintUint64->IsBigInt());
|
||||
EXPECT_TRUE(maxBigintUint64->IsBigInt(vm_));
|
||||
int64_t num = -11;
|
||||
int64_t num1 = num;
|
||||
bool lossless = true;
|
||||
@ -1798,7 +1798,7 @@ HWTEST_F_L0(JSNApiTests, BigIntToUint64)
|
||||
LocalScope scope(vm_);
|
||||
uint64_t maxUint64 = std::numeric_limits<uint64_t>::max();
|
||||
Local<BigIntRef> maxBigintUint64 = BigIntRef::New(vm_, maxUint64);
|
||||
EXPECT_TRUE(maxBigintUint64->IsBigInt());
|
||||
EXPECT_TRUE(maxBigintUint64->IsBigInt(vm_));
|
||||
uint64_t num = -11;
|
||||
uint64_t num1 = num;
|
||||
bool lossless = true;
|
||||
@ -2128,7 +2128,7 @@ HWTEST_F_L0(JSNApiTests, IsNativePointer)
|
||||
void *vp1 = static_cast<void *>(new std::string("test"));
|
||||
void *vp2 = static_cast<void *>(new std::string("test"));
|
||||
Local<NativePointerRef> res = NativePointerRef::New(vm_, vp1, callBack, vp2, 0);
|
||||
ASSERT_TRUE(res->IsNativePointer());
|
||||
ASSERT_TRUE(res->IsNativePointer(vm_));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2151,7 +2151,7 @@ HWTEST_F_L0(JSNApiTests, ToType_ToBoolean_ToString_ToObject)
|
||||
ASSERT_EQ(toString->ToNumber(vm_)->Value(), -1.3);
|
||||
ASSERT_EQ(toString->ToBoolean(vm_)->Value(), true);
|
||||
ASSERT_EQ(toValue->ToString(vm_)->ToString(), "-1.3");
|
||||
ASSERT_TRUE(toValue->ToObject(vm_)->IsObject());
|
||||
ASSERT_TRUE(toValue->ToObject(vm_)->IsObject(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2169,16 +2169,16 @@ HWTEST_F_L0(JSNApiTests, IsTypedArray)
|
||||
char buffer[4];
|
||||
memset_s(buffer, sizeof(buffer), 0, sizeof(buffer));
|
||||
Local<StringRef> testString = StringRef::NewFromUtf8(vm_, test.c_str());
|
||||
EXPECT_EQ(testString->WriteUtf8(buffer, 4), 4);
|
||||
EXPECT_EQ(testString->WriteUtf8(vm_, buffer, 4), 4);
|
||||
// testString 是一个字符串,而不是类型化数组
|
||||
ASSERT_FALSE(testString->IsTypedArray());
|
||||
ASSERT_FALSE(testString->IsTypedArray(vm_));
|
||||
const int32_t length = 30;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer());
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer(vm_));
|
||||
Local<Uint32ArrayRef> typedArray = Uint32ArrayRef::New(vm_, arrayBuffer, 4, 6);
|
||||
// 是否是类型化数组
|
||||
ASSERT_TRUE(typedArray->IsTypedArray());
|
||||
ASSERT_TRUE(typedArray->IsTypedArray(vm_));
|
||||
ASSERT_FALSE(typedArray->IsUndefined());
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(), arrayBuffer->GetBuffer());
|
||||
ASSERT_EQ(typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_), arrayBuffer->GetBuffer(vm_));
|
||||
}
|
||||
} // namespace panda::test
|
||||
|
@ -186,7 +186,7 @@ HWTEST_F_L0(JSNApiSampleTest, Sample_PrimitiveRef_BigIntRef_Int64)
|
||||
<< " [ " << i << " ] : " << iresultWords[i];
|
||||
}
|
||||
Local<PrimitiveRef> pint64tObject = int64tObject;
|
||||
GTEST_LOG_(INFO) << "sample_primitive_BigIntRef_pint64tObject_IsBigInt : " << pint64tObject->IsBigInt();
|
||||
GTEST_LOG_(INFO) << "sample_primitive_BigIntRef_pint64tObject_IsBigInt : " << pint64tObject->IsBigInt(vm_);
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSNApiSampleTest, Sample_PrimitiveRef_BooleanRef)
|
||||
@ -214,7 +214,7 @@ HWTEST_F_L0(JSNApiSampleTest, Sample_PrimitiveRef_StringRef_Char)
|
||||
StringRef *charObject = StringRef::Cast(jsValue);
|
||||
EXPECT_EQ(charObject->Utf8Length(vm_), 12);
|
||||
char buffer[12];
|
||||
EXPECT_EQ(charObject->WriteUtf8(buffer, 12), 12);
|
||||
EXPECT_EQ(charObject->WriteUtf8(vm_, buffer, 12), 12);
|
||||
std::string res(buffer);
|
||||
GTEST_LOG_(INFO) << "sample_primitive_StringRef_charObject : " << res;
|
||||
std::string charObjectStr = charObject->ToString();
|
||||
@ -222,16 +222,16 @@ HWTEST_F_L0(JSNApiSampleTest, Sample_PrimitiveRef_StringRef_Char)
|
||||
uint32_t charSize = charObject->Length();
|
||||
GTEST_LOG_(INFO) << "sample_primitive_StringRef_charObject_Length : " << charSize;
|
||||
char cs[16] = {0};
|
||||
int length = charObject->WriteLatin1(cs, 12);
|
||||
int length = charObject->WriteLatin1(vm_, cs, 12);
|
||||
GTEST_LOG_(INFO) << "sample_primitive_StringRef_charObject_WriteLatin1 : " << length;
|
||||
Local<StringRef> napiWrapperString = charObject->GetNapiWrapperString(vm_);
|
||||
EXPECT_EQ(napiWrapperString->Utf8Length(vm_), 13);
|
||||
char buffer1[12];
|
||||
EXPECT_EQ(charObject->WriteUtf8(buffer1, 12), 12);
|
||||
EXPECT_EQ(charObject->WriteUtf8(vm_, buffer1, 12), 12);
|
||||
std::string res1(buffer1);
|
||||
GTEST_LOG_(INFO) << "sample_primitive_StringRef_charObject_GetNapiWrapperString : " << res1;
|
||||
PrimitiveRef *pcharObject = charObject;
|
||||
GTEST_LOG_(INFO) << "sample_primitive_StringRef_pcharObject_IsString : " << pcharObject->IsString();
|
||||
GTEST_LOG_(INFO) << "sample_primitive_StringRef_pcharObject_IsString : " << pcharObject->IsString(vm_);
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSNApiSampleTest, Sample_PrimitiveRef_StringRef_Char16)
|
||||
@ -244,7 +244,7 @@ HWTEST_F_L0(JSNApiSampleTest, Sample_PrimitiveRef_StringRef_Char16)
|
||||
StringRef *char16tObject = StringRef::Cast(jsValue);
|
||||
EXPECT_EQ(char16tObject->Utf8Length(vm_), 10);
|
||||
char16_t buffer2[10];
|
||||
EXPECT_EQ(char16tObject->WriteUtf16(buffer2, 9), 9);
|
||||
EXPECT_EQ(char16tObject->WriteUtf16(vm_, buffer2, 9), 9);
|
||||
std::string res2(buffer2, buffer2 + sizeof(buffer2) / sizeof(char16_t));
|
||||
GTEST_LOG_(INFO) << "sample_primitive_StringRef_char16tObject : " << res2 << std::endl;
|
||||
std::string char16tObjectStr = char16tObject->ToString();
|
||||
@ -252,16 +252,16 @@ HWTEST_F_L0(JSNApiSampleTest, Sample_PrimitiveRef_StringRef_Char16)
|
||||
uint32_t charSize = char16tObject->Length();
|
||||
GTEST_LOG_(INFO) << "sample_primitive_StringRef_char16tObject_Length : " << charSize;
|
||||
char cs1[10] = {0};
|
||||
int length = char16tObject->WriteLatin1(cs1, 10);
|
||||
int length = char16tObject->WriteLatin1(vm_, cs1, 10);
|
||||
GTEST_LOG_(INFO) << "sample_primitive_StringRef_char16tObject_WriteLatin1 : " << length;
|
||||
Local<StringRef> napiWrapperString = char16tObject->GetNapiWrapperString(vm_);
|
||||
EXPECT_EQ(napiWrapperString->Utf8Length(vm_), 13);
|
||||
char16_t buffer3[10];
|
||||
EXPECT_EQ(char16tObject->WriteUtf16(buffer3, 9), 9);
|
||||
EXPECT_EQ(char16tObject->WriteUtf16(vm_, buffer3, 9), 9);
|
||||
std::string res3(buffer3, buffer3 + sizeof(buffer3) / sizeof(char16_t));
|
||||
GTEST_LOG_(INFO) << "sample_primitive_StringRef_char16tObject : " << res3;
|
||||
PrimitiveRef *pchar16tObject = char16tObject;
|
||||
GTEST_LOG_(INFO) << "sample_primitive_StringRef_pchar16tObject_IsString : " << pchar16tObject->IsString();
|
||||
GTEST_LOG_(INFO) << "sample_primitive_StringRef_pchar16tObject_IsString : " << pchar16tObject->IsString(vm_);
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSNApiSampleTest, Sample_PrimitiveRef_SymbolRef)
|
||||
@ -272,7 +272,7 @@ HWTEST_F_L0(JSNApiSampleTest, Sample_PrimitiveRef_SymbolRef)
|
||||
Local<StringRef> symbolDescription = symbolObject->GetDescription(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_primitive_symbol_description : " << symbolDescription->ToString();
|
||||
Local<PrimitiveRef> psymbolObject = symbolObject;
|
||||
GTEST_LOG_(INFO) << "sample_primitive_SymbolRef_Psym_IsSymbol : " << psymbolObject->IsSymbol();
|
||||
GTEST_LOG_(INFO) << "sample_primitive_SymbolRef_Psym_IsSymbol : " << psymbolObject->IsSymbol(vm_);
|
||||
}
|
||||
|
||||
/* demo2 本地指针包装的使用。 */
|
||||
@ -420,7 +420,7 @@ Local<JSValueRef> Setter2(JsiRuntimeCallInfo *info)
|
||||
Local<JSValueRef> arg = info->GetCallArgRef(0);
|
||||
Local<JSValueRef> value = info->GetThisRef();
|
||||
Local<ObjectRef> obj = value->ToObject(info->GetVM());
|
||||
if (!arg->IsString()) {
|
||||
if (!arg->IsString(info->GetVM())) {
|
||||
return JSValueRef::Undefined(info->GetVM());
|
||||
}
|
||||
obj->Set(info->GetVM(), GetSymbolRef(info->GetVM())[cnt], arg);
|
||||
@ -435,7 +435,7 @@ Local<JSValueRef> Setter3(JsiRuntimeCallInfo *info)
|
||||
Local<JSValueRef> arg = info->GetCallArgRef(0);
|
||||
Local<JSValueRef> value = info->GetThisRef();
|
||||
Local<ObjectRef> obj = value->ToObject(info->GetVM());
|
||||
if (!arg->IsSymbol()) {
|
||||
if (!arg->IsSymbol(info->GetVM())) {
|
||||
return JSValueRef::Undefined(info->GetVM());
|
||||
}
|
||||
obj->Set(info->GetVM(), GetSymbolRef(info->GetVM())[cnt], arg);
|
||||
@ -469,7 +469,7 @@ Local<JSValueRef> Getter3(JsiRuntimeCallInfo *info)
|
||||
Local<JSValueRef> value = info->GetThisRef();
|
||||
Local<ObjectRef> obj = value->ToObject(info->GetVM());
|
||||
Local<JSValueRef> temp = obj->Get(info->GetVM(), GetSymbolRef(info->GetVM())[cnt]);
|
||||
if (!temp->IsSymbol()) {
|
||||
if (!temp->IsSymbol(info->GetVM())) {
|
||||
JSValueRef::Undefined(info->GetVM());
|
||||
}
|
||||
Local<SymbolRef> str = temp;
|
||||
@ -525,7 +525,7 @@ void GetProperty(Local<ObjectRef> object, EcmaVM *vm)
|
||||
GTEST_LOG_(INFO) << "GetOwnPropertyNames cnt: " << cnt;
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
Local<JSValueRef> value = ArrayRef::GetValueAt(vm, names, i);
|
||||
if (value->IsSymbol()) {
|
||||
if (value->IsSymbol(vm)) {
|
||||
Local<SymbolRef> symbol = value;
|
||||
GTEST_LOG_(INFO) << "PropertyNames: " << symbol->GetDescription(vm)->ToString();
|
||||
} else {
|
||||
@ -539,15 +539,15 @@ void Get(Local<ObjectRef> object, EcmaVM *vm)
|
||||
GTEST_LOG_(INFO) << "Get";
|
||||
int cnt = 1; // 1 = key
|
||||
Local<JSValueRef> value = object->Get(vm, cnt);
|
||||
if (value->IsString()) {
|
||||
if (value->IsString(vm)) {
|
||||
GTEST_LOG_(INFO) << "Key:1 Value:" << value->ToString(vm)->ToString();
|
||||
}
|
||||
value = object->Get(vm, StringRef::NewFromUtf8(vm, "Test2"));
|
||||
if (value->IsString()) {
|
||||
if (value->IsString(vm)) {
|
||||
GTEST_LOG_(INFO) << "Key:Test2 Value:" << value->ToString(vm)->ToString();
|
||||
}
|
||||
value = object->Get(vm, StringRef::NewFromUtf8(vm, "AttributeKey1"));
|
||||
if (value->IsString()) {
|
||||
if (value->IsString(vm)) {
|
||||
GTEST_LOG_(INFO) << "Key:AttributeKey1 Value:" << value->ToString(vm)->ToString();
|
||||
}
|
||||
int num = 10; // 10 = randomness
|
||||
@ -556,15 +556,15 @@ void Get(Local<ObjectRef> object, EcmaVM *vm)
|
||||
object->Set(vm, StringRef::NewFromUtf8(vm, "AttributeKey3"),
|
||||
SymbolRef::New(vm, StringRef::NewFromUtf8(vm, "AttributeKey3Value")));
|
||||
Local<StringRef> str = object->Get(vm, StringRef::NewFromUtf8(vm, "AttributeKey3"));
|
||||
if (str->IsString()) {
|
||||
if (str->IsString(vm)) {
|
||||
GTEST_LOG_(INFO) << "Key:AttributeKey3 Value:" << str->ToString();
|
||||
}
|
||||
str = object->Get(vm, StringRef::NewFromUtf8(vm, "Accessor1"));
|
||||
if (str->IsString()) {
|
||||
if (str->IsString(vm)) {
|
||||
GTEST_LOG_(INFO) << "Key:Accessor1 Value:" << str->ToString();
|
||||
}
|
||||
str = object->Get(vm, StringRef::NewFromUtf8(vm, "Test3"));
|
||||
if (str->IsString()) {
|
||||
if (str->IsString(vm)) {
|
||||
GTEST_LOG_(INFO) << "Key:Test3 Value:" << str->ToString();
|
||||
}
|
||||
}
|
||||
@ -599,7 +599,7 @@ void GetOwnEnumerablePropertyNames(Local<ObjectRef> object, EcmaVM *vm)
|
||||
GTEST_LOG_(INFO) << "GetOwnEnumerablePropertyNames cnt: " << cnt;
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
Local<JSValueRef> value = ArrayRef::GetValueAt(vm, names, i);
|
||||
if (value->IsSymbol()) {
|
||||
if (value->IsSymbol(vm)) {
|
||||
Local<SymbolRef> symbol = value;
|
||||
GTEST_LOG_(INFO) << "PropertyNames: " << symbol->GetDescription(vm)->ToString();
|
||||
} else {
|
||||
@ -630,7 +630,7 @@ void PrintAllProperty(Local<ObjectRef> object, EcmaVM *vm, int flag)
|
||||
}
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
Local<JSValueRef> value = ArrayRef::GetValueAt(vm, names, i);
|
||||
if (value->IsSymbol()) {
|
||||
if (value->IsSymbol(vm)) {
|
||||
Local<SymbolRef> symbol = value;
|
||||
GTEST_LOG_(INFO) << "PropertyNames: " << symbol->GetDescription(vm)->ToString();
|
||||
} else {
|
||||
@ -1098,7 +1098,7 @@ Local<FunctionRef> Greeter::GetClassFunction(EcmaVM *vm)
|
||||
{
|
||||
Local<ObjectRef> globalObj = JSNApi::GetGlobalObject(vm);
|
||||
Local<JSValueRef> jsClaFunc = globalObj->Get(vm, StringRef::NewFromUtf8(vm, Greeter::CLASS_NAME.c_str()));
|
||||
if (jsClaFunc->IsFunction()) {
|
||||
if (jsClaFunc->IsFunction(vm)) {
|
||||
return jsClaFunc;
|
||||
}
|
||||
Local<FunctionRef> claFunc = Greeter::NewClassFunction(vm);
|
||||
@ -1188,9 +1188,9 @@ void Greeter::AddFunction(EcmaVM *vm, Local<ObjectRef> &proto)
|
||||
Local<JSValueRef> jsGreeting = thisRef->Get(vm, StringRef::NewFromUtf8(vm, "greeting"));
|
||||
Local<JSValueRef> jsStandardGreetingStr = claFunc->Get(vm, Greeter::standardGreetingStrKey);
|
||||
std::string ret;
|
||||
if (jsPrivateGreeting->IsString()) {
|
||||
if (jsPrivateGreeting->IsString(vm)) {
|
||||
ret.append("Hello, ").append(jsPrivateGreeting->ToString(vm)->ToString());
|
||||
} else if (jsGreeting->IsString()) {
|
||||
} else if (jsGreeting->IsString(vm)) {
|
||||
ret.append("Hello, ").append(jsGreeting->ToString(vm)->ToString());
|
||||
} else {
|
||||
ret.append(jsStandardGreetingStr->ToString(vm)->ToString());
|
||||
@ -1431,7 +1431,7 @@ Local<FunctionRef> Derive::GetClassFunction(EcmaVM *vm)
|
||||
{
|
||||
Local<ObjectRef> globalObj = JSNApi::GetGlobalObject(vm);
|
||||
Local<JSValueRef> jsClaFunc = globalObj->Get(vm, StringRef::NewFromUtf8(vm, Derive::CLASS_NAME.c_str()));
|
||||
if (jsClaFunc->IsFunction()) {
|
||||
if (jsClaFunc->IsFunction(vm)) {
|
||||
return jsClaFunc;
|
||||
}
|
||||
Local<FunctionRef> claFunc = Derive::NewClassFunction(vm);
|
||||
@ -1537,7 +1537,7 @@ Local<FunctionRef> DeriveDouble::GetClassFunction(EcmaVM *vm)
|
||||
{
|
||||
Local<ObjectRef> globalObj = JSNApi::GetGlobalObject(vm);
|
||||
Local<JSValueRef> jsClaFunc = globalObj->Get(vm, StringRef::NewFromUtf8(vm, DeriveDouble::CLASS_NAME.c_str()));
|
||||
if (jsClaFunc->IsFunction()) {
|
||||
if (jsClaFunc->IsFunction(vm)) {
|
||||
return jsClaFunc;
|
||||
}
|
||||
Local<FunctionRef> claFunc = DeriveDouble::NewClassFunction(vm);
|
||||
@ -1635,7 +1635,7 @@ Local<FunctionRef> DerivedTriple::GetClassFunction(EcmaVM *vm)
|
||||
{
|
||||
Local<ObjectRef> globalObj = JSNApi::GetGlobalObject(vm);
|
||||
Local<JSValueRef> jsClaFunc = globalObj->Get(vm, StringRef::NewFromUtf8(vm, DerivedTriple::CLASS_NAME.c_str()));
|
||||
if (jsClaFunc->IsFunction()) {
|
||||
if (jsClaFunc->IsFunction(vm)) {
|
||||
return jsClaFunc;
|
||||
}
|
||||
Local<FunctionRef> claFunc = DerivedTriple::NewClassFunction(vm);
|
||||
@ -1792,14 +1792,14 @@ HWTEST_F_L0(JSNApiSampleTest, sample_ArrayRef_String)
|
||||
for (int i = 0; i < (int)arrayLength; i++) {
|
||||
ArrayRef::SetValueAt(vm_, arrayObject, i, stringValue);
|
||||
char setBuffer[20];
|
||||
stringValue->WriteUtf8(setBuffer, inputString.length());
|
||||
stringValue->WriteUtf8(vm_, setBuffer, inputString.length());
|
||||
std::string result(setBuffer);
|
||||
GTEST_LOG_(INFO) << "sample_setStringValue_index_" << i << ": " << result;
|
||||
memset_s(setBuffer, sizeof(setBuffer), 0, sizeof(setBuffer));
|
||||
}
|
||||
Local<StringRef> resultString = ArrayRef::GetValueAt(vm_, arrayObject, index);
|
||||
char getBuffer[20];
|
||||
resultString->WriteUtf8(getBuffer, inputString.length());
|
||||
resultString->WriteUtf8(vm_, getBuffer, inputString.length());
|
||||
std::string getResult(getBuffer);
|
||||
GTEST_LOG_(INFO) << "sample_getStringValue_index_0: " << getResult;
|
||||
bool setResult = ArrayRef::SetValueAt(vm_, arrayObject, arrayLength, stringValue);
|
||||
@ -1810,13 +1810,13 @@ HWTEST_F_L0(JSNApiSampleTest, sample_ArrayRef_String)
|
||||
ArrayRef::SetValueAt(vm_, arrayObject, index, changedStringValue);
|
||||
Local<StringRef> resultChangedString = ArrayRef::GetValueAt(vm_, arrayObject, index);
|
||||
char changedBuffer[20];
|
||||
resultChangedString->WriteUtf8(changedBuffer, changedString.length());
|
||||
resultChangedString->WriteUtf8(vm_, changedBuffer, changedString.length());
|
||||
std::string changedResult(changedBuffer);
|
||||
GTEST_LOG_(INFO) << "sample_getChangedStringValue_index_0: " << changedResult;
|
||||
for (int i = 0; i < (int)arrayLength; i++) {
|
||||
Local<StringRef> printString = ArrayRef::GetValueAt(vm_, arrayObject, i);
|
||||
char printBuffer[20];
|
||||
printString->WriteUtf8(printBuffer, inputString.length());
|
||||
printString->WriteUtf8(vm_, printBuffer, inputString.length());
|
||||
std::string printResult(printBuffer);
|
||||
GTEST_LOG_(INFO) << "sample_printStringValue_index_" << i << ": " << printResult;
|
||||
memset_s(printBuffer, sizeof(printBuffer), 0, sizeof(printBuffer));
|
||||
@ -1829,7 +1829,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_Int8Array)
|
||||
const int32_t length = 15; // arraybuffer length = 15
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
int32_t arrayLength = arrayBuffer->ByteLength(vm_);
|
||||
int8_t *ptr = (int8_t *)arrayBuffer->GetBuffer();
|
||||
int8_t *ptr = (int8_t *)arrayBuffer->GetBuffer(vm_);
|
||||
for (int i = 0; i < arrayLength; i++) {
|
||||
*ptr = int8_t(i + 10);
|
||||
ptr++;
|
||||
@ -1840,7 +1840,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_Int8Array)
|
||||
GTEST_LOG_(INFO) << "sample_Int8Array_byteLength : " << typedArray->ByteLength(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Int8Array_byteOffset : " << typedArray->ByteOffset(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Int8Array_arrayLength : " << typedArray->ArrayLength(vm_);
|
||||
int8_t *result = (int8_t *)typedArray->GetArrayBuffer(vm_)->GetBuffer();
|
||||
int8_t *result = (int8_t *)typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_);
|
||||
for (int i = 0; i < int8ArrayLength; i++) {
|
||||
int value = int8_t(*result);
|
||||
GTEST_LOG_(INFO) << "sample_Int8Array_getInt8ArrayValue : " << value;
|
||||
@ -1854,7 +1854,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_Uint8Array)
|
||||
const int32_t length = 15; // arraybuffer length = 15
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
int32_t arrayLength = arrayBuffer->ByteLength(vm_);
|
||||
uint8_t *ptr = (uint8_t *)arrayBuffer->GetBuffer();
|
||||
uint8_t *ptr = (uint8_t *)arrayBuffer->GetBuffer(vm_);
|
||||
for (int i = 0; i < arrayLength; i++) {
|
||||
*ptr = uint8_t(i + 10);
|
||||
ptr++;
|
||||
@ -1865,7 +1865,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_Uint8Array)
|
||||
GTEST_LOG_(INFO) << "sample_Uint8Array_byteLength : " << typedArray->ByteLength(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Uint8Array_byteOffset : " << typedArray->ByteOffset(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Uint8Array_arrayLength : " << typedArray->ArrayLength(vm_);
|
||||
uint8_t *result = (uint8_t *)typedArray->GetArrayBuffer(vm_)->GetBuffer();
|
||||
uint8_t *result = (uint8_t *)typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_);
|
||||
for (int i = 0; i < Uint8ArrayLength; i++) {
|
||||
int value = uint8_t(*result);
|
||||
GTEST_LOG_(INFO) << "sample_Uint8Array_getUint8ArrayValue : " << value;
|
||||
@ -1879,7 +1879,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_Uint8ClampedArray)
|
||||
const int32_t length = 15; // arraybuffer length = 15
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
int32_t arrayLength = arrayBuffer->ByteLength(vm_);
|
||||
uint8_t *ptr = (uint8_t *)arrayBuffer->GetBuffer();
|
||||
uint8_t *ptr = (uint8_t *)arrayBuffer->GetBuffer(vm_);
|
||||
for (int i = 0; i < arrayLength; i++) {
|
||||
*ptr = uint8_t(i + 10);
|
||||
ptr++;
|
||||
@ -1890,7 +1890,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_Uint8ClampedArray)
|
||||
GTEST_LOG_(INFO) << "sample_Uint8ClampedArray_byteLength : " << typedArray->ByteLength(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Uint8ClampedArray_byteOffset : " << typedArray->ByteOffset(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Uint8ClampedArray_arrayLength : " << typedArray->ArrayLength(vm_);
|
||||
uint8_t *result = (uint8_t *)typedArray->GetArrayBuffer(vm_)->GetBuffer();
|
||||
uint8_t *result = (uint8_t *)typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_);
|
||||
for (int i = 0; i < uint8ArrLength; i++) {
|
||||
int value = uint8_t(*result);
|
||||
GTEST_LOG_(INFO) << "sample_Uint8ClampedArray_getUint8ClampedArrayValue : " << value;
|
||||
@ -1904,7 +1904,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_Int16Array)
|
||||
const int32_t length = 30; // arraybuffer length = 30
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
int32_t arrayLength = arrayBuffer->ByteLength(vm_);
|
||||
int16_t *ptr = (int16_t *)arrayBuffer->GetBuffer();
|
||||
int16_t *ptr = (int16_t *)arrayBuffer->GetBuffer(vm_);
|
||||
for (int i = 0; i < arrayLength / 2; i++) {
|
||||
*ptr = int16_t(i + 10);
|
||||
ptr++;
|
||||
@ -1915,7 +1915,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_Int16Array)
|
||||
GTEST_LOG_(INFO) << "sample_Int16Array_byteLength : " << typedArray->ByteLength(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Int16Array_byteOffset : " << typedArray->ByteOffset(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Int16Array_arrayLength : " << typedArray->ArrayLength(vm_);
|
||||
int16_t *result = (int16_t *)typedArray->GetArrayBuffer(vm_)->GetBuffer();
|
||||
int16_t *result = (int16_t *)typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_);
|
||||
for (int i = 0; i < int16ArrayLength; i++) {
|
||||
int value = int16_t(*result);
|
||||
GTEST_LOG_(INFO) << "sample_Int16Array_getInt16ArrayValue : " << value;
|
||||
@ -1929,7 +1929,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_Uint16Array)
|
||||
const int32_t length = 30; // arraybuffer length = 30
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
int32_t arrayLength = arrayBuffer->ByteLength(vm_);
|
||||
uint16_t *ptr = (uint16_t *)arrayBuffer->GetBuffer();
|
||||
uint16_t *ptr = (uint16_t *)arrayBuffer->GetBuffer(vm_);
|
||||
for (int i = 0; i < arrayLength / 2; i++) {
|
||||
*ptr = uint16_t(i + 10);
|
||||
ptr++;
|
||||
@ -1940,7 +1940,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_Uint16Array)
|
||||
GTEST_LOG_(INFO) << "sample_Uint16Array_byteLength : " << typedArray->ByteLength(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Uint16Array_byteOffset : " << typedArray->ByteOffset(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Uint16Array_arrayLength : " << typedArray->ArrayLength(vm_);
|
||||
uint16_t *result = (uint16_t *)typedArray->GetArrayBuffer(vm_)->GetBuffer();
|
||||
uint16_t *result = (uint16_t *)typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_);
|
||||
for (int i = 0; i < uint16ArrayLength; i++) {
|
||||
int value = uint16_t(*result);
|
||||
GTEST_LOG_(INFO) << "sample_Uint16Array_getUint16ArrayValue : " << value;
|
||||
@ -1954,7 +1954,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_Int32Array)
|
||||
const int32_t length = 32; // arraybuffer length = 32
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
int32_t arrayLength = arrayBuffer->ByteLength(vm_);
|
||||
int32_t *ptr = (int32_t *)arrayBuffer->GetBuffer();
|
||||
int32_t *ptr = (int32_t *)arrayBuffer->GetBuffer(vm_);
|
||||
for (int i = 0; i < arrayLength / 4; i++) {
|
||||
*ptr = int32_t(i + 10);
|
||||
ptr++;
|
||||
@ -1965,7 +1965,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_Int32Array)
|
||||
GTEST_LOG_(INFO) << "sample_Int32Array_byteLength : " << typedArray->ByteLength(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Int32Array_byteOffset : " << typedArray->ByteOffset(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Int32Array_arrayLength : " << typedArray->ArrayLength(vm_);
|
||||
int32_t *result = (int32_t *)typedArray->GetArrayBuffer(vm_)->GetBuffer();
|
||||
int32_t *result = (int32_t *)typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_);
|
||||
for (int i = 0; i < int32ArrayLength; i++) {
|
||||
int value = int32_t(*result);
|
||||
GTEST_LOG_(INFO) << "sample_Int32Array_getInt32ArrayValue : " << value;
|
||||
@ -1979,7 +1979,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_Uint32Array)
|
||||
const int32_t length = 32; // arraybuffer length = 32
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
int32_t arrayLength = arrayBuffer->ByteLength(vm_);
|
||||
uint32_t *ptr = (uint32_t *)arrayBuffer->GetBuffer();
|
||||
uint32_t *ptr = (uint32_t *)arrayBuffer->GetBuffer(vm_);
|
||||
for (int i = 0; i < arrayLength / 4; i++) {
|
||||
*ptr = uint32_t(i + 10);
|
||||
ptr++;
|
||||
@ -1990,7 +1990,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_Uint32Array)
|
||||
GTEST_LOG_(INFO) << "sample_Uint32Array_byteLength : " << typedArray->ByteLength(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Uint32Array_byteOffset : " << typedArray->ByteOffset(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Uint32Array_arrayLength : " << typedArray->ArrayLength(vm_);
|
||||
uint32_t *result = (uint32_t *)typedArray->GetArrayBuffer(vm_)->GetBuffer();
|
||||
uint32_t *result = (uint32_t *)typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_);
|
||||
for (int i = 0; i < uint32ArrayLength; i++) {
|
||||
int value = uint32_t(*result);
|
||||
GTEST_LOG_(INFO) << "sample_Uint32Array_getUint32ArrayValue : " << value;
|
||||
@ -2004,7 +2004,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_Float32Array)
|
||||
const int32_t length = 32; // arraybuffer length = 32
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
int32_t arrayLength = arrayBuffer->ByteLength(vm_);
|
||||
float *ptr = (float *)arrayBuffer->GetBuffer();
|
||||
float *ptr = (float *)arrayBuffer->GetBuffer(vm_);
|
||||
for (int i = 0; i < arrayLength / 4; i++) {
|
||||
*ptr = float(i + 10);
|
||||
ptr++;
|
||||
@ -2015,7 +2015,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_Float32Array)
|
||||
GTEST_LOG_(INFO) << "sample_Float32Array_byteLength : " << typedArray->ByteLength(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Float32Array_byteOffset : " << typedArray->ByteOffset(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Float32Array_arrayLength : " << typedArray->ArrayLength(vm_);
|
||||
float *result = (float *)typedArray->GetArrayBuffer(vm_)->GetBuffer();
|
||||
float *result = (float *)typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_);
|
||||
for (int i = 0; i < float32ArrayLength; i++) {
|
||||
int value = float(*result);
|
||||
GTEST_LOG_(INFO) << "sample_Float32Array_getFloat32ArrayValue : " << value;
|
||||
@ -2029,7 +2029,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_Float64Array)
|
||||
const int32_t length = 64; // arraybuffer length = 64
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
int32_t arrayLength = arrayBuffer->ByteLength(vm_);
|
||||
double *ptr = (double *)arrayBuffer->GetBuffer();
|
||||
double *ptr = (double *)arrayBuffer->GetBuffer(vm_);
|
||||
for (int i = 0; i < arrayLength / 8; i++) {
|
||||
*ptr = double(i + 10);
|
||||
ptr++;
|
||||
@ -2040,7 +2040,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_Float64Array)
|
||||
GTEST_LOG_(INFO) << "sample_Float64Array_byteLength : " << typedArray->ByteLength(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Float64Array_byteOffset : " << typedArray->ByteOffset(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Float64Array_arrayLength : " << typedArray->ArrayLength(vm_);
|
||||
double *result = (double *)typedArray->GetArrayBuffer(vm_)->GetBuffer();
|
||||
double *result = (double *)typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_);
|
||||
for (int i = 0; i < float64ArrayLength; i++) {
|
||||
int value = double(*result);
|
||||
GTEST_LOG_(INFO) << "sample_Float64Array_getFloat64ArrayValue : " << value;
|
||||
@ -2054,7 +2054,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_BigInt64Array)
|
||||
const int32_t length = 64; // arraybuffer length = 64
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
int32_t arrayLength = arrayBuffer->ByteLength(vm_);
|
||||
int64_t *ptr = (int64_t *)arrayBuffer->GetBuffer();
|
||||
int64_t *ptr = (int64_t *)arrayBuffer->GetBuffer(vm_);
|
||||
for (int i = 0; i < arrayLength / 8; i++) {
|
||||
*ptr = int64_t(i * 100);
|
||||
ptr++;
|
||||
@ -2065,7 +2065,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_BigInt64Array)
|
||||
GTEST_LOG_(INFO) << "sample_BigInt64Array_byteLength : " << typedArray->ByteLength(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_BigInt64Array_byteOffset : " << typedArray->ByteOffset(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_BigInt64Array_arrayLength : " << typedArray->ArrayLength(vm_);
|
||||
int64_t *result = (int64_t *)typedArray->GetArrayBuffer(vm_)->GetBuffer();
|
||||
int64_t *result = (int64_t *)typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_);
|
||||
for (int i = 0; i < bigInt64ArrayLength; i++) {
|
||||
int value = int64_t(*result);
|
||||
GTEST_LOG_(INFO) << "sample_BigInt64Array_getBigInt64ArrayValue : " << value;
|
||||
@ -2079,7 +2079,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_BigUint64Array)
|
||||
const int32_t length = 64; // arraybuffer length = 64
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
int32_t arrayLength = arrayBuffer->ByteLength(vm_);
|
||||
uint64_t *ptr = (uint64_t *)arrayBuffer->GetBuffer();
|
||||
uint64_t *ptr = (uint64_t *)arrayBuffer->GetBuffer(vm_);
|
||||
for (int i = 0; i < arrayLength / 8; i++) {
|
||||
*ptr = int64_t(i * 100);
|
||||
ptr++;
|
||||
@ -2090,7 +2090,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_TypedArrayRef_BigUint64Array)
|
||||
GTEST_LOG_(INFO) << "sample_BigUint64Array_byteLength : " << typedArray->ByteLength(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_BigUint64Array_byteOffset : " << typedArray->ByteOffset(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_BigUint64Array_arrayLength : " << typedArray->ArrayLength(vm_);
|
||||
uint64_t *result = (uint64_t *)typedArray->GetArrayBuffer(vm_)->GetBuffer();
|
||||
uint64_t *result = (uint64_t *)typedArray->GetArrayBuffer(vm_)->GetBuffer(vm_);
|
||||
for (int i = 0; i < bigUint64ArrayLength; i++) {
|
||||
int value = uint64_t(*result);
|
||||
GTEST_LOG_(INFO) << "sample_BigUint64Array_getBigUint64ArrayValue : " << value;
|
||||
@ -2108,7 +2108,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_DataViewRef)
|
||||
Local<DataViewRef> dataView = DataViewRef::New(vm_, arrayBuffer, byteOffset, dataViewLength);
|
||||
GTEST_LOG_(INFO) << "sample_DataView_byteLength : " << dataView->ByteLength();
|
||||
GTEST_LOG_(INFO) << "sample_DataView_byteOffset : " << dataView->ByteOffset();
|
||||
GTEST_LOG_(INFO) << "sample_DataView_getArrayBuffer : " << dataView->GetArrayBuffer(vm_)->GetBuffer();
|
||||
GTEST_LOG_(INFO) << "sample_DataView_getArrayBuffer : " << dataView->GetArrayBuffer(vm_)->GetBuffer(vm_);
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSNApiSampleTest, sample_ArrayBuffer_New_Detach)
|
||||
@ -2118,10 +2118,10 @@ HWTEST_F_L0(JSNApiSampleTest, sample_ArrayBuffer_New_Detach)
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
int32_t arrayLength = arrayBuffer->ByteLength(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_ArrayBuffer_byteLength : " << arrayLength;
|
||||
GTEST_LOG_(INFO) << "sample_ArrayBuffer_getArrayBuffer : " << arrayBuffer->GetBuffer();
|
||||
GTEST_LOG_(INFO) << "sample_ArrayBuffer_getArrayBuffer : " << arrayBuffer->GetBuffer(vm_);
|
||||
arrayBuffer->Detach(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_ArrayBuffer_getDetachArrayBuffer : " << arrayBuffer->GetBuffer();
|
||||
bool result = arrayBuffer->IsDetach();
|
||||
GTEST_LOG_(INFO) << "sample_ArrayBuffer_getDetachArrayBuffer : " << arrayBuffer->GetBuffer(vm_);
|
||||
bool result = arrayBuffer->IsDetach(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_ArrayBuffer_getIsDetach : " << result;
|
||||
}
|
||||
|
||||
@ -2144,10 +2144,10 @@ HWTEST_F_L0(JSNApiSampleTest, sample_ArrayBufferWithBuffer_New_Detach)
|
||||
uint8_t *buffer = new uint8_t[length]();
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, buffer, length, deleter, data);
|
||||
GTEST_LOG_(INFO) << "sample_ArrayBufferWithBuffer_byteLength : " << arrayBuffer->ByteLength(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_ArrayBufferWithBuffer_getArrayBuffer : " << arrayBuffer->GetBuffer();
|
||||
GTEST_LOG_(INFO) << "sample_ArrayBufferWithBuffer_getArrayBuffer : " << arrayBuffer->GetBuffer(vm_);
|
||||
arrayBuffer->Detach(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_ArrayBufferWithBuffer_getDetachArrayBuffer : " << arrayBuffer->GetBuffer();
|
||||
bool result = arrayBuffer->IsDetach();
|
||||
GTEST_LOG_(INFO) << "sample_ArrayBufferWithBuffer_getDetachArrayBuffer : " << arrayBuffer->GetBuffer(vm_);
|
||||
bool result = arrayBuffer->IsDetach(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_ArrayBufferWithBuffer_getIsDetach : " << result;
|
||||
}
|
||||
|
||||
@ -2157,7 +2157,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_Buffer_New_GetBuffer)
|
||||
const int32_t length = 5; // buffer length = 5
|
||||
Local<BufferRef> buffer = BufferRef::New(vm_, length);
|
||||
GTEST_LOG_(INFO) << "sample_Buffer_byteLength : " << buffer->ByteLength(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_Buffer_getBuffer : " << buffer->GetBuffer();
|
||||
GTEST_LOG_(INFO) << "sample_Buffer_getBuffer : " << buffer->GetBuffer(vm_);
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSNApiSampleTest, sample_BufferWithBuffer_New_GetBuffer)
|
||||
@ -2179,7 +2179,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_BufferWithBuffer_New_GetBuffer)
|
||||
uint8_t *buffer = new uint8_t[length]();
|
||||
Local<BufferRef> bufferObj = BufferRef::New(vm_, buffer, length, deleter, data);
|
||||
GTEST_LOG_(INFO) << "sample_bufferWithBuffer_byteLength : " << bufferObj->ByteLength(vm_);
|
||||
GTEST_LOG_(INFO) << "sample_bufferWithBuffer_getBuffer : " << bufferObj->GetBuffer();
|
||||
GTEST_LOG_(INFO) << "sample_bufferWithBuffer_getBuffer : " << bufferObj->GetBuffer(vm_);
|
||||
}
|
||||
|
||||
/* domo8 异步操作。 ts:
|
||||
@ -2249,13 +2249,13 @@ HWTEST_F_L0(JSNApiSampleTest, sample_demo8_async_test_1)
|
||||
// JSValueRef转为字符串输出。
|
||||
std::string jsValue2String(EcmaVM *vm, Local<JSValueRef> &jsVal)
|
||||
{
|
||||
if (jsVal->IsString()) {
|
||||
if (jsVal->IsString(vm)) {
|
||||
return "type string, val : " + jsVal->ToString(vm)->ToString();
|
||||
} else if (jsVal->IsNumber()) {
|
||||
return "type number, val : " + std::to_string(jsVal->Int32Value(vm));
|
||||
} else if (jsVal->IsBoolean()) {
|
||||
return "type bool, val : " + std::to_string(jsVal->BooleaValue());
|
||||
} else if (jsVal->IsSymbol()) {
|
||||
} else if (jsVal->IsSymbol(vm)) {
|
||||
Local<SymbolRef> symbol = jsVal;
|
||||
return "type symbol, val : " + symbol->GetDescription(vm)->ToString();
|
||||
} else {
|
||||
@ -2282,7 +2282,7 @@ void MapSetValue(EcmaVM *vm, Local<MapRef> &map, Local<JSValueRef> symbolKey)
|
||||
void MapGetValue(EcmaVM *vm, Local<MapRef> &map, Local<JSValueRef> symbolKey)
|
||||
{
|
||||
Local<JSValueRef> val1 = map->Get(vm, StringRef::NewFromUtf8(vm, "key1"));
|
||||
bool val1IsString = val1->IsString();
|
||||
bool val1IsString = val1->IsString(vm);
|
||||
GTEST_LOG_(INFO) << "key1 : IsString:" << val1IsString << " val:" << val1->ToString(vm)->ToString();
|
||||
|
||||
Local<JSValueRef> val2 = map->Get(vm, StringRef::NewFromUtf8(vm, "key2"));
|
||||
@ -2294,7 +2294,7 @@ void MapGetValue(EcmaVM *vm, Local<MapRef> &map, Local<JSValueRef> symbolKey)
|
||||
GTEST_LOG_(INFO) << "key3 : IsBoolean:" << val3IsBoolean << " val:" << val3->BooleaValue();
|
||||
|
||||
Local<JSValueRef> val4 = map->Get(vm, StringRef::NewFromUtf8(vm, "key4"));
|
||||
bool val4IsSymbol = val4->IsSymbol();
|
||||
bool val4IsSymbol = val4->IsSymbol(vm);
|
||||
Local<SymbolRef> val4Symbol = val4;
|
||||
GTEST_LOG_(INFO) << "key4 : IsSymbol:" << val4IsSymbol << " val:" << val4Symbol->GetDescription(vm)->ToString();
|
||||
|
||||
@ -2472,7 +2472,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_demo10_weakset)
|
||||
void JsonObjGetValue(EcmaVM *vm, Local<ObjectRef> obj)
|
||||
{
|
||||
Local<JSValueRef> jsVal1 = obj->Get(vm, StringRef::NewFromUtf8(vm, "str1"));
|
||||
bool jsVal1IsString = jsVal1->IsString();
|
||||
bool jsVal1IsString = jsVal1->IsString(vm);
|
||||
Local<StringRef> val1 = jsVal1->ToString(vm);
|
||||
GTEST_LOG_(INFO) << "str1 : is string : " << jsVal1IsString << " value : " << val1->ToString();
|
||||
Local<JSValueRef> jsVal2 = obj->Get(vm, StringRef::NewFromUtf8(vm, "str2"));
|
||||
@ -2643,7 +2643,7 @@ HWTEST_F_L0(JSNApiSampleTest, sample_demo11_json_test_2_stringify_object)
|
||||
obj->Set(vm_, StringRef::NewFromUtf8(vm_, "obj7"), obj7);
|
||||
|
||||
Local<JSValueRef> jsStr = JSON::Stringify(vm_, obj);
|
||||
GTEST_LOG_(INFO) << "jsStr is String : " << jsStr->IsString();
|
||||
GTEST_LOG_(INFO) << "jsStr is String : " << jsStr->IsString(vm_);
|
||||
Local<StringRef> strRef = jsStr->ToString(vm_);
|
||||
std::string str = strRef->ToString();
|
||||
GTEST_LOG_(INFO) << "json : " << str;
|
||||
@ -2790,13 +2790,13 @@ HWTEST_F_L0(JSNApiSampleTest, sample_demo11_json_test_3_parse_array5)
|
||||
GTEST_LOG_(INFO) << "arr5 length : " << arr5Length;
|
||||
for (uint32_t i = 0; i < arr5Length; ++i) {
|
||||
Local<JSValueRef> arr5Item = ArrayRef::GetValueAt(vm_, arr5, i);
|
||||
if (arr5Item->IsString()) {
|
||||
if (arr5Item->IsString(vm_)) {
|
||||
GTEST_LOG_(INFO) << "arr5 index : " << i << " value : " << arr5Item->ToString(vm_)->ToString();
|
||||
} else if (arr5Item->IsNumber()) {
|
||||
GTEST_LOG_(INFO) << "arr5 index : " << i << " value : " << arr5Item->Int32Value(vm_);
|
||||
} else if (arr5Item->IsBoolean()) {
|
||||
GTEST_LOG_(INFO) << "arr5 index : " << i << " value : " << arr5Item->ToBoolean(vm_)->Value();
|
||||
} else if (arr5Item->IsObject()) {
|
||||
} else if (arr5Item->IsObject(vm_)) {
|
||||
Local<ObjectRef> obj = arr5Item->ToObject(vm_);
|
||||
Local<ObjectRef> val1 = obj->Get(vm_, StringRef::NewFromUtf8(vm_, "key1"));
|
||||
Local<ObjectRef> val2 = obj->Get(vm_, StringRef::NewFromUtf8(vm_, "key2"));
|
||||
|
@ -159,7 +159,7 @@ void CheckReject(JsiRuntimeCallInfo *info)
|
||||
{
|
||||
ASSERT_EQ(info->GetArgsNumber(), 1U);
|
||||
Local<JSValueRef> reason = info->GetCallArgRef(0);
|
||||
ASSERT_TRUE(reason->IsString());
|
||||
ASSERT_TRUE(reason->IsString(info->GetVM()));
|
||||
ASSERT_EQ(Local<StringRef>(reason)->ToString(), "Reject");
|
||||
}
|
||||
|
||||
@ -259,7 +259,7 @@ HWTEST_F_L0(JSNApiTests, ObjectRef_GetAllPropertyNames)
|
||||
Local<ObjectRef> object = ObjectRef::New(vm_);
|
||||
uint32_t filter = 3;
|
||||
Local<ArrayRef> res = object->GetAllPropertyNames(vm_, filter);
|
||||
ASSERT_FALSE(res->IsBigInt());
|
||||
ASSERT_FALSE(res->IsBigInt(vm_));
|
||||
ASSERT_TRUE(res->IsArray(vm_));
|
||||
}
|
||||
|
||||
@ -322,7 +322,7 @@ HWTEST_F_L0(JSNApiTests, GetKind_entries_values_keys)
|
||||
Local<MapIteratorRef> mapIterator = JSNApiHelper::ToLocal<MapIteratorRef>(jsMapIteratorTag);
|
||||
Local<JSValueRef> res = mapIterator->GetKind(vm_);
|
||||
EXPECT_EQ(expectedResult, res->ToString(vm_)->ToString());
|
||||
EXPECT_TRUE(mapIterator->IsMapIterator());
|
||||
EXPECT_TRUE(mapIterator->IsMapIterator(vm_));
|
||||
JSHandle<JSTaggedValue> jsMapIteratorTag1 = JSMapIterator::CreateMapIterator(thread, mapTag, IterationKind::KEY);
|
||||
Local<MapIteratorRef> mapIterator1 = JSNApiHelper::ToLocal<MapIteratorRef>(jsMapIteratorTag1);
|
||||
Local<JSValueRef> res1 = mapIterator1->GetKind(vm_);
|
||||
@ -428,7 +428,7 @@ HWTEST_F_L0(JSNApiTests, GetKind_003)
|
||||
Local<MapIteratorRef> mapIterator = JSNApiHelper::ToLocal<MapIteratorRef>(jsMapIteratorTag);
|
||||
Local<JSValueRef> res = mapIterator->GetKind(vm_);
|
||||
EXPECT_EQ(expectedResult, res->ToString(vm_)->ToString());
|
||||
EXPECT_TRUE(mapIterator->IsMapIterator());
|
||||
EXPECT_TRUE(mapIterator->IsMapIterator(vm_));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -444,11 +444,11 @@ HWTEST_F_L0(JSNApiTests, GetProperty_IsFunction)
|
||||
LocalScope scope(vm_);
|
||||
Local<ObjectRef> globalObject = JSNApi::GetGlobalObject(vm_);
|
||||
ASSERT_FALSE(globalObject.IsEmpty());
|
||||
ASSERT_TRUE(globalObject->IsObject());
|
||||
ASSERT_TRUE(globalObject->IsObject(vm_));
|
||||
|
||||
Local<ObjectRef> key = StringRef::NewFromUtf8(vm_, "Number");
|
||||
Local<ObjectRef> property = globalObject->Get(vm_, key);
|
||||
ASSERT_TRUE(property->IsFunction());
|
||||
ASSERT_TRUE(property->IsFunction(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -491,14 +491,14 @@ HWTEST_F_L0(JSNApiTests, PromiseRef_Finally_IsPromise)
|
||||
Local<PromiseRef> gitpromise = capability->GetPromise(vm_);
|
||||
Local<FunctionRef> rejectcallback = FunctionRef::New(vm_, RejectCallback);
|
||||
Local<PromiseRef> catchPromise = gitpromise->Finally(vm_, rejectcallback);
|
||||
ASSERT_TRUE(gitpromise->IsPromise());
|
||||
ASSERT_TRUE(catchPromise->IsPromise());
|
||||
ASSERT_TRUE(gitpromise->IsPromise(vm_));
|
||||
ASSERT_TRUE(catchPromise->IsPromise(vm_));
|
||||
Local<PromiseRef> catchPromise2 = gitpromise->Then(vm_, rejectcallback, rejectcallback);
|
||||
ASSERT_TRUE(catchPromise2->IsPromise());
|
||||
ASSERT_TRUE(catchPromise2->IsPromise(vm_));
|
||||
Local<FunctionRef> functioncallback = FunctionRef::New(vm_, FunctionCallback);
|
||||
ASSERT_TRUE(!functioncallback.IsEmpty());
|
||||
Local<PromiseRef> catchPromise3 = gitpromise->Then(vm_, functioncallback);
|
||||
ASSERT_TRUE(catchPromise3->IsPromise());
|
||||
ASSERT_TRUE(catchPromise3->IsPromise(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -513,7 +513,7 @@ HWTEST_F_L0(JSNApiTests, IsBuffer)
|
||||
LocalScope scope(vm_);
|
||||
const int32_t length = 15;
|
||||
Local<BufferRef> buffer = BufferRef::New(vm_, length);
|
||||
ASSERT_TRUE(buffer->IsBuffer());
|
||||
ASSERT_TRUE(buffer->IsBuffer(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -529,7 +529,7 @@ HWTEST_F_L0(JSNApiTests, IsDataView)
|
||||
const int32_t length = 15;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
Local<DataViewRef> dataView = DataViewRef::New(vm_, arrayBuffer, 5, 7);
|
||||
ASSERT_TRUE(dataView->IsDataView());
|
||||
ASSERT_TRUE(dataView->IsDataView(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -544,7 +544,7 @@ HWTEST_F_L0(JSNApiTests, IsSharedArrayBuffer)
|
||||
LocalScope scope(vm_);
|
||||
const int32_t length = 15;
|
||||
Local<JSValueRef> sharedArrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
ASSERT_FALSE(sharedArrayBuffer->IsSharedArrayBuffer());
|
||||
ASSERT_FALSE(sharedArrayBuffer->IsSharedArrayBuffer(vm_));
|
||||
}
|
||||
|
||||
|
||||
@ -587,7 +587,7 @@ HWTEST_F_L0(JSNApiTests, IsConstructor)
|
||||
{
|
||||
LocalScope scope(vm_);
|
||||
Local<FunctionRef> target = FunctionRef::New(vm_, FunctionCallback);
|
||||
ASSERT_FALSE(target->IsConstructor());
|
||||
ASSERT_FALSE(target->IsConstructor(vm_));
|
||||
}
|
||||
|
||||
|
||||
@ -631,7 +631,7 @@ HWTEST_F_L0(JSNApiTests, JSValueRef_IsTreeMap)
|
||||
jsTreeMap->SetTreeMap(thread, treeMap);
|
||||
JSHandle<JSTaggedValue> argumentTag = JSHandle<JSTaggedValue>::Cast(jsTreeMap);
|
||||
Local<JSValueRef> TreeMap = JSNApiHelper::ToLocal<JSAPITreeSet>(argumentTag);
|
||||
EXPECT_TRUE(TreeMap->IsTreeMap());
|
||||
EXPECT_TRUE(TreeMap->IsTreeMap(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -654,7 +654,7 @@ HWTEST_F_L0(JSNApiTests, JSValueRef_IsTreeSet)
|
||||
jsTreeSet->SetTreeSet(thread, treeSet);
|
||||
JSHandle<JSTaggedValue> argumentTag = JSHandle<JSTaggedValue>::Cast(jsTreeSet);
|
||||
Local<JSValueRef> TreeSet = JSNApiHelper::ToLocal<JSAPITreeSet>(argumentTag);
|
||||
EXPECT_TRUE(TreeSet->IsTreeSet());
|
||||
EXPECT_TRUE(TreeSet->IsTreeSet(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -676,7 +676,7 @@ HWTEST_F_L0(JSNApiTests, JSValueRef_IsVector)
|
||||
jsVector->SetLength(0);
|
||||
JSHandle<JSTaggedValue> argumentTag = JSHandle<JSTaggedValue>::Cast(jsVector);
|
||||
Local<JSValueRef> Vector = JSNApiHelper::ToLocal<JSAPIVector>(argumentTag);
|
||||
EXPECT_TRUE(Vector->IsVector());
|
||||
EXPECT_TRUE(Vector->IsVector(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -707,7 +707,7 @@ HWTEST_F_L0(JSNApiTests, JSValueRef_IsMap)
|
||||
{
|
||||
LocalScope scope(vm_);
|
||||
Local<MapRef> map = MapRef::New(vm_);
|
||||
EXPECT_TRUE(map->IsMap());
|
||||
EXPECT_TRUE(map->IsMap(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -730,7 +730,7 @@ HWTEST_F_L0(JSNApiTests, SetRef_IsSet)
|
||||
set->SetLinkedSet(thread, hashSet);
|
||||
JSHandle<JSTaggedValue> setTag = JSHandle<JSTaggedValue>::Cast(set);
|
||||
Local<SetRef> Set = JSNApiHelper::ToLocal<SetRef>(setTag);
|
||||
EXPECT_TRUE(Set->IsSet());
|
||||
EXPECT_TRUE(Set->IsSet(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -791,7 +791,7 @@ HWTEST_F_L0(JSNApiTests, ArrayRefNew_uint32Length_SetValueAt_GetValueAt)
|
||||
LocalScope scope(vm_);
|
||||
Local<ObjectRef> globalObject = JSNApi::GetGlobalObject(vm_);
|
||||
ASSERT_FALSE(globalObject.IsEmpty());
|
||||
ASSERT_TRUE(globalObject->IsObject());
|
||||
ASSERT_TRUE(globalObject->IsObject(vm_));
|
||||
Local<ArrayRef> property = ArrayRef::New(vm_, 3); // 3 : length
|
||||
ASSERT_TRUE(property->IsArray(vm_));
|
||||
ASSERT_EQ(property->Length(vm_), 3); // 3 : test case of input
|
||||
@ -824,7 +824,7 @@ HWTEST_F_L0(JSNApiTests, WeakSetRef_GetSize_GetTotalElements_GetValue)
|
||||
weakSet->SetLinkedSet(thread, hashSet);
|
||||
JSHandle<JSTaggedValue> weakSetTag = JSHandle<JSTaggedValue>::Cast(weakSet);
|
||||
Local<JSValueRef> set1 = JSNApiHelper::ToLocal<WeakSetRef>(weakSetTag);
|
||||
EXPECT_TRUE(set1->IsWeakSet());
|
||||
EXPECT_TRUE(set1->IsWeakSet(vm_));
|
||||
Local<WeakSetRef> set = JSNApiHelper::ToLocal<WeakSetRef>(weakSetTag);
|
||||
JSHandle<JSTaggedValue> value(factory->NewFromASCII("value"));
|
||||
JSWeakSet::Add(thread, weakSet, value);
|
||||
@ -937,7 +937,7 @@ HWTEST_F_L0(JSNApiTests, JSValueRef_IsRegExp)
|
||||
jSRegExp->SetLength(0);
|
||||
JSHandle<JSTaggedValue> argumentTag = JSHandle<JSTaggedValue>::Cast(jSRegExp);
|
||||
Local<JSValueRef> regexp = JSNApiHelper::ToLocal<JSRegExp>(argumentTag);
|
||||
EXPECT_TRUE(regexp->IsRegExp());
|
||||
EXPECT_TRUE(regexp->IsRegExp(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -954,7 +954,7 @@ HWTEST_F_L0(JSNApiTests, GetAndClearUncaughtException)
|
||||
EXPECT_FALSE(tryCatch.HasCaught());
|
||||
Local<StringRef> message = StringRef::NewFromUtf8(vm_, "ErrorTest");
|
||||
Local<JSValueRef> error = Exception::Error(vm_, message);
|
||||
EXPECT_TRUE(error->IsError());
|
||||
EXPECT_TRUE(error->IsError(vm_));
|
||||
JSNApi::ThrowException(vm_, error);
|
||||
EXPECT_TRUE(vm_->GetJSThread()->HasPendingException());
|
||||
JSNApi::GetAndClearUncaughtException(vm_);
|
||||
@ -976,7 +976,7 @@ HWTEST_F_L0(JSNApiTests, JSValueRef_IsJSPrimitiveNumber)
|
||||
JSHandle<JSPrimitiveRef> jsprimitive = factory->NewJSPrimitiveRef(PrimitiveType::PRIMITIVE_NUMBER, jstagvalue);
|
||||
JSHandle<JSTaggedValue> jspri = JSHandle<JSTaggedValue>::Cast(jsprimitive);
|
||||
Local<JSValueRef> object = JSNApiHelper::ToLocal<JSValueRef>(jspri);
|
||||
EXPECT_FALSE(object->IsJSPrimitiveNumber());
|
||||
EXPECT_FALSE(object->IsJSPrimitiveNumber(vm_));
|
||||
}
|
||||
|
||||
|
||||
@ -996,7 +996,7 @@ HWTEST_F_L0(JSNApiTests, StringUtf16_NewFromUtf16_Length_WriteUtf16_01)
|
||||
Local<StringRef> testString = StringRef::NewFromUtf16(vm_, test);
|
||||
EXPECT_EQ(testString->Length(), 2); // 2 : length of testString("年度")
|
||||
char16_t buffer[3]; // 3 : length of testString + 1
|
||||
EXPECT_EQ(testString->WriteUtf16(buffer, 2), 2); // 2 : length of testString("年度")
|
||||
EXPECT_EQ(testString->WriteUtf16(vm_, buffer, 2), 2); // 2 : length of testString("年度")
|
||||
GTEST_LOG_(WARNING) << "年度test =" << buffer;
|
||||
ASSERT_EQ(buffer[0], u'年');
|
||||
ASSERT_EQ(buffer[1], u'度');
|
||||
@ -1017,7 +1017,7 @@ HWTEST_F_L0(JSNApiTests, StringUtf16_NewFromUtf16_Length_WriteUtf16_02)
|
||||
|
||||
EXPECT_EQ(testString->Length(), 14);
|
||||
char16_t buffer[15]; // 15 : length of testString + 1
|
||||
EXPECT_EQ(testString->WriteUtf16(buffer, 14), 14); // 14 : length of testString("hello world!!!")
|
||||
EXPECT_EQ(testString->WriteUtf16(vm_, buffer, 14), 14); // 14 : length of testString("hello world!!!")
|
||||
ASSERT_EQ(buffer[0], u'h');
|
||||
ASSERT_EQ(buffer[13], u'?');
|
||||
}
|
||||
@ -1046,7 +1046,7 @@ HWTEST_F_L0(JSNApiTests, SetRef_IsSet_GetSize_GetTotalElements_GetValue)
|
||||
jsSet->SetLinkedSet(thread, hashSet);
|
||||
JSHandle<JSTaggedValue> setTag = JSHandle<JSTaggedValue>::Cast(jsSet);
|
||||
Local<SetRef> set = JSNApiHelper::ToLocal<SetRef>(setTag);
|
||||
EXPECT_TRUE(set->IsSet());
|
||||
EXPECT_TRUE(set->IsSet(vm_));
|
||||
JSHandle<JSTaggedValue> fristValue(factory->NewFromASCII("vlue1"));
|
||||
JSSet::Add(thread, jsSet, fristValue);
|
||||
JSSet::Add(thread, jsSet, fristValue);
|
||||
@ -1099,7 +1099,7 @@ HWTEST_F_L0(JSNApiTests, JSSetIterator_IsSetIterator_GetIndex_GetKind)
|
||||
JSHandle<JSSetIterator> jsSetIterator1(jsTagSetIterator);
|
||||
EXPECT_EQ(JSTaggedValue::SameValue(jsSetIterator1->GetIteratedSet(), jsSet->GetLinkedSet()), true);
|
||||
Local<SetIteratorRef> setIterator = JSNApiHelper::ToLocal<SetIteratorRef>(jsTagSetIterator);
|
||||
EXPECT_TRUE(setIterator->IsSetIterator());
|
||||
EXPECT_TRUE(setIterator->IsSetIterator(vm_));
|
||||
EXPECT_EQ(setIterator->GetIndex(), 0U);
|
||||
Local<JSValueRef> resultKey = StringRef::NewFromUtf8(vm_, "keys");
|
||||
EXPECT_EQ(setIterator->GetKind(vm_)->ToString(vm_)->ToString(), resultKey->ToString(vm_)->ToString());
|
||||
@ -1129,7 +1129,7 @@ HWTEST_F_L0(JSNApiTests, JSValueRef_IsMapIterator)
|
||||
JSHandle<JSMapIterator> jsMapIterator(jsMapIteratorTag);
|
||||
EXPECT_EQ(JSTaggedValue::SameValue(jsMapIterator->GetIteratedMap(), jsMap->GetLinkedMap()), true);
|
||||
Local<JSValueRef> mapIterator = JSNApiHelper::ToLocal<MapIteratorRef>(jsMapIteratorTag);
|
||||
EXPECT_TRUE(mapIterator->IsMapIterator());
|
||||
EXPECT_TRUE(mapIterator->IsMapIterator(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1159,6 +1159,6 @@ HWTEST_F_L0(JSNApiTests, JSValueRef_IsModuleNamespaceObject)
|
||||
EXPECT_TRUE(ModuleNamespace::PreventExtensions());
|
||||
JSHandle<JSTaggedValue> moduleNamespaceTag = JSHandle<JSTaggedValue>::Cast(np);
|
||||
Local<JSValueRef> moduleNamespace = JSNApiHelper::ToLocal<ModuleNamespace>(moduleNamespaceTag);
|
||||
ASSERT_TRUE(moduleNamespace->IsModuleNamespaceObject());
|
||||
ASSERT_TRUE(moduleNamespace->IsModuleNamespaceObject(vm_));
|
||||
}
|
||||
} // namespace panda::test
|
@ -167,12 +167,12 @@ HWTEST_F_L0(JSNApiTests, NewSendableClassFunction)
|
||||
Local<FunctionRef> constructor = GetNewSendableClassFunction(vm_, FunctionRef::Null(vm_));
|
||||
|
||||
ASSERT_EQ("name", constructor->GetName(vm_)->ToString());
|
||||
ASSERT_TRUE(constructor->IsFunction());
|
||||
ASSERT_TRUE(constructor->IsFunction(vm_));
|
||||
JSHandle<JSTaggedValue> jsConstructor = JSNApiHelper::ToJSHandle(constructor);
|
||||
ASSERT_TRUE(jsConstructor->IsClassConstructor());
|
||||
|
||||
Local<JSValueRef> functionPrototype = constructor->GetFunctionPrototype(vm_);
|
||||
ASSERT_TRUE(functionPrototype->IsObject());
|
||||
ASSERT_TRUE(functionPrototype->IsObject(vm_));
|
||||
JSHandle<JSTaggedValue> jsPrototype = JSNApiHelper::ToJSHandle(functionPrototype);
|
||||
ASSERT_TRUE(jsPrototype->IsClassPrototype());
|
||||
|
||||
@ -446,7 +446,7 @@ HWTEST_F_L0(JSNApiTests, NewSendableClassFunctionFunction)
|
||||
vm_, FunctionCallback, nullptr, nullptr, StringRef::NewFromUtf8(vm_, "name"), infos, FunctionRef::Null(vm_));
|
||||
|
||||
Local<FunctionRef> staticValue = constructor->Get(vm_, staticKey);
|
||||
ASSERT_TRUE(staticValue->IsFunction());
|
||||
ASSERT_TRUE(staticValue->IsFunction(vm_));
|
||||
Local<JSValueRef> res = staticValue->Call(vm_, JSValueRef::Undefined(vm_), nullptr, 0);
|
||||
ASSERT_EQ("funcResult", res->ToString(vm_)->ToString());
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ void CheckReject(JsiRuntimeCallInfo *info)
|
||||
{
|
||||
ASSERT_EQ(info->GetArgsNumber(), 1U);
|
||||
Local<JSValueRef> reason = info->GetCallArgRef(0);
|
||||
ASSERT_TRUE(reason->IsString());
|
||||
ASSERT_TRUE(reason->IsString(info->GetVM()));
|
||||
ASSERT_EQ(Local<StringRef>(reason)->ToString(), "Reject");
|
||||
}
|
||||
|
||||
@ -206,7 +206,7 @@ HWTEST_F_L0(JSNApiTests, JSValueRef_IsGeneratorObject)
|
||||
genObjHandleVal->SetGeneratorContext(thread_, generatorContextVal.GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> genObjTagHandleVal = JSHandle<JSTaggedValue>::Cast(genObjHandleVal);
|
||||
Local<JSValueRef> genObjectRef = JSNApiHelper::ToLocal<GeneratorObjectRef>(genObjTagHandleVal);
|
||||
ASSERT_TRUE(genObjectRef->IsGeneratorObject());
|
||||
ASSERT_TRUE(genObjectRef->IsGeneratorObject(vm_));
|
||||
}
|
||||
|
||||
static JSFunction *JSObjectTestCreate(JSThread *thread)
|
||||
@ -247,7 +247,7 @@ HWTEST_F_L0(JSNApiTests, JSValueRef_IsProxy)
|
||||
JSProxy::GetOwnProperty(thread_, proxyHandle, key, desc);
|
||||
EXPECT_EQ(desc.GetValue()->GetInt(), 1);
|
||||
Local<JSValueRef> proxy = JSNApiHelper::ToLocal<JSProxy>(JSHandle<JSTaggedValue>(proxyHandle));
|
||||
ASSERT_TRUE(proxy->IsProxy());
|
||||
ASSERT_TRUE(proxy->IsProxy(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -264,7 +264,7 @@ HWTEST_F_L0(JSNApiTests, BufferRef_New_ByteLength)
|
||||
LocalScope scope(vm_);
|
||||
int32_t length = 10;
|
||||
Local<BufferRef> buffer = BufferRef::New(vm_, length);
|
||||
ASSERT_TRUE(buffer->IsBuffer());
|
||||
ASSERT_TRUE(buffer->IsBuffer(vm_));
|
||||
EXPECT_EQ(buffer->ByteLength(vm_), length);
|
||||
}
|
||||
|
||||
@ -283,9 +283,9 @@ HWTEST_F_L0(JSNApiTests, BufferRef_New_ByteLength_GetBuffer)
|
||||
LocalScope scope(vm_);
|
||||
int32_t length = 10;
|
||||
Local<BufferRef> buffer = BufferRef::New(vm_, length);
|
||||
ASSERT_TRUE(buffer->IsBuffer());
|
||||
ASSERT_TRUE(buffer->IsBuffer(vm_));
|
||||
EXPECT_EQ(buffer->ByteLength(vm_), 10U);
|
||||
ASSERT_NE(buffer->GetBuffer(), nullptr);
|
||||
ASSERT_NE(buffer->GetBuffer(vm_), nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -315,11 +315,11 @@ HWTEST_F_L0(JSNApiTests, BufferRef_New01_ByteLength_GetBuffer_BufferToStringCall
|
||||
Data *data = new Data();
|
||||
data->length = length;
|
||||
Local<BufferRef> bufferRef = BufferRef::New(vm_, buffer, length, deleter, data);
|
||||
ASSERT_TRUE(bufferRef->IsBuffer());
|
||||
ASSERT_TRUE(bufferRef->IsBuffer());
|
||||
ASSERT_TRUE(bufferRef->IsBuffer(vm_));
|
||||
ASSERT_TRUE(bufferRef->IsBuffer(vm_));
|
||||
EXPECT_EQ(bufferRef->ByteLength(vm_), 15U);
|
||||
Local<StringRef> bufferStr = bufferRef->ToString(vm_);
|
||||
ASSERT_TRUE(bufferStr->IsString());
|
||||
ASSERT_TRUE(bufferStr->IsString(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -489,7 +489,7 @@ HWTEST_F_L0(JSNApiTests, IsDetach)
|
||||
LocalScope scope(vm_);
|
||||
const int32_t length = 33;
|
||||
Local<ArrayBufferRef> arraybuffer = ArrayBufferRef::New(vm_, length);
|
||||
ASSERT_FALSE(arraybuffer->IsDetach());
|
||||
ASSERT_FALSE(arraybuffer->IsDetach(vm_));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -519,9 +519,9 @@ HWTEST_F_L0(JSNApiTests, New1)
|
||||
LocalScope scope(vm_);
|
||||
const int32_t length = 33;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, length);
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer());
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer(vm_));
|
||||
ASSERT_EQ(arrayBuffer->ByteLength(vm_), length);
|
||||
ASSERT_NE(arrayBuffer->GetBuffer(), nullptr);
|
||||
ASSERT_NE(arrayBuffer->GetBuffer(vm_), nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -551,9 +551,9 @@ HWTEST_F_L0(JSNApiTests, New2)
|
||||
LocalScope scope(vm_);
|
||||
uint8_t *buffer = new uint8_t[length]();
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm_, buffer, length, deleter, data);
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer());
|
||||
ASSERT_TRUE(arrayBuffer->IsArrayBuffer(vm_));
|
||||
ASSERT_EQ(arrayBuffer->ByteLength(vm_), length);
|
||||
ASSERT_EQ(arrayBuffer->GetBuffer(), buffer);
|
||||
ASSERT_EQ(arrayBuffer->GetBuffer(vm_), buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -584,7 +584,7 @@ HWTEST_F_L0(JSNApiTests, GetBuffer)
|
||||
LocalScope scope(vm_);
|
||||
const int32_t length = 33;
|
||||
Local<ArrayBufferRef> arraybuffer = ArrayBufferRef::New(vm_, length);
|
||||
ASSERT_NE(arraybuffer->GetBuffer(), nullptr);
|
||||
ASSERT_NE(arraybuffer->GetBuffer(vm_), nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -603,10 +603,10 @@ HWTEST_F_L0(JSNApiTests, Is32Arraytest)
|
||||
char16_t utf16[] = u"This is a char16 array";
|
||||
int size = sizeof(utf16);
|
||||
Local<StringRef> obj = StringRef::NewFromUtf16(vm_, utf16, size);
|
||||
ASSERT_FALSE(obj->IsInt32Array());
|
||||
ASSERT_FALSE(obj->IsUint32Array());
|
||||
ASSERT_FALSE(obj->IsFloat32Array());
|
||||
ASSERT_FALSE(obj->IsFloat64Array());
|
||||
ASSERT_FALSE(obj->IsInt32Array(vm_));
|
||||
ASSERT_FALSE(obj->IsUint32Array(vm_));
|
||||
ASSERT_FALSE(obj->IsFloat32Array(vm_));
|
||||
ASSERT_FALSE(obj->IsFloat64Array(vm_));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -806,7 +806,7 @@ HWTEST_F_L0(JSNApiTests, GetNapiWrapperString)
|
||||
{
|
||||
LocalScope scope(vm_);
|
||||
Local<StringRef> result = StringRef::GetNapiWrapperString(vm_);
|
||||
ASSERT_TRUE(result->IsString());
|
||||
ASSERT_TRUE(result->IsString(vm_));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -844,7 +844,7 @@ HWTEST_F_L0(JSNApiTests, WeakMapRef_GetSize_GetTotalElements_GetKey_GetValue)
|
||||
JSHandle<JSTaggedValue> weakMapTag = JSHandle<JSTaggedValue>::Cast(weakMap);
|
||||
|
||||
Local<WeakMapRef> map = JSNApiHelper::ToLocal<WeakMapRef>(weakMapTag);
|
||||
EXPECT_TRUE(map->IsWeakMap());
|
||||
EXPECT_TRUE(map->IsWeakMap(vm_));
|
||||
JSHandle<JSTaggedValue> value(factory->NewFromASCII("value"));
|
||||
JSHandle<JSTaggedValue> key(factory->NewFromASCII("key"));
|
||||
JSWeakMap::Set(thread, weakMap, key, value);
|
||||
@ -872,9 +872,9 @@ HWTEST_F_L0(JSNApiTests, IsAGJA)
|
||||
char16_t utf16[] = u"This is a char16 array";
|
||||
int size = sizeof(utf16);
|
||||
Local<StringRef> obj = StringRef::NewFromUtf16(vm_, utf16, size);
|
||||
ASSERT_FALSE(obj->IsArgumentsObject());
|
||||
ASSERT_FALSE(obj->IsGeneratorFunction());
|
||||
ASSERT_FALSE(obj->IsAsyncFunction());
|
||||
ASSERT_FALSE(obj->IsArgumentsObject(vm_));
|
||||
ASSERT_FALSE(obj->IsGeneratorFunction(vm_));
|
||||
ASSERT_FALSE(obj->IsAsyncFunction(vm_));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -889,7 +889,7 @@ HWTEST_F_L0(JSNApiTests, HasCaught)
|
||||
LocalScope scope(vm_);
|
||||
Local<StringRef> message = StringRef::NewFromUtf8(vm_, "ErrorTest");
|
||||
Local<JSValueRef> error = Exception::Error(vm_, message);
|
||||
ASSERT_TRUE(error->IsError());
|
||||
ASSERT_TRUE(error->IsError(vm_));
|
||||
JSNApi::ThrowException(vm_, error);
|
||||
TryCatch tryCatch(vm_);
|
||||
ASSERT_TRUE(tryCatch.HasCaught());
|
||||
@ -924,7 +924,7 @@ HWTEST_F_L0(JSNApiTests, GetAndClearException)
|
||||
LocalScope scope(vm_);
|
||||
Local<StringRef> message = StringRef::NewFromUtf8(vm_, "ErrorTest");
|
||||
Local<JSValueRef> error = Exception::Error(vm_, message);
|
||||
ASSERT_TRUE(error->IsError());
|
||||
ASSERT_TRUE(error->IsError(vm_));
|
||||
JSNApi::ThrowException(vm_, error);
|
||||
ASSERT_TRUE(vm_->GetJSThread()->HasPendingException());
|
||||
TryCatch tryCatch(vm_);
|
||||
|
@ -45,10 +45,10 @@ void ArrayBufferRef_New_IsDetach_Detach_ByteLength_GetBuffer_FuzzTest(const uint
|
||||
}
|
||||
NativePointerCallback deleter = nullptr;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
||||
arrayBuffer->IsDetach();
|
||||
arrayBuffer->IsDetach(vm);
|
||||
arrayBuffer->Detach(vm);
|
||||
arrayBuffer->ByteLength(vm);
|
||||
arrayBuffer->GetBuffer();
|
||||
arrayBuffer->GetBuffer(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ void ArrayBufferRef_New_IsDetach_Detach_ByteLength_GetBuffer_FuzzTest(const uint
|
||||
UNREACHABLE();
|
||||
}
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, input);
|
||||
arrayBuffer->IsDetach();
|
||||
arrayBuffer->IsDetach(vm);
|
||||
arrayBuffer->Detach(vm);
|
||||
arrayBuffer->ByteLength(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
|
@ -72,7 +72,7 @@ void BufferRefGetBufferFuzzTest([[maybe_unused]]const uint8_t *data, size_t size
|
||||
return;
|
||||
}
|
||||
Local<BufferRef> buffer = BufferRef::New(vm, (int32_t)size);
|
||||
buffer->GetBuffer();
|
||||
buffer->GetBuffer(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ namespace OHOS {
|
||||
}
|
||||
Local<ArrayBufferRef> ref = ArrayBufferRef::New(vm, input);
|
||||
Local<Float32ArrayRef> float32ArrayRef = Float32ArrayRef::New(vm, ref, (int32_t)size, (int32_t)size);
|
||||
float32ArrayRef->IsFloat32Array();
|
||||
float32ArrayRef->IsFloat32Array(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ namespace OHOS {
|
||||
}
|
||||
Local<ArrayBufferRef> ref = ArrayBufferRef::New(vm, input);
|
||||
Local<Float64ArrayRef> float64ArrayRef = Float64ArrayRef::New(vm, ref, (int32_t)size, (int32_t)size);
|
||||
float64ArrayRef->IsFloat64Array();
|
||||
float64ArrayRef->IsFloat64Array(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ void IsGeneratorFuzztest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
}
|
||||
Local<GeneratorObjectRef> genObjectRef = CreateGeneratorObj(vm);
|
||||
Local<GeneratorFunctionRef> object = genObjectRef->GetGeneratorFunction(vm);
|
||||
object->IsGenerator();
|
||||
object->IsGenerator(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ namespace OHOS {
|
||||
}
|
||||
Local<ArrayBufferRef> ref = ArrayBufferRef::New(vm, input);
|
||||
Local<Int32ArrayRef> int32ArrayRef = Int32ArrayRef::New(vm, ref, (int32_t)size, (int32_t)size);
|
||||
int32ArrayRef->IsInt32Array();
|
||||
int32ArrayRef->IsInt32Array(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ void JSNApiIsArrayIterator_FuzzTest([[maybe_unused]]const uint8_t *data, size_t
|
||||
return;
|
||||
}
|
||||
Local<ArrayBufferRef> arraybuffer = ArrayBufferRef::New(vm_, (int32_t)size);
|
||||
arraybuffer->IsArrayIterator();
|
||||
arraybuffer->IsArrayIterator(vm_);
|
||||
JSNApi::DestroyJSVM(vm_);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ void JSNApiIsConstructorFuzzTest([[maybe_unused]]const uint8_t *data, size_t siz
|
||||
return;
|
||||
}
|
||||
Local<IntegerRef> intValue = IntegerRef::New(vm_, (int)size);
|
||||
intValue->IsConstructor();
|
||||
intValue->IsConstructor(vm_);
|
||||
JSNApi::DestroyJSVM(vm_);
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ void JSNApiIsStringIterator_FuzzTest(const uint8_t *data, size_t size)
|
||||
LOG_ECMA(ERROR) << "memcpy_s failed!";
|
||||
}
|
||||
Local<StringRef> origin = StringRef::NewFromUtf8(vm_, value, (int)size);
|
||||
origin->IsStringIterator();
|
||||
origin->IsStringIterator(vm_);
|
||||
JSNApi::DestroyJSVM(vm_);
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ void JSValueRefIsStringValueFuzzTest(const uint8_t *data, size_t size)
|
||||
return;
|
||||
}
|
||||
Local<JSValueRef> tag = StringRef::NewFromUtf8(vm, (char *)data, (int)size);
|
||||
tag->IsString();
|
||||
tag->IsString(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ void JSValueRefIsFunctionValueFuzzTest(const uint8_t *data, size_t size)
|
||||
NativePointerCallback deleter = nullptr;
|
||||
FunctionCallback nativeFunc = FunCallback;
|
||||
Local<FunctionRef> obj(FunctionRef::NewClassFunction(vm, nativeFunc, deleter, (void *)(data + size)));
|
||||
(void)obj->IsFunction();
|
||||
(void)obj->IsFunction(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ void JSValueRefIsTypedArrayValueFuzzTest(const uint8_t *data, size_t size)
|
||||
UNREACHABLE();
|
||||
}
|
||||
Local<JSValueRef> targetUInt = IntegerRef::New(vm, number);
|
||||
targetUInt->IsTypedArray();
|
||||
targetUInt->IsTypedArray(vm);
|
||||
int32_t input;
|
||||
if (memcpy_s(&input, MAXBYTELEN, data, size) != 0) {
|
||||
std::cout << "memcpy_s failed!";
|
||||
@ -148,9 +148,9 @@ void JSValueRefIsTypedArrayValueFuzzTest(const uint8_t *data, size_t size)
|
||||
input = MaxMenory;
|
||||
}
|
||||
Local<ArrayBufferRef> ref = ArrayBufferRef::New(vm, input);
|
||||
ref->IsArrayBuffer();
|
||||
ref->IsArrayBuffer(vm);
|
||||
Local<Uint32ArrayRef> typedArray = Uint32ArrayRef::New(vm, ref, (int32_t)size, (int32_t)size);
|
||||
typedArray->IsTypedArray();
|
||||
typedArray->IsTypedArray(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -190,10 +190,10 @@ void JSValueRefIsDateValueFuzzTest(const uint8_t *data, size_t size)
|
||||
UNREACHABLE();
|
||||
}
|
||||
Local<DateRef> dateRef = DateRef::New(vm, timeRef);
|
||||
resUnit32->IsDate();
|
||||
intValue->IsDate();
|
||||
stringUtf8->IsDate();
|
||||
dateRef->IsDate();
|
||||
resUnit32->IsDate(vm);
|
||||
intValue->IsDate(vm);
|
||||
stringUtf8->IsDate(vm);
|
||||
dateRef->IsDate(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -223,10 +223,10 @@ void JSValueRefIsErrorValueFuzzTest(const uint8_t *data, size_t size)
|
||||
Local<NumberRef> resUnit32 = NumberRef::New(vm, inputUnit32);
|
||||
Local<StringRef> stringUtf8 = StringRef::NewFromUtf8(vm, (char *)data, (int)size);
|
||||
Local<JSValueRef> error = Exception::Error(vm, stringUtf8);
|
||||
resUnit32->IsError();
|
||||
intValue->IsError();
|
||||
stringUtf8->IsError();
|
||||
error->IsError();
|
||||
resUnit32->IsError(vm);
|
||||
intValue->IsError(vm);
|
||||
stringUtf8->IsError(vm);
|
||||
error->IsError(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ void IsInt8ArrayFuzztest(const uint8_t *data, size_t size)
|
||||
NativePointerCallback deleter = nullptr;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
||||
Local<JSValueRef> typedArray = Int8ArrayRef::New(vm, arrayBuffer, 0, (int32_t)size);
|
||||
typedArray->IsInt8Array();
|
||||
typedArray->IsInt8Array(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ void IsUint8ArrayFuzztest(const uint8_t *data, size_t size)
|
||||
NativePointerCallback deleter = nullptr;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
||||
Local<JSValueRef> typedArray = Uint8ArrayRef::New(vm, arrayBuffer, 0, (int32_t)size);
|
||||
typedArray->IsUint8Array();
|
||||
typedArray->IsUint8Array(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ void IsUint8ClampedArrayFuzztest(const uint8_t *data, size_t size)
|
||||
NativePointerCallback deleter = nullptr;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
||||
Local<JSValueRef> typedArray = Uint8ClampedArrayRef::New(vm, arrayBuffer, 0, (int32_t)size);
|
||||
typedArray->IsUint8ClampedArray();
|
||||
typedArray->IsUint8ClampedArray(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ void IsInt16ArrayFuzztest(const uint8_t *data, size_t size)
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
||||
int32_t length = size / sizeof(int16_t);
|
||||
Local<JSValueRef> typedArray = Int16ArrayRef::New(vm, arrayBuffer, 0, length);
|
||||
typedArray->IsInt16Array();
|
||||
typedArray->IsInt16Array(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ void IsUint16ArrayFuzztest(const uint8_t *data, size_t size)
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (void *)data, (int32_t)size, deleter, (void *)data);
|
||||
int32_t length = size / sizeof(uint16_t);
|
||||
Local<JSValueRef> typedArray = Uint16ArrayRef::New(vm, arrayBuffer, 0, length);
|
||||
typedArray->IsUint16Array();
|
||||
typedArray->IsUint16Array(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ void JSValueRefIsArrayBufferFuzzerTest([[maybe_unused]]const uint8_t *data, size
|
||||
return;
|
||||
}
|
||||
Local<ArrayBufferRef> arrayBufferRef = ArrayBufferRef::New(vm, (int32_t)size);
|
||||
arrayBufferRef->IsArrayBuffer();
|
||||
arrayBufferRef->IsArrayBuffer(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ namespace OHOS {
|
||||
JSHandle<JSFunction> asyncGeneratorFunction = factory->NewJSAsyncGeneratorFunction(method);
|
||||
JSHandle<JSTaggedValue> asyncgefu = JSHandle<JSTaggedValue>::Cast(asyncGeneratorFunction);
|
||||
Local<JSValueRef> object = JSNApiHelper::ToLocal<JSValueRef>(asyncgefu);
|
||||
[[maybe_unused]] auto it = object->IsAsyncGeneratorFunction();
|
||||
[[maybe_unused]] auto it = object->IsAsyncGeneratorFunction(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ namespace OHOS {
|
||||
ptr = const_cast<uint8_t*>(data);
|
||||
int num = static_cast<int>(size);
|
||||
Local<JSValueRef> object = IntegerRef::New(vm, num);
|
||||
object->IsAsyncGeneratorFunction();
|
||||
object->IsAsyncGeneratorFunction(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ namespace OHOS {
|
||||
JSHandle<JSFunction> asyncGeneratorFunction = factory->NewJSAsyncGeneratorFunction(method);
|
||||
JSHandle<JSTaggedValue> asyncgefu = JSHandle<JSTaggedValue>::Cast(asyncGeneratorFunction);
|
||||
Local<JSValueRef> object = JSNApiHelper::ToLocal<JSValueRef>(asyncgefu);
|
||||
[[maybe_unused]] auto it = object->IsAsyncGeneratorObject();
|
||||
[[maybe_unused]] auto it = object->IsAsyncGeneratorObject(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ namespace OHOS {
|
||||
ptr = const_cast<uint8_t*>(data);
|
||||
int num = static_cast<int>(size);
|
||||
Local<JSValueRef> object = IntegerRef::New(vm, num);
|
||||
object->IsAsyncGeneratorObject();
|
||||
object->IsAsyncGeneratorObject(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ void JSValueRefIsBigInt64ArrayFuzzTest(const uint8_t *data, size_t size)
|
||||
}
|
||||
Local<ArrayBufferRef> ref = ArrayBufferRef::New(vm, input);
|
||||
Local<BigInt64ArrayRef> typedArray = BigInt64ArrayRef::New(vm, ref, (int32_t)size, (int32_t)size);
|
||||
typedArray->IsBigInt64Array();
|
||||
typedArray->IsBigInt64Array(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ void JSValueRefIsBigUint64ArrayRefNewFuzzTest(const uint8_t *data, size_t size)
|
||||
}
|
||||
Local<ArrayBufferRef> ref = ArrayBufferRef::New(vm, input);
|
||||
Local<BigUint64ArrayRef> typedArray = BigUint64ArrayRef::New(vm, ref, (int32_t)size, (int32_t)size);
|
||||
typedArray->IsBigUint64Array();
|
||||
typedArray->IsBigUint64Array(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ void JSValueRefIsBufferFuzzerTest([[maybe_unused]]const uint8_t *data, size_t si
|
||||
return;
|
||||
}
|
||||
Local<BufferRef> bufferRef = BufferRef::New(vm, (int32_t)size);
|
||||
bufferRef->IsBuffer();
|
||||
bufferRef->IsBuffer(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ void JSValueRefIsVectorFuzzTest([[maybe_unused]]const uint8_t *data, size_t size
|
||||
jsVector->SetLength(0);
|
||||
JSHandle<JSTaggedValue> argumentTag = JSHandle<JSTaggedValue>::Cast(jsVector);
|
||||
Local<JSValueRef> isVector = JSNApiHelper::ToLocal<JSAPIVector>(argumentTag);
|
||||
isVector->IsVector();
|
||||
isVector->IsVector(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
return;
|
||||
}
|
||||
@ -64,7 +64,7 @@ void JSValueRefIsMapFuzzTest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
return;
|
||||
}
|
||||
Local<MapRef> map = MapRef::New(vm);
|
||||
map->IsMap();
|
||||
map->IsMap(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
return;
|
||||
}
|
||||
@ -90,7 +90,7 @@ void JSValueRefIsRegExpFuzzTest([[maybe_unused]]const uint8_t *data, size_t size
|
||||
jSRegExp->SetLength(0);
|
||||
JSHandle<JSTaggedValue> argumentTag = JSHandle<JSTaggedValue>::Cast(jSRegExp);
|
||||
Local<JSValueRef> regexp = JSNApiHelper::ToLocal<JSRegExp>(argumentTag);
|
||||
regexp->IsRegExp();
|
||||
regexp->IsRegExp(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
return;
|
||||
}
|
||||
@ -113,7 +113,7 @@ void JSValueRefIsSetFuzzTest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
set->SetLinkedSet(thread, hashSet);
|
||||
JSHandle<JSTaggedValue> setTag = JSHandle<JSTaggedValue>::Cast(set);
|
||||
Local<SetRef> isSet = JSNApiHelper::ToLocal<SetRef>(setTag);
|
||||
isSet->IsSet();
|
||||
isSet->IsSet(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
return;
|
||||
}
|
||||
@ -136,7 +136,7 @@ void JSValueRefIsTreeMapFuzzTest([[maybe_unused]]const uint8_t *data, size_t siz
|
||||
jsTreeMap->SetTreeMap(thread, treeMap);
|
||||
JSHandle<JSTaggedValue> argumentTag = JSHandle<JSTaggedValue>::Cast(jsTreeMap);
|
||||
Local<JSValueRef> isTreeMap = JSNApiHelper::ToLocal<JSAPITreeMap>(argumentTag);
|
||||
isTreeMap->IsTreeMap();
|
||||
isTreeMap->IsTreeMap(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ void JSValueRefIsTreeSetFuzzTest([[maybe_unused]]const uint8_t *data, size_t siz
|
||||
jsTreeSet->SetTreeSet(thread, treeSet);
|
||||
JSHandle<JSTaggedValue> argumentTag = JSHandle<JSTaggedValue>::Cast(jsTreeSet);
|
||||
Local<JSValueRef> isTreeSet = JSNApiHelper::ToLocal<JSAPITreeSet>(argumentTag);
|
||||
isTreeSet->IsTreeSet();
|
||||
isTreeSet->IsTreeSet(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ void JSValueRefIsDataViewFuzzerTest([[maybe_unused]]const uint8_t *data, size_t
|
||||
}
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (int32_t)size);
|
||||
Local<DataViewRef> dataView = DataViewRef::New(vm, arrayBuffer, 0, (int32_t)size - 1);
|
||||
dataView->IsDataView();
|
||||
dataView->IsDataView(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ void IsGeneratorObjectFuzzTest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
JSFunction::InitializeJSFunction(vm->GetJSThread(), generatorFunc, FunctionKind::GENERATOR_FUNCTION);
|
||||
JSHandle<JSTaggedValue> genObjTagHandleVal = JSHandle<JSTaggedValue>::Cast(genObjHandleVal);
|
||||
Local<JSValueRef> genObjectRef = JSNApiHelper::ToLocal<GeneratorObjectRef>(genObjTagHandleVal);
|
||||
genObjectRef->IsGeneratorObject();
|
||||
genObjectRef->IsGeneratorObject(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ void JSValueRefIsHashMapFuzzTest([[maybe_unused]] const uint8_t *data, size_t si
|
||||
JSHandle<JSAPIHashMap> map = ConstructobjectHashMap(thread);
|
||||
JSHandle<JSTaggedValue> jshashmap = JSHandle<JSTaggedValue>::Cast(map);
|
||||
Local<JSValueRef> tag = JSNApiHelper::ToLocal<JSValueRef>(jshashmap);
|
||||
tag->IsHashMap();
|
||||
tag->IsHashMap(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ void JSValueRefIsHashSetFuzzTest([[maybe_unused]] const uint8_t *data, size_t si
|
||||
JSHandle<JSAPIHashSet> setHandle = ConstructobjectHashSet(thread);
|
||||
JSHandle<JSTaggedValue> jshashmap = JSHandle<JSTaggedValue>::Cast(setHandle);
|
||||
Local<JSValueRef> tag = JSNApiHelper::ToLocal<JSValueRef>(jshashmap);
|
||||
tag->IsHashSet();
|
||||
tag->IsHashSet(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ void JSValueRefIsJSPrimitiveNumberFuzzTest([[maybe_unused]]const uint8_t *data,
|
||||
JSHandle<JSPrimitiveRef> jsprimitive = factory->NewJSPrimitiveRef(PrimitiveType::PRIMITIVE_NUMBER, jstagvalue);
|
||||
JSHandle<JSTaggedValue> jspri = JSHandle<JSTaggedValue>::Cast(jsprimitive);
|
||||
Local<JSValueRef> object = JSNApiHelper::ToLocal<JSValueRef>(jspri);
|
||||
object->IsJSPrimitiveNumber();
|
||||
object->IsJSPrimitiveNumber(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
return;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ void IsJSPrimitiveSymbolFuzztest([[maybe_unused]]const uint8_t *data, size_t siz
|
||||
JSHandle<JSPrimitiveRef> jsPrimitive = factory->NewJSPrimitiveRef(PrimitiveType::PRIMITIVE_SYMBOL, jsTagValue);
|
||||
JSHandle<JSTaggedValue> jsTagPrimitive = JSHandle<JSTaggedValue>::Cast(jsPrimitive);
|
||||
Local<JSValueRef> object = JSNApiHelper::ToLocal<JSValueRef>(jsTagPrimitive);
|
||||
object->IsJSPrimitiveSymbol();
|
||||
object->IsJSPrimitiveSymbol(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ void IsJSPrimitiveStringFuzztest([[maybe_unused]]const uint8_t *data, size_t siz
|
||||
JSHandle<JSPrimitiveRef> jsPrimitive = factory->NewJSPrimitiveRef(PrimitiveType::PRIMITIVE_SYMBOL, jsTagValue);
|
||||
JSHandle<JSTaggedValue> jsTagPrimitive = JSHandle<JSTaggedValue>::Cast(jsPrimitive);
|
||||
Local<JSValueRef> object = JSNApiHelper::ToLocal<JSValueRef>(jsTagPrimitive);
|
||||
object->IsJSPrimitiveString();
|
||||
object->IsJSPrimitiveString(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ void IsJSPrimitiveIntFuzztest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
JSHandle<JSPrimitiveRef> jsPrimitive = factory->NewJSPrimitiveRef(PrimitiveType::PRIMITIVE_BIGINT, jsTagValue);
|
||||
JSHandle<JSTaggedValue> jsTagPrimitive = JSHandle<JSTaggedValue>::Cast(jsPrimitive);
|
||||
Local<JSValueRef> object = JSNApiHelper::ToLocal<JSValueRef>(jsTagPrimitive);
|
||||
object->IsJSPrimitiveInt();
|
||||
object->IsJSPrimitiveInt(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ void JSValueRefIsLightWeightMapFuzzTest([[maybe_unused]] const uint8_t *data, si
|
||||
JSHandle<JSAPILightWeightMap> mapHandle = ConstructobjectLightWeightMap(thread);
|
||||
JSHandle<JSTaggedValue> jshashmap = JSHandle<JSTaggedValue>::Cast(mapHandle);
|
||||
Local<JSValueRef> tag = JSNApiHelper::ToLocal<JSValueRef>(jshashmap);
|
||||
tag->IsLightWeightMap();
|
||||
tag->IsLightWeightMap(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ void JSValueRefIsLightWeightSetFuzzTest([[maybe_unused]] const uint8_t *data, si
|
||||
JSHandle<JSAPILightWeightSet> mapHandle = ConstructobjectLightWeightSet(thread);
|
||||
JSHandle<JSTaggedValue> jshashmap = JSHandle<JSTaggedValue>::Cast(mapHandle);
|
||||
Local<JSValueRef> tag = JSNApiHelper::ToLocal<JSValueRef>(jshashmap);
|
||||
tag->IsLightWeightSet();
|
||||
tag->IsLightWeightSet(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ void JSValueRefIsLinkedListFuzzTest([[maybe_unused]] const uint8_t *data, size_t
|
||||
linkedList->SetDoubleList(thread, doubleList);
|
||||
JSHandle<JSTaggedValue> linkedlisttag = JSHandle<JSTaggedValue>::Cast(linkedList);
|
||||
Local<JSValueRef> object = JSNApiHelper::ToLocal<JSValueRef>(linkedlisttag);
|
||||
object->IsLinkedList();
|
||||
object->IsLinkedList(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ void JSValueRefIsLinkedListIteratorFuzzTest([[maybe_unused]] const uint8_t *data
|
||||
JSAPILinkedListIterator::CreateLinkedListIterator(thread, taggedValueHandle).GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> linkedListIteratortag = JSHandle<JSTaggedValue>::Cast(linkedListIterator);
|
||||
Local<JSValueRef> object = JSNApiHelper::ToLocal<JSValueRef>(linkedListIteratortag);
|
||||
object->IsLinkedListIterator();
|
||||
object->IsLinkedListIterator(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ void JSValueRefIsListFuzzTest([[maybe_unused]] const uint8_t *data, size_t size)
|
||||
list->SetSingleList(thread, singleList);
|
||||
JSHandle<JSTaggedValue> Listtag = JSHandle<JSTaggedValue>::Cast(list);
|
||||
Local<JSValueRef> object = JSNApiHelper::ToLocal<JSValueRef>(Listtag);
|
||||
object->IsList();
|
||||
object->IsList(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ void IsModuleNamespaceObjectFuzztest([[maybe_unused]]const uint8_t *data, size_t
|
||||
ModuleNamespace::PreventExtensions();
|
||||
JSHandle<JSTaggedValue> moduleNamespaceTag = JSHandle<JSTaggedValue>::Cast(np);
|
||||
Local<JSValueRef> moduleNamespace = JSNApiHelper::ToLocal<ModuleNamespace>(moduleNamespaceTag);
|
||||
moduleNamespace->IsModuleNamespaceObject();
|
||||
moduleNamespace->IsModuleNamespaceObject(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ void IsProxyFuzztest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle<JSFunction>::Cast(hclass), hclass));
|
||||
JSHandle<JSProxy> proxyHandle = JSProxy::ProxyCreate(thread, targetHandle, handlerHandle);
|
||||
Local<JSValueRef> proxy = JSNApiHelper::ToLocal<JSProxy>(JSHandle<JSTaggedValue>(proxyHandle));
|
||||
proxy->IsProxy();
|
||||
proxy->IsProxy(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ void IsJSCollatorFuzztest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
|
||||
JSHandle<JSTaggedValue> collatorTagHandleVal = JSHandle<JSTaggedValue>::Cast(initCollator);
|
||||
Local<JSValueRef> object = JSNApiHelper::ToLocal<JSValueRef>(collatorTagHandleVal);
|
||||
object->IsJSCollator();
|
||||
object->IsJSCollator(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ void IsJSPluralRulesFuzztest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
JSPluralRules::InitializePluralRules(thread, pluralRules, localeStr, optionHandle);
|
||||
JSHandle<JSTaggedValue> tagPlureRules = JSHandle<JSTaggedValue>::Cast(initPluralRules);
|
||||
Local<JSValueRef> object = JSNApiHelper::ToLocal<JSValueRef>(tagPlureRules);
|
||||
object->IsJSPluralRules();
|
||||
object->IsJSPluralRules(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ void IsJSListFormatFuzztest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
return;
|
||||
}
|
||||
Local<JSValueRef> object = ObjectRef::New(vm);
|
||||
object->IsJSListFormat();
|
||||
object->IsJSListFormat(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ void IsJSPrimitiveRefFuzztest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
TaggedObject *taggedObject = factory->NewObject(jsClassHandle);
|
||||
JSHandle<JSTaggedValue> jsTaggedValue(thread, JSTaggedValue(taggedObject));
|
||||
Local<JSValueRef> jsValueRef = JSNApiHelper::ToLocal<JSPrimitiveRef>(jsTaggedValue);
|
||||
jsValueRef->IsJSPrimitiveRef();
|
||||
jsValueRef->IsJSPrimitiveRef(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ void IsDequeFuzztest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
jsQueue->SetElements(thread, newElements);
|
||||
JSHandle<JSTaggedValue> Que = JSHandle<JSTaggedValue>::Cast(jsQueue);
|
||||
Local<JSValueRef> jsValueRef = JSNApiHelper::ToLocal<ArrayRef>(Que);
|
||||
jsValueRef->IsDeque();
|
||||
jsValueRef->IsDeque(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@ void IsJSIntlFuzztest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
return;
|
||||
}
|
||||
Local<JSValueRef> jsInt1 = CreateJSValueRef(vm, JSType::JS_INTL);
|
||||
jsInt1->IsJSIntl();
|
||||
jsInt1->IsJSIntl(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -243,7 +243,7 @@ void IsJSDateTimeFormatFuzztest([[maybe_unused]]const uint8_t *data, size_t size
|
||||
return;
|
||||
}
|
||||
Local<JSValueRef> dateTime = CreateJSValueRef(vm, JSType::JS_DATE_TIME_FORMAT);
|
||||
dateTime->IsJSDateTimeFormat();
|
||||
dateTime->IsJSDateTimeFormat(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -257,7 +257,7 @@ void IsJSNumberFormatFuzztest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
return;
|
||||
}
|
||||
Local<JSValueRef> number = CreateJSValueRef(vm, JSType::JS_NUMBER_FORMAT);
|
||||
number->IsJSNumberFormat();
|
||||
number->IsJSNumberFormat(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -271,7 +271,7 @@ void IsJSRelativeTimeFormatFuzztest([[maybe_unused]]const uint8_t *data, size_t
|
||||
return;
|
||||
}
|
||||
Local<JSValueRef> relative = CreateJSValueRef(vm, JSType::JS_RELATIVE_TIME_FORMAT);
|
||||
relative->IsJSRelativeTimeFormat();
|
||||
relative->IsJSRelativeTimeFormat(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ void JSValueRefIsNativePointerValueFuzzTest(const uint8_t *data, size_t size)
|
||||
}
|
||||
NativePointerCallback callBack = nullptr;
|
||||
Local<NativePointerRef> res = NativePointerRef::New(vm, (void *)(data + size), callBack, (void *)data);
|
||||
res->IsNativePointer();
|
||||
res->IsNativePointer(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ void JSValueRefIsPlainArrayFuzzTest([[maybe_unused]] const uint8_t *data, size_t
|
||||
plainArray->SetValues(thread, valueArray);
|
||||
JSHandle<JSTaggedValue> plainarraytag = JSHandle<JSTaggedValue>::Cast(plainArray);
|
||||
Local<JSValueRef> object = JSNApiHelper::ToLocal<JSValueRef>(plainarraytag);
|
||||
object->IsPlainArray();
|
||||
object->IsPlainArray(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ void JSValueRefIsPromiseValueFuzzTest(const uint8_t *data, size_t size)
|
||||
NativePointerCallback deleter = nullptr;
|
||||
Local<FunctionRef> reject = FunctionRef::New(vm, nativeFunc, deleter, (void *)(data + size));
|
||||
Local<PromiseRef> catchPromise = promise->Catch(vm, reject);
|
||||
promise->IsPromise();
|
||||
catchPromise->IsPromise();
|
||||
promise->IsPromise(vm);
|
||||
catchPromise->IsPromise(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ void JSValueRefIsWeakMapFuzzerTest([[maybe_unused]]const uint8_t *data, size_t s
|
||||
return;
|
||||
}
|
||||
Local<JSValueRef> sharedArrayBuffer = ArrayBufferRef::New(vm_, (int32_t)size);
|
||||
sharedArrayBuffer->IsSharedArrayBuffer();
|
||||
sharedArrayBuffer->IsSharedArrayBuffer(vm_);
|
||||
JSNApi::DestroyJSVM(vm_);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ namespace OHOS {
|
||||
}
|
||||
Local<StringRef> description = StringRef::NewFromUtf8(vm, (char*)data, size);
|
||||
Local<SymbolRef> symbol = SymbolRef::New(vm, description);
|
||||
symbol->IsSymbol();
|
||||
symbol->IsSymbol(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ namespace OHOS {
|
||||
}
|
||||
constexpr int input = 2147483646;
|
||||
Local<IntegerRef> intValue = IntegerRef::New(vm, input);
|
||||
[[maybe_unused]]bool res = intValue->IsBigInt();
|
||||
[[maybe_unused]]bool res = intValue->IsBigInt(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ namespace OHOS {
|
||||
return;
|
||||
}
|
||||
Local<JSValueRef> res = IntegerRef::New(vm, (int)size);
|
||||
[[maybe_unused]]bool result = res->IsObject();
|
||||
[[maybe_unused]]bool result = res->IsObject(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ namespace OHOS {
|
||||
ObjectFactory *factory = vm->GetFactory();
|
||||
JSHandle<JSArguments> obj = factory->NewJSArguments();
|
||||
JSHandle<JSTaggedValue> argumentTag = JSHandle<JSTaggedValue>::Cast(obj);
|
||||
JSNApiHelper::ToLocal<ObjectRef>(argumentTag)->IsArgumentsObject();
|
||||
JSNApiHelper::ToLocal<ObjectRef>(argumentTag)->IsArgumentsObject(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ namespace OHOS {
|
||||
}
|
||||
int length = size / sizeof(char16_t);
|
||||
Local<StringRef> obj = StringRef::NewFromUtf16(vm, (char16_t*)data, length);
|
||||
obj->IsJSPrimitiveBoolean();
|
||||
obj->IsJSPrimitiveBoolean(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ namespace OHOS {
|
||||
}
|
||||
int length = size / sizeof(char16_t);
|
||||
Local<StringRef> obj = StringRef::NewFromUtf16(vm, (char16_t*)data, length);
|
||||
obj->IsGeneratorFunction();
|
||||
obj->IsGeneratorFunction(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ namespace OHOS {
|
||||
return;
|
||||
}
|
||||
Local<JSValueRef> object = IntegerRef::New(vm, (int)size);
|
||||
object->IsMapIterator();
|
||||
object->IsMapIterator(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ void ObjectRefGetGlobalObjectFuzzTest([[maybe_unused]] const uint8_t *data, size
|
||||
return;
|
||||
}
|
||||
Local<ObjectRef> globalObject = JSNApi::GetGlobalObject(vm);
|
||||
globalObject->IsObject();
|
||||
globalObject->IsObject(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ void LocalRegExpRefGetOriginalFlagsFuzzTest([[maybe_unused]]const uint8_t *data,
|
||||
jSRegExp->SetLength(0);
|
||||
JSHandle<JSTaggedValue> jsregtag = JSHandle<JSTaggedValue>::Cast(jSRegExp);
|
||||
Local<RegExpRef> object = JSNApiHelper::ToLocal<RegExpRef>(jsregtag);
|
||||
object->GetOriginalFlags();
|
||||
object->GetOriginalFlags(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ void SetIteratorRefGetFuzztest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
JSTaggedValue::SameValue(jsSetIterator1->GetIteratedSet(), jsSet->GetLinkedSet());
|
||||
Local<SetIteratorRef> setIterator = JSNApiHelper::ToLocal<SetIteratorRef>(jsTagSetIterator);
|
||||
Local<JSValueRef> setIterator1 = setIterator;
|
||||
setIterator1->IsSetIterator();
|
||||
setIterator1->IsSetIterator(vm);
|
||||
setIterator->GetIndex();
|
||||
setIterator->GetKind(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
|
@ -38,7 +38,7 @@ namespace OHOS {
|
||||
LOG_ECMA(ERROR) << "memcpy_s failed!";
|
||||
UNREACHABLE();
|
||||
}
|
||||
res->WriteLatin1(value, (int)size);
|
||||
res->WriteLatin1(vm, value, (int)size);
|
||||
delete[] value;
|
||||
value = nullptr;
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
|
@ -42,7 +42,7 @@ namespace OHOS {
|
||||
if (length == 1) {
|
||||
buffer[0] = '\0';
|
||||
} else if (length != 0) {
|
||||
int count = res->WriteUtf16(buffer, length - 1);
|
||||
int count = res->WriteUtf16(vm, buffer, length - 1);
|
||||
buffer[count] = '\0';
|
||||
}
|
||||
delete[] buffer;
|
||||
|
@ -39,7 +39,7 @@ namespace OHOS {
|
||||
std::cout << "memcpy_s failed!";
|
||||
UNREACHABLE();
|
||||
}
|
||||
res->WriteUtf8(value, (int)size);
|
||||
res->WriteUtf8(vm, value, (int)size);
|
||||
delete[] value;
|
||||
value = nullptr;
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
|
@ -46,7 +46,7 @@ namespace OHOS {
|
||||
}
|
||||
Local<ArrayBufferRef> ref = ArrayBufferRef::New(vm, input);
|
||||
Local<Uint32ArrayRef> uint32ArrayRef = Uint32ArrayRef::New(vm, ref, (int32_t)size, (int32_t)size);
|
||||
uint32ArrayRef->IsUint32Array();
|
||||
uint32ArrayRef->IsUint32Array(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user