summaryrefslogtreecommitdiff
path: root/src/analysis/type.h
blob: f5cc242e329f8485df757c9ea72010a49b4760c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123

/* Chrysalide - Outil d'analyse de fichiers binaires
 * type.h - prototypes pour la manipulation des types en tout genre
 *
 * Copyright (C) 2010-2018 Cyrille Bagard
 *
 *  This file is part of Chrysalide.
 *
 *  Chrysalide is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Chrysalide is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Chrysalide.  If not, see <http://www.gnu.org/licenses/>.
 */


#ifndef _ANALYSIS_TYPE_H
#define _ANALYSIS_TYPE_H


#include <glib-object.h>
#include <stdbool.h>



#define G_TYPE_DATA_TYPE            g_data_type_get_type()
#define G_DATA_TYPE(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_DATA_TYPE, GDataType))
#define G_IS_DATA_TYPE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_DATA_TYPE))
#define G_DATA_TYPE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_DATA_TYPE, GDataTypeClass))
#define G_IS_DATA_TYPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_DATA_TYPE))
#define G_DATA_TYPE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_DATA_TYPE, GDataTypeClass))


/* Description de type quelconque (instance) */
typedef struct _GDataType GDataType;

/* Description de type quelconque (classe) */
typedef struct _GDataTypeClass GDataTypeClass;


/* Qualificatifs de variables */
typedef enum _TypeQualifier
{
    TQF_NONE        = (0 << 0),             /* Néant                       */
    TQF_RESTRICT    = (1 << 0),             /* restrict (C99)              */
    TQF_VOLATILE    = (1 << 1),             /* volatile                    */
    TQF_CONST       = (1 << 2),             /* const                       */

    TQF_ALL         = ((1 << 3) - 1)        /* Masque de qualificatifs     */

} TypeQualifier;

/* Propriétés particulières d'un type */
typedef enum _TypeFlag
{
    TFL_NONE            = (0 << 0),         /* Aucune propriété            */
    TFL_SINGLETON_SOON  = (1 << 0),         /* Singleton en devenir        */
    TFL_SINGLETON       = (1 << 1),         /* Singleton effectif          */

    TFL_USER_LOW_BIT    = (1 << 2),         /* Premier bit libre           */
    TFL_USER_HIGH_BIT   = (1 << 7)          /* Dernier bit libre           */

} TypeFlag;


/* Indique le type défini pour un type quelconque. */
GType g_data_type_get_type(void);

/* Calcule une empreinte pour un type de données. */
guint g_data_type_hash(const GDataType *);

/* Crée un copie d'un type existant. */
GDataType *g_data_type_dup(const GDataType *);

/* Décrit le type fourni sous forme de caractères. */
char *g_data_type_to_string(const GDataType *, bool);

/* Définit l'ensemble des qualificatifs d'une instance de type. */
void g_data_type_set_qualifiers(GDataType *, TypeQualifier);

/* Ajoute un qualificatif à une instance de type. */
void g_data_type_add_qualifier(GDataType *, TypeQualifier);

/* Fournit les qualificatifs associés à une instance de type. */
TypeQualifier g_data_type_get_qualifiers(const GDataType *);

/* Définit le groupe d'appartenance d'un type donné. */
bool g_data_type_set_namespace(GDataType *, GDataType *, const char *);

/* Fournit le groupe d'appartenance d'un type donné. */
GDataType *g_data_type_get_namespace(const GDataType *);

/* Fournit la chaîne de séparation entre deux entités. */
char *g_data_type_get_namespace_separator(const GDataType *);

/* Indique si le type assure une gestion des espaces de noms. */
bool g_data_type_handle_namespaces(const GDataType *);

/* Définit l'ensemble des fanions d'une instance de type. */
void g_data_type_set_flags(GDataType *, TypeFlag);

/* Ajoute un fanion à une instance de type. */
void g_data_type_add_flag(GDataType *, TypeFlag);

/* Fournit les fanions associés à une instance de type. */
TypeFlag g_data_type_get_flags(const GDataType *);

/* Indique si le type est un pointeur. */
bool g_data_type_is_pointer(const GDataType *);

/* Indique si le type est une référence. */
bool g_data_type_is_reference(const GDataType *);



#endif  /* _ANALYSIS_TYPE_H */