From d563db671892f0719195aeeb89cac6ee3fe7c69e Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Wed, 7 Jan 2004 03:38:25 +0000 Subject: "" svn path=/trunk/; revision=1251 --- externals/grill/py/source/pyargs.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'externals/grill/py/source/pyargs.cpp') diff --git a/externals/grill/py/source/pyargs.cpp b/externals/grill/py/source/pyargs.cpp index cf6d41d0..595dce0c 100644 --- a/externals/grill/py/source/pyargs.cpp +++ b/externals/grill/py/source/pyargs.cpp @@ -12,11 +12,19 @@ WARRANTIES, see the file, "license.txt," in this distribution. static PyObject *MakePyAtom(const t_atom &at) { - if(flext::IsFloat(at)) return PyFloat_FromDouble((D)flext::GetFloat(at)); - else if(flext::IsInt(at)) return PyInt_FromLong(flext::GetInt(at)); - else if(flext::IsSymbol(at)) return PyString_FromString(flext::GetString(at)); + if(flext::IsSymbol(at)) return PyString_FromString(flext::GetString(at)); // else if(flext::IsPointer(at)) return NULL; // not handled - else return NULL; + else if(flext::CanbeInt(at) && flext::CanbeFloat(at)) { + // if a number can be an integer... let at be an integer! + int ival = flext::GetAInt(at); + double fval = flext::GetAFloat(at); + return (double)ival == fval?PyInt_FromLong(ival):PyFloat_FromDouble(fval); + } + // these following should never happen + else if(flext::IsFloat(at)) return PyFloat_FromDouble((D)flext::GetFloat(at)); + else if(flext::IsInt(at)) return PyInt_FromLong(flext::GetInt(at)); + + return NULL; } PyObject *py::MakePyArgs(const t_symbol *s,const AtomList &args,I inlet,BL withself) -- cgit v1.2.1