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: 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


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.3.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

nimc-1.3.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nimc-1.3.0.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

Hashes for nimc-1.3.0.tar.gz
Algorithm Hash digest
SHA256 1fc76a9dc0f6b0b36746379f70884ae5272c8a10c8095dd1dee8f02e257ddca7
MD5 20453130dcb54a22617f773fc723ce58
BLAKE2b-256 a87d0a0bf17ee223867416c6cb95804c7f1a785955277d7479fcf49b1ec3421e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nimc-1.3.0-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

Hashes for nimc-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26ee0969e8f1c638877c65ead580464819a60b39704f3aa5b9f81aec08dc8a16
MD5 565fac2a199a12a529c51d19e1e91dd2
BLAKE2b-256 a5651d067dd4a1e979e0cefadf97ebf2832996f20364de3359214e723ff8f449

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