diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2025-03-28 04:45:19 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2025-03-28 04:45:19 (GMT) | 
| commit | 41f0c0f9089ec941ceb70e2a6ad1b958483eb2ae (patch) | |
| tree | a065a5e463e5ec4253568e5b36c891988362c7b3 /plugins/pychrysalide | |
| parent | ec6706fe5e9b71ece7f2a6770f57f6757c375b33 (diff) | |
Add a locking feature to thick objects.
Diffstat (limited to 'plugins/pychrysalide')
| -rw-r--r-- | plugins/pychrysalide/glibext/objhole.c | 102 | 
1 files changed, 101 insertions, 1 deletions
| diff --git a/plugins/pychrysalide/glibext/objhole.c b/plugins/pychrysalide/glibext/objhole.c index 2a3ad6f..6bea5d1 100644 --- a/plugins/pychrysalide/glibext/objhole.c +++ b/plugins/pychrysalide/glibext/objhole.c @@ -37,12 +37,25 @@ -CREATE_DYN_CONSTRUCTOR(thick_object, G_TYPE_THICK_OBJECT); +/* ------------------------ GLUE POUR CREATION DEPUIS PYTHON ------------------------ */ + +CREATE_DYN_CONSTRUCTOR(thick_object, G_TYPE_THICK_OBJECT);  /* Initialise une instance sur la base du dérivé de GObject. */  static int py_thick_object_init(PyObject *, PyObject *, PyObject *); + + +/* ------------------ LIAISON DE FONCTIONNALITES AVEC L'API PYTHON ------------------ */ + + +/* Pose un verrou à l'aide du bit dédié de GObject. */ +static PyObject *py_thick_object_lock(PyObject *, PyObject *); + +/* Retire un verrou via le bit dédié de GObject. */ +static PyObject *py_thick_object_unlock(PyObject *, PyObject *); +  /* Indique le nombre de bits accaparés par la GLib. */  static PyObject *py_thick_object_get__GOBJECT_RESERVED_EXTRA_BITS(PyObject *, void *); @@ -54,6 +67,11 @@ static int py_thick_object_set_extra(PyObject *, PyObject *, void *); +/* ---------------------------------------------------------------------------------- */ +/*                          GLUE POUR CREATION DEPUIS PYTHON                          */ +/* ---------------------------------------------------------------------------------- */ + +  /******************************************************************************  *                                                                             *  *  Paramètres  : self = objet à initialiser (théoriquement).                  * @@ -92,6 +110,86 @@ static int py_thick_object_init(PyObject *self, PyObject *args, PyObject *kwds)  } + +/* ---------------------------------------------------------------------------------- */ +/*                    LIAISON DE FONCTIONNALITES AVEC L'API PYTHON                    */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : self = instance représentant une extension d'objet.          * +*                args = arguments fournis à l'appel, non utilisé ici.         * +*                                                                             * +*  Description : Pose un verrou à l'aide du bit dédié de GObject.             * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static PyObject *py_thick_object_lock(PyObject *self, PyObject *args) +{ +    PyObject *result;                       /* Résultat à retourner        */ +    GThickObject *obj;                      /* Version GLib de l'instance  */ + +#define THICK_OBJECT_LOCK_METHOD PYTHON_METHOD_DEF      \ +(                                                       \ +    lock, "$self",                                      \ +    METH_NOARGS, py_thick_object,                       \ +    "Lock the object using the internal GLib bit.\n"    \ +) + +    obj = G_THICK_OBJECT(pygobject_get(self)); + +    g_thick_object_lock(obj); + +    result = Py_None; +    Py_INCREF(result); + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : self = instance représentant une extension d'objet.          * +*                args = arguments fournis à l'appel, non utilisé ici.         * +*                                                                             * +*  Description : Retire un verrou via le bit dédié de GObject.                * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static PyObject *py_thick_object_unlock(PyObject *self, PyObject *args) +{ +    PyObject *result;                       /* Résultat à retourner        */ +    GThickObject *obj;                      /* Version GLib de l'instance  */ + +#define THICK_OBJECT_UNLOCK_METHOD PYTHON_METHOD_DEF    \ +(                                                       \ +    unlock, "$self",                                    \ +    METH_NOARGS, py_thick_object,                       \ +    "Unlock the object using the internal GLib bit.\n"  \ +) + +    obj = G_THICK_OBJECT(pygobject_get(self)); + +    g_thick_object_unlock(obj); + +    result = Py_None; +    Py_INCREF(result); + +    return result; + +} + +  /******************************************************************************  *                                                                             *  *  Paramètres  : self    = objet Python concerné par l'appel.                 * @@ -215,6 +313,8 @@ static int py_thick_object_set_extra(PyObject *self, PyObject *value, void *clos  PyTypeObject *get_python_thick_object_type(void)  {      static PyMethodDef py_thick_object_methods[] = { +        THICK_OBJECT_LOCK_METHOD, +        THICK_OBJECT_UNLOCK_METHOD,          { NULL }      }; | 
