Skip to content

Commit

Permalink
extract codegen into macro-rules macros (#185)
Browse files Browse the repository at this point in the history
* extract a `setup_class` macro

The procedural macro now generates a call to
`setup_class!` which generates the actual code.

* copious comments

* move constructor definition to a macro-rules macro

* introduce setup_constructor macro

* add a devcontainer

* wip

* extract `setup_op_method`

* extract `setup_obj_method`

* extract `setup_static_method` into a macro

* extract `setup_inherent_object_method`

* extract setup_static_field_getter

* pass in "token tree" description of java type

We used to process types in many ways and pass
in a number of various. We now generate most of
those in declarative macro-rules logic in
`java_types.rs` so that we can just pass in
token tree description of the java type and
let the rest of the code work.

* move jni field function to macro-rules

* extract `jni_call_fn` into macro-rules

* extract `jni_static_call_fn` to macro-rules

* extract `prepare_inputs` into macro-rules

This lets us avoid the grodiness of having
to pass in the self identifier.

* break out java-types macros into their own files

makes it easier to find them.

also, improve comments.

* document macro-if and move to separate file

---------

Co-authored-by: Niko Matsakis <[email protected]>
  • Loading branch information
nikomatsakis and Niko Matsakis authored Oct 1, 2024
1 parent ea24ff7 commit 0a81378
Show file tree
Hide file tree
Showing 30 changed files with 1,487 additions and 1,105 deletions.
36 changes: 36 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
{
"name": "Rust",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bullseye",
"features": {
"ghcr.io/devcontainers/features/java:1": {},
"ghcr.io/mikaello/devcontainer-features/kotlinc:1": {},
"ghcr.io/guiyomh/features/just:0": {}
}

// Use 'mounts' to make the cargo cache persistent in a Docker Volume.
// "mounts": [
// {
// "source": "devcontainer-cargo-cache-${devcontainerId}",
// "target": "/usr/local/cargo",
// "type": "volume"
// }
// ]

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "rustc --version",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["duchess-reflect"]
members = ["duchess-reflect", "macro-rules"]

[workspace.package]
version = "0.3.0"
Expand All @@ -20,6 +20,7 @@ readme = "README.md"
[dependencies]
derive_more = "0.99.17"
duchess-macro = { path = "macro", version = "0.3.0" }
duchess-macro-rules = { version = "0.3.0", path = "macro-rules" }
jni-sys = "0.3.0"
cesu8 = "1.1.0"
once_cell = "1.17.1"
Expand All @@ -29,6 +30,7 @@ java-locator = { version = "0.1.3", optional = true }
libloading = { version = "0.8.0", optional = true }
derive-where = "1.2.1"


[features]
default = ["dylibjvm"]
dylibjvm = ["java-locator", "libloading"]
Expand Down
Loading

0 comments on commit 0a81378

Please sign in to comment.