libraries:machine_code:mcl

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
libraries:machine_code:mcl [2023-12-17 03:00] – [MCL [v1][v2]] Update description geeklibraries:machine_code:mcl [2023-12-17 03:08] (current) – Fix broken markup geek
Line 25: Line 25:
 The primary goal of MCL is to enable much more complex machine code functions/libraries without resorting to a dll. For example [[libraries:json:cjson]] which is compiled under MCL, and makes use of global variables, "exporting" multiple functions, and floating point numbers. The primary goal of MCL is to enable much more complex machine code functions/libraries without resorting to a dll. For example [[libraries:json:cjson]] which is compiled under MCL, and makes use of global variables, "exporting" multiple functions, and floating point numbers.
  
-MCL also supports a tiny subset of C++ (no STL, exceptions, or RTTI). For example, see [[https://github.com/G33kDude/MCL.ahk/blob/main/Tests/CPP/Spooky.cpp|the SpookyHash test]], which uses a C++ implementation of the [[https://burtleburtle.net/bob/hash/spooky.html|SpookyHash]] hashing algorithm.+MCL also supports a tiny subset of %%C++%% (no STL, exceptions, or RTTI). For example, see [[https://github.com/G33kDude/MCL.ahk/blob/main/Tests/CPP/Spooky.cpp|the SpookyHash test]], which uses a %%C++%% implementation of the [[https://burtleburtle.net/bob/hash/spooky.html|SpookyHash]] hashing algorithm.
  
 MCL also adds the ability for code to "import" functions from DLLs in the same way you can with ''DllCall''. This feature doesn't replace DLL files, and isn't the primary goal of the project. Just think of it as a cherry on top. MCL also adds the ability for code to "import" functions from DLLs in the same way you can with ''DllCall''. This feature doesn't replace DLL files, and isn't the primary goal of the project. Just think of it as a cherry on top.
  
-And a (low level) warning for this feature: There is a bug with mingw-w64 compilers which results in the stack being misaligned, which will cause a crash the next time a Windows API (or standard library) function is called from your C/C++. This bug can be tracked [[https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54412|here]].+And a (low level) warning for this feature: There is a bug with mingw-w64 compilers which results in the stack being misaligned, which will cause a crash the next time a Windows API (or standard library) function is called from your C/%%C++%%. This bug can be tracked [[https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54412|here]].
  
 For an example of "importing" functions, see [[user:cloakersmoker]]'s [[https://github.com/CloakerSmoker/PDFGen.ahk|PDFGen example library]], which uses a regular C library with a few headers changed around along with an incredible number of imported standard library functions. For an example of "importing" functions, see [[user:cloakersmoker]]'s [[https://github.com/CloakerSmoker/PDFGen.ahk|PDFGen example library]], which uses a regular C library with a few headers changed around along with an incredible number of imported standard library functions.
Line 84: Line 84:
 In AHK, MCL provides all functionality through the ''MCL'' class.  In AHK, MCL provides all functionality through the ''MCL'' class. 
  
-Any method which is described as "returning compiled code" returns an object that wraps the exported functions and global variables as methods and properties respectively. The object is also callable, in which case it will invoke any export named "main".+Any method which is described as "returning compiled code" returns an object that wraps the exported functions and global variables as methods and properties respectively. The object is also callable, in which case it will invoke any export named "%%__main%%".
  
 Now, for the API: Now, for the API:
Line 95: Line 95:
 For any method which takes an ''Options'' parameter, the following options can be provided to control the bitness/format of the generated code: For any method which takes an ''Options'' parameter, the following options can be provided to control the bitness/format of the generated code:
  
-  * ''MCL.Options.OutputAHKBit'' generates code which will run in `A_PtrSize * 8AHK. So, on AHK U32, this flag tells MCL to generate 32 bit code. On AHK U64, this flag tells MCL to generate 64 bit code.+  * ''MCL.Options.OutputAHKBit'' generates code which will run in ''A_PtrSize * 8'' AHK. So, on AHK U32, this flag tells MCL to generate 32 bit code. On AHK U64, this flag tells MCL to generate 64 bit code.
   * ''MCL.Options.Output32Bit'' generates 32 bit code, ignoring the bitness of the AHK executable.   * ''MCL.Options.Output32Bit'' generates 32 bit code, ignoring the bitness of the AHK executable.
   * ''MCL.Options.Output64Bit'' generates 64 bit code, ignoring the bitness of the AHK executable.   * ''MCL.Options.Output64Bit'' generates 64 bit code, ignoring the bitness of the AHK executable.