Skip to content

Commit 6def3e8

Browse files
committed
[diff] add stub codes
1 parent d98c886 commit 6def3e8

File tree

1 file changed

+261
-26
lines changed

1 file changed

+261
-26
lines changed

diff.c

Lines changed: 261 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,83 +2,318 @@
22
#include "php_git2_priv.h"
33
#include "diff.h"
44

5-
/* {{{ proto void git_diff_free(diff)
6-
*/
5+
/* {{{ proto void git_diff_free(resource $diff)
6+
*/
77
PHP_FUNCTION(git_diff_free)
88
{
9+
zval *diff = NULL;
10+
php_git2_t *_diff = NULL;
11+
12+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
13+
"r", &diff) == FAILURE) {
14+
return;
15+
}
16+
17+
ZEND_FETCH_RESOURCE(_diff, php_git2_t*, &diff, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
18+
if (_diff->should_free_v) {
19+
git_diff_free(PHP_GIT2_V(_diff, diff));
20+
};
21+
zval_ptr_dtor(&diff);
922
}
23+
/* }}} */
1024

11-
/* {{{ proto resource git_diff_tree_to_tree(repo, old_tree, new_tree, opts)
12-
*/
25+
26+
/* {{{ proto long git_diff_tree_to_tree(resource $repo, resource $old_tree, resource $new_tree, $opts)
27+
*/
1328
PHP_FUNCTION(git_diff_tree_to_tree)
1429
{
30+
int result = 0;
31+
git_diff *diff = NULL;
32+
zval *repo = NULL;
33+
php_git2_t *_repo = NULL;
34+
zval *old_tree = NULL;
35+
php_git2_t *_old_tree = NULL;
36+
zval *new_tree = NULL;
37+
php_git2_t *_new_tree = NULL;
38+
zval *opts = NULL;
39+
int error = 0;
40+
41+
/* TODO(chobie): generate converter */
42+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
43+
"rrra", &repo, &old_tree, &new_tree, &opts) == FAILURE) {
44+
return;
45+
}
46+
47+
ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
48+
ZEND_FETCH_RESOURCE(_old_tree, php_git2_t*, &old_tree, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
49+
ZEND_FETCH_RESOURCE(_new_tree, php_git2_t*, &new_tree, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
50+
result = git_diff_tree_to_tree(&diff, PHP_GIT2_V(_repo, repository), PHP_GIT2_V(_old_tree, tree), PHP_GIT2_V(_new_tree, tree), opts);
51+
RETURN_LONG(result);
1552
}
53+
/* }}} */
1654

17-
/* {{{ proto resource git_diff_tree_to_index(repo, old_tree, index, opts)
18-
*/
55+
56+
/* {{{ proto long git_diff_tree_to_index(resource $repo, resource $old_tree, resource $index, $opts)
57+
*/
1958
PHP_FUNCTION(git_diff_tree_to_index)
2059
{
60+
int result = 0;
61+
git_diff *diff = NULL;
62+
zval *repo = NULL;
63+
php_git2_t *_repo = NULL;
64+
zval *old_tree = NULL;
65+
php_git2_t *_old_tree = NULL;
66+
zval *index = NULL;
67+
php_git2_t *_index = NULL;
68+
zval *opts = NULL;
69+
int error = 0;
70+
71+
/* TODO(chobie): generate converter */
72+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
73+
"rrra", &repo, &old_tree, &index, &opts) == FAILURE) {
74+
return;
75+
}
76+
77+
ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
78+
ZEND_FETCH_RESOURCE(_old_tree, php_git2_t*, &old_tree, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
79+
ZEND_FETCH_RESOURCE(_index, php_git2_t*, &index, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
80+
result = git_diff_tree_to_index(&diff, PHP_GIT2_V(_repo, repository), PHP_GIT2_V(_old_tree, tree), PHP_GIT2_V(_index, index), opts);
81+
RETURN_LONG(result);
2182
}
83+
/* }}} */
2284

23-
/* {{{ proto resource git_diff_index_to_workdir(repo, index, opts)
24-
*/
85+
86+
/* {{{ proto long git_diff_index_to_workdir(resource $repo, resource $index, $opts)
87+
*/
2588
PHP_FUNCTION(git_diff_index_to_workdir)
2689
{
90+
int result = 0;
91+
git_diff *diff = NULL;
92+
zval *repo = NULL;
93+
php_git2_t *_repo = NULL;
94+
zval *index = NULL;
95+
php_git2_t *_index = NULL;
96+
zval *opts = NULL;
97+
int error = 0;
98+
99+
/* TODO(chobie): generate converter */
100+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
101+
"rra", &repo, &index, &opts) == FAILURE) {
102+
return;
103+
}
104+
105+
ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
106+
ZEND_FETCH_RESOURCE(_index, php_git2_t*, &index, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
107+
result = git_diff_index_to_workdir(&diff, PHP_GIT2_V(_repo, repository), PHP_GIT2_V(_index, index), opts);
108+
RETURN_LONG(result);
27109
}
110+
/* }}} */
28111

