From 1e7d3d1eb8aee8a516a2989c5e13b04757d2782c Mon Sep 17 00:00:00 2001 From: Alec Cooper Date: Sat, 23 Jan 2016 15:52:35 -0500 Subject: [PATCH] Don't write empty swigargs structs --- Source/Modules/go.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index a214a4153..4b4a52fb1 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -2112,6 +2112,7 @@ private: emit_attach_parmmaps(parms, f); int parm_count = emit_num_arguments(parms); int required_count = emit_num_required(parms); + bool needs_swigargs = false; emit_return_variable(n, result, f); @@ -2125,6 +2126,7 @@ private: String *swigargs = NewString("\tstruct swigargs {\n"); if (parm_count > required_count) { + needs_swigargs = true; Printv(swigargs, "\t\tintgo _swig_optargc;\n", NULL); } @@ -2136,6 +2138,7 @@ private: SwigType *pt = Getattr(p, "type"); String *ct = gcCTypeForGoValue(p, pt, ln); Printv(swigargs, "\t\t\t", ct, ";\n", NULL); + needs_swigargs = true; Delete(ct); String *gn = NewStringf("_swig_go_%d", i); @@ -2152,6 +2155,7 @@ private: String *ct = gcCTypeForGoValue(n, result, ln); Delete(ln); Printv(swigargs, "\t\t", ct, ";\n", NULL); + needs_swigargs = true; Delete(ct); ln = NewString("_swig_go_result"); @@ -2208,7 +2212,10 @@ private: cleanupFunction(n, f, parms); - Printv(f->locals, swigargs, NULL); + if (needs_swigargs) + { + Printv(f->locals, swigargs, NULL); + } Printv(f->code, "}\n", NULL);