Bonjour,

Je suis en train de développer un générateur d'extension PHP en Python à partir d'un fichier gabarit XML.

J’aimerais simplement savoir si je suis sur la bonne voie, la question ne porte pas sur le générateur python mais sur le fichier PHP que je génère.

Il y en a 4 que je génère :
- config.m4
- config.w32
- module.c
- php_module.c

Ma question porte d'abord sur le fichier php_module.c, je voudrais savoir s'il est correctement généré (honnêtement j'ai du mal à comprendre les fonctions de l'API ZEND). Je me suis basé sur différents tutoriels et j’ai aussi regardé les différentes extensions déjà intégré à PHP, voici mon code généré :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
#ifndef FREEAGE_MODULE_MODULE_INCLUDED
#define FREEAGE_MODULE_MODULE_INCLUDED
 
#define PHP_MODULE_EXTNAME	"module"
#define PHP_MODULE_EXTVER	"1.0"
 
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
 
#include "php.h"
#include "net_types.h"
#include <stdarg.h>
 
/* Registration module inputs.	*/
extern zend_module_entry module_module_entry;
#define phpext_module_ptr &module_module_entry
 
PHP_MINIT_FUNCTION(module);
PHP_MINFO_FUNCTION(module);
 
/* Declaration of functions to create.	*/
PHP_FUNCTION(test_module);
PHP_FUNCTION(test_module_result);
PHP_FUNCTION(test_sql);
PHP_FUNCTION(test_sql_result);
 
#ifdef __cplusplus
extern "C" {
#endif
 
ZEND_BEGIN_MODULE_GLOBALS(module)
 
struct net_struct;
struct net_packet;
struct net_func_instance;
struct net_func_callbacks;
struct net_client;
 
/* test_module params declaration.	*/
struct test_module_params
{
	net_int_t arg; /*< An argument.	*/
};
 
/* test_module result declaration.	*/
struct test_module_result
{
	net_int_t ret; /*< A result.	*/
};
 
/* A test function.	*/
/*
 * \param client A pointer to the client structure.
 * \param callbacks An optional pointer to the instance callbacks.
 * \param arg An argument.
 * \return A pointer to a function instance, or NULL if an error occured.
 */
struct net_func_instance *
test_module ( struct net_client * client, const struct net_func_callbacks * callbacks, const net_int_t arg );
 
/* Pop a result from an instance of the function test_module.	*/
/*
 * \see test_module
 * \param instance A pointer to an instance of the function test_module.
 * \return A pointer to a result or NULL if no results are available.
 */
const struct test_module_result *
test_module_result ( struct net_func_instance * instance );
 
/* test_sql params declaration.	*/
struct test_sql_params
{
	net_char_t name [32]; /*< The test argument.	*/
};
 
/* test_sql result declaration.	*/
struct test_sql_result
{
	net_int_t intval; /*< An integer.	*/
	net_float_t floatval; /*< A float.	*/
	net_char_t strval [32]; /*< A string.	*/
};
 
/* A function to test the sql client.	*/
/*
 * \param client A pointer to the client structure.
 * \param callbacks An optional pointer to the instance callbacks.
 * \param name The test argument.
 * \return A pointer to a function instance, or NULL if an error occured.
 */
struct net_func_instance *
test_sql ( struct net_client * client, const struct net_func_callbacks * callbacks, const net_char_t name [32] );
 
/* Pop a result from an instance of the function test_sql.	*/
/*
 * \see test_sql
 * \param instance A pointer to an instance of the function test_sql.
 * \return A pointer to a result or NULL if no results are available.
 */
const struct test_sql_result *
test_sql_result ( struct net_func_instance * instance );
 
ZEND_END_MODULE_GLOBALS(module)
 
#ifdef ZTS
#define MODULE_G(v) TSRMG(module_globals_id, zend_module_globals*, v)
#else
#define MODULE_G(v) (module_globals.v)
#endif
 
ZEND_EXTERN_MODULE_GLOBALS(module)
 
#ifdef __cplusplus
}
#endif
 
#endif /* FREEAGE_MODULE_MODULE_INCLUDED */
Avant de m'attaquer à la génération du fichier d'implémentation module.c, ce fichier déjà est-il bon ? Y a-t-il des erreurs ?

Merci d'avance.