forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem-library.h
More file actions
185 lines (148 loc) · 5.86 KB
/
system-library.h
File metadata and controls
185 lines (148 loc) · 5.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*
Copyright (C) 2017 LiveCode Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
#if !defined(__MCS_SYSTEM_H_INSIDE__)
# error "Only <foundation-system.h> can be included directly"
#endif
/* ================================================================
* Loadable library handling
* ================================================================ */
/* The MCSLibrary library provides an API for handling loadable libraries in a
* standardized fashion. */
/* ================================================================
* Types
* ================================================================ */
/* An opaque custom value ref type representing a loaded library. */
typedef struct __MCSLibrary *MCSLibraryRef;
/* The binding to the internal MCTypeInfoRef for the MCSLibraryRef type */
MC_DLLEXPORT MCTypeInfoRef
MCSLibraryTypeInfo(void) ATTRIBUTE_PURE;
/* ================================================================
* Construction and querying
* ================================================================ */
/* Create an MCSLibraryRef object by loading the library from the specified
* path.
*
* If the path is absolute, then only an attempt to load that specific library
* will be made. If the path is relative, however, an attempt to load the
* library will use the system's default search order.
*
* On Mac, bundles, frameworks and dylibs are supported. In order to load a
* bundle, an absolute path must be supplied. Otherwise, if the path ends in
* <LEAF>.framework then the path will be modified to end in
* <LEAF>.framework/<LEAF>. In the dylib and framework case, dlopen's default
* search strategy is used.
*
* On Windows, dlls are supported. They are loaded using LoadLibraryEx with
* the LOAD_WITH_ALTERED_SEARCH_PATH flag set.
*
* On Linux, shared objects (.so) are supported. They are loaded using dlopen's
* search strategy.
*
* On Android, shared objects (.so) are supported. They are loaded using
* dlopen's search strategy which requires that non-system libraries be loaded
* using absolute paths (otherwise they can fail to load).
*
* On iOS, only statically linked and registered objects are supported. The
* name is matched exactly with the name specified in the static registration
* record. */
MC_DLLEXPORT bool
MCSLibraryCreateWithPath(MCStringRef p_path,
MCSLibraryRef& r_library);
/* Create an MCSLibraryRef object by referencing the library currently loaded
* at the specified address. */
MC_DLLEXPORT bool
MCSLibraryCreateWithAddress(void *p_address,
MCSLibraryRef& r_library);
/* Copy the full native path to the specified library. If the library is of
* static type, this returns the path of the loadable object which the library
* is linked into. */
MC_DLLEXPORT bool
MCSLibraryCopyNativePath(MCSLibraryRef p_library,
MCStringRef& r_path);
/* Copy the full (non-native) path to the specified library. If the library is of
* static type, this returns the path of the loadable object which the library
* is linked into. */
MC_DLLEXPORT bool
MCSLibraryCopyPath(MCSLibraryRef p_library,
MCStringRef& r_path);
/* Lookup the symbol in the specified library. */
MC_DLLEXPORT void *
MCSLibraryLookupSymbol(MCSLibraryRef p_library,
MCStringRef p_symbol);
#if defined(__ANDROID__)
/* Sets the path to use as the base path for the paths of libraries.
* This must be called after MCSInitialize, with the value of the
* Android application's context's nativeLibPath member. */
MC_DLLEXPORT void
MCSLibraryAndroidSetNativeLibPath(MCStringRef p_path);
#endif
#ifdef __MCS_INTERNAL_API__
bool
__MCSLibraryThrowCreateWithNativePathFailed(MCStringRef p_native_path);
bool
__MCSLibraryThrowCreateWithAddressFailed(void *p_address);
bool
__MCSLibraryThrowResolvePathFailed(void);
#endif
/* ================================================================
* Static binding (iOS only)
* ================================================================ */
#ifdef __IOS__
/* New style (C++ based) - not implemented yet */
#if defined(MCS_LIBRARY_CXX_IOS_STATIC)
/* The record which each statically linked library should register using a
* constructor. */
struct MCSLibraryStaticInfo
{
MCSLibraryStaticInfo *__next;
const char *name;
struct {
const char *symbol;
void *address;
} *exports;
};
/* Register the given statically linked library and required symbols. The
* record passed as p_info must exist until the foundation library is
* shutdown. */
MC_DLLEXPORT void
MCSLibraryRegisterStatic(MCSLibraryStaticInfo& p_info);
#endif
/* Old style (section based) */
#if !defined(MCS_LIBRARY_CXX_IOS_STATIC)
struct MCSLibraryStaticLibExport
{
const char *symbol;
void *address;
};
struct MCSLibraryStaticLibInfo
{
char * const * name;
const struct MCSLibraryStaticLibExport *exports;
};
#endif
#endif
/* ================================================================
* Library API initialization
* ================================================================ */
#ifdef __MCS_INTERNAL_API__
bool
__MCSLibraryInitialize(void);
void
__MCSLibraryFinalize(void);
#endif
/* ================================================================
* C++ API
* ================================================================ */
#ifdef __cplusplus
typedef MCAutoValueRefBase<MCSLibraryRef> MCSAutoLibraryRef;
#endif