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

Fix extendr_module importing #469

Merged
merged 7 commits into from
Feb 10, 2023
Merged

Fix extendr_module importing #469

merged 7 commits into from
Feb 10, 2023

Conversation

CGMossa
Copy link
Member

@CGMossa CGMossa commented Feb 3, 2023

The issue is that these get_<module>_metadata are generated in their respective modules, but then they aren't realy imported in the place where they get recursively called.
Others experienced this, see discord message

@CGMossa
Copy link
Member Author

CGMossa commented Feb 3, 2023

I accidentally made a branch from a branch where I just was half done doing something.
Please accept the minor documentation edits. I was going to make a full PR of these things.

@multimeric
Copy link
Member

Can you write a test for this?

@CGMossa
Copy link
Member Author

CGMossa commented Feb 4, 2023

I've no idea how to...

@multimeric
Copy link
Member

Maybe an integration test that has multiple Rust modules in the same file, each with their own extendr_module?

@CGMossa
Copy link
Member Author

CGMossa commented Feb 4, 2023

Perfect. I added a test and fixed another extendr_module! issue.

@multimeric
Copy link
Member

Hmm it would be nice to be able to make assertions about the generated code. Can you call the metadata function in a test block and assert that it contains all the exported functions, or something?

@CGMossa
Copy link
Member Author

CGMossa commented Feb 5, 2023

I'll think about that. But no I don't think that this is easily possible.

I'm hoping this is a smal pr that we would get merged soon. And released. It is very annoying to users.

@multimeric
Copy link
Member

I understand the desire to get it merged, but from my perspective as a reviewer I have no particular evidence that this works. Each module should define a pub fn #module_metadata_name() -> extendr_api::metadata::Metadata. Are you sure you can't just call that for each module to assert that it exists?

@CGMossa
Copy link
Member Author

CGMossa commented Feb 5, 2023

First, I did put the integration test that you wanted. And that one shows that this now works.
Second, the way this works, is you have a root module that calls its own meta data functions. Then based on the use statements it calls the other ExtendR modules' meta data.

So these functions are already being called.

I do valid your input and if I can make this more robust in the future, I'll make a PR.

@CGMossa
Copy link
Member Author

CGMossa commented Feb 5, 2023

This is a an issue with the current code-base that Andy had already warned us about in #404. Quite frankly it is up to people like me to clean this sort of thing up, but I've not done it before now.
So this addresses it part of the way, but generally everywhere we should be able to invoke the macros without
special importing statements.

@CGMossa
Copy link
Member Author

CGMossa commented Feb 9, 2023

Alright, I think we should merge this ASAP. I'm going to request rewiews now.

@CGMossa
Copy link
Member Author

CGMossa commented Feb 9, 2023 via email

@CGMossa
Copy link
Member Author

CGMossa commented Feb 9, 2023

Alright, so the submodule in extendrtests now no longer imports everything, thus it should have made an error just now. It hasn't. So there are now an R integration test as well.

@CGMossa CGMossa merged commit f27bda0 into master Feb 10, 2023
CGMossa added a commit that referenced this pull request Feb 10, 2023
* Started documenting the `#[extendr]` proc-macro

* fixes the need for
`use module::get_module_metadata`.

* Revert some changes

* Added an integration test.

* Fixed the need to import
the trait `GetSexp`.

* expanded the test with an adjacent module

* This should now force the extendrtests to test
this bug
@CGMossa CGMossa deleted the fix_get_metadata_use branch April 11, 2023 14:57
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.

None yet

3 participants