Skip to content

Template instantiation #491

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

Merged
merged 12 commits into from
Feb 10, 2017
Merged

Conversation

fitzgen
Copy link
Member

@fitzgen fitzgen commented Feb 7, 2017

I very much suspect this needs a rebase, but I haven't done it yet.

This is the majority of #446, although it doesn't have the name generation for anonymous named types patches yet (that will be a different PR).

@highfive
Copy link

highfive commented Feb 7, 2017

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@fitzgen
Copy link
Member Author

fitzgen commented Feb 7, 2017

r? @emilio

Ok, I think this is ready for review. Phew!

Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

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

So nasty... But I guess r=me :)

Pass it through stylo before merging please. I can do it tomorrow if needed.


fn num_template_params(&self, _ctx: &BindgenContext) -> Option<usize> {
// Wouldn't it be nice if libclang would reliably give us this
// information‽
Copy link
Contributor

Choose a reason for hiding this comment

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

indeed.

@emilio
Copy link
Contributor

emilio commented Feb 8, 2017

Oh, and thanks for all the cleanups! :)

@bors-servo
Copy link

☔ The latest upstream changes (presumably #480) made this pull request unmergeable. Please resolve the merge conflicts.

@fitzgen
Copy link
Member Author

fitzgen commented Feb 8, 2017

@emilio do you think you could try this out on stylo? I don't have a local set up.

@fitzgen
Copy link
Member Author

fitzgen commented Feb 8, 2017

Thanks!

@emilio
Copy link
Contributor

emilio commented Feb 8, 2017

Sure! Any chance to get it rebased? That way I'll also test all the other merged changes at the same time :)

@fitzgen
Copy link
Member Author

fitzgen commented Feb 8, 2017

Working on a rebase

This commit adds collect_children, has_children, and has_at_least_num_children
methods to Cursor.
The `CanonicalTypeDeclaration` type exists as proof-by-construction that its
cursor is the canonical declaration for its type. If you have a
`CanonicalTypeDeclaration` instance, you know for sure that the type and cursor
match up in a canonical declaration relationship, and it simply cannot be
otherwise.
The TemplateDeclaration trait aggregates information about template
declarations (separate from instantiations and specializations) and their
template parameters into a single source of truth.
This commit create the PartialType type to represent types that we are in the
middle of parsing and their cursor where we found them. Additionally, it fixes a
long standing FIXME to make `currently_parsed_types` private. Finally, it
implements `TemplateDeclaration` for `PartialType` so that we can get
information about a partially parsed template declaration type's template
parameters.
This commit renames `build_template_wrapper` to `instantiate_template` because
that is what it is really doing. Additionally, it completely reworks its
logic. Sometimes clang gives us rather sorry ASTs for template
instantiations (particularly when they involve incomplete template declarations)
and we need to manually reconstruct the template argument nesting.
@fitzgen fitzgen force-pushed the template-instantiation branch from c0897e1 to 41a109a Compare February 8, 2017 18:09
@fitzgen
Copy link
Member Author

fitzgen commented Feb 8, 2017

@emilio rebased!

@fitzgen
Copy link
Member Author

fitzgen commented Feb 8, 2017

This is running into some issues within the <type_traits> header, our old nemesis >:-|

@fitzgen
Copy link
Member Author

fitzgen commented Feb 8, 2017

Ok latest commit lets me generate SM bindings (which pulls in <type_traits>) again.

@fitzgen
Copy link
Member Author

fitzgen commented Feb 9, 2017

@bors-servo r=emilio

@bors-servo
Copy link

📌 Commit 5b5d4f8 has been approved by emilio

@bors-servo
Copy link

⌛ Testing commit 5b5d4f8 with merge 0001606...

bors-servo pushed a commit that referenced this pull request Feb 9, 2017
Template instantiation

I very much suspect this needs a rebase, but I haven't done it yet.

This is the majority of #446, although it doesn't have the name generation for anonymous named types patches yet (that will be a different PR).
@bors-servo
Copy link

☀️ Test successful - status-travis
Approved by: emilio
Pushing 0001606 to master...

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.

4 participants