1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_ACE_NAPI_NATIVE_ENGINE_NATIVE_SENDABLE_H 17 #define FOUNDATION_ACE_NAPI_NATIVE_ENGINE_NATIVE_SENDABLE_H 18 19 #include "ecmascript/napi/include/jsnapi.h" 20 #include "native_engine/native_property.h" 21 22 using FunctionRef = panda::FunctionRef; 23 using panda::Local; 24 25 class NativeSendable { 26 public: 27 static FunctionRef::SendablePropertiesInfos CreateSendablePropertiesInfos(napi_env env, 28 const NapiPropertyDescriptor* properties, 29 size_t propertiesLength); 30 static void NapiDefineSendabledProperty(napi_env env, 31 Local<panda::ObjectRef>& obj, 32 NapiPropertyDescriptor& propertyDescriptor, 33 Local<panda::JSValueRef>& propertyName, 34 bool& result); 35 static void InitSendablePropertiesInfo(napi_env env, 36 FunctionRef::SendablePropertiesInfo& info, 37 NapiPropertyDescriptor propertyDescriptor, 38 FunctionRef::SendableType type = FunctionRef::SendableType::NONE); 39 40 private: 41 static Local<panda::JSValueRef> NapiNativeCreateSendableFunction(napi_env env, 42 const char* name, 43 NapiNativeCallback cb, 44 void* value); 45 }; 46 47 #endif 48