Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 8d0e05a

Browse files
committed
[[ SysLibrary ]] Update revdb to use new engine library loading
This patch updates revdb so that it uses the engine library loading callbacks exclusively removing all the platform-specific code currently present.
1 parent 68e3768 commit 8d0e05a

File tree

13 files changed

+138
-680
lines changed

13 files changed

+138
-680
lines changed

revdb/revdb.gyp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@
88
{
99
'revdb_sources':
1010
[
11+
'src/revdb.h',
12+
'src/revdbapi.h',
13+
'src/database.h',
14+
'src/dbcursor.h',
15+
'src/dbdriver.h',
16+
'src/iossupport.h',
17+
'src/osxsupport.h',
18+
'src/unxsupport.h',
19+
'src/w32support.h',
20+
'src/large_buffer.h',
21+
1122
'src/revdb.cpp',
1223
'src/iossupport.cpp',
1324
'src/osxsupport.cpp',
@@ -19,6 +30,7 @@
1930

2031
'dbmysql_sources':
2132
[
33+
'src/dbmysql.h',
2234
'src/dbdrivercommon.cpp',
2335
'src/database.cpp',
2436
'src/dbmysqlapi.cpp',
@@ -28,7 +40,8 @@
2840
],
2941

3042
'dbodbc_sources':
31-
[
43+
[
44+
'src/dbodbc.h',
3245
'src/dbdrivercommon.cpp',
3346
'src/database.cpp',
3447
'src/dbodbcapi.cpp',
@@ -37,7 +50,8 @@
3750
],
3851

3952
'dbpostgresql_sources':
40-
[
53+
[
54+
'src/dbpostgresql.h',
4155
'src/dbdrivercommon.cpp',
4256
'src/database.cpp',
4357
'src/dbpostgresqlapi.cpp',
@@ -48,6 +62,7 @@
4862

4963
'dbsqlite_sources':
5064
[
65+
'src/dbsqlite.h',
5166
'src/dbdrivercommon.cpp',
5267
'src/database.cpp',
5368
'src/dbsqliteapi.cpp',
@@ -611,6 +626,11 @@
611626
'../libexternal/libexternal.gyp:libExternal-symbol-exports',
612627
],
613628

629+
'defines':
630+
[
631+
'REVDB_BUILD',
632+
],
633+
614634
'include_dirs':
615635
[
616636
'src',
@@ -681,6 +701,11 @@
681701
'../libexternal/libexternal.gyp:libExternal',
682702
],
683703

704+
'defines':
705+
[
706+
'REVDB_BUILD',
707+
],
708+
684709
'include_dirs':
685710
[
686711
'src',

revdb/src/dbdrivercommon.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,25 +469,27 @@ extern "C" LIBRARY_EXPORT void setcallbacksref(DBcallbacks *callbacks)
469469
dbcallbacks = callbacks;
470470
}
471471

472-
extern "C" void *MCU_loadmodule(const char *p_path)
472+
#ifndef REVDB_BUILD
473+
extern "C" void *MCSupportLibraryLoad(const char *p_path)
473474
{
474475
if (dbcallbacks == NULL)
475476
return NULL;
476477
return dbcallbacks -> load_module(p_path);
477478
}
478479

479-
extern "C" void MCU_unloadmodule(void *p_handle)
480+
extern "C" void MCSupportLibraryUnload(void *p_handle)
480481
{
481482
if (dbcallbacks == NULL)
482483
return;
483484
dbcallbacks -> unload_module(p_handle);
484485
}
485486

486-
extern "C" void *MCU_resolvemodulesymbol(void *p_handle, const char *p_symbol)
487+
extern "C" void *MCSupportLibraryLookupSymbol(void *p_handle, const char *p_symbol)
487488
{
488489
if (dbcallbacks == NULL)
489490
return NULL;
490491
return dbcallbacks -> resolve_symbol_in_module(p_handle, p_symbol);
491492
}
493+
#endif
492494

493495
////////////////////////////////////////////////////////////////////////////////

revdb/src/iossupport.cpp

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
2121

2222
#include <CoreFoundation/CoreFoundation.h>
2323

24-
void FreeDatabaseDriver( DATABASEREC *tdatabaserec)
25-
{
26-
dlclose(tdatabaserec -> driverref);
27-
}
28-
2924
void MCU_path2std(char *p_path)
3025
{
3126
if (p_path == NULL || !*p_path)
@@ -175,102 +170,3 @@ char *MCS_resolvepath(const char *path)
175170
return newname;
176171
}
177172

178-
179-
// DoLoadDatabaseDriver
180-
extern "C" void *load_module(const char *);
181-
extern "C" void *resolve_symbol(void *, const char *);
182-
DATABASEREC *DoLoadDatabaseDriver(const char *p_path)
183-
{
184-
char *t_filename;
185-
// SN-2015-05-12: [[ Bug 14972 ]] We don't want to write somewhere we don't
186-
// own the memory
187-
t_filename = (char *)malloc((sizeof(char) * strlen(p_path)) + 7);
188-
sprintf(t_filename, "%s.dylib", p_path);
189-
190-
#if defined(__i386__) || defined(__x86_64__)
191-
void *t_driver_handle;
192-
t_driver_handle = dlopen(t_filename, RTLD_NOW);
193-
194-
if (t_driver_handle == NULL)
195-
{
196-
free(t_filename);
197-
return NULL;
198-
}
199-
200-
201-
DATABASEREC *t_result;
202-
t_result = new (nothrow) DATABASEREC;
203-
204-
t_result -> driverref = t_driver_handle;
205-
t_result -> idcounterptr = (idcounterrefptr)dlsym(t_driver_handle, "setidcounterref");
206-
t_result -> newconnectionptr = (new_connectionrefptr)dlsym(t_driver_handle, "newdbconnectionref");
207-
t_result -> releaseconnectionptr = (release_connectionrefptr)dlsym(t_driver_handle, "releasedbconnectionref");
208-
t_result -> setcallbacksptr = (set_callbacksrefptr)dlsym(t_driver_handle, "setcallbacksref");
209-
free(t_filename);
210-
return t_result;
211-
#else
212-
void *t_driver_handle;
213-
t_driver_handle = load_module(t_filename);
214-
215-
if (t_driver_handle == NULL)
216-
{
217-
free(t_filename);
218-
return NULL;
219-
}
220-
221-
222-
DATABASEREC *t_result;
223-
t_result = new (nothrow) DATABASEREC;
224-
225-
t_result -> driverref = t_driver_handle;
226-
t_result -> idcounterptr = (idcounterrefptr)resolve_symbol(t_driver_handle, "setidcounterref");
227-
t_result -> newconnectionptr = (new_connectionrefptr)resolve_symbol(t_driver_handle, "newdbconnectionref");
228-
t_result -> releaseconnectionptr = (release_connectionrefptr)resolve_symbol(t_driver_handle, "releasedbconnectionref");
229-
t_result -> setcallbacksptr = (set_callbacksrefptr)resolve_symbol(t_driver_handle, "setcallbacksref");
230-
free(t_filename);
231-
return t_result;
232-
#endif
233-
}
234-
235-
const char *GetExternalFolder(void)
236-
{
237-
return NULL;
238-
}
239-
240-
char *GetBundleFolder(CFBundleRef p_bundle)
241-
{
242-
CFURLRef t_bundle_url;
243-
t_bundle_url = CFBundleCopyBundleURL(p_bundle);
244-
if (t_bundle_url == NULL)
245-
return NULL;
246-
247-
CFStringRef t_bundle_folder_path;
248-
t_bundle_folder_path = CFURLCopyFileSystemPath(t_bundle_url, kCFURLPOSIXPathStyle);
249-
CFRelease(t_bundle_url);
250-
if (t_bundle_folder_path == NULL)
251-
return NULL;
252-
253-
CFIndex t_length;
254-
t_length = CFStringGetMaximumSizeForEncoding(CFStringGetLength(t_bundle_folder_path), kCFStringEncodingUTF8);
255-
256-
char *t_result;
257-
t_result = (char *)malloc(t_length + 1);
258-
CFStringGetCString(t_bundle_folder_path, t_result, t_length + 1, kCFStringEncodingUTF8);
259-
CFRelease(t_bundle_folder_path);
260-
t_result = (char *)realloc(t_result, strlen(t_result) + 1);
261-
262-
return t_result;
263-
}
264-
265-
const char *GetApplicationFolder(void)
266-
{
267-
static char *s_folder = NULL;
268-
if (s_folder == NULL)
269-
{
270-
CFBundleRef t_bundle;
271-
t_bundle = CFBundleGetMainBundle();
272-
if (t_bundle != NULL)
273-
s_folder = GetBundleFolder(t_bundle);
274-
}
275-
return s_folder;
276-
}

revdb/src/iossupport.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,6 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
4747

4848
#include "revdb.h"
4949

50-
struct DATABASEREC
51-
{
52-
char dbname[255];
53-
idcounterrefptr idcounterptr;
54-
new_connectionrefptr newconnectionptr;
55-
release_connectionrefptr releaseconnectionptr;
56-
set_callbacksrefptr setcallbacksptr;
57-
void *driverref;
58-
};
59-
60-
61-
// Implemented by TS.
62-
const char *GetExternalFolder(void);
63-
const char *GetApplicationFolder(void);
64-
DATABASEREC *DoLoadDatabaseDriver(const char *p_path);
65-
66-
67-
void FreeDatabaseDriver( DATABASEREC *tdatabaserec);
68-
DATABASEREC *DoLoadDatabaseDriver(const char *p_path);
69-
const char *GetExternalFolder(void);
70-
const char *GetApplicationFolder(void);
7150
void MCU_path2std(char *p_path);
7251
void MCU_path2native(char *p_path);
7352
void MCU_fix_path(char *cstr);

0 commit comments

Comments
 (0)