Skip to content

improvement: update macros to not require manual imports#1071

Open
timokoesters wants to merge 3 commits intorhaiscript:mainfrom
timokoesters:main
Open

improvement: update macros to not require manual imports#1071
timokoesters wants to merge 3 commits intorhaiscript:mainfrom
timokoesters:main

Conversation

@timokoesters
Copy link

This should make it easier for users of the library, because they don't have to add random use statements for all the things the macros need.

@timokoesters
Copy link
Author

It could be made even more robust by adding the absolute path for Vec and Ok, but I think that's too messy to read and has little benefit

@schungx
Copy link
Collaborator

schungx commented Mar 17, 2026

My question is: what if the user pulls in Rhai under a different name?

@schungx
Copy link
Collaborator

schungx commented Mar 17, 2026

There are some CI tests not passing. Can you also take care of those? Thanks.

@schungx
Copy link
Collaborator

schungx commented Mar 18, 2026

Can you put in an attribute (e.g. root or crate_name) which defaults to rhai?

The test output failure I can fix.

Copy link
Author

@timokoesters timokoesters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've implemented the root argument and added a test for it called one_arg_fn_with_context_custom_root


output.extend(function_def.generate());
// This function is deprecated and does not have custom root support
let root: Path = syn::parse_quote!(::rhai);
Copy link
Author

@timokoesters timokoesters Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

::rhai is hard coded for this and a few more deprecated function.

|| p.path == context_type_path2
|| p.path == context_type_path2x =>
if p.path.segments.last().map(|s| s.ident.to_string())
== Some("NativeCallContext".to_owned()) =>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is an implementation of Parser and I could not pass the custom root here. For checking NativeCallContext I instead only compare the last segment of the path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants