Skip to content
Permalink
Browse files

[mapscript/php] Fix build problems for PHP 7.3

 * array_init is no longer function-like
   * generally was probably never worth checking the return type, so all
     checks for failure removed

 * Changes in API for reference counting for GC
  • Loading branch information...
ejn committed Mar 4, 2019
1 parent ce2169f commit f1a579a7ce06289c7783a4c770b78262ab409635
Showing with 26 additions and 20 deletions.
  1. +1 −3 mapscript/php/php_mapscript.c
  2. +21 −5 mapscript/php/php_mapscript_util.h
  3. +4 −12 mapscript/php/php_proj.c
@@ -898,9 +898,7 @@ PHP_FUNCTION(ms_tokenizeMap)
filename);
return;
} else {
if (array_init(return_value) == FAILURE) {
RETURN_FALSE;
}
array_init(return_value);

for (i=0; i<numtokens; i++) {
#if PHP_VERSION_ID < 70000
@@ -145,19 +145,34 @@ static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isre
FREE_HASHTABLE(zobj->std.properties);
#endif /* PHP_VERSION_ID < 70000 */

#if PHP_VERSION_ID >= 70300
#define MAPSCRIPT_ADDREF(zv) zend_gc_addref(&(Z_COUNTED(zv))->gc)
#define MAPSCRIPT_ADDREF_P(p) zend_gc_addref(&(Z_COUNTED_P(p))->gc)
#else
#if PHP_VERSION_ID >= 70000
#define MAPSCRIPT_ADDREF(zv) if(!(Z_ISUNDEF(zv))) GC_REFCOUNT(Z_COUNTED(zv))++;
#define MAPSCRIPT_ADDREF_P(zv) if(!(Z_ISUNDEF(*zv))) GC_REFCOUNT(Z_COUNTED_P(zv))++;
#else
#define MAPSCRIPT_ADDREF(zobj) if (zobj) Z_ADDREF_P(zobj)
#define MAPSCRIPT_ADDREF_P(zv) MAPSCRIPT_ADDREF(zv)
#endif
#endif /* PHP_VERSION_ID >= 70000 */
#endif /* PHP_VERSION_ID >= 70300 */

#if PHP_VERSION_ID >= 70300
#define MAPSCRIPT_DELREF(zv) \
if (!(Z_ISUNDEF(zv))) \
{ \
zend_refcounted *_gc = Z_COUNTED(zv); \
zend_gc_delref(&_gc->gc); \
if(GC_REFCOUNT(_gc) == 0) \
rc_dtor_func(_gc); \
ZVAL_UNDEF(&zv); \
}
#else
#if PHP_VERSION_ID >= 70000
#ifndef _zval_dtor_func_for_ptr
//use _zval_dtor_func in PHP7.1 instead
#if PHP_VERSION_ID >= 70100
#define _zval_dtor_func_for_ptr _zval_dtor_func
#endif
#endif /* PHP_VERSION_ID >= 70100 */
#define MAPSCRIPT_DELREF(zv) \
if (!(Z_ISUNDEF(zv))) \
{ \
@@ -178,7 +193,8 @@ static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isre
} \
zobj = NULL; \
}
#endif
#endif /* PHP_VERSION_ID >= 70000 */
#endif /* PHP_VERSION_ID >= 70300 */

#if PHP_VERSION_ID >= 70000
#define MAPSCRIPT_FREE_PARENT(parent) \
@@ -403,9 +403,7 @@ DLEXPORT void php_proj_pj_fwd(INTERNAL_FUNCTION_PARAMETERS)
/* -------------------------------------------------------------------- */
/* initilize return array. */
/* -------------------------------------------------------------------- */
if (array_init(return_value) == FAILURE) {
RETURN_FALSE;
}
array_init(return_value);

convert_to_double(p1);
convert_to_double(p2);
@@ -467,9 +465,7 @@ DLEXPORT void php_proj_pj_inv(INTERNAL_FUNCTION_PARAMETERS)
/* -------------------------------------------------------------------- */
/* initilize return array. */
/* -------------------------------------------------------------------- */
if (array_init(return_value) == FAILURE) {
RETURN_FALSE;
}
array_init(return_value);

convert_to_double(p1);
convert_to_double(p2);
@@ -524,9 +520,7 @@ DLEXPORT void php_proj_pj_transform(INTERNAL_FUNCTION_PARAMETERS)
/* -------------------------------------------------------------------- */
/* initilize return array. */
/* -------------------------------------------------------------------- */
if (array_init(return_value) == FAILURE) {
RETURN_FALSE;
}
array_init(return_value);

convert_to_double(p1);
convert_to_double(p2);
@@ -602,9 +596,7 @@ DLEXPORT void php_proj_pj_datum_transform(INTERNAL_FUNCTION_PARAMETERS)
/* -------------------------------------------------------------------- */
/* initilize return array. */
/* -------------------------------------------------------------------- */
if (array_init(return_value) == FAILURE) {
RETURN_FALSE;
}
array_init(return_value);

convert_to_double(p1);
convert_to_double(p2);

0 comments on commit f1a579a

Please sign in to comment.
You can’t perform that action at this time.