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

integration_tests: added breaking template static function test #1394

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SDAChess
Copy link

Adds a test for #1393

Please let me know if the test I wrote is correct.

Copy link

google-cla bot commented Sep 20, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@adetaylor
Copy link
Collaborator

Thanks very much for this - I'm not ignoring it - I just need to get to the bottom of #1396 first

@adetaylor
Copy link
Collaborator

FWIW I consider this to be half-way between a bug and a feature request. The concrete types generated aren't exactly the same as "real" structs which are generated fully by autocxx, and so it's unsurprising to me that they lack static methods. I can see that it might be surprising to users, though, so I plan to look into how hard it would be to add that functionality. I suspect it will be hard, in which case I'm afraid I'm just going to close this, but I won't do so until I've made sure that it's not an easy addition.

@SDAChess
Copy link
Author

SDAChess commented Jan 9, 2025

Thank you for the work. If it's not an easy addition I'll try to take a stab at it :)

@adetaylor
Copy link
Collaborator

I did a bit of investigation building on your test, and it's not failing where I expected it to fail, it's failing earlier :)

Here's what I have been working with:

      class Boobar {
      public:
        static int test2() {
            return 1;
        }
      };
      
      template <typename T>
      class Toto
      {
      public:
      	static int test()
      	{
            return 1;
      	}
        T t;
      };
      

and with generate! directives fro Boobar and Toto along with your concrete! directive.

Results:

  • Without the T t; field, autocxx refuses to generate anything for Toto because of the unused T. I have long term hopes to solve this by sneaking in extra PhantomData for each template param within bindgen, but I haven't done this yet.
  • Even with the T t; and generate!("Toto") we still don't generate anything, because bindgen tells us nothing about Toto::test (but it does tell us about Boobar::test2).

So, I think at this point the first step is to figure out how to get bindgen to fess up about the existence of Toto::test in cases such as this. You can see the bindgen output in RUST_LOG=autocxx_engine=info cargo test test_cpp_static_template -- --nocapture.

What I expected was for bindgen to tell us about the various static functions in Toto but then for us to fail to attach them to the concrete type we generate.

If you think you might work on this, I'll leave it open for now.

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