summaryrefslogtreecommitdiff
path: root/src/format/dex/method.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/format/dex/method.c')
-rw-r--r--src/format/dex/method.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/format/dex/method.c b/src/format/dex/method.c
index 316f094..bc4a063 100644
--- a/src/format/dex/method.c
+++ b/src/format/dex/method.c
@@ -24,6 +24,9 @@
#include "method.h"
+#include <string.h>
+
+
#include <i18n.h>
@@ -40,6 +43,7 @@ struct _GDexMethod
GBinRoutine *routine; /* Représentation interne */
+ /* FIXME : méthode interne seulement */
encoded_method info; /* Propriétés de la méthode */
code_item body; /* Corps de la méthode */
off_t offset; /* Position du code */
@@ -220,14 +224,27 @@ GDexMethod *g_dex_method_new(GDexFormat *format, const encoded_method *seed, ule
* *
******************************************************************************/
-GDexMethod *g_dex_method_new_empty(const GDexFormat *format, const method_id_item *method_id)
+GDexMethod *g_dex_method_new_empty(GDexFormat *format, const method_id_item *method_id)
{
GDexMethod *result; /* Composant à retourner */
+ const char *name; /* Nom de la routine finale */
+ GBinRoutine *routine; /* Routine représentée */
+ result = NULL;
+ name = get_string_from_dex_pool(format, method_id->name_idx);
+ if (name == NULL) goto gdmne_exit;
+
+ routine = get_prototype_from_dex_pool(format, method_id->proto_idx);
+ if (routine == NULL) goto gdmne_exit;
+
+ g_binary_routine_set_name(routine, strdup(name));
result = g_object_new(G_TYPE_DEX_METHOD, NULL);
+ result->routine = routine;
+
+ gdmne_exit:
return result;
@@ -286,7 +303,13 @@ const code_item *g_dex_method_get_dex_body(const GDexMethod *method)
GBinRoutine *g_dex_method_get_routine(const GDexMethod *method)
{
- return method->routine;
+ GBinRoutine *result; /* Instance à retourner */
+
+ result = method->routine;
+
+ g_object_ref(G_OBJECT(result));
+
+ return result;
}