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

Commit 1479e2c

Browse files
committed
libfoundation: Add new MC_DLLEXPORT_DEF macro.
The `used` attribute is needed for Emscripten builds to ensure that native functions accessed by name via dlsym() and/or from JavaScript keep their names and are not removed even when aggressive optimisation is used. `used` can only be attached to definitions, so it cannot be added to `MC_DLLEXPORT`, because that is attached to declarations. It is also not possible to move `MC_DLLEXPORT` from declarations to definitions, because on Windows, the `dllexport` attribute must be attached to declarations (it changes the storage type of the symbol to which it is attached). This patch therefore adds a new `MC_DLLEXPORT_DEF` macro that must be attached to the definitions of exported functions or variables, while `MC_DLLEXPORT` is reserved for advance declarations (e.g. in header files). All symbols that are declared `MC_DLLEXPORT` are now defined with `MC_DLLEXPORT_DEF`, and all uses of `MC_DLLEXPORT` on definitions are replaced with `MC_DLLEXPORT_DEF`.
1 parent cf60420 commit 1479e2c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1210
-519
lines changed

engine/src/module-canvas.cpp

Lines changed: 285 additions & 42 deletions
Large diffs are not rendered by default.

engine/src/module-engine.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct __MCScriptObjectImpl
5050

5151
////////////////////////////////////////////////////////////////////////////////
5252

53-
MCTypeInfoRef kMCEngineScriptObjectTypeInfo;
53+
MC_DLLEXPORT_DEF MCTypeInfoRef kMCEngineScriptObjectTypeInfo;
5454

5555
////////////////////////////////////////////////////////////////////////////////
5656

@@ -116,7 +116,7 @@ void MCEngineScriptObjectAllowAccess(void)
116116

117117
////////////////////////////////////////////////////////////////////////////////
118118

