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

Better namespace resolution for namespaced types #83

Merged
merged 5 commits into from
Sep 6, 2020

Conversation

HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented Aug 29, 2020

Fixes #67. More specifically,

  • The Clang parser now reports inheritance relations using fully qualified names. This allows Bindgen to pick up inherited classes in namespaces.
  • Binding type names are guaranteed not to include ::, by replacing them with underscores.
  • C++ BgInherit structs now inherit constructors of namespaced types properly.
  • The names of BgJumptable and BgInherit structs now include any enclosing namespaces of the C++ types (because these structs are all emitted to the top-level C++ namespace).

A consequence of these fixes is that namespaced types can be mapped directly:

classes:
  Module::Super: Module::Super

types:
  # no longer required, Bindgen always does this now
  # Module::Super: { binding_type: Module_Super }

I have also confirmed that this doesn't break qt5.cr (it merely removes a bunch of redundant Binding::s under lib Binding).

@@ -364,7 +364,7 @@ module Bindgen

rules = @db.get_or_add(cpp_struct.name)
rules.graph_node = crystal_struct
rules.crystal_type = typer.qualified(crystal_struct.name, in_lib: true)
rules.crystal_type = crystal_struct.name
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Qualified name is not necessary here, because copy_structure already signals the fact that the jumptable struct will be defined under lib Binding.

@HertzDevil
Copy link
Contributor Author

Is there anything blocking this PR?

@Papierkorb Papierkorb merged commit 9a5d352 into Papierkorb:master Sep 6, 2020
@HertzDevil HertzDevil deleted the namespaces branch September 6, 2020 11:50
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.

Issues wrapping namespaced classes
2 participants