Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Unreleased

### Changed

- Generated helpers pass plain lists and indexed items and let RustQ borrow
them. This needs RustQ 1.0.0-rc.21.

## v0.7.0 - 2026-10-26

### Removed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ in Rust what is too large or too hot for Elixir. It needs
add it where you generate:

```elixir
{:rustq, "~> 1.0.0-rc.19", only: [:dev, :test], runtime: false}
{:rustq, "~> 1.0.0-rc.21", only: [:dev, :test], runtime: false}
```

Then generate from `rustq.exs`, and let `mix rustq.gen` write the file and
Expand Down
42 changes: 18 additions & 24 deletions codegen/kiwi_codec/rustler_generator/full/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,22 @@ if Code.ensure_loaded?(RustQ) do
cached_struct_keys(
env,
ref(keys_static),
ref(
array([
repeat keys do
key
end
])
)
[
repeat keys do
key
end
]
)

make_struct_from_arrays(
env,
keys,
ref(
array([
module_atom.to_term(env),
repeat fields do
field_expr.encode(env)
end
])
)
[
module_atom.to_term(env),
repeat fields do
field_expr.encode(env)
end
]
)
end
end
Expand Down Expand Up @@ -109,13 +105,11 @@ if Code.ensure_loaded?(RustQ) do
cached_struct_keys(
env,
ref(keys_static),
ref(
array([
repeat keys do
key
end
])
)
[
repeat keys do
key
end
]
)

values = default_struct_values(env, module_atom, keys.len() - 1)
Expand Down Expand Up @@ -161,11 +155,11 @@ if Code.ensure_loaded?(RustQ) do
field_id = decoder.read_var_uint()

if field_id == 0 do
make_struct_from_arrays(env, keys, ref(values))
make_struct_from_arrays(env, keys, values)
else
case fields.binary_search_by_key(field_id, fn field -> field.id end) do
{:ok, index} ->
field = fields.get(index).unwrap()
field = index(fields, index)

