semvec/pypi-packages huggingface dataset:
nimc 1.3.1
Python Package made by Mhadhbi Issam .

# Nimc 
command line utilty in order to create Defold naitive extensions in Nim .


## ♠ Install  
```bash
pip install nimc
```

## ♠ Getting started
open terminal in root path of defold project  : 
### ♠♠ Create Extension named ext : 
```bash
nimc init ext
```
### ♠♠ Build project : 
```bash
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 `nimc`  will take care of cpp file to export functions !! 

```nim
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 : 
```cpp
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 : 
```lua
	local result = ext.add(10,12)
	print(result)
```