Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow arbitrary NIF names (e.g. those ending with ! or ?) #505

Closed
Closed
Changes from 1 commit
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
6 changes: 2 additions & 4 deletions rustler_codegen/src/nif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ pub fn transcoder_decorator(args: syn::AttributeArgs, fun: syn::ItemFn) -> Token
let arity = arity(inputs.clone());
let decoded_terms = extract_inputs(inputs.clone());
let argument_names = create_function_params(inputs.clone());
let erl_func_name = extract_attr_value(args, "name")
.map(|ref n| syn::Ident::new(n, Span::call_site()))
.unwrap_or_else(|| name.clone());
let erl_func_name = extract_attr_value(args, "name").unwrap_or_else(|| name.to_string());
filmor marked this conversation as resolved.
Show resolved Hide resolved

quote! {
#[allow(non_camel_case_types)]
pub struct #name;

impl rustler::Nif for #name {
const NAME: *const u8 = concat!(stringify!(#erl_func_name), "\0").as_ptr() as *const u8;
const NAME: *const u8 = concat!(#erl_func_name, "\0").as_ptr() as *const u8;
const ARITY: u32 = #arity;
const FLAGS: u32 = #flags as u32;
const RAW_FUNC: unsafe extern "C" fn(
Expand Down