assign!(
index(values, field.index),
Expand Down
2 changes: 1 addition & 1 deletion codegen/kiwi_codec/rustler_generator/skip/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ if Code.ensure_loaded?(RustQ) do
:ok
else
case fields.binary_search_by_key(field_id, fn field -> field.id end) do
{:ok, index} -> kiwi_skip_kind(decoder, ref(index(fields, index).kind))
{:ok, index} -> kiwi_skip_kind(decoder, index(fields, index).kind)
{:error, _index} -> kiwi_unknown_field(decoder, definition_name, field_id)
end

Expand Down
2 changes: 1 addition & 1 deletion codegen/kiwi_codec/rustler_generator/sparse/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ if Code.ensure_loaded?(RustQ) do
else
case fields.binary_search_by_key(field_id, fn field -> field.id end) do
{:ok, index} ->
field = ref(index(fields, index))
field = index(fields, index)
keys.push(kiwi_atom(env, field.name).encode(env))
values.push(kiwi_field_value(env, decoder, field.repeated, field.decode))

Expand Down
2 changes: 1 addition & 1 deletion guides/native-decoders.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The generator needs RustQ, an optional dependency of KiwiCodec. Add it where you
generate, usually only in development and test:

```elixir
{:rustq, "~> 1.0.0-rc.19", only: [:dev, :test], runtime: false}
{:rustq, "~> 1.0.0-rc.21", only: [:dev, :test], runtime: false}
```

Generate from `rustq.exs`. `mix rustq.gen` writes the file, and
Expand Down
2 changes: 1 addition & 1 deletion integration/generator_consumer/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defmodule KiwiCodecGeneratorConsumer.MixProject do
defp deps do
[
{:kiwi_codec, path: System.fetch_env!("KIWI_CODEC_PACKAGE_PATH")},
{:rustq, "~> 1.0.0-rc.19", only: [:dev, :test], runtime: false}
{:rustq, "~> 1.0.0-rc.21", only: [:dev, :test], runtime: false}
]
end
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ defmodule KiwiCodec.MixProject do
# RUSTQ_PATH points at a local RustQ checkout, to try changes to it here.
defp rustq_dep do
case System.get_env("RUSTQ_PATH") do
nil -> {:rustq, "~> 1.0.0-rc.19", optional: true, runtime: false}
nil -> {:rustq, "~> 1.0.0-rc.21", optional: true, runtime: false}
path -> {:rustq, path: path, optional: true, runtime: false, override: true}
end
end
Expand Down
4 changes: 2 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"nimble_parsec": {:hex, :nimble_parsec, "1.4.2", "8efba0122db06df95bfaa78f791344a89352ba04baedd3849593bfce4d0dc1c6", [:mix], [], "hexpm", "4b21398942dda052b403bbe1da991ccd03a053668d147d53fb8c4e0efe09c973"},
"reach": {:hex, :reach, "2.8.4", "1158c2a43c7dc1a3a3531b751e97af7b4d770300b0cb2dd45500a48e63de5675", [:mix], [{:boxart, "~> 0.3.3", [hex: :boxart, repo: "hexpm", optional: true]}, {:ex_ast, "~> 0.12.0", [hex: :ex_ast, repo: "hexpm", optional: false]}, {:ex_dna, "~> 1.5", [hex: :ex_dna, repo: "hexpm", optional: true]}, {:libgraph, "~> 0.16.0", [hex: :libgraph, repo: "hexpm", optional: false]}, {:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: true]}, {:makeup_js, "~> 0.1", [hex: :makeup_js, repo: "hexpm", optional: true]}, {:quickbeam, "~> 0.10", [hex: :quickbeam, repo: "hexpm", optional: true]}], "hexpm", "06c01236ca0bec2c6a88cc1fbe240484958f76dc380418c7fea19eaffe804e44"},
"rustler": {:hex, :rustler, "0.38.0", "7a8906998ff0d28e3021c0a73264abcda719bda344b2e58307c6805b0f87c9b4", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "704c03c1bf66be12b031c5a389347b91c81c5cb819a24b068b0de36fe4a5652a"},
"rustq": {:hex, :rustq, "1.0.0-rc.19", "189a1d64df08cf501bc0a056b6b330b9a228ab056ff004bf29c5e123bed9d840", [:mix], [{:json_codec, "~> 0.1", [hex: :json_codec, repo: "hexpm", optional: false]}, {:nimble_options, "~> 1.1", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:reach, "~> 2.0", [hex: :reach, repo: "hexpm", optional: false]}, {:rustler, "~> 0.37", [hex: :rustler, repo: "hexpm", optional: false]}, {:toml_elixir, "~> 3.1", [hex: :toml_elixir, repo: "hexpm", optional: false]}], "hexpm", "8bafa85947a00a9b5c7a41fbca3db6c975f21184bc67f8867a32922134386ded"},
"rustq": {:hex, :rustq, "1.0.0-rc.21", "ebffffc0234b60f80229c705df42d573adf329eeb89e4e86812f2e384552563b", [:mix], [{:json_codec, "~> 0.1", [hex: :json_codec, repo: "hexpm", optional: false]}, {:nimble_options, "~> 1.1", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:reach, "~> 2.0", [hex: :reach, repo: "hexpm", optional: false]}, {:rustler, "~> 0.37", [hex: :rustler, repo: "hexpm", optional: false]}, {:toml_elixir, "~> 3.1", [hex: :toml_elixir, repo: "hexpm", optional: false]}], "hexpm", "89bcaee02cc21ee361904ac7ca4525365360839ca4ac27587acd45c305d0d9b1"},
"sourceror": {:hex, :sourceror, "1.13.0", "96bec2d8e5b183979fb70bd4d461b69db47fdc90871da599fababe76f7dae493", [:mix], [], "hexpm", "d72dd66dd2b82cc8e818b54ba0ab2ef0314c83ffcf231b1ad2ade00fa2ee3375"},
"toml_elixir": {:hex, :toml_elixir, "3.2.1", "3468b04dc54c0c33ffc05ec6996d5cb720a2e05192078fd0d9ec02b364ede9d8", [:mix], [], "hexpm", "64a723f91bb618dc53d11aff2167b4e55fbfdc3d8ff3b5030ecf52f345441629"},
"toml_elixir": {:hex, :toml_elixir, "3.3.0", "146cb7acca1e3a4f708da89a6f873035c1621d95a63e0ae532030e2bf8005c29", [:mix], [], "hexpm", "121a9e9f95e3c29b067abae64d303ec0649ad0998c71232b5651bd5600d4e093"},
"varint": {:hex, :varint, "1.6.0", "7bced828599b2eb84491a9f067f8a5a67fc35a946d3b7582278083c7fd434b00", [:mix], [], "hexpm", "2b4f4a20650aeebe993a70b03bb99571bcbddc27c361322c28b586d8a772ce4e"},
}
1 change: 0 additions & 1 deletion test/kiwi_codec/rustler_generator_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ defmodule KiwiCodec.RustlerGenerator.NativeTest do
@moduletag timeout: 600_000

@prefix "KiwiCodec.NativeTest.Schema"
@runtime KiwiCodec.RustlerGenerator.Decoder.source()

@schema """
enum Kind {
Expand Down
Loading