Skip to main content

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 nimc will 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:int  ): 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 = 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 :

	local result = ext.add(10,12)
	print(result)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nimc-1.2.6.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

nimc-1.2.6-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file nimc-1.2.6.tar.gz.

File metadata

  • Download URL: nimc-1.2.6.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for nimc-1.2.6.tar.gz
Algorithm Hash digest
SHA256 064d6fd028502815afcb7e2b82fb0b5b928808e5f8558b0b99065b3f261acda5
MD5 3c100114ddce3cc6c5bdffcb56a5f30b
BLAKE2b-256 64dd9a8789a5c2a1c2fd62822f69de30d2d5302a4405a69ca2f78775f1c5d69f

See more details on using hashes here.

File details

Details for the file nimc-1.2.6-py3-none-any.whl.

File metadata

  • Download URL: nimc-1.2.6-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for nimc-1.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b6965df023e73e2c11ea7339c09f19eab0fc1d5c5c8a47d3436253f02f05b283
MD5 f1f12cdf2e944a2f89cee3b9764f3a63
BLAKE2b-256 fb1b2fdf9c73a4ba2f950c740cb3cc566e0a4a8b4b012fbe7b70807ca7c5aee0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page