1/* 2 * Copyright (c) 2023 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#include "interfaces/inner_api/ace/serializeable_object.h" 17 18#include "utils.h" 19#include "ace_forward_compatibility.h" 20 21namespace OHOS::Ace { 22namespace { 23 24using CreateFunction = SerializeableObject* (*)(); 25constexpr char NODE_OBJECT_CREATE_FUNC[] = "OHOS_ACE_CreateNodeObject"; 26 27SerializeableObject* CreateNodeObjectInner() 28{ 29 LIBHANDLE handle = LOADLIB(AceForwardCompatibility::GetAceLibName()); 30 if (handle == nullptr) { 31 return nullptr; 32 } 33 34 auto entry = reinterpret_cast<CreateFunction>(LOADSYM(handle, NODE_OBJECT_CREATE_FUNC)); 35 if (entry == nullptr) { 36 FREELIB(handle); 37 return nullptr; 38 } 39 40 auto nodeObject = entry(); 41 return nodeObject; 42} 43} // namespace 44 45std::unique_ptr<SerializeableObject> SerializeableObject::CreateNodeObject() 46{ 47 std::unique_ptr<SerializeableObject> obj; 48 obj.reset(CreateNodeObjectInner()); 49 return obj; 50} 51} // namespace OHOS::Ace 52