2
2
#include "php_git2_priv.h"
3
3
#include "status.h"
4
4
5
- /* {{{ proto long git_status_foreach(repo, callback, payload)
6
- */
5
+ /* {{{ proto long git_status_foreach(resource $ repo, Callable $ callback, $ payload)
6
+ */
7
7
PHP_FUNCTION (git_status_foreach )
8
8
{
9
- zval * repo ;
10
- php_git2_t * _repo ;
11
- zval * callback ;
12
- php_git2_t * _callback ;
13
- zval * payload ;
14
-
15
- /* TODO(chobie): implement this */
16
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "git_status_foreach not implemented yet" );
17
- return ;
18
-
9
+ int result = 0 , error = 0 ;
10
+ zval * repo = NULL , * callback = NULL , * payload = NULL ;
11
+ php_git2_t * _repo = NULL ;
12
+ zend_fcall_info fci = empty_fcall_info ;
13
+ zend_fcall_info_cache fcc = empty_fcall_info_cache ;
14
+ php_git2_cb_t * cb = NULL ;
15
+
19
16
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
20
- "rrz " , & repo , & callback , & payload ) == FAILURE ) {
17
+ "rfz " , & repo , & fci , & fcc , & payload ) == FAILURE ) {
21
18
return ;
22
19
}
20
+
23
21
ZEND_FETCH_RESOURCE (_repo , php_git2_t * , & repo , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
22
+ if (php_git2_cb_init (& cb , & fci , & fcc , payload TSRMLS_CC )) {
23
+ RETURN_FALSE ;
24
+ }
25
+ //result = git_status_foreach(PHP_GIT2_V(_repo, repository), <CHANGEME>, cb);
26
+ php_git2_cb_free (cb );
27
+ RETURN_LONG (result );
24
28
}
29
+ /* }}} */
25
30
26
- /* {{{ proto long git_status_foreach_ext(repo, opts, callback, payload)
27
- */
31
+ /* {{{ proto long git_status_foreach_ext(resource $ repo, $ opts, Callable $ callback, $ payload)
32
+ */
28
33
PHP_FUNCTION (git_status_foreach_ext )
29
34
{
30
- zval * repo ;
31
- php_git2_t * _repo ;
32
- zval * opts ;
33
- php_git2_t * _opts ;
34
- zval * callback ;
35
- php_git2_t * _callback ;
36
- zval * payload ;
37
-
38
- /* TODO(chobie): implement this */
39
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "git_status_foreach_ext not implemented yet" );
40
- return ;
41
-
35
+ int result = 0 , error = 0 ;
36
+ zval * repo = NULL , * opts = NULL , * callback = NULL , * payload = NULL ;
37
+ php_git2_t * _repo = NULL ;
38
+ zend_fcall_info fci = empty_fcall_info ;
39
+ zend_fcall_info_cache fcc = empty_fcall_info_cache ;
40
+ php_git2_cb_t * cb = NULL ;
41
+
42
42
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
43
- "rrrz " , & repo , & opts , & callback , & payload ) == FAILURE ) {
43
+ "r<git_status_options>fz " , & repo , & opts , & fci , & fcc , & payload ) == FAILURE ) {
44
44
return ;
45
45
}
46
+
46
47
ZEND_FETCH_RESOURCE (_repo , php_git2_t * , & repo , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
48
+ if (php_git2_cb_init (& cb , & fci , & fcc , payload TSRMLS_CC )) {
49
+ RETURN_FALSE ;
50
+ }
51
+ //result = git_status_foreach_ext(PHP_GIT2_V(_repo, repository), opts, <CHANGEME>, cb);
52
+ php_git2_cb_free (cb );
53
+ RETURN_LONG (result );
47
54
}
55
+ /* }}} */
48
56
49
- /* {{{ proto long git_status_file(resource $repo, string $path)
57
+ /* {{{ proto long git_status_file(long $status_flags, resource $repo, string $path)
50
58
*/
51
59
PHP_FUNCTION (git_status_file )
52
60
{
53
- unsigned int status_flags = 0 ;
61
+ int result = 0 , path_len = 0 , error = 0 ;
62
+ long status_flags = 0 ;
54
63
zval * repo = NULL ;
55
64
php_git2_t * _repo = NULL ;
56
65
char * path = NULL ;
57
- int path_len = 0 ;
58
- int error = 0 ;
59
-
66
+
60
67
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
61
- "rs" , & repo , & path , & path_len ) == FAILURE ) {
68
+ "lrs" , & status_flags , & repo , & path , & path_len ) == FAILURE ) {
62
69
return ;
63
70
}
64
-
71
+
65
72
ZEND_FETCH_RESOURCE (_repo , php_git2_t * , & repo , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
66
- error = git_status_file (status_flags , PHP_GIT2_V (_repo , repository ), path );
67
- if (php_git2_check_error (error , "git_status_file" TSRMLS_CC )) {
68
- RETURN_FALSE ;
69
- }
70
- RETURN_LONG (status_flags );
73
+ result = git_status_file (status_flags , PHP_GIT2_V (_repo , repository ), path );
74
+ RETURN_LONG (result );
71
75
}
72
76
/* }}} */
73
77
74
-
75
78
/* {{{ proto resource git_status_list_new(resource $repo, $opts)
76
79
*/
77
80
PHP_FUNCTION (git_status_list_new )
78
81
{
79
- php_git2_t * result = NULL ;
82
+ php_git2_t * result = NULL , * _repo = NULL ;
80
83
git_status_list * out = NULL ;
81
- zval * repo = NULL ;
82
- php_git2_t * _repo = NULL ;
83
- zval * opts = NULL ;
84
+ zval * repo = NULL , * opts = NULL ;
84
85
int error = 0 ;
85
-
86
+
86
87
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
87
- "rz " , & repo , & opts ) == FAILURE ) {
88
+ "r<git_status_options> " , & repo , & opts ) == FAILURE ) {
88
89
return ;
89
90
}
90
-
91
- /* TODO(chobie): convert arra to git_status_options */
92
-
91
+
93
92
ZEND_FETCH_RESOURCE (_repo , php_git2_t * , & repo , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
94
93
error = git_status_list_new (& out , PHP_GIT2_V (_repo , repository ), opts );
95
94
if (php_git2_check_error (error , "git_status_list_new" TSRMLS_CC )) {
96
95
RETURN_FALSE ;
97
96
}
98
-
99
- PHP_GIT2_MAKE_RESOURCE (result );
100
- PHP_GIT2_V (result , status_list ) = out ;
101
- result -> type = PHP_GIT2_TYPE_STATUS_LIST ;
102
- result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
103
- result -> should_free_v = 0 ;
104
- ZVAL_RESOURCE (return_value , result -> resource_id );
97
+ if (php_git2_make_resource (& result , PHP_GIT2_TYPE_STATUS_LIST , out , 1 TSRMLS_CC )) {
98
+ RETURN_FALSE ;
99
+ }
100
+ ZVAL_RESOURCE (return_value , GIT2_RVAL_P (result ));
105
101
}
106
102
/* }}} */
107
103
@@ -112,12 +108,12 @@ PHP_FUNCTION(git_status_list_entrycount)
112
108
size_t result = 0 ;
113
109
zval * statuslist = NULL ;
114
110
php_git2_t * _statuslist = NULL ;
115
-
111
+
116
112
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
117
113
"r" , & statuslist ) == FAILURE ) {
118
114
return ;
119
115
}
120
-
116
+
121
117
ZEND_FETCH_RESOURCE (_statuslist , php_git2_t * , & statuslist , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
122
118
result = git_status_list_entrycount (PHP_GIT2_V (_statuslist , status_list ));
123
119
RETURN_LONG (result );
@@ -128,16 +124,16 @@ PHP_FUNCTION(git_status_list_entrycount)
128
124
*/
129
125
PHP_FUNCTION (git_status_byindex )
130
126
{
131
- const git_status_entry * result = NULL ;
127
+ const git_status_entry * result = NULL ;
132
128
zval * statuslist = NULL ;
133
129
php_git2_t * _statuslist = NULL ;
134
130
long idx = 0 ;
135
-
131
+
136
132
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
137
133
"rl" , & statuslist , & idx ) == FAILURE ) {
138
134
return ;
139
135
}
140
-
136
+
141
137
ZEND_FETCH_RESOURCE (_statuslist , php_git2_t * , & statuslist , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
142
138
result = git_status_byindex (PHP_GIT2_V (_statuslist , status_list ), idx );
143
139
/* TODO(chobie): implement this */
@@ -150,43 +146,39 @@ PHP_FUNCTION(git_status_list_free)
150
146
{
151
147
zval * statuslist = NULL ;
152
148
php_git2_t * _statuslist = NULL ;
153
-
149
+
154
150
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
155
151
"r" , & statuslist ) == FAILURE ) {
156
152
return ;
157
153
}
158
-
154
+
159
155
ZEND_FETCH_RESOURCE (_statuslist , php_git2_t * , & statuslist , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
160
- if (_statuslist -> should_free_v ) {
156
+ if (GIT2_SHOULD_FREE ( _statuslist ) ) {
161
157
git_status_list_free (PHP_GIT2_V (_statuslist , status_list ));
158
+ GIT2_SHOULD_FREE (_statuslist ) = 0 ;
162
159
};
163
160
zval_ptr_dtor (& statuslist );
164
161
}
165
162
/* }}} */
166
163
167
- /* {{{ proto long git_status_should_ignore(resource $repo, string $path)
164
+ /* {{{ proto long git_status_should_ignore(long $ignored, resource $repo, string $path)
168
165
*/
169
166
PHP_FUNCTION (git_status_should_ignore )
170
167
{
171
- int ignored = 0 ;
168
+ int result = 0 , path_len = 0 , error = 0 ;
169
+ long ignored = 0 ;
172
170
zval * repo = NULL ;
173
171
php_git2_t * _repo = NULL ;
174
172
char * path = NULL ;
175
- int path_len = 0 ;
176
- int error = 0 ;
177
-
173
+
178
174
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
179
- "rs" , & repo , & path , & path_len ) == FAILURE ) {
175
+ "lrs" , & ignored , & repo , & path , & path_len ) == FAILURE ) {
180
176
return ;
181
177
}
182
-
178
+
183
179
ZEND_FETCH_RESOURCE (_repo , php_git2_t * , & repo , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
184
- error = git_status_should_ignore (& ignored , PHP_GIT2_V (_repo , repository ), path );
185
- if (php_git2_check_error (error , "git_status_should_ignore" TSRMLS_CC )) {
186
- RETURN_FALSE ;
187
- }
188
-
189
- RETURN_LONG (ignored );
180
+ result = git_status_should_ignore (ignored , PHP_GIT2_V (_repo , repository ), path );
181
+ RETURN_LONG (result );
190
182
}
191
183
/* }}} */
192
184
0 commit comments