{"id":19647810,"url":"https://github.com/chances/wasmer-d","last_synced_at":"2025-07-11T23:40:59.396Z","repository":{"id":55114610,"uuid":"324009622","full_name":"chances/wasmer-d","owner":"chances","description":"WebAssembly runtime for D","archived":false,"fork":false,"pushed_at":"2021-01-12T16:16:39.000Z","size":201,"stargazers_count":19,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T09:24:47.782Z","etag":null,"topics":["wasm","wasmer"],"latest_commit_sha":null,"homepage":"https://chances.github.io/wasmer-d","language":"D","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/chances.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["chances"],"patreon":"chances","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-12-23T21:59:06.000Z","updated_at":"2024-06-04T07:15:06.000Z","dependencies_parsed_at":"2022-08-14T12:30:25.489Z","dependency_job_id":null,"html_url":"https://github.com/chances/wasmer-d","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chances%2Fwasmer-d","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chances%2Fwasmer-d/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chances%2Fwasmer-d/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chances%2Fwasmer-d/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chances","download_url":"https://codeload.github.com/chances/wasmer-d/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251338767,"owners_count":21573609,"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":["wasm","wasmer"],"created_at":"2024-11-11T14:46:07.456Z","updated_at":"2025-04-28T15:32:09.104Z","avatar_url":"https://github.com/chances.png","language":"D","funding_links":["https://github.com/sponsors/chances","https://patreon.com/chances"],"categories":[],"sub_categories":[],"readme":"# wasmer-d\n\n[![DUB Package](https://img.shields.io/dub/v/wasmer.svg)](https://code.dlang.org/packages/wasmer)\n[![wasmer-d CI](https://github.com/chances/wasmer-d/workflows/wasmer-d%20CI/badge.svg)](https://github.com/chances/wasmer-d/actions)\n[![codecov](https://codecov.io/gh/chances/wasmer-d/branch/master/graph/badge.svg?token=U6BqigvJI6)](https://codecov.io/gh/chances/wasmer-d)\n\nD bindings to [wasmer](https://wasmer.io/), a standalone WebAssembly runtime for running WebAssembly outside of the browser.\n\nAlso includes an idiomatic D wrapper of the [Wasmer Runtime C API](https://github.com/wasmerio/wasmer/tree/master/lib/c-api#readme).\n\n## Usage\n\n```json\n\"dependencies\": {\n    \"wasmer\": \"0.2.0\"\n}\n```\n\nSee the official [Wasmer Runtime C API](https://github.com/wasmerio/wasmer/tree/master/lib/c-api#readme) documentation.\n\n### Run a WebAssembly Module\n\nSum function in a WebAssembly [text format](https://webassembly.github.io/spec/core/text/index.html) module:\n\n```d\nconst string wat_sum_module =\n  \"(module\\n\" ~\n  \"  (type $sum_t (func (param i32 i32) (result i32)))\\n\" ~\n  \"  (func $sum_f (type $sum_t) (param $x i32) (param $y i32) (result i32)\\n\" ~\n  \"    local.get $x\\n\" ~\n  \"    local.get $y\\n\" ~\n  \"    i32.add)\\n\" ~\n  \"  (export \\\"sum\\\" (func $sum_f)))\";\n\nauto engine = new Engine();\nauto store = new Store(engine);\nauto module_ = Module.from(store, wat_sum_module);\nassert(engine.valid \u0026\u0026 store.valid \u0026\u0026 module_.valid, \"Could not load module!\");\n\nauto instance = new Instance(store, module_);\nassert(instance.valid, \"Could not instantiate module!\");\n\nassert(instance.exports[0].name == \"sum\");\nauto sumFunc = Function.from(instance.exports[0]);\nassert(sumFunc.valid, \"Could not load exported 'sum' function!\");\n\nValue[] results;\nassert(sumFunc.call([new Value(3), new Value(4)], results), \"Error calling the `sum` function!\");\nassert(results.length == 1 \u0026\u0026 results[0].value.of.i32 == 7);\n```\n\n### Import a D Function into a WebAssembly Module\n\n```d\nconst string wat_callback_module =\n  \"(module\" ~\n  \"  (func $print (import \\\"\\\" \\\"print\\\") (param i32) (result i32))\" ~\n  \"  (func (export \\\"run\\\") (param $x i32) (param $y i32) (result i32)\" ~\n  \"    (call $print (i32.add (local.get $x) (local.get $y)))\" ~\n  \"  )\" ~\n  \")\";\n\nauto engine = new Engine();\nauto store = new Store(engine);\nauto module_ = Module.from(store, wat_callback_module);\nassert(module_.valid, \"Error compiling module!\");\n\nauto print = (Module module_, int value) =\u003e {\n  return value;\n}();\nauto imports = [new Function(store, module_, print.toDelegate).asExtern];\nauto instance = module_.instantiate(imports);\nassert(instance.valid, \"Could not instantiate module!\");\n\nauto runFunc = Function.from(instance.exports[0]);\nassert(instance.exports[0].name == \"run\" \u0026\u0026 runFunc.valid, \"Failed to get the `run` function!\");\n\nauto three = new Value(3);\nauto four = new Value(4);\nValue[] results;\nassert(runFunc.call([three, four], results), \"Error calling the `run` function!\");\nassert(results.length == 1 \u0026\u0026 results[0].value.of.i32 == 7);\n\ndestroy(three);\ndestroy(four);\ndestroy(instance);\ndestroy(module_);\n```\n\n## License\n\n[MIT Licence](https://opensource.org/licenses/MIT)\n\nCopyright \u0026copy; 2020-2021 Chance Snow. All rights reserved.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchances%2Fwasmer-d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchances%2Fwasmer-d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchances%2Fwasmer-d/lists"}