44 +----------------------------------------------------------------------+
55 | Copyright (c) 2017-2017 The Viest |
66 +----------------------------------------------------------------------+
7- | http://www.vtiful.com |
7+ | http://www.viest.me |
88 +----------------------------------------------------------------------+
99 | Author: viest <[email protected] > | 1010 +----------------------------------------------------------------------+
2020
2121#include "php.h"
2222
23- #include "php_vtiful.h"
2423#include "excel.h"
2524#include "exception.h"
2625#include "write.h"
2726
2827zend_class_entry * vtiful_excel_ce ;
2928
29+ /* {{{ ARG_INFO
30+ */
3031ZEND_BEGIN_ARG_INFO_EX (excel_construct_arginfo , 0 , 0 , 1 )
3132 ZEND_ARG_INFO (0 , config )
3233ZEND_END_ARG_INFO ()
@@ -64,7 +65,9 @@ ZEND_END_ARG_INFO()
6465ZEND_BEGIN_ARG_INFO_EX (excel_auto_filter_arginfo , 0 , 0 , 1 )
6566 ZEND_ARG_INFO (0 , range )
6667ZEND_END_ARG_INFO ()
68+ /* }}} */
6769
70+ /* {{{ */
6871excel_resource_t * zval_get_resource (zval * handle )
6972{
7073 excel_resource_t * res ;
@@ -75,8 +78,9 @@ excel_resource_t * zval_get_resource(zval *handle)
7578
7679 return res ;
7780}
81+ /* }}} */
7882
79- /* {{{ \Vtiful\Kernel\Excel::__construct(array $config)
83+ /** {{{ \Vtiful\Kernel\Excel::__construct(array $config)
8084 */
8185PHP_METHOD (vtiful_excel , __construct )
8286{
@@ -100,7 +104,7 @@ PHP_METHOD(vtiful_excel, __construct)
100104}
101105/* }}} */
102106
103- /* {{{ \Vtiful\Kernel\Excel::filename(string $fileName)
107+ /** {{{ \Vtiful\Kernel\Excel::filename(string $fileName)
104108 */
105109PHP_METHOD (vtiful_excel , fileName )
106110{
@@ -141,7 +145,7 @@ PHP_METHOD(vtiful_excel, fileName)
141145}
142146/* }}} */
143147
144- /* {{{ \Vtiful\Kernel\Excel::header(array $header)
148+ /** {{{ \Vtiful\Kernel\Excel::header(array $header)
145149 */
146150PHP_METHOD (vtiful_excel , header )
147151{
@@ -156,9 +160,7 @@ PHP_METHOD(vtiful_excel, header)
156160 ZVAL_COPY (return_value , getThis ());
157161
158162 attr_handle = zend_read_property (vtiful_excel_ce , return_value , ZEND_STRL (V_EXCEL_HANDLE ), 0 , & rv TSRMLS_DC );
159- if ((res = (excel_resource_t * )zend_fetch_resource (Z_RES_P (attr_handle ), VTIFUL_RESOURCE_NAME , le_vtiful )) == NULL ) {
160- zend_throw_exception (vtiful_exception_ce , "Excel resources resolution fail" , 210 );
161- }
163+ res = zval_get_resource (attr_handle );
162164
163165 ZEND_HASH_FOREACH_NUM_KEY_VAL (Z_ARRVAL_P (header ), header_l_key , header_value ) {
164166 type_writer (header_value , 0 , header_l_key , res );
@@ -170,7 +172,7 @@ PHP_METHOD(vtiful_excel, header)
170172}
171173/* }}} */
172174
173- /* {{{ \Vtiful\Kernel\Excel::data(array $data)
175+ /** {{{ \Vtiful\Kernel\Excel::data(array $data)
174176 */
175177PHP_METHOD (vtiful_excel , data )
176178{
@@ -185,9 +187,7 @@ PHP_METHOD(vtiful_excel, data)
185187 ZVAL_COPY (return_value , getThis ());
186188
187189 attr_handle = zend_read_property (vtiful_excel_ce , return_value , ZEND_STRL (V_EXCEL_HANDLE ), 0 , & rv TSRMLS_DC );
188- if ((res = (excel_resource_t * )zend_fetch_resource (Z_RES_P (attr_handle ), VTIFUL_RESOURCE_NAME , le_vtiful )) == NULL ) {
189- zend_throw_exception (vtiful_exception_ce , "Excel resources resolution fail" , 210 );
190- }
190+ res = zval_get_resource (attr_handle );
191191
192192 ZEND_HASH_FOREACH_NUM_KEY_VAL (Z_ARRVAL_P (data ), data_r_key , data_r_value ) {
193193 if (Z_TYPE_P (data_r_value ) == IS_ARRAY ) {
@@ -203,18 +203,15 @@ PHP_METHOD(vtiful_excel, data)
203203}
204204/* }}} */
205205
206- /* {{{ \Vtiful\Kernel\Excel::output()
206+ /** {{{ \Vtiful\Kernel\Excel::output()
207207 */
208208PHP_METHOD (vtiful_excel , output )
209209{
210210 zval rv , * handle , null_handle ;
211211 excel_resource_t * res ;
212212
213213 handle = zend_read_property (vtiful_excel_ce , getThis (), ZEND_STRL (V_EXCEL_HANDLE ), 0 , & rv TSRMLS_DC );
214-
215- if ((res = (excel_resource_t * )zend_fetch_resource (Z_RES_P (handle ), VTIFUL_RESOURCE_NAME , le_vtiful )) == NULL ) {
216- zend_throw_exception (vtiful_exception_ce , "Excel resources resolution fail" , 210 );
217- }
214+ res = zval_get_resource (handle );
218215
219216 workbook_file (res , handle );
220217
@@ -225,7 +222,7 @@ PHP_METHOD(vtiful_excel, output)
225222}
226223/* }}} */
227224
228- /* {{{ \Vtiful\Kernel\Excel::getHandle()
225+ /** {{{ \Vtiful\Kernel\Excel::getHandle()
229226 */
230227PHP_METHOD (vtiful_excel , getHandle )
231228{
@@ -238,13 +235,13 @@ PHP_METHOD(vtiful_excel, getHandle)
238235}
239236/* }}} */
240237
241- /* {{{ \Vtiful\Kernel\Excel::insertText(int $row, int $column, string|int|double $data)
238+ /** {{{ \Vtiful\Kernel\Excel::insertText(int $row, int $column, string|int|double $data)
242239 */
243240PHP_METHOD (vtiful_excel , insertText )
244241{
245242 zval rv , res_handle ;
246243 zval * attr_handle , * data ;
247- zend_long * row , * column ;
244+ zend_long row , column ;
248245 excel_resource_t * res ;
249246
250247 ZEND_PARSE_PARAMETERS_START (3 , 3 )
@@ -256,9 +253,7 @@ PHP_METHOD(vtiful_excel, insertText)
256253 ZVAL_COPY (return_value , getThis ());
257254
258255 attr_handle = zend_read_property (vtiful_excel_ce , return_value , ZEND_STRL (V_EXCEL_HANDLE ), 0 , & rv TSRMLS_DC );
259- if ((res = (excel_resource_t * )zend_fetch_resource (Z_RES_P (attr_handle ), VTIFUL_RESOURCE_NAME , le_vtiful )) == NULL) {
260- zend_throw_exception (vtiful_exception_ce , "Excel resources resolution fail" , 210 );
261- }
256+ res = zval_get_resource (attr_handle );
262257
263258 type_writer (data , row , column , res );
264259
@@ -267,13 +262,13 @@ PHP_METHOD(vtiful_excel, insertText)
267262}
268263/* }}} */
269264
270- /* {{{ \Vtiful\Kernel\Excel::insertImage(int $row, int $column, string $imagePath)
265+ /** {{{ \Vtiful\Kernel\Excel::insertImage(int $row, int $column, string $imagePath)
271266 */
272267PHP_METHOD (vtiful_excel , insertImage )
273268{
274269 zval rv , res_handle ;
275270 zval * attr_handle , * image ;
276- zend_long * row , * column ;
271+ zend_long row , column ;
277272 excel_resource_t * res ;
278273
279274 ZEND_PARSE_PARAMETERS_START (3 , 3 )
@@ -285,9 +280,7 @@ PHP_METHOD(vtiful_excel, insertImage)
285280 ZVAL_COPY (return_value , getThis ());
286281
287282 attr_handle = zend_read_property (vtiful_excel_ce , return_value , ZEND_STRL (V_EXCEL_HANDLE ), 0 , & rv TSRMLS_DC );
288- if ((res = (excel_resource_t * )zend_fetch_resource (Z_RES_P (attr_handle ), VTIFUL_RESOURCE_NAME , le_vtiful )) == NULL) {
289- zend_throw_exception (vtiful_exception_ce , "Excel resources resolution fail" , 210 );
290- }
283+ res = zval_get_resource (attr_handle );
291284
292285 image_writer (image , row , column , res );
293286
@@ -296,13 +289,13 @@ PHP_METHOD(vtiful_excel, insertImage)
296289}
297290/* }}} */
298291
299- /* {{{ \Vtiful\Kernel\Excel::insertImage(int $row, int $column, string $imagePath)
292+ /** {{{ \Vtiful\Kernel\Excel::insertImage(int $row, int $column, string $imagePath)
300293 */
301294PHP_METHOD (vtiful_excel , insertFormula )
302295{
303296 zval rv , res_handle ;
304297 zval * attr_handle , * formula ;
305- zend_long * row , * column ;
298+ zend_long row , column ;
306299 excel_resource_t * res ;
307300
308301 ZEND_PARSE_PARAMETERS_START (3 , 3 )
@@ -314,9 +307,7 @@ PHP_METHOD(vtiful_excel, insertFormula)
314307 ZVAL_COPY (return_value , getThis ());
315308
316309 attr_handle = zend_read_property (vtiful_excel_ce , return_value , ZEND_STRL (V_EXCEL_HANDLE ), 0 , & rv TSRMLS_DC );
317- if ((res = (excel_resource_t * )zend_fetch_resource (Z_RES_P (attr_handle ), VTIFUL_RESOURCE_NAME , le_vtiful )) == NULL) {
318- zend_throw_exception (vtiful_exception_ce , "Excel resources resolution fail" , 210 );
319- }
310+ res = zval_get_resource (attr_handle );
320311
321312 formula_writer (formula , row , column , res );
322313
@@ -325,7 +316,7 @@ PHP_METHOD(vtiful_excel, insertFormula)
325316}
326317/* }}} */
327318
328- /* {{{ \Vtiful\Kernel\Excel::autoFilter(int $rowStart, int $rowEnd, int $columnStart, int $columnEnd)
319+ /** {{{ \Vtiful\Kernel\Excel::autoFilter(int $rowStart, int $rowEnd, int $columnStart, int $columnEnd)
329320 */
330321PHP_METHOD (vtiful_excel , autoFilter )
331322{
@@ -350,6 +341,8 @@ PHP_METHOD(vtiful_excel, autoFilter)
350341}
351342/* }}} */
352343
344+ /** {{{ excel_methods
345+ */
353346zend_function_entry excel_methods [] = {
354347 PHP_ME (vtiful_excel , __construct , excel_construct_arginfo , ZEND_ACC_PUBLIC |ZEND_ACC_CTOR )
355348 PHP_ME (vtiful_excel , fileName , excel_file_name_arginfo , ZEND_ACC_PUBLIC )
@@ -363,7 +356,10 @@ zend_function_entry excel_methods[] = {
363356 PHP_ME (vtiful_excel , insertFormula , excel_insert_formula_arginfo , ZEND_ACC_PUBLIC )
364357 PHP_FE_END
365358};
359+ /* }}} */
366360
361+ /** {{{ VTIFUL_STARTUP_FUNCTION
362+ */
367363VTIFUL_STARTUP_FUNCTION (excel ) {
368364 zend_class_entry ce ;
369365
@@ -377,6 +373,7 @@ VTIFUL_STARTUP_FUNCTION(excel) {
377373
378374 return SUCCESS ;
379375}
376+ /* }}} */
380377
381378
382379
0 commit comments