From 0c8f6d6db3ce84a576f8558df9793c668e1f30d0 Mon Sep 17 00:00:00 2001 From: viest <986465329@qq.com> Date: Mon, 27 Nov 2017 22:11:41 +0800 Subject: [PATCH 1/4] clang compile --- kernel/excel.h | 2 -- kernel/exception.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/kernel/excel.h b/kernel/excel.h index 53b7637..110f552 100644 --- a/kernel/excel.h +++ b/kernel/excel.h @@ -27,8 +27,6 @@ typedef struct { extern zend_class_entry *vtiful_excel_ce; -VTIFUL_STARTUP_FUNCTION(excel); - excel_resource_t * zval_get_resource(zval *handle); #endif diff --git a/kernel/exception.h b/kernel/exception.h index dd8fea3..48c13ab 100644 --- a/kernel/exception.h +++ b/kernel/exception.h @@ -15,6 +15,4 @@ extern zend_class_entry *vtiful_exception_ce; -VTIFUL_STARTUP_FUNCTION(vtiful_exception); - #endif From 9056a7d6346f0a88bce23fed3ac60411e226e989 Mon Sep 17 00:00:00 2001 From: viest Date: Tue, 28 Nov 2017 00:31:08 +0800 Subject: [PATCH 2/4] clang compiling --- config.m4 | 2 ++ kernel/excel.c | 7 +++---- kernel/excel.h | 3 +++ kernel/exception.h | 2 ++ php_vtiful.h | 6 ++++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/config.m4 b/config.m4 index c1faeb5..3aa13fb 100644 --- a/config.m4 +++ b/config.m4 @@ -41,4 +41,6 @@ if test "$PHP_VTIFUL" != "no"; then PHP_SUBST(VTIFUL_SHARED_LIBADD) PHP_NEW_EXTENSION(vtiful, $vtiful_sources, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) + + PHP_ADD_BUILD_DIR([$ext_builddir/kernel]) fi diff --git a/kernel/excel.c b/kernel/excel.c index 1f381ee..b389041 100644 --- a/kernel/excel.c +++ b/kernel/excel.c @@ -20,7 +20,6 @@ #include "php.h" -#include "php_vtiful.h" #include "excel.h" #include "exception.h" #include "write.h" @@ -244,7 +243,7 @@ PHP_METHOD(vtiful_excel, insertText) { zval rv, res_handle; zval *attr_handle, *data; - zend_long *row, *column; + zend_long row, column; excel_resource_t *res; ZEND_PARSE_PARAMETERS_START(3, 3) @@ -273,7 +272,7 @@ PHP_METHOD(vtiful_excel, insertImage) { zval rv, res_handle; zval *attr_handle, *image; - zend_long *row, *column; + zend_long row, column; excel_resource_t *res; ZEND_PARSE_PARAMETERS_START(3, 3) @@ -302,7 +301,7 @@ PHP_METHOD(vtiful_excel, insertFormula) { zval rv, res_handle; zval *attr_handle, *formula; - zend_long *row, *column; + zend_long row, column; excel_resource_t *res; ZEND_PARSE_PARAMETERS_START(3, 3) diff --git a/kernel/excel.h b/kernel/excel.h index 110f552..5dfc5d2 100644 --- a/kernel/excel.h +++ b/kernel/excel.h @@ -13,6 +13,7 @@ #ifndef VTIFUL_EXCEL_H #define VTIFUL_EXCEL_H +#include "php_vtiful.h" #include "xlsxwriter.h" typedef struct { @@ -29,4 +30,6 @@ extern zend_class_entry *vtiful_excel_ce; excel_resource_t * zval_get_resource(zval *handle); +VTIFUL_STARTUP_FUNCTION(excel); + #endif diff --git a/kernel/exception.h b/kernel/exception.h index 48c13ab..dd8fea3 100644 --- a/kernel/exception.h +++ b/kernel/exception.h @@ -15,4 +15,6 @@ extern zend_class_entry *vtiful_exception_ce; +VTIFUL_STARTUP_FUNCTION(vtiful_exception); + #endif diff --git a/php_vtiful.h b/php_vtiful.h index 86bc04a..d7aeb81 100644 --- a/php_vtiful.h +++ b/php_vtiful.h @@ -44,6 +44,12 @@ void _php_vtiful_excel_close(zend_resource *rsrc TSRMLS_DC); ZEND_TSRMLS_CACHE_EXTERN(); #endif +PHP_MINIT_FUNCTION(vtiful); +PHP_MSHUTDOWN_FUNCTION(vtiful); +PHP_RINIT_FUNCTION(vtiful); +PHP_RSHUTDOWN_FUNCTION(vtiful); +PHP_MINFO_FUNCTION(vtiful); + #endif From dd26c3e75100140a58481c8db0f60de2a579b197 Mon Sep 17 00:00:00 2001 From: viest <986465329@qq.com> Date: Tue, 28 Nov 2017 08:46:00 +0800 Subject: [PATCH 3/4] code format adjustment --- kernel/excel.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/kernel/excel.c b/kernel/excel.c index b389041..2c0e571 100644 --- a/kernel/excel.c +++ b/kernel/excel.c @@ -26,6 +26,8 @@ zend_class_entry *vtiful_excel_ce; +/* {{{ ARG_INFO + */ ZEND_BEGIN_ARG_INFO_EX(excel_construct_arginfo, 0, 0, 1) ZEND_ARG_INFO(0, config) ZEND_END_ARG_INFO() @@ -63,7 +65,9 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(excel_auto_filter_arginfo, 0, 0, 1) ZEND_ARG_INFO(0, range) ZEND_END_ARG_INFO() +/* }}} */ +/* {{{ */ excel_resource_t * zval_get_resource(zval *handle) { excel_resource_t *res; @@ -74,6 +78,7 @@ excel_resource_t * zval_get_resource(zval *handle) return res; } +/* }}} */ /* {{{ \Vtiful\Kernel\Excel::__construct(array $config) */ @@ -155,9 +160,7 @@ PHP_METHOD(vtiful_excel, header) ZVAL_COPY(return_value, getThis()); attr_handle = zend_read_property(vtiful_excel_ce, return_value, ZEND_STRL(V_EXCEL_HANDLE), 0, &rv TSRMLS_DC); - if((res = (excel_resource_t *)zend_fetch_resource(Z_RES_P(attr_handle), VTIFUL_RESOURCE_NAME, le_vtiful)) == NULL) { - zend_throw_exception(vtiful_exception_ce, "Excel resources resolution fail", 210); - } + res = zval_get_resource(attr_handle); ZEND_HASH_FOREACH_NUM_KEY_VAL(Z_ARRVAL_P(header), header_l_key, header_value) { type_writer(header_value, 0, header_l_key, res); @@ -184,9 +187,7 @@ PHP_METHOD(vtiful_excel, data) ZVAL_COPY(return_value, getThis()); attr_handle = zend_read_property(vtiful_excel_ce, return_value, ZEND_STRL(V_EXCEL_HANDLE), 0, &rv TSRMLS_DC); - if((res = (excel_resource_t *)zend_fetch_resource(Z_RES_P(attr_handle), VTIFUL_RESOURCE_NAME, le_vtiful)) == NULL) { - zend_throw_exception(vtiful_exception_ce, "Excel resources resolution fail", 210); - } + res = zval_get_resource(attr_handle); ZEND_HASH_FOREACH_NUM_KEY_VAL(Z_ARRVAL_P(data), data_r_key, data_r_value) { if(Z_TYPE_P(data_r_value) == IS_ARRAY) { @@ -210,10 +211,7 @@ PHP_METHOD(vtiful_excel, output) excel_resource_t *res; handle = zend_read_property(vtiful_excel_ce, getThis(), ZEND_STRL(V_EXCEL_HANDLE), 0, &rv TSRMLS_DC); - - if((res = (excel_resource_t *)zend_fetch_resource(Z_RES_P(handle), VTIFUL_RESOURCE_NAME, le_vtiful)) == NULL) { - zend_throw_exception(vtiful_exception_ce, "Excel resources resolution fail", 210); - } + res = zval_get_resource(handle); workbook_file(res, handle); @@ -255,9 +253,7 @@ PHP_METHOD(vtiful_excel, insertText) ZVAL_COPY(return_value, getThis()); attr_handle = zend_read_property(vtiful_excel_ce, return_value, ZEND_STRL(V_EXCEL_HANDLE), 0, &rv TSRMLS_DC); - if((res = (excel_resource_t *)zend_fetch_resource(Z_RES_P(attr_handle), VTIFUL_RESOURCE_NAME, le_vtiful)) == NULL) { - zend_throw_exception(vtiful_exception_ce, "Excel resources resolution fail", 210); - } + res = zval_get_resource(attr_handle); type_writer(data, row, column, res); @@ -284,9 +280,7 @@ PHP_METHOD(vtiful_excel, insertImage) ZVAL_COPY(return_value, getThis()); attr_handle = zend_read_property(vtiful_excel_ce, return_value, ZEND_STRL(V_EXCEL_HANDLE), 0, &rv TSRMLS_DC); - if((res = (excel_resource_t *)zend_fetch_resource(Z_RES_P(attr_handle), VTIFUL_RESOURCE_NAME, le_vtiful)) == NULL) { - zend_throw_exception(vtiful_exception_ce, "Excel resources resolution fail", 210); - } + res = zval_get_resource(attr_handle); image_writer(image, row, column, res); @@ -313,9 +307,7 @@ PHP_METHOD(vtiful_excel, insertFormula) ZVAL_COPY(return_value, getThis()); attr_handle = zend_read_property(vtiful_excel_ce, return_value, ZEND_STRL(V_EXCEL_HANDLE), 0, &rv TSRMLS_DC); - if((res = (excel_resource_t *)zend_fetch_resource(Z_RES_P(attr_handle), VTIFUL_RESOURCE_NAME, le_vtiful)) == NULL) { - zend_throw_exception(vtiful_exception_ce, "Excel resources resolution fail", 210); - } + res = zval_get_resource(attr_handle); formula_writer(formula, row, column, res); From 5b9a2512ba08b2520fad49096375f2f970222fb4 Mon Sep 17 00:00:00 2001 From: viest <986465329@qq.com> Date: Tue, 28 Nov 2017 08:50:48 +0800 Subject: [PATCH 4/4] code format adjustment --- kernel/excel.c | 28 +++++++++++++++++----------- kernel/excel.h | 2 +- kernel/exception.c | 8 +++++++- kernel/exception.h | 2 +- kernel/write.c | 2 +- kernel/write.h | 2 +- 6 files changed, 28 insertions(+), 16 deletions(-) diff --git a/kernel/excel.c b/kernel/excel.c index 2c0e571..1e3317b 100644 --- a/kernel/excel.c +++ b/kernel/excel.c @@ -4,7 +4,7 @@ +----------------------------------------------------------------------+ | Copyright (c) 2017-2017 The Viest | +----------------------------------------------------------------------+ - | http://www.vtiful.com | + | http://www.viest.me | +----------------------------------------------------------------------+ | Author: viest | +----------------------------------------------------------------------+ @@ -80,7 +80,7 @@ excel_resource_t * zval_get_resource(zval *handle) } /* }}} */ -/* {{{ \Vtiful\Kernel\Excel::__construct(array $config) +/** {{{ \Vtiful\Kernel\Excel::__construct(array $config) */ PHP_METHOD(vtiful_excel, __construct) { @@ -104,7 +104,7 @@ PHP_METHOD(vtiful_excel, __construct) } /* }}} */ -/* {{{ \Vtiful\Kernel\Excel::filename(string $fileName) +/** {{{ \Vtiful\Kernel\Excel::filename(string $fileName) */ PHP_METHOD(vtiful_excel, fileName) { @@ -145,7 +145,7 @@ PHP_METHOD(vtiful_excel, fileName) } /* }}} */ -/* {{{ \Vtiful\Kernel\Excel::header(array $header) +/** {{{ \Vtiful\Kernel\Excel::header(array $header) */ PHP_METHOD(vtiful_excel, header) { @@ -172,7 +172,7 @@ PHP_METHOD(vtiful_excel, header) } /* }}} */ -/* {{{ \Vtiful\Kernel\Excel::data(array $data) +/** {{{ \Vtiful\Kernel\Excel::data(array $data) */ PHP_METHOD(vtiful_excel, data) { @@ -203,7 +203,7 @@ PHP_METHOD(vtiful_excel, data) } /* }}} */ -/* {{{ \Vtiful\Kernel\Excel::output() +/** {{{ \Vtiful\Kernel\Excel::output() */ PHP_METHOD(vtiful_excel, output) { @@ -222,7 +222,7 @@ PHP_METHOD(vtiful_excel, output) } /* }}} */ -/* {{{ \Vtiful\Kernel\Excel::getHandle() +/** {{{ \Vtiful\Kernel\Excel::getHandle() */ PHP_METHOD(vtiful_excel, getHandle) { @@ -235,7 +235,7 @@ PHP_METHOD(vtiful_excel, getHandle) } /* }}} */ -/* {{{ \Vtiful\Kernel\Excel::insertText(int $row, int $column, string|int|double $data) +/** {{{ \Vtiful\Kernel\Excel::insertText(int $row, int $column, string|int|double $data) */ PHP_METHOD(vtiful_excel, insertText) { @@ -262,7 +262,7 @@ PHP_METHOD(vtiful_excel, insertText) } /* }}} */ -/* {{{ \Vtiful\Kernel\Excel::insertImage(int $row, int $column, string $imagePath) +/** {{{ \Vtiful\Kernel\Excel::insertImage(int $row, int $column, string $imagePath) */ PHP_METHOD(vtiful_excel, insertImage) { @@ -289,7 +289,7 @@ PHP_METHOD(vtiful_excel, insertImage) } /* }}} */ -/* {{{ \Vtiful\Kernel\Excel::insertImage(int $row, int $column, string $imagePath) +/** {{{ \Vtiful\Kernel\Excel::insertImage(int $row, int $column, string $imagePath) */ PHP_METHOD(vtiful_excel, insertFormula) { @@ -316,7 +316,7 @@ PHP_METHOD(vtiful_excel, insertFormula) } /* }}} */ -/* {{{ \Vtiful\Kernel\Excel::autoFilter(int $rowStart, int $rowEnd, int $columnStart, int $columnEnd) +/** {{{ \Vtiful\Kernel\Excel::autoFilter(int $rowStart, int $rowEnd, int $columnStart, int $columnEnd) */ PHP_METHOD(vtiful_excel, autoFilter) { @@ -341,6 +341,8 @@ PHP_METHOD(vtiful_excel, autoFilter) } /* }}} */ +/** {{{ excel_methods +*/ zend_function_entry excel_methods[] = { PHP_ME(vtiful_excel, __construct, excel_construct_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(vtiful_excel, fileName, excel_file_name_arginfo, ZEND_ACC_PUBLIC) @@ -354,7 +356,10 @@ zend_function_entry excel_methods[] = { PHP_ME(vtiful_excel, insertFormula, excel_insert_formula_arginfo, ZEND_ACC_PUBLIC) PHP_FE_END }; +/* }}} */ +/** {{{ VTIFUL_STARTUP_FUNCTION +*/ VTIFUL_STARTUP_FUNCTION(excel) { zend_class_entry ce; @@ -368,6 +373,7 @@ VTIFUL_STARTUP_FUNCTION(excel) { return SUCCESS; } +/* }}} */ diff --git a/kernel/excel.h b/kernel/excel.h index 5dfc5d2..efa31e5 100644 --- a/kernel/excel.h +++ b/kernel/excel.h @@ -4,7 +4,7 @@ +----------------------------------------------------------------------+ | Copyright (c) 2017-2017 The Viest | +----------------------------------------------------------------------+ - | http://www.vtiful.com | + | http://www.viest.me | +----------------------------------------------------------------------+ | Author: viest | +----------------------------------------------------------------------+ diff --git a/kernel/exception.c b/kernel/exception.c index b0d9d06..1ddd5c8 100644 --- a/kernel/exception.c +++ b/kernel/exception.c @@ -4,7 +4,7 @@ +----------------------------------------------------------------------+ | Copyright (c) 2017-2017 The Viest | +----------------------------------------------------------------------+ - | http://www.vtiful.com | + | http://www.viest.me | +----------------------------------------------------------------------+ | Author: viest | +----------------------------------------------------------------------+ @@ -17,10 +17,15 @@ zend_class_entry *vtiful_exception_ce; +/** {{{ exception_methods +*/ zend_function_entry exception_methods[] = { PHP_FE_END }; +/* }}} */ +/** {{{ VTIFUL_STARTUP_FUNCTION +*/ VTIFUL_STARTUP_FUNCTION(vtiful_exception) { zend_class_entry ce; @@ -30,3 +35,4 @@ VTIFUL_STARTUP_FUNCTION(vtiful_exception) { return SUCCESS; } +/* }}} */ diff --git a/kernel/exception.h b/kernel/exception.h index dd8fea3..be63077 100644 --- a/kernel/exception.h +++ b/kernel/exception.h @@ -4,7 +4,7 @@ +----------------------------------------------------------------------+ | Copyright (c) 2017-2017 The Viest | +----------------------------------------------------------------------+ - | http://www.vtiful.com | + | http://www.viest.me | +----------------------------------------------------------------------+ | Author: viest | +----------------------------------------------------------------------+ diff --git a/kernel/write.c b/kernel/write.c index 2bd25fc..5203ccd 100644 --- a/kernel/write.c +++ b/kernel/write.c @@ -4,7 +4,7 @@ +----------------------------------------------------------------------+ | Copyright (c) 2017-2017 The Viest | +----------------------------------------------------------------------+ - | http://www.vtiful.com | + | http://www.viest.me | +----------------------------------------------------------------------+ | Author: viest | +----------------------------------------------------------------------+ diff --git a/kernel/write.h b/kernel/write.h index 09a5d4a..80e891f 100644 --- a/kernel/write.h +++ b/kernel/write.h @@ -4,7 +4,7 @@ +----------------------------------------------------------------------+ | Copyright (c) 2017-2017 The Viest | +----------------------------------------------------------------------+ - | http://www.vtiful.com | + | http://www.viest.me | +----------------------------------------------------------------------+ | Author: viest | +----------------------------------------------------------------------+