Skip to content

Commit b2c08fc

Browse files
[[ Broken Win Compilation ]] Fixes cefbrower issues on Windows:
* rename LoadModule (which is a Windows API function) * Change MCU_loadmodule, MCU_unloadmodule and MCU_resolvemodulesymbol prototype to use void* instead of MCSysModuleHandle
1 parent 0b7da72 commit b2c08fc

File tree

8 files changed

+37
-22
lines changed

8 files changed

+37
-22
lines changed

engine/src/external.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ MCExternal *MCExternal::Load(const char *p_filename)
222222
if (t_success)
223223
{
224224
// AL-2015-02-10: [[ SB Inclusions ]] Load external using new module loading utility
225-
t_module = MCU_loadmodule(p_filename);
225+
t_module = (MCSysModuleHandle)MCU_loadmodule(p_filename);
226226
if (t_module == NULL)
227227
t_success = false;
228228
}

engine/src/externalv0.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ static char *load_module(const char *arg1, const char *arg2,
817817
MCSysModuleHandle *t_result;
818818
t_result = (MCSysModuleHandle *)arg2;
819819

820-
*t_result = MCU_loadmodule(arg1);
820+
*t_result = (MCSysModuleHandle)MCU_loadmodule(arg1);
821821

822822
if (*t_result == nil)
823823
*retval = xresFail;

engine/src/util.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2930,7 +2930,9 @@ bool MCU_random_bytes(size_t p_count, void *p_buffer)
29302930
// AL-2015-02-06: [[ SB Inclusions ]] Add utility functions for module loading where
29312931
// p_module can be a universal module name, where a mapping from module names to
29322932
// relative paths has been provided.
2933-
MCSysModuleHandle MCU_loadmodule(const char *p_module)
2933+
// SN-2015-02-23: [[ Broken Win Compilation ]] Use void*, as the function is imported
2934+
// as extern in revbrowser/src/cefshared.h - where MCSysModuleHandle does not exist
2935+
void* MCU_loadmodule(const char *p_module)
29342936
{
29352937
MCSysModuleHandle t_handle;
29362938
t_handle = nil;
@@ -2998,20 +3000,24 @@ MCSysModuleHandle MCU_loadmodule(const char *p_module)
29983000
return t_handle;
29993001
}
30003002

3001-
void MCU_unloadmodule(MCSysModuleHandle p_module)
3003+
// SN-2015-02-23: [[ Broken Win Compilation ]] Use void*, as the function is imported
3004+
// as extern in revbrowser/src/cefshared.h - where MCSysModuleHandle does not exist
3005+
void MCU_unloadmodule(void *p_module)
30023006
{
3003-
MCS_unloadmodule(p_module);
3007+
MCS_unloadmodule((MCSysModuleHandle)p_module);
30043008
}
30053009

3006-
void *MCU_resolvemodulesymbol(MCSysModuleHandle p_module, const char *p_symbol)
3010+
// SN-2015-02-23: [[ Broken Win Compilation ]] Use void*, as the function is imported
3011+
// as extern in revbrowser/src/cefshared.h - where MCSysModuleHandle does not exist
3012+
void *MCU_resolvemodulesymbol(void* p_module, const char *p_symbol)
30073013
{
30083014
#if defined(_MACOSX) || defined(_MAC_SERVER)
30093015
NSSymbol t_symbol;
30103016
t_symbol = NSLookupSymbolInImage((mach_header *)p_module, p_symbol, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW);
30113017
if (t_symbol != NULL)
30123018
return NSAddressOfSymbol(t_symbol);
30133019
#endif
3014-
return MCS_resolvemodulesymbol(p_module, p_symbol);
3020+
return MCS_resolvemodulesymbol((MCSysModuleHandle)p_module, p_symbol);
30153021
}
30163022

30173023
///////////////////////////////////////////////////////////////////////////////

engine/src/util.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,11 @@ extern double MCU_squared_distance_from_line(int4 sx, int4 sy, int4 ex, int4 ey,
180180
extern bool MCU_random_bytes(size_t count, void *buffer);
181181

182182
// AL-2015-02-06: [[ SB Inclusions ]] Add utility functions for module loading
183-
extern "C" MCSysModuleHandle MCU_loadmodule(const char *p_module);
184-
extern "C" void MCU_unloadmodule(MCSysModuleHandle p_module);
185-
extern "C" void *MCU_resolvemodulesymbol(MCSysModuleHandle p_module, const char *p_symbol);
183+
// SN-2015-02-23: [[ Broken Win Compilation ]] Use void*, as the function is imported
184+
// as extern in revbrowser/src/cefshared.h - where MCSysModuleHandle does not exist
185+
extern "C" void* MCU_loadmodule(const char *p_module);
186+
extern "C" void MCU_unloadmodule(void* p_module);
187+
extern "C" void *MCU_resolvemodulesymbol(void* p_module, const char *p_symbol);
186188

187189
//
188190

libexternal/include/revolution/external.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,8 @@ extern void StackToWindowRect(unsigned int p_win_id, MCRectangle32 *x_rect, int
451451
extern void WindowToStackRect(unsigned int p_win_id, MCRectangle32 *x_rect, int *r_success);
452452

453453
// AL-2015-02-10: [[ SB Inclusions ]] Add wrappers for ExternalV0 module loading callbacks
454-
extern void LoadModule(const char *p_module, void **r_handle, int *r_success);
454+
// SN-2015-02-24: [[ Broken Win Compilation ]] LoadModule is a Win32 API function...
455+
extern void LoadModuleByName(const char *p_module, void **r_handle, int *r_success);
455456
extern void UnloadModule(void *p_handle, int *r_success);
456457
extern void ResolveSymbolInModule(void *p_handle, const char *p_symbol, void **r_resolved, int *r_success);
457458

libexternal/src/external.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -413,15 +413,17 @@ void WindowToStackRect(unsigned int p_win_id, MCRectangle32 *x_rect, int *r_succ
413413
////////////////////////////////////////////////////////////////////////////////
414414

415415
// AL-2015-02-10: [[ SB Inclusions ]] Add wrappers for ExternalV0 module loading callbacks
416-
void LoadModule(const char *p_module, void **r_handle, int *r_success)
416+
// SN-2015-02-24: [[ Broken Win Compilation ]] LoadModule is a Win32 API function...
417+
void LoadModuleByName(const char *p_module, void **r_handle, int *r_success)
417418
{
419+
char *t_result;
420+
418421
if (s_external_interface_version < 2)
419422
{
420423
*r_success = EXTERNAL_FAILURE;
421424
return;
422425
}
423-
424-
char *t_result;
426+
425427
t_result = (s_operations[OPERATION_LOAD_MODULE])(p_module, (const char *)r_handle, NULL, r_success);
426428

427429
if (t_result != NULL)
@@ -430,13 +432,14 @@ void LoadModule(const char *p_module, void **r_handle, int *r_success)
430432

431433
void UnloadModule(void *p_handle, int *r_success)
432434
{
435+
char *t_result;
436+
433437
if (s_external_interface_version < 2)
434438
{
435439
*r_success = EXTERNAL_FAILURE;
436440
return;
437441
}
438-
439-
char *t_result;
442+
440443
t_result = (s_operations[OPERATION_UNLOAD_MODULE])(p_handle, NULL, NULL, r_success);
441444

442445
if (t_result != NULL)
@@ -445,13 +448,14 @@ void UnloadModule(void *p_handle, int *r_success)
445448

446449
void ResolveSymbolInModule(void *p_handle, const char *p_symbol, void **r_resolved, int *r_success)
447450
{
451+
char *t_result;
452+
448453
if (s_external_interface_version < 2)
449454
{
450455
*r_success = EXTERNAL_FAILURE;
451456
return;
452457
}
453-
454-
char *t_result;
458+
455459
t_result = (s_operations[OPERATION_RESOLVE_SYMBOL_IN_MODULE])(p_handle, p_symbol, (const char *)r_resolved, r_success);
456460

457461
if (t_result != NULL)

revbrowser/src/cefbrowser_w32.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,5 +533,5 @@ void MCU_unloadmodule(void *p_module)
533533

534534
void *MCU_resolvemodulesymbol(void *p_module, const char *p_name)
535535
{
536-
return GetProcAddress(p_module, p_name);
536+
return GetProcAddress((HMODULE)p_module, p_name);
537537
}

revdb/src/revdb.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static void *DBcallback_loadmodule(const char *p_path)
139139
{
140140
int t_success;
141141
void *t_handle;
142-
LoadModule(p_path, &t_handle, &t_success);
142+
LoadModuleByName(p_path, &t_handle, &t_success);
143143
if (t_success == EXTERNAL_FAILURE)
144144
return NULL;
145145
return t_handle;
@@ -271,7 +271,7 @@ DATABASEREC *LoadDatabaseDriverFromName(const char *p_type)
271271
int t_retvalue;
272272
void *t_handle;
273273
t_handle = NULL;
274-
LoadModule(p_type, &t_handle, &t_retvalue);
274+
LoadModuleByName(p_type, &t_handle, &t_retvalue);
275275

276276
if (t_handle == NULL)
277277
return NULL;
@@ -280,8 +280,10 @@ DATABASEREC *LoadDatabaseDriverFromName(const char *p_type)
280280
t_result = new DATABASEREC;
281281
#if (defined _MACOSX && !defined _MAC_SERVER)
282282
t_result -> driverref = (CFBundleRef)t_handle;
283+
#elif (defined _WINDOWS)
284+
t_result -> driverref = (HINSTANCE)t_handle;
283285
#else
284-
t_result -> driverref = t_handle;
286+
t_result -> driverref = t_handle;
285287
#endif
286288

287289
void *id_counterref_ptr, *new_connectionref_ptr, *release_connectionref_ptr;

0 commit comments

Comments
 (0)