@@ -95,11 +95,16 @@ static PyObject *object_call(ObjectData *self, PyObject *args, PyObject *kwds) {
9595 const int nargs = PyTuple_Size (args );
9696 for (int i = 0 ; i < nargs ; ++ i ) {
9797 PyObject * item = PyTuple_GetItem (args , i );
98- if (PyLong_Check (item )) {
98+ if (PyBool_Check (item )) {
99+ } else if (PyLong_Check (item )) {
100+ } else if (PyFloat_Check (item )) {
99101 } else if (PyUnicode_Check (item )) {
100102 } else if (PyObject_IsInstance (item , (PyObject * )& Object )) {
101103 } else {
102- PyErr_Format (PyExc_ValueError , "Unsupported type when calling quickjs object" );
104+ PyErr_Format (PyExc_ValueError ,
105+ "Unsupported type of argument %d when calling quickjs object: %s." ,
106+ i ,
107+ Py_TYPE (item )-> tp_name );
103108 return NULL ;
104109 }
105110 }
@@ -108,8 +113,12 @@ static PyObject *object_call(ObjectData *self, PyObject *args, PyObject *kwds) {
108113 JSValueConst * jsargs = malloc (nargs * sizeof (JSValueConst ));
109114 for (int i = 0 ; i < nargs ; ++ i ) {
110115 PyObject * item = PyTuple_GetItem (args , i );
111- if (PyLong_Check (item )) {
116+ if (PyBool_Check (item )) {
117+ jsargs [i ] = JS_MKVAL (JS_TAG_BOOL , item == Py_True ? 1 : 0 );
118+ } else if (PyLong_Check (item )) {
112119 jsargs [i ] = JS_MKVAL (JS_TAG_INT , PyLong_AsLong (item ));
120+ } else if (PyFloat_Check (item )) {
121+ jsargs [i ] = JS_NewFloat64 (self -> context -> context , PyFloat_AsDouble (item ));
113122 } else if (PyUnicode_Check (item )) {
114123 jsargs [i ] = JS_NewString (self -> context -> context , PyUnicode_AsUTF8 (item ));
115124 } else if (PyObject_IsInstance (item , (PyObject * )& Object )) {
0 commit comments