{"id":23213759,"url":"https://github.com/metaffi/plugin-sdk","last_synced_at":"2025-06-23T19:33:30.243Z","repository":{"id":165282978,"uuid":"349368171","full_name":"MetaFFI/plugin-sdk","owner":"MetaFFI","description":"SDK for OpenFFI plugins","archived":false,"fork":false,"pushed_at":"2024-08-24T20:14:11.000Z","size":367,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-30T09:28:37.128Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","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":"2021-03-19T09:30:10.000Z","updated_at":"2024-08-18T04:56:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"ee6689e9-9f6b-4663-a7a6-153430d8646f","html_url":"https://github.com/MetaFFI/plugin-sdk","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MetaFFI%2Fplugin-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MetaFFI%2Fplugin-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MetaFFI%2Fplugin-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MetaFFI%2Fplugin-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MetaFFI","download_url":"https://codeload.github.com/MetaFFI/plugin-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247339161,"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.245Z","updated_at":"2025-04-05T13:11:33.859Z","avatar_url":"https://github.com/MetaFFI.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"The following readme explains how to use the provided SDK to implement a new language support for MetaFFI.\n\nUsing the SDK is not mandatory, as the sole requirement is to implement the interfaces `idl_plugin_interface.h`, `language_plugin_interface.h` and `runtime_plugin_interface.h` in anyway the developer see fit.\n\n# Legend\n* H - Mandatory for host\n* G - Mandatory for guest\n* OH - Optional for host\n* OG - Optional for guest\n\n# Compiler\nThe compilers plugin compiles MetaFFI IDL to either host language code or guest language code to provide access to the MetaFFI system from the host language, or from MetaFFI system to the guest language. A new language support does not have to implement both guest and host.\n\nThe plugin main (`PluginMain.go`) exports a C function called `void init_plugin(void)`, which MetaFFI compiler uses to initialize the compiler plugin. A typical `PluginMain.go` would be:\n\n```go\npackage main\n\nimport (\n\t\"github.com/MetaFFI/plugin-sdk/compiler/go\"\n)\n\nimport \"C\"\n\n//export init_plugin\nfunc init_plugin() {\n\tcompiler.PluginMain = compiler.NewLanguagePluginMain(NewHostCompiler(), NewGuestCompiler())\n}\n\n//--------------------------------------------------------------------\nfunc main() {}\n\n//--------------------------------------------------------------------\n```\n\nThe line `compiler.PluginMain = compiler.NewLanguagePluginMain` creates an object for MetaFFI providing the objects to use for compilation in MetaFFI. The compilers must implement the following interfaces:\n```google go\ntype GuestCompiler interface {\n\tCompile(definition *IDL.IDLDefinition, outputDir string, outputFilename string, blockName string, blockCode string) (err error)\n}\n\ntype HostCompiler interface {\n\tCompile(definition *IDL.IDLDefinition, outputDir string, outputFilename string, hostOptions map[string]string) (err error)\n}\n```\n## Guest Compiler (G)\nLet's examine `GuestCompiler.Compile`:\n* `definition` - MetaFFI definition of the foreign entities\n* `outputDir` - Directory to write compiler output\n* `outputFilename` - Filename to write output. If empty, uses `definition.IDLSource`. If contains a coed block (using # delimiter), contains the code block name\n* `hostOptions` - Plugin specific options passed from MetaFFI CLI to the plugin\n\nThe function `NewGuestCompiler()` returns an instance of the object implementing the interface.\n\n## Host Compiler (H)\nLet's examine `HostCompiler.Compile`:\n* `definition` - MetaFFI definition of the foreign entities\n* `outputDir` - Directory to write compiler output\n* `outputFilename` - Filename to write output. If empty, uses `definition.IDLSource`. If contains a coed block (using # delimiter), contains the code block name \n* `blockName` - If IDL generated from source code within an embedded code block, this is the name of the block\n* `blockCode` - If IDL generated from source code within an embedded code block, this is the code of the block\n\nThe function `NewHostCompiler()` returns an instance of the object implementing the interface.\n\nThe steps a Host compiler `Compile` method usually are:\n* Generate code - generate the stubs from the host language to call MetaFFI system (to XLLR API)\n* (if applicable) Generate executable code for the host language. For example, for Java, the code can be compiled to a JAR file which is referenced by the Java to call the foreign entities\n* Write generated code (or executable code) to output file in output path\n\n# Runtime (G)\n\n\n# IDL (G)\n\n# Code Embedding (OG)\n\n# CDTS\n## MetaFFI Primitives (H,G)\n## Object Support (OG, OH)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetaffi%2Fplugin-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetaffi%2Fplugin-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetaffi%2Fplugin-sdk/lists"}