diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/pychrysalide/glibext/buffercache.c | 134 |
1 files changed, 120 insertions, 14 deletions
diff --git a/plugins/pychrysalide/glibext/buffercache.c b/plugins/pychrysalide/glibext/buffercache.c index d3bee45..0cf3342 100644 --- a/plugins/pychrysalide/glibext/buffercache.c +++ b/plugins/pychrysalide/glibext/buffercache.c @@ -55,6 +55,12 @@ static int py_buffer_cache_init(PyObject *, PyObject *, PyObject *); /* -------------------------- TAMPON POUR CODE DESASSEMBLE -------------------------- */ +/* Met à disposition un encadrement des accès aux lignes. */ +static PyObject *py_buffer_cache_lock(PyObject *, PyObject *); + +/* Met à disposition un encadrement des accès aux lignes. */ +static PyObject *py_buffer_cache_unlock(PyObject *, PyObject *); + /* Insère un générateur dans des lignes à une position donnée. */ static PyObject *py_buffer_cache_insert_at(PyObject *, PyObject *); @@ -243,6 +249,104 @@ static int py_buffer_cache_init(PyObject *self, PyObject *args, PyObject *kwds) * Paramètres : self = classe représentant un tampon de code. * * args = arguments fournis à l'appel. * * * +* Description : Met à disposition un encadrement des accès aux lignes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_buffer_cache_lock(PyObject *self, PyObject *args) +{ + PyObject *result; /* Trouvailles à retourner */ + int write; /* Type de verrou à poser */ + int ret; /* Bilan de lecture des args. */ + GBufferCache *cache; /* Tampon natif à consulter */ + +#define BUFFER_CACHE_LOCK_METHOD PYTHON_METHOD_DEF \ +( \ + lock, "$self, /, write=False", \ + METH_VARARGS, py_buffer_cache, \ + "Lock for access the content of a buffer cache instance.\n" \ + "\n" \ + "The *write* parameter is a boolean value which has to be set" \ + " if the access to perform will modify the buffer cache.\n" \ + "\n" \ + "Each call of this method has to followed by a call to" \ + " pychrysalide.glibext.BufferCache.unlock(), with the same" \ + " *write* parameter." \ +) + + write = 0; + + ret = PyArg_ParseTuple(args, "|p", &write); + if (!ret) return NULL; + + cache = G_BUFFER_CACHE(pygobject_get(self)); + + g_buffer_cache_lock_unlock(cache, write, true); + + result = Py_None; + Py_INCREF(result); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : self = classe représentant un tampon de code. * +* args = arguments fournis à l'appel. * +* * +* Description : Met à disposition un encadrement des accès aux lignes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_buffer_cache_unlock(PyObject *self, PyObject *args) +{ + PyObject *result; /* Trouvailles à retourner */ + int write; /* Type de verrou à poser */ + int ret; /* Bilan de lecture des args. */ + GBufferCache *cache; /* Tampon natif à consulter */ + +#define BUFFER_CACHE_UNLOCK_METHOD PYTHON_METHOD_DEF \ +( \ + unlock, "$self, /, write=False", \ + METH_VARARGS, py_buffer_cache, \ + "Unlock the content of a buffer cache instance.\n" \ + "\n" \ + "The *write* parameter is a boolean value which has to be set" \ + " if the performed access has modified the buffer cache.\n" \ +) + + write = 0; + + ret = PyArg_ParseTuple(args, "|p", &write); + if (!ret) return NULL; + + cache = G_BUFFER_CACHE(pygobject_get(self)); + + g_buffer_cache_lock_unlock(cache, write, false); + + result = Py_None; + Py_INCREF(result); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : self = classe représentant un tampon de code. * +* args = arguments fournis à l'appel. * +* * * Description : Insère un générateur dans des lignes à une position donnée. * * * * Retour : - * @@ -276,7 +380,7 @@ static PyObject *py_buffer_cache_insert_at(PyObject *self, PyObject *args) " extra pychrysalide.glibext.BufferLine.BufferLineFlags" \ " values.\n" \ "\n" \ - "An access lock has to be held for the cache; see the" \ + "An write access lock has to be held for the cache; see the" \ " pychrysalide.glibext.BufferCache.lock() function." \ ) @@ -326,7 +430,7 @@ static PyObject *py_buffer_cache_delete_at(PyObject *self, PyObject *args) METH_VARARGS, py_buffer_cache, \ "Delete the line at the *index* position from a buffer cache.\n" \ "\n" \ - "An access lock has to be held for the cache; see the" \ + "An write access lock has to be held for the cache; see the" \ " pychrysalide.glibext.BufferCache.lock() function." \ ) @@ -384,7 +488,7 @@ static PyObject *py_buffer_cache_delete_type_at(PyObject *self, PyObject *args) "The function returns the deleted generator as a" \ " pychrysalide.glibext.LineGenerator instance, or None if none found.\n"\ "\n" \ - "An access lock has to be held for the cache; see the" \ + "An write access lock has to be held for the cache; see the" \ " pychrysalide.glibext.BufferCache.lock() function." \ ) @@ -451,7 +555,7 @@ static PyObject *py_buffer_cache_append(PyObject *self, PyObject *args) " properties can be set for the line as extra" \ " pychrysalide.glibext.BufferLine.BufferLineFlags values.\n" \ "\n" \ - "An access lock has to be held for the cache; see the" \ + "An write access lock has to be held for the cache; see the" \ " pychrysalide.glibext.BufferCache.lock() function." \ ) @@ -504,9 +608,9 @@ static PyObject *py_buffer_cache_extend_with(PyObject *self, PyObject *args) " quantity, otherwise the call makes no sense. The generator" \ " is a pychrysalide.glibext.LineGenerator instance used to" \ " produce the extra new lines on demand." \ - "\n" \ - "An access lock has to be held for the cache; see the" \ - " pychrysalide.glibext.BufferCache.lock() function." \ + "\n" \ + "An write access lock has to be held for the cache; see the" \ + " pychrysalide.glibext.BufferCache.lock() function." \ ) ret = PyArg_ParseTuple(args, "nO&", &count, convert_to_line_generator, &generator); @@ -553,7 +657,7 @@ static PyObject *py_buffer_cache_truncate(PyObject *self, PyObject *args) "The *max* number should be lesser than the current line quantity," \ " otherwise no effect will happen." \ "\n" \ - "An access lock has to be held for the cache; see the" \ + "An write access lock has to be held for the cache; see the" \ " pychrysalide.glibext.BufferCache.lock() function." \ ) @@ -603,7 +707,7 @@ static PyObject *py_buffer_cache_add_line_flag(PyObject *self, PyObject *args) "The *index* has to be a simple integer, and the *flag* a" \ " pychrysalide.glibext.BufferLine.BufferLineFlags value.\n" \ "\n" \ - "An access lock has to be held for the cache; see the" \ + "An write access lock has to be held for the cache; see the" \ " pychrysalide.glibext.BufferCache.lock() function." \ ) @@ -653,7 +757,7 @@ static PyObject *py_buffer_cache_get_line_flags(PyObject *self, PyObject *args) "The result is a pychrysalide.glibext.BufferLine.BufferLineFlags" \ " value.\n" \ "\n" \ - "An access lock has to be held for the cache; see the" \ + "An read access lock has to be held for the cache; see the" \ " pychrysalide.glibext.BufferCache.lock() function." \ ) @@ -702,7 +806,7 @@ static PyObject *py_buffer_cache_remove_line_flag(PyObject *self, PyObject *args "The *index* has to be a simple integer, and the *flag* a" \ " pychrysalide.glibext.BufferLine.BufferLineFlags value.\n" \ "\n" \ - "An access lock has to be held for the cache; see the" \ + "An write access lock has to be held for the cache; see the" \ " pychrysalide.glibext.BufferCache.lock() function." \ ) @@ -751,7 +855,7 @@ static PyObject *py_buffer_cache_find_line_by_index(PyObject *self, PyObject *ar "The result is a pychrysalide.glibext.BufferLine instance or" \ " None.\n" \ "\n" \ - "An access lock has to be held for the cache; see the" \ + "An read access lock has to be held for the cache; see the" \ " pychrysalide.glibext.BufferCache.lock() function." \ ) @@ -815,7 +919,7 @@ static PyObject *py_buffer_cache_look_for_flag(PyObject *self, PyObject *args) " or, if no match is found, the number of lines in the buffer" \ " cache.\n" \ "\n" \ - "An access lock has to be held for the cache; see the" \ + "An read access lock has to be held for the cache; see the" \ " pychrysalide.glibext.BufferCache.lock() function." \ ) @@ -1012,7 +1116,7 @@ static PyObject *py_buffer_cache_get_lines_count(PyObject *self, void *closure) lines_count, py_buffer_cache, \ "Count the number of lines contained in a buffer cache.\n" \ "\n" \ - "An access lock has to be held for the cache; see the" \ + "An read access lock has to be held for the cache; see the" \ " pychrysalide.glibext.BufferCache.lock() function." \ ) @@ -1042,6 +1146,8 @@ static PyObject *py_buffer_cache_get_lines_count(PyObject *self, void *closure) PyTypeObject *get_python_buffer_cache_type(void) { static PyMethodDef py_buffer_cache_methods[] = { + BUFFER_CACHE_LOCK_METHOD, + BUFFER_CACHE_UNLOCK_METHOD, BUFFER_CACHE_INSERT_AT_METHOD, BUFFER_CACHE_DELETE_AT_METHOD, BUFFER_CACHE_DELETE_TYPE_AT_METHOD, |