deno_bindgen icon indicating copy to clipboard operation
deno_bindgen copied to clipboard

feat: language agnostic rust codegen

Open eliassjogreen opened this issue 3 years ago • 2 comments

⚠️ WIP! ⚠️

This PR addresses #43, #4, #23 by implementing a new codegen in rust which in turn will be used by the macro and in the future extensions to deno bindgen which could enable for example c header support.

Todo:

  • [ ] Make the macro use the codegen crate
  • [ ] Update the CLI (it will have to be converted to rust to use the new codegen)
  • [x] Library loader
    • [x] Deno
    • [x] Plug
  • [x] Function generation
  • [ ] Into
    • [x] Primitives
    • [x] Pointers
    • [x] Buffers
    • [x] CString
    • [x] Type aliases
    • [x] Structs
    • [x] Tuples
    • [ ] Enums
    • [ ] Arrays
  • [ ] From
    • [x] Primitives
    • [x] Pointers
    • [x] Buffers
    • [x] CString
    • [x] Type aliases
    • [x] Structs
    • [x] Tuples
    • [ ] Enums
    • [ ] Arrays
  • [ ] JSON/serde fallback?
  • [x] Packed structs?
  • [ ] Automatic minification and or formatting?
  • [ ] Flexible array members?

Previous works, references and resources:

  • https://github.com/rustwasm/wasm-bindgen
  • https://doc.rust-lang.org/nomicon/other-reprs.html
  • https://github.com/rust-lang/rfcs/blob/master/text/2195-really-tagged-unions.md
  • https://github.com/sunshine-protocol/dart-bindgen
  • https://github.com/dart-lang/ffigen
  • https://github.com/denosaurs/plug
  • https://github.com/rust-lang/rust-bindgen
  • https://github.com/eqrion/cbindgen
  • https://github.com/infinyon/node-bindgen

eliassjogreen avatar Jan 12 '22 18:01 eliassjogreen

@eliassjogreen maybe the new CLI should be a custom cargo subcommand? https://github.com/rust-lang/cargo/wiki/Third-party-cargo-subcommands I want to avoid distributing native binaries.

littledivy avatar Jan 13 '22 02:01 littledivy

@littledivy Yep I agree, that sounds like a wise choice

eliassjogreen avatar Jan 13 '22 02:01 eliassjogreen

Closing because stale and merge conflicts.

littledivy avatar Jan 15 '23 03:01 littledivy