Skip to content

Commit d6cc07e

Browse files
authored
Merge pull request #11 from viest/dev
compatible with clang compiler
2 parents a9efd65 + 5b9a251 commit d6cc07e

File tree

8 files changed

+53
-41
lines changed

8 files changed

+53
-41
lines changed

config.m4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@ if test "$PHP_VTIFUL" != "no"; then
4141
PHP_SUBST(VTIFUL_SHARED_LIBADD)
4242

4343
PHP_NEW_EXTENSION(vtiful, $vtiful_sources, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
44+
45+
PHP_ADD_BUILD_DIR([$ext_builddir/kernel])
4446
fi

kernel/excel.c

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
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
+----------------------------------------------------------------------+
@@ -20,13 +20,14 @@
2020

2121
#include "php.h"
2222

23-
#include "php_vtiful.h"
2423
#include "excel.h"
2524
#include "exception.h"
2625
#include "write.h"
2726

2827
zend_class_entry *vtiful_excel_ce;
2928

29+
/* {{{ ARG_INFO
30+
*/
3031
ZEND_BEGIN_ARG_INFO_EX(excel_construct_arginfo, 0, 0, 1)
3132
ZEND_ARG_INFO(0, config)
3233
ZEND_END_ARG_INFO()
@@ -64,7 +65,9 @@ ZEND_END_ARG_INFO()
6465
ZEND_BEGIN_ARG_INFO_EX(excel_auto_filter_arginfo, 0, 0, 1)
6566
ZEND_ARG_INFO(0, range)
6667
ZEND_END_ARG_INFO()
68+
/* }}} */
6769

70+
/* {{{ */
6871
excel_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
*/
8185
PHP_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
*/
105109
PHP_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
*/
146150
PHP_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
*/
175177
PHP_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
*/
208208
PHP_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
*/
230227
PHP_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
*/
243240
PHP_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
*/
272267
PHP_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
*/
301294
PHP_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
*/
330321
PHP_METHOD(vtiful_excel, autoFilter)
331322
{
@@ -350,6 +341,8 @@ PHP_METHOD(vtiful_excel, autoFilter)
350341
}
351342
/* }}} */
352343

344+
/** {{{ excel_methods
345+
*/
353346
zend_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+
*/
367363
VTIFUL_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

kernel/excel.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
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
+----------------------------------------------------------------------+
@@ -13,6 +13,7 @@
1313
#ifndef VTIFUL_EXCEL_H
1414
#define VTIFUL_EXCEL_H
1515

16+
#include "php_vtiful.h"
1617
#include "xlsxwriter.h"
1718

1819
typedef struct {
@@ -27,8 +28,8 @@ typedef struct {
2728

2829
extern zend_class_entry *vtiful_excel_ce;
2930

30-
VTIFUL_STARTUP_FUNCTION(excel);
31-
3231
excel_resource_t * zval_get_resource(zval *handle);
3332

33+
VTIFUL_STARTUP_FUNCTION(excel);
34+
3435
#endif

kernel/exception.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
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
+----------------------------------------------------------------------+
@@ -17,10 +17,15 @@
1717

1818
zend_class_entry *vtiful_exception_ce;
1919

20+
/** {{{ exception_methods
21+
*/
2022
zend_function_entry exception_methods[] = {
2123
PHP_FE_END
2224
};
25+
/* }}} */
2326

27+
/** {{{ VTIFUL_STARTUP_FUNCTION
28+
*/
2429
VTIFUL_STARTUP_FUNCTION(vtiful_exception) {
2530
zend_class_entry ce;
2631

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

3136
return SUCCESS;
3237
}
38+
/* }}} */

kernel/exception.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
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
+----------------------------------------------------------------------+

kernel/write.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
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
+----------------------------------------------------------------------+

kernel/write.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
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
+----------------------------------------------------------------------+

php_vtiful.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ void _php_vtiful_excel_close(zend_resource *rsrc TSRMLS_DC);
4444
ZEND_TSRMLS_CACHE_EXTERN();
4545
#endif
4646

47+
PHP_MINIT_FUNCTION(vtiful);
48+
PHP_MSHUTDOWN_FUNCTION(vtiful);
49+
PHP_RINIT_FUNCTION(vtiful);
50+
PHP_RSHUTDOWN_FUNCTION(vtiful);
51+
PHP_MINFO_FUNCTION(vtiful);
52+
4753
#endif
4854

4955

0 commit comments

Comments
 (0)