summaryrefslogtreecommitdiff
path: root/gi/pygspawn.c
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:46:23 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:46:27 +0900
commit392945d666d2cfb31a844826a72b1eb65a52546f (patch)
treea21354051734cbace4e92d6b10c8fa8cd2721dda /gi/pygspawn.c
parent4723e0bb24cc41607e5af3bb7036855fa767df0b (diff)
downloadpygobject2-392945d666d2cfb31a844826a72b1eb65a52546f.tar.gz
pygobject2-392945d666d2cfb31a844826a72b1eb65a52546f.tar.bz2
pygobject2-392945d666d2cfb31a844826a72b1eb65a52546f.zip
Imported Upstream version 3.25.1
Change-Id: I31412b37aa390505e71295f3a2c2e3cf2ba88b41 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'gi/pygspawn.c')
-rw-r--r--gi/pygspawn.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/gi/pygspawn.c b/gi/pygspawn.c
index c66c50f..7828d23 100644
--- a/gi/pygspawn.c
+++ b/gi/pygspawn.c
@@ -32,12 +32,22 @@ struct _PyGChildSetupData {
PyObject *data;
};
-PYGLIB_DEFINE_TYPE("gi._glib.Pid", PyGPid_Type, PYGLIB_PyLongObject)
+PYGLIB_DEFINE_TYPE("gi._gi.Pid", PyGPid_Type, PYGLIB_PyLongObject)
+
+static GPid
+pyg_pid_get_pid (PyObject *self)
+{
+#ifdef G_OS_WIN32
+ return (GPid)PyLong_AsVoidPtr (self);
+#else
+ return (GPid)PYGLIB_PyLong_AsLong (self);
+#endif
+}
static PyObject *
pyg_pid_close(PyObject *self, PyObject *args, PyObject *kwargs)
{
- g_spawn_close_pid(PYGLIB_PyLong_AsLong(self));
+ g_spawn_close_pid(pyg_pid_get_pid (self));
Py_INCREF(Py_None);
return Py_None;
}
@@ -50,22 +60,28 @@ static PyMethodDef pyg_pid_methods[] = {
static void
pyg_pid_free(PyObject *gpid)
{
- g_spawn_close_pid((GPid) PYGLIB_PyLong_AsLong(gpid));
+ g_spawn_close_pid(pyg_pid_get_pid (gpid));
PYGLIB_PyLong_Type.tp_free((void *) gpid);
}
static int
pyg_pid_tp_init(PyObject *self, PyObject *args, PyObject *kwargs)
{
- PyErr_SetString(PyExc_TypeError, "gi._glib.Pid cannot be manually instantiated");
+ PyErr_SetString(PyExc_TypeError, "gi._gi.Pid cannot be manually instantiated");
return -1;
}
PyObject *
pyg_pid_new(GPid pid)
{
- return PyObject_CallMethod((PyObject*)&PyGPid_Type, "__new__", "Oi",
- &PyGPid_Type, pid);
+ PyObject *long_val;
+#ifdef G_OS_WIN32
+ long_val = PyLong_FromVoidPtr (pid);
+#else
+ long_val = PYGLIB_PyLong_FromLong (pid);
+#endif
+ return PyObject_CallMethod((PyObject*)&PyGPid_Type, "__new__", "ON",
+ &PyGPid_Type, long_val);
}
static void
@@ -76,7 +92,7 @@ _pyg_spawn_async_callback(gpointer user_data)
PyGILState_STATE gil;
data = (struct _PyGChildSetupData *) user_data;
- gil = pyglib_gil_state_ensure();
+ gil = PyGILState_Ensure();
if (data->data)
retval = PyObject_CallFunction(data->func, "O", data->data);
else
@@ -88,7 +104,7 @@ _pyg_spawn_async_callback(gpointer user_data)
Py_DECREF(data->func);
Py_XDECREF(data->data);
g_slice_free(struct _PyGChildSetupData, data);
- pyglib_gil_state_release(gil);
+ PyGILState_Release(gil);
}
PyObject *
@@ -106,10 +122,10 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs)
gint *standard_input, *standard_output, *standard_error;
struct _PyGChildSetupData *callback_data = NULL;
GError *error = NULL;
- GPid child_pid = -1;
+ GPid child_pid = 0;
Py_ssize_t len, i;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OsiOOOOO:gi._glib.spawn_async",
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OsiOOOOO:gi._gi.spawn_async",
kwlist,
&pyargv, &pyenvp, &working_directory, &flags,
&func, &user_data,
@@ -134,7 +150,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs)
/* parse argv */
if (!PySequence_Check(pyargv)) {
PyErr_SetString(PyExc_TypeError,
- "gi._glib.spawn_async: "
+ "gi._gi.spawn_async: "
"first argument must be a sequence of strings");
return NULL;
}
@@ -144,7 +160,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs)
PyObject *tmp = PySequence_ITEM(pyargv, i);
if (tmp == NULL || !PYGLIB_PyUnicode_Check(tmp)) {
PyErr_SetString(PyExc_TypeError,
- "gi._glib.spawn_async: "
+ "gi._gi.spawn_async: "
"first argument must be a sequence of strings");
g_free(argv);
Py_XDECREF(tmp);
@@ -158,7 +174,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs)
if (pyenvp) {
if (!PySequence_Check(pyenvp)) {
PyErr_SetString(PyExc_TypeError,
- "gi._glib.spawn_async: "
+ "gi._gi.spawn_async: "
"second argument must be a sequence of strings");
g_free(argv);
return NULL;
@@ -169,7 +185,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs)
PyObject *tmp = PySequence_ITEM(pyenvp, i);
if (tmp == NULL || !PYGLIB_PyUnicode_Check(tmp)) {
PyErr_SetString(PyExc_TypeError,
- "gi._glib.spawn_async: "
+ "gi._gi.spawn_async: "
"second argument must be a sequence of strings");
g_free(envp);
Py_XDECREF(tmp);