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

Add an UsingDecl AST node #1758

Open
deadlocklogic opened this issue Aug 14, 2023 · 9 comments · May be fixed by #1769
Open

Add an UsingDecl AST node #1758

deadlocklogic opened this issue Aug 14, 2023 · 9 comments · May be fixed by #1769
Assignees

Comments

@deadlocklogic
Copy link
Contributor

deadlocklogic commented Aug 14, 2023

I am just trying to iterate around parsed AST entities in ILibrary::Preprocess().
Simple example:

struct Base {
private:
	void test() {}
};

Now you might ask why you need private or protected members?
Simple answer:
Consider the following:

struct Child : Base {
	using Base::test;
};

Now Base::test() should be accessible in the binding generator.

@tritao After fixing this, you can consider adding a Pass which imports all these hidden members (functions/classes/variables/templates etc...) in the inherited hierarchies.

@deadlocklogic deadlocklogic changed the title Private AST member aren't showing Private AST members aren't showing Aug 14, 2023
@tritao
Copy link
Collaborator

tritao commented Aug 14, 2023

Those are skipped at the native Clang parser level, you can enable them with the SkipPrivateDeclarations parser option.

Now Base::test() should be accessible in the binding generator.

I see, that's an interesting pattern, seems like it would be worth fixing but personally I am not going to spend time working on it any soon. Seems like something that would take just a few hours to implement and test.

@deadlocklogic
Copy link
Contributor Author

Never mind, I can do that on my own, and maybe you can review it when I make a PR.
BTW I am making a serious progress with other Generators which I will make a PR when finished.
Still will need you to fix template parameter types later as we discussed before.

Just another simple question:
How using declarations are parsed?
In what form using Base::test; is available in the AST?

@deadlocklogic
Copy link
Contributor Author

@tritao I surfed the AST members and even searched the whole project for a pattern like UsingDecl but barely found something relevant in the C# AST.
Could a UsingDecl member be added, and inserted when it needs to?
I only need such thing in order to implement the above.
I am not in a rush to see an implementation I can wait a bit, but just to keep in mind such feature is necessary.

@tritao tritao changed the title Private AST members aren't showing Add an UsingDecl AST node Aug 15, 2023
@tritao
Copy link
Collaborator

tritao commented Aug 15, 2023

Could a UsingDecl member be added, and inserted when it needs to?

Sure, that seems like something we should add. Renamed this issue to keep track of it.

@tritao tritao self-assigned this Aug 15, 2023
@deadlocklogic
Copy link
Contributor Author

Nice!
I can wait a bit no problem. Still myself need a bit of time in order to finish my work (Remember I am refactoring my old code to the best possible form in order to migrate easily).
I am like 80% done, and I feel like with CppSharp the bindings will be more precise.
Thanks.

tritao added a commit that referenced this issue Sep 30, 2023
@tritao tritao linked a pull request Sep 30, 2023 that will close this issue
tritao added a commit that referenced this issue Sep 30, 2023
tritao added a commit that referenced this issue Sep 30, 2023
@deadlocklogic
Copy link
Contributor Author

deadlocklogic commented Oct 4, 2023

When all tests pass, would be handy if we add in the enum FunctionSynthKind a value indicating that a function is inherited using UsingDecl (can be used when creating a pass to import all protected UsingDecl explicitly).

@deadlocklogic
Copy link
Contributor Author

I found out CXXMethodKind.UsingDirective already exists, so maybe it can be used too. I don't know which implementation is the best: UsingDecl as a synthetic function or as a normal function with CXXMethodKind.UsingDirective.

@tritao
Copy link
Collaborator

tritao commented Oct 6, 2023

Technically I guess it's not a synthetic function since it's not generated by us but already exists in the source.

@deadlocklogic
Copy link
Contributor Author

Yes, we can add a pass which import them all as a UsingDirective method kind.

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 a pull request may close this issue.

2 participants