29-
/* {{{ proto resource git_diff_tree_to_workdir(repo, old_tree, opts)
30-
*/
112+
113+
/* {{{ proto long git_diff_tree_to_workdir(resource $repo, resource $old_tree, $opts)
114+
*/
31115
PHP_FUNCTION(git_diff_tree_to_workdir)
32116
{
117+
int result = 0;
118+
git_diff *diff = NULL;
119+
zval *repo = NULL;
120+
php_git2_t *_repo = NULL;
121+
zval *old_tree = NULL;
122+
php_git2_t *_old_tree = NULL;
123+
zval *opts = NULL;
124+
int error = 0;
125+
126+
/* TODO(chobie): generate converter */
127+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
128+
"rra", &repo, &old_tree, &opts) == FAILURE) {
129+
return;
130+
}
131+
132+
ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
133+
ZEND_FETCH_RESOURCE(_old_tree, php_git2_t*, &old_tree, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
134+
result = git_diff_tree_to_workdir(&diff, PHP_GIT2_V(_repo, repository), PHP_GIT2_V(_old_tree, tree), opts);
135+
RETURN_LONG(result);
33136
}
137+
/* }}} */
34138

35-
/* {{{ proto resource git_diff_tree_to_workdir_with_index(repo, old_tree, opts)
36-
*/
139+
140+
/* {{{ proto long git_diff_tree_to_workdir_with_index(resource $repo, resource $old_tree, $opts)
141+
*/
37142
PHP_FUNCTION(git_diff_tree_to_workdir_with_index)
38143
{
144+
int result = 0;
145+
git_diff *diff = NULL;
146+
zval *repo = NULL;
147+
php_git2_t *_repo = NULL;
148+
zval *old_tree = NULL;
149+
php_git2_t *_old_tree = NULL;
150+
zval *opts = NULL;
151+
int error = 0;
152+
153+
/* TODO(chobie): generate converter */
154+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
155+
"rra", &repo, &old_tree, &opts) == FAILURE) {
156+
return;
157+
}
158+
159+
ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
160+
ZEND_FETCH_RESOURCE(_old_tree, php_git2_t*, &old_tree, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
161+
result = git_diff_tree_to_workdir_with_index(&diff, PHP_GIT2_V(_repo, repository), PHP_GIT2_V(_old_tree, tree), opts);
162+
RETURN_LONG(result);
39163
}
164+
/* }}} */
40165

41-
/* {{{ proto long git_diff_merge(onto, from)
42-
*/
166+
167+
/* {{{ proto long git_diff_merge(resource $onto, resource $from)
168+
*/
43169
PHP_FUNCTION(git_diff_merge)
44170
{
171+
int result = 0;
172+
zval *onto = NULL;
173+
php_git2_t *_onto = NULL;
174+
zval *from = NULL;
175+
php_git2_t *_from = NULL;
176+
int error = 0;
177+
178+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
179+
"rr", &onto, &from) == FAILURE) {
180+
return;
181+
}
182+
183+
ZEND_FETCH_RESOURCE(_onto, php_git2_t*, &onto, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
184+
ZEND_FETCH_RESOURCE(_from, php_git2_t*, &from, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
185+
result = git_diff_merge(PHP_GIT2_V(_onto, diff), PHP_GIT2_V(_from, diff));
186+
RETURN_LONG(result);
45187
}
188+
/* }}} */
46189

47-
/* {{{ proto long git_diff_find_similar(diff, options)
48-
*/
190+
191+
/* {{{ proto long git_diff_find_similar(resource $diff, $options)
192+
*/
49193
PHP_FUNCTION(git_diff_find_similar)
50194
{
195+
int result = 0;
196+
zval *diff = NULL;
197+
php_git2_t *_diff = NULL;
198+
zval *options = NULL;
199+
int error = 0;
200+
201+
/* TODO(chobie): generate converter */
202+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
203+
"ra", &diff, &options) == FAILURE) {
204+
return;
205+
}
206+
207+
ZEND_FETCH_RESOURCE(_diff, php_git2_t*, &diff, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
208+
result = git_diff_find_similar(PHP_GIT2_V(_diff, diff), options);
209+
RETURN_LONG(result);
51210
}
211+
/* }}} */
52212

