• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ArkScript-lang / Ark / 16862444454

10 Aug 2025 02:08PM UTC coverage: 87.685% (+0.8%) from 86.869%
16862444454

Pull #568

github

web-flow
Merge d1e05ae6b into c65ea7e5b
Pull Request #568: feat(closures): captures are no longer fully qualified

106 of 118 new or added lines in 11 files covered. (89.83%)

6 existing lines in 1 file now uncovered.

7633 of 8705 relevant lines covered (87.69%)

125464.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/include/Ark/VM/SharedLibrary.hpp
1
/**
2
 * @file SharedLibrary.hpp
3
 * @author Lex Plateau (lexplt.dev@gmail.com)
4
 * @brief Loads .dll/.so/.dynlib files
5
 * @date 2020-10-27
6
 *
7
 * @copyright Copyright (c) 2020-2025
8
 *
9
 */
10

11
#ifndef ARK_VM_SHAREDLIBRARY_HPP
12
#define ARK_VM_SHAREDLIBRARY_HPP
13

14
#include <Ark/Utils/Platform.hpp>
15

16
#if defined(ARK_OS_WINDOWS)
17
#    include <Proxy/MiniWindows.h>
18
#elif defined(ARK_OS_LINUX)
19
#    include <dlfcn.h>
20
#else
21
#    error "Can not identify the platform on which you are running, aborting"
22
#endif
23

24
#include <string>
25
#include <system_error>
26

27
#include <fmt/core.h>
28

29
namespace Ark::internal
30
{
31
    /**
32
     * @brief Handling a shared library as an ArkScript VM plugin
33
     *
34
     */
35
    class SharedLibrary
36
    {
37
    public:
38
        /**
39
         * @brief Construct a new Shared Library object
40
         *
41
         */
42
        SharedLibrary();
43

44
        /**
45
         * @brief Disable copy semantics as this contains a pointer.
46
         *
47
         */
48
        SharedLibrary(const SharedLibrary&) = delete;
49

50
        /**
51
         * @brief Disable copy semantics as this contains a pointer.
52
         *
53
         */
54
        SharedLibrary& operator=(const SharedLibrary&) = delete;
55

56
        /**
57
         * @brief Construct a new Shared Library object
58
         *
59
         * @param path path to the shared library
60
         */
61
        explicit SharedLibrary(std::string path);
62

63
        /**
64
         * @brief Destroy the Shared Library object
65
         *
66
         */
67
        ~SharedLibrary();
68

69
        /**
70
         * @brief Load a shared library
71
         *
72
         * @param path path to the shared library
73
         */
74
        void load(const std::string& path);
75

76
        /**
77
         * @brief Unload the shared library
78
         *
79
         */
80
        void unload() const;
81

82
        [[nodiscard]] const std::string& path() const { return m_path; }
×
83

84
        /**
85
         * @brief Return a function from the shared library
86
         *
87
         * @tparam T the type of the function to retrieve
88
         * @param procname the name of the function to retrieve
89
         * @return T the function from the shared library, if it was found
90
         */
91
        template <typename T>
92
        T get(const std::string& procname)
1✔
93
        {
1✔
94
            T funcptr;
1✔
95

96
#if defined(ARK_OS_WINDOWS)
97
            if (NULL == (funcptr = reinterpret_cast<T>(GetProcAddress(m_instance, procname.c_str()))))
98
            {
99
                throw std::system_error(
100
                    std::error_code(::GetLastError(), std::system_category()), std::string("PluginError: Couldn't find ") + procname);
101
            }
102
#elif defined(ARK_OS_LINUX)
103
            if (NULL == (funcptr = reinterpret_cast<T>(dlsym(m_instance, procname.c_str()))))
1✔
104
            {
105
                throw std::system_error(
×
NEW
106
                    std::error_code(errno, std::system_category()), fmt::format("SharedLibraryError: Couldn't find {}, {}", procname, dlerror()));
×
107
            }
108
#endif
109
            return funcptr;
2✔
110
        }
1✔
111

112
    private:
113
#if defined(ARK_OS_WINDOWS)
114
        HINSTANCE m_instance;
115
#elif defined(ARK_OS_LINUX)
116
        void* m_instance;
117
#endif
118
        std::string m_path;
119
        bool m_loaded;
120
    };
121
}
122

123
#endif  // ARK_VM_SHAREDLIBRARY_HPP
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc