Skip to content

Commit

Permalink
bump to 0.5.0, resource related nifs changed
Browse files Browse the repository at this point in the history
There are const/mut changes in the resource nifs to better reflect
the intended meaning in Rust.  ErlNifResourceType and resource pointers become const
because they can be safely referenced from multiple threads (interior mutation
still permitted of course.)
  • Loading branch information
goertzenator committed Jun 28, 2016
1 parent 13c20e3 commit f801f2e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "erlang_nif-sys"
version = "0.4.3"
version = "0.5.0"
authors = ["Daniel Goertzen <daniel.goertzen@gmail.com>"]
description = "Create Erlang NIF modules in Rust using the C NIF API."
documentation = "http://goertzenator.github.io/erlang_nif-sys/erlang_nif_sys/index.html"
Expand Down
16 changes: 8 additions & 8 deletions gen_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ api_list(Opts) -> [
{"ERL_NIF_TERM", "enif_make_tuple_from_array", "arg1: *mut ErlNifEnv, arr: *const ERL_NIF_TERM, cnt: c_uint"},
{"ERL_NIF_TERM", "enif_make_list_from_array", "arg1: *mut ErlNifEnv, arr: *const ERL_NIF_TERM, cnt: c_uint"},
{"c_int", "enif_is_empty_list", "arg1: *mut ErlNifEnv, term: ERL_NIF_TERM"},
{"*mut ErlNifResourceType", "enif_open_resource_type", "arg1: *mut ErlNifEnv, module_str: *const c_uchar, name_str: *const c_uchar, dtor: Option<extern \"C\" fn (arg1: *mut ErlNifEnv, arg2: *mut c_void)>, flags: ErlNifResourceFlags, tried: *mut ErlNifResourceFlags"},
{"*mut c_void", "enif_alloc_resource", "_type: *mut ErlNifResourceType, size: size_t"},
{"", "enif_release_resource", "obj: *mut c_void"},
{"ERL_NIF_TERM", "enif_make_resource", "arg1: *mut ErlNifEnv, obj: *mut c_void"},
{"c_int", "enif_get_resource", "arg1: *mut ErlNifEnv, term: ERL_NIF_TERM, _type: *mut ErlNifResourceType, objp: *mut *mut c_void"},
{"size_t", "enif_sizeof_resource", "obj: *mut c_void"},
{"*const ErlNifResourceType", "enif_open_resource_type", "arg1: *mut ErlNifEnv, module_str: *const c_uchar, name_str: *const c_uchar, dtor: Option<extern \"C\" fn (arg1: *mut ErlNifEnv, arg2: *mut c_void)>, flags: ErlNifResourceFlags, tried: *mut ErlNifResourceFlags"},
{"*mut c_void", "enif_alloc_resource", "_type: *const ErlNifResourceType, size: size_t"},
{"", "enif_release_resource", "obj: *const c_void"},
{"ERL_NIF_TERM", "enif_make_resource", "arg1: *mut ErlNifEnv, obj: *const c_void"},
{"c_int", "enif_get_resource", "arg1: *mut ErlNifEnv, term: ERL_NIF_TERM, _type: *const ErlNifResourceType, objp: *mut *const c_void"},
{"size_t", "enif_sizeof_resource", "obj: *const c_void"},
{"*mut c_uchar", "enif_make_new_binary", "arg1: *mut ErlNifEnv, size: size_t, termp: *mut ERL_NIF_TERM"},
{"c_int", "enif_is_list", "arg1: *mut ErlNifEnv, term: ERL_NIF_TERM"},
{"c_int", "enif_is_tuple", "arg1: *mut ErlNifEnv, term: ERL_NIF_TERM"},
Expand All @@ -181,8 +181,8 @@ api_list(Opts) -> [
{"ERL_NIF_TERM", "enif_make_copy", "dst_env: *mut ErlNifEnv, src_term: ERL_NIF_TERM"},
{"*mut ErlNifPid", "enif_self", "caller_env: *mut ErlNifEnv, pid: *mut ErlNifPid"},
{"c_int", "enif_get_local_pid", "env: *mut ErlNifEnv, arg1: ERL_NIF_TERM, pid: *mut ErlNifPid"},
{"", "enif_keep_resource", "obj: *mut c_void"},
{"ERL_NIF_TERM", "enif_make_resource_binary", "arg1: *mut ErlNifEnv, obj: *mut c_void, data: *const c_void, size: size_t"}
{"", "enif_keep_resource", "obj: *const c_void"},
{"ERL_NIF_TERM", "enif_make_resource_binary", "arg1: *mut ErlNifEnv, obj: *const c_void, data: *const c_void, size: size_t"}
] ++

case proplists:get_value(ulongsize, Opts) of
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ extern "C" fn native_add(env: *mut ErlNifEnv,
let mut a:c_int = uninitialized();
let mut b:c_int = uninitialized();
if argc == 2 &&
0 != enif_get_int(env, *args, &mut a) &&
0 != enif_get_int(env, *args, &mut a) &&
0 != enif_get_int(env, *args.offset(1), &mut b) {
enif_make_int(env, a+b)
}
Expand Down

0 comments on commit f801f2e

Please sign in to comment.