1 /** 2 * Copyright (c) 2021-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 PANDA_PLUGINS_ETS_RUNTIME_ETS_NATIVE_LIBRARY_PROVIDER_H_ 17 #define PANDA_PLUGINS_ETS_RUNTIME_ETS_NATIVE_LIBRARY_PROVIDER_H_ 18 19 #include "libpandabase/os/mutex.h" 20 #include "plugins/ets/runtime/ets_native_library.h" 21 #include "plugins/ets/runtime/napi/ets_napi.h" 22 #include "runtime/include/mem/panda_containers.h" 23 24 namespace ark::ets { 25 class NativeLibraryProvider { 26 public: 27 NativeLibraryProvider() = default; 28 ~NativeLibraryProvider() = default; 29 30 NO_COPY_SEMANTIC(NativeLibraryProvider); 31 NO_MOVE_SEMANTIC(NativeLibraryProvider); 32 33 std::optional<std::string> LoadLibrary(EtsEnv *env, const PandaString &name); 34 void *ResolveSymbol(const PandaString &name) const; 35 36 private: 37 mutable os::memory::RWLock lock_; 38 PandaSet<EtsNativeLibrary> libraries_ GUARDED_BY(lock_); 39 }; 40 } // namespace ark::ets 41 42 #endif // PANDA_PLUGINS_ETS_RUNTIME_ETS_NATIVE_LIBRARY_PROVIDER_H_ 43