Metadata-Version: 2.1
Name: nimc
Version: 1.2.6
Summary: Python Package made by Mhadhbi Issam . 
Home-page: https://gitlab.com/game-dev-comapny/nimc.git
Author: $GITLAB_USER_LOGIN
Author-email: mhadhbixissam@gmail.com
Project-URL: Documentation, https://pydefold.readthedocs.io/en/latest/
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
Requires-Dist: pyyaml
Requires-Dist: click
Requires-Dist: jinja2

# 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:int  ): 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 = None(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)
```
