From da3da13a32a2f98c16a591a389e274a7803fc48a Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Thu, 30 Sep 2021 08:41:23 +0200 Subject: Move loaded contents from interface to object structures. --- plugins/pychrysalide/analysis/binary.c | 2 +- plugins/pychrysalide/analysis/loaded.c | 119 +++++++++++++++++------ src/analysis/binary.c | 67 +++++-------- src/analysis/loaded-int.h | 17 ++-- src/analysis/loaded.c | 173 +++++++++++++++++++++++---------- src/analysis/loaded.h | 22 ++--- 6 files changed, 256 insertions(+), 144 deletions(-) diff --git a/plugins/pychrysalide/analysis/binary.c b/plugins/pychrysalide/analysis/binary.c index c9dc9c5..d8f01e5 100644 --- a/plugins/pychrysalide/analysis/binary.c +++ b/plugins/pychrysalide/analysis/binary.c @@ -562,7 +562,7 @@ bool ensure_python_loaded_binary_is_registered(void) if (!ensure_python_loaded_content_is_registered()) return false; - if (!register_class_for_pygobject(dict, G_TYPE_LOADED_BINARY, type, &PyGObject_Type)) + if (!register_class_for_pygobject(dict, G_TYPE_LOADED_BINARY, type, get_python_loaded_content_type())) return false; } diff --git a/plugins/pychrysalide/analysis/loaded.c b/plugins/pychrysalide/analysis/loaded.c index 3ed51d5..607f57c 100644 --- a/plugins/pychrysalide/analysis/loaded.c +++ b/plugins/pychrysalide/analysis/loaded.c @@ -35,6 +35,7 @@ #include #include +#include #include "content.h" @@ -47,8 +48,11 @@ /* ------------------------ GLUE POUR CREATION DEPUIS PYTHON ------------------------ */ -/* Procède à l'initialisation de l'interface de génération. */ -static void py_loaded_content_interface_init(GLoadedContentIface *, gpointer *); +/* Accompagne la création d'une instance dérivée en Python. */ +static PyObject *py_loaded_content_new(PyTypeObject *, PyObject *, PyObject *); + +/* Initialise la classe générique des contenus chargés. */ +static void py_loaded_content_init_gclass(GLoadedContentClass *, gpointer); /* Fournit le contenu représenté de l'élément chargé. */ static GBinContent *py_loaded_content_get_content_wrapper(const GLoadedContent *); @@ -121,21 +125,28 @@ static PyObject *py_loaded_content_get_format_name(PyObject *, void *); /****************************************************************************** * * -* Paramètres : iface = interface GLib à initialiser. * -* unused = adresse non utilisée ici. * +* Paramètres : type = type du nouvel objet à mettre en place. * +* args = éventuelle liste d'arguments. * +* kwds = éventuel dictionnaire de valeurs mises à disposition. * * * -* Description : Procède à l'initialisation de l'interface de génération. * +* Description : Accompagne la création d'une instance dérivée en Python. * * * -* Retour : - * +* Retour : Nouvel objet Python mis en place ou NULL en cas d'échec. * * * * Remarques : - * * * ******************************************************************************/ -static void py_loaded_content_interface_init(GLoadedContentIface *iface, gpointer *unused) +static PyObject *py_loaded_content_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { + PyObject *result; /* Objet à retourner */ + PyTypeObject *base; /* Type de base à dériver */ + bool first_time; /* Evite les multiples passages*/ + GType gtype; /* Nouveau type de processeur */ + bool status; /* Bilan d'un enregistrement */ + #define LOADED_CONTENT_DOC \ - "The LoadedContent interface is an intermediary level of abstraction" \ + "The LoadedContent object is an intermediary level of abstraction" \ " for all loaded binary contents to analyze." \ "\n" \ "No matter if the loaded content comes from an ELF file or XML data," \ @@ -157,18 +168,74 @@ static void py_loaded_content_interface_init(GLoadedContentIface *iface, gpointe "* pychrysalide.analysis.storage.LoadedContent._build_view();\n" \ "* pychrysalide.analysis.storage.LoadedContent._get_view_index();\n" - iface->get_content = py_loaded_content_get_content_wrapper; - iface->get_format_name = py_loaded_content_get_format_name_wrapper; + /* Validations diverses */ + + base = get_python_loaded_content_type(); + + if (type == base) + { + result = NULL; + PyErr_Format(PyExc_RuntimeError, _("%s is an abstract class"), type->tp_name); + goto exit; + } + + /* Mise en place d'un type dédié */ + + first_time = (g_type_from_name(type->tp_name) == 0); + + gtype = build_dynamic_type(G_TYPE_LOADED_CONTENT, type->tp_name, + (GClassInitFunc)py_loaded_content_init_gclass, NULL, NULL); + + if (first_time) + { + status = register_class_for_dynamic_pygobject(gtype, type, base); + + if (!status) + { + result = NULL; + goto exit; + } + + } + + /* On crée, et on laisse ensuite la main à PyGObject_Type.tp_init() */ + + result = PyType_GenericNew(type, args, kwds); + + exit: + + return result; - iface->analyze = py_loaded_content_analyze_wrapper; +} - iface->describe = py_loaded_content_describe_wrapper; - iface->count_views = py_loaded_content_count_views_wrapper; - iface->get_view_name = py_loaded_content_get_view_name_wrapper; - iface->build_def_view = py_loaded_content_build_default_view_wrapper; - iface->build_view = py_loaded_content_build_view_wrapper; - iface->get_view_index = py_loaded_content_get_view_index_wrapper; +/****************************************************************************** +* * +* Paramètres : class = classe à initialiser. * +* unused = données non utilisées ici. * +* * +* Description : Initialise la classe générique des contenus chargés. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void py_loaded_content_init_gclass(GLoadedContentClass *class, gpointer unused) +{ + class->get_content = py_loaded_content_get_content_wrapper; + class->get_format_name = py_loaded_content_get_format_name_wrapper; + + class->analyze = py_loaded_content_analyze_wrapper; + + class->describe = py_loaded_content_describe_wrapper; + + class->count_views = py_loaded_content_count_views_wrapper; + class->get_view_name = py_loaded_content_get_view_name_wrapper; + class->build_def_view = py_loaded_content_build_default_view_wrapper; + class->build_view = py_loaded_content_build_view_wrapper; + class->get_view_index = py_loaded_content_get_view_index_wrapper; } @@ -1396,14 +1463,16 @@ PyTypeObject *get_python_loaded_content_type(void) PyVarObject_HEAD_INIT(NULL, 0) .tp_name = "pychrysalide.analysis.LoadedContent", - .tp_basicsize = sizeof(PyObject), + .tp_basicsize = sizeof(PyGObject), - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_BASETYPE, .tp_doc = LOADED_CONTENT_DOC, .tp_methods = py_loaded_content_methods, - .tp_getset = py_loaded_content_getseters + .tp_getset = py_loaded_content_getseters, + + .tp_new = py_loaded_content_new, }; @@ -1430,14 +1499,6 @@ bool ensure_python_loaded_content_is_registered(void) PyObject *module; /* Module à recompléter */ PyObject *dict; /* Dictionnaire du module */ - static GInterfaceInfo info = { /* Paramètres d'inscription */ - - .interface_init = (GInterfaceInitFunc)py_loaded_content_interface_init, - .interface_finalize = NULL, - .interface_data = NULL, - - }; - type = get_python_loaded_content_type(); if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) @@ -1449,7 +1510,7 @@ bool ensure_python_loaded_content_is_registered(void) if (!ensure_python_named_widget_is_registered()) return false; - if (!register_interface_for_pygobject(dict, G_TYPE_LOADED_CONTENT, type, &info)) + if (!register_class_for_pygobject(dict, G_TYPE_LOADED_CONTENT, type, &PyGObject_Type)) return false; } diff --git a/src/analysis/binary.c b/src/analysis/binary.c index 2b23eff..ddd2e30 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -63,7 +63,7 @@ /* Description de fichier binaire (instance) */ struct _GLoadedBinary { - GObject parent; /* A laisser en premier */ + GLoadedContent parent; /* A laisser en premier */ bool use_remote; /* Enregistrements distants ? */ char *remote_host; /* Nom du serveur distant */ @@ -91,7 +91,7 @@ struct _GLoadedBinary /* Description de fichier binaire (classe) */ struct _GLoadedBinaryClass { - GObjectClass parent; /* A laisser en premier */ + GLoadedContentClass parent; /* A laisser en premier */ }; @@ -102,9 +102,6 @@ static void g_loaded_binary_class_init(GLoadedBinaryClass *); /* Initialise une description de fichier binaire. */ static void g_loaded_binary_init(GLoadedBinary *); -/* Procède à l'initialisation de l'interface de contenu chargé. */ -static void g_loaded_binary_interface_init(GLoadedContentInterface *); - /* Supprime toutes les références externes. */ static void g_loaded_binary_dispose(GLoadedBinary *); @@ -197,9 +194,7 @@ static GDisplayOptions *g_loaded_binary_get_display_options(const GLoadedBinary /* Indique le type défini pour une description de fichier binaire. */ -G_DEFINE_TYPE_WITH_CODE(GLoadedBinary, g_loaded_binary, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(G_TYPE_LOADED_CONTENT, g_loaded_binary_interface_init) - G_IMPLEMENT_INTERFACE(G_TYPE_NAMED_WIDGET, g_loaded_content_named_interface_init)); +G_DEFINE_TYPE(GLoadedBinary, g_loaded_binary, G_TYPE_LOADED_CONTENT); /****************************************************************************** @@ -217,12 +212,33 @@ G_DEFINE_TYPE_WITH_CODE(GLoadedBinary, g_loaded_binary, G_TYPE_OBJECT, static void g_loaded_binary_class_init(GLoadedBinaryClass *klass) { GObjectClass *object; /* Autre version de la classe */ + GLoadedContentClass *loaded; /* Forme parente de la classe */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_loaded_binary_dispose; object->finalize = (GObjectFinalizeFunc)g_loaded_binary_finalize; + loaded = G_LOADED_CONTENT_CLASS(klass); + + loaded->restore = (restore_content_fc)g_loaded_binary_restore; + loaded->save = (save_content_fc)g_loaded_binary_save; + + loaded->get_content = (get_content_fc)g_loaded_binary_get_content; + loaded->get_format_name = (get_format_name_fc)g_loaded_binary_get_format_name; + + loaded->analyze = (analyze_loaded_fc)g_loaded_binary_analyze; + + loaded->describe = (describe_loaded_fc)g_loaded_binary_describe; + + loaded->count_views = (count_loaded_views_fc)g_loaded_binary_count_views; + loaded->get_view_name = (get_loaded_view_name_fc)g_loaded_binary_get_view_name; + loaded->build_def_view = (build_loaded_def_view_fc)g_loaded_binary_build_default_view; + loaded->build_view = (build_loaded_view_fc)g_loaded_binary_build_view; + loaded->get_view_index = (get_loaded_view_index_fc)g_loaded_binary_get_view_index; + + loaded->get_options = (get_loaded_options_fc)g_loaded_binary_get_display_options; + } @@ -270,41 +286,6 @@ static void g_loaded_binary_init(GLoadedBinary *binary) /****************************************************************************** * * -* Paramètres : iface = interface GLib à initialiser. * -* * -* Description : Procède à l'initialisation de l'interface de contenu chargé. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_loaded_binary_interface_init(GLoadedContentInterface *iface) -{ - iface->restore = (restore_content_fc)g_loaded_binary_restore; - iface->save = (save_content_fc)g_loaded_binary_save; - - iface->get_content = (get_content_fc)g_loaded_binary_get_content; - iface->get_format_name = (get_format_name_fc)g_loaded_binary_get_format_name; - - iface->analyze = (analyze_loaded_fc)g_loaded_binary_analyze; - - iface->describe = (describe_loaded_fc)g_loaded_binary_describe; - - iface->count_views = (count_loaded_views_fc)g_loaded_binary_count_views; - iface->get_view_name = (get_loaded_view_name_fc)g_loaded_binary_get_view_name; - iface->build_def_view = (build_loaded_def_view_fc)g_loaded_binary_build_default_view; - iface->build_view = (build_loaded_view_fc)g_loaded_binary_build_view; - iface->get_view_index = (get_loaded_view_index_fc)g_loaded_binary_get_view_index; - - iface->get_options = (get_loaded_options_fc)g_loaded_binary_get_display_options; - -} - - -/****************************************************************************** -* * * Paramètres : binary = instance d'objet GLib à traiter. * * * * Description : Supprime toutes les références externes. * diff --git a/src/analysis/loaded-int.h b/src/analysis/loaded-int.h index 0476af5..cd47a6a 100644 --- a/src/analysis/loaded-int.h +++ b/src/analysis/loaded-int.h @@ -67,10 +67,17 @@ typedef unsigned int (* get_loaded_view_index_fc) (GLoadedContent *, GtkWidget * typedef GDisplayOptions * (* get_loaded_options_fc) (const GLoadedContent *, unsigned int); -/* Accès à un contenu binaire quelconque (interface) */ -struct _GLoadedContentIface +/* Accès à un contenu binaire quelconque (instance) */ +struct _GLoadedContent { - GTypeInterface base_iface; /* A laisser en premier */ + GObject parent; /* A laisser en premier */ + +}; + +/* Accès à un contenu binaire quelconque (classe) */ +struct _GLoadedContentClass +{ + GObjectClass parent; /* A laisser en premier */ /* Méthodes virtuelles */ @@ -99,9 +106,5 @@ struct _GLoadedContentIface }; -/* Redéfinition */ -typedef GLoadedContentIface GLoadedContentInterface; - - #endif /* _ANALYSIS_LOADED_INT_H */ diff --git a/src/analysis/loaded.c b/src/analysis/loaded.c index 10ab05e..3a497f9 100644 --- a/src/analysis/loaded.c +++ b/src/analysis/loaded.c @@ -39,11 +39,6 @@ -/* Analyse de contenu chargé (instance) */ -typedef struct _GLoadedAnalysis GLoadedAnalysis; - - - /* ---------------------- GESTION SOUS FORME DE CONTENU CHARGE ---------------------- */ @@ -59,8 +54,20 @@ typedef struct _analysis_data_t } analysis_data_t; -/* Procède à l'initialisation de l'interface de contenu chargé. */ -static void g_loaded_content_default_init(GLoadedContentInterface *); +/* Initialise la classe des contenus chargés. */ +static void g_loaded_content_class_init(GLoadedContentClass *); + +/* Initialise un contenu chargé. */ +static void g_loaded_content_init(GLoadedContent *); + +/* Procède à l'initialisation de l'interface de composant nommé. */ +static void g_loaded_content_named_init(GNamedWidgetIface *); + +/* Supprime toutes les références externes. */ +static void g_loaded_content_dispose(GLoadedContent *); + +/* Procède à la libération totale de la mémoire. */ +static void g_loaded_content_finalize(GLoadedContent *); /* Crée une structure pour accompagner une tâche d'analyse. */ static analysis_data_t *create_analysis_data(GLoadedContent *, bool, bool); @@ -82,14 +89,15 @@ static void on_loaded_content_analysis_completed(GSeqWork *, analysis_data_t *); /* Détermine le type d'une interface pour l'intégration de contenu chargé. */ -G_DEFINE_INTERFACE(GLoadedContent, g_loaded_content, G_TYPE_OBJECT); +G_DEFINE_TYPE_WITH_CODE(GLoadedContent, g_loaded_content, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE(G_TYPE_NAMED_WIDGET, g_loaded_content_named_init)); /****************************************************************************** * * -* Paramètres : iface = interface GLib à initialiser. * +* Paramètres : klass = classe à initialiser. * * * -* Description : Procède à l'initialisation de l'interface de contenu chargé. * +* Description : Initialise la classe des contenus chargés. * * * * Retour : - * * * @@ -97,12 +105,19 @@ G_DEFINE_INTERFACE(GLoadedContent, g_loaded_content, G_TYPE_OBJECT); * * ******************************************************************************/ -static void g_loaded_content_default_init(GLoadedContentInterface *iface) +static void g_loaded_content_class_init(GLoadedContentClass *klass) { + GObjectClass *object; /* Autre version de la classe */ + + object = G_OBJECT_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_loaded_content_dispose; + object->finalize = (GObjectFinalizeFunc)g_loaded_content_finalize; + g_signal_new("analyzed", G_TYPE_LOADED_CONTENT, G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(GLoadedContentIface, analyzed), + G_STRUCT_OFFSET(GLoadedContentClass, analyzed), NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); @@ -112,6 +127,24 @@ static void g_loaded_content_default_init(GLoadedContentInterface *iface) /****************************************************************************** * * +* Paramètres : content = instance à initialiser. * +* * +* Description : Initialise un contenu chargé. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_loaded_content_init(GLoadedContent *content) +{ + +} + + +/****************************************************************************** +* * * Paramètres : iface = interface GLib à initialiser. * * * * Description : Procède à l'initialisation de l'interface de composant nommé.* @@ -122,7 +155,7 @@ static void g_loaded_content_default_init(GLoadedContentInterface *iface) * * ******************************************************************************/ -void g_loaded_content_named_interface_init(GNamedWidgetIface *iface) +static void g_loaded_content_named_init(GNamedWidgetIface *iface) { iface->get_name = (get_named_widget_name_fc)g_loaded_content_describe; iface->get_widget = (get_named_widget_widget_fc)g_loaded_content_build_default_view; @@ -132,6 +165,44 @@ void g_loaded_content_named_interface_init(GNamedWidgetIface *iface) /****************************************************************************** * * +* Paramètres : content = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_loaded_content_dispose(GLoadedContent *content) +{ + G_OBJECT_CLASS(g_loaded_content_parent_class)->dispose(G_OBJECT(content)); + +} + + +/****************************************************************************** +* * +* Paramètres : content = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_loaded_content_finalize(GLoadedContent *content) +{ + G_OBJECT_CLASS(g_loaded_content_parent_class)->finalize(G_OBJECT(content)); + +} + + +/****************************************************************************** +* * * Paramètres : content = élément chargé à traiter. * * xdoc = structure XML en cours d'édition. * * context = contexte à utiliser pour les recherches. * @@ -148,12 +219,12 @@ void g_loaded_content_named_interface_init(GNamedWidgetIface *iface) bool g_loaded_content_restore(GLoadedContent *content, xmlDocPtr xdoc, xmlXPathContextPtr context, const char *path) { bool result; /* Bilan à faire remonter */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); - if (iface->restore != NULL) - result = iface->restore(content, xdoc, context, path); + if (class->restore != NULL) + result = class->restore(content, xdoc, context, path); else result = true; @@ -181,12 +252,12 @@ bool g_loaded_content_restore(GLoadedContent *content, xmlDocPtr xdoc, xmlXPathC bool g_loaded_content_save(GLoadedContent *content, xmlDocPtr xdoc, xmlXPathContextPtr context, const char *path) { bool result; /* Bilan à faire remonter */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); - if (iface->save != NULL) - result = iface->save(content, xdoc, context, path); + if (class->save != NULL) + result = class->save(content, xdoc, context, path); else result = true; @@ -211,11 +282,11 @@ bool g_loaded_content_save(GLoadedContent *content, xmlDocPtr xdoc, xmlXPathCont GBinContent *g_loaded_content_get_content(const GLoadedContent *content) { GBinContent *result; /* Contenu interne à renvoyer */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); - result = iface->get_content(content); + result = class->get_content(content); return result; @@ -237,11 +308,11 @@ GBinContent *g_loaded_content_get_content(const GLoadedContent *content) char *g_loaded_content_get_format_name(const GLoadedContent *content) { char *result; /* Contenu interne à renvoyer */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); - result = iface->get_format_name(content); + result = class->get_format_name(content); return result; @@ -298,17 +369,17 @@ static analysis_data_t *create_analysis_data(GLoadedContent *content, bool conne static bool process_analysis_with_data(analysis_data_t *data, size_t i, GtkStatusStack *status, activity_id_t id) { - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ GWorkQueue *queue; /* Gestionnaire de différés */ wgroup_id_t gid; /* Identifiant pour les tâches */ - iface = G_LOADED_CONTENT_GET_IFACE(data->content); + class = G_LOADED_CONTENT_GET_CLASS(data->content); queue = get_work_queue(); gid = g_work_queue_define_work_group(queue); - data->success = iface->analyze(data->content, data->connect, data->cache, gid, status); + data->success = class->analyze(data->content, data->connect, data->cache, gid, status); if (data->success) handle_loaded_content(PGA_CONTENT_ANALYZED, data->content, gid, status); @@ -460,11 +531,11 @@ bool g_loaded_content_analyze_and_wait(GLoadedContent *content, bool connect, bo char *g_loaded_content_describe(const GLoadedContent *content, bool full) { char *result; /* Description à retourner */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); - result = iface->describe(content, full); + result = class->describe(content, full); return result; @@ -520,11 +591,11 @@ char **g_loaded_content_detect_obfuscators(const GLoadedContent *content, bool v unsigned int g_loaded_content_count_views(const GLoadedContent *content) { unsigned int result; /* Quantité de vues à renvoyer */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); - result = iface->count_views(content); + result = class->count_views(content); return result; @@ -547,13 +618,13 @@ unsigned int g_loaded_content_count_views(const GLoadedContent *content) char *g_loaded_content_get_view_name(const GLoadedContent *content, unsigned int index) { char *result; /* Désignation à retourner */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); assert(index <= g_loaded_content_count_views(content)); - result = iface->get_view_name(content, index); + result = class->get_view_name(content, index); return result; @@ -575,11 +646,11 @@ char *g_loaded_content_get_view_name(const GLoadedContent *content, unsigned int GtkWidget *g_loaded_content_build_default_view(GLoadedContent *content) { GtkWidget *result; /* Support à retourner */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); - result = iface->build_def_view(content); + result = class->build_def_view(content); return result; @@ -602,13 +673,13 @@ GtkWidget *g_loaded_content_build_default_view(GLoadedContent *content) GtkWidget *g_loaded_content_build_view(GLoadedContent *content, unsigned int index) { GtkWidget *result; /* Support à retourner */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); assert(index <= g_loaded_content_count_views(content)); - result = iface->build_view(content, index); + result = class->build_view(content, index); return result; @@ -631,11 +702,11 @@ GtkWidget *g_loaded_content_build_view(GLoadedContent *content, unsigned int ind unsigned int g_loaded_content_get_view_index(GLoadedContent *content, GtkWidget *view) { unsigned int result; /* Indice à retourner */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); - result = iface->get_view_index(content, view); + result = class->get_view_index(content, view); assert(result == -1 || result <= g_loaded_content_count_views(content)); @@ -660,13 +731,13 @@ unsigned int g_loaded_content_get_view_index(GLoadedContent *content, GtkWidget GDisplayOptions *g_loaded_content_get_display_options(const GLoadedContent *content, unsigned int index) { GDisplayOptions *result; /* Accès aux options à renvoyer*/ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ assert(index <= g_loaded_content_count_views(content)); - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); - result = iface->get_options(content, index); + result = class->get_options(content, index); return result; diff --git a/src/analysis/loaded.h b/src/analysis/loaded.h index 46404e1..9a88f8c 100644 --- a/src/analysis/loaded.h +++ b/src/analysis/loaded.h @@ -33,7 +33,6 @@ #include "content.h" #include "../common/xml.h" #include "../glibext/gdisplayoptions.h" -#include "../glibext/named.h" #include "../gtkext/gtkdockstation.h" @@ -41,27 +40,24 @@ /* ---------------------- GESTION SOUS FORME DE CONTENU CHARGE ---------------------- */ -#define G_TYPE_LOADED_CONTENT (g_loaded_content_get_type()) -#define G_LOADED_CONTENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_LOADED_CONTENT, GLoadedContent)) -#define G_LOADED_CONTENT_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST((vtable), G_TYPE_LOADED_CONTENT, GLoadedContentIface)) -#define G_IS_LOADED_CONTENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_LOADED_CONTENT)) -#define G_IS_LOADED_CONTENT_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE((vtable), G_TYPE_LOADED_CONTENT)) -#define G_LOADED_CONTENT_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), G_TYPE_LOADED_CONTENT, GLoadedContentIface)) +#define G_TYPE_LOADED_CONTENT g_loaded_content_get_type() +#define G_LOADED_CONTENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_LOADED_CONTENT, GLoadedContent)) +#define G_IS_LOADED_CONTENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_LOADED_CONTENT)) +#define G_LOADED_CONTENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_LOADED_CONTENT, GLoadedContentClass)) +#define G_IS_LOADED_CONTENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_LOADED_CONTENT)) +#define G_LOADED_CONTENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_LOADED_CONTENT, GLoadedContentClass)) -/* Accès à un contenu binaire quelconque (coquille vide) */ +/* Accès à un contenu binaire quelconque (instance) */ typedef struct _GLoadedContent GLoadedContent; -/* Accès à un contenu binaire quelconque (interface) */ -typedef struct _GLoadedContentIface GLoadedContentIface; +/* Accès à un contenu binaire quelconque (instance) */ +typedef struct _GLoadedContentClass GLoadedContentClass; /* Détermine le type d'une interface pour l'intégration de contenu chargé. */ GType g_loaded_content_get_type(void) G_GNUC_CONST; -/* Procède à l'initialisation de l'interface de composant nommé. */ -void g_loaded_content_named_interface_init(GNamedWidgetIface *); - /* Interprète un contenu chargé avec un appui XML. */ bool g_loaded_content_restore(GLoadedContent *, xmlDoc *, xmlXPathContext *, const char *); -- cgit v0.11.2-87-g4458