Skip to content

Gotta land some of this stuff... #539

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 4 commits into from
Feb 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/ir/comp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ impl CompInfo {
}

impl TemplateDeclaration for CompInfo {
fn template_params(&self, _ctx: &BindgenContext) -> Option<Vec<ItemId>> {
fn self_template_params(&self, _ctx: &BindgenContext) -> Option<Vec<ItemId>> {
if self.template_args.is_empty() {
None
} else {
Expand Down Expand Up @@ -1040,10 +1040,10 @@ impl Trace for CompInfo {
if let Some(template) = self.specialized_template() {
// This is an instantiation of a template declaration with concrete
// template type arguments.
tracer.visit(template);
tracer.visit_kind(template, EdgeKind::TemplateDeclaration);
let args = item.applicable_template_args(context);
for a in args {
tracer.visit(a);
tracer.visit_kind(a, EdgeKind::TemplateArgument);
}
} else {
let params = item.applicable_template_args(context);
Expand All @@ -1055,27 +1055,27 @@ impl Trace for CompInfo {
}

for base in self.base_members() {
tracer.visit(base.ty);
tracer.visit_kind(base.ty, EdgeKind::BaseMember);
}

for field in self.fields() {
tracer.visit(field.ty());
tracer.visit_kind(field.ty(), EdgeKind::Field);
}

for &ty in self.inner_types() {
tracer.visit(ty);
tracer.visit_kind(ty, EdgeKind::InnerType);
}

for &var in self.inner_vars() {
tracer.visit(var);
tracer.visit_kind(var, EdgeKind::InnerVar);
}

for method in self.methods() {
tracer.visit(method.signature);
tracer.visit_kind(method.signature, EdgeKind::Method);
}

for &ctor in self.constructors() {
tracer.visit(ctor);
tracer.visit_kind(ctor, EdgeKind::Constructor);
}
}
}
10 changes: 5 additions & 5 deletions src/ir/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ impl<'ctx> BindgenContext<'ctx> {
.and_then(|canon_decl| {
self.get_resolved_type(&canon_decl)
.and_then(|template_decl_id| {
template_decl_id.num_template_params(self)
template_decl_id.num_self_template_params(self)
.map(|num_params| {
(*canon_decl.cursor(),
template_decl_id,
Expand All @@ -658,7 +658,7 @@ impl<'ctx> BindgenContext<'ctx> {
.cloned()
})
.and_then(|template_decl| {
template_decl.num_template_params(self)
template_decl.num_self_template_params(self)
.map(|num_template_params| {
(*template_decl.decl(),
template_decl.id(),
Expand Down Expand Up @@ -706,7 +706,7 @@ impl<'ctx> BindgenContext<'ctx> {
use clang_sys;

let num_expected_args = match self.resolve_type(template)
.num_template_params(self) {
.num_self_template_params(self) {
Some(n) => n,
None => {
warn!("Tried to instantiate a template for which we could not \
Expand Down Expand Up @@ -1331,13 +1331,13 @@ impl PartialType {
}

impl TemplateDeclaration for PartialType {
fn template_params(&self, _ctx: &BindgenContext) -> Option<Vec<ItemId>> {
fn self_template_params(&self, _ctx: &BindgenContext) -> Option<Vec<ItemId>> {
// Maybe at some point we will eagerly parse named types, but for now we
// don't and this information is unavailable.
None
}

fn num_template_params(&self, _ctx: &BindgenContext) -> Option<usize> {
fn num_self_template_params(&self, _ctx: &BindgenContext) -> Option<usize> {
// Wouldn't it be nice if libclang would reliably give us this
// information‽
match self.decl().kind() {
Expand Down
6 changes: 3 additions & 3 deletions src/ir/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use super::context::{BindgenContext, ItemId};
use super::dot::DotAttributes;
use super::item::Item;
use super::traversal::{Trace, Tracer};
use super::traversal::{EdgeKind, Trace, Tracer};
use super::ty::TypeKind;
use clang;
use clang_sys::CXCallingConv;
Expand Down Expand Up @@ -336,10 +336,10 @@ impl Trace for FunctionSig {
fn trace<T>(&self, _: &BindgenContext, tracer: &mut T, _: &())
where T: Tracer,
{
tracer.visit(self.return_type());
tracer.visit_kind(self.return_type(), EdgeKind::FunctionReturn);

for &(_, ty) in self.argument_types() {
tracer.visit(ty);
tracer.visit_kind(ty, EdgeKind::FunctionParameter);
}
}
}
16 changes: 8 additions & 8 deletions src/ir/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::dot::{DotAttributes};
use super::function::Function;
use super::item_kind::ItemKind;
use super::module::Module;
use super::traversal::{Trace, Tracer};
use super::traversal::{EdgeKind, Trace, Tracer};
use super::ty::{TemplateDeclaration, Type, TypeKind};
use clang;
use clang_sys;
Expand Down Expand Up @@ -205,7 +205,7 @@ impl Trace for Item {
tracer.visit(fun.signature());
}
ItemKind::Var(ref var) => {
tracer.visit(var.ty());
tracer.visit_kind(var.ty(), EdgeKind::VarType);
}
ItemKind::Module(_) => {
// Module -> children edges are "weak", and we do not want to
Expand Down Expand Up @@ -930,22 +930,22 @@ impl DotAttributes for Item {
}

impl TemplateDeclaration for ItemId {
fn template_params(&self, ctx: &BindgenContext) -> Option<Vec<ItemId>> {
fn self_template_params(&self, ctx: &BindgenContext) -> Option<Vec<ItemId>> {
ctx.resolve_item_fallible(*self)
.and_then(|item| item.template_params(ctx))
.and_then(|item| item.self_template_params(ctx))
}
}

impl TemplateDeclaration for Item {
fn template_params(&self, ctx: &BindgenContext) -> Option<Vec<ItemId>> {
self.kind.template_params(ctx)
fn self_template_params(&self, ctx: &BindgenContext) -> Option<Vec<ItemId>> {
self.kind.self_template_params(ctx)
}
}

impl TemplateDeclaration for ItemKind {
fn template_params(&self, ctx: &BindgenContext) -> Option<Vec<ItemId>> {
fn self_template_params(&self, ctx: &BindgenContext) -> Option<Vec<ItemId>> {
match *self {
ItemKind::Type(ref ty) => ty.template_params(ctx),
ItemKind::Type(ref ty) => ty.self_template_params(ctx),
// If we start emitting bindings to explicitly instantiated
// functions, then we'll need to check ItemKind::Function for
// template params.
Expand Down
Loading