Skip to content

Commit dd26c3e

Browse files
author
viest
committed
code format adjustment
1 parent 9056a7d commit dd26c3e

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

kernel/excel.c

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
zend_class_entry *vtiful_excel_ce;
2828

29+
/* {{{ ARG_INFO
30+
*/
2931
ZEND_BEGIN_ARG_INFO_EX(excel_construct_arginfo, 0, 0, 1)
3032
ZEND_ARG_INFO(0, config)
3133
ZEND_END_ARG_INFO()
@@ -63,7 +65,9 @@ ZEND_END_ARG_INFO()
6365
ZEND_BEGIN_ARG_INFO_EX(excel_auto_filter_arginfo, 0, 0, 1)
6466
ZEND_ARG_INFO(0, range)
6567
ZEND_END_ARG_INFO()
68+
/* }}} */
6669

70+
/* {{{ */
6771
excel_resource_t * zval_get_resource(zval *handle)
6872
{
6973
excel_resource_t *res;
@@ -74,6 +78,7 @@ excel_resource_t * zval_get_resource(zval *handle)
7478

7579
return res;
7680
}
81+
/* }}} */
7782

7883
/* {{{ \Vtiful\Kernel\Excel::__construct(array $config)
7984
*/
@@ -155,9 +160,7 @@ PHP_METHOD(vtiful_excel, header)
155160
ZVAL_COPY(return_value, getThis());
156161

157162
attr_handle = zend_read_property(vtiful_excel_ce, return_value, ZEND_STRL(V_EXCEL_HANDLE), 0, &rv TSRMLS_DC);
158-
if((res = (excel_resource_t *)zend_fetch_resource(Z_RES_P(attr_handle), VTIFUL_RESOURCE_NAME, le_vtiful)) == NULL) {
159-
zend_throw_exception(vtiful_exception_ce, "Excel resources resolution fail", 210);
160-
}
163+
res = zval_get_resource(attr_handle);
161164

162165
ZEND_HASH_FOREACH_NUM_KEY_VAL(Z_ARRVAL_P(header), header_l_key, header_value) {
163166
type_writer(header_value, 0, header_l_key, res);
@@ -184,9 +187,7 @@ PHP_METHOD(vtiful_excel, data)
184187
ZVAL_COPY(return_value, getThis());
185188

186189
attr_handle = zend_read_property(vtiful_excel_ce, return_value, ZEND_STRL(V_EXCEL_HANDLE), 0, &rv TSRMLS_DC);
187-
if((res = (excel_resource_t *)zend_fetch_resource(Z_RES_P(attr_handle), VTIFUL_RESOURCE_NAME, le_vtiful)) == NULL) {
188-
zend_throw_exception(vtiful_exception_ce, "Excel resources resolution fail", 210);
189-
}
190+
res = zval_get_resource(attr_handle);
190191

191192
ZEND_HASH_FOREACH_NUM_KEY_VAL(Z_ARRVAL_P(data), data_r_key, data_r_value) {
192193
if(Z_TYPE_P(data_r_value) == IS_ARRAY) {
@@ -210,10 +211,7 @@ PHP_METHOD(vtiful_excel, output)
210211
excel_resource_t *res;
211212

212213
handle = zend_read_property(vtiful_excel_ce, getThis(), ZEND_STRL(V_EXCEL_HANDLE), 0, &rv TSRMLS_DC);
213-
214-
if((res = (excel_resource_t *)zend_fetch_resource(Z_RES_P(handle), VTIFUL_RESOURCE_NAME, le_vtiful)) == NULL) {
215-
zend_throw_exception(vtiful_exception_ce, "Excel resources resolution fail", 210);
216-
}
214+
res = zval_get_resource(handle);
217215

218216
workbook_file(res, handle);
219217

@@ -255,9 +253,7 @@ PHP_METHOD(vtiful_excel, insertText)
255253
ZVAL_COPY(return_value, getThis());
256254

257255
attr_handle = zend_read_property(vtiful_excel_ce, return_value, ZEND_STRL(V_EXCEL_HANDLE), 0, &rv TSRMLS_DC);
258-
if((res = (excel_resource_t *)zend_fetch_resource(Z_RES_P(attr_handle), VTIFUL_RESOURCE_NAME, le_vtiful)) == NULL) {
259-
zend_throw_exception(vtiful_exception_ce, "Excel resources resolution fail", 210);
260-
}
256+
res = zval_get_resource(attr_handle);
261257

262258
type_writer(data, row, column, res);
263259

@@ -284,9 +280,7 @@ PHP_METHOD(vtiful_excel, insertImage)
284280
ZVAL_COPY(return_value, getThis());
285281

286282
attr_handle = zend_read_property(vtiful_excel_ce, return_value, ZEND_STRL(V_EXCEL_HANDLE), 0, &rv TSRMLS_DC);
287-
if((res = (excel_resource_t *)zend_fetch_resource(Z_RES_P(attr_handle), VTIFUL_RESOURCE_NAME, le_vtiful)) == NULL) {
288-
zend_throw_exception(vtiful_exception_ce, "Excel resources resolution fail", 210);
289-
}
283+
res = zval_get_resource(attr_handle);
290284

291285
image_writer(image, row, column, res);
292286

@@ -313,9 +307,7 @@ PHP_METHOD(vtiful_excel, insertFormula)
313307
ZVAL_COPY(return_value, getThis());
314308

315309
attr_handle = zend_read_property(vtiful_excel_ce, return_value, ZEND_STRL(V_EXCEL_HANDLE), 0, &rv TSRMLS_DC);
316-
if((res = (excel_resource_t *)zend_fetch_resource(Z_RES_P(attr_handle), VTIFUL_RESOURCE_NAME, le_vtiful)) == NULL) {
317-
zend_throw_exception(vtiful_exception_ce, "Excel resources resolution fail", 210);
318-
}
310+
res = zval_get_resource(attr_handle);
319311

320312
formula_writer(formula, row, column, res);
321313

0 commit comments

Comments
 (0)