diff options
author | Christoph Reiter <reiter.christoph@gmail.com> | 2018-03-31 10:13:37 +0200 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2018-03-31 10:16:24 +0200 |
commit | 515fe7b2cb2603b08af263a92a9ea82525bd2ac1 (patch) | |
tree | 0217958299370e658f021e6634c5317b310d4476 | |
parent | cf0d51009a1b16ffa26ffdd972ca1948af741f1a (diff) | |
download | pygobject-515fe7b2cb2603b08af263a92a9ea82525bd2ac1.tar.gz |
Port more integer converters
-rw-r--r-- | gi/gimodule.c | 31 | ||||
-rw-r--r-- | gi/pygi-argument.c | 2 | ||||
-rw-r--r-- | gi/pygi-basictype.c | 6 | ||||
-rw-r--r-- | gi/pygi-basictype.h | 1 | ||||
-rw-r--r-- | gi/pygi-boxed.c | 3 | ||||
-rw-r--r-- | gi/pygi-info.c | 18 | ||||
-rw-r--r-- | gi/pygi-type.c | 22 | ||||
-rw-r--r-- | gi/pygobject-object.c | 11 | ||||
-rw-r--r-- | gi/pygoptioncontext.c | 5 | ||||
-rw-r--r-- | gi/pygparamspec.c | 69 | ||||
-rw-r--r-- | gi/pygspawn.c | 9 |
11 files changed, 95 insertions, 82 deletions
diff --git a/gi/gimodule.c b/gi/gimodule.c index 81868158..4714ff17 100644 --- a/gi/gimodule.c +++ b/gi/gimodule.c @@ -53,6 +53,7 @@ #include "pygi-util.h" #include "gimodule.h" #include "pygi-python-compat.h" +#include "pygi-basictype.h" PyObject *PyGIWarning; PyObject *PyGIDeprecationWarning; @@ -2059,7 +2060,7 @@ pyg_add_emission_hook(PyGObject *self, PyObject *args) data, (GDestroyNotify)pyg_destroy_notify); - return PyLong_FromUnsignedLong(hook_id); + return pygi_gulong_to_py (hook_id); } static PyObject * @@ -2124,7 +2125,7 @@ pyg_signal_new(PyObject *self, PyObject *args) return_type, n_params, param_types); g_free(param_types); if (signal_id != 0) - return PYGLIB_PyLong_FromLong(signal_id); + return pygi_guint_to_py (signal_id); PyErr_SetString(PyExc_RuntimeError, "could not create signal"); return NULL; } @@ -2347,24 +2348,24 @@ static int pygi_register_constants(PyObject *m) { /* PyFloat_ return a new ref, and add object takes the ref */ - PyModule_AddObject(m, "G_MINFLOAT", PyFloat_FromDouble(G_MINFLOAT)); - PyModule_AddObject(m, "G_MAXFLOAT", PyFloat_FromDouble(G_MAXFLOAT)); - PyModule_AddObject(m, "G_MINDOUBLE", PyFloat_FromDouble(G_MINDOUBLE)); - PyModule_AddObject(m, "G_MAXDOUBLE", PyFloat_FromDouble(G_MAXDOUBLE)); + PyModule_AddObject(m, "G_MINFLOAT", pygi_gfloat_to_py (G_MINFLOAT)); + PyModule_AddObject(m, "G_MAXFLOAT", pygi_gfloat_to_py (G_MAXFLOAT)); + PyModule_AddObject(m, "G_MINDOUBLE", pygi_gdouble_to_py (G_MINDOUBLE)); + PyModule_AddObject(m, "G_MAXDOUBLE", pygi_gdouble_to_py (G_MAXDOUBLE)); PyModule_AddIntConstant(m, "G_MINSHORT", G_MINSHORT); PyModule_AddIntConstant(m, "G_MAXSHORT", G_MAXSHORT); PyModule_AddIntConstant(m, "G_MAXUSHORT", G_MAXUSHORT); PyModule_AddIntConstant(m, "G_MININT", G_MININT); PyModule_AddIntConstant(m, "G_MAXINT", G_MAXINT); - PyModule_AddObject(m, "G_MAXUINT", PyLong_FromUnsignedLong(G_MAXUINT)); - PyModule_AddObject(m, "G_MINLONG", PyLong_FromLong(G_MINLONG)); - PyModule_AddObject(m, "G_MAXLONG", PyLong_FromLong(G_MAXLONG)); - PyModule_AddObject(m, "G_MAXULONG", PyLong_FromUnsignedLong(G_MAXULONG)); - PyModule_AddObject(m, "G_MAXSIZE", PyLong_FromSize_t(G_MAXSIZE)); - PyModule_AddObject(m, "G_MAXSSIZE", PyLong_FromSsize_t(G_MAXSSIZE)); - PyModule_AddObject(m, "G_MINSSIZE", PyLong_FromSsize_t(G_MINSSIZE)); - PyModule_AddObject(m, "G_MINOFFSET", PyLong_FromLongLong(G_MINOFFSET)); - PyModule_AddObject(m, "G_MAXOFFSET", PyLong_FromLongLong(G_MAXOFFSET)); + PyModule_AddObject(m, "G_MAXUINT", pygi_guint_to_py (G_MAXUINT)); + PyModule_AddObject(m, "G_MINLONG", pygi_glong_to_py (G_MINLONG)); + PyModule_AddObject(m, "G_MAXLONG", pygi_glong_to_py (G_MAXLONG)); + PyModule_AddObject(m, "G_MAXULONG", pygi_gulong_to_py (G_MAXULONG)); + PyModule_AddObject(m, "G_MAXSIZE", pygi_gsize_to_py (G_MAXSIZE)); + PyModule_AddObject(m, "G_MAXSSIZE", pygi_gssize_to_py (G_MAXSSIZE)); + PyModule_AddObject(m, "G_MINSSIZE", pygi_gssize_to_py (G_MINSSIZE)); + PyModule_AddObject(m, "G_MINOFFSET", pygi_gint64_to_py (G_MINOFFSET)); + PyModule_AddObject(m, "G_MAXOFFSET", pygi_gint64_to_py (G_MAXOFFSET)); PyModule_AddIntConstant(m, "SIGNAL_RUN_FIRST", G_SIGNAL_RUN_FIRST); PyModule_AddIntConstant(m, "PARAM_READWRITE", G_PARAM_READWRITE); diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c index f3014355..be76930b 100644 --- a/gi/pygi-argument.c +++ b/gi/pygi-argument.c @@ -831,7 +831,7 @@ _pygi_argument_to_object (GIArgument *arg, return NULL; py_args = PyTuple_New (1); - if (PyTuple_SetItem (py_args, 0, PyLong_FromLong (arg->v_int)) != 0) { + if (PyTuple_SetItem (py_args, 0, pygi_gint_to_py (arg->v_int)) != 0) { Py_DECREF (py_args); Py_DECREF (py_type); return NULL; diff --git a/gi/pygi-basictype.c b/gi/pygi-basictype.c index ba618a3f..089a7dde 100644 --- a/gi/pygi-basictype.c +++ b/gi/pygi-basictype.c @@ -90,6 +90,12 @@ pygi_gsize_to_py (gsize value) return PYGLIB_PyLong_FromSize_t (value); } +PyObject * +pygi_gssize_to_py (gssize value) +{ + return PYGLIB_PyLong_FromSsize_t (value); +} + gboolean pygi_gdouble_from_py (PyObject *py_arg, gdouble *result) { diff --git a/gi/pygi-basictype.h b/gi/pygi-basictype.h index e5bb99ed..281eba6e 100644 --- a/gi/pygi-basictype.h +++ b/gi/pygi-basictype.h @@ -65,6 +65,7 @@ PyObject *pygi_guint_to_py (guint value); PyObject *pygi_gulong_to_py (gulong value); PyObject *pygi_filename_to_py (gchar *value); PyObject *pygi_gsize_to_py (gsize value); +PyObject *pygi_gssize_to_py (gssize value); gboolean pygi_gboolean_from_py (PyObject *object, gboolean *result); gboolean pygi_gint64_from_py (PyObject *object, gint64 *result); diff --git a/gi/pygi-boxed.c b/gi/pygi-boxed.c index eaf56d69..ce3d7487 100644 --- a/gi/pygi-boxed.c +++ b/gi/pygi-boxed.c @@ -23,6 +23,7 @@ #include "pygi-info.h" #include "pygboxed.h" #include "pygi-type.h" +#include "pygi-basictype.h" #include "pygi-python-compat.h" #include <girepository.h> @@ -189,7 +190,7 @@ pygi_boxed_new (PyTypeObject *type, static PyObject * boxed_get_free_on_dealloc(PyGIBoxed *self, void *closure) { - return PyBool_FromLong( ((PyGBoxed *)self)->free_on_dealloc ); + return pygi_gboolean_to_py( ((PyGBoxed *)self)->free_on_dealloc ); } /** diff --git a/gi/pygi-info.c b/gi/pygi-info.c index a7a8e89b..9d639e6f 100644 --- a/gi/pygi-info.c +++ b/gi/pygi-info.c @@ -858,28 +858,28 @@ _wrap_g_arg_info_get_direction (PyGIBaseInfo *self) static PyObject * _wrap_g_arg_info_is_caller_allocates (PyGIBaseInfo *self) { - return PyBool_FromLong ( + return pygi_gboolean_to_py ( g_arg_info_is_caller_allocates ((GIArgInfo*)self->info) ); } static PyObject * _wrap_g_arg_info_is_return_value (PyGIBaseInfo *self) { - return PyBool_FromLong ( + return pygi_gboolean_to_py ( g_arg_info_is_return_value ((GIArgInfo*)self->info) ); } static PyObject * _wrap_g_arg_info_is_optional (PyGIBaseInfo *self) { - return PyBool_FromLong ( + return pygi_gboolean_to_py ( g_arg_info_is_optional ((GIArgInfo*)self->info) ); } static PyObject * _wrap_g_arg_info_may_be_null (PyGIBaseInfo *self) { - return PyBool_FromLong ( + return pygi_gboolean_to_py ( g_arg_info_may_be_null ((GIArgInfo*)self->info) ); } @@ -938,7 +938,7 @@ PYGLIB_DEFINE_TYPE ("gi.TypeInfo", PyGITypeInfo_Type, PyGIBaseInfo); static PyObject * _wrap_g_type_info_is_pointer (PyGIBaseInfo *self) { - return PyBool_FromLong (g_type_info_is_pointer (self->info)); + return pygi_gboolean_to_py (g_type_info_is_pointer (self->info)); } static PyObject * @@ -1030,7 +1030,7 @@ _wrap_g_function_info_is_constructor (PyGIBaseInfo *self) flags = g_function_info_get_flags ( (GIFunctionInfo*) self->info); is_constructor = flags & GI_FUNCTION_IS_CONSTRUCTOR; - return PyBool_FromLong (is_constructor); + return pygi_gboolean_to_py (is_constructor); } static PyObject * @@ -1042,7 +1042,7 @@ _wrap_g_function_info_is_method (PyGIBaseInfo *self) flags = g_function_info_get_flags ( (GIFunctionInfo*) self->info); is_method = flags & GI_FUNCTION_IS_METHOD; - return PyBool_FromLong (is_method); + return pygi_gboolean_to_py (is_method); } gsize @@ -1538,7 +1538,7 @@ static PyObject * _wrap_g_object_info_get_abstract (PyGIBaseInfo *self) { gboolean is_abstract = g_object_info_get_abstract ( (GIObjectInfo*) self->info); - return PyBool_FromLong (is_abstract); + return pygi_gboolean_to_py (is_abstract); } static PyObject * @@ -1556,7 +1556,7 @@ _wrap_g_object_info_get_type_init (PyGIBaseInfo *self) static PyObject * _wrap_g_object_info_get_fundamental (PyGIBaseInfo *self) { - return PyBool_FromLong (g_object_info_get_fundamental ( (GIObjectInfo*) self->info)); + return pygi_gboolean_to_py (g_object_info_get_fundamental ( (GIObjectInfo*) self->info)); } static PyObject * diff --git a/gi/pygi-type.c b/gi/pygi-type.c index a48352dc..4115b733 100644 --- a/gi/pygi-type.c +++ b/gi/pygi-type.c @@ -312,7 +312,7 @@ _wrap_g_type_wrapper__get_interfaces(PyGTypeWrapper *self, void *closure) static PyObject * _wrap_g_type_wrapper__get_depth(PyGTypeWrapper *self, void *closure) { - return PYGLIB_PyLong_FromLong(g_type_depth(self->type)); + return pygi_guint_to_py (g_type_depth (self->type)); } static PyGetSetDef _PyGTypeWrapper_getsets[] = { @@ -329,55 +329,55 @@ static PyGetSetDef _PyGTypeWrapper_getsets[] = { static PyObject* _wrap_g_type_is_interface(PyGTypeWrapper *self) { - return PyBool_FromLong(G_TYPE_IS_INTERFACE(self->type)); + return pygi_gboolean_to_py (G_TYPE_IS_INTERFACE (self->type)); } static PyObject* _wrap_g_type_is_classed(PyGTypeWrapper *self) { - return PyBool_FromLong(G_TYPE_IS_CLASSED(self->type)); + return pygi_gboolean_to_py (G_TYPE_IS_CLASSED (self->type)); } static PyObject* _wrap_g_type_is_instantiatable(PyGTypeWrapper *self) { - return PyBool_FromLong(G_TYPE_IS_INSTANTIATABLE(self->type)); + return pygi_gboolean_to_py (G_TYPE_IS_INSTANTIATABLE(self->type)); } static PyObject* _wrap_g_type_is_derivable(PyGTypeWrapper *self) { - return PyBool_FromLong(G_TYPE_IS_DERIVABLE(self->type)); + return pygi_gboolean_to_py (G_TYPE_IS_DERIVABLE (self->type)); } static PyObject* _wrap_g_type_is_deep_derivable(PyGTypeWrapper *self) { - return PyBool_FromLong(G_TYPE_IS_DEEP_DERIVABLE(self->type)); + return pygi_gboolean_to_py (G_TYPE_IS_DEEP_DERIVABLE (self->type)); } static PyObject* _wrap_g_type_is_abstract(PyGTypeWrapper *self) { - return PyBool_FromLong(G_TYPE_IS_ABSTRACT(self->type)); + return pygi_gboolean_to_py (G_TYPE_IS_ABSTRACT (self->type)); } static PyObject* _wrap_g_type_is_value_abstract(PyGTypeWrapper *self) { - return PyBool_FromLong(G_TYPE_IS_VALUE_ABSTRACT(self->type)); + return pygi_gboolean_to_py (G_TYPE_IS_VALUE_ABSTRACT (self->type)); } static PyObject* _wrap_g_type_is_value_type(PyGTypeWrapper *self) { - return PyBool_FromLong(G_TYPE_IS_VALUE_TYPE(self->type)); + return pygi_gboolean_to_py (G_TYPE_IS_VALUE_TYPE (self->type)); } static PyObject* _wrap_g_type_has_value_table(PyGTypeWrapper *self) { - return PyBool_FromLong(G_TYPE_HAS_VALUE_TABLE(self->type)); + return pygi_gboolean_to_py (G_TYPE_HAS_VALUE_TABLE (self->type)); } static PyObject* @@ -409,7 +409,7 @@ _wrap_g_type_is_a(PyGTypeWrapper *self, PyObject *args) else if ((parent = pyg_type_from_object(gparent)) == 0) return NULL; - return PyBool_FromLong(g_type_is_a(self->type, parent)); + return pygi_gboolean_to_py (g_type_is_a (self->type, parent)); } static PyMethodDef _PyGTypeWrapper_methods[] = { diff --git a/gi/pygobject-object.c b/gi/pygobject-object.c index 0f5b3e27..1d6d5633 100644 --- a/gi/pygobject-object.c +++ b/gi/pygobject-object.c @@ -32,6 +32,7 @@ #include "pygi-type.h" #include "pygi-property.h" #include "pygi-signal-closure.h" +#include "pygi-basictype.h" extern PyObject *PyGIDeprecationWarning; @@ -1665,7 +1666,7 @@ connect_helper(PyGObject *self, gchar *name, PyObject *callback, PyObject *extra pygobject_watch_closure((PyObject *)self, closure); handlerid = g_signal_connect_closure_by_id(self->obj, sigid, detail, closure, after); - return PyLong_FromUnsignedLong(handlerid); + return pygi_gulong_to_py (handlerid); } static PyObject * @@ -2052,7 +2053,7 @@ pygobject_disconnect_by_func(PyGObject *self, PyObject *args) 0, 0, closure, NULL, NULL); - return PYGLIB_PyLong_FromLong(retval); + return pygi_guint_to_py (retval); } static PyObject * @@ -2086,7 +2087,7 @@ pygobject_handler_block_by_func(PyGObject *self, PyObject *args) 0, 0, closure, NULL, NULL); - return PYGLIB_PyLong_FromLong(retval); + return pygi_guint_to_py (retval); } static PyObject * @@ -2120,7 +2121,7 @@ pygobject_handler_unblock_by_func(PyGObject *self, PyObject *args) 0, 0, closure, NULL, NULL); - return PYGLIB_PyLong_FromLong(retval); + return pygi_guint_to_py (retval); } @@ -2167,7 +2168,7 @@ pygobject_get_refcount(PyGObject *self, void *closure) PyErr_Format(PyExc_TypeError, "GObject instance is not yet created"); return NULL; } - return PYGLIB_PyLong_FromLong(self->obj->ref_count); + return pygi_guint_to_py (self->obj->ref_count); } static PyObject * diff --git a/gi/pygoptioncontext.c b/gi/pygoptioncontext.c index bd4f0f4d..cf34aad2 100644 --- a/gi/pygoptioncontext.c +++ b/gi/pygoptioncontext.c @@ -23,6 +23,7 @@ #include "pygoptioncontext.h" #include "pygi-error.h" #include "pygi-util.h" +#include "pygi-basictype.h" PYGLIB_DEFINE_TYPE("gi._gi.OptionContext", PyGOptionContext_Type, PyGOptionContext) @@ -209,7 +210,7 @@ pyg_option_context_set_help_enabled(PyGOptionContext *self, static PyObject * pyg_option_context_get_help_enabled(PyGOptionContext *self) { - return PyBool_FromLong(g_option_context_get_help_enabled(self->context)); + return pygi_gboolean_to_py (g_option_context_get_help_enabled(self->context)); } static PyObject * @@ -236,7 +237,7 @@ pyg_option_context_set_ignore_unknown_options(PyGOptionContext *self, static PyObject * pyg_option_context_get_ignore_unknown_options(PyGOptionContext *self) { - return PyBool_FromLong( + return pygi_gboolean_to_py ( g_option_context_get_ignore_unknown_options(self->context)); } diff --git a/gi/pygparamspec.c b/gi/pygparamspec.c index 851f2218..091f57b3 100644 --- a/gi/pygparamspec.c +++ b/gi/pygparamspec.c @@ -28,6 +28,7 @@ #include "pygi-type.h" #include "pygparamspec.h" #include "pygi-util.h" +#include "pygi-basictype.h" PYGLIB_DEFINE_TYPE("gobject.GParamSpec", PyGParamSpec_Type, PyGParamSpec); @@ -125,7 +126,7 @@ pyg_param_spec_getattr(PyGParamSpec *self, const gchar *attr) } else if (!strcmp(attr, "blurb") || !strcmp(attr, "__doc__")) { return Py_BuildValue("s", g_param_spec_get_blurb(pspec)); } else if (!strcmp(attr, "flags")) { - return PYGLIB_PyLong_FromLong(pspec->flags); + return pygi_guint_to_py (pspec->flags); } else if (!strcmp(attr, "value_type")) { return pyg_type_wrapper_new(pspec->value_type); } else if (!strcmp(attr, "owner_type")) { @@ -137,70 +138,70 @@ pyg_param_spec_getattr(PyGParamSpec *self, const gchar *attr) return PYGLIB_PyUnicode_FromFormat( "%c", G_PARAM_SPEC_CHAR(pspec)->default_value); } else if (!strcmp(attr, "minimum")) { - return PYGLIB_PyLong_FromLong(G_PARAM_SPEC_CHAR(pspec)->minimum); + return pygi_gint8_to_py (G_PARAM_SPEC_CHAR(pspec)->minimum); } else if (!strcmp(attr, "maximum")) { - return PYGLIB_PyLong_FromLong(G_PARAM_SPEC_CHAR(pspec)->maximum); + return pygi_gint8_to_py (G_PARAM_SPEC_CHAR(pspec)->maximum); } } else if (G_IS_PARAM_SPEC_UCHAR(pspec)) { if (!strcmp(attr, "default_value")) { return PYGLIB_PyUnicode_FromFormat( "%c", G_PARAM_SPEC_UCHAR(pspec)->default_value); } else if (!strcmp(attr, "minimum")) { - return PYGLIB_PyLong_FromLong(G_PARAM_SPEC_UCHAR(pspec)->minimum); + return pygi_guint8_to_py (G_PARAM_SPEC_UCHAR(pspec)->minimum); } else if (!strcmp(attr, "maximum")) { - return PYGLIB_PyLong_FromLong(G_PARAM_SPEC_UCHAR(pspec)->maximum); + return pygi_guint8_to_py (G_PARAM_SPEC_UCHAR(pspec)->maximum); } } else if (G_IS_PARAM_SPEC_BOOLEAN(pspec)) { if (!strcmp(attr, "default_value")) { - return PyBool_FromLong(G_PARAM_SPEC_BOOLEAN(pspec)->default_value); + return pygi_gboolean_to_py (G_PARAM_SPEC_BOOLEAN(pspec)->default_value); } } else if (G_IS_PARAM_SPEC_INT(pspec)) { if (!strcmp(attr, "default_value")) { - return PYGLIB_PyLong_FromLong(G_PARAM_SPEC_INT(pspec)->default_value); + return pygi_gint_to_py (G_PARAM_SPEC_INT(pspec)->default_value); } else if (!strcmp(attr, "minimum")) { - return PYGLIB_PyLong_FromLong(G_PARAM_SPEC_INT(pspec)->minimum); + return pygi_gint_to_py (G_PARAM_SPEC_INT(pspec)->minimum); } else if (!strcmp(attr, "maximum")) { - return PYGLIB_PyLong_FromLong(G_PARAM_SPEC_INT(pspec)->maximum); + return pygi_gint_to_py (G_PARAM_SPEC_INT(pspec)->maximum); } } else if (G_IS_PARAM_SPEC_UINT(pspec)) { if (!strcmp(attr, "default_value")) { - return PyLong_FromUnsignedLong(G_PARAM_SPEC_UINT(pspec)->default_value); + return pygi_guint_to_py (G_PARAM_SPEC_UINT(pspec)->default_value); } else if (!strcmp(attr, "minimum")) { - return PyLong_FromUnsignedLong(G_PARAM_SPEC_UINT(pspec)->minimum); + return pygi_guint_to_py (G_PARAM_SPEC_UINT(pspec)->minimum); } else if (!strcmp(attr, "maximum")) { - return PyLong_FromUnsignedLong(G_PARAM_SPEC_UINT(pspec)->maximum); + return pygi_guint_to_py (G_PARAM_SPEC_UINT(pspec)->maximum); } } else if (G_IS_PARAM_SPEC_LONG(pspec)) { if (!strcmp(attr, "default_value")) { - return PyLong_FromLong(G_PARAM_SPEC_LONG(pspec)->default_value); + return pygi_glong_to_py (G_PARAM_SPEC_LONG(pspec)->default_value); } else if (!strcmp(attr, "minimum")) { - return PyLong_FromLong(G_PARAM_SPEC_LONG(pspec)->minimum); + return pygi_glong_to_py (G_PARAM_SPEC_LONG(pspec)->minimum); } else if (!strcmp(attr, "maximum")) { - return PyLong_FromLong(G_PARAM_SPEC_LONG(pspec)->maximum); + return pygi_glong_to_py (G_PARAM_SPEC_LONG(pspec)->maximum); } } else if (G_IS_PARAM_SPEC_ULONG(pspec)) { if (!strcmp(attr, "default_value")) { - return PyLong_FromUnsignedLong(G_PARAM_SPEC_ULONG(pspec)->default_value); + return pygi_gulong_to_py (G_PARAM_SPEC_ULONG(pspec)->default_value); } else if (!strcmp(attr, "minimum")) { - return PyLong_FromUnsignedLong(G_PARAM_SPEC_ULONG(pspec)->minimum); + return pygi_gulong_to_py (G_PARAM_SPEC_ULONG(pspec)->minimum); } else if (!strcmp(attr, "maximum")) { - return PyLong_FromUnsignedLong(G_PARAM_SPEC_ULONG(pspec)->maximum); + return pygi_gulong_to_py (G_PARAM_SPEC_ULONG(pspec)->maximum); } } else if (G_IS_PARAM_SPEC_INT64(pspec)) { if (!strcmp(attr, "default_value")) { - return PyLong_FromLongLong(G_PARAM_SPEC_INT64(pspec)->default_value); + return pygi_gint64_to_py (G_PARAM_SPEC_INT64(pspec)->default_value); } else if (!strcmp(attr, "minimum")) { - return PyLong_FromLongLong(G_PARAM_SPEC_INT64(pspec)->minimum); + return pygi_gint64_to_py (G_PARAM_SPEC_INT64(pspec)->minimum); } else if (!strcmp(attr, "maximum")) { - return PyLong_FromLongLong(G_PARAM_SPEC_INT64(pspec)->maximum); + return pygi_gint64_to_py (G_PARAM_SPEC_INT64(pspec)->maximum); } } else if (G_IS_PARAM_SPEC_UINT64(pspec)) { if (!strcmp(attr, "default_value")) { - return PyLong_FromUnsignedLongLong(G_PARAM_SPEC_UINT64(pspec)->default_value); + return pygi_guint64_to_py (G_PARAM_SPEC_UINT64(pspec)->default_value); } else if (!strcmp(attr, "minimum")) { - return PyLong_FromUnsignedLongLong(G_PARAM_SPEC_UINT64(pspec)->minimum); + return pygi_guint64_to_py (G_PARAM_SPEC_UINT64(pspec)->minimum); } else if (!strcmp(attr, "maximum")) { - return PyLong_FromUnsignedLongLong(G_PARAM_SPEC_UINT64(pspec)->maximum); + return pygi_guint64_to_py (G_PARAM_SPEC_UINT64(pspec)->maximum); } } else if (G_IS_PARAM_SPEC_UNICHAR(pspec)) { if (!strcmp(attr, "default_value")) { @@ -223,24 +224,24 @@ pyg_param_spec_getattr(PyGParamSpec *self, const gchar *attr) } } else if (G_IS_PARAM_SPEC_FLOAT(pspec)) { if (!strcmp(attr, "default_value")) { - return PyFloat_FromDouble(G_PARAM_SPEC_FLOAT(pspec)->default_value); + return pygi_gfloat_to_py (G_PARAM_SPEC_FLOAT(pspec)->default_value); } else if (!strcmp(attr, "minimum")) { - return PyFloat_FromDouble(G_PARAM_SPEC_FLOAT(pspec)->minimum); + return pygi_gfloat_to_py (G_PARAM_SPEC_FLOAT(pspec)->minimum); } else if (!strcmp(attr, "maximum")) { - return PyFloat_FromDouble(G_PARAM_SPEC_FLOAT(pspec)->maximum); + return pygi_gfloat_to_py (G_PARAM_SPEC_FLOAT(pspec)->maximum); } else if (!strcmp(attr, "epsilon")) { - return PyFloat_FromDouble(G_PARAM_SPEC_FLOAT(pspec)->epsilon); + return pygi_gfloat_to_py (G_PARAM_SPEC_FLOAT(pspec)->epsilon); } } else if (G_IS_PARAM_SPEC_DOUBLE(pspec)) { if (!strcmp(attr, "default_value")) { - return PyFloat_FromDouble( + return pygi_gdouble_to_py ( G_PARAM_SPEC_DOUBLE(pspec)->default_value); } else if (!strcmp(attr, "minimum")) { - return PyFloat_FromDouble(G_PARAM_SPEC_DOUBLE(pspec)->minimum); + return pygi_gdouble_to_py (G_PARAM_SPEC_DOUBLE(pspec)->minimum); } else if (!strcmp(attr, "maximum")) { - return PyFloat_FromDouble(G_PARAM_SPEC_DOUBLE(pspec)->maximum); + return pygi_gdouble_to_py (G_PARAM_SPEC_DOUBLE(pspec)->maximum); } else if (!strcmp(attr, "epsilon")) { - return PyFloat_FromDouble(G_PARAM_SPEC_DOUBLE(pspec)->epsilon); + return pygi_gdouble_to_py (G_PARAM_SPEC_DOUBLE(pspec)->epsilon); } } else if (G_IS_PARAM_SPEC_STRING(pspec)) { if (!strcmp(attr, "default_value")) { @@ -256,10 +257,10 @@ pyg_param_spec_getattr(PyGParamSpec *self, const gchar *attr) return Py_BuildValue( "c", G_PARAM_SPEC_STRING(pspec)->substitutor); } else if (!strcmp(attr, "null_fold_if_empty")) { - return PyBool_FromLong( + return pygi_gboolean_to_py ( G_PARAM_SPEC_STRING(pspec)->null_fold_if_empty); } else if (!strcmp(attr, "ensure_non_null")) { - return PyBool_FromLong( + return pygi_gboolean_to_py ( G_PARAM_SPEC_STRING(pspec)->ensure_non_null); } } else { diff --git a/gi/pygspawn.c b/gi/pygspawn.c index e97f3fbf..9457c6de 100644 --- a/gi/pygspawn.c +++ b/gi/pygspawn.c @@ -23,6 +23,7 @@ #include <glib.h> #include "pygi-python-compat.h" +#include "pygi-basictype.h" #include "pygspawn.h" #include "pygi-error.h" @@ -77,7 +78,7 @@ pyg_pid_new(GPid pid) #ifdef G_OS_WIN32 long_val = PyLong_FromVoidPtr (pid); #else - long_val = PYGLIB_PyLong_FromLong (pid); + long_val = pygi_gint_to_py (pid); #endif return PyObject_CallMethod((PyObject*)&PyGPid_Type, "__new__", "ON", &PyGPid_Type, long_val); @@ -236,21 +237,21 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs) if (envp) g_free(envp); if (standard_input) - pystdin = PYGLIB_PyLong_FromLong(*standard_input); + pystdin = pygi_gint_to_py(*standard_input); else { Py_INCREF(Py_None); pystdin = Py_None; } if (standard_output) - pystdout = PYGLIB_PyLong_FromLong(*standard_output); + pystdout = pygi_gint_to_py(*standard_output); else { Py_INCREF(Py_None); pystdout = Py_None; } if (standard_error) - pystderr = PYGLIB_PyLong_FromLong(*standard_error); + pystderr = pygi_gint_to_py(*standard_error); else { Py_INCREF(Py_None); pystderr = Py_None; |