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
|
/* Chrysalide - Outil d'analyse de fichiers binaires
* self.h - définitions de fonctionnalités facilitant la mise en place d'extensions natives
*
* Copyright (C) 2020-2025 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _PLUGINS_SELF_H
#define _PLUGINS_SELF_H
#include <assert.h>
#include <malloc.h>
#include "plugin.h"
#include "../common/compiler.h"
/* Symboles principaux */
#define PLUGIN_CORE_SELF \
static GPluginModule *_this_plugin = NULL; \
static void chrysalide_plugin_set_self(GPluginModule *); \
static void chrysalide_plugin_set_self(GPluginModule *plugin) \
{ \
assert(_this_plugin == NULL); \
_this_plugin = plugin; \
}; \
__private GPluginModule *_chrysalide_plugin_get_self(void); \
__private GPluginModule *_chrysalide_plugin_get_self(void) \
{ \
return _this_plugin; \
};
#define NATIVE_PLUGIN_ENTRYPOINT(fc) \
PLUGIN_CORE_SELF; \
G_MODULE_EXPORT GPluginModule *get_chrysalide_plugin_instance(GModule *); \
G_MODULE_EXPORT GPluginModule *get_chrysalide_plugin_instance(GModule *module) \
{ \
GPluginModule *result; /* Instance à retourner */ \
result = fc(module); \
chrysalide_plugin_set_self(result); \
return result; \
}
/* Spécifications */
#define CHRYSALIDE_WEBSITE(p) "https://www.chrysalide.re/" p
#define NO_REQ NULL, 0
#define BUILD_PG_LIST(lst) lst, sizeof(lst) / sizeof(lst[0])
#define REQ_LIST(...) BUILD_PG_LIST((const char *[]){ __VA_ARGS__ })
/* Journalisation */
__private GPluginModule *_chrysalide_plugin_get_self(void);
#define log_plugin_simple_message(type, msg) \
do \
{ \
GPluginModule *__this; \
__this = _chrysalide_plugin_get_self(); \
if (__this != NULL) \
g_plugin_module_log_simple_message(__this, type, msg); \
else \
log_simple_message(type, msg); \
} \
while (0)
#define log_plugin_variadic_message(type, msg, ...) \
do \
{ \
GPluginModule *__this; \
__this = _chrysalide_plugin_get_self(); \
if (__this != NULL) \
g_plugin_module_log_variadic_message(__this, type, msg, __VA_ARGS__); \
else \
log_variadic_message(type, msg, __VA_ARGS__); \
} \
while (0)
#endif /* _PLUGINS_SELF_H */
|