forked from RogerGee/php-git2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch.h
326 lines (298 loc) · 9.38 KB
/
patch.h
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
/*
* patch.h
*
* Copyright (C) Roger P. Gee
*/
#ifndef PHPGIT2_PATCH_H
#define PHPGIT2_PATCH_H
#include "diff.h"
namespace php_git2
{
// Explicitly specialize git2_resource destructor for git_patch.
template<> php_git_patch::~git2_resource()
{
git_patch_free(handle);
}
// Provide a type to return a git_diff_hunk value.
class php_git_diff_hunk
{
public:
const git_diff_hunk** byval_git2()
{
return &hunk;
}
void ret(zval* return_value)
{
convert_diff_hunk(return_value,hunk);
}
private:
const git_diff_hunk* hunk;
};
// Provide a type to return a git_diff_line value.
class php_git_diff_line
{
public:
const git_diff_line** byval_git2()
{
return &line;
}
void ret(zval* return_value)
{
convert_diff_line(return_value,line);
}
private:
const git_diff_line* line;
};
} // namespace php_git2
// Funtions
static constexpr auto ZIF_GIT_PATCH_FREE = zif_php_git2_function_free<
php_git2::local_pack<
php_git2::php_resource_cleanup<php_git2::php_git_patch>
>
>;
static constexpr auto ZIF_GIT_PATCH_FROM_BLOB_AND_BUFFER = zif_php_git2_function<
php_git2::func_wrapper<
int,
git_patch**,
const git_blob*,
const char*,
const void*,
size_t,
const char*,
const git_diff_options*>::func<git_patch_from_blob_and_buffer>,
php_git2::local_pack<
php_git2::php_resource_ref<php_git2::php_git_patch>,
php_git2::php_resource_nullable<php_git2::php_git_blob>,
php_git2::php_string_nullable,
php_git2::connector_wrapper<
php_git2::php_string_length_connector_nullable<size_t>
>,
php_git2::php_string_nullable,
php_git2::php_string_nullable,
php_git2::php_git_diff_options
>,
1,
php_git2::sequence<1,2,4,5,6>,
php_git2::sequence<0,1,2,4,3,5,6>
>;
static constexpr auto ZIF_GIT_PATCH_FROM_BLOBS = zif_php_git2_function<
php_git2::func_wrapper<
int,
git_patch**,
const git_blob*,
const char*,
const git_blob*,
const char*,
const git_diff_options*>::func<git_patch_from_blobs>,
php_git2::local_pack<
php_git2::php_resource_ref<php_git2::php_git_patch>,
php_git2::php_resource_nullable<php_git2::php_git_blob>,
php_git2::php_string_nullable,
php_git2::php_resource_nullable<php_git2::php_git_blob>,
php_git2::php_string_nullable,
php_git2::php_git_diff_options
>,
1,
php_git2::sequence<1,2,3,4,5>,
php_git2::sequence<0,1,2,3,4,5>
>;
static constexpr auto ZIF_GIT_PATCH_FROM_BUFFERS = zif_php_git2_function<
php_git2::func_wrapper<
int,
git_patch**,
const void*,
size_t,
const char*,
const void*,
size_t,
const char*,
const git_diff_options*>::func<git_patch_from_buffers>,
php_git2::local_pack<
php_git2::php_resource_ref<php_git2::php_git_patch>,
php_git2::connector_wrapper<
php_git2::php_string_length_connector_nullable<size_t>
>,
php_git2::php_string_nullable,
php_git2::php_string_nullable,
php_git2::connector_wrapper<
php_git2::php_string_length_connector_nullable<size_t>
>,
php_git2::php_string_nullable,
php_git2::php_string_nullable,
php_git2::php_git_diff_options
>,
1,
php_git2::sequence<2,3,5,6,7>,
php_git2::sequence<0,2,1,3,5,4,6,7>
>;
static constexpr auto ZIF_GIT_PATCH_FROM_DIFF = zif_php_git2_function<
php_git2::func_wrapper<
int,
git_patch**,
git_diff*,
size_t>::func<git_patch_from_diff>,
php_git2::local_pack<
php_git2::php_resource_ref<php_git2::php_git_patch>,
php_git2::php_resource<php_git2::php_git_diff>,
php_git2::php_long_cast<size_t>
>,
1,
php_git2::sequence<1,2>,
php_git2::sequence<0,1,2>
>;
static constexpr auto ZIF_GIT_PATCH_GET_DELTA = zif_php_git2_function_rethandler<
php_git2::func_wrapper<
const git_diff_delta*,
const git_patch*>::func<git_patch_get_delta>,
php_git2::local_pack<
php_git2::php_resource<php_git2::php_git_patch>
>,
php_git2::php_git_diff_delta_rethandler<
php_git2::php_resource<php_git2::php_git_patch>
>
>;
static constexpr auto ZIF_GIT_PATCH_GET_HUNK = zif_php_git2_function<
php_git2::func_wrapper<
int,
const git_diff_hunk**,
size_t*,
git_patch*,
size_t>::func<git_patch_get_hunk>,
php_git2::local_pack<
php_git2::php_git_diff_hunk,
php_git2::php_long_out<size_t>,
php_git2::php_resource<php_git2::php_git_patch>,
php_git2::php_long_cast<size_t>
>,
1,
php_git2::sequence<1,2,3>,
php_git2::sequence<0,1,2,3>
>;
ZEND_BEGIN_ARG_INFO_EX(git_patch_get_hunk_arginfo,0,0,3)
ZEND_ARG_PASS_INFO(1)
ZEND_END_ARG_INFO()
static constexpr auto ZIF_GIT_PATCH_GET_LINE_IN_HUNK = zif_php_git2_function<
php_git2::func_wrapper<
int,
const git_diff_line**,
git_patch*,
size_t,
size_t>::func<git_patch_get_line_in_hunk>,
php_git2::local_pack<
php_git2::php_git_diff_line,
php_git2::php_resource<php_git2::php_git_patch>,
php_git2::php_long_cast<size_t>,
php_git2::php_long_cast<size_t>
>,
1,
php_git2::sequence<1,2,3>,
php_git2::sequence<0,1,2,3>
>;
static constexpr auto ZIF_GIT_PATCH_LINE_STATS = zif_php_git2_function<
php_git2::func_wrapper<
int,
size_t*,
size_t*,
size_t*,
const git_patch*>::func<git_patch_line_stats>,
php_git2::local_pack<
php_git2::php_long_ref<size_t>,
php_git2::php_long_out<size_t>,
php_git2::php_long_out<size_t>,
php_git2::php_resource<php_git2::php_git_patch>
>,
1,
php_git2::sequence<1,2,3>,
php_git2::sequence<0,1,2,3>
>;
ZEND_BEGIN_ARG_INFO_EX(git_patch_line_stats_arginfo,0,0,3)
ZEND_ARG_PASS_INFO(1)
ZEND_ARG_PASS_INFO(1)
ZEND_END_ARG_INFO()
static constexpr auto ZIF_GIT_PATCH_NUM_HUNKS = zif_php_git2_function<
php_git2::func_wrapper<
size_t,
const git_patch*>::func<git_patch_num_hunks>,
php_git2::local_pack<
php_git2::php_resource<php_git2::php_git_patch>
>,
0
>;
static constexpr auto ZIF_GIT_PATCH_NUM_LINES_IN_HUNK = zif_php_git2_function_rethandler<
php_git2::func_wrapper<
int,
const git_patch*,
size_t>::func<git_patch_num_lines_in_hunk>,
php_git2::local_pack<
php_git2::php_resource<php_git2::php_git_patch>,
php_git2::php_long_cast<size_t>
>,
php_git2::php_notfound_retval_rethandler
>;
static constexpr auto ZIF_GIT_PATCH_PRINT = zif_php_git2_function<
php_git2::func_wrapper<
int,
git_patch*,
git_diff_line_cb,
void*>::func<git_patch_print>,
php_git2::local_pack<
php_git2::php_resource<php_git2::php_git_patch>,
php_git2::php_callback_handler<php_git2::diff_line_callback>,
php_git2::php_callback_sync
>,
-1,
php_git2::sequence<0,2,2>, // pass callback in twice for function and payload
php_git2::sequence<0,1,2>
>;
static constexpr auto ZIF_GIT_PATCH_SIZE = zif_php_git2_function<
php_git2::func_wrapper<
size_t,
git_patch*,
int,
int,
int>::func<git_patch_size>,
php_git2::local_pack<
php_git2::php_resource<php_git2::php_git_patch>,
php_git2::php_bool,
php_git2::php_bool,
php_git2::php_bool
>,
0
>;
static constexpr auto ZIF_GIT_PATCH_TO_BUF = zif_php_git2_function<
php_git2::func_wrapper<
int,
git_buf*,
git_patch*>::func<git_patch_to_buf>,
php_git2::local_pack<
php_git2::php_git_buf,
php_git2::php_resource<php_git2::php_git_patch>
>,
1,
php_git2::sequence<1>,
php_git2::sequence<0,1>
>;
// Function Entries
#define GIT_PATCH_FE \
PHP_GIT2_FE(git_patch_free,ZIF_GIT_PATCH_FREE,NULL) \
PHP_GIT2_FE(git_patch_from_blob_and_buffer,ZIF_GIT_PATCH_FROM_BLOB_AND_BUFFER,NULL) \
PHP_GIT2_FE(git_patch_from_blobs,ZIF_GIT_PATCH_FROM_BLOBS,NULL) \
PHP_GIT2_FE(git_patch_from_buffers,ZIF_GIT_PATCH_FROM_BUFFERS,NULL) \
PHP_GIT2_FE(git_patch_from_diff,ZIF_GIT_PATCH_FROM_DIFF,NULL) \
PHP_GIT2_FE(git_patch_get_delta,ZIF_GIT_PATCH_GET_DELTA,NULL) \
PHP_GIT2_FE(git_patch_get_hunk,ZIF_GIT_PATCH_GET_HUNK,git_patch_get_hunk_arginfo) \
PHP_GIT2_FE(git_patch_get_line_in_hunk,ZIF_GIT_PATCH_GET_LINE_IN_HUNK,NULL) \
PHP_GIT2_FE(git_patch_line_stats,ZIF_GIT_PATCH_LINE_STATS,git_patch_line_stats_arginfo) \
PHP_GIT2_FE(git_patch_num_hunks,ZIF_GIT_PATCH_NUM_HUNKS,NULL) \
PHP_GIT2_FE(git_patch_num_lines_in_hunk,ZIF_GIT_PATCH_NUM_LINES_IN_HUNK,NULL) \
PHP_GIT2_FE(git_patch_print,ZIF_GIT_PATCH_PRINT,NULL) \
PHP_GIT2_FE(git_patch_size,ZIF_GIT_PATCH_SIZE,NULL) \
PHP_GIT2_FE(git_patch_to_buf,ZIF_GIT_PATCH_TO_BUF,NULL)
#endif
/*
* Local Variables:
* mode:c++
* indent-tabs-mode:nil
* tab-width:4
* End:
*/