aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/py/source/pyargs.cpp
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2004-01-07 03:38:25 +0000
committerThomas Grill <xovo@users.sourceforge.net>2004-01-07 03:38:25 +0000
commitd563db671892f0719195aeeb89cac6ee3fe7c69e (patch)
tree2724d6e05233b1b7c5e475938553b1b907c2cbf6 /externals/grill/py/source/pyargs.cpp
parent58e4d7bbbdebe1ee96b318873391b634ca3b8a8f (diff)
""
svn path=/trunk/; revision=1251
Diffstat (limited to 'externals/grill/py/source/pyargs.cpp')
-rw-r--r--externals/grill/py/source/pyargs.cpp16
1 files changed, 12 insertions, 4 deletions
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)