Skip to content

Commit

Permalink
Update documentation and template
Browse files Browse the repository at this point in the history
  • Loading branch information
filmor committed Jun 6, 2024
1 parent ac4ef53 commit 713db84
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 117 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn add(a: i64, b: i64) -> i64 {
a + b
}

rustler::init!("Elixir.Math", [add]);
rustler::init!("Elixir.Math");
```

#### Minimal Supported Rust Version (MSRV)
Expand Down
2 changes: 1 addition & 1 deletion rustler/src/serde/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ in a better way and allow more Erlang-y configurations).
use rustler::{self, Encoder, SerdeTerm};
use serde::{Serialize, Deserialize};
rustler::init!("Elixir.SerdeNif", [readme]);
rustler::init!("Elixir.SerdeNif");
// NOTE: to serialize to the correct Elixir record, you MUST tell serde to
// rename the variants to the full Elixir record module atom.
Expand Down
17 changes: 1 addition & 16 deletions rustler_benchmarks/native/benchmark/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,4 @@ mod nif_record;
mod nif_struct;
mod nif_various;

rustler::init!(
"Elixir.Benchmark",
[
nif_struct::benchmark,
nif_record::benchmark,
nif_various::encode_tagged_enum,
nif_various::decode_tagged_enum,
nif_various::decode_struct,
nif_various::decode_struct_string,
nif_various::decode_string,
nif_various::decode_term,
nif_various::void,
nif_various::encode_atom,
nif_various::compare_atom
]
);
rustler::init!("Elixir.Benchmark");
2 changes: 1 addition & 1 deletion rustler_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ enum RustlerAttr {
/// true
/// }
///
/// rustler::init!("Elixir.Math", [add, sub, mul, div], load = load);
/// rustler::init!("Elixir.Math", load = load);
/// ```
#[proc_macro]
pub fn init(input: TokenStream) -> TokenStream {
Expand Down
2 changes: 1 addition & 1 deletion rustler_mix/priv/templates/basic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ fn add(a: i64, b: i64) -> i64 {
a + b
}

rustler::init!("<%= native_module %>", [add]);
rustler::init!("<%= native_module %>");
2 changes: 1 addition & 1 deletion rustler_tests/native/dynamic_load/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ fn build_path_buf(priv_path: &[u8]) -> PathBuf {
PathBuf::from(priv_path)
}

rustler::init!("Elixir.DynamicData", [get_dataset], load = load);
rustler::init!("Elixir.DynamicData", load = load);
2 changes: 1 addition & 1 deletion rustler_tests/native/rustler_bigint_test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ pub fn add(a: BigInt, b: BigInt) -> NifResult<BigInt> {
Ok(a.checked_add(&b).unwrap())
}

rustler::init!("Elixir.RustlerBigintTest", [echo, add_one, add]);
rustler::init!("Elixir.RustlerBigintTest");
97 changes: 2 additions & 95 deletions rustler_tests/native/rustler_test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,101 +16,8 @@ mod test_term;
mod test_thread;
mod test_tuple;

rustler::init!(
"Elixir.RustlerTest",
[
test_primitives::add_u32,
test_primitives::add_i32,
test_primitives::echo_u8,
test_primitives::option_inc,
test_primitives::erlang_option_inc,
test_primitives::result_to_int,
test_primitives::echo_u128,
test_primitives::echo_i128,
test_list::sum_list,
test_list::make_list,
test_local_pid::compare_local_pids,
test_local_pid::are_equal_local_pids,
test_term::term_debug,
test_term::term_eq,
test_term::term_cmp,
test_term::term_internal_hash,
test_term::term_phash2_hash,
test_term::term_type,
test_map::sum_map_values,
test_map::map_entries,
test_map::map_entries_reversed,
test_map::map_from_arrays,
test_map::map_from_pairs,
test_map::map_generic,
test_resource::resource_make,
test_resource::resource_set_integer_field,
test_resource::resource_get_integer_field,
test_resource::resource_make_immutable,
test_resource::resource_immutable_count,
test_resource::resource_make_with_binaries,
test_resource::resource_make_binaries,
test_atom::atom_to_string,
test_atom::atom_equals_ok,
test_atom::binary_to_atom,
test_atom::binary_to_existing_atom,
test_binary::make_shorter_subbinary,
test_binary::parse_integer,
test_binary::binary_new,
test_binary::owned_binary_new,
test_binary::new_binary_new,
test_binary::unowned_to_owned,
test_binary::realloc_shrink,
test_binary::realloc_grow,
test_binary::encode_string,
test_binary::decode_iolist,
test_thread::threaded_fac,
test_thread::threaded_sleep,
test_env::send_all,
test_env::send,
test_env::whereis_pid,
test_env::is_process_alive,
test_env::sublists,
test_codegen::tuple_echo,
test_codegen::record_echo,
test_codegen::map_echo,
test_codegen::exception_echo,
test_codegen::struct_echo,
test_codegen::unit_enum_echo,
test_codegen::tagged_enum_1_echo,
test_codegen::tagged_enum_2_echo,
test_codegen::tagged_enum_3_echo,
test_codegen::tagged_enum_4_echo,
test_codegen::untagged_enum_echo,
test_codegen::untagged_enum_with_truthy,
test_codegen::untagged_enum_for_issue_370,
test_codegen::newtype_echo,
test_codegen::tuplestruct_echo,
test_codegen::newtype_record_echo,
test_codegen::tuplestruct_record_echo,
test_dirty::dirty_cpu,
test_dirty::dirty_io,
test_range::sum_range,
test_error::bad_arg_error,
test_error::atom_str_error,
test_error::raise_atom_error,
test_error::raise_term_with_string_error,
test_error::raise_term_with_atom_error,
test_error::term_with_tuple_error,
test_nif_attrs::can_rename,
test_tuple::add_from_tuple,
test_tuple::add_one_to_tuple,
test_tuple::join_tuple_elements,
test_tuple::maybe_add_one_to_tuple,
test_tuple::add_i32_from_tuple,
test_tuple::greeting_person_from_tuple,
test_codegen::reserved_keywords::reserved_keywords_type_echo,
test_codegen::generic_types::generic_struct_echo,
test_codegen::generic_types::mk_generic_map,
test_path::append_to_path,
],
load = load
);
// Intentional usage of the explicit form (in an "invalid" way, listing a wrong set of functions) to ensure that the warning stays alive
rustler::init!("Elixir.RustlerTest", [deprecated, usage], load = load);

fn load(env: rustler::Env, _: rustler::Term) -> bool {
test_resource::on_load(env);
Expand Down

0 comments on commit 713db84

Please sign in to comment.