From: <pj...@us...> - 2008-07-31 23:18:35
|
Revision: 5035 http://jython.svn.sourceforge.net/jython/?rev=5035&view=rev Author: pjenvey Date: 2008-07-31 23:18:33 +0000 (Thu, 31 Jul 2008) Log Message: ----------- sync with a couple of manual changes PyInstance has had Modified Paths: -------------- branches/asm/Misc/make_binops.py Modified: branches/asm/Misc/make_binops.py =================================================================== --- branches/asm/Misc/make_binops.py 2008-07-31 23:16:37 UTC (rev 5034) +++ branches/asm/Misc/make_binops.py 2008-07-31 23:18:33 UTC (rev 5035) @@ -100,8 +100,8 @@ template1 = comment + """\ public %(ret)s __%(name)s__() { PyObject ret = invoke("__%(name)s__"); - if (ret instanceof %(ret)s) - return (%(ret)s)ret; + if (%(checks)s) + return %(cast)sret; throw Py.TypeError("__%(name)s__() should return a %(retname)s"); } @@ -115,17 +115,33 @@ string = 'PyString', 'string' ops = [('hex', string), ('oct', string), - ('int', ('PyInteger', 'int')), ('float', ('PyFloat', 'float')), - ('long', ('PyLong', 'long')), ('complex', ('PyComplex', 'complex')), + ('int', ('PyObject', 'int'), ('PyLong', 'PyInteger')), + ('float', ('PyFloat', 'float')), + ('long', ('PyObject', 'long'), ('PyLong', 'PyInteger')), + ('complex', ('PyComplex', 'complex')), ('pos', None), ('neg', None), ('abs', None), ('invert', None)] fp.write(' // Unary ops\n\n') -for name, ret in ops: +for item in ops: + checks = None + if len(item) == 2: + name, ret = item + else: + name, ret, checks = item if ret is None: fp.write(template2 % {'name':name}) else: ret, retname = ret - fp.write(template1 % {'name':name, 'ret':ret, 'retname':retname}) + if checks: + checks = ' || '.join(['ret instanceof %s' % check for check in checks]) + else: + checks = 'ret instanceof %s' % ret + if ret == 'PyObject': + cast = '' + else: + cast = '(%s)' % ret + fp.write(template1 % {'name':name, 'ret':ret, 'retname':retname, + 'checks':checks, 'cast':cast}) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |