{"id":16186941,"url":"https://github.com/robloach/wren-bind","last_synced_at":"2026-04-02T02:17:10.192Z","repository":{"id":66036616,"uuid":"369106379","full_name":"RobLoach/wren-bind","owner":"RobLoach","description":null,"archived":false,"fork":false,"pushed_at":"2021-05-21T22:33:54.000Z","size":13,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-02T01:41:36.774Z","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/RobLoach.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-05-20T06:37:11.000Z","updated_at":"2025-04-08T23:15:59.000Z","dependencies_parsed_at":"2023-02-22T22:01:39.828Z","dependency_job_id":null,"html_url":"https://github.com/RobLoach/wren-bind","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RobLoach/wren-bind","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobLoach%2Fwren-bind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobLoach%2Fwren-bind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobLoach%2Fwren-bind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobLoach%2Fwren-bind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobLoach","download_url":"https://codeload.github.com/RobLoach/wren-bind/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobLoach%2Fwren-bind/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31294487,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T01:43:37.129Z","status":"online","status_checked_at":"2026-04-02T02:00:08.535Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-10T07:19:53.304Z","updated_at":"2026-04-02T02:17:10.172Z","avatar_url":"https://github.com/RobLoach.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wren-bind\n\nProvides a registry to easily bind multiple compiled Wren modules.\n\n## Usage\n\n1. This is a single-header library, so define `WREN_BIND_IMPLEMENTATION` in one of your `.c` source files when including *wren-bind.h*:\n\n    ``` c\n    #define WREN_BIND_IMPLEMENTATION\n    #include \"wren-bind.h\"\n    ```\n\n2. Define your modules with the `WrenModule` struct:\n\n    ``` c\n    void FooBar(WrenVM* vm) {\n      double a = wrenGetSlotDouble(vm, 1);\n      double b = wrenGetSlotDouble(vm, 2);\n      wrenSetSlotDouble(vm, 0, a + b);\n    }\n\n    WrenForeignMethodFn FooModuleMethod(WrenVM* vm, const char* module,\n        const char* className, bool isStatic, const char* signature) {\n      if (strcmp(module, \"Foo\") == 0) {\n        if (strcmp(className, \"Foo\") == 0) {\n          if (isStatic \u0026\u0026 strcmp(signature, \"bar(_,_)\") == 0) {\n            return FooBar;\n          }\n        }\n      }\n\n      return NULL;\n    }\n\n    WrenModule Foo() {\n      WrenModule module;\n      module.name = \"Foo\";\n      module.code = \"\\n\\\n        class Foo {\\\n          foreign static bar(a, b)\\\n        }\\\n      \";\n      module.methodFunction = FooModuleMethod;\n      module.classFunction = NULL;\n      return module;\n    }\n    ```\n\n3. Register the module to the VM using the `wrenBind()` method:\n    ``` c\n    WrenVM* vm = wrenNewVM(\u0026config);\n\n    WrenModule foo = Foo();\n    wrenBind(vm, \u0026foo);\n    ```\n\n4. Alternatively, you can bind the module by binding the parameters with `wrenBindModule()`:\n    ``` c\n    WrenVM* vm = wrenNewVM(\u0026config);\n\n    wrenBindModule(vm, \"Foo\", code, FooModuleMethod, NULL);\n    ```\n\n5. Once bound, you'll be able to use the Foo module from Wren:\n    ``` js\n    import \"Foo\" for Foo\n    System.print(Foo.bar(5, 8))\n    ```\n\n## Notes\n\n- Overrides `vm.bindForeignMethodFn` to manage multiple modules for foreign methods\n- Overrides `vm.bindForeignClassFn` to manage multiple modules for classes\n- Stores module data within `vm.config.userData`\n\n## License\n\n*wren-bind* is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobloach%2Fwren-bind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobloach%2Fwren-bind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobloach%2Fwren-bind/lists"}