def makeReturn(code, ret): if ret == Void.TYPE: return code if Class.isPrimitive(ret): r = jast.InvokeStatic("Py", "py2" + ret.__name__, [code]) else: typname = typeName(ret) r = jast.InvokeStatic( "Py", "tojava", [code, jast.GetStaticAttribute(typname, 'class')]) r = jast.Cast(typname, r) return jast.Return(r)
def asa(self, code, type, message=None): ret = self.isa(code, type) if ret is not None: return ret if primitives.has_key(type): return jast.InvokeStatic('Py', primitives[type], [code]) if type == java.lang.Boolean.TYPE: return jast.Invoke(code, '__nonzero__', []) tname = type.__name__ tojava = jast.InvokeStatic( 'Py', 'tojava', [code, jast.GetStaticAttribute(tname, 'class')]) return jast.Cast(tname, tojava)