7
7
PHP_FUNCTION (git_pathspec_new )
8
8
{
9
9
php_git2_t * result = NULL ;
10
- git_pathspec * out ;
10
+ git_pathspec * out = NULL ;
11
11
zval * pathspec = NULL ;
12
+ git_strarray _pathspec = {0 };
12
13
int error = 0 ;
13
14
14
15
/* TODO(chobie): generate converter */
@@ -17,20 +18,18 @@ PHP_FUNCTION(git_pathspec_new)
17
18
return ;
18
19
}
19
20
21
+ php_git2_array_to_strarray (& _pathspec , pathspec TSRMLS_CC );
20
22
error = git_pathspec_new (& out , pathspec );
21
23
if (php_git2_check_error (error , "git_pathspec_new" TSRMLS_CC )) {
22
24
RETURN_FALSE ;
23
25
}
24
- PHP_GIT2_MAKE_RESOURCE (result );
25
- PHP_GIT2_V (result , pathspec ) = out ;
26
- result -> type = PHP_GIT2_TYPE_PATHSPEC ;
27
- result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
28
- result -> should_free_v = 0 ;
29
- ZVAL_RESOURCE (return_value , result -> resource_id );
26
+ if (php_git2_make_resource (& result , PHP_GIT2_TYPE_PATHSPEC , out , 1 TSRMLS_CC )) {
27
+ RETURN_FALSE ;
28
+ }
29
+ ZVAL_RESOURCE (return_value , GIT2_RVAL_P (result ));
30
30
}
31
31
/* }}} */
32
32
33
-
34
33
/* {{{ proto void git_pathspec_free(resource $ps)
35
34
*/
36
35
PHP_FUNCTION (git_pathspec_free )
@@ -44,8 +43,9 @@ PHP_FUNCTION(git_pathspec_free)
44
43
}
45
44
46
45
ZEND_FETCH_RESOURCE (_ps , php_git2_t * , & ps , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
47
- if (_ps -> should_free_v ) {
46
+ if (GIT2_SHOULD_FREE ( _ps ) ) {
48
47
git_pathspec_free (PHP_GIT2_V (_ps , pathspec ));
48
+ GIT2_SHOULD_FREE (_ps ) = 0 ;
49
49
};
50
50
zval_ptr_dtor (& ps );
51
51
}
@@ -56,13 +56,11 @@ PHP_FUNCTION(git_pathspec_free)
56
56
*/
57
57
PHP_FUNCTION (git_pathspec_matches_path )
58
58
{
59
- int result = 0 ;
59
+ int result = 0 , path_len = 0 , error = 0 ;
60
60
zval * ps = NULL ;
61
61
php_git2_t * _ps = NULL ;
62
62
long flags = 0 ;
63
63
char * path = NULL ;
64
- int path_len = 0 ;
65
- int error = 0 ;
66
64
67
65
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
68
66
"rls" , & ps , & flags , & path , & path_len ) == FAILURE ) {
@@ -80,13 +78,10 @@ PHP_FUNCTION(git_pathspec_matches_path)
80
78
*/
81
79
PHP_FUNCTION (git_pathspec_match_workdir )
82
80
{
83
- php_git2_t * result = NULL ;
81
+ php_git2_t * result = NULL , * _repo = NULL , * _ps = NULL ;
84
82
git_pathspec_match_list * out = NULL ;
85
- zval * repo = NULL ;
86
- php_git2_t * _repo = NULL ;
83
+ zval * repo = NULL , * ps = NULL ;
87
84
long flags = 0 ;
88
- zval * ps = NULL ;
89
- php_git2_t * _ps = NULL ;
90
85
int error = 0 ;
91
86
92
87
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
@@ -100,27 +95,21 @@ PHP_FUNCTION(git_pathspec_match_workdir)
100
95
if (php_git2_check_error (error , "git_pathspec_match_workdir" TSRMLS_CC )) {
101
96
RETURN_FALSE ;
102
97
}
103
- PHP_GIT2_MAKE_RESOURCE (result );
104
- PHP_GIT2_V (result , pathspec_match_list ) = out ;
105
- result -> type = PHP_GIT2_TYPE_PATHSPEC_MATCH_LIST ;
106
- result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
107
- result -> should_free_v = 0 ;
108
- ZVAL_RESOURCE (return_value , result -> resource_id );
98
+ if (php_git2_make_resource (& result , PHP_GIT2_TYPE_PATHSPEC_MATCH_LIST , out , 0 TSRMLS_CC )) {
99
+ RETURN_FALSE ;
100
+ }
101
+ ZVAL_RESOURCE (return_value , GIT2_RVAL_P (result ));
109
102
}
110
103
/* }}} */
111
104
112
-
113
105
/* {{{ proto resource git_pathspec_match_index(resource $index, long $flags, resource $ps)
114
106
*/
115
107
PHP_FUNCTION (git_pathspec_match_index )
116
108
{
117
- php_git2_t * result = NULL ;
109
+ php_git2_t * result = NULL , * _index = NULL , * _ps = NULL ;
118
110
git_pathspec_match_list * out = NULL ;
119
- zval * index = NULL ;
120
- php_git2_t * _index = NULL ;
111
+ zval * index = NULL , * ps = NULL ;
121
112
long flags = 0 ;
122
- zval * ps = NULL ;
123
- php_git2_t * _ps = NULL ;
124
113
int error = 0 ;
125
114
126
115
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
@@ -134,27 +123,21 @@ PHP_FUNCTION(git_pathspec_match_index)
134
123
if (php_git2_check_error (error , "git_pathspec_match_index" TSRMLS_CC )) {
135
124
RETURN_FALSE ;
136
125
}
137
- PHP_GIT2_MAKE_RESOURCE (result );
138
- PHP_GIT2_V (result , pathspec_match_list ) = out ;
139
- result -> type = PHP_GIT2_TYPE_PATHSPEC_MATCH_LIST ;
140
- result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
141
- result -> should_free_v = 0 ;
142
- ZVAL_RESOURCE (return_value , result -> resource_id );
126
+ if (php_git2_make_resource (& result , PHP_GIT2_TYPE_PATHSPEC_MATCH_LIST , out , 1 TSRMLS_CC )) {
127
+ RETURN_FALSE ;
128
+ }
129
+ ZVAL_RESOURCE (return_value , GIT2_RVAL_P (result ));
143
130
}
144
131
/* }}} */
145
132
146
-
147
133
/* {{{ proto resource git_pathspec_match_tree(resource $tree, long $flags, resource $ps)
148
134
*/
149
135
PHP_FUNCTION (git_pathspec_match_tree )
150
136
{
151
- php_git2_t * result = NULL ;
137
+ php_git2_t * result = NULL , * _tree = NULL , * _ps = NULL ;
152
138
git_pathspec_match_list * out = NULL ;
153
- zval * tree = NULL ;
154
- php_git2_t * _tree = NULL ;
139
+ zval * tree = NULL , * ps = NULL ;
155
140
long flags = 0 ;
156
- zval * ps = NULL ;
157
- php_git2_t * _ps = NULL ;
158
141
int error = 0 ;
159
142
160
143
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
@@ -168,27 +151,21 @@ PHP_FUNCTION(git_pathspec_match_tree)
168
151
if (php_git2_check_error (error , "git_pathspec_match_tree" TSRMLS_CC )) {
169
152
RETURN_FALSE ;
170
153
}
171
- PHP_GIT2_MAKE_RESOURCE (result );
172
- PHP_GIT2_V (result , pathspec_match_list ) = out ;
173
- result -> type = PHP_GIT2_TYPE_PATHSPEC_MATCH_LIST ;
174
- result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
175
- result -> should_free_v = 0 ;
176
- ZVAL_RESOURCE (return_value , result -> resource_id );
154
+ if (php_git2_make_resource (& result , PHP_GIT2_TYPE_PATHSPEC_MATCH_LIST , out , 1 TSRMLS_CC )) {
155
+ RETURN_FALSE ;
156
+ }
157
+ ZVAL_RESOURCE (return_value , GIT2_RVAL_P (result ));
177
158
}
178
159
/* }}} */
179
160
180
-
181
161
/* {{{ proto resource git_pathspec_match_diff(resource $diff, long $flags, resource $ps)
182
162
*/
183
163
PHP_FUNCTION (git_pathspec_match_diff )
184
164
{
185
- php_git2_t * result = NULL ;
165
+ php_git2_t * result = NULL , * _diff = NULL , * _ps = NULL ;
186
166
git_pathspec_match_list * out = NULL ;
187
- zval * diff = NULL ;
188
- php_git2_t * _diff = NULL ;
167
+ zval * diff = NULL , * ps = NULL ;
189
168
long flags = 0 ;
190
- zval * ps = NULL ;
191
- php_git2_t * _ps = NULL ;
192
169
int error = 0 ;
193
170
194
171
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
@@ -202,16 +179,13 @@ PHP_FUNCTION(git_pathspec_match_diff)
202
179
if (php_git2_check_error (error , "git_pathspec_match_diff" TSRMLS_CC )) {
203
180
RETURN_FALSE ;
204
181
}
205
- PHP_GIT2_MAKE_RESOURCE (result );
206
- PHP_GIT2_V (result , pathspec_match_list ) = out ;
207
- result -> type = PHP_GIT2_TYPE_PATHSPEC_MATCH_LIST ;
208
- result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
209
- result -> should_free_v = 0 ;
210
- ZVAL_RESOURCE (return_value , result -> resource_id );
182
+ if (php_git2_make_resource (& result , PHP_GIT2_TYPE_PATHSPEC_MATCH_LIST , out , 0 TSRMLS_CC )) {
183
+ RETURN_FALSE ;
184
+ }
185
+ ZVAL_RESOURCE (return_value , GIT2_RVAL_P (result ));
211
186
}
212
187
/* }}} */
213
188
214
-
215
189
/* {{{ proto void git_pathspec_match_list_free(resource $m)
216
190
*/
217
191
PHP_FUNCTION (git_pathspec_match_list_free )
@@ -225,8 +199,9 @@ PHP_FUNCTION(git_pathspec_match_list_free)
225
199
}
226
200
227
201
ZEND_FETCH_RESOURCE (_m , php_git2_t * , & m , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
228
- if (_m -> should_free_v ) {
202
+ if (GIT2_SHOULD_FREE ( _m ) ) {
229
203
git_pathspec_match_list_free (PHP_GIT2_V (_m , pathspec_match_list ));
204
+ GIT2_SHOULD_FREE (_m ) = 0 ;
230
205
};
231
206
zval_ptr_dtor (& m );
232
207
}
@@ -278,7 +253,7 @@ PHP_FUNCTION(git_pathspec_match_list_entry)
278
253
*/
279
254
PHP_FUNCTION (git_pathspec_match_list_diff_entry )
280
255
{
281
- const git_diff_delta * result = NULL ;
256
+ const git_diff_delta * result = NULL ;
282
257
zval * m = NULL ;
283
258
php_git2_t * _m = NULL ;
284
259
long pos = 0 ;
0 commit comments