{"id":23213760,"url":"https://github.com/metaffi/metaffi.github.io","last_synced_at":"2026-01-20T02:28:14.065Z","repository":{"id":217107725,"uuid":"743100195","full_name":"MetaFFI/metaffi.github.io","owner":"MetaFFI","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-18T12:41:03.000Z","size":120,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-11T04:11:31.598Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TeX","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MetaFFI.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-14T10:33:04.000Z","updated_at":"2025-01-08T09:26:26.000Z","dependencies_parsed_at":"2024-11-18T13:49:28.551Z","dependency_job_id":"5049061f-e787-41be-97f9-4c4dfaf3b740","html_url":"https://github.com/MetaFFI/metaffi.github.io","commit_stats":null,"previous_names":["metaffi/metaffi.github.io"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MetaFFI%2Fmetaffi.github.io","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MetaFFI%2Fmetaffi.github.io/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MetaFFI%2Fmetaffi.github.io/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MetaFFI%2Fmetaffi.github.io/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MetaFFI","download_url":"https://codeload.github.com/MetaFFI/metaffi.github.io/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247339154,"owners_count":20923014,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-18T19:19:08.262Z","updated_at":"2026-01-20T02:28:14.058Z","avatar_url":"https://github.com/MetaFFI.png","language":"TeX","funding_links":[],"categories":[],"sub_categories":[],"readme":"MetaFFI is a Multilingual Indirect Interoperability System. It’s a clever solution to a common problem: how do we make different programming languages play nicely together?\n\nEach language has its strengths, and sometimes we need to harness those strengths in harmony. But here comes the challenge, how do we get these languages to talk to each other without all the low-level hassle?\n\nMetaFFI uses the concept of loading and using dynamic libraries, but expands it to any programming language module. Not just binary.\nIt can be a Python package, a Go module, or even a Java class.\n\nTo be a bit more technical, MetaFFI uses Foreign Function Interface (FFI) and embedding mechanisms to link the runtimes together using a C-based Hub.\nIt’s like a bridge that connects different programming languages, allowing them to communicate and share data.\n\nThere is no virtual machine, interpreters or re-compilation envolved - each programming language runs in its own original runtime.\n\n\n## Installation\n\n\nInstaller is available at:\n\n[`v0.3.0 - Windows`](https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-installer-0.3.0.exe)\n[`v0.3.0 - Ubuntu`](https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-installer-0.3.0)\n\n**-s**: To install in silent mode with default installation directory.\u003cbr\u003e\n\nTo uninstall, execute _uninstall_ executable in the installation directory.\n\nInstallers tested on: Windows 11, Windows Server 2022, Ubuntu 22.04\n\nWindows CMD: `curl -LO https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-installer-0.3.0.exe \u0026\u0026 metaffi-installer-0.3.0.exe -s`\n\nWindows PowerShell: `Invoke-WebRequest -Uri https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-installer-0.3.0.exe -OutFile metaffi-installer.exe; Start-Process .\\metaffi-installer.exe -ArgumentList '-s' -Wait`\n\nUbuntu bash: `wget https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-installer-0.3.0 \u0026\u0026 chmod +x metaffi-installer-0.3.0 \u0026\u0026 ./metaffi-installer-0.3.0 -s`\n\n\n### Plugin installers:\n* Python 3 - [Windows](https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-plugin-installer-0.3.0-python311.exe), [Ubuntu](https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-plugin-installer-0.3.0-python311)\n\t* PIP package is available at `pip3 install metaffi-api`\n\t* Tested with Python 3.11\n    * Should work with Python \u003e=3.11, but not tested with installer\n    * Should work with Python \u003c3.10, but not tested\n* Go - [Windows](https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-plugin-installer-0.3.0-go.exe), [Ubuntu](https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-plugin-installer-0.3.0-go)\n  * Currently, supports Go 1.23.1 - will be support any go version in near future\n* OpenJDK - [Windows](https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-plugin-installer-0.3.0-openjdk.exe), [Ubuntu](https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-plugin-installer-0.3.0-openjdk)\n\t* JAR ships with the installer\n    * Tested with OpenJDK 21\n    * Tested with OpenJDK 11 without testing installer\n\nWindows CMD: `curl -LO https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-plugin-installer-0.3.0-python311.exe \u0026\u0026 metaffi-plugin-installer-0.3.0-python311.exe \u0026\u0026 curl -LO https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-plugin-installer-0.3.0-go.exe \u0026\u0026 metaffi-plugin-installer-0.3.0-go.exe \u0026\u0026 curl -LO https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-plugin-installer-0.3.0-openjdk.exe \u0026\u0026 metaffi-plugin-installer-0.3.0-openjdk.exe`\n\nWindows PowerShell: `Invoke-WebRequest https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-plugin-installer-0.3.0-python311.exe -OutFile python311.exe; Start-Process .\\python311.exe -Wait; Invoke-WebRequest https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-plugin-installer-0.3.0-go.exe -OutFile go.exe; Start-Process .\\go.exe -Wait; Invoke-WebRequest https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-plugin-installer-0.3.0-openjdk.exe -OutFile openjdk.exe; Start-Process .\\openjdk.exe -Wait`\n\nUbuntu bash: `wget https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-plugin-installer-0.3.0-python311 -O python311 \u0026\u0026 chmod +x python311 \u0026\u0026 ./python311 \u0026\u0026 wget https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-plugin-installer-0.3.0-go -O go \u0026\u0026 chmod +x go \u0026\u0026 ./go \u0026\u0026 wget https://github.com/MetaFFI/metaffi-root/releases/download/v0.3.0/metaffi-plugin-installer-0.3.0-openjdk -O openjdk \u0026\u0026 chmod +x openjdk \u0026\u0026 ./openjdk`\n\n### What does the MetaFFI installer do?\n#### Windows\n* Checks for prerequisites for current programming languages support\n\t* Installer offers to install missing dependencies if somehthing is missing (automatic in silent mode)\n* Copies the MetaFFI files to installation directory (default is `%USERPROFILE%\\metaffi`)\n* Add installation directory to PATH environment variables\n* Adds `METAFFI_HOME` environment variable pointing at the installation directory\n\n#### Linux\n* Checks for prerequisites for current programming languages support\n\t* Installer offers to install missing dependencies if somehthing is missing (automatic in silent mode)\n* Copies the MetaFFI files to installation directory (default is `/usr/local/metaffi`)\n* Adds `METAFFI_HOME` environment variable to `~/.profile` pointing at the installation directory \n\n## Pre-Installed Docker Container\nUbuntu 22.04: `docker pull tscs/metaffi-u2204:0.3.0`\nWindows server core 2022: `docker pull tscs/metaffi-win-core2022:0.3.0`\n\n## Distribute Binaries\nYou can distribute MetaFFI binaries with your application (under the license terms). To use MetaFFI on the target machine, you can either install MetaFFI using the installer, or place the MetaFFI directory (without the executable) within your application directory.\n\nMake sure to set `METAFFI_HOME` environment variable. You can set it in your application before your code uses MetaFFI. On windows, also add to `PATH` environment variable.\n\n## (Currently) Supported Programming Langauges\n\n|Language |     Supported     |              Fully Tested With Installer               |\n|:--------|:-----------------:|:------------------------------------------------------:|\n| Go |   From v1.22.7    |                   v1.18 \u0026rarr; v1.23                   |\n| JVM Languages | JNI supported JVM | OpenJDK11/21 x64\u003cbr\u003eMicrosoft OpenJDK11/21 Hotspot JVM \n| Python3 |       v3.x        |                         v3.11                          |\n\n* Note: Due to a [bug](https://github.com/golang/go/issues/58542) in Go, using Go \u0026rarr; OpenJDK in **Windows**, causes the process to crash. Fix is expected in Go1.23. In the meantime, MetaFFI install provides a temporary patch to fix the issue.\n\n* Lack of support is not due to system limitations, but time. If you like the project, consider to contribute [add a new language support](add-language-plugin) 😊\n\n## (Currently) Supported Operating Systems\n\n| Operating System | Supported Versions | Tested with installer |\n|:---|:------------------:|:---------------------:|\n| Windows |         \u003e7         |          11           |\n| Ubuntu |       \u003e20.04       |         22.04         |\n\n* Lack of support is not due to system limitations, but time. If you like the project, consider to contribute and [add a new language support](add-language-plugin) 😊\n\n## Build From Source\nMetaFFI uses `CMake` build system and `vcpkg` for dependency management.\nThe build system is cross-platform and should work on any platform supported by CMake.\n\nAuthor uses CLion IDE for the core development, but you can use any IDE that supports CMake.\n\n1. Install CMake and VCPKG\n2. Pull https://github.com/MetaFFI/metaffi-root\n3. Run the CMake configuration and build\n4. CMake script will pull the required dependencies\n\nThe GitHub project contains:\n* MetaFFI Core\n* Python3 Plugin\n* JVM Plugin\n* Go Plugin\n\n## MetaFFI Paper\nThe paper ([link](https://arxiv.org/abs/2408.14175)) discusses the research and internals of MetaFFI. Sections for academic audiance or technical audiance are explicitly marked, as explained in the end of the introduction section.\n\n## Documentation\n\nThe following provide documentation and explaination about the following MetaFFI APIs:\n* GO [API](usage/go/) documentation and [Entity Path](usage/entity_path/go/) documentation\n* JVM [API](usage/jvm/) documentation and [Entity Path](usage/entity_path/jvm/) documentation\n* Python3 [API](usage/python3/) documentation and [Entity Path](usage/entity_path/python3/) documentation\n\n## Two Usage Examples\n\n`log4j` from Python3 ([link](https://github.com/MetaFFI/lang-plugin-python3/blob/main/api/tests/extended/openjdk/log4j/log4j_test.py)):\n\n```python\n# load JVM\nruntime = metaffi.metaffi_runtime.MetaFFIRuntime('openjdk')\n\n# load log4j\nlog4j_api_module = runtime.load_module('log4j-api-2.21.1.jar;log4j-core-2.21.1.jar')\n\n# load getLogger() method to get a new logger\ngetLogger = log4j_api_module.load_entity('class=org.apache.logging.log4j.LogManager,callable=getLogger', \n\t\t[new_metaffi_type_info(metaffi_string8_type)], \n\t\t[new_metaffi_type_info(metaffi_handle_type, 'org.apache.logging.log4j.Logger')])\n\n# load error() method in logger\nperror = log4j_api_module.load_entity('class=org.apache.logging.log4j.Logger,callable=error,instance_required',\n\t[new_metaffi_type_info(MetaFFITypes.metaffi_handle_type),\n\tnew_metaffi_type_info(MetaFFITypes.metaffi_string8_type)],\n\tNone)\n\n# create logger with getLogger()\nlogger = getLogger('pylogger')\nperror(logger, 'Logging error from python!')\n\nruntime.release_runtime_plugin()\n```\n\nMore examples from [Python3](https://github.com/MetaFFI/lang-plugin-python3/tree/v0.2.0/api/tests), [Java](https://github.com/MetaFFI/lang-plugin-openjdk/tree/v0.2.0/api/tests) and [Go](https://github.com/MetaFFI/lang-plugin-go/tree/v0.2.0/api/tests).\n\n\n### Example using a compiler\nSome programming languages, like Go, need some help from MetaFFI to build a module available to other programming languages. For that, MetaFFI also provides a compiler to build a MetaFFI enabled module.\n\nFor example, assume \u003cspan style=\"font-family:courier\"\u003eTestMap.go\u003c/span\u003e:\n```go\nfunc NewTestMap() *TestMap{\n\treturn \u0026TestMap{ \n\t\tm: make(map[string]interface{}),\n\t\tName: \"TestMap Name\",\n\t}\n}\n\nfunc (this *TestMap) Set(k string, v interface{}){\n\tthis.m[k] = v\n}\n\nfunc (this *TestMap) Get(k string) interface{}{\n\tv := this.m[k]\n\treturn v\n}\n\nfunc (this *TestMap) Contains(k string) bool{\n\t_, found := this.m[k]\n\treturn found\n}\n```\n\nTo use it from other languages using MetaFFI, execute the MetaFFI compiler:\n\n`metaffi -c --idl TestMap.go -g`\n\nThis creates a dynamic library for TestMap (i.e. `.so` or `.dll`).\nTo use it, simply load the dynamic library using MetaFFI. Here's an example in Java using JVM MetaFFI API:\n```java\n\n// Load Go runtime\nMetaFFIRuntime runtime = new MetaFFIRuntime(\"go\");\nruntime.loadRuntimePlugin();\n\n// Load the compiled module (in this case, .dll in windows)\nMetaFFIModule module = runtime.loadModule(\"TestMap_MetaFFIGuest.dll\");\n\n// Load a function that creates an instance of TestMap\nmetaffi.Caller newTestMap = module.load(\"callable=NewTestMap\",\n\t\tnull,\n\t\tnew MetaFFITypeInfo[]{\n\t\t\t// returns MetaFFI Handle (i.e. handle to the object)\n\t\t\tnew MetaFFITypeInfo(MetaFFITypes.MetaFFIHandle)\n\t\t});\n\n// Load Set() method\nmetaffi.Caller testMapSet = module.load(\"callable=TestMap.Set,instance_required\",\n\t\tnew MetaFFITypeInfo[]{\n\t\t\t// 1st parameter is an instance of the object\n\t\t\tnew MetaFFITypeInfo(MetaFFITypes.MetaFFIHandle),\n\t\t\tnew MetaFFITypeInfo(MetaFFITypes.MetaFFIString8), // key\n\t\t\tnew MetaFFITypeInfo(MetaFFITypes.MetaFFIAny) // // value\n\t\t},\n\t\tnull); // no return values\n\n// Load Contains() method\nmetaffi.Caller testMapContains = module.load(\"callable=TestMap.Contains,instance_required\",\n\t\tnew MetaFFITypeInfo[]{ \n\t\t\tnew MetaFFITypeInfo(MetaFFITypes.MetaFFIHandle),\n\t\t\tnew MetaFFITypeInfo(MetaFFITypes.MetaFFIString8) // key\n\t\t},\n\t\tnew MetaFFITypeInfo[]{ \n\t\t\t// boolean return value\n\t\t\tnew MetaFFITypeInfo(MetaFFITypes.MetaFFIBool)\n\t\t});\n\n// Load Get() method\nmetaffi.Caller testMapGet = module.load(\"callable=TestMap.Get,instance_required\",\n\t\tnew MetaFFITypeInfo[]{\n\t\t\tnew MetaFFITypeInfo(MetaFFITypes.MetaFFIHandle),\n\t\t\tnew MetaFFITypeInfo(MetaFFITypes.MetaFFIString8) // key\n\t\t},\n\t\tnew MetaFFITypeInfo[]{\n\t\t\tnew MetaFFITypeInfo(MetaFFITypes.MetaFFIAny) // returned value\n\t\t});\n\n// Create new TestMap\n// call() method in the API returns Object[], as other languages\n// can return multiple return values. We will update the API for a more convenient usage.\nvar testMap = ((Object[])newTestMap.call())[0];\n\n// set into the map an array of strings:\ntestMapSet.call(testMap, \"key\", new ArrayList\u003c\u003e(Arrays.asList(\"one\", \"two\", \"three\")));\n\n// get the array list from the map:\nvar arr = testMapGet.call(testMap, \"key\");\nArrayList\u003cString\u003e list = (ArrayList\u003cString\u003e)arr[0];\n```\n\n## Finding a foreign entity - Entity Path\n\n*Entity path* refers to a string that represents the foreign entity within the loaded module.\n\nFor instance, in `C`, a module corresponds to a `.so/.dll` file, and the function path corresponds to the name of the exported function.\n\nHowever, in other languages or for other entities besides functions, a single name is insufficient. Hence, the function path consists of a list of key-value pairs or tags separated by commas: `key1=val1,tag1,...,...,tagN,keyN=valN`.\n\nEach plugin requires different keys and tags. Although the keys and tags are similar across plugins, they are not identical.\n\nThe following links provide the list of each runtime plugin:\n\n[Python3](/usage/entity_path/python3/), [Java Virtual Machine](/usage/entity_path/jvm/), [Go](/usage/entity_path/go/)\n\n\n## Bridging Language Boundaries - MetaFFI *XCall* and Capabilities-based calling convension\nThe XCall is the mechanism MetaFFI uses to facilitate cross-language calls. MetaFFI's agnostic approach ensures that each language remains unaware of the others, allowing for independent plugin development.\n\nXCall is a runtime-independent calling convention that uses Common Data Types (inspired by Microsoft's Variant and GTK gObject) to enable languages to call and use entities in other languages, even if they lack certain features. While the generic calling convention supports a wide range of cross-language calls, it can affect the performance. \u003c/br\u003eTherefore, XCall determines the calling convention used at runtime, based on the required capabilities. This allows MetaFFI to use the full-featured calling convention when necessary, a subset of the capabilities to improve performance, or revert completely to a direct function call when possible (like x64 calling convension), resulting in efficient cross-language interactions.\n\nFor more details, please refer to the MetaFFI paper.\n\nNote: The current version of MetaFFI always chooses the generic calling convention due to the differences between the initial languages implemented.\n\n## Report a bug\n\nFound a bug? You can report it [here](https://github.com/MetaFFI/metaffi-root/issues/new).\n\n\n## GitHub Projects\n\nThe [MetaFFI Project](https://github.com/MetaFFI/) on GitHub.com contains several repositories:\n* [MetaFFI Root](https://github.com/MetaFFI/metaffi-root) contains the SCons build system root (SConstruct), VSCode workspace file and the dev containers `devcontainer.json` files. To build from source, clone this.\n* [MetaFFI Core](https://github.com/MetaFFI/metaffi-core/) contains MetaFFI CLI tool, XLLR (Cross-Language Link Runtime), implementation of XCall (cross-call) and CDTs (Common Data Types)\n* [Python3 Plugin](https://github.com/MetaFFI/lang-plugin-python3) implements MetaFFI support for Python3 using *CTypes* and *CPython API*\n* [JVM Plugin](https://github.com/MetaFFI/lang-plugin-openjdk) implements support for OpenJDK using *JNI*\n* [Go Plugin](https://github.com/MetaFFI/lang-plugin-go) implements support for Go using *CGo*\n* [Installer](https://github.com/MetaFFI/metaffi-installer) implements the MetaFFI Python installer\n* [Containers](https://github.com/MetaFFI/containers) contain the Dockerfiles for the pre-installed containers\n* [metaffi.github.io](https://github.com/MetaFFI/metaffi.github.io) contains this GitHub pages website\n\n\n## Environment variable\n\n**METAFFI_HOME** environment variable is set to MetaFFI installation directory. On Windows, also set METAFFI_HOME to the PATH environment variable.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetaffi%2Fmetaffi.github.io","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetaffi%2Fmetaffi.github.io","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetaffi%2Fmetaffi.github.io/lists"}