119-
extern "C" MC_DLLEXPORT MCScriptObjectRef MCEngineExecResolveScriptObject(MCStringRef p_object_id)
119+
extern "C" MC_DLLEXPORT_DEF MCScriptObjectRef MCEngineExecResolveScriptObject(MCStringRef p_object_id)
120120
{
121121
if (!MCEngineScriptObjectAccessIsAllowed())
122122
return nil;
@@ -164,7 +164,7 @@ extern "C" MC_DLLEXPORT MCScriptObjectRef MCEngineExecResolveScriptObject(MCStri
164164
return t_script_object;
165165
}
166166

167-
extern "C" MC_DLLEXPORT void MCEngineEvalScriptObjectExists(MCScriptObjectRef p_object, bool& r_exists)
167+
extern "C" MC_DLLEXPORT_DEF void MCEngineEvalScriptObjectExists(MCScriptObjectRef p_object, bool& r_exists)
168168
{
169169
// This method does't require any script interaction so it always allowed.
170170

@@ -177,7 +177,7 @@ extern "C" MC_DLLEXPORT void MCEngineEvalScriptObjectExists(MCScriptObjectRef p_
177177
r_exists = false;
178178
}
179179

180-
extern "C" MC_DLLEXPORT void MCEngineEvalScriptObjectDoesNotExist(MCScriptObjectRef p_object, bool& r_not_exists)
180+
extern "C" MC_DLLEXPORT_DEF void MCEngineEvalScriptObjectDoesNotExist(MCScriptObjectRef p_object, bool& r_not_exists)
181181
{
182182
// This method does't require any script interaction so it always allowed.
183183

@@ -254,7 +254,7 @@ MCValueRef MCEngineGetPropertyOfObject(MCExecContext &ctxt, MCStringRef p_proper
254254
return t_value_ref;
255255
}
256256

257-
extern "C" MC_DLLEXPORT MCValueRef MCEngineExecGetPropertyOfScriptObject(MCStringRef p_property, MCScriptObjectRef p_object)
257+
extern "C" MC_DLLEXPORT_DEF MCValueRef MCEngineExecGetPropertyOfScriptObject(MCStringRef p_property, MCScriptObjectRef p_object)
258258
{
259259
if (!MCEngineScriptObjectAccessIsAllowed())
260260
return nil;
@@ -311,7 +311,7 @@ void MCEngineSetPropertyOfObject(MCExecContext &ctxt, MCStringRef p_property, MC
311311
}
312312
}
313313

314-
extern "C" MC_DLLEXPORT void MCEngineExecSetPropertyOfScriptObject(MCStringRef p_property, MCScriptObjectRef p_object, MCValueRef p_value)
314+
extern "C" MC_DLLEXPORT_DEF void MCEngineExecSetPropertyOfScriptObject(MCStringRef p_property, MCScriptObjectRef p_object, MCValueRef p_value)
315315
{
316316
MCObject *t_object;
317317
uint32_t t_part_id;
@@ -323,7 +323,7 @@ extern "C" MC_DLLEXPORT void MCEngineExecSetPropertyOfScriptObject(MCStringRef p
323323
MCEngineSetPropertyOfObject(ctxt, p_property, t_object, t_part_id, p_value);
324324
}
325325

326-
extern "C" MC_DLLEXPORT void MCEngineEvalOwnerOfScriptObject(MCScriptObjectRef p_object, MCScriptObjectRef &r_owner)
326+
extern "C" MC_DLLEXPORT_DEF void MCEngineEvalOwnerOfScriptObject(MCScriptObjectRef p_object, MCScriptObjectRef &r_owner)
327327
{
328328
// This method does't require any script interaction so it always allowed.
329329

@@ -364,7 +364,7 @@ struct MCScriptObjectChildControlsVisitor : public MCObjectVisitor
364364
MCProperListRef m_list;
365365
};
366366

367-
extern "C" MC_DLLEXPORT void MCEngineEvalChildrenOfScriptObject(MCScriptObjectRef p_object, MCProperListRef &r_controls)
367+
extern "C" MC_DLLEXPORT_DEF void MCEngineEvalChildrenOfScriptObject(MCScriptObjectRef p_object, MCProperListRef &r_controls)
368368
{
369369
// This method does't require any script interaction so it always allowed.
370370

@@ -465,7 +465,7 @@ MCValueRef MCEngineDoSendToObjectWithArguments(bool p_is_function, MCStringRef p
465465
return t_result;
466466
}
467467

468-
extern "C" MC_DLLEXPORT MCValueRef MCEngineExecSendToScriptObjectWithArguments(bool p_is_function, MCStringRef p_message, MCScriptObjectRef p_object, MCProperListRef p_arguments)
468+
extern "C" MC_DLLEXPORT_DEF MCValueRef MCEngineExecSendToScriptObjectWithArguments(bool p_is_function, MCStringRef p_message, MCScriptObjectRef p_object, MCProperListRef p_arguments)
469469
{
470470
if (!MCEngineScriptObjectAccessIsAllowed())
471471
return nil;
@@ -478,7 +478,7 @@ extern "C" MC_DLLEXPORT MCValueRef MCEngineExecSendToScriptObjectWithArguments(b
478478
return MCEngineDoSendToObjectWithArguments(p_is_function, p_message, t_object, p_arguments);
479479
}
480480

481-
extern "C" MC_DLLEXPORT MCValueRef MCEngineExecSendToScriptObject(bool p_is_function, MCStringRef p_message, MCScriptObjectRef p_object)
481+
extern "C" MC_DLLEXPORT_DEF MCValueRef MCEngineExecSendToScriptObject(bool p_is_function, MCStringRef p_message, MCScriptObjectRef p_object)
482482
{
483483
return MCEngineExecSendToScriptObjectWithArguments(p_is_function, p_message, p_object, kMCEmptyProperList);
484484
}
@@ -501,7 +501,7 @@ void MCEngineDoPostToObjectWithArguments(MCStringRef p_message, MCObject *p_obje
501501
MCscreen -> addmessage(p_object, *t_message_as_name, 0.0f, t_params);
502502
}
503503

504-
extern "C" MC_DLLEXPORT void MCEngineExecPostToScriptObjectWithArguments(MCStringRef p_message, MCScriptObjectRef p_object, MCProperListRef p_arguments)
504+
extern "C" MC_DLLEXPORT_DEF void MCEngineExecPostToScriptObjectWithArguments(MCStringRef p_message, MCScriptObjectRef p_object, MCProperListRef p_arguments)
505505
{
506506
if (!MCEngineScriptObjectAccessIsAllowed())
507507
return;
@@ -514,17 +514,17 @@ extern "C" MC_DLLEXPORT void MCEngineExecPostToScriptObjectWithArguments(MCStrin
514514
MCEngineDoPostToObjectWithArguments(p_message, t_object, p_arguments);
515515
}
516516

517-
extern "C" MC_DLLEXPORT void MCEngineExecPostToScriptObject(MCStringRef p_message, MCScriptObjectRef p_object)
517+
extern "C" MC_DLLEXPORT_DEF void MCEngineExecPostToScriptObject(MCStringRef p_message, MCScriptObjectRef p_object)
518518
{
519519
MCEngineExecPostToScriptObjectWithArguments(p_message, p_object, kMCEmptyProperList);
520520
}
521521

522-
extern "C" MC_DLLEXPORT void MCEngineEvalMessageWasHandled(bool& r_handled)
522+
extern "C" MC_DLLEXPORT_DEF void MCEngineEvalMessageWasHandled(bool& r_handled)
523523
{
524524
r_handled = s_last_message_was_handled;
525525
}
526526

527-
extern "C" MC_DLLEXPORT void MCEngineEvalMessageWasNotHandled(bool& r_not_handled)
527+
extern "C" MC_DLLEXPORT_DEF void MCEngineEvalMessageWasNotHandled(bool& r_not_handled)
528528
{
529529
bool t_handled;
530530
MCEngineEvalMessageWasHandled(t_handled);
@@ -533,7 +533,7 @@ extern "C" MC_DLLEXPORT void MCEngineEvalMessageWasNotHandled(bool& r_not_handle
533533

534534
////////////////////////////////////////////////////////////////////////////////
535535

536-
extern "C" MC_DLLEXPORT MCValueRef MCEngineExecExecuteScript(MCStringRef p_script)
536+
extern "C" MC_DLLEXPORT_DEF MCValueRef MCEngineExecExecuteScript(MCStringRef p_script)
537537
{
538538
if (!MCEngineScriptObjectAccessIsAllowed())
539539
return nil;
@@ -636,7 +636,7 @@ class MCEngineLogChangedEvent: public MCCustomEvent
636636
}
637637
};
638638

639-
extern "C" MC_DLLEXPORT void MCEngineExecLog(MCValueRef p_message)
639+
extern "C" MC_DLLEXPORT_DEF void MCEngineExecLog(MCValueRef p_message)
640640
{
641641
if (p_message == nil)
642642
p_message = kMCNull;
@@ -673,7 +673,7 @@ extern "C" MC_DLLEXPORT void MCEngineExecLog(MCValueRef p_message)
673673
#endif
674674
}
675675

676-
extern "C" MC_DLLEXPORT void MCEngineExecLogWithValues(MCStringRef p_message, MCProperListRef p_values)
676+
extern "C" MC_DLLEXPORT_DEF void MCEngineExecLogWithValues(MCStringRef p_message, MCProperListRef p_values)
677677
{
678678
MCAutoStringRef t_formatted_message;
679679
if (!MCStringCreateMutable(0, &t_formatted_message))
@@ -724,8 +724,8 @@ extern "C" MC_DLLEXPORT void MCEngineExecLogWithValues(MCStringRef p_message, MC
724724

725725
////////////////////////////////////////////////////////////////////////////////
726726

727-
MCTypeInfoRef kMCEngineScriptObjectDoesNotExistErrorTypeInfo = nil;
728-
MCTypeInfoRef kMCEngineScriptObjectNoContextErrorTypeInfo = nil;
727+
MC_DLLEXPORT_DEF MCTypeInfoRef kMCEngineScriptObjectDoesNotExistErrorTypeInfo = nil;
728+
MC_DLLEXPORT_DEF MCTypeInfoRef kMCEngineScriptObjectNoContextErrorTypeInfo = nil;
729729

730730
////////////////////////////////////////////////////////////////////////////////
731731

engine/src/text-api.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "text-pane.h"
2222

2323

24+
MC_DLLEXPORT_DEF
2425
void MCTextCellSetMaxSize(MCTextCellRef p_cell, coord_t p_width, coord_t p_height)
2526
{
2627
p_cell->setMaxSize(p_width, p_height);
@@ -29,13 +30,15 @@ void MCTextCellSetMaxSize(MCTextCellRef p_cell, coord_t p_width, coord_t p_heigh
2930
// Creates a new, empty text pane. The specified stack is used for scaling and
3031
// theming only - the pane isn't a LiveCode control and isn't a child of the
3132
// stack.
33+
MC_DLLEXPORT_DEF
3234
bool MCTextPaneCreate(class MCStack* p_on_stack, MCTextPaneRef& r_pane)
3335
{
3436
r_pane = new MCTextPane;
3537
return true;
3638
}
3739

3840
// Deletes the given text pane
41+
MC_DLLEXPORT_DEF
3942
bool MCTextPaneDelete(MCTextPaneRef p_pane)
4043
{
4144
delete p_pane;
@@ -45,24 +48,30 @@ bool MCTextPaneDelete(MCTextPaneRef p_pane)
4548
// Sets the contents of the text pane to be the given string. Other than certain
4649
// inline control characters (tabs, newlines, BiDi controls, etc), the string
4750
// is unformatted.
51+
MC_DLLEXPORT_DEF
4852
bool MCTextPaneSetContentsPlain(MCTextPaneRef p_pane, MCStringRef p_contents)
4953
{
5054
p_pane->setContentsPlain(p_contents);
5155
return true;
5256
}
5357

5458
static MCTextPaneRef s_pane;
59+
60+
MC_DLLEXPORT_DEF
5561
MCTextPaneRef MCTextPaneGet()
5662
{
5763
return s_pane;
5864
}
5965

66+
MC_DLLEXPORT_DEF
6067
void MCTextPaneSet(MCTextPaneRef p_pane)
6168
{
6269
s_pane = p_pane;
6370
}
6471

6572
extern MCDC* g_widget_paint_dc;
73+
74+
MC_DLLEXPORT_DEF
6675
void MCTextPanePaintShim(MCTextPaneRef p_pane)
6776
{
6877
// AL-2015-07-08: Removed temporarily as it was causing build issues

0 commit comments

Comments
 (0)