summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMikko Lehtonen <scoopr@iki.fi>2017-03-14 01:43:59 +0200
committerMikko Lehtonen <scoopr@iki.fi>2017-05-03 00:54:14 +0300
commitc266097617f199d66b422a27ecd0bf22c6a9fdb2 (patch)
tree7c6b45f4f668ba05a02ce131aeb73ff4db10e396 /src
parent86aabcf4479e72d63d75eeea802290802a55fb22 (diff)
objc: Handle template params
The objetive-c template type params were handled as Typedefs so every interface generated its own, clashing in the namespace. This now maps them to id.
Diffstat (limited to 'src')
-rw-r--r--src/ir/ty.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/ir/ty.rs b/src/ir/ty.rs
index c3f26572..a9054e98 100644
--- a/src/ir/ty.rs
+++ b/src/ir/ty.rs
@@ -836,6 +836,24 @@ impl Type {
_ => {}
}
+ // Objective C template type parameter
+ // FIXME: This is probably wrong, we are attempting to find the
+ // objc template params, which seem to manifest as a typedef.
+ // We are rewriting them as id to suppress multiple conflicting
+ // typedefs at root level
+ if ty_kind == CXType_Typedef {
+ let is_template_type_param = ty.declaration().kind() == CXCursor_TemplateTypeParameter;
+ let is_canonical_objcpointer = canonical_ty.kind() == CXType_ObjCObjectPointer;
+
+ // We have found a template type for objc interface
+ if is_canonical_objcpointer && is_template_type_param {
+ // Objective-C generics are just ids with fancy name.
+ // To keep it simple, just name them ids
+ name = "id".to_owned();
+ }
+
+ }
+
if location.kind() == CXCursor_ClassTemplatePartialSpecialization {
// Sorry! (Not sorry)
warn!("Found a partial template specialization; bindgen does not \