-
Notifications
You must be signed in to change notification settings - Fork 354
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 renaming cosmwasm-schema
#1420
Milestone
Comments
We have the same issue in #[proc_macro_attribute]
pub fn entry_point(_attr: TokenStream, mut item: TokenStream) -> TokenStream {
let cloned = item.clone();
let function = parse_macro_input!(cloned as syn::ItemFn);
let name = function.sig.ident.to_string();
// The first argument is `deps`, the rest is region pointers
let args = function.sig.inputs.len() - 1;
// E.g. "ptr0: u32, ptr1: u32, ptr2: u32, "
let typed_ptrs = (0..args).fold(String::new(), |acc, i| format!("{}ptr{}: u32, ", acc, i));
// E.g. "ptr0, ptr1, ptr2, "
let ptrs = (0..args).fold(String::new(), |acc, i| format!("{}ptr{}, ", acc, i));
let new_code = format!(
r##"
#[cfg(target_arch = "wasm32")]
mod __wasm_export_{name} {{ // new module to avoid conflict of function name
#[no_mangle]
extern "C" fn {name}({typed_ptrs}) -> u32 {{
cosmwasm_std::do_{name}(&super::{name}, {ptrs})
}}
}}
"##,
name = name,
typed_ptrs = typed_ptrs,
ptrs = ptrs
);
let entry = TokenStream::from_str(&new_code).unwrap();
item.extend(entry);
item
} |
I tend to agree. Like #1539 but with
|
Agreed on both fronts :) |
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Right now, renaming the
cosmwasm-schema
dependency in a contract would causecosmwasm-schema
macros to break.One fix (my preference probably) is to add an attribute to all macros that allows manually overriding the path to
cosmwasm-schema
.Another is using something like
proc-macro-crate
to find out the crate name fromCargo.toml
, but I really don't like the idea of source code depending on the build system like this.The text was updated successfully, but these errors were encountered: