From 5ad34dc69befbd59601c507c90571b1662e0e66d Mon Sep 17 00:00:00 2001 From: Timothy J Fontaine Date: Tue, 18 Mar 2014 12:11:44 -0700 Subject: [PATCH] add support for unexposed type definitions desperately need tests. --- lib/generateffi.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/generateffi.js b/lib/generateffi.js index 215e2fe..dae4fd3 100644 --- a/lib/generateffi.js +++ b/lib/generateffi.js @@ -163,8 +163,20 @@ exports.generate = function (opts) { } else if (this.kind == Cursor.FieldDecl && this.type.kind == Type.Unexposed) { //console.error('FieldDecl', this.type.kind, this.type.spelling); t = wrap.elements[wrap.elements.length - 1]; - t.name = this.spelling; - return Cursor.Continue; + /* This may not be entirely correct, we're assuming that because we + * already have elements defined that we're at the name of it, + * consider `union { int foo; } myUnion;` but it's also possible + * we are at an actual definition and we should be defining this type + * + * TODO -- man I need tests. + */ + if (t) { + t.name = this.spelling; + return Cursor.Continue; + } else { + t = defineType(this.type.declaration); + tname = this.spelling; + } } else { t = mapType(this.type, this.spelling); tname = this.spelling;