metacall / dlang-port

DLang wrapper for MetaCall, a library for providing inter-language foreign function interface calls.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

M E T A C A L L

M E T A C A L L

A library for providing inter-language foreign function interface calls

Abstract

METACALL is a library that allows calling functions, methods or procedures between programming languages. With METACALL you can transparently execute code from / to any programming language, for example, call Python code from NodeJS.

Install

Install MetaCall binaries first (click here for additional info about the install script):

bash <(curl -sL https://raw.githubusercontent.com/metacall/install/master/install.sh)

Then install MetaCall Dub package:

dub add metacall

Example

sum.py

def sum(a, b):
  return a + b

main.d

import std.stdio;
import std.variant;
import metacall; // Import MetaCall

int main()
{
	dmetacall_initialize();
	string[] scripts = [
		"script.py"
	];
	dmetacall_load_from_file("py",scripts);
	Variant ret = dmetacall!(int,int)("add",1,2);
	writefln("add(1,2) = %d",ret.get!(long)); // 3
	dmetacall_destroy();
	return 0;
}

Testing

In order to test you'll have to run dub add-local .. in the test folder.

About

DLang wrapper for MetaCall, a library for providing inter-language foreign function interface calls.

License:Apache License 2.0


Languages

Language:D 99.5%Language:Python 0.5%