Skip to content

Commit

Permalink
Merge pull request #11 from viest/dev
Browse files Browse the repository at this point in the history
compatible with clang compiler
  • Loading branch information
viest authored Nov 28, 2017
2 parents a9efd65 + 5b9a251 commit d6cc07e
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 41 deletions.
2 changes: 2 additions & 0 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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
65 changes: 31 additions & 34 deletions kernel/excel.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
+----------------------------------------------------------------------+
| Copyright (c) 2017-2017 The Viest |
+----------------------------------------------------------------------+
| http://www.vtiful.com |
| http://www.viest.me |
+----------------------------------------------------------------------+
| Author: viest <dev@service.viest.me> |
+----------------------------------------------------------------------+
Expand All @@ -20,13 +20,14 @@

#include "php.h"

#include "php_vtiful.h"
#include "excel.h"
#include "exception.h"
#include "write.h"

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()
Expand Down Expand Up @@ -64,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;
Expand All @@ -75,8 +78,9 @@ excel_resource_t * zval_get_resource(zval *handle)

return res;
}
/* }}} */

/* {{{ \Vtiful\Kernel\Excel::__construct(array $config)
/** {{{ \Vtiful\Kernel\Excel::__construct(array $config)
*/
PHP_METHOD(vtiful_excel, __construct)
{
Expand All @@ -100,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)
{
Expand Down Expand Up @@ -141,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)
{
Expand All @@ -156,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);
Expand All @@ -170,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)
{
Expand All @@ -185,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) {
Expand All @@ -203,18 +203,15 @@ PHP_METHOD(vtiful_excel, data)
}
/* }}} */

/* {{{ \Vtiful\Kernel\Excel::output()
/** {{{ \Vtiful\Kernel\Excel::output()
*/
PHP_METHOD(vtiful_excel, output)
{
zval rv, *handle, null_handle;
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);

Expand All @@ -225,7 +222,7 @@ PHP_METHOD(vtiful_excel, output)
}
/* }}} */

/* {{{ \Vtiful\Kernel\Excel::getHandle()
/** {{{ \Vtiful\Kernel\Excel::getHandle()
*/
PHP_METHOD(vtiful_excel, getHandle)
{
Expand All @@ -238,13 +235,13 @@ 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)
{
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)
Expand All @@ -256,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);

Expand All @@ -267,13 +262,13 @@ 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)
{
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)
Expand All @@ -285,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);

Expand All @@ -296,13 +289,13 @@ 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)
{
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)
Expand All @@ -314,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);

Expand All @@ -325,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)
{
Expand All @@ -350,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)
Expand All @@ -363,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;

Expand All @@ -377,6 +373,7 @@ VTIFUL_STARTUP_FUNCTION(excel) {

return SUCCESS;
}
/* }}} */



7 changes: 4 additions & 3 deletions kernel/excel.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
+----------------------------------------------------------------------+
| Copyright (c) 2017-2017 The Viest |
+----------------------------------------------------------------------+
| http://www.vtiful.com |
| http://www.viest.me |
+----------------------------------------------------------------------+
| Author: viest <dev@service.viest.me> |
+----------------------------------------------------------------------+
Expand All @@ -13,6 +13,7 @@
#ifndef VTIFUL_EXCEL_H
#define VTIFUL_EXCEL_H

#include "php_vtiful.h"
#include "xlsxwriter.h"

typedef struct {
Expand All @@ -27,8 +28,8 @@ typedef struct {

extern zend_class_entry *vtiful_excel_ce;

VTIFUL_STARTUP_FUNCTION(excel);

excel_resource_t * zval_get_resource(zval *handle);

VTIFUL_STARTUP_FUNCTION(excel);

#endif
8 changes: 7 additions & 1 deletion kernel/exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
+----------------------------------------------------------------------+
| Copyright (c) 2017-2017 The Viest |
+----------------------------------------------------------------------+
| http://www.vtiful.com |
| http://www.viest.me |
+----------------------------------------------------------------------+
| Author: viest <dev@service.viest.me> |
+----------------------------------------------------------------------+
Expand All @@ -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;

Expand All @@ -30,3 +35,4 @@ VTIFUL_STARTUP_FUNCTION(vtiful_exception) {

return SUCCESS;
}
/* }}} */
2 changes: 1 addition & 1 deletion kernel/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
+----------------------------------------------------------------------+
| Copyright (c) 2017-2017 The Viest |
+----------------------------------------------------------------------+
| http://www.vtiful.com |
| http://www.viest.me |
+----------------------------------------------------------------------+
| Author: viest <dev@service.viest.me> |
+----------------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion kernel/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
+----------------------------------------------------------------------+
| Copyright (c) 2017-2017 The Viest |
+----------------------------------------------------------------------+
| http://www.vtiful.com |
| http://www.viest.me |
+----------------------------------------------------------------------+
| Author: viest <dev@service.viest.me> |
+----------------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion kernel/write.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
+----------------------------------------------------------------------+
| Copyright (c) 2017-2017 The Viest |
+----------------------------------------------------------------------+
| http://www.vtiful.com |
| http://www.viest.me |
+----------------------------------------------------------------------+
| Author: viest <dev@service.viest.me> |
+----------------------------------------------------------------------+
Expand Down
6 changes: 6 additions & 0 deletions php_vtiful.h
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit d6cc07e

Please sign in to comment.