DLL - hpgDesigns/hpgdesigns-dev.io GitHub Wiki
In computer science, DLL stands for "Dynamically Linked Library" (Also "Dynamic Link Library" [*.dll] on Windows, [*.dylib] on OS X; "Shared Objects" [*.so] on Linux). This means they can be compiled outside of ENIGMA, but ENIGMA games can make calls to them at runtime. Additionally, they are often used for storing pieces of the game's code that may be changed out frequently. Linking the code dynamically allows patches to be made to games to change the behavior of a wide range of events.
ENIGMA itself also takes the form of a DLL for interacting with LateralGM as a Plugin.
Use
In Game Maker, DLLs served mostly as a means of extending the engine. In ENIGMA, however, C++ can already be used to amend or append the engine, and so DLLs will not so frequently be necessary for the sole purpose of extending language functionality.
Part of ENIGMA's philosophy is to not require DLLs in a stand-alone game.
There are presently no solid plans for DLLs in terms of modularizing individual objects in the game, though in the future it is likely for there to be a method of exporting individual objects and functions to separate modules .
Reading DLLs
For the purposes of emulating Game Maker's external_define(), a method needs to be used that allows loading DLLs without knowing anything about them at compile time. This presents an issue in a type-safe language such as C++. Originally, small pieces of assembly were used to pull off the feat, but LibFFI later proved to be a more elegant, more encompassing solution.
LibFFI
On Windows, ENIGMA interfaces with [*.dll] link libraries via
LibFFI1. LibFFI is described as a
"Portable Foreign Function Interface Library." It allows calls to be
made to external libraries by manually setting up the calling convention
when passed a sequence of values and a type index. ENIGMA uses only
char*
and double
, making the calls to FFI (and the defining of a
function from EDL) relatively trivial.
DLL Functions
-
Defines a DLL function to call, returning its ID.
-
Calls a previously defined external function.
-
Frees a previously defined external function. Frees the DLL if no more of its functions are in use.