diff --git a/include/pocketpy/pocketpy.h b/include/pocketpy/pocketpy.h index 128dbb4f..bd7e0f3a 100644 --- a/include/pocketpy/pocketpy.h +++ b/include/pocketpy/pocketpy.h @@ -149,6 +149,7 @@ py_GlobalRef py_tpmagic(py_Type type, py_Name name); // new style decl-based bindings void py_bind(py_Ref obj, const char* sig, py_CFunction f); + py_ObjectRef py_bind2(py_Ref obj, const char* sig, py_CFunction f, @@ -156,20 +157,6 @@ py_ObjectRef py_bind2(py_Ref obj, const char* docstring, int slots); -py_ObjectRef py_bind3(py_Ref obj, - py_CFunction f, - c11_sv name, - c11_sv* args, - int argc, - c11_sv starred_arg, - c11_sv* kwargs, - int kwargc, - py_Ref kwdefaults, // a tuple contains default values - c11_sv starred_kwarg, - enum BindType bt, - const char* docstring, - int slots); - // old style argc-based bindings void py_bindmethod(py_Type type, const char* name, py_CFunction f); void py_bindmethod2(py_Type type, const char* name, py_CFunction f, enum BindType bt); @@ -381,6 +368,9 @@ bool py_tpcall(py_Type type, int argc, py_Ref argv); /// Check if the object is an instance of the given type. bool py_checktype(py_Ref self, py_Type type); +/// Get the type of the object. +py_Type py_typeof(py_Ref self); + #define py_checkint(self) py_checktype(self, tp_int) #define py_checkfloat(self) py_checktype(self, tp_float) #define py_checkbool(self) py_checktype(self, tp_bool) diff --git a/src/public/cast.c b/src/public/cast.c index 833f74b6..81bf6a6d 100644 --- a/src/public/cast.c +++ b/src/public/cast.c @@ -42,8 +42,8 @@ void* py_touserdata(py_Ref self) { bool py_istype(py_Ref self, py_Type type) { return self->type == type; } bool py_checktype(py_Ref self, py_Type type) { - if(self->type != type) { - return TypeError("expected %t, got %t", type, self->type); - } - return true; -} \ No newline at end of file + if(self->type == type) return true; + return TypeError("expected %t, got %t", type, self->type); +} + +py_Type py_typeof(py_Ref self) { return self->type; } \ No newline at end of file