mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-27 04:00:37 +00:00
!5217 add function getdata and setdata
Merge pull request !5217 from wangzhaoyong/scope11
This commit is contained in:
commit
e1b9aa3ed4
@ -771,6 +771,8 @@ public:
|
|||||||
Local<StringRef> GetName(const EcmaVM *vm);
|
Local<StringRef> GetName(const EcmaVM *vm);
|
||||||
Local<StringRef> GetSourceCode(const EcmaVM *vm, int lineNumber);
|
Local<StringRef> GetSourceCode(const EcmaVM *vm, int lineNumber);
|
||||||
bool IsNative(const EcmaVM *vm);
|
bool IsNative(const EcmaVM *vm);
|
||||||
|
void SetData(const EcmaVM *vm, void *data, Deleter deleter = nullptr, bool callNapi = false);
|
||||||
|
void* GetData(const EcmaVM *vm);
|
||||||
};
|
};
|
||||||
|
|
||||||
class PUBLIC_API ArrayRef : public ObjectRef {
|
class PUBLIC_API ArrayRef : public ObjectRef {
|
||||||
|
@ -1920,6 +1920,33 @@ bool FunctionRef::IsNative(const EcmaVM *vm)
|
|||||||
return method->IsNativeWithCallField();
|
return method->IsNativeWithCallField();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FunctionRef::SetData(const EcmaVM *vm, void *data, Deleter deleter, bool callNapi)
|
||||||
|
{
|
||||||
|
CHECK_HAS_PENDING_EXCEPTION_WITHOUT_RETURN(vm);
|
||||||
|
JSThread *thread = vm->GetJSThread();
|
||||||
|
JSHandle<JSTaggedValue> funcValue = JSNApiHelper::ToJSHandle(this);
|
||||||
|
JSHandle<JSFunction> function(funcValue);
|
||||||
|
function->SetFunctionExtraInfo(thread, nullptr, deleter, data, 0);
|
||||||
|
function->SetCallNapi(callNapi);
|
||||||
|
}
|
||||||
|
|
||||||
|
void* FunctionRef::GetData(const EcmaVM *vm)
|
||||||
|
{
|
||||||
|
CHECK_HAS_PENDING_EXCEPTION(vm, nullptr);
|
||||||
|
JSThread *thread = vm->GetJSThread();
|
||||||
|
JSHandle<JSTaggedValue> funcValue = JSNApiHelper::ToJSHandle(this);
|
||||||
|
JSHandle<JSFunction> function(funcValue);
|
||||||
|
if (!function->IsCallNapi()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
JSTaggedValue extraInfoValue = function->GetFunctionExtraInfo();
|
||||||
|
if (!extraInfoValue.IsNativePointer()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
JSHandle<JSNativePointer> extraInfo(thread, extraInfoValue);
|
||||||
|
return extraInfo->GetData();
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------- ArrayRef ----------------------------------------
|
// ----------------------------------- ArrayRef ----------------------------------------
|
||||||
Local<ArrayRef> ArrayRef::New(const EcmaVM *vm, uint32_t length)
|
Local<ArrayRef> ArrayRef::New(const EcmaVM *vm, uint32_t length)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user