Sep 18, 2021Kuina-chan
This is the language specification 16 of Kuin Programming Language, and is about the advanced features of Kuin.
If you specify exe as the execution environment, you can call DLLs for x64 created in other languages. For example, write as shown in Figure 1-1 in C++ and compile for x64 in Visual C++ to create a DLL.
If the resulting DLL is named test_dll.dll, the Kuin program can call the function in the DLL by writing Figure 1-2.
By defining the function "func[DLL File Name,Function Name In DLL]Any Function Name(Argument):Return Value" as shown in line 1, you can call the function in the DLL as a function of Kuin as shown in line 5.
If you write a process in the content of a DLL function definition such as the first line, the DLL will be called after the process is done, but if it is not necessary, leave it empty. DLL file names can be handled with an extension other than .dll.
Now, finally, you need to copy test_dll.dll to the directory under the exe generated by Kuin. In the menu, select "Edit", then "Other Settings...". and add test_dll.dll to the related files. This will automatically copy test_dll.dll to the data folder next to the exe and call it from the exe.
When run in the CUI environment, "25" will be displayed on the screen.
The Kuin value type (non-reference type) has a correspondence with the argument and return types of DLL functions as shown in Table 1-1, and can be passed as is.
|Kuin Value Type||DLL Value Type|
|int||8byte Signed Integer Type|
|float||8byte Floating-point Type|
|char||2byte Character Type (UCS-2)|
|bool||1byte Boolean Type|
|bit8||1byte Unsigned Integer Type|
|bit16||2byte Unsigned Integer Type|
|bit32||4byte Unsigned Integer Type|
|bit64||8byte Unsigned Integer Type|
|enum||8byte Signed Integer Type|
Be careful when rewriting the reference type of Kuin on the DLL side, as it uses garbage collection for memory management. Because of the complexity of the rules, it is usually best to treat them as read-only and not rewrite them in the DLL side.
(This page is being written...)