diff options
Diffstat (limited to 'plugins/pychrysalide/arch/constants.c')
| -rw-r--r-- | plugins/pychrysalide/arch/constants.c | 56 | 
1 files changed, 56 insertions, 0 deletions
| diff --git a/plugins/pychrysalide/arch/constants.c b/plugins/pychrysalide/arch/constants.c index f738ec3..04d0917 100644 --- a/plugins/pychrysalide/arch/constants.c +++ b/plugins/pychrysalide/arch/constants.c @@ -192,3 +192,59 @@ bool define_proc_context_constants(PyTypeObject *type)      return result;  } + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : arg = argument quelconque à tenter de convertir.             * +*                dst = destination des valeurs récupérées en cas de succès.   * +*                                                                             * +*  Description : Tente de convertir en constante DisassPriorityLevel.         * +*                                                                             * +*  Retour      : Bilan de l'opération, voire indications supplémentaires.     * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +int convert_to_disass_priority_level(PyObject *arg, void *dst) +{ +    int result;                             /* Bilan à retourner           */ +    unsigned long value;                    /* Valeur transcrite           */ + +    result = PyObject_IsInstance(arg, (PyObject *)&PyLong_Type); + +    switch (result) +    { +        case -1: +            /* L'exception est déjà fixée par Python */ +            result = 0; +            break; + +        case 0: +            PyErr_SetString(PyExc_TypeError, "unable to convert the provided argument to DisassPriorityLevel"); +            break; + +        case 1: +            value = PyLong_AsUnsignedLong(arg); + +            if (value > DPL_COUNT) +            { +                PyErr_SetString(PyExc_TypeError, "invalid value for DisassPriorityLevel"); +                result = 0; +            } + +            else +                *((DisassPriorityLevel *)dst) = value; + +            break; + +        default: +            assert(false); +            break; + +    } + +    return result; + +} | 
