diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2022-02-22 12:57:05 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2022-02-22 12:57:05 (GMT) | 
| commit | fbde6e0ebfc5b0203eda1c5fe3c6ba72d1427896 (patch) | |
| tree | f825dde8617b9efa0e77124785e8afa3f9d1a031 /plugins/pychrysalide/helpers.h | |
| parent | 8bf77ba6e5ef40d8bb936dc952ac2c8cc30aab3e (diff) | |
Introduce a generic way to subclass Python analysis clients.
Diffstat (limited to 'plugins/pychrysalide/helpers.h')
| -rw-r--r-- | plugins/pychrysalide/helpers.h | 16 | 
1 files changed, 16 insertions, 0 deletions
diff --git a/plugins/pychrysalide/helpers.h b/plugins/pychrysalide/helpers.h index 0ef8adc..32851c0 100644 --- a/plugins/pychrysalide/helpers.h +++ b/plugins/pychrysalide/helpers.h @@ -158,6 +158,22 @@ bool register_python_module_object(PyObject *, PyTypeObject *);  #define APPLY_ABSTRACT_FLAG(tp) tp->tp_new = PyBaseObject_Type.tp_new +/* Accompagne la création d'une instance dérivée en Python. */ +PyObject *python_constructor_with_dynamic_gtype(PyTypeObject *, PyObject *, PyObject *, PyTypeObject *, GType); + + +#define CREATE_DYN_CONSTRUCTOR(pyname, gbase)                                               \ +static PyObject *py_ ## pyname ## _new(PyTypeObject *, PyObject *, PyObject *);             \ +static PyObject *py_ ## pyname ## _new(PyTypeObject *type, PyObject *args, PyObject *kwds)  \ +{                                                                                           \ +    PyObject *result;                       /* Objet à retourner           */               \ +    PyTypeObject *base;                     /* Type de base à dériver      */               \ +    base = get_python_ ## pyname ## _type();                                                \ +    result = python_constructor_with_dynamic_gtype(type, args, kwds, base, gbase);          \ +    return result;                                                                          \ +} + +  /* Marque l'interdiction d'une instanciation depuis Python. */  PyObject *no_python_constructor_allowed(PyTypeObject *, PyObject *, PyObject *);  | 
