Python Package made by Mhadhbi Issam .
Project description
Nimc
command line utilty in order to create Defold naitive extensions in Nim .
♠ Install
pip install nimc
♠ Getting started
open terminal in root path of defold project :
♠♠ Create Extension named ext :
nimc init ext
♠♠ Build project :
nimc build ext
♠♠ Edit Nim code inside ext/extext.nim :
Note :
-
To export the functions from nim it must be add exported public through
*annoation . -
To export the functions from nim it must be added with pargma through
{.cdecl,exportc,dynlib.}annoation . -
After any of edit of nim file make sure to call build command
nimc build ext -
the
nimcwill take care of cpp file to export functions !!
proc add*( a : cint , b:cint ): cint {.cdecl,exportc,dynlib.} =
return a + b
proc function*( a : cint , b:cint , c: cint ): cint {.cdecl,exportc,dynlib.} =
return a + b * 2
this will generate in cpp file :
static int nim_add(lua_State* L)
{
int a = luaL_checkinteger(L, 1);
int b = luaL_checkinteger(L, 2);
int result = add(
a ,
b ,
) ;
lua_pushinteger(L, result);
return 1;
}
static int nim_function(lua_State* L)
{
int a = luaL_checkinteger(L, 1);
int b = luaL_checkinteger(L, 2);
int c = luaL_checkinteger(L, 3);
int result = function(
a ,
b ,
c ,
) ;
lua_pushinteger(L, result);
return 1;
}
static const luaL_reg Module_methods[] =
{
{"add", nim_add},
{"function", nim_function},
{0, 0}
};
♠♠ Usage of naitive extension :
in any script file :
local result = ext.add(10,12)
print(result)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nimc-1.3.1.tar.gz.
File metadata
- Download URL: nimc-1.3.1.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
151e08de65922c95ebf533bc4927049d6600b1f5a0251e336ed013595ad97f77
|
|
| MD5 |
b674e25105dcec96846548185b7d205a
|
|
| BLAKE2b-256 |
c5fb4289af8f1bcfbcbf88e26f0534f3ec13674d274946e157e6a4cf3deb0237
|
File details
Details for the file nimc-1.3.1-py3-none-any.whl.
File metadata
- Download URL: nimc-1.3.1-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c29d8ea19ceb343a39d7c7e85e61267745fc76faadff86ea036dc648b93535a
|
|
| MD5 |
606e3ba652ae7636b77c86c887f1da86
|
|
| BLAKE2b-256 |
744cf13f9765ead688a16f810401a2405644a497e8539d1cec5194c1a8b6391b
|