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)
Metadata
Release files for nimc 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nimc-1.3.1.tar.gz | 7.8 kB | Without provenance | Details for nimc-1.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nimc-1.3.1-py3-none-any.whl | Python 3 | none | any | Details for nimc-1.3.1-py3-none-any.whl |
Total release size: 15.4 kB
Release files / nimc-1.3.1.tar.gz
| Download URL | nimc-1.3.1.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
151e08de65922c95ebf533bc4927049d6600b1f5a0251e336ed013595ad97f77
|
|
BLAKE2b-256 checksum How to use checksums |
c5fb4289af8f1bcfbcbf88e26f0534f3ec13674d274946e157e6a4cf3deb0237
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / nimc-1.3.1-py3-none-any.whl
| Download URL | nimc-1.3.1-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c29d8ea19ceb343a39d7c7e85e61267745fc76faadff86ea036dc648b93535a
|
|
BLAKE2b-256 checksum How to use checksums |
744cf13f9765ead688a16f810401a2405644a497e8539d1cec5194c1a8b6391b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for nimc 1.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.