53-
/* {{{ proto long git_diff_options_init(options, version)
54-
*/
213+
214+
/* {{{ proto long git_diff_options_init( $options, long $version)
215+
*/
55216
PHP_FUNCTION(git_diff_options_init)
56217
{
218+
int result = 0;
219+
zval *options = NULL;
220+
long version = 0;
221+
int error = 0;
222+
223+
/* TODO(chobie): generate converter */
224+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
225+
"al", &options, &version) == FAILURE) {
226+
return;
227+
}
228+
229+
result = git_diff_options_init(options, version);
230+
RETURN_LONG(result);
57231
}
232+
/* }}} */
58233

59-
/* {{{ proto resource git_diff_num_deltas(diff)
60-
*/
234+
235+
/* {{{ proto long git_diff_num_deltas(resource $diff)
236+
*/
61237
PHP_FUNCTION(git_diff_num_deltas)
62238
{
239+
size_t result = 0;
240+
zval *diff = NULL;
241+
php_git2_t *_diff = NULL;
242+
243+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
244+
"r", &diff) == FAILURE) {
245+
return;
246+
}
247+
248+
ZEND_FETCH_RESOURCE(_diff, php_git2_t*, &diff, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
249+
result = git_diff_num_deltas(PHP_GIT2_V(_diff, diff));
250+
RETURN_LONG(result);
63251
}
252+
/* }}} */
64253

65-
/* {{{ proto resource git_diff_num_deltas_of_type(diff, type)
66-
*/
254+
255+
/* {{{ proto long git_diff_num_deltas_of_type(resource $diff, $type)
256+
*/
67257
PHP_FUNCTION(git_diff_num_deltas_of_type)
68258
{
259+
size_t result = 0;
260+
zval *diff = NULL;
261+
php_git2_t *_diff = NULL;
262+
long type = 0;
263+
264+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
265+
"rl", &diff, &type) == FAILURE) {
266+
return;
267+
}
268+
269+
ZEND_FETCH_RESOURCE(_diff, php_git2_t*, &diff, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
270+
result = git_diff_num_deltas_of_type(PHP_GIT2_V(_diff, diff), type);
271+
RETURN_LONG(result);
69272
}
273+
/* }}} */
70274

71-
/* {{{ proto resource git_diff_get_delta(diff, idx)
72-
*/
275+
276+
/* {{{ proto resource git_diff_get_delta(resource $diff, long $idx)
277+
*/
73278
PHP_FUNCTION(git_diff_get_delta)
74279
{
280+
const git_diff_delta *result = NULL;
281+
zval *diff = NULL;
282+
php_git2_t *_diff = NULL;
283+
long idx = 0;
284+
285+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
286+
"rl", &diff, &idx) == FAILURE) {
287+
return;
288+
}
289+
290+
ZEND_FETCH_RESOURCE(_diff, php_git2_t*, &diff, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
291+
result = git_diff_get_delta(PHP_GIT2_V(_diff, diff), idx);
292+
/* TODO(chobie): implement this */
75293
}
294+
/* }}} */
76295

77-
/* {{{ proto long git_diff_is_sorted_icase(diff)
78-
*/
296+
297+
/* {{{ proto long git_diff_is_sorted_icase(resource $diff)
298+
*/
79299
PHP_FUNCTION(git_diff_is_sorted_icase)
80300
{
301+
int result = 0;
302+
zval *diff = NULL;
303+
php_git2_t *_diff = NULL;
304+
int error = 0;
305+
306+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
307+
"r", &diff) == FAILURE) {
308+
return;
309+
}
310+
311+
ZEND_FETCH_RESOURCE(_diff, php_git2_t*, &diff, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
312+
result = git_diff_is_sorted_icase(PHP_GIT2_V(_diff, diff));
313+
RETURN_BOOL(result);
81314
}
315+
/* }}} */
316+
82317

83318
/* {{{ proto long git_diff_foreach(diff, file_cb, hunk_cb, line_cb, payload)
84319
*/

0 commit comments

Comments
 (0)