diff options
Diffstat (limited to 'plugins/dex/python/translate.c')
-rw-r--r-- | plugins/dex/python/translate.c | 246 |
1 files changed, 246 insertions, 0 deletions
diff --git a/plugins/dex/python/translate.c b/plugins/dex/python/translate.c index eb80c43..3d73616 100644 --- a/plugins/dex/python/translate.c +++ b/plugins/dex/python/translate.c @@ -39,6 +39,152 @@ * * * Paramètres : info = ensemble d'informations Dex à décrire en Python. * * * +* Description : Traduit des informations de type Dex en Python. * +* * +* Retour : Structure mise en place ou NULL en cas d'erreur. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyObject *translate_dex_type_id_to_python(const type_id_item *info) +{ + PyObject *result; /* Construction à retourner */ + PyTypeObject *base; /* Modèle d'objet à créer */ + PyObject *attrib; /* Attribut à constituer */ + int ret; /* Bilan d'une mise en place */ + + base = get_python_py_struct_type(); + + result = PyObject_CallFunction((PyObject *)base, NULL); + assert(result != NULL); + + /* Champs réguliers */ + +#define TRANSLATE_ENCODED_TYPE_PROP(_f) \ + do \ + { \ + attrib = PyLong_FromUnsignedLongLong(info->_f); \ + ret = PyDict_SetItemString(result, #_f, attrib); \ + if (ret != 0) goto tdcdtp_failed; \ + } \ + while (0); + + TRANSLATE_ENCODED_TYPE_PROP(descriptor_idx); + + return result; + + tdcdtp_failed: + + Py_DECREF(result); + + return NULL; + +} + + +/****************************************************************************** +* * +* Paramètres : info = ensemble d'informations Dex à décrire en Python. * +* * +* Description : Traduit des informations de type Dex en Python. * +* * +* Retour : Structure mise en place ou NULL en cas d'erreur. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyObject *translate_dex_type_item_to_python(const type_item *info) +{ + PyObject *result; /* Construction à retourner */ + PyTypeObject *base; /* Modèle d'objet à créer */ + PyObject *attrib; /* Attribut à constituer */ + int ret; /* Bilan d'une mise en place */ + + base = get_python_py_struct_type(); + + result = PyObject_CallFunction((PyObject *)base, NULL); + assert(result != NULL); + + /* Champs réguliers */ + +#define TRANSLATE_ENCODED_TYPE_PROP(_f) \ + do \ + { \ + attrib = PyLong_FromUnsignedLongLong(info->_f); \ + ret = PyDict_SetItemString(result, #_f, attrib); \ + if (ret != 0) goto tdcdtp_failed; \ + } \ + while (0); + + TRANSLATE_ENCODED_TYPE_PROP(type_idx); + + return result; + + tdcdtp_failed: + + Py_DECREF(result); + + return NULL; + +} + + +/****************************************************************************** +* * +* Paramètres : info = ensemble d'informations Dex à décrire en Python. * +* * +* Description : Traduit des informations de champ Dex en Python. * +* * +* Retour : Structure mise en place ou NULL en cas d'erreur. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyObject *translate_dex_field_id_to_python(const field_id_item *info) +{ + PyObject *result; /* Construction à retourner */ + PyTypeObject *base; /* Modèle d'objet à créer */ + PyObject *attrib; /* Attribut à constituer */ + int ret; /* Bilan d'une mise en place */ + + base = get_python_py_struct_type(); + + result = PyObject_CallFunction((PyObject *)base, NULL); + assert(result != NULL); + + /* Champs réguliers */ + +#define TRANSLATE_ENCODED_FIELD_PROP(_f) \ + do \ + { \ + attrib = PyLong_FromUnsignedLongLong(info->_f); \ + ret = PyDict_SetItemString(result, #_f, attrib); \ + if (ret != 0) goto tdcdtp_failed; \ + } \ + while (0); + + TRANSLATE_ENCODED_FIELD_PROP(class_idx); + TRANSLATE_ENCODED_FIELD_PROP(type_idx); + TRANSLATE_ENCODED_FIELD_PROP(name_idx); + + return result; + + tdcdtp_failed: + + Py_DECREF(result); + + return NULL; + +} + + +/****************************************************************************** +* * +* Paramètres : info = ensemble d'informations Dex à décrire en Python. * +* * * Description : Traduit des informations de champ de classe Dex en Python. * * * * Retour : Structure mise en place ou NULL en cas d'erreur. * @@ -88,6 +234,106 @@ PyObject *translate_dex_field_info_to_python(const encoded_field *info) * * * Paramètres : info = ensemble d'informations Dex à décrire en Python. * * * +* Description : Traduit des identifiants de prototype Dex en Python. * +* * +* Retour : Structure mise en place ou NULL en cas d'erreur. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyObject *translate_dex_proto_id_to_python(const proto_id_item *info) +{ + PyObject *result; /* Construction à retourner */ + PyTypeObject *base; /* Modèle d'objet à créer */ + PyObject *attrib; /* Attribut à constituer */ + int ret; /* Bilan d'une mise en place */ + + base = get_python_py_struct_type(); + + result = PyObject_CallFunction((PyObject *)base, NULL); + assert(result != NULL); + + /* Champs réguliers */ + +#define TRANSLATE_ID_PROTO_PROP(_f) \ + do \ + { \ + attrib = PyLong_FromUnsignedLongLong(info->_f); \ + ret = PyDict_SetItemString(result, #_f, attrib); \ + if (ret != 0) goto failed; \ + } \ + while (0); + + TRANSLATE_ID_PROTO_PROP(shorty_idx); + TRANSLATE_ID_PROTO_PROP(return_type_idx); + TRANSLATE_ID_PROTO_PROP(parameters_off); + + return result; + + failed: + + Py_DECREF(result); + + return NULL; + +} + + +/****************************************************************************** +* * +* Paramètres : info = ensemble d'informations Dex à décrire en Python. * +* * +* Description : Traduit des identifiants de méthode Dex en Python. * +* * +* Retour : Structure mise en place ou NULL en cas d'erreur. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyObject *translate_dex_method_id_to_python(const method_id_item *info) +{ + PyObject *result; /* Construction à retourner */ + PyTypeObject *base; /* Modèle d'objet à créer */ + PyObject *attrib; /* Attribut à constituer */ + int ret; /* Bilan d'une mise en place */ + + base = get_python_py_struct_type(); + + result = PyObject_CallFunction((PyObject *)base, NULL); + assert(result != NULL); + + /* Champs réguliers */ + +#define TRANSLATE_ID_METHOD_PROP(_f) \ + do \ + { \ + attrib = PyLong_FromUnsignedLongLong(info->_f); \ + ret = PyDict_SetItemString(result, #_f, attrib); \ + if (ret != 0) goto tdcdtp_failed; \ + } \ + while (0); + + TRANSLATE_ID_METHOD_PROP(class_idx); + TRANSLATE_ID_METHOD_PROP(proto_idx); + TRANSLATE_ID_METHOD_PROP(name_idx); + + return result; + + tdcdtp_failed: + + Py_DECREF(result); + + return NULL; + +} + + +/****************************************************************************** +* * +* Paramètres : info = ensemble d'informations Dex à décrire en Python. * +* * * Description : Traduit des informations de méthode Dex en Python. * * * * Retour : Structure mise en place ou NULL en cas d'erreur. * |