diff options
Diffstat (limited to 'plugins/pychrysa/arch')
| -rw-r--r-- | plugins/pychrysa/arch/instruction.c | 190 | 
1 files changed, 0 insertions, 190 deletions
| diff --git a/plugins/pychrysa/arch/instruction.c b/plugins/pychrysa/arch/instruction.c index 9e676d2..8ebdef0 100644 --- a/plugins/pychrysa/arch/instruction.c +++ b/plugins/pychrysa/arch/instruction.c @@ -403,32 +403,6 @@ bool register_python_arch_instruction(PyObject *module) -/* --------------------- ITERATEUR POUR BOUCLE SUR INSTRUCTIONS --------------------- */ - - -/* Itérateur pour les instructions */ -typedef struct _PyArchInstructionIter -{ -    PyObject_HEAD                           /* A laisser en premier        */ - -    GArchInstruction *head;                 /* Ancrage supposé             */ -    PyObject *current;                      /* Départ, puis parcours...    */ -    bool started;                           /* Démarrage effectué ?        */ - -} PyArchInstructionIter; - - -/* Prépare l'itérateur pour un parcours d'instructions. */ -static PyObject *py_arch_instruction_iterator_create(PyObject *); - -/* Libère la mémoire d'un itérateur de 'ArchInstruction'. */ -static void py_arch_instruction_iterator_dealloc(PyArchInstructionIter *); - -/* Fournit l'élément suivant dans un parcours d'instructions. */ -static PyObject *py_arch_instruction_iterator_next(PyArchInstructionIter *); - - -  /* --------------------- INSTRUCTIONS D'ARCHITECTURES EN PYTHON --------------------- */ @@ -447,170 +421,6 @@ static PyObject *py_arch_instruction_get_keyword(PyObject *, void *);  /* ---------------------------------------------------------------------------------- */ -/*                       ITERATEUR POUR BOUCLE SUR INSTRUCTIONS                       */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : origin = élément à l'origine du parcours.                    * -*                                                                             * -*  Description : Prépare l'itérateur pour un parcours d'instructions.         * -*                                                                             * -*  Retour      : Instance d'itérateur prête à emploi.                         * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyObject *py_arch_instruction_iterator_create(PyObject *origin) -{ -    PyArchInstructionIter *result;          /* Nouvelle instance à renvoyer*/ -    PyObject *module;                       /* Module d'appartenance       */ -    PyTypeObject *type;                     /* Type d'objet à créer        */ - -    module = PyImport_ImportModule("pychrysalide.arch"); -    type = (PyTypeObject *)PyObject_GetAttrString(module, "ArchInstructionIterator"); -    Py_DECREF(module); - -    result = (PyArchInstructionIter *)type->tp_alloc(type, 0); -    Py_DECREF(type); - -    if (result != NULL) -    { -        Py_INCREF(origin); -        result->head = G_ARCH_INSTRUCTION(pygobject_get(origin)); -        g_object_ref(G_OBJECT(result->head)); - -        result->current = origin; -    } - -    return (PyObject *)result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : self = instance d'objet à supprimer.                         * -*                                                                             * -*  Description : Libère la mémoire d'un itérateur de 'ArchInstruction'.       * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void py_arch_instruction_iterator_dealloc(PyArchInstructionIter *self) -{ -    PyObject *first;                        /* Récupération de la première */ - -    first = pygobject_new(G_OBJECT(self->head)); - -    Py_DECREF(first); -    g_object_unref(G_OBJECT(self->head)); - -#if PY_VERSION_HEX < 0x03000000 -    self->ob_type->tp_free((PyObject *)self); -#else -    Py_TYPE(self)->tp_free((PyObject *)self); -#endif - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : self = instance manipulée à traiter.                         * -*                                                                             * -*  Description : Fournit l'élément suivant dans un parcours d'instructions.   * -*                                                                             * -*  Retour      : Point suivant du parcours ou NULL.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyObject *py_arch_instruction_iterator_next(PyArchInstructionIter *self) -{ -    PyObject *result;                       /* Elément à retourner         */ -    GArchInstruction *next;                 /* Elément réel suivant        */ - -    if (!self->started) -    { -        self->started = true; -        result = self->current; -        Py_INCREF(result); - -    } -    else -    { -        next = G_ARCH_INSTRUCTION(pygobject_get(self->current)); -        next = g_arch_instruction_get_next_iter(self->head, next, VMPA_MAX); - -        if (next != NULL) -        { -            result = pygobject_new(G_OBJECT(next)); -            self->current = result; -        } -        else result = NULL; - -    } - -    Py_XINCREF(result); -    return (PyObject *)result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : module = module dont la définition est à compléter.          * -*                                                                             * -*  Description : Permet une itération de 'pychrysalide.arch.ArchInstruction'. * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool register_python_arch_instruction_iterator(PyObject *module) -{ -    int ret;                                /* Bilan d'un appel            */ - -    static PyTypeObject py_arch_instruction_iterator_type = { - -        PyObject_HEAD_INIT(NULL) - -        .tp_name        = "pychrysalide.arch.ArchInstructionIterator", -        .tp_basicsize   = sizeof(PyArchInstructionIter), - -        .tp_dealloc     = (destructor)py_arch_instruction_iterator_dealloc, - -        //.tp_flags       = Py_TPFLAGS_HAVE_ITER | Py_TPFLAGS_HAVE_CLASS, - -        .tp_doc         = "PyChrysalide architecture instruction iterator", - -        .tp_iter        = PyObject_SelfIter, -        .tp_iternext    = (iternextfunc)py_arch_instruction_iterator_next - -    }; - -    if (PyType_Ready(&py_arch_instruction_iterator_type) < 0) -        return false; - -    Py_INCREF(&py_arch_instruction_iterator_type); -    ret = PyModule_AddObject(module, "ArchInstructionIterator", (PyObject *)&py_arch_instruction_iterator_type); - -    return (ret == 0); - -} - - - -/* ---------------------------------------------------------------------------------- */  /*                       INSTRUCTIONS D'ARCHITECTURES EN PYTHON                       */  /* ---------------------------------------------------------------------------------- */ | 
