From d14595f0524e11bd5a3f4cc233adf44ac161cf03 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 1 Jul 2009 10:57:29 +0200 Subject: [PATCH] codegen: Fix const GBoxed return wrapping. --- codegen/argtypes.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/codegen/argtypes.py b/codegen/argtypes.py index de34feb94e..4dc5faaa90 100644 --- a/codegen/argtypes.py +++ b/codegen/argtypes.py @@ -645,18 +645,23 @@ class BoxedArg(ArgType): info.arglist.append(pname) info.add_parselist('O', ['&py_' + pname], [pname]) ret_tmpl = ' /* pyg_boxed_new handles NULL checking */\n' \ - ' return pyg_boxed_new(%(typecode)s, %(ret)s, %(copy)s, TRUE);' + ' return pyg_boxed_new(%(typecode)s, (%(saferet)s) %(ret)s, %(copy)s, TRUE);' def write_return(self, ptype, ownsreturn, info): + if ptype[:6] == 'const-': + ptype = "const " + ptype[6:] if ptype[-1] == '*': - info.varlist.add(self.typename, '*ret') + info.varlist.add(ptype[:-1], '*ret') ret = 'ret' + stype = self.typename + '*' else: - info.varlist.add(self.typename, 'ret') + info.varlist.add(ptype, 'ret') ret = '&ret' ownsreturn = 0 # of course it can't own a ref to a local var ... + stype = self.typename info.codeafter.append(self.ret_tmpl % { 'typecode': self.typecode, 'ret': ret, + 'saferet' : stype, 'copy': ownsreturn and 'FALSE' or 'TRUE'}) class CustomBoxedArg(ArgType):