• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <string>
20 #include "libpandabase/os/mutex.h"
21 #include "plugins/ets/runtime/ets_native_library.h"
22 #include "plugins/ets/runtime/napi/ets_napi.h"
23 #include "runtime/include/mem/panda_containers.h"
24 
25 namespace ark::ets {
26 class NativeLibraryProvider {
27 public:
28     NativeLibraryProvider() = default;
29     ~NativeLibraryProvider() = default;
30 
31     NO_COPY_SEMANTIC(NativeLibraryProvider);
32     NO_MOVE_SEMANTIC(NativeLibraryProvider);
33 
34     std::optional<std::string> LoadLibrary(EtsEnv *env, const PandaString &name);
35     void *ResolveSymbol(const PandaString &name) const;
36 
37     PandaVector<PandaString> GetLibraryPath() const;
38     void SetLibraryPath(const PandaVector<PandaString> &pathes);
39     void AddLibraryPath(const PandaString &path);
40 
41 private:
42     mutable os::memory::RWLock lock_;
43     PandaSet<EtsNativeLibrary> libraries_ GUARDED_BY(lock_);
44     PandaVector<PandaString> libraryPath_ GUARDED_BY(lock_);
45 };
46 }  // namespace ark::ets
47 
48 #endif  // PANDA_PLUGINS_ETS_RUNTIME_ETS_NATIVE_LIBRARY_PROVIDER_H_
49