mapserver/5461.patch

8837 lines
312 KiB
Diff
Raw Normal View History

From 9dbfe1b23d9c9529c9c980bd3de79dbf2033f388 Mon Sep 17 00:00:00 2001
From: bjoernboldt <mapscript@pixaweb.net>
Date: Mon, 3 Jul 2017 09:32:20 +0200
Subject: [PATCH 1/5] Add PHP7.x-support
---
mapscript/php/class.c | 184 +++++++++++-----
mapscript/php/cluster.c | 81 +++++--
mapscript/php/color.c | 68 +++++-
mapscript/php/error.c | 96 ++++++--
mapscript/php/grid.c | 82 ++++++-
mapscript/php/hashtable.c | 73 ++++++-
mapscript/php/image.c | 67 +++++-
mapscript/php/label.c | 141 +++++++++---
mapscript/php/labelcache.c | 56 ++++-
mapscript/php/labelcachemember.c | 104 +++++++--
mapscript/php/labelleader.c | 58 ++++-
mapscript/php/layer.c | 438 ++++++++++++++++++++++++-------------
mapscript/php/legend.c | 76 ++++++-
mapscript/php/line.c | 101 +++++++--
mapscript/php/map.c | 378 +++++++++++++++++++++-----------
mapscript/php/mapscript_error.c | 13 ++
mapscript/php/outputformat.c | 81 ++++++-
mapscript/php/owsrequest.c | 174 ++++++++++++---
mapscript/php/php_mapscript.c | 80 +++++--
mapscript/php/php_mapscript.h | 326 ++++++++++++++++++++++++++-
mapscript/php/php_mapscript_util.c | 77 ++++---
mapscript/php/php_mapscript_util.h | 89 +++++++-
mapscript/php/point.c | 121 ++++++++--
mapscript/php/projection.c | 83 ++++++-
mapscript/php/querymap.c | 73 ++++++-
mapscript/php/rect.c | 108 +++++++--
mapscript/php/referencemap.c | 75 ++++++-
mapscript/php/result.c | 59 ++++-
mapscript/php/scalebar.c | 81 ++++++-
mapscript/php/shape.c | 199 +++++++++++------
mapscript/php/shapefile.c | 79 +++++--
mapscript/php/style.c | 158 +++++++++----
mapscript/php/symbol.c | 92 ++++++--
mapscript/php/web.c | 75 ++++++-
34 files changed, 3259 insertions(+), 787 deletions(-)
diff --git a/mapscript/php/class.c b/mapscript/php/class.c
index 48f2f812a..a256ac9bd 100644
--- a/mapscript/php/class.c
+++ b/mapscript/php/class.c
@@ -143,10 +143,10 @@ PHP_METHOD(classObj, __construct)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_layer = (php_layer_object *) zend_object_store_get_object(zlayer TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zlayer);
if (zclass)
- php_class2 = (php_class_object *) zend_object_store_get_object(zclass TSRMLS_CC);
+ php_class2 = MAPSCRIPT_OBJ_P(php_class_object, zclass);
if ((class = classObj_new(php_layer->layer, (zclass ? php_class2->class:NULL))) == NULL) {
@@ -177,7 +177,7 @@ PHP_METHOD(classObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
IF_GET_STRING("name", php_class->class->name)
else IF_GET_STRING("title", php_class->class->title)
@@ -213,7 +213,7 @@ PHP_METHOD(classObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
/* special case for "template" which we want to set to NULL and not an empty string */
if(Z_TYPE_P(value)==IS_NULL && !strcmp(property,"template")) {
@@ -258,8 +258,8 @@ PHP_METHOD(classObj, addLabel)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_label = (php_label_object *) zend_object_store_get_object(zlabel TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zlabel);
status = classObj_addLabel(php_class->class, php_label->label);
php_label->is_ref = 1;
@@ -287,7 +287,7 @@ PHP_METHOD(classObj, removeLabel)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
if ((label = classObj_removeLabel(php_class->class, index)) == NULL) {
mapscript_report_mapserver_error(E_WARNING TSRMLS_CC);
@@ -318,7 +318,7 @@ PHP_METHOD(classObj, getLabel)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
if ((label = classObj_getLabel(php_class->class, index)) == NULL) {
mapscript_throw_exception("Invalid label index." TSRMLS_CC);
@@ -349,7 +349,7 @@ PHP_METHOD(classObj, updateFromString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
status = classObj_updateFromString(php_class->class, snippet);
@@ -378,14 +378,14 @@ PHP_METHOD(classObj, convertToString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
value = classObj_convertToString(php_class->class);
if (value == NULL)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -408,7 +408,7 @@ PHP_METHOD(classObj, setExpression)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
status = classObj_setExpression(php_class->class, expression);
@@ -437,14 +437,14 @@ PHP_METHOD(classObj, getExpressionString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
value = classObj_getExpressionString(php_class->class);
if (value == NULL)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -468,8 +468,8 @@ PHP_METHOD(classObj, setText)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_layer = (php_layer_object *) zend_object_store_get_object(php_class->parent.val TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
+ php_layer = MAPSCRIPT_OBJ(php_layer_object, php_class->parent.val);
status = classObj_setText(php_class->class, php_layer->layer, text);
@@ -498,14 +498,14 @@ PHP_METHOD(classObj, getTextString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
value = classObj_getTextString(php_class->class);
if (value == NULL)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -528,7 +528,7 @@ PHP_METHOD(classObj, getStyle)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
if (index < 0 || index >= php_class->class->numstyles) {
mapscript_throw_exception("Invalid style index." TSRMLS_CC);
@@ -560,8 +560,8 @@ PHP_METHOD(classObj, insertStyle)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_style = (php_style_object *) zend_object_store_get_object(zstyle TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
+ php_style = MAPSCRIPT_OBJ_P(php_style_object, zstyle);
RETURN_LONG(msInsertStyle(php_class->class, php_style->style, index));
}
@@ -585,7 +585,7 @@ PHP_METHOD(classObj, removeStyle)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
style = msRemoveStyle(php_class->class, index);
@@ -615,7 +615,7 @@ PHP_METHOD(classObj, moveStyleUp)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
status = classObj_moveStyleUp(php_class->class, index);
@@ -643,7 +643,7 @@ PHP_METHOD(classObj, moveStyleDown)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
status = classObj_moveStyleDown(php_class->class, index);
@@ -669,7 +669,7 @@ PHP_METHOD(classObj, deleteStyle)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
status = classObj_deleteStyle(php_class->class, index);
@@ -684,7 +684,7 @@ PHP_METHOD(classObj, getMetaData)
zval *zname;
zval *zobj = getThis();
php_class_object *php_class;
- zval *retval;
+ MAPSCRIPT_ZVAL retval;
PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z",
@@ -694,12 +694,15 @@ PHP_METHOD(classObj, getMetaData)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
CHECK_OBJECT(mapscript_ce_hashtable, php_class->metadata, &php_class->class->metadata);
-
MAPSCRIPT_CALL_METHOD_1(php_class->metadata, "get", retval, zname);
+#if PHP_VERSION_ID < 70000
RETURN_STRING(Z_STRVAL_P(retval),1);
+#else
+ RETURN_STRING(Z_STRVAL(retval));
+#endif
}
/* }}} */
@@ -710,7 +713,7 @@ PHP_METHOD(classObj, setMetaData)
zval *zname, *zvalue;
zval *zobj = getThis();
php_class_object *php_class;
- zval *retval;
+ MAPSCRIPT_ZVAL retval;
PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz",
@@ -720,12 +723,16 @@ PHP_METHOD(classObj, setMetaData)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
CHECK_OBJECT(mapscript_ce_hashtable, php_class->metadata, &php_class->class->metadata);
MAPSCRIPT_CALL_METHOD_2(php_class->metadata, "set", retval, zname, zvalue);
+#if PHP_VERSION_ID < 70000
RETURN_LONG(Z_LVAL_P(retval));
+#else
+ RETURN_LONG(Z_LVAL(retval));
+#endif
}
/* }}} */
@@ -736,7 +743,7 @@ PHP_METHOD(classObj, removeMetaData)
zval *zname;
zval *zobj = getThis();
php_class_object *php_class;
- zval *retval;
+ MAPSCRIPT_ZVAL retval;
PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z",
@@ -746,12 +753,16 @@ PHP_METHOD(classObj, removeMetaData)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
CHECK_OBJECT(mapscript_ce_hashtable, php_class->metadata, &php_class->class->metadata);
MAPSCRIPT_CALL_METHOD_1(php_class->metadata, "remove", retval, zname);
+#if PHP_VERSION_ID < 70000
RETURN_LONG(Z_LVAL_P(retval));
+#else
+ RETURN_LONG(Z_LVAL(retval));
+#endif
}
/* }}} */
@@ -774,15 +785,15 @@ PHP_METHOD(classObj, createLegendIcon)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_layer = (php_layer_object *) zend_object_store_get_object(php_class->parent.val TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
+ php_layer = MAPSCRIPT_OBJ(php_layer_object, php_class->parent.val);
- if (!php_layer->parent.val) {
+ if (ZVAL_IS_UNDEF(php_layer->parent.val)) {
mapscript_throw_exception("No map object associated with this class object." TSRMLS_CC);
return;
}
- php_map = (php_map_object *) zend_object_store_get_object(php_layer->parent.val TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ(php_map_object, php_layer->parent.val);
if ((image = classObj_createLegendIcon(php_class->class,
php_map->map,
@@ -820,17 +831,17 @@ PHP_METHOD(classObj, drawLegendIcon)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_image = (php_image_object *) zend_object_store_get_object(zimage TSRMLS_CC);
- php_layer = (php_layer_object *) zend_object_store_get_object(php_class->parent.val TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
+ php_image = MAPSCRIPT_OBJ_P(php_image_object, zimage);
+ php_layer = MAPSCRIPT_OBJ(php_layer_object, php_class->parent.val);
- if (!php_layer->parent.val) {
+ if (ZVAL_IS_UNDEF(php_layer->parent.val)) {
mapscript_throw_exception("No map object associated with this class object." TSRMLS_CC);
return;
}
- php_map = (php_map_object *) zend_object_store_get_object(php_layer->parent.val TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ(php_map_object, php_layer->parent.val);
if (!MS_RENDERER_PLUGIN(php_image->image->format)) {
mapscript_report_mapserver_error(E_WARNING TSRMLS_CC);
@@ -865,7 +876,7 @@ PHP_METHOD(classObj, free)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zobj);
MAPSCRIPT_DELREF(php_class->metadata);
}
@@ -905,13 +916,87 @@ void mapscript_create_class(classObj *class, parent_object parent, zval *return_
{
php_class_object * php_class;
object_init_ex(return_value, mapscript_ce_class);
- php_class = (php_class_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, return_value);
php_class->class = class;
php_class->parent = parent;
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_class_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_class_object *php_class;
+
+ php_class = ecalloc(1, sizeof(*php_class) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_class->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_class->zobj, ce);
+
+ php_class->zobj.handlers = &mapscript_class_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_class->parent);
+ ZVAL_UNDEF(&php_class->metadata);
+ ZVAL_UNDEF(&php_class->leader);
+
+ return &php_class->zobj;
+}
+
+static void mapscript_class_free_object(zend_object *object)
+{
+ php_class_object *php_class;
+
+ php_class = (php_class_object *)((char *)object - XtOffsetOf(php_class_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_class->parent);
+
+ MAPSCRIPT_DELREF(php_class->metadata);
+ MAPSCRIPT_DELREF(php_class->leader);
+
+ /* We don't need to free the classObj */
+
+ zend_object_std_dtor(object);
+}
+
+static zend_object* mapscript_class_clone_object(zval *zobj)
+{
+ php_class_object *php_class_old, *php_class_new;
+ php_layer_object *php_layer;
+ zend_object* zobj_new;
+
+ php_class_old = MAPSCRIPT_OBJ_P(php_class_object, zobj);
+ php_layer = MAPSCRIPT_OBJ(php_layer_object, php_class_old->parent.val);
+
+ zobj_new = mapscript_class_create_object(mapscript_ce_class);
+ php_class_new = (php_class_object *)((char *)zobj_new - XtOffsetOf(php_class_object, zobj));
+
+ zend_objects_clone_members(&php_class_new->zobj, &php_class_old->zobj);
+
+ php_class_new->class = classObj_clone(php_class_old->class, php_layer->layer);
+
+ return zobj_new;
+}
+
+PHP_MINIT_FUNCTION(class)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "classObj", class_functions);
+ mapscript_ce_class = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_class->create_object = mapscript_class_create_object;
+ mapscript_ce_class->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_class_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_class_object_handlers));
+ mapscript_class_object_handlers.free_obj = mapscript_class_free_object;
+ mapscript_class_object_handlers.clone_obj = mapscript_class_clone_object;
+ mapscript_class_object_handlers.offset = XtOffsetOf(php_class_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_class_object_destroy(void *object TSRMLS_DC)
{
php_class_object *php_class = (php_class_object *)object;
@@ -961,8 +1046,8 @@ static zend_object_value mapscript_class_object_clone(zval *zobj TSRMLS_DC)
php_layer_object *php_layer;
zend_object_value new_ov;
- php_class_old = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_layer = (php_layer_object *) zend_object_store_get_object(php_class_old->parent.val TSRMLS_CC);
+ php_class_old = MAPSCRIPT_OBJ_P(php_class_object, zobj);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, php_class_old->parent.val);
new_ov = mapscript_class_object_new_ex(mapscript_ce_class, &php_class_new TSRMLS_CC);
zend_objects_clone_members(&php_class_new->std, new_ov, &php_class_old->std, Z_OBJ_HANDLE_P(zobj) TSRMLS_CC);
@@ -988,3 +1073,4 @@ PHP_MINIT_FUNCTION(class)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/cluster.c b/mapscript/php/cluster.c
index 1031c020a..48dce8ae4 100644
--- a/mapscript/php/cluster.c
+++ b/mapscript/php/cluster.c
@@ -32,6 +32,9 @@
#include "php_mapscript.h"
zend_class_entry *mapscript_ce_cluster;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_cluster_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(cluster___get_args, 0, 0, 1)
ZEND_ARG_INFO(0, property)
@@ -78,7 +81,7 @@ PHP_METHOD(clusterObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_cluster = (php_cluster_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_cluster = MAPSCRIPT_OBJ_P(php_cluster_object, zobj);
IF_GET_DOUBLE("maxdistance", php_cluster->cluster->maxdistance)
else IF_GET_DOUBLE("buffer", php_cluster->cluster->buffer)
@@ -104,7 +107,7 @@ PHP_METHOD(clusterObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_cluster = (php_cluster_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_cluster = MAPSCRIPT_OBJ_P(php_cluster_object, zobj);
IF_SET_DOUBLE("maxdistance", php_cluster->cluster->maxdistance, value)
else IF_SET_DOUBLE("buffer", php_cluster->cluster->buffer, value)
@@ -132,7 +135,7 @@ PHP_METHOD(clusterObj, updateFromString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_cluster = (php_cluster_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_cluster = MAPSCRIPT_OBJ_P(php_cluster_object, zobj);
status = clusterObj_updateFromString(php_cluster->cluster, snippet);
@@ -161,14 +164,14 @@ PHP_METHOD(clusterObj, convertToString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_cluster = (php_cluster_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_cluster = MAPSCRIPT_OBJ_P(php_cluster_object, zobj);
value = clusterObj_convertToString(php_cluster->cluster);
if (value == NULL)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -191,7 +194,7 @@ PHP_METHOD(clusterObj, setGroup)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_cluster = (php_cluster_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_cluster = MAPSCRIPT_OBJ_P(php_cluster_object, zobj);
if ((status = clusterObj_setGroup(php_cluster->cluster, group)) != MS_SUCCESS) {
mapscript_throw_mapserver_exception("" TSRMLS_CC);
@@ -217,14 +220,14 @@ PHP_METHOD(clusterObj, getGroupString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_cluster = (php_cluster_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_cluster = MAPSCRIPT_OBJ_P(php_cluster_object, zobj);
value = clusterObj_getGroupString(php_cluster->cluster);
if (value == NULL) {
RETURN_NULL();
}
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -247,7 +250,7 @@ PHP_METHOD(clusterObj, setFilter)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_cluster = (php_cluster_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_cluster = MAPSCRIPT_OBJ_P(php_cluster_object, zobj);
if ((status = clusterObj_setFilter(php_cluster->cluster, filter)) != MS_SUCCESS) {
mapscript_throw_mapserver_exception("" TSRMLS_CC);
@@ -273,14 +276,14 @@ PHP_METHOD(clusterObj, getFilterString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_cluster = (php_cluster_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_cluster = MAPSCRIPT_OBJ_P(php_cluster_object, zobj);
value = clusterObj_getFilterString(php_cluster->cluster);
if (value == NULL) {
RETURN_NULL();
}
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -304,16 +307,65 @@ void mapscript_create_cluster(clusterObj *cluster, parent_object parent, zval *r
{
php_cluster_object * php_cluster;
object_init_ex(return_value, mapscript_ce_cluster);
- php_cluster = (php_cluster_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_cluster = MAPSCRIPT_OBJ_P(php_cluster_object, return_value);
php_cluster->cluster = cluster;
- if (parent.val)
+ if (ZVAL_NOT_UNDEF(parent.val))
php_cluster->is_ref = 1;
php_cluster->parent = parent;
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_cluster_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_cluster_object *php_cluster;
+
+ php_cluster = ecalloc(1, sizeof(*php_cluster) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_cluster->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_cluster->zobj, ce);
+
+ php_cluster->zobj.handlers = &mapscript_cluster_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_cluster->parent);
+
+ return &php_cluster->zobj;
+}
+
+static void mapscript_cluster_free_object(zend_object *object)
+{
+ php_cluster_object *php_cluster;
+
+ php_cluster = (php_cluster_object *)((char *)object - XtOffsetOf(php_cluster_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_cluster->parent);
+
+ /* We don't need to free the clusterObj */
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(cluster)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "clusterObj", cluster_functions);
+ mapscript_ce_cluster = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_cluster->create_object = mapscript_cluster_create_object;
+ mapscript_ce_cluster->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_cluster_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_cluster_object_handlers));
+ mapscript_cluster_object_handlers.free_obj = mapscript_cluster_free_object;
+ mapscript_cluster_object_handlers.offset = XtOffsetOf(php_cluster_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_cluster_object_destroy(void *object TSRMLS_DC)
{
php_cluster_object *php_cluster = (php_cluster_object *)object;
@@ -356,3 +408,4 @@ PHP_MINIT_FUNCTION(cluster)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/color.c b/mapscript/php/color.c
index bc86f3b35..559ef5eb0 100644
--- a/mapscript/php/color.c
+++ b/mapscript/php/color.c
@@ -32,6 +32,9 @@
#include "php_mapscript.h"
zend_class_entry *mapscript_ce_color;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_color_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(color___get_args, 0, 0, 1)
ZEND_ARG_INFO(0, property)
@@ -79,7 +82,7 @@ PHP_METHOD(colorObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_color = (php_color_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_color = MAPSCRIPT_OBJ_P(php_color_object, zobj);
IF_GET_LONG("red", php_color->color->red)
else IF_GET_LONG("green", php_color->color->green)
@@ -106,7 +109,7 @@ PHP_METHOD(colorObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_color = (php_color_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_color = MAPSCRIPT_OBJ_P(php_color_object, zobj);
IF_SET_COLOR("red", php_color->color->red, value)
else IF_SET_COLOR("green", php_color->color->green, value)
@@ -134,7 +137,7 @@ PHP_METHOD(colorObj, setRGB)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_color = (php_color_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_color = MAPSCRIPT_OBJ_P(php_color_object, zobj);
MS_INIT_COLOR(*(php_color->color), red, green, blue, alpha);
@@ -173,7 +176,7 @@ PHP_METHOD(colorObj, setHex)
RETURN_LONG(MS_FAILURE);
}
- php_color = (php_color_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_color = MAPSCRIPT_OBJ_P(php_color_object, zobj);
MS_INIT_COLOR(*(php_color->color), red, green, blue, alpha);
@@ -194,7 +197,7 @@ PHP_METHOD(colorObj, toHex)
php_color_object *php_color;
colorObj *color;
- php_color = (php_color_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_color = MAPSCRIPT_OBJ_P(php_color_object, zobj);
color = php_color->color;
if (color->red < 0 || color->green < 0 || color->blue < 0) {
@@ -215,7 +218,7 @@ PHP_METHOD(colorObj, toHex)
return;
}
- RETURN_STRINGL(hex, strlen(hex), 0);
+ MAPSCRIPT_RETURN_STRINGL(hex, strlen(hex), 0);
}
/* }}} */
@@ -235,7 +238,7 @@ void mapscript_create_color(colorObj *color, parent_object parent, zval *return_
{
php_color_object * php_color;
object_init_ex(return_value, mapscript_ce_color);
- php_color = (php_color_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_color = MAPSCRIPT_OBJ_P(php_color_object, return_value);
php_color->color = color;
php_color->parent = parent;
@@ -243,6 +246,55 @@ void mapscript_create_color(colorObj *color, parent_object parent, zval *return_
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_color_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_color_object *php_color;
+
+ php_color = ecalloc(1, sizeof(*php_color) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_color->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_color->zobj, ce);
+
+ php_color->zobj.handlers = &mapscript_color_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_color->parent);
+
+ return &php_color->zobj;
+}
+
+static void mapscript_color_free_object(zend_object *object)
+{
+ php_color_object *php_color;
+
+ php_color = (php_color_object *)((char *)object - XtOffsetOf(php_color_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_color->parent);
+
+ /* We don't need to free the colorObj, the mapObj will do it */
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(color)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "colorObj", color_functions);
+ mapscript_ce_color = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_color->create_object = mapscript_color_create_object;
+ mapscript_ce_color->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_color_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_color_object_handlers));
+ mapscript_color_object_handlers.free_obj = mapscript_color_free_object;
+ mapscript_color_object_handlers.offset = XtOffsetOf(php_color_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_color_object_destroy(void *object TSRMLS_DC)
{
php_color_object *php_color = (php_color_object *)object;
@@ -284,4 +336,4 @@ PHP_MINIT_FUNCTION(color)
return SUCCESS;
}
-
+#endif
diff --git a/mapscript/php/error.c b/mapscript/php/error.c
index 2e96eea27..881295ef4 100644
--- a/mapscript/php/error.c
+++ b/mapscript/php/error.c
@@ -31,7 +31,7 @@
#include "php_mapscript.h"
-#if PHP_VERSION_ID >= 50625
+#if PHP_VERSION_ID >= 50625 && PHP_VERSION_ID < 70000
#undef ZVAL_STRING
#define ZVAL_STRING(z, s, duplicate) do { \
const char *__s=(s); \
@@ -43,6 +43,9 @@
#endif
zend_class_entry *mapscript_ce_error;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_error_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(error___get_args, 0, 0, 1)
ZEND_ARG_INFO(0, property)
@@ -66,7 +69,8 @@ PHP_METHOD(errorObj, __get)
char *property;
long property_len = 0;
zval *zobj = getThis();
- php_error_object *php_error;
+ /* php_error is in PHP7 defined in php.h, so we use php_errobj instead */
+ php_error_object *php_errobj;
PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
@@ -76,12 +80,12 @@ PHP_METHOD(errorObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_error = (php_error_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_errobj = MAPSCRIPT_OBJ_P(php_error_object, zobj);
- IF_GET_LONG("code", php_error->error->code)
- else IF_GET_STRING("routine", php_error->error->routine)
- else IF_GET_STRING("message", php_error->error->message)
- else IF_GET_LONG("isreported", php_error->error->isreported)
+ IF_GET_LONG("code", php_errobj->error->code)
+ else IF_GET_STRING("routine", php_errobj->error->routine)
+ else IF_GET_STRING("message", php_errobj->error->message)
+ else IF_GET_LONG("isreported", php_errobj->error->isreported)
else {
mapscript_throw_exception("Property '%s' does not exist in this object." TSRMLS_CC, property);
}
@@ -92,8 +96,8 @@ PHP_METHOD(errorObj, __set)
char *property;
long property_len = 0;
zval *value;
- zval *zobj = getThis();
- php_error_object *php_error;
+ /* zval *zobj = getThis(); */
+ /* php_error_object *php_errobj; */
PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz",
@@ -103,7 +107,7 @@ PHP_METHOD(errorObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_error = (php_error_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ /* php_errobj = MAPSCRIPT_OBJ_P(php_error_object, zobj); */
if ( (STRING_EQUAL("code", property)) ||
(STRING_EQUAL("routine", property)) ||
@@ -120,7 +124,7 @@ PHP_METHOD(errorObj, __set)
PHP_METHOD(errorObj, next)
{
zval *zobj = getThis();
- php_error_object *php_error;
+ php_error_object *php_errobj;
errorObj *error = NULL;
PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
@@ -130,15 +134,15 @@ PHP_METHOD(errorObj, next)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_error = (php_error_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_errobj = MAPSCRIPT_OBJ_P(php_error_object, zobj);
- if (php_error->error->next == NULL)
+ if (php_errobj->error->next == NULL)
RETURN_NULL();
/* Make sure 'self' is still valid. It may have been deleted by
* msResetErrorList() */
error = msGetErrorObj();
- while(error != php_error->error) {
+ while(error != php_errobj->error) {
if (error->next == NULL) {
mapscript_throw_exception("Trying to access an errorObj that has expired." TSRMLS_CC);
return;
@@ -146,7 +150,7 @@ PHP_METHOD(errorObj, next)
error = error->next;
}
- php_error->error = php_error->error->next;
+ php_errobj->error = php_errobj->error->next;
*return_value = *zobj;
zval_copy_ctor(return_value);
INIT_PZVAL(return_value);
@@ -164,17 +168,62 @@ zend_function_entry error_functions[] = {
void mapscript_create_error(errorObj *error, zval *return_value TSRMLS_DC)
{
- php_error_object * php_error;
+ php_error_object * php_errobj;
object_init_ex(return_value, mapscript_ce_error);
- php_error = (php_error_object *)zend_object_store_get_object(return_value TSRMLS_CC);
- php_error->error = error;
+ php_errobj = MAPSCRIPT_OBJ_P(php_error_object, return_value);
+ php_errobj->error = error;
+}
+
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_error_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_error_object *php_errobj;
+
+ php_errobj = ecalloc(1, sizeof(*php_errobj) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_errobj->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_errobj->zobj, ce);
+
+ php_errobj->zobj.handlers = &mapscript_error_object_handlers;
+
+ return &php_errobj->zobj;
}
+/*
+static void mapscript_error_free_object(zend_object *object)
+{
+ php_error_object *php_errobj;
+
+ php_errobj = (php_error_object *)((char *)object - XtOffsetOf(php_error_object, zobj));
+
+ zend_object_std_dtor(object);
+}
+*/
+
+PHP_MINIT_FUNCTION(error)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "errorObj", error_functions);
+ mapscript_ce_error = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_error->create_object = mapscript_error_create_object;
+ mapscript_ce_error->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_error_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_error_object_handlers));
+ /* mapscript_error_object_handlers.free_obj = mapscript_error_free_object; // nothing to do here -> use standard handler */
+ mapscript_error_object_handlers.offset = XtOffsetOf(php_error_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_error_object_destroy(void *object TSRMLS_DC)
{
- php_error_object *php_error = (php_error_object *)object;
+ php_error_object *php_errobj = (php_error_object *)object;
- MAPSCRIPT_FREE_OBJECT(php_error);
+ MAPSCRIPT_FREE_OBJECT(php_errobj);
/* We don't need to free the errorObj */
@@ -184,11 +233,11 @@ static void mapscript_error_object_destroy(void *object TSRMLS_DC)
static zend_object_value mapscript_error_object_new(zend_class_entry *ce TSRMLS_DC)
{
zend_object_value retval;
- php_error_object *php_error;
+ php_error_object *php_errobj;
- MAPSCRIPT_ALLOC_OBJECT(php_error, php_error_object);
+ MAPSCRIPT_ALLOC_OBJECT(php_errobj, php_error_object);
- retval = mapscript_object_new(&php_error->std, ce,
+ retval = mapscript_object_new(&php_errobj->std, ce,
&mapscript_error_object_destroy TSRMLS_CC);
return retval;
@@ -207,3 +256,4 @@ PHP_MINIT_FUNCTION(error)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/grid.c b/mapscript/php/grid.c
index 977b7600d..c13f54bc3 100644
--- a/mapscript/php/grid.c
+++ b/mapscript/php/grid.c
@@ -32,6 +32,9 @@
#include "php_mapscript.h"
zend_class_entry *mapscript_ce_grid;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_grid_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(grid___construct_args, 0, 1, 1)
ZEND_ARG_OBJ_INFO(0, layer, layerObj, 0)
@@ -63,8 +66,8 @@ PHP_METHOD(gridObj, __construct)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_grid = (php_grid_object *) zend_object_store_get_object(getThis() TSRMLS_CC);
- php_layer = (php_layer_object *) zend_object_store_get_object(zlayer TSRMLS_CC);
+ php_grid = MAPSCRIPT_OBJ_P(php_grid_object, getThis());
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zlayer);
php_layer->layer->connectiontype = MS_GRATICULE;
@@ -78,17 +81,30 @@ PHP_METHOD(gridObj, __construct)
php_grid->grid = (graticuleObj *)php_layer->layer->layerinfo;
- if (php_layer->grid && (Z_TYPE_P(php_layer->grid) == IS_OBJECT)) {
- php_old_grid = (php_grid_object *) zend_object_store_get_object(php_layer->grid TSRMLS_CC);
+ if (ZVAL_NOT_UNDEF(php_layer->grid) && (MAPSCRIPT_TYPE(php_layer->grid) == IS_OBJECT)) {
+ php_old_grid = MAPSCRIPT_OBJ(php_grid_object, php_layer->grid);
php_old_grid->parent.child_ptr = NULL;
+#if PHP_VERSION_ID < 70000
zend_objects_store_del_ref(php_layer->grid TSRMLS_CC);
+#else
+/*
+ Z_SET_REFCOUNT(php_layer->grid, 0);
+ _zval_dtor_func_for_ptr(Z_COUNTED(php_layer->grid));
+ Z_UNDEF(&php_layer->grid);
+*/
+ MAPSCRIPT_DELREF(php_layer->grid);
+#endif
}
MAKE_STD_ZVAL(php_layer->grid);
MAPSCRIPT_MAKE_PARENT(zlayer, &php_layer->grid);
+#if PHP_VERSION_ID < 70000
mapscript_create_grid((graticuleObj *)(php_layer->layer->layerinfo), parent, php_layer->grid TSRMLS_CC);
-
return_value_ptr = &php_layer->grid;
+#else
+ mapscript_create_grid((graticuleObj *)(php_layer->layer->layerinfo), parent, &php_layer->grid TSRMLS_CC);
+ return_value = &php_layer->grid;
+#endif
}
/* }}} */
@@ -107,7 +123,7 @@ PHP_METHOD(gridObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_grid = (php_grid_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_grid = MAPSCRIPT_OBJ_P(php_grid_object, zobj);
IF_GET_DOUBLE("minsubdivide", php_grid->grid->minsubdivides)
else IF_GET_DOUBLE("maxsubdivide", php_grid->grid->maxsubdivides)
@@ -137,7 +153,7 @@ PHP_METHOD(gridObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_grid = (php_grid_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_grid = MAPSCRIPT_OBJ_P(php_grid_object, zobj);
IF_SET_DOUBLE("minsubdivide", php_grid->grid->minsubdivides, value)
else IF_SET_DOUBLE("maxsubdivide", php_grid->grid->maxsubdivides, value)
@@ -160,11 +176,60 @@ zend_function_entry grid_functions[] = {
}
};
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_grid_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_grid_object *php_grid;
+
+ php_grid = ecalloc(1, sizeof(*php_grid) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_grid->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_grid->zobj, ce);
+
+ php_grid->zobj.handlers = &mapscript_grid_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_grid->parent);
+
+ return &php_grid->zobj;
+}
+
+static void mapscript_grid_free_object(zend_object *object)
+{
+ php_grid_object *php_grid;
+
+ php_grid = (php_grid_object *)((char *)object - XtOffsetOf(php_grid_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_grid->parent);
+
+ /* We don't need to free the gridObj */
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(grid)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "gridObj", grid_functions);
+ mapscript_ce_grid = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_grid->create_object = mapscript_grid_create_object;
+ mapscript_ce_grid->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_grid_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_grid_object_handlers));
+ mapscript_grid_object_handlers.free_obj = mapscript_grid_free_object;
+ mapscript_grid_object_handlers.offset = XtOffsetOf(php_grid_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
void mapscript_create_grid(graticuleObj *grid, parent_object parent, zval *return_value TSRMLS_DC)
{
php_grid_object * php_grid;
object_init_ex(return_value, mapscript_ce_grid);
- php_grid = (php_grid_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_grid = MAPSCRIPT_OBJ_P(php_grid_object, return_value);
php_grid->grid = grid;
php_grid->parent = parent;
@@ -212,3 +277,4 @@ PHP_MINIT_FUNCTION(grid)
return SUCCESS;
}
+#endif
\ No newline at end of file
diff --git a/mapscript/php/hashtable.c b/mapscript/php/hashtable.c
index 44f56805f..3e6c0c783 100644
--- a/mapscript/php/hashtable.c
+++ b/mapscript/php/hashtable.c
@@ -32,6 +32,9 @@
#include "php_mapscript.h"
zend_class_entry *mapscript_ce_hashtable;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_hashtable_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(hashtable___get_args, 0, 0, 1)
ZEND_ARG_INFO(0, property)
@@ -82,7 +85,7 @@ PHP_METHOD(hashtableObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_hashtable = (php_hashtable_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_hashtable = MAPSCRIPT_OBJ_P(php_hashtable_object, zobj);
IF_GET_LONG("numitems", php_hashtable->hashtable->numitems)
else {
@@ -129,14 +132,14 @@ PHP_METHOD(hashtableObj, get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_hashtable = (php_hashtable_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_hashtable = MAPSCRIPT_OBJ_P(php_hashtable_object, zobj);
value = hashTableObj_get(php_hashtable->hashtable, key);
if (value == NULL) {
- RETURN_STRING("",1);
+ MAPSCRIPT_RETURN_STRING("",1);
}
- RETURN_STRING((char *)value, 1);
+ MAPSCRIPT_RETURN_STRING((char *)value, 1);
}
/* }}} */
@@ -158,7 +161,7 @@ PHP_METHOD(hashtableObj, set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_hashtable = (php_hashtable_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_hashtable = MAPSCRIPT_OBJ_P(php_hashtable_object, zobj);
if ((status = hashTableObj_set(php_hashtable->hashtable, key, value)) != MS_SUCCESS) {
mapscript_throw_mapserver_exception("" TSRMLS_CC);
@@ -187,7 +190,7 @@ PHP_METHOD(hashtableObj, remove)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_hashtable = (php_hashtable_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_hashtable = MAPSCRIPT_OBJ_P(php_hashtable_object, zobj);
if ((status = hashTableObj_remove(php_hashtable->hashtable, key)) != MS_SUCCESS) {
mapscript_throw_mapserver_exception("" TSRMLS_CC);
@@ -212,7 +215,7 @@ PHP_METHOD(hashtableObj, clear)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_hashtable = (php_hashtable_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_hashtable = MAPSCRIPT_OBJ_P(php_hashtable_object, zobj);
hashTableObj_clear(php_hashtable->hashtable);
}
@@ -237,14 +240,14 @@ PHP_METHOD(hashtableObj, nextKey)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_hashtable = (php_hashtable_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_hashtable = MAPSCRIPT_OBJ_P(php_hashtable_object, zobj);
value = hashTableObj_nextKey(php_hashtable->hashtable, key);
if (value == NULL)
RETURN_NULL();
- RETURN_STRING(value, 1);
+ MAPSCRIPT_RETURN_STRING(value, 1);
}
/* }}} */
@@ -265,7 +268,7 @@ void mapscript_create_hashtable(hashTableObj *hashtable, parent_object parent, z
{
php_hashtable_object * php_hashtable;
object_init_ex(return_value, mapscript_ce_hashtable);
- php_hashtable = (php_hashtable_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_hashtable = MAPSCRIPT_OBJ_P(php_hashtable_object, return_value);
php_hashtable->hashtable = hashtable;
php_hashtable->parent = parent;
@@ -273,6 +276,55 @@ void mapscript_create_hashtable(hashTableObj *hashtable, parent_object parent, z
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_hashtable_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_hashtable_object *php_hashtable;
+
+ php_hashtable = ecalloc(1, sizeof(*php_hashtable) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_hashtable->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_hashtable->zobj, ce);
+
+ php_hashtable->zobj.handlers = &mapscript_hashtable_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_hashtable->parent);
+
+ return &php_hashtable->zobj;
+}
+
+static void mapscript_hashtable_free_object(zend_object *object)
+{
+ php_hashtable_object *php_hashtable;
+
+ php_hashtable = (php_hashtable_object *)((char *)object - XtOffsetOf(php_hashtable_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_hashtable->parent);
+
+ /* We don't need to free the hashTableObj */
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(hashtable)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "hashTableObj", hashtable_functions);
+ mapscript_ce_hashtable = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_hashtable->create_object = mapscript_hashtable_create_object;
+ mapscript_ce_hashtable->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_hashtable_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_hashtable_object_handlers));
+ mapscript_hashtable_object_handlers.free_obj = mapscript_hashtable_free_object;
+ mapscript_hashtable_object_handlers.offset = XtOffsetOf(php_hashtable_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_hashtable_object_destroy(void *object TSRMLS_DC)
{
php_hashtable_object *php_hashtable = (php_hashtable_object *)object;
@@ -314,3 +366,4 @@ PHP_MINIT_FUNCTION(hashtable)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/image.c b/mapscript/php/image.c
index f284e5936..719208866 100644
--- a/mapscript/php/image.c
+++ b/mapscript/php/image.c
@@ -34,6 +34,9 @@
#include "main/php_output.h"
zend_class_entry *mapscript_ce_image;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_image_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(image___get_args, 0, 0, 1)
ZEND_ARG_INFO(0, property)
@@ -81,7 +84,7 @@ PHP_METHOD(imageObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_image = (php_image_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_image = MAPSCRIPT_OBJ_P(php_image_object, zobj);
IF_GET_LONG("width", php_image->image->width)
else IF_GET_LONG("height", php_image->image->height)
@@ -111,7 +114,7 @@ PHP_METHOD(imageObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_image = (php_image_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_image = MAPSCRIPT_OBJ_P(php_image_object, zobj);
IF_SET_STRING("imagepath", php_image->image->imagepath, value)
else IF_SET_STRING("imageurl", php_image->image->imageurl, value)
@@ -144,7 +147,7 @@ PHP_METHOD(imageObj, saveWebImage)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_image = (php_image_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_image = MAPSCRIPT_OBJ_P(php_image_object, zobj);
imageFilename = msTmpFilename(php_image->image->format->extension);
imageFile = msBuildPath(path, php_image->image->imagepath, imageFilename);
@@ -157,7 +160,7 @@ PHP_METHOD(imageObj, saveWebImage)
imageUrlFull = msBuildPath(path, php_image->image->imageurl, imageFilename);
msFree(imageFilename);
- RETURN_STRING(imageUrlFull, 1);
+ MAPSCRIPT_RETURN_STRING(imageUrlFull, 1);
}
/* }}} */
@@ -194,8 +197,8 @@ PHP_METHOD(imageObj, pasteImage)
if (ZEND_NUM_ARGS() == 3)
mapscript_report_php_error(E_WARNING, "dstX parameter given but not dstY" TSRMLS_CC);
- php_image = (php_image_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_imageSrc = (php_image_object *) zend_object_store_get_object(zimage TSRMLS_CC);
+ php_image = MAPSCRIPT_OBJ_P(php_image_object, zobj);
+ php_imageSrc = MAPSCRIPT_OBJ_P(php_image_object, zimage);
if (!MS_RENDERER_PLUGIN(php_imageSrc->image->format) ||
!MS_RENDERER_PLUGIN(php_image->image->format)) {
@@ -274,9 +277,9 @@ PHP_METHOD(imageObj, saveImage)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_image = (php_image_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_image = MAPSCRIPT_OBJ_P(php_image_object, zobj);
if (zmap)
- php_map = (php_map_object *) zend_object_store_get_object(zmap TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zmap);
if(filename_len > 0) {
if ((status = msSaveImage((zmap ? php_map->map:NULL), php_image->image, filename) != MS_SUCCESS)) {
@@ -339,10 +342,55 @@ void mapscript_create_image(imageObj *image, zval *return_value TSRMLS_DC)
{
php_image_object * php_image;
object_init_ex(return_value, mapscript_ce_image);
- php_image = (php_image_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_image = MAPSCRIPT_OBJ_P(php_image_object, return_value);
php_image->image = image;
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_image_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_image_object *php_image;
+
+ php_image = ecalloc(1, sizeof(*php_image) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_image->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_image->zobj, ce);
+
+ php_image->zobj.handlers = &mapscript_image_object_handlers;
+
+ return &php_image->zobj;
+}
+
+static void mapscript_image_free_object(zend_object *object)
+{
+ php_image_object *php_image;
+
+ php_image = (php_image_object *)((char *)object - XtOffsetOf(php_image_object, zobj));
+
+ msFreeImage(php_image->image);
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(image)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "imageObj", image_functions);
+ mapscript_ce_image = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_image->create_object = mapscript_image_create_object;
+ mapscript_ce_image->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_image_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_image_object_handlers));
+ mapscript_image_object_handlers.free_obj = mapscript_image_free_object;
+ mapscript_image_object_handlers.offset = XtOffsetOf(php_image_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_image_object_destroy(void *object TSRMLS_DC)
{
php_image_object *php_image = (php_image_object *)object;
@@ -380,3 +428,4 @@ PHP_MINIT_FUNCTION(image)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/label.c b/mapscript/php/label.c
index 9fab6ec3e..214dfb19b 100644
--- a/mapscript/php/label.c
+++ b/mapscript/php/label.c
@@ -106,7 +106,7 @@ PHP_METHOD(labelObj, __construct)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, getThis());
if ((php_label->label = labelObj_new()) == NULL) {
mapscript_throw_exception("Unable to construct labelObj." TSRMLS_CC);
@@ -130,7 +130,7 @@ PHP_METHOD(labelObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
IF_GET_STRING("font", php_label->label->font)
else IF_GET_STRING("encoding", php_label->label->encoding)
@@ -187,7 +187,7 @@ PHP_METHOD(labelObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
IF_SET_STRING("font", php_label->label->font, value)
else IF_SET_STRING("encoding", php_label->label->encoding, value)
@@ -248,7 +248,7 @@ PHP_METHOD(labelObj, updateFromString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
if ((status = labelObj_updateFromString(php_label->label, snippet)) != MS_SUCCESS) {
mapscript_throw_mapserver_exception("" TSRMLS_CC);
@@ -274,14 +274,14 @@ PHP_METHOD(labelObj, convertToString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
value = labelObj_convertToString(php_label->label);
if (value == NULL)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -304,7 +304,7 @@ PHP_METHOD(labelObj, setBinding)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
if (bindingId < 0 || bindingId > MS_LABEL_BINDING_LENGTH) {
mapscript_throw_exception("Invalid binding id." TSRMLS_CC);
@@ -347,7 +347,7 @@ PHP_METHOD(labelObj, getBinding)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
if (bindingId < 0 || bindingId > MS_LABEL_BINDING_LENGTH) {
mapscript_throw_exception("Invalid binding id." TSRMLS_CC);
@@ -355,7 +355,7 @@ PHP_METHOD(labelObj, getBinding)
}
if( (value = php_label->label->bindings[bindingId].item) != NULL) {
- RETURN_STRING(value, 1);
+ MAPSCRIPT_RETURN_STRING(value, 1);
}
RETURN_NULL();
@@ -379,7 +379,7 @@ PHP_METHOD(labelObj, removeBinding)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
if (bindingId < 0 || bindingId > MS_LABEL_BINDING_LENGTH) {
mapscript_throw_exception("Invalid binding id." TSRMLS_CC);
@@ -417,7 +417,7 @@ PHP_METHOD(labelObj, getStyle)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
if (index < 0 || index >= php_label->label->numstyles) {
mapscript_throw_exception("Invalid style index." TSRMLS_CC);
@@ -449,8 +449,8 @@ PHP_METHOD(labelObj, insertStyle)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_style = (php_style_object *) zend_object_store_get_object(zstyle TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
+ php_style = MAPSCRIPT_OBJ_P(php_style_object, zstyle);
RETURN_LONG(msInsertLabelStyle(php_label->label, php_style->style, index));
}
@@ -474,7 +474,7 @@ PHP_METHOD(labelObj, removeStyle)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
style = msRemoveLabelStyle(php_label->label, index);
@@ -500,7 +500,7 @@ PHP_METHOD(labelObj, moveStyleUp)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
status = labelObj_moveStyleUp(php_label->label, index);
@@ -524,7 +524,7 @@ PHP_METHOD(labelObj, moveStyleDown)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
status = labelObj_moveStyleDown(php_label->label, index);
@@ -548,7 +548,7 @@ PHP_METHOD(labelObj, deleteStyle)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
status = labelObj_deleteStyle(php_label->label, index);
@@ -570,7 +570,7 @@ PHP_METHOD(labelObj, free)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
MAPSCRIPT_DELREF(php_label->color);
MAPSCRIPT_DELREF(php_label->outlinecolor);
@@ -596,7 +596,7 @@ PHP_METHOD(labelObj, setExpression)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
status = labelObj_setExpression(php_label->label, expression);
@@ -625,14 +625,14 @@ PHP_METHOD(labelObj, getExpressionString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
value = labelObj_getExpressionString(php_label->label);
if (value == NULL)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -656,8 +656,8 @@ PHP_METHOD(labelObj, setText)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_layer = (php_layer_object *) zend_object_store_get_object(php_label->parent.val TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
+ php_layer = MAPSCRIPT_OBJ(php_layer_object, php_label->parent.val);
status = labelObj_setText(php_label->label, php_layer->layer, text);
@@ -686,14 +686,14 @@ PHP_METHOD(labelObj, getTextString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zobj);
value = labelObj_getTextString(php_label->label);
if (value == NULL)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -728,16 +728,93 @@ void mapscript_create_label(labelObj *label, parent_object parent, zval *return_
{
php_label_object * php_label;
object_init_ex(return_value, mapscript_ce_label);
- php_label = (php_label_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, return_value);
php_label->label = label;
- if (parent.val)
+ if(ZVAL_NOT_UNDEF(parent.val))
php_label->is_ref = 1;
php_label->parent = parent;
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_label_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_label_object *php_label;
+
+ php_label = ecalloc(1, sizeof(*php_label) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_label->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_label->zobj, ce);
+
+ php_label->zobj.handlers = &mapscript_label_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_label->parent);
+ php_label->is_ref = 0;
+ ZVAL_UNDEF(&php_label->color);
+ ZVAL_UNDEF(&php_label->outlinecolor);
+ ZVAL_UNDEF(&php_label->shadowcolor);
+ ZVAL_UNDEF(&php_label->leader);
+
+
+ return &php_label->zobj;
+}
+
+static void mapscript_label_free_object(zend_object *object)
+{
+ php_label_object *php_label;
+
+ php_label = (php_label_object *)((char *)object - XtOffsetOf(php_label_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_label->parent);
+ MAPSCRIPT_DELREF(php_label->color);
+ MAPSCRIPT_DELREF(php_label->outlinecolor);
+ MAPSCRIPT_DELREF(php_label->shadowcolor);
+ MAPSCRIPT_DELREF(php_label->leader);
+
+ if (php_label->label && !php_label->is_ref) {
+ labelObj_destroy(php_label->label);
+ }
+
+ zend_object_std_dtor(object);
+}
+
+static zend_object* mapscript_label_clone_object(zval *zobj)
+{
+ php_label_object *php_label_old, *php_label_new;
+ zend_object* zobj_new;
+
+ php_label_old = MAPSCRIPT_OBJ_P(php_label_object, zobj);
+
+ zobj_new = mapscript_label_create_object(mapscript_ce_label);
+ php_label_new = (php_label_object *)((char *)zobj_new - XtOffsetOf(php_label_object, zobj));
+
+ php_label_new->label = labelObj_clone(php_label_old->label);
+
+ return zobj_new;
+}
+
+PHP_MINIT_FUNCTION(label)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "labelObj", label_functions);
+ mapscript_ce_label = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_label->create_object = mapscript_label_create_object;
+ mapscript_ce_label->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_label_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_label_object_handlers));
+ mapscript_label_object_handlers.free_obj = mapscript_label_free_object;
+ mapscript_label_object_handlers.clone_obj = mapscript_label_clone_object;
+ mapscript_label_object_handlers.offset = XtOffsetOf(php_label_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_label_object_destroy(void *object TSRMLS_DC)
{
php_label_object *php_label = (php_label_object *)object;
@@ -791,7 +868,7 @@ static zend_object_value mapscript_label_object_clone(zval *zobj TSRMLS_DC)
php_label_object *php_label_old, *php_label_new;
zend_object_value new_ov;
- php_label_old = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_label_old = MAPSCRIPT_OBJ_P(php_label_object, zobj);
new_ov = mapscript_label_object_new_ex(mapscript_ce_label, &php_label_new TSRMLS_CC);
zend_objects_clone_members(&php_label_new->std, new_ov, &php_label_old->std, Z_OBJ_HANDLE_P(zobj) TSRMLS_CC);
@@ -817,4 +894,4 @@ PHP_MINIT_FUNCTION(label)
return SUCCESS;
}
-
+#endif
diff --git a/mapscript/php/labelcache.c b/mapscript/php/labelcache.c
index 43f6ef503..cd04b3cdf 100644
--- a/mapscript/php/labelcache.c
+++ b/mapscript/php/labelcache.c
@@ -32,6 +32,9 @@
#include "php_mapscript.h"
zend_class_entry *mapscript_ce_labelcache;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_labelcache_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(labelcache___get_args, 0, 0, 1)
ZEND_ARG_INFO(0, property)
@@ -75,7 +78,7 @@ PHP_METHOD(labelCacheObj, freeCache)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_labelcache = (php_labelcache_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_labelcache = MAPSCRIPT_OBJ_P(php_labelcache_object, zobj);
labelCacheObj_freeCache(php_labelcache->labelcache);
@@ -96,13 +99,61 @@ void mapscript_create_labelcache(labelCacheObj *labelcache, parent_object parent
{
php_labelcache_object * php_labelcache;
object_init_ex(return_value, mapscript_ce_labelcache);
- php_labelcache = (php_labelcache_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_labelcache = MAPSCRIPT_OBJ_P(php_labelcache_object, return_value);
php_labelcache->labelcache = labelcache;
php_labelcache->parent = parent;
MAPSCRIPT_ADDREF(parent.val);
}
+
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_labelcache_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_labelcache_object *php_labelcache;
+
+ php_labelcache = ecalloc(1, sizeof(*php_labelcache) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_labelcache->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_labelcache->zobj, ce);
+
+ php_labelcache->zobj.handlers = &mapscript_labelcache_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_labelcache->parent);
+
+ return &php_labelcache->zobj;
+}
+
+static void mapscript_labelcache_free_object(zend_object *object)
+{
+ php_labelcache_object *php_labelcache;
+
+ php_labelcache = (php_labelcache_object *)((char *)object - XtOffsetOf(php_labelcache_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_labelcache->parent);
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(labelcache)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "labelcacheObj", labelcache_functions);
+ mapscript_ce_labelcache = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_labelcache->create_object = mapscript_labelcache_create_object;
+ mapscript_ce_labelcache->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_labelcache_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_labelcache_object_handlers));
+ mapscript_labelcache_object_handlers.free_obj = mapscript_labelcache_free_object;
+ mapscript_labelcache_object_handlers.offset = XtOffsetOf(php_labelcache_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_labelcache_object_destroy(void *object TSRMLS_DC)
{
php_labelcache_object *php_labelcache = (php_labelcache_object *)object;
@@ -144,3 +195,4 @@ PHP_MINIT_FUNCTION(labelcache)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/labelcachemember.c b/mapscript/php/labelcachemember.c
index e34010673..6241b9528 100644
--- a/mapscript/php/labelcachemember.c
+++ b/mapscript/php/labelcachemember.c
@@ -29,10 +29,12 @@
* DEALINGS IN THE SOFTWARE.
**********************************************************************/
-#ifdef what_the_fxxx_is_this_for
#include "php_mapscript.h"
zend_class_entry *mapscript_ce_labelcachemember;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_labelcachemember_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(labelcachemember___get_args, 0, 0, 1)
ZEND_ARG_INFO(0, property)
@@ -66,21 +68,21 @@ PHP_METHOD(labelCacheMemberObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_labelcachemember = (php_labelcachemember_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_labelcachemember = MAPSCRIPT_OBJ_P(php_labelcachemember_object, zobj);
IF_GET_LONG("classindex", php_labelcachemember->labelcachemember->classindex)
- else IF_GET_LONG("featuresize", php_labelcachemember->labelcachemember->featuresize)
+ /* else IF_GET_LONG("featuresize", php_labelcachemember->labelcachemember->featuresize) */
else IF_GET_LONG("layerindex", php_labelcachemember->labelcachemember->layerindex)
- else IF_GET_LONG("numstyles", php_labelcachemember->labelcachemember->numstyles)
- else IF_GET_LONG("numlabels", php_labelcachemember->labelcachemember->numlabels)
+ /* else IF_GET_LONG("numstyles", php_labelcachemember->labelcachemember->numstyles) */
+ /* else IF_GET_LONG("numlabels", php_labelcachemember->labelcachemember->numlabels) */
/* else IF_GET_LONG("shapeindex", php_labelcachemember->labelcachemember->shapeindex) */
else IF_GET_LONG("status", php_labelcachemember->labelcachemember->status)
else IF_GET_LONG("markerid", php_labelcachemember->labelcachemember->markerid)
/* else IF_GET_LONG("tileindex", php_labelcachemember->labelcachemember->tileindex) */
else IF_GET_OBJECT("point", mapscript_ce_point, php_labelcachemember->point, &php_labelcachemember->labelcachemember->point)
- else IF_GET_OBJECT("labels", mapscript_ce_label, php_labelcachemember->labels, &php_labelcachemember->labelcachemember->labels)
- else IF_GET_OBJECT("styles", mapscript_ce_style, php_labelcachemember->styles, php_labelcachemember->labelcachemember->styles)
- else IF_GET_OBJECT("poly", mapscript_ce_shape, php_labelcachemember->poly, php_labelcachemember->labelcachemember->poly)
+ /* else IF_GET_OBJECT("labels", mapscript_ce_label, php_labelcachemember->labels, &php_labelcachemember->labelcachemember->labels) */
+ /* else IF_GET_OBJECT("styles", mapscript_ce_style, php_labelcachemember->styles, php_labelcachemember->labelcachemember->styles) */
+ /* else IF_GET_OBJECT("poly", mapscript_ce_shape, php_labelcachemember->poly, php_labelcachemember->labelcachemember->poly) */
else {
mapscript_throw_exception("Property '%s' does not exist in this object." TSRMLS_CC, property);
}
@@ -91,8 +93,8 @@ PHP_METHOD(labelCacheMemberObj, __set)
char *property;
long property_len = 0;
zval *value;
- zval *zobj = getThis();
- php_labelcachemember_object *php_labelcachemember;
+ /* zval *zobj = getThis(); */
+ /* php_labelcachemember_object *php_labelcachemember; */
PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz",
@@ -102,20 +104,20 @@ PHP_METHOD(labelCacheMemberObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_labelcachemember = (php_labelcachemember_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ /* php_labelcachemember = MAPSCRIPT_OBJ_P(php_labelcachemember_object, zobj); */
if ( (STRING_EQUAL("classindex", property)) ||
- (STRING_EQUAL("featuresize", property)) ||
+ /* (STRING_EQUAL("featuresize", property)) || */
(STRING_EQUAL("layerindex", property)) ||
- (STRING_EQUAL("numstyles", property)) ||
- (STRING_EQUAL("numlabels", property)) ||
- (STRING_EQUAL("shapeindex", property)) ||
+ /* (STRING_EQUAL("numstyles", property)) || */
+ /* (STRING_EQUAL("numlabels", property)) || */
+ /* (STRING_EQUAL("shapeindex", property)) || */
(STRING_EQUAL("status", property)) ||
(STRING_EQUAL("markerid", property)) ||
- (STRING_EQUAL("tileindex", property)) ||
- (STRING_EQUAL("labels", property)) ||
- (STRING_EQUAL("styles", property)) ||
- (STRING_EQUAL("poly", property)) ||
+ /* (STRING_EQUAL("tileindex", property)) || */
+ /* (STRING_EQUAL("labels", property)) || */
+ /* (STRING_EQUAL("styles", property)) || */
+ /* (STRING_EQUAL("poly", property)) || */
(STRING_EQUAL("point", property))) {
mapscript_throw_exception("Property '%s' is read-only and cannot be set." TSRMLS_CC, property);
} else {
@@ -137,7 +139,7 @@ PHP_METHOD(labelCacheMemberObj, free)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_labelcachemember = (php_labelcachemember_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_labelcachemember = MAPSCRIPT_OBJ_P(php_labelcachemember_object, zobj);
MAPSCRIPT_DELREF(php_labelcachemember->point);
MAPSCRIPT_DELREF(php_labelcachemember->labels);
@@ -162,7 +164,7 @@ void mapscript_create_labelcachemember(labelCacheMemberObj *labelcachemember,
{
php_labelcachemember_object * php_labelcachemember;
object_init_ex(return_value, mapscript_ce_labelcachemember);
- php_labelcachemember = (php_labelcachemember_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_labelcachemember = MAPSCRIPT_OBJ_P(php_labelcachemember_object, return_value);
php_labelcachemember->labelcachemember = labelcachemember;
php_labelcachemember->parent = parent;
@@ -170,6 +172,65 @@ void mapscript_create_labelcachemember(labelCacheMemberObj *labelcachemember,
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_labelcachemember_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_labelcachemember_object *php_labelcachemember;
+
+ php_labelcachemember = ecalloc(1, sizeof(*php_labelcachemember) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_labelcachemember->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_labelcachemember->zobj, ce);
+
+ php_labelcachemember->zobj.handlers = &mapscript_labelcachemember_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_labelcachemember->parent);
+ ZVAL_UNDEF(&php_labelcachemember->point);
+ ZVAL_UNDEF(&php_labelcachemember->labels);
+ ZVAL_UNDEF(&php_labelcachemember->styles);
+ ZVAL_UNDEF(&php_labelcachemember->poly);
+
+
+ return &php_labelcachemember->zobj;
+}
+
+static void mapscript_labelcachemember_free_object(zend_object *object)
+{
+ php_labelcachemember_object *php_labelcachemember;
+
+ php_labelcachemember = (php_labelcachemember_object *)((char *)object - XtOffsetOf(php_labelcachemember_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_labelcachemember->parent);
+ MAPSCRIPT_DELREF(php_labelcachemember->point);
+ MAPSCRIPT_DELREF(php_labelcachemember->labels);
+ MAPSCRIPT_DELREF(php_labelcachemember->styles);
+ MAPSCRIPT_DELREF(php_labelcachemember->poly);
+
+ /* We don't need to free the labelCacheMemberObj, the mapObj will do it */
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(labelcachemember)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "labelCacheMemberObj", labelcachemember_functions);
+ mapscript_ce_labelcachemember = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_labelcachemember->create_object = mapscript_labelcachemember_create_object;
+ mapscript_ce_labelcachemember->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_labelcachemember_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_labelcachemember_object_handlers));
+ mapscript_labelcachemember_object_handlers.free_obj = mapscript_labelcachemember_free_object;
+ mapscript_labelcachemember_object_handlers.offset = XtOffsetOf(php_labelcachemember_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
+
static void mapscript_labelcachemember_object_destroy(void *object TSRMLS_DC)
{
php_labelcachemember_object *php_labelcachemember = (php_labelcachemember_object *)object;
@@ -220,4 +281,3 @@ PHP_MINIT_FUNCTION(labelcachemember)
return SUCCESS;
}
#endif
-
diff --git a/mapscript/php/labelleader.c b/mapscript/php/labelleader.c
index 343a531e8..edf4d113a 100644
--- a/mapscript/php/labelleader.c
+++ b/mapscript/php/labelleader.c
@@ -30,6 +30,9 @@
#include "php_mapscript.h"
zend_class_entry *mapscript_ce_labelleader;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_labelleader_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(labelleader___get_args, 0, 0, 1)
ZEND_ARG_INFO(0, property)
@@ -63,7 +66,7 @@ PHP_METHOD(labelLeaderObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_labelleader = (php_labelleader_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_labelleader = MAPSCRIPT_OBJ_P(php_labelleader_object, zobj);
IF_GET_LONG("maxdistance", php_labelleader->labelleader->maxdistance)
else IF_GET_LONG("gridstep", php_labelleader->labelleader->gridstep)
@@ -106,13 +109,63 @@ void mapscript_create_labelleader(labelLeaderObj *labelleader, parent_object par
{
php_labelleader_object * php_labelleader;
object_init_ex(return_value, mapscript_ce_labelleader);
- php_labelleader = (php_labelleader_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_labelleader = MAPSCRIPT_OBJ_P(php_labelleader_object, return_value);
php_labelleader->labelleader = labelleader;
php_labelleader->parent = parent;
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_labelleader_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_labelleader_object *php_labelleader;
+
+ php_labelleader = ecalloc(1, sizeof(*php_labelleader) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_labelleader->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_labelleader->zobj, ce);
+
+ php_labelleader->zobj.handlers = &mapscript_labelleader_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_labelleader->parent);
+
+ return &php_labelleader->zobj;
+}
+
+static void mapscript_labelleader_free_object(zend_object *object)
+{
+ php_labelleader_object *php_labelleader;
+
+ php_labelleader = (php_labelleader_object *)((char *)object - XtOffsetOf(php_labelleader_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_labelleader->parent);
+
+ /* We don't need to free the labelLeaderObj */
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(labelleader)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "labelLeaderObj", labelleader_functions);
+ mapscript_ce_labelleader = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_labelleader->create_object = mapscript_labelleader_create_object;
+ mapscript_ce_labelleader->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_labelleader_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_labelleader_object_handlers));
+ mapscript_labelleader_object_handlers.free_obj = mapscript_labelleader_free_object;
+ mapscript_labelleader_object_handlers.offset = XtOffsetOf(php_labelleader_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
+
static void mapscript_labelleader_object_destroy(void *object TSRMLS_DC)
{
php_labelleader_object *php_labelleader = (php_labelleader_object *)object;
@@ -154,3 +207,4 @@ PHP_MINIT_FUNCTION(labelleader)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/layer.c b/mapscript/php/layer.c
index 8567bc8e2..09c961173 100644
--- a/mapscript/php/layer.c
+++ b/mapscript/php/layer.c
@@ -220,10 +220,10 @@ PHP_METHOD(layerObj, __construct)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *)zend_object_store_get_object(zobj TSRMLS_CC);
- php_map = (php_map_object *)zend_object_store_get_object(zmap TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zmap);
if (zlayer)
- php_layer2 = (php_layer_object *)zend_object_store_get_object(zlayer TSRMLS_CC);
+ php_layer2 = MAPSCRIPT_OBJ_P(php_layer_object, zlayer);
if ((layer = layerObj_new(php_map->map)) == NULL) {
mapscript_throw_mapserver_exception("" TSRMLS_CC);
@@ -235,7 +235,7 @@ PHP_METHOD(layerObj, __construct)
MAPSCRIPT_MAKE_PARENT(zmap, NULL);
php_layer->parent = parent;
- MAPSCRIPT_ADDREF(zmap);
+ MAPSCRIPT_ADDREF_P(zmap);
/* if a layer is passed as argument, copy the layer into
the new one */
@@ -248,7 +248,11 @@ PHP_METHOD(layerObj, __construct)
if (layer->connectiontype != MS_GRATICULE || layer->layerinfo == NULL) {
MAKE_STD_ZVAL(php_layer->grid);
+#if PHP_VERSION_ID < 70000
ZVAL_NULL(php_layer->grid);
+#else
+ ZVAL_NULL(&php_layer->grid);
+#endif
}
}
/* }}} */
@@ -268,7 +272,7 @@ PHP_METHOD(layerObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
IF_GET_LONG("numclasses", php_layer->layer->numclasses)
else IF_GET_STRING("encoding", php_layer->layer->encoding)
@@ -345,7 +349,7 @@ PHP_METHOD(layerObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
/* special case for "template" which we want to set to NULL and not an empty string */
if(Z_TYPE_P(value)==IS_NULL && !strcmp(property,"template")) {
@@ -433,15 +437,15 @@ PHP_METHOD(layerObj, draw)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_image = (php_image_object *) zend_object_store_get_object(zimage TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
+ php_image = MAPSCRIPT_OBJ_P(php_image_object, zimage);
- if (!php_layer->parent.val) {
+ if (ZVAL_IS_UNDEF(php_layer->parent.val)) {
mapscript_throw_exception("No map object associated with this layer object." TSRMLS_CC);
return;
}
- php_map = (php_map_object *) zend_object_store_get_object(php_layer->parent.val TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ(php_map_object, php_layer->parent.val);
if ((status = layerObj_draw(php_layer->layer, php_map->map, php_image->image)) != MS_SUCCESS)
mapscript_report_mapserver_error(E_WARNING TSRMLS_CC);
@@ -469,15 +473,15 @@ PHP_METHOD(layerObj, drawQuery)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_image = (php_image_object *) zend_object_store_get_object(zimage TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
+ php_image = MAPSCRIPT_OBJ_P(php_image_object, zimage);
- if (!php_layer->parent.val) {
+ if (ZVAL_IS_UNDEF(php_layer->parent.val)) {
mapscript_throw_exception("No map object associated with this layer object." TSRMLS_CC);
return;
}
- php_map = (php_map_object *) zend_object_store_get_object(php_layer->parent.val TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ(php_map_object, php_layer->parent.val);
if ((status = layerObj_drawQuery(php_layer->layer, php_map->map, php_image->image)) != MS_SUCCESS)
mapscript_report_mapserver_error(E_WARNING TSRMLS_CC);
@@ -508,15 +512,15 @@ PHP_METHOD(layerObj, queryByPoint)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_point = (php_point_object *) zend_object_store_get_object(zpoint TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, zpoint);
- if (!php_layer->parent.val) {
+ if (ZVAL_IS_UNDEF(php_layer->parent.val)) {
mapscript_throw_exception("No map object associated with this layer object." TSRMLS_CC);
return;
}
- php_map = (php_map_object *) zend_object_store_get_object(php_layer->parent.val TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ(php_map_object, php_layer->parent.val);
if ((status = layerObj_queryByPoint(php_layer->layer, php_map->map, php_point->point,
mode, buffer)) != MS_SUCCESS)
@@ -545,15 +549,15 @@ PHP_METHOD(layerObj, queryByRect)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_rect = (php_rect_object *) zend_object_store_get_object(zrect TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
+ php_rect = MAPSCRIPT_OBJ_P(php_rect_object, zrect);
- if (!php_layer->parent.val) {
+ if (ZVAL_IS_UNDEF(php_layer->parent.val)) {
mapscript_throw_exception("No map object associated with this layer object." TSRMLS_CC);
return;
}
- php_map = (php_map_object *) zend_object_store_get_object(php_layer->parent.val TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ(php_map_object, php_layer->parent.val);
if ((status = layerObj_queryByRect(php_layer->layer, php_map->map, *(php_rect->rect))) != MS_SUCCESS)
mapscript_report_mapserver_error(E_WARNING TSRMLS_CC);
@@ -581,15 +585,15 @@ PHP_METHOD(layerObj, queryByShape)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
- if (!php_layer->parent.val) {
+ if (ZVAL_IS_UNDEF(php_layer->parent.val)) {
mapscript_throw_exception("No map object associated with this layer object." TSRMLS_CC);
return;
}
- php_map = (php_map_object *) zend_object_store_get_object(php_layer->parent.val TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ(php_map_object, php_layer->parent.val);
if ((status = layerObj_queryByShape(php_layer->layer, php_map->map, php_shape->shape)) != MS_SUCCESS)
mapscript_report_mapserver_error(E_WARNING TSRMLS_CC);
@@ -616,14 +620,14 @@ PHP_METHOD(layerObj, queryByFeatures)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
- if (!php_layer->parent.val) {
+ if (ZVAL_IS_UNDEF(php_layer->parent.val)) {
mapscript_throw_exception("No map object associated with this layer object." TSRMLS_CC);
return;
}
- php_map = (php_map_object *) zend_object_store_get_object(php_layer->parent.val TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ(php_map_object, php_layer->parent.val);
if ((status = layerObj_queryByFeatures(php_layer->layer, php_map->map, slayer)) != MS_SUCCESS)
mapscript_report_mapserver_error(E_WARNING TSRMLS_CC);
@@ -656,14 +660,14 @@ PHP_METHOD(layerObj, queryByAttributes)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
- if (!php_layer->parent.val) {
+ if (ZVAL_IS_UNDEF(php_layer->parent.val)) {
mapscript_throw_exception("No map object associated with this layer object." TSRMLS_CC);
return;
}
- php_map = (php_map_object *) zend_object_store_get_object(php_layer->parent.val TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ(php_map_object, php_layer->parent.val);
if ((status = layerObj_queryByAttributes(php_layer->layer, php_map->map,
item, string, mode)) != MS_SUCCESS)
@@ -692,14 +696,14 @@ PHP_METHOD(layerObj, queryByFilter)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
- if (!php_layer->parent.val) {
+ if (ZVAL_IS_UNDEF(php_layer->parent.val)) {
mapscript_throw_exception("No map object associated with this layer object." TSRMLS_CC);
return;
}
- php_map = (php_map_object *) zend_object_store_get_object(php_layer->parent.val TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ(php_map_object, php_layer->parent.val);
if ((status = layerObj_queryByFilter(php_layer->layer, php_map->map,
string)) != MS_SUCCESS)
@@ -728,14 +732,14 @@ PHP_METHOD(layerObj, queryByIndex)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
- if (!php_layer->parent.val) {
+ if (ZVAL_IS_UNDEF(php_layer->parent.val)) {
mapscript_throw_exception("No map object associated with this layer object." TSRMLS_CC);
return;
}
- php_map = (php_map_object *) zend_object_store_get_object(php_layer->parent.val TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ(php_map_object, php_layer->parent.val);
if ((status = layerObj_queryByIndex(php_layer->layer, php_map->map,
tileindex, shapeindex, addtoquery)) != MS_SUCCESS)
@@ -763,7 +767,7 @@ PHP_METHOD(layerObj, updateFromString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
if ((status = layerObj_updateFromString(php_layer->layer, snippet)) != MS_SUCCESS) {
mapscript_throw_mapserver_exception("" TSRMLS_CC);
@@ -789,14 +793,14 @@ PHP_METHOD(layerObj, convertToString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
value = layerObj_convertToString(php_layer->layer);
if (value == NULL)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -819,7 +823,7 @@ PHP_METHOD(layerObj, getClass)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
if ((class = layerObj_getClass(php_layer->layer, index)) == NULL) {
mapscript_throw_exception("Invalid class index." TSRMLS_CC);
@@ -837,7 +841,8 @@ PHP_METHOD(layerObj, getClass)
PHP_METHOD(layerObj, getClassIndex)
{
zval *zobj = getThis();
- zval *zshape, **ppzval, *zclassgroup = NULL;
+ zval *zshape, *zclassgroup = NULL;
+ MAPSCRIPT_ZVAL_P ppzval;
int numElements, *classGroups = NULL;
int retval = -1, i = 0;
long numClasses = 0;
@@ -856,15 +861,15 @@ PHP_METHOD(layerObj, getClassIndex)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
- if (!php_layer->parent.val) {
+ if (ZVAL_IS_UNDEF(php_layer->parent.val)) {
mapscript_throw_exception("No map object associated with this layer object." TSRMLS_CC);
return;
}
- php_map = (php_map_object *) zend_object_store_get_object(php_layer->parent.val TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ(php_map_object, php_layer->parent.val);
if (zclassgroup) {
classgroup_hash = Z_ARRVAL_P(zclassgroup);
@@ -874,7 +879,11 @@ PHP_METHOD(layerObj, getClassIndex)
for(zend_hash_internal_pointer_reset(classgroup_hash);
zend_hash_has_more_elements(classgroup_hash) == SUCCESS;
zend_hash_move_forward(classgroup_hash), ++i) {
+#if PHP_VERSION_ID < 70000
zend_hash_get_current_data(classgroup_hash, (void **)&ppzval);
+#else
+ ppzval = zend_hash_get_current_data(classgroup_hash);
+#endif
classGroups[i] = Z_LVAL_PP(ppzval);
}
}
@@ -907,7 +916,7 @@ PHP_METHOD(layerObj, setFilter)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
if ((status = layerObj_setFilter(php_layer->layer, expression)) != MS_SUCCESS) {
mapscript_throw_mapserver_exception("" TSRMLS_CC);
@@ -933,14 +942,14 @@ PHP_METHOD(layerObj, getFilterString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
value = layerObj_getFilter(php_layer->layer);
if (value == NULL) {
RETURN_NULL();
}
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -964,16 +973,16 @@ PHP_METHOD(layerObj, setProjection)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- if (php_layer->projection)
- php_projection = (php_projection_object *) zend_object_store_get_object(php_layer->projection TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
+ if (ZVAL_NOT_UNDEF(php_layer->projection))
+ php_projection = MAPSCRIPT_OBJ(php_projection_object, php_layer->projection);
if ((status = layerObj_setProjection(php_layer->layer, projection)) != MS_SUCCESS) {
mapscript_report_php_error(E_WARNING, "setProjection failed" TSRMLS_CC);
RETURN_LONG(status);
}
- if (php_layer->projection)
+ if (ZVAL_NOT_UNDEF(php_layer->projection))
php_projection->projection = &(php_layer->layer->projection);
RETURN_LONG(status);
@@ -995,14 +1004,14 @@ PHP_METHOD(layerObj, getProjection)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
projection = layerObj_getProjection(php_layer->layer);
if (projection == NULL) {
RETURN_NULL();
}
- RETVAL_STRING(projection, 1);
+ MAPSCRIPT_RETVAL_STRING(projection, 1);
free(projection);
}
/* }}} */
@@ -1026,16 +1035,16 @@ PHP_METHOD(layerObj, setWKTProjection)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- if (php_layer->projection)
- php_projection = (php_projection_object *) zend_object_store_get_object(php_layer->projection TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
+ if (ZVAL_NOT_UNDEF(php_layer->projection))
+ php_projection = MAPSCRIPT_OBJ(php_projection_object, php_layer->projection);
if ((status = layerObj_setWKTProjection(php_layer->layer, projection)) != MS_SUCCESS) {
mapscript_throw_mapserver_exception("" TSRMLS_CC);
return;
}
- if (php_layer->projection)
+ if (ZVAL_NOT_UNDEF(php_layer->projection))
php_projection->projection = &(php_layer->layer->projection);
RETURN_LONG(status);
@@ -1056,7 +1065,7 @@ PHP_METHOD(layerObj, getNumResults)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
if (!php_layer->layer->resultcache)
@@ -1081,7 +1090,7 @@ PHP_METHOD(layerObj, getResultsBounds)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
if (!php_layer->layer->resultcache)
RETURN_NULL();
@@ -1111,7 +1120,7 @@ PHP_METHOD(layerObj, getResult)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
if ((result = layerObj_getResult(php_layer->layer, index)) == NULL) {
mapscript_throw_exception("Invalid result index." TSRMLS_CC);
@@ -1140,7 +1149,7 @@ PHP_METHOD(layerObj, open)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
status = layerObj_open(php_layer->layer);
@@ -1182,8 +1191,8 @@ PHP_METHOD(layerObj, whichShapes)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_rect = (php_rect_object *) zend_object_store_get_object(zrect TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
+ php_rect = MAPSCRIPT_OBJ_P(php_rect_object, zrect);
status = layerObj_whichShapes(php_layer->layer, php_rect->rect);
@@ -1207,7 +1216,7 @@ PHP_METHOD(layerObj, nextShape)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
shape = layerObj_nextShape(php_layer->layer);
@@ -1234,7 +1243,7 @@ PHP_METHOD(layerObj, close)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
layerObj_close(php_layer->layer);
}
@@ -1256,7 +1265,7 @@ PHP_METHOD(layerObj, getExtent)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
/* Create a new rectObj to hold the result */
if ((rect = rectObj_new()) == NULL) {
@@ -1290,7 +1299,7 @@ PHP_METHOD(layerObj, setExtent)
return;
}
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
if (minx > maxx || miny > maxy) {
mapscript_throw_mapserver_exception("Invalid min/max values" TSRMLS_CC);
@@ -1320,8 +1329,8 @@ PHP_METHOD(layerObj, addFeature)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
status = layerObj_addFeature(php_layer->layer, php_shape->shape);
@@ -1337,7 +1346,7 @@ PHP_METHOD(layerObj, getMetaData)
zval *zname;
zval *zobj = getThis();
php_layer_object *php_layer;
- zval *retval;
+ MAPSCRIPT_ZVAL retval;
PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z",
@@ -1347,12 +1356,16 @@ PHP_METHOD(layerObj, getMetaData)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
CHECK_OBJECT(mapscript_ce_hashtable, php_layer->metadata, &php_layer->layer->metadata);
MAPSCRIPT_CALL_METHOD_1(php_layer->metadata, "get", retval, zname);
+#if PHP_VERSION_ID < 70000
RETURN_STRING(Z_STRVAL_P(retval),1);
+#else
+ RETURN_STRING(Z_STRVAL(retval))
+#endif
}
/* }}} */
@@ -1363,7 +1376,7 @@ PHP_METHOD(layerObj, setMetaData)
zval *zname, *zvalue;
zval *zobj = getThis();
php_layer_object *php_layer;
- zval *retval;
+ MAPSCRIPT_ZVAL retval;
PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz",
@@ -1373,12 +1386,16 @@ PHP_METHOD(layerObj, setMetaData)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
CHECK_OBJECT(mapscript_ce_hashtable, php_layer->metadata, &php_layer->layer->metadata);
MAPSCRIPT_CALL_METHOD_2(php_layer->metadata, "set", retval, zname, zvalue);
+#if PHP_VERSION_ID < 70000
RETURN_LONG(Z_LVAL_P(retval));
+#else
+ RETURN_LONG(Z_LVAL(retval));
+#endif
}
/* }}} */
@@ -1389,7 +1406,7 @@ PHP_METHOD(layerObj, removeMetaData)
zval *zname;
zval *zobj = getThis();
php_layer_object *php_layer;
- zval *retval;
+ MAPSCRIPT_ZVAL retval;
PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z",
@@ -1399,12 +1416,16 @@ PHP_METHOD(layerObj, removeMetaData)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
CHECK_OBJECT(mapscript_ce_hashtable, php_layer->metadata, &php_layer->layer->metadata);
MAPSCRIPT_CALL_METHOD_1(php_layer->metadata, "remove", retval, zname);
+#if PHP_VERSION_ID < 70000
RETURN_LONG(Z_LVAL_P(retval));
+#else
+ RETURN_LONG(Z_LVAL(retval));
+#endif
}
/* }}} */
@@ -1429,14 +1450,14 @@ PHP_METHOD(layerObj, getWMSFeatureInfoURL)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
- if (!php_layer->parent.val) {
+ if (ZVAL_IS_UNDEF(php_layer->parent.val)) {
mapscript_throw_exception("No map object associated with this layer object." TSRMLS_CC);
return;
}
- php_map = (php_map_object *) zend_object_store_get_object(php_layer->parent.val TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ(php_map_object, php_layer->parent.val);
if ((value = layerObj_getWMSFeatureInfoURL(php_layer->layer, php_map->map,
clickx,
@@ -1444,10 +1465,10 @@ PHP_METHOD(layerObj, getWMSFeatureInfoURL)
featureCount,
infoFormat)) == NULL) {
mapscript_report_mapserver_error(E_WARNING TSRMLS_CC);
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
}
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -1467,7 +1488,7 @@ PHP_METHOD(layerObj, getItems)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
array_init(return_value);
status = msLayerGetItems(php_layer->layer);
@@ -1475,7 +1496,7 @@ PHP_METHOD(layerObj, getItems)
if (status != MS_FAILURE && php_layer->layer->numitems > 0) {
for (i=0; i<php_layer->layer->numitems; i++) {
/* add a copy of the group name to the PHP array */
- add_next_index_string(return_value, php_layer->layer->items[i], 1);
+ mapscript_add_next_index_string(return_value, php_layer->layer->items[i], 1);
}
}
}
@@ -1498,7 +1519,7 @@ PHP_METHOD(layerObj, setProcessing)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
php_layer->layer->numprocessing++;
if(php_layer->layer->numprocessing == 1)
@@ -1532,7 +1553,7 @@ PHP_METHOD(layerObj, setProcessingKey)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
msLayerSetProcessingKey( php_layer->layer, key, value );
@@ -1555,12 +1576,12 @@ PHP_METHOD(layerObj, getProcessing)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
array_init(return_value);
if (php_layer->layer->numprocessing > 0) {
for (i=0; i<php_layer->layer->numprocessing; i++) {
- add_next_index_string(return_value, php_layer->layer->processing[i], 1);
+ mapscript_add_next_index_string(return_value, php_layer->layer->processing[i], 1);
}
}
}
@@ -1581,7 +1602,7 @@ PHP_METHOD(layerObj, clearProcessing)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
if (php_layer->layer->numprocessing > 0) {
for(i=0; i<php_layer->layer->numprocessing; i++)
@@ -1608,12 +1629,12 @@ PHP_METHOD(layerObj, executeWFSGetFeature)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
if ((value=layerObj_executeWFSGetFeature(php_layer->layer)) == NULL)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -1642,7 +1663,7 @@ PHP_METHOD(layerObj, applySLD)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
status = layerObj_applySLD(php_layer->layer, sldxml, namedLayer);
@@ -1675,7 +1696,7 @@ PHP_METHOD(layerObj, applySLDURL)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
status = layerObj_applySLDURL(php_layer->layer, sldurl, namedLayer);
@@ -1699,16 +1720,16 @@ PHP_METHOD(layerObj, generateSLD)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
buffer = layerObj_generateSLD(php_layer->layer);
if (buffer) {
- RETVAL_STRING(buffer, 1);
+ MAPSCRIPT_RETVAL_STRING(buffer, 1);
free(buffer);
} else {
mapscript_report_mapserver_error(E_WARNING TSRMLS_CC);
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
}
}
/* }}} */
@@ -1731,7 +1752,7 @@ PHP_METHOD(layerObj, moveClassUp)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
status = layerObj_moveClassUp(php_layer->layer, index);
@@ -1757,7 +1778,7 @@ PHP_METHOD(layerObj, moveClassDown)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
status = layerObj_moveClassDown(php_layer->layer, index);
@@ -1784,7 +1805,7 @@ PHP_METHOD(layerObj, removeClass)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
if ((class = layerObj_removeClass(php_layer->layer, index)) == NULL) {
mapscript_report_mapserver_error(E_WARNING TSRMLS_CC);
@@ -1814,14 +1835,14 @@ PHP_METHOD(layerObj, isVisible)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
- if (!php_layer->parent.val) {
+ if (ZVAL_IS_UNDEF(php_layer->parent.val)) {
mapscript_throw_exception("No map object associated with this layer object." TSRMLS_CC);
return;
}
- php_map = (php_map_object *) zend_object_store_get_object(php_layer->parent.val TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ(php_map_object, php_layer->parent.val);
retval = msLayerIsVisible(php_map->map, php_layer->layer);
@@ -1849,7 +1870,7 @@ PHP_METHOD(layerObj, setConnectionType)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
if ((status = layerObj_setConnectionType(php_layer->layer,
type,
@@ -1859,10 +1880,14 @@ PHP_METHOD(layerObj, setConnectionType)
}
if (php_layer->layer->connectiontype != MS_GRATICULE || php_layer->layer->layerinfo == NULL) {
- if (php_layer->grid && Z_TYPE_P(php_layer->grid) == IS_OBJECT) {
+ if (ZVAL_NOT_UNDEF(php_layer->grid) && MAPSCRIPT_TYPE(php_layer->grid) == IS_OBJECT) {
MAPSCRIPT_DELREF(php_layer->grid);
MAKE_STD_ZVAL(php_layer->grid);
+#if PHP_VERSION_ID < 70000
ZVAL_NULL(php_layer->grid);
+#else
+ ZVAL_NULL(&php_layer->grid);
+#endif
}
}
@@ -1876,7 +1901,7 @@ PHP_METHOD(layerObj, getGridIntersectionCoordinates)
{
zval *zobj = getThis();
graticuleIntersectionObj *values=NULL;
- zval *tmp_arr1;
+ MAPSCRIPT_ZVAL tmp_arr1;
int i=0;
php_layer_object *php_layer;
php_map_object *php_map;
@@ -1888,14 +1913,14 @@ PHP_METHOD(layerObj, getGridIntersectionCoordinates)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
- if (!php_layer->parent.val) {
+ if (ZVAL_IS_UNDEF(php_layer->parent.val)) {
mapscript_throw_exception("No map object associated with this layer object." TSRMLS_CC);
return;
}
- php_map = (php_map_object *) zend_object_store_get_object(php_layer->parent.val TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ(php_map_object, php_layer->parent.val);
array_init(return_value);
@@ -1914,92 +1939,118 @@ PHP_METHOD(layerObj, getGridIntersectionCoordinates)
add_assoc_double(return_value, "topnumpoints", values->nTop);
MAKE_STD_ZVAL(tmp_arr1);
- array_init(tmp_arr1);
+ mapscript_array_init(tmp_arr1);
for (i=0; i<values->nTop; i++) {
+#if PHP_VERSION_ID < 70000
add_next_index_string(tmp_arr1, values->papszTopLabels[i],1);
+#else
+ add_next_index_string(&tmp_arr1, values->papszTopLabels[i]);
+#endif
}
- zend_hash_update(Z_ARRVAL_P(return_value), "toplabels", strlen("toplabels")+1, &tmp_arr1,
- sizeof(tmp_arr1), NULL);
+ mapscript_hash_update(Z_ARRVAL_P(return_value), "toplabels", tmp_arr1);
MAKE_STD_ZVAL(tmp_arr1);
- array_init(tmp_arr1);
+ mapscript_array_init(tmp_arr1);
for (i=0; i<values->nTop; i++) {
+#if PHP_VERSION_ID < 70000
add_next_index_double(tmp_arr1, values->pasTop[i].x);
add_next_index_double(tmp_arr1, values->pasTop[i].y);
+#else
+ add_next_index_double(&tmp_arr1, values->pasTop[i].x);
+ add_next_index_double(&tmp_arr1, values->pasTop[i].y);
+#endif
}
- zend_hash_update(Z_ARRVAL_P(return_value), "toppoints", strlen("toppoints")+1, &tmp_arr1,
- sizeof(tmp_arr1), NULL);
+ mapscript_hash_update(Z_ARRVAL_P(return_value), "toppoints", tmp_arr1);
/*BOTTOM*/
add_assoc_double(return_value, "bottomnumpoints", values->nBottom);
MAKE_STD_ZVAL(tmp_arr1);
- array_init(tmp_arr1);
+ mapscript_array_init(tmp_arr1);
for (i=0; i<values->nBottom; i++) {
+#if PHP_VERSION_ID < 70000
add_next_index_string(tmp_arr1, values->papszBottomLabels[i],1);
+#else
+ add_next_index_string(&tmp_arr1, values->papszBottomLabels[i]);
+#endif
}
- zend_hash_update(Z_ARRVAL_P(return_value), "bottomlabels", strlen("bottomlabels")+1, &tmp_arr1,
- sizeof(tmp_arr1), NULL);
+ mapscript_hash_update(Z_ARRVAL_P(return_value), "bottomlabels", tmp_arr1);
MAKE_STD_ZVAL(tmp_arr1);
- array_init(tmp_arr1);
+ mapscript_array_init(tmp_arr1);
for (i=0; i<values->nBottom; i++) {
+#if PHP_VERSION_ID < 70000
add_next_index_double(tmp_arr1, values->pasBottom[i].x);
add_next_index_double(tmp_arr1, values->pasBottom[i].y);
+#else
+ add_next_index_double(&tmp_arr1, values->pasBottom[i].x);
+ add_next_index_double(&tmp_arr1, values->pasBottom[i].y);
+#endif
}
- zend_hash_update(Z_ARRVAL_P(return_value), "bottompoints", strlen("bottompoints")+1, &tmp_arr1,
- sizeof(tmp_arr1), NULL);
+ mapscript_hash_update(Z_ARRVAL_P(return_value), "bottompoints", tmp_arr1);
/*LEFT*/
add_assoc_double(return_value, "leftnumpoints", values->nLeft);
MAKE_STD_ZVAL(tmp_arr1);
- array_init(tmp_arr1);
+ mapscript_array_init(tmp_arr1);
for (i=0; i<values->nLeft; i++) {
+#if PHP_VERSION_ID < 70000
add_next_index_string(tmp_arr1, values->papszLeftLabels[i],1);
+#else
+ add_next_index_string(&tmp_arr1, values->papszLeftLabels[i]);
+#endif
}
- zend_hash_update(Z_ARRVAL_P(return_value), "leftlabels", strlen("leftlabels")+1, &tmp_arr1,
- sizeof(tmp_arr1), NULL);
+ mapscript_hash_update(Z_ARRVAL_P(return_value), "leftlabels", tmp_arr1);
MAKE_STD_ZVAL(tmp_arr1);
- array_init(tmp_arr1);
+ mapscript_array_init(tmp_arr1);
for (i=0; i<values->nLeft; i++) {
+#if PHP_VERSION_ID < 70000
add_next_index_double(tmp_arr1, values->pasLeft[i].x);
add_next_index_double(tmp_arr1, values->pasLeft[i].y);
-
+#else
+ add_next_index_double(&tmp_arr1, values->pasLeft[i].x);
+ add_next_index_double(&tmp_arr1, values->pasLeft[i].y);
+#endif
}
- zend_hash_update(Z_ARRVAL_P(return_value), "leftpoints", strlen("leftpoints")+1, &tmp_arr1,
- sizeof(tmp_arr1), NULL);
+ mapscript_hash_update(Z_ARRVAL_P(return_value), "leftpoints", tmp_arr1);
/*RIGHT*/
add_assoc_double(return_value, "rightnumpoints", values->nRight);
MAKE_STD_ZVAL(tmp_arr1);
- array_init(tmp_arr1);
+ mapscript_array_init(tmp_arr1);
for (i=0; i<values->nRight; i++) {
+#if PHP_VERSION_ID < 70000
add_next_index_string(tmp_arr1, values->papszRightLabels[i],1);
+#else
+ add_next_index_string(&tmp_arr1, values->papszRightLabels[i]);
+#endif
}
- zend_hash_update(Z_ARRVAL_P(return_value), "rightlabels", strlen("rightlabels")+1, &tmp_arr1,
- sizeof(tmp_arr1), NULL);
+ mapscript_hash_update(Z_ARRVAL_P(return_value), "rightlabels", tmp_arr1);
MAKE_STD_ZVAL(tmp_arr1);
- array_init(tmp_arr1);
+ mapscript_array_init(tmp_arr1);
for (i=0; i<values->nRight; i++) {
+#if PHP_VERSION_ID < 70000
add_next_index_double(tmp_arr1, values->pasRight[i].x);
add_next_index_double(tmp_arr1, values->pasRight[i].y);
-
+#else
+ add_next_index_double(&tmp_arr1, values->pasRight[i].x);
+ add_next_index_double(&tmp_arr1, values->pasRight[i].y);
+#endif
}
- zend_hash_update(Z_ARRVAL_P(return_value), "rightpoints", strlen("rightpoints")+1, &tmp_arr1,
- sizeof(tmp_arr1), NULL);
+ mapscript_hash_update(Z_ARRVAL_P(return_value), "rightpoints", tmp_arr1);
msGraticuleLayerFreeIntersectionPoints(values);
}
@@ -2024,8 +2075,8 @@ PHP_METHOD(layerObj, getShape)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_result = (php_result_object *) zend_object_store_get_object(zresult TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
+ php_result = MAPSCRIPT_OBJ_P(php_result_object, zresult);
/* Create a new shapeObj to hold the result
* Note that the type used to create the shape (MS_NULL) does not matter
@@ -2062,13 +2113,13 @@ PHP_METHOD(layerObj, getGeomTransform)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
if (php_layer->layer->_geomtransform.type == MS_GEOMTRANSFORM_NONE ||
!php_layer->layer->_geomtransform.string)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETURN_STRING(php_layer->layer->_geomtransform.string, 1);
+ MAPSCRIPT_RETURN_STRING(php_layer->layer->_geomtransform.string, 1);
}
/* }}} */
@@ -2089,7 +2140,7 @@ PHP_METHOD(layerObj, setGeomTransform)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
msFree(php_layer->layer->_geomtransform.string);
if (transform_len > 0) {
@@ -2118,10 +2169,10 @@ PHP_METHOD(layerObj, free)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
MAPSCRIPT_DELREF(php_layer->offsite);
- if (php_layer->grid && Z_TYPE_P(php_layer->grid) == IS_OBJECT)
+ if (ZVAL_NOT_UNDEF(php_layer->grid) && MAPSCRIPT_TYPE(php_layer->grid) == IS_OBJECT)
MAPSCRIPT_DELREF(php_layer->grid);
MAPSCRIPT_DELREF(php_layer->metadata);
MAPSCRIPT_DELREF(php_layer->bindvals);
@@ -2195,21 +2246,110 @@ void mapscript_create_layer(layerObj *layer, parent_object parent, zval *return_
{
php_layer_object * php_layer;
object_init_ex(return_value, mapscript_ce_layer);
- php_layer = (php_layer_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, return_value);
php_layer->layer = layer;
if (layer->connectiontype != MS_GRATICULE || layer->layerinfo == NULL) {
MAKE_STD_ZVAL(php_layer->grid);
+#if PHP_VERSION_ID < 70000
ZVAL_NULL(php_layer->grid);
+#else
+ ZVAL_NULL(&php_layer->grid);
+#endif
}
- if (parent.val)
+ if(ZVAL_NOT_UNDEF(parent.val))
php_layer->is_ref = 1;
php_layer->parent = parent;
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_layer_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_layer_object *php_layer;
+
+ php_layer = ecalloc(1, sizeof(*php_layer) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_layer->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_layer->zobj, ce);
+
+ php_layer->zobj.handlers = &mapscript_layer_object_handlers;
+
+ php_layer->is_ref = 0;
+ MAPSCRIPT_INIT_PARENT(php_layer->parent);
+ ZVAL_UNDEF(&php_layer->offsite);
+ ZVAL_UNDEF(&php_layer->grid);
+ ZVAL_UNDEF(&php_layer->metadata);
+ ZVAL_UNDEF(&php_layer->bindvals);
+ ZVAL_UNDEF(&php_layer->cluster);
+ ZVAL_UNDEF(&php_layer->projection);
+ ZVAL_UNDEF(&php_layer->extent);
+
+ return &php_layer->zobj;
+}
+
+static void mapscript_layer_free_object(zend_object *object)
+{
+ php_layer_object *php_layer;
+
+ php_layer = (php_layer_object *)((char *)object - XtOffsetOf(php_layer_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_layer->parent);
+ MAPSCRIPT_DELREF(php_layer->offsite);
+ if (ZVAL_NOT_UNDEF(php_layer->grid) && MAPSCRIPT_TYPE(php_layer->grid) == IS_OBJECT)
+ MAPSCRIPT_DELREF(php_layer->grid);
+ MAPSCRIPT_DELREF(php_layer->metadata);
+ MAPSCRIPT_DELREF(php_layer->bindvals);
+ MAPSCRIPT_DELREF(php_layer->cluster);
+ MAPSCRIPT_DELREF(php_layer->projection);
+ MAPSCRIPT_DELREF(php_layer->extent);
+
+ if (php_layer->layer && !php_layer->is_ref) {
+ layerObj_destroy(php_layer->layer);
+ }
+
+ zend_object_std_dtor(object);
+}
+
+static zend_object* mapscript_layer_clone_object(zval *zobj)
+{
+ php_layer_object *php_layer_old, *php_layer_new;
+ zend_object* zobj_new;
+
+ php_layer_old = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
+
+ zobj_new = mapscript_layer_create_object(mapscript_ce_layer);
+ php_layer_new = (php_layer_object *)((char *)zobj_new - XtOffsetOf(php_layer_object, zobj));
+
+ zend_objects_clone_members(&php_layer_new->zobj, &php_layer_old->zobj);
+
+ php_layer_new->layer = layerObj_clone(php_layer_old->layer);
+
+ return zobj_new;
+}
+
+PHP_MINIT_FUNCTION(layer)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "layerObj", layer_functions);
+ mapscript_ce_layer = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_layer->create_object = mapscript_layer_create_object;
+ mapscript_ce_layer->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_layer_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_layer_object_handlers));
+ mapscript_layer_object_handlers.free_obj = mapscript_layer_free_object;
+ mapscript_layer_object_handlers.clone_obj = mapscript_layer_clone_object;
+ mapscript_layer_object_handlers.offset = XtOffsetOf(php_layer_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_layer_object_destroy(void *object TSRMLS_DC)
{
php_layer_object *php_layer = (php_layer_object *)object;
@@ -2269,7 +2409,7 @@ static zend_object_value mapscript_layer_object_clone(zval *zobj TSRMLS_DC)
php_layer_object *php_layer_old, *php_layer_new;
zend_object_value new_ov;
- php_layer_old = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_layer_old = MAPSCRIPT_OBJ_P(php_layer_object, zobj);
new_ov = mapscript_layer_object_new_ex(mapscript_ce_layer, &php_layer_new TSRMLS_CC);
zend_objects_clone_members(&php_layer_new->std, new_ov, &php_layer_old->std, Z_OBJ_HANDLE_P(zobj) TSRMLS_CC);
@@ -2295,4 +2435,4 @@ PHP_MINIT_FUNCTION(layer)
return SUCCESS;
}
-
+#endif
diff --git a/mapscript/php/legend.c b/mapscript/php/legend.c
index 52258fec5..29e080df7 100644
--- a/mapscript/php/legend.c
+++ b/mapscript/php/legend.c
@@ -30,6 +30,9 @@
**********************************************************************/
#include "php_mapscript.h"
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_legend_object_handlers;
+#endif
zend_class_entry *mapscript_ce_legend;
@@ -69,7 +72,7 @@ PHP_METHOD(legendObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_legend = (php_legend_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_legend = MAPSCRIPT_OBJ_P(php_legend_object, zobj);
IF_GET_LONG("height", php_legend->legend->height)
else IF_GET_LONG("width", php_legend->legend->width)
@@ -105,7 +108,7 @@ PHP_METHOD(legendObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_legend = (php_legend_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_legend = MAPSCRIPT_OBJ_P(php_legend_object, zobj);
IF_SET_LONG("height", php_legend->legend->height, value)
else IF_SET_LONG("width", php_legend->legend->width, value)
@@ -144,7 +147,7 @@ PHP_METHOD(legendObj, updateFromString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_legend = (php_legend_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_legend = MAPSCRIPT_OBJ_P(php_legend_object, zobj);
status = legendObj_updateFromString(php_legend->legend, snippet);
@@ -172,14 +175,14 @@ PHP_METHOD(legendObj, convertToString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_legend = (php_legend_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_legend = MAPSCRIPT_OBJ_P(php_legend_object, zobj);
value = legendObj_convertToString(php_legend->legend);
if (value == NULL)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -198,7 +201,7 @@ PHP_METHOD(legendObj, free)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_legend = (php_legend_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_legend = MAPSCRIPT_OBJ_P(php_legend_object, zobj);
MAPSCRIPT_DELREF(php_legend->outlinecolor);
MAPSCRIPT_DELREF(php_legend->imagecolor);
@@ -217,11 +220,67 @@ zend_function_entry legend_functions[] = {
}
};
+
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_legend_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_legend_object *php_legend;
+
+ php_legend = ecalloc(1, sizeof(*php_legend) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_legend->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_legend->zobj, ce);
+
+ php_legend->zobj.handlers = &mapscript_legend_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_legend->parent);
+ ZVAL_UNDEF(&php_legend->outlinecolor);
+ ZVAL_UNDEF(&php_legend->imagecolor);
+ ZVAL_UNDEF(&php_legend->label);
+
+ return &php_legend->zobj;
+}
+
+static void mapscript_legend_free_object(zend_object *object)
+{
+ php_legend_object *php_legend;
+
+ php_legend = (php_legend_object *)((char *)object - XtOffsetOf(php_legend_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_legend->parent);
+ MAPSCRIPT_DELREF(php_legend->outlinecolor);
+ MAPSCRIPT_DELREF(php_legend->imagecolor);
+ MAPSCRIPT_DELREF(php_legend->label);
+
+ /* We don't need to free the legendObj */
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(legend)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "legendObj", legend_functions);
+ mapscript_ce_legend = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_legend->create_object = mapscript_legend_create_object;
+ mapscript_ce_legend->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_legend_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_legend_object_handlers));
+ mapscript_legend_object_handlers.free_obj = mapscript_legend_free_object;
+ mapscript_legend_object_handlers.offset = XtOffsetOf(php_legend_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
void mapscript_create_legend(legendObj *legend, parent_object parent, zval *return_value TSRMLS_DC)
{
php_legend_object * php_legend;
object_init_ex(return_value, mapscript_ce_legend);
- php_legend = (php_legend_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_legend = MAPSCRIPT_OBJ_P(php_legend_object, return_value);
php_legend->legend = legend;
php_legend->parent = parent;
@@ -275,3 +334,4 @@ PHP_MINIT_FUNCTION(legend)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/line.c b/mapscript/php/line.c
index cf73316a2..44aeb583c 100644
--- a/mapscript/php/line.c
+++ b/mapscript/php/line.c
@@ -87,7 +87,7 @@ PHP_METHOD(lineObj, __construct)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_line = (php_line_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
+ php_line = MAPSCRIPT_OBJ_P(php_line_object, getThis());
if ((php_line->line = lineObj_new()) == NULL) {
mapscript_throw_exception("Unable to construct lineObj." TSRMLS_CC);
@@ -111,7 +111,7 @@ PHP_METHOD(lineObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_line = (php_line_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_line = MAPSCRIPT_OBJ_P(php_line_object, zobj);
IF_GET_LONG("numpoints", php_line->line->numpoints)
else {
@@ -158,8 +158,8 @@ PHP_METHOD(lineObj, add)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_line = (php_line_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_point = (php_point_object *) zend_object_store_get_object(zobj_point TSRMLS_CC);
+ php_line = MAPSCRIPT_OBJ_P(php_line_object, zobj);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, zobj_point);
status = lineObj_add(php_line->line, php_point->point);
@@ -185,7 +185,7 @@ PHP_METHOD(lineObj, addXY)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_line = (php_line_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_line = MAPSCRIPT_OBJ_P(php_line_object, zobj);
point.x = x;
point.y = y;
@@ -220,7 +220,7 @@ PHP_METHOD(lineObj, addXYZ)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_line = (php_line_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_line = MAPSCRIPT_OBJ_P(php_line_object, zobj);
point.x = x;
point.y = y;
@@ -255,9 +255,9 @@ PHP_METHOD(lineObj, project)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_line = (php_line_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_proj_in = (php_projection_object *) zend_object_store_get_object(zobj_proj_in TSRMLS_CC);
- php_proj_out = (php_projection_object *) zend_object_store_get_object(zobj_proj_out TSRMLS_CC);
+ php_line = MAPSCRIPT_OBJ_P(php_line_object, zobj);
+ php_proj_in = MAPSCRIPT_OBJ_P(php_projection_object, zobj_proj_in);
+ php_proj_out = MAPSCRIPT_OBJ_P(php_projection_object, zobj_proj_out);
status = lineObj_project(php_line->line, php_proj_in->projection, php_proj_out->projection);
if (status != MS_SUCCESS) {
@@ -284,7 +284,7 @@ PHP_METHOD(lineObj, point)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_line = (php_line_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_line = MAPSCRIPT_OBJ_P(php_line_object, zobj);
if ( (index < 0) || (index >= php_line->line->numpoints)) {
mapscript_throw_exception("Point '%d' does not exist in this object." TSRMLS_CC, index);
@@ -314,14 +314,14 @@ PHP_METHOD(lineObj, set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_line = (php_line_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_line = MAPSCRIPT_OBJ_P(php_line_object, zobj);
if ( (index < 0) || (index >= php_line->line->numpoints)) {
mapscript_throw_exception("Point '%d' does not exist in this object." TSRMLS_CC, index);
return;
}
- php_point = (php_point_object *) zend_object_store_get_object(zobj_point TSRMLS_CC);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, zobj_point);
php_line->line->point[index].x = php_point->point->x;
php_line->line->point[index].y = php_point->point->y;
@@ -350,16 +350,86 @@ void mapscript_create_line(lineObj *line, parent_object parent, zval *return_val
{
php_line_object * php_line;
object_init_ex(return_value, mapscript_ce_line);
- php_line = (php_line_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_line = MAPSCRIPT_OBJ_P(php_line_object, return_value);
php_line->line = line;
- if (parent.val)
+ if (ZVAL_NOT_UNDEF(parent.val))
php_line->is_ref = 1;
php_line->parent = parent;
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_line_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_line_object *php_line;
+
+ php_line = ecalloc(1, sizeof(*php_line) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_line->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_line->zobj, ce);
+
+ php_line->zobj.handlers = &mapscript_line_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_line->parent);
+ php_line->is_ref = 0;
+
+ return &php_line->zobj;
+}
+
+static void mapscript_line_free_object(zend_object *object)
+{
+ php_line_object *php_line;
+
+ php_line = (php_line_object *)((char *)object - XtOffsetOf(php_line_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_line->parent);
+
+ if (php_line->line && !php_line->is_ref) {
+ lineObj_destroy(php_line->line);
+ }
+
+ zend_object_std_dtor(object);
+}
+
+static zend_object* mapscript_line_clone_object(zval *zobj)
+{
+ php_line_object *php_line_old, *php_line_new;
+ zend_object* zobj_new;
+
+ php_line_old = MAPSCRIPT_OBJ_P(php_line_object, zobj);
+
+ zobj_new = mapscript_line_create_object(mapscript_ce_line);
+ php_line_new = (php_line_object *)((char *)zobj_new - XtOffsetOf(php_line_object, zobj));
+
+ zend_objects_clone_members(&php_line_new->zobj, &php_line_old->zobj);
+
+ php_line_new->line = lineObj_clone(php_line_old->line);
+
+ return zobj_new;
+}
+
+PHP_MINIT_FUNCTION(line)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "lineObj", line_functions);
+ mapscript_ce_line = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_line->create_object = mapscript_line_create_object;
+ mapscript_ce_line->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_line_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_line_object_handlers));
+ mapscript_line_object_handlers.free_obj = mapscript_line_free_object;
+ mapscript_line_object_handlers.clone_obj = mapscript_line_clone_object;
+ mapscript_line_object_handlers.offset = XtOffsetOf(php_line_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_line_object_destroy(void *object TSRMLS_DC)
{
php_line_object *php_line = (php_line_object *)object;
@@ -405,7 +475,7 @@ static zend_object_value mapscript_line_object_clone(zval *zobj TSRMLS_DC)
php_line_object *php_line_old, *php_line_new;
zend_object_value new_ov;
- php_line_old = (php_line_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_line_old = MAPSCRIPT_OBJ_P(php_line_object, zobj);
new_ov = mapscript_line_object_new_ex(mapscript_ce_line, &php_line_new TSRMLS_CC);
zend_objects_clone_members(&php_line_new->std, new_ov, &php_line_old->std, Z_OBJ_HANDLE_P(zobj) TSRMLS_CC);
@@ -432,3 +502,4 @@ PHP_MINIT_FUNCTION(line)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/map.c b/mapscript/php/map.c
index aa477375a..b8fcfda86 100644
--- a/mapscript/php/map.c
+++ b/mapscript/php/map.c
@@ -312,9 +312,11 @@ ZEND_BEGIN_ARG_INFO_EX(map_removeLayer_args, 0, 0, 1)
ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO()
+#ifdef disabled
ZEND_BEGIN_ARG_INFO_EX(map_getLabel_args, 0, 0, 1)
ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO()
+#endif
/* {{{ proto void __construct(string mapFileName, newMapPath)
Create a new mapObj instance. */
@@ -337,7 +339,7 @@ PHP_METHOD(mapObj, __construct)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *)zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
map = mapObj_new(filename, path);
@@ -365,7 +367,7 @@ PHP_METHOD(mapObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
IF_GET_LONG("numlayers", php_map->map->numlayers)
else IF_GET_STRING("name", php_map->map->name)
@@ -424,7 +426,7 @@ PHP_METHOD(mapObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
IF_SET_STRING("name", php_map->map->name, value)
else IF_SET_LONG("status", php_map->map->status, value)
@@ -487,7 +489,7 @@ PHP_METHOD(mapObj, getSymbolByName)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
symbolId = mapObj_getSymbolByName(php_map->map, symbolName);
@@ -514,7 +516,7 @@ PHP_METHOD(mapObj, getSymbolObjectById)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
if ( symbolId < 0 || symbolId >= php_map->map->symbolset.numsymbols) {
mapscript_throw_exception("Invalid symbol index." TSRMLS_CC);
@@ -543,7 +545,7 @@ PHP_METHOD(mapObj, prepareQuery)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
mapObj_prepareQuery(php_map->map);
}
@@ -564,7 +566,7 @@ PHP_METHOD(mapObj, prepareImage)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
image = mapObj_prepareImage(php_map->map);
if (image == NULL) {
@@ -593,7 +595,7 @@ PHP_METHOD(mapObj, draw)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
image = mapObj_draw(php_map->map);
if (image == NULL) {
@@ -620,7 +622,7 @@ PHP_METHOD(mapObj, drawQuery)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
image = mapObj_drawQuery(php_map->map);
if (image == NULL) {
@@ -647,7 +649,7 @@ PHP_METHOD(mapObj, drawLegend)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
image = mapObj_drawLegend(php_map->map);
if (image == NULL) {
@@ -675,7 +677,7 @@ PHP_METHOD(mapObj, drawReferenceMap)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
image = mapObj_drawReferenceMap(php_map->map);
if (image == NULL) {
@@ -703,7 +705,7 @@ PHP_METHOD(mapObj, drawScaleBar)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
image = mapObj_drawScalebar(php_map->map);
if (image == NULL) {
@@ -734,8 +736,8 @@ PHP_METHOD(mapObj, embedLegend)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_image = (php_image_object *) zend_object_store_get_object(zimage TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
+ php_image = MAPSCRIPT_OBJ_P(php_image_object, zimage);
retval = mapObj_embedLegend(php_map->map, php_image->image);
if ( (retval == MS_FAILURE) || (retval == -1) ) {
@@ -766,8 +768,8 @@ PHP_METHOD(mapObj, embedScaleBar)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_image = (php_image_object *) zend_object_store_get_object(zimage TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
+ php_image = MAPSCRIPT_OBJ_P(php_image_object, zimage);
retval = mapObj_embedScalebar(php_map->map, php_image->image);
if ( (retval == MS_FAILURE) || (retval == -1) ) {
@@ -798,8 +800,8 @@ PHP_METHOD(mapObj, drawLabelCache)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_image = (php_image_object *) zend_object_store_get_object(zimage TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
+ php_image = MAPSCRIPT_OBJ_P(php_image_object, zimage);
retval = mapObj_drawLabelCache(php_map->map, php_image->image);
if ( (retval == MS_FAILURE) || (retval == -1) ) {
@@ -830,7 +832,7 @@ PHP_METHOD(mapObj, getLayer)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
layer = mapObj_getLayer(php_map->map, index);
if (layer == NULL) {
@@ -864,7 +866,7 @@ PHP_METHOD(mapObj, getLayerByName)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
layer = mapObj_getLayerByName(php_map->map, layerName);
if (layer == NULL) {
@@ -898,7 +900,7 @@ PHP_METHOD(mapObj, getColorByIndex)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
palette = php_map->map->palette;
@@ -934,7 +936,7 @@ PHP_METHOD(mapObj, setExtent)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
status = msMapSetExtent( php_map->map,
minx, miny,
@@ -967,8 +969,8 @@ PHP_METHOD(mapObj, setCenter)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_point = (php_point_object *) zend_object_store_get_object(zpoint TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, zpoint);
status = mapObj_setCenter(php_map->map, php_point->point);
if (status != MS_SUCCESS) {
@@ -996,7 +998,7 @@ PHP_METHOD(mapObj, offsetExtent)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
status = mapObj_offsetExtent(php_map->map, x, y);
if (status != MS_SUCCESS) {
@@ -1025,7 +1027,7 @@ PHP_METHOD(mapObj, scaleExtent)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
status = mapObj_scaleExtent(php_map->map, zoomFactor, minScaleDenom, maxScaleDenom);
if (status != MS_SUCCESS) {
@@ -1056,7 +1058,7 @@ PHP_METHOD(mapObj, setRotation)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
status = mapObj_setRotation(php_map->map, angle);
if (status != MS_SUCCESS) {
@@ -1086,7 +1088,7 @@ PHP_METHOD(mapObj, setSize)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
status = msMapSetSize(php_map->map, width, height);
if (status != MS_SUCCESS) {
@@ -1126,11 +1128,11 @@ PHP_METHOD(mapObj, zoomPoint)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_pixelPosition = (php_point_object *) zend_object_store_get_object(zpoint TSRMLS_CC);
- php_geoRefExtent = (php_rect_object *) zend_object_store_get_object(zgeoRefExtent TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
+ php_pixelPosition = MAPSCRIPT_OBJ_P(php_point_object, zpoint);
+ php_geoRefExtent = MAPSCRIPT_OBJ_P(php_rect_object, zgeoRefExtent);
if (zmaxGeoRefExtent)
- php_maxGeoRefExtent = (php_rect_object *) zend_object_store_get_object(zmaxGeoRefExtent TSRMLS_CC);
+ php_maxGeoRefExtent = MAPSCRIPT_OBJ_P(php_rect_object, zmaxGeoRefExtent);
/* -------------------------------------------------------------------- */
/* check the validity of the parameters. */
@@ -1345,11 +1347,11 @@ PHP_METHOD(mapObj, zoomRectangle)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_pixelExtent = (php_rect_object *) zend_object_store_get_object(zpixelExtent TSRMLS_CC);
- php_geoRefExtent = (php_rect_object *) zend_object_store_get_object(zgeoRefExtent TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
+ php_pixelExtent = MAPSCRIPT_OBJ_P(php_rect_object, zpixelExtent);
+ php_geoRefExtent = MAPSCRIPT_OBJ_P(php_rect_object, zgeoRefExtent);
if (zmaxGeoRefExtent)
- php_maxGeoRefExtent = (php_rect_object *) zend_object_store_get_object(zmaxGeoRefExtent TSRMLS_CC);
+ php_maxGeoRefExtent = MAPSCRIPT_OBJ_P(php_rect_object, zmaxGeoRefExtent);
/* -------------------------------------------------------------------- */
@@ -1540,11 +1542,11 @@ PHP_METHOD(mapObj, zoomScale)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_pixelPosition = (php_point_object *) zend_object_store_get_object(zpoint TSRMLS_CC);
- php_geoRefExtent = (php_rect_object *) zend_object_store_get_object(zgeoRefExtent TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
+ php_pixelPosition = MAPSCRIPT_OBJ_P(php_point_object, zpoint);
+ php_geoRefExtent = MAPSCRIPT_OBJ_P(php_rect_object, zgeoRefExtent);
if (zmaxGeoRefExtent)
- php_maxGeoRefExtent = (php_rect_object *) zend_object_store_get_object(zmaxGeoRefExtent TSRMLS_CC);
+ php_maxGeoRefExtent = MAPSCRIPT_OBJ_P(php_rect_object, zmaxGeoRefExtent);
/* -------------------------------------------------------------------- */
/* check the validity of the parameters. */
@@ -1771,8 +1773,8 @@ PHP_METHOD(mapObj, queryByPoint)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_point = (php_point_object *) zend_object_store_get_object(zpoint TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, zpoint);
status = mapObj_queryByPoint(php_map->map, php_point->point, mode, buffer);
if (status != MS_SUCCESS) {
@@ -1800,8 +1802,8 @@ PHP_METHOD(mapObj, queryByRect)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_rect = (php_rect_object *) zend_object_store_get_object(zrect TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
+ php_rect = MAPSCRIPT_OBJ_P(php_rect_object, zrect);
status = mapObj_queryByRect(php_map->map, *(php_rect->rect));
if (status != MS_SUCCESS) {
@@ -1836,8 +1838,8 @@ PHP_METHOD(mapObj, queryByShape)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
status = mapObj_queryByShape(php_map->map, php_shape->shape);
if (status != MS_SUCCESS) {
@@ -1864,7 +1866,7 @@ PHP_METHOD(mapObj, queryByFeatures)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
status = mapObj_queryByFeatures(php_map->map, slayer);
if (status != MS_SUCCESS) {
@@ -1902,7 +1904,7 @@ PHP_METHOD(mapObj, queryByIndex)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
status = mapObj_queryByIndex(php_map->map, layerIndex,
tileIndex,
@@ -1933,7 +1935,7 @@ PHP_METHOD(mapObj, queryByFilter)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
status = mapObj_queryByFilter(php_map->map, string);
if (status != MS_SUCCESS) {
@@ -1963,7 +1965,7 @@ PHP_METHOD(mapObj, saveQuery)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
status = mapObj_saveQuery(php_map->map, filename, results);
@@ -1991,7 +1993,7 @@ PHP_METHOD(mapObj, saveQueryAsGML)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
status = msGMLWriteQuery(php_map->map, filename, namespace);
@@ -2017,7 +2019,7 @@ PHP_METHOD(mapObj, loadQuery)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
status = mapObj_loadQuery(php_map->map, filename);
@@ -2042,7 +2044,7 @@ PHP_METHOD(mapObj, freeQuery)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
mapObj_freeQuery(php_map->map, qlayer);
@@ -2068,7 +2070,7 @@ PHP_METHOD(mapObj, save)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
status = mapObj_save(php_map->map, filename);
if (status != MS_SUCCESS) {
@@ -2100,7 +2102,7 @@ PHP_METHOD(mapObj, setProjection)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
status = mapscript_map_setProjection(MS_FALSE, php_map,
projection, setUnitsAndExtents TSRMLS_CC);
@@ -2123,14 +2125,14 @@ PHP_METHOD(mapObj, getProjection)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
projection = mapObj_getProjection(php_map->map);
if (projection == NULL) {
RETURN_NULL();
}
- RETVAL_STRING(projection, 1);
+ MAPSCRIPT_RETVAL_STRING(projection, 1);
free(projection);
}
/* }}} */
@@ -2154,7 +2156,7 @@ PHP_METHOD(mapObj, setWKTProjection)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
status = mapscript_map_setProjection(MS_TRUE, php_map,
projection, setUnitsAndExtents TSRMLS_CC);
@@ -2169,7 +2171,7 @@ PHP_METHOD(mapObj, getMetaData)
zval *zname;
zval *zobj = getThis();
php_map_object *php_map;
- zval *retval;
+ MAPSCRIPT_ZVAL retval;
PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z",
@@ -2179,12 +2181,16 @@ PHP_METHOD(mapObj, getMetaData)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
CHECK_OBJECT(mapscript_ce_hashtable, php_map->metadata, &php_map->map->web.metadata);
MAPSCRIPT_CALL_METHOD_1(php_map->metadata, "get", retval, zname);
+#if PHP_VERSION_ID < 70000
RETURN_STRING(Z_STRVAL_P(retval),1);
+#else
+ RETURN_STRING(Z_STRVAL(retval));
+#endif
}
/* }}} */
@@ -2195,7 +2201,7 @@ PHP_METHOD(mapObj, setMetaData)
zval *zname, *zvalue;
zval *zobj = getThis();
php_map_object *php_map;
- zval *retval;
+ MAPSCRIPT_ZVAL retval;
PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz",
@@ -2205,12 +2211,16 @@ PHP_METHOD(mapObj, setMetaData)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
CHECK_OBJECT(mapscript_ce_hashtable, php_map->metadata, &php_map->map->web.metadata);
MAPSCRIPT_CALL_METHOD_2(php_map->metadata, "set", retval, zname, zvalue);
+#if PHP_VERSION_ID < 70000
RETURN_LONG(Z_LVAL_P(retval));
+#else
+ RETURN_LONG(Z_LVAL(retval));
+#endif
}
/* }}} */
@@ -2221,7 +2231,7 @@ PHP_METHOD(mapObj, removeMetaData)
zval *zname;
zval *zobj = getThis();
php_map_object *php_map;
- zval *retval;
+ MAPSCRIPT_ZVAL retval;
PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z",
@@ -2231,12 +2241,16 @@ PHP_METHOD(mapObj, removeMetaData)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
CHECK_OBJECT(mapscript_ce_hashtable, php_map->metadata, &php_map->map->web.metadata);
MAPSCRIPT_CALL_METHOD_1(php_map->metadata, "remove", retval, zname);
+#if PHP_VERSION_ID < 70000
RETURN_LONG(Z_LVAL_P(retval));
+#else
+ RETURN_LONG(Z_LVAL(retval));
+#endif
}
/* }}} */
@@ -2260,7 +2274,7 @@ PHP_METHOD(mapObj, getLayersIndexByGroup)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
array_init(return_value);
indexes = mapObj_getLayersIndexByGroup(php_map->map, groupName, &count);
@@ -2290,7 +2304,7 @@ PHP_METHOD(mapObj, getAllGroupNames)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
array_init(return_value);
if (php_map->map->numlayers > 0) {
@@ -2298,7 +2312,11 @@ PHP_METHOD(mapObj, getAllGroupNames)
for (i=0; i<numTok; i++) {
/* add a copy of the group name to the PHP array */
+#if PHP_VERSION_ID < 70000
add_next_index_string(return_value, groups[i], 1);
+#else
+ add_next_index_string(return_value, groups[i]);
+#endif
free(groups[i]);
}
free(groups);
@@ -2322,12 +2340,16 @@ PHP_METHOD(mapObj, getAllLayerNames)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
array_init(return_value);
count = php_map->map->numlayers;
for (i=0; i<count; i++) {
+#if PHP_VERSION_ID < 70000
add_next_index_string(return_value, php_map->map->layers[i]->name, 1);
+#else
+ add_next_index_string(return_value, php_map->map->layers[i]->name);
+#endif
}
}
/* }}} */
@@ -2349,7 +2371,7 @@ PHP_METHOD(mapObj, moveLayerUp)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
status = mapObj_moveLayerup(php_map->map, index);
@@ -2374,7 +2396,7 @@ PHP_METHOD(mapObj, moveLayerDown)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
status = mapObj_moveLayerdown(php_map->map, index);
@@ -2400,7 +2422,7 @@ PHP_METHOD(mapObj, getLayersDrawingOrder)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
array_init(return_value);
@@ -2436,7 +2458,8 @@ PHP_METHOD(mapObj, getLayersDrawingOrder)
PHP_METHOD(mapObj, setLayersDrawingOrder)
{
zval *zobj = getThis();
- zval *zindexes, **ppzval;
+ zval *zindexes;
+ MAPSCRIPT_ZVAL_P ppzval;
HashTable *indexes_hash = NULL;
int *indexes = NULL;
int numElements = 0;
@@ -2451,7 +2474,7 @@ PHP_METHOD(mapObj, setLayersDrawingOrder)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
indexes_hash = Z_ARRVAL_P(zindexes);
numElements = zend_hash_num_elements(indexes_hash);
@@ -2468,7 +2491,11 @@ PHP_METHOD(mapObj, setLayersDrawingOrder)
for(zend_hash_internal_pointer_reset(indexes_hash);
zend_hash_has_more_elements(indexes_hash) == SUCCESS;
zend_hash_move_forward(indexes_hash), ++i) {
+#if PHP_VERSION_ID < 70000
zend_hash_get_current_data(indexes_hash, (void **)&ppzval);
+#else
+ ppzval = zend_hash_get_current_data(indexes_hash);
+#endif
indexes[i] = Z_LVAL_PP(ppzval);
}
@@ -2506,7 +2533,7 @@ PHP_METHOD(mapObj, processTemplate)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
indexes_hash = Z_ARRVAL_P(zindexes);
/**
@@ -2534,7 +2561,7 @@ PHP_METHOD(mapObj, processTemplate)
} else {
// Failed for some reason
mapscript_report_php_error(E_WARNING, "processTemplate: failed reading array" TSRMLS_CC);
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
}
efree(papszNameValue);
@@ -2545,11 +2572,11 @@ PHP_METHOD(mapObj, processTemplate)
msFree(papszValue);
if (buffer) {
- RETVAL_STRING(buffer, 1);
+ MAPSCRIPT_RETVAL_STRING(buffer, 1);
free(buffer);
} else {
mapscript_report_mapserver_error(E_WARNING TSRMLS_CC);
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
}
}
/* }}} */
@@ -2578,7 +2605,7 @@ PHP_METHOD(mapObj, processQueryTemplate)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
indexes_hash = Z_ARRVAL_P(zindexes);
/**
@@ -2607,7 +2634,7 @@ PHP_METHOD(mapObj, processQueryTemplate)
} else {
// Failed for some reason
mapscript_report_php_error(E_WARNING, "processQueryTemplate: failed reading array" TSRMLS_CC);
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
}
efree(papszNameValue);
@@ -2619,11 +2646,11 @@ PHP_METHOD(mapObj, processQueryTemplate)
msFree(papszValue);
if (buffer) {
- RETVAL_STRING(buffer, 1);
+ MAPSCRIPT_RETVAL_STRING(buffer, 1);
free(buffer);
} else {
mapscript_report_mapserver_error(E_WARNING TSRMLS_CC);
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
}
}
/* }}} */
@@ -2651,7 +2678,7 @@ PHP_METHOD(mapObj, processLegendTemplate)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
indexes_hash = Z_ARRVAL_P(zindexes);
/**
@@ -2680,7 +2707,7 @@ PHP_METHOD(mapObj, processLegendTemplate)
} else {
// Failed for some reason
mapscript_report_php_error(E_WARNING, "processLegendTemplate: failed reading array" TSRMLS_CC);
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
}
efree(papszNameValue);
@@ -2692,11 +2719,11 @@ PHP_METHOD(mapObj, processLegendTemplate)
msFree(papszValue);
if (buffer) {
- RETVAL_STRING(buffer, 1);
+ MAPSCRIPT_RETVAL_STRING(buffer, 1);
free(buffer);
} else {
mapscript_report_mapserver_error(E_WARNING TSRMLS_CC);
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
}
}
/* }}} */
@@ -2718,7 +2745,7 @@ PHP_METHOD(mapObj, setSymbolSet)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
if(filename_len > 0) {
if ((status = mapObj_setSymbolSet(php_map->map,
@@ -2748,7 +2775,7 @@ PHP_METHOD(mapObj, getNumSymbols)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
RETURN_LONG(php_map->map->symbolset.numsymbols);
}
@@ -2771,7 +2798,7 @@ PHP_METHOD(mapObj, setFontSet)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
if(filename_len > 0) {
if ((status = mapObj_setFontSet(php_map->map,
@@ -2805,9 +2832,9 @@ PHP_METHOD(mapObj, selectOutputFormat)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- if (php_map->outputformat)
- php_outputformat = (php_outputformat_object *) zend_object_store_get_object(php_map->outputformat TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
+ if (ZVAL_NOT_UNDEF(php_map->outputformat))
+ php_outputformat = MAPSCRIPT_OBJ(php_outputformat_object, php_map->outputformat);
if ((status = mapObj_selectOutputFormat(php_map->map,
type)) != MS_SUCCESS)
@@ -2815,7 +2842,7 @@ PHP_METHOD(mapObj, selectOutputFormat)
{
mapscript_report_php_error(E_WARNING, "Unable to set output format to '%s'" TSRMLS_CC,
type);
- } else if (php_map->outputformat) {
+ } else if (ZVAL_NOT_UNDEF(php_map->outputformat)) {
php_outputformat->outputformat = php_map->map->outputformat;
}
@@ -2841,8 +2868,8 @@ PHP_METHOD(mapObj, appendOutputFormat)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_outputformat = (php_outputformat_object *) zend_object_store_get_object(zoutputformat TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
+ php_outputformat = MAPSCRIPT_OBJ_P(php_outputformat_object, zoutputformat);
retval = msAppendOutputFormat(php_map->map, php_outputformat->outputformat);
@@ -2868,7 +2895,7 @@ PHP_METHOD(mapObj, removeOutputFormat)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
if ((status = msRemoveOutputFormat(php_map->map, name)) != MS_SUCCESS)
@@ -2898,7 +2925,7 @@ PHP_METHOD(mapObj, getOutputFormat)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
if (index < 0 || index >= php_map->map->numoutputformats) {
mapscript_throw_mapserver_exception("Invalid outputformat index." TSRMLS_CC);
@@ -2928,7 +2955,7 @@ PHP_METHOD(mapObj, saveMapContext)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
if(filename_len > 0) {
if ((status = mapObj_saveMapContext(php_map->map, filename)) != MS_SUCCESS) {
@@ -2961,7 +2988,7 @@ PHP_METHOD(mapObj, loadMapContext)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
if(filename_len > 0) {
if ((status = mapObj_loadMapContext(php_map->map, filename, unique)) != MS_SUCCESS) {
@@ -2994,7 +3021,7 @@ PHP_METHOD(mapObj, applySLD)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
status = mapObj_applySLD(php_map->map, sldxml);
@@ -3021,7 +3048,7 @@ PHP_METHOD(mapObj, applySLDURL)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
status = mapObj_applySLDURL(php_map->map, sldurl);
@@ -3044,16 +3071,16 @@ PHP_METHOD(mapObj, generateSLD)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
buffer = mapObj_generateSLD(php_map->map);
if (buffer) {
- RETVAL_STRING(buffer, 1);
+ MAPSCRIPT_RETVAL_STRING(buffer, 1);
free(buffer);
} else {
mapscript_report_mapserver_error(E_WARNING TSRMLS_CC);
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
}
}
/* }}} */
@@ -3078,12 +3105,12 @@ PHP_METHOD(mapObj, getConfigOption)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
if ((value = (char *)msGetConfigOption(php_map->map, key)) == NULL) {
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
} else {
- RETURN_STRING(value, 1);
+ MAPSCRIPT_RETURN_STRING(value, 1);
}
}
/* }}} */
@@ -3107,7 +3134,7 @@ PHP_METHOD(mapObj, setConfigOption)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
msSetConfigOption(php_map->map, key,value);
@@ -3129,7 +3156,7 @@ PHP_METHOD(mapObj, applyConfigOptions)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
msApplyMapConfigOptions(php_map->map);
RETURN_LONG(MS_SUCCESS);
@@ -3158,8 +3185,8 @@ PHP_METHOD(mapObj, loadOwsParameters)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_request = (php_owsrequest_object *) zend_object_store_get_object(zrequest TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
+ php_request = MAPSCRIPT_OBJ_P(php_owsrequest_object, zrequest);
if (!version) {
version = strdup("1.1.1");
@@ -3193,8 +3220,8 @@ PHP_METHOD(mapObj, owsDispatch)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_request = (php_owsrequest_object *) zend_object_store_get_object(zrequest TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
+ php_request = MAPSCRIPT_OBJ_P(php_owsrequest_object, zrequest);
status = mapObj_OWSDispatch(php_map->map, php_request->cgirequest);
@@ -3221,8 +3248,8 @@ PHP_METHOD(mapObj, insertLayer)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_layer = (php_layer_object *) zend_object_store_get_object(zlayer TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zlayer);
if ((retval = mapObj_insertLayer(php_map->map, php_layer->layer, index)) < 0) {
@@ -3254,7 +3281,7 @@ PHP_METHOD(mapObj, removeLayer)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
if ((layer = mapObj_removeLayer(php_map->map, index)) == NULL) {
mapscript_throw_mapserver_exception("" TSRMLS_CC);
@@ -3287,7 +3314,7 @@ PHP_METHOD(mapObj, getLabel)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
labelCacheMember=mapObj_getLabel(php_map->map, index);
@@ -3316,14 +3343,14 @@ PHP_METHOD(mapObj, convertToString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
value = mapObj_convertToString(php_map->map);
if (value == NULL)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -3352,7 +3379,7 @@ PHP_METHOD(mapObj, getLatLongExtent)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
geoRefExt.minx = php_map->map->extent.minx;
geoRefExt.miny = php_map->map->extent.miny;
@@ -3389,7 +3416,7 @@ PHP_METHOD(mapObj, free)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zobj);
MAPSCRIPT_DELREF(php_map->outputformat);
MAPSCRIPT_DELREF(php_map->extent);
@@ -3505,10 +3532,10 @@ static int mapscript_map_setProjection(int isWKTProj, php_map_object *php_map,
php_projection_object *php_projection = NULL;
php_rect_object *php_extent = NULL;
- if (php_map->projection)
- php_projection = (php_projection_object *) zend_object_store_get_object(php_map->projection TSRMLS_CC);
- if (php_map->extent)
- php_extent = (php_rect_object *) zend_object_store_get_object(php_map->extent TSRMLS_CC);
+ if (ZVAL_NOT_UNDEF(php_map->projection))
+ php_projection = MAPSCRIPT_OBJ(php_projection_object, php_map->projection);
+ if (ZVAL_NOT_UNDEF(php_map->extent))
+ php_extent = MAPSCRIPT_OBJ(php_rect_object, php_map->extent);
in = php_map->map->projection;
msInitProjection(&out);
@@ -3535,7 +3562,7 @@ static int mapscript_map_setProjection(int isWKTProj, php_map_object *php_map,
if (status == -1) {
mapscript_report_php_error(E_WARNING, "setProjection failed" TSRMLS_CC);
return MS_FAILURE;
- } else if (php_map->projection) {
+ } else if (ZVAL_NOT_UNDEF(php_map->projection)) {
php_projection->projection = &(php_map->map->projection);
}
@@ -3554,7 +3581,7 @@ static int mapscript_map_setProjection(int isWKTProj, php_map_object *php_map,
msCalculateScale(php_map->map->extent, php_map->map->units, php_map->map->width, php_map->map->height,
php_map->map->resolution, &(php_map->map->scaledenom));
- if (php_map->extent)
+ if (ZVAL_NOT_UNDEF(php_map->extent))
php_extent->rect = &(php_map->map->extent);
}
}
@@ -3570,10 +3597,103 @@ void mapscript_create_map(mapObj *map, zval *return_value TSRMLS_DC)
{
php_map_object * php_map;
object_init_ex(return_value, mapscript_ce_map);
- php_map = (php_map_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, return_value);
php_map->map = map;
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_map_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_map_object *php_map;
+
+ php_map = ecalloc(1, sizeof(*php_map) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_map->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_map->zobj, ce);
+
+ php_map->zobj.handlers = &mapscript_map_object_handlers;
+
+ ZVAL_UNDEF(&php_map->outputformat);
+ ZVAL_UNDEF(&php_map->extent);
+ ZVAL_UNDEF(&php_map->web);
+ ZVAL_UNDEF(&php_map->reference);
+ ZVAL_UNDEF(&php_map->imagecolor);
+ ZVAL_UNDEF(&php_map->scalebar);
+ ZVAL_UNDEF(&php_map->legend);
+ ZVAL_UNDEF(&php_map->querymap);
+#ifdef disabled
+ ZVAL_UNDEF(&php_map->labelcache);
+#endif
+ ZVAL_UNDEF(&php_map->projection);
+ ZVAL_UNDEF(&php_map->metadata);
+ ZVAL_UNDEF(&php_map->configoptions);
+
+ return &php_map->zobj;
+}
+
+static void mapscript_map_free_object(zend_object *object)
+{
+ php_map_object *php_map;
+
+ php_map = (php_map_object *)((char *)object - XtOffsetOf(php_map_object, zobj));
+
+ MAPSCRIPT_DELREF(php_map->outputformat);
+ MAPSCRIPT_DELREF(php_map->extent);
+ MAPSCRIPT_DELREF(php_map->web);
+ MAPSCRIPT_DELREF(php_map->reference);
+ MAPSCRIPT_DELREF(php_map->imagecolor);
+ MAPSCRIPT_DELREF(php_map->scalebar);
+ MAPSCRIPT_DELREF(php_map->legend);
+ MAPSCRIPT_DELREF(php_map->querymap);
+#ifdef disabled
+ MAPSCRIPT_DELREF(php_map->labelcache);
+#endif
+ MAPSCRIPT_DELREF(php_map->projection);
+ MAPSCRIPT_DELREF(php_map->metadata);
+ MAPSCRIPT_DELREF(php_map->configoptions);
+
+ mapObj_destroy(php_map->map);
+
+ zend_object_std_dtor(object);
+}
+
+static zend_object* mapscript_map_clone_object(zval *zobj)
+{
+ php_map_object *php_map_old, *php_map_new;
+ zend_object* zobj_new;
+
+ php_map_old = MAPSCRIPT_OBJ_P(php_map_object, zobj);
+
+ zobj_new = mapscript_map_create_object(mapscript_ce_map);
+ php_map_new = (php_map_object *)((char *)zobj_new - XtOffsetOf(php_map_object, zobj));
+
+ zend_objects_clone_members(&php_map_new->zobj, &php_map_old->zobj);
+
+ php_map_new->map = mapObj_clone(php_map_old->map);
+
+ return zobj_new;
+}
+
+PHP_MINIT_FUNCTION(map)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "mapObj", map_functions);
+ mapscript_ce_map = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_map->create_object = mapscript_map_create_object;
+ mapscript_ce_map->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_map_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_map_object_handlers));
+ mapscript_map_object_handlers.free_obj = mapscript_map_free_object;
+ mapscript_map_object_handlers.clone_obj = mapscript_map_clone_object;
+ mapscript_map_object_handlers.offset = XtOffsetOf(php_map_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_map_object_destroy(void *object TSRMLS_DC)
{
php_map_object *php_map = (php_map_object *)object;
@@ -3641,7 +3761,7 @@ static zend_object_value mapscript_map_object_clone(zval *zobj TSRMLS_DC)
php_map_object *php_map_old, *php_map_new;
zend_object_value new_ov;
- php_map_old = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_map_old = MAPSCRIPT_OBJ_P(php_map_object, zobj);
new_ov = mapscript_map_object_new_ex(mapscript_ce_map, &php_map_new TSRMLS_CC);
zend_objects_clone_members(&php_map_new->std, new_ov, &php_map_old->std, Z_OBJ_HANDLE_P(zobj) TSRMLS_CC);
@@ -3667,4 +3787,4 @@ PHP_MINIT_FUNCTION(map)
return SUCCESS;
}
-
+#endif
diff --git a/mapscript/php/mapscript_error.c b/mapscript/php/mapscript_error.c
index e2bef8ae5..dccf066d6 100644
--- a/mapscript/php/mapscript_error.c
+++ b/mapscript/php/mapscript_error.c
@@ -39,7 +39,11 @@
zend_class_entry *mapscript_ce_mapscriptexception;
+#if PHP_VERSION_ID >= 70000
+zend_object* mapscript_throw_exception(char *format TSRMLS_DC, ...)
+#else
zval* mapscript_throw_exception(char *format TSRMLS_DC, ...)
+#endif
{
va_list args;
char message[MAX_EXCEPTION_MSG];
@@ -53,7 +57,11 @@ zval* mapscript_throw_exception(char *format TSRMLS_DC, ...)
return zend_throw_exception(mapscript_ce_mapscriptexception, message, 0 TSRMLS_CC);
}
+#if PHP_VERSION_ID >= 70000
+zend_object* mapscript_throw_mapserver_exception(char *format TSRMLS_DC, ...)
+#else
zval* mapscript_throw_mapserver_exception(char *format TSRMLS_DC, ...)
+#endif
{
va_list args;
char message[MAX_EXCEPTION_MSG];
@@ -111,7 +119,12 @@ PHP_MINIT_FUNCTION(mapscript_error)
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "MapScriptException", NULL);
+
+#if PHP_VERSION_ID >= 70000
+ mapscript_ce_mapscriptexception = zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C));
+#else
mapscript_ce_mapscriptexception = zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C), "Exception" TSRMLS_CC);
+#endif
return SUCCESS;
}
diff --git a/mapscript/php/outputformat.c b/mapscript/php/outputformat.c
index a6dca9435..887a2de07 100644
--- a/mapscript/php/outputformat.c
+++ b/mapscript/php/outputformat.c
@@ -32,6 +32,9 @@
#include "php_mapscript.h"
zend_class_entry *mapscript_ce_outputformat;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_outputformat_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(outputformat___construct_args, 0, 0, 1)
ZEND_ARG_INFO(0, driver)
@@ -79,7 +82,7 @@ PHP_METHOD(outputFormatObj, __construct)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_outputformat = (php_outputformat_object *)zend_object_store_get_object(zobj TSRMLS_CC);
+ php_outputformat = MAPSCRIPT_OBJ_P(php_outputformat_object, zobj);
if ((php_outputformat->outputformat = outputFormatObj_new(driver, name)) == NULL) {
mapscript_throw_exception("Unable to construct outputFormatObj." TSRMLS_CC);
@@ -103,7 +106,7 @@ PHP_METHOD(outputFormatObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_outputformat = (php_outputformat_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_outputformat = MAPSCRIPT_OBJ_P(php_outputformat_object, zobj);
IF_GET_STRING("name", php_outputformat->outputformat->name)
@@ -136,7 +139,7 @@ PHP_METHOD(outputFormatObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_outputformat = (php_outputformat_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_outputformat = MAPSCRIPT_OBJ_P(php_outputformat_object, zobj);
IF_SET_STRING("name", php_outputformat->outputformat->name, value)
else IF_SET_STRING("mimetype", php_outputformat->outputformat->mimetype, value)
@@ -174,7 +177,7 @@ PHP_METHOD(outputFormatObj, setOption)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_outputformat = (php_outputformat_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_outputformat = MAPSCRIPT_OBJ_P(php_outputformat_object, zobj);
msSetOutputFormatOption(php_outputformat->outputformat, property, value);
@@ -201,11 +204,11 @@ PHP_METHOD(outputFormatObj, getOption)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_outputformat = (php_outputformat_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_outputformat = MAPSCRIPT_OBJ_P(php_outputformat_object, zobj);
value = msGetOutputFormatOption(php_outputformat->outputformat, property, "");
- RETURN_STRING((char*)value,1);
+ MAPSCRIPT_RETURN_STRING((char*)value,1);
}
/* }}} */
@@ -226,7 +229,7 @@ PHP_METHOD(outputFormatObj, validate)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_outputformat = (php_outputformat_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_outputformat = MAPSCRIPT_OBJ_P(php_outputformat_object, zobj);
status = msOutputFormatValidate(php_outputformat->outputformat, MS_TRUE);
if (status != MS_TRUE) {
@@ -253,19 +256,19 @@ PHP_METHOD(outputFormatObj, getOptionByIndex)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_outputformat = (php_outputformat_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_outputformat = MAPSCRIPT_OBJ_P(php_outputformat_object, zobj);
if (index < 0 || index >= php_outputformat->outputformat->numformatoptions) {
mapscript_throw_mapserver_exception("Invalid format option index." TSRMLS_CC);
return;
}
- RETURN_STRING(php_outputformat->outputformat->formatoptions[index],1);
+ MAPSCRIPT_RETURN_STRING(php_outputformat->outputformat->formatoptions[index],1);
}
/* }}} */
zend_function_entry outputformat_functions[] = {
- PHP_ME(outputFormatObj, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
+ PHP_ME(outputFormatObj, __construct, outputformat___construct_args, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(outputFormatObj, __get, outputformat___get_args, ZEND_ACC_PUBLIC)
PHP_ME(outputFormatObj, __set, outputformat___set_args, ZEND_ACC_PUBLIC)
PHP_MALIAS(outputFormatObj, set, __set, NULL, ZEND_ACC_PUBLIC)
@@ -281,16 +284,69 @@ void mapscript_create_outputformat(outputFormatObj *outputformat, parent_object
{
php_outputformat_object * php_outputformat;
object_init_ex(return_value, mapscript_ce_outputformat);
- php_outputformat = (php_outputformat_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_outputformat = MAPSCRIPT_OBJ_P(php_outputformat_object, return_value);
php_outputformat->outputformat = outputformat;
- if (parent.val)
+ if(ZVAL_NOT_UNDEF(parent.val))
php_outputformat->is_ref = 1;
php_outputformat->parent = parent;
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_outputformat_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_outputformat_object *php_outputformat;
+
+ php_outputformat = ecalloc(1, sizeof(*php_outputformat) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_outputformat->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_outputformat->zobj, ce);
+
+ php_outputformat->zobj.handlers = &mapscript_outputformat_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_outputformat->parent);
+ php_outputformat->is_ref = 0;
+
+ return &php_outputformat->zobj;
+}
+
+static void mapscript_outputformat_free_object(zend_object *object)
+{
+ php_outputformat_object *php_outputformat;
+
+ php_outputformat = (php_outputformat_object *)((char *)object - XtOffsetOf(php_outputformat_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_outputformat->parent);
+
+ if (php_outputformat->outputformat && !php_outputformat->is_ref) {
+ outputFormatObj_destroy(php_outputformat->outputformat);
+ }
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(outputformat)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "outputFormatObj", outputformat_functions);
+ mapscript_ce_outputformat = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_outputformat->create_object = mapscript_outputformat_create_object;
+ mapscript_ce_outputformat->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_outputformat_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_outputformat_object_handlers));
+ mapscript_outputformat_object_handlers.free_obj = mapscript_outputformat_free_object;
+ mapscript_outputformat_object_handlers.offset = XtOffsetOf(php_outputformat_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
+
static void mapscript_outputformat_object_destroy(void *object TSRMLS_DC)
{
php_outputformat_object *php_outputformat = (php_outputformat_object *)object;
@@ -335,3 +391,4 @@ PHP_MINIT_FUNCTION(outputformat)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/owsrequest.c b/mapscript/php/owsrequest.c
index 11d999609..ce4a05362 100644
--- a/mapscript/php/owsrequest.c
+++ b/mapscript/php/owsrequest.c
@@ -39,6 +39,9 @@
char *owsrequest_getenv(const char *name, void *thread_context);
zend_class_entry *mapscript_ce_owsrequest;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_owsrequest_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(owsrequest___get_args, 0, 0, 1)
ZEND_ARG_INFO(0, property)
@@ -86,7 +89,7 @@ PHP_METHOD(OWSRequestObj, __construct)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_owsrequest = (php_owsrequest_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_owsrequest = MAPSCRIPT_OBJ_P(php_owsrequest_object, zobj);
if ((request = cgirequestObj_new()) == NULL) {
mapscript_throw_mapserver_exception("" TSRMLS_CC);
@@ -112,7 +115,7 @@ PHP_METHOD(OWSRequestObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_owsrequest = (php_owsrequest_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_owsrequest = MAPSCRIPT_OBJ_P(php_owsrequest_object, zobj);
IF_GET_LONG("numparams", php_owsrequest->cgirequest->NumParams)
@@ -157,24 +160,24 @@ PHP_METHOD(OWSRequestObj, __set)
PHP_METHOD(OWSRequestObj, loadParams)
{
zval *zobj = getThis();
- zval **val;
+ MAPSCRIPT_ZVAL_P val;
php_owsrequest_object *php_owsrequest;
void *thread_context;
+ PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
+ if (zend_parse_parameters_none() == FAILURE) {
+ PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
+ return;
+ }
+ PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
+
#ifdef ZTS
thread_context = (void*)TSRMLS_C;
#else
thread_context = NULL;
#endif
- //PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
- if (zend_parse_parameters_none() == FAILURE) {
- //PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- return;
- }
- //PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
-
- php_owsrequest = (php_owsrequest_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_owsrequest = MAPSCRIPT_OBJ_P(php_owsrequest_object, zobj);
if ( (STRING_EQUAL(sapi_module.name,"cli")) ||
(STRING_EQUAL(sapi_module.name,"cgi")) ||
@@ -184,6 +187,15 @@ PHP_METHOD(OWSRequestObj, loadParams)
// check if we have input data for GET method
if (SG(request_info).request_method &&
STRING_EQUAL(SG(request_info).request_method, "GET")) {
+#if PHP_VERSION_ID >= 70000
+ zend_is_auto_global_str("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC);
+ if ( !Z_ISUNDEF(PG(http_globals)[TRACK_VARS_SERVER]) &&
+ ((val = zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), "QUERY_STRING", sizeof("QUERY_STRING")-1)) != NULL) &&
+ (Z_TYPE_P(val) == IS_STRING) &&
+ (Z_STRLEN_P(val) > 0) ) {
+ cgirequestObj_loadParams(php_owsrequest->cgirequest, owsrequest_getenv, NULL, 0, thread_context);
+ }
+#else
zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC);
if ( PG(http_globals)[TRACK_VARS_SERVER] &&
(zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "QUERY_STRING", sizeof("QUERY_STRING"), (void **) &val) == SUCCESS) &&
@@ -191,24 +203,40 @@ PHP_METHOD(OWSRequestObj, loadParams)
(Z_STRLEN_PP(val) > 0) ) {
cgirequestObj_loadParams(php_owsrequest->cgirequest, owsrequest_getenv, NULL, 0, thread_context);
}
+#endif
} else {
#if PHP_VERSION_ID >= 50600
php_stream *s = php_stream_temp_new();
php_stream *input = php_stream_open_wrapper("php://input", "r", 0, NULL);
+#if PHP_VERSION_ID >= 70000
+ zend_string *raw_post_data = NULL;
+#else
char *raw_post_data = NULL;
long raw_post_data_length = 0;
+#endif
/* php://input does not support stat */
php_stream_copy_to_stream_ex(input, s, -1, NULL);
php_stream_close(input);
php_stream_rewind(s);
+
- raw_post_data_length = php_stream_copy_to_mem(s, raw_post_data, -1, 0);
+#if PHP_VERSION_ID >= 70000
+ raw_post_data = php_stream_copy_to_mem(s, -1, 0);
+
+ cgirequestObj_loadParams(php_owsrequest->cgirequest, owsrequest_getenv,
+ ZSTR_VAL(raw_post_data),
+ ZSTR_LEN(raw_post_data), thread_context);
+
+ if(raw_post_data) zend_string_free(raw_post_data);
+#else
+ raw_post_data_length = php_stream_copy_to_mem(s, raw_post_data, -1, 0);
cgirequestObj_loadParams(php_owsrequest->cgirequest, owsrequest_getenv,
raw_post_data,
raw_post_data_length, thread_context);
+#endif
#else
cgirequestObj_loadParams(php_owsrequest->cgirequest, owsrequest_getenv,
SG(request_info).raw_post_data,
@@ -240,7 +268,7 @@ PHP_METHOD(OWSRequestObj, setParameter)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_owsrequest = (php_owsrequest_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_owsrequest = MAPSCRIPT_OBJ_P(php_owsrequest_object, zobj);
cgirequestObj_setParameter(php_owsrequest->cgirequest, name, value);
@@ -267,7 +295,7 @@ PHP_METHOD(OWSRequestObj, addParameter)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_owsrequest = (php_owsrequest_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_owsrequest = MAPSCRIPT_OBJ_P(php_owsrequest_object, zobj);
cgirequestObj_addParameter(php_owsrequest->cgirequest, name, value);
@@ -276,7 +304,7 @@ PHP_METHOD(OWSRequestObj, addParameter)
/* }}} */
/* {{{ proto string owsrequest.getName(int index)
- Return the name of the parameter at index in the requests array of parameter names. */
+ Return the name of the parameter at index in the request's array of parameter names. */
PHP_METHOD(OWSRequestObj, getName)
{
long index;
@@ -292,13 +320,13 @@ PHP_METHOD(OWSRequestObj, getName)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_owsrequest = (php_owsrequest_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_owsrequest = MAPSCRIPT_OBJ_P(php_owsrequest_object, zobj);
value = cgirequestObj_getName(php_owsrequest->cgirequest, index);
if (!value)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETURN_STRING(value,1);
+ MAPSCRIPT_RETURN_STRING(value,1);
}
/* }}} */
@@ -319,13 +347,13 @@ PHP_METHOD(OWSRequestObj, getValue)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_owsrequest = (php_owsrequest_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_owsrequest = MAPSCRIPT_OBJ_P(php_owsrequest_object, zobj);
value = cgirequestObj_getValue(php_owsrequest->cgirequest, index);
if (!value)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETURN_STRING(value,1);
+ MAPSCRIPT_RETURN_STRING(value,1);
}
/* }}} */
@@ -347,13 +375,13 @@ PHP_METHOD(OWSRequestObj, getValueByName)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_owsrequest = (php_owsrequest_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_owsrequest = MAPSCRIPT_OBJ_P(php_owsrequest_object, zobj);
value = cgirequestObj_getValueByName(php_owsrequest->cgirequest, name);
if (!value)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETURN_STRING(value,1);
+ MAPSCRIPT_RETURN_STRING(value,1);
}
/* }}} */
@@ -371,6 +399,7 @@ zend_function_entry owsrequest_functions[] = {
}
};
+#if PHP_VERSION_ID < 70000
char *owsrequest_getenv(const char *name, void *thread_context)
{
zval **val, **ppzval;
@@ -410,15 +439,108 @@ char *owsrequest_getenv(const char *name, void *thread_context)
return NULL;
}
+#else
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+char *owsrequest_getenv(const char *name, void *thread_context)
+{
+ zval *val, *ppzval;
+ zval cookie_result;
+ HashTable *cookies;
+ zend_string *string_key;
+ zend_string *result = NULL;
+ zend_ulong num_key;
+ size_t len, sum = 0;
+ int i = 0;
+ TSRMLS_FETCH_FROM_CTX(thread_context);
+
+ if (STRING_EQUAL(name, "HTTP_COOKIE")) {
+ cookies = Z_ARRVAL(PG(http_globals)[TRACK_VARS_COOKIE]);
+ for(zend_hash_internal_pointer_reset(cookies);
+ zend_hash_has_more_elements(cookies) == SUCCESS;
+ zend_hash_move_forward(cookies), ++i) {
+ ppzval = zend_hash_get_current_data(cookies);
+ zend_hash_get_current_key(cookies, &string_key, &num_key);
+ len = (ZSTR_LEN(string_key)+Z_STRLEN_P(ppzval)+2) * sizeof(char);
+ if(!result)
+ result = zend_string_alloc(len, 1);
+ else
+ result = zend_string_extend(result, sum + len, 1);
+ sprintf(&result->val[sum], "%s=%s;",ZSTR_VAL(string_key),Z_STRVAL_P(ppzval));
+ sum += len;
+ }
+ if (result){
+ ZVAL_STRINGL(&cookie_result, ZSTR_VAL(result), ZSTR_LEN(result));
+ zend_string_free(result);
+ return Z_STRVAL(cookie_result); /* this string will stay in memory until php-script exit */
+ }
+ else
+ return "";
+ } else {
+ zend_is_auto_global_str("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC);
+ if ( (!Z_ISUNDEF(PG(http_globals)[TRACK_VARS_SERVER])) &&
+ ((val = zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), name, strlen(name))) != NULL) &&
+ (Z_TYPE_P(val) == IS_STRING)) {
+ return Z_STRVAL_P(val);
+ }
+ }
+
+ return NULL;
+}
+#endif
void mapscript_create_owsrequest(cgiRequestObj *cgirequest, zval *return_value TSRMLS_DC)
{
php_owsrequest_object * php_owsrequest;
object_init_ex(return_value, mapscript_ce_owsrequest);
- php_owsrequest = (php_owsrequest_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_owsrequest = MAPSCRIPT_OBJ_P(php_owsrequest_object, return_value);
php_owsrequest->cgirequest = cgirequest;
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_owsrequest_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_owsrequest_object *php_owsrequest;
+
+ php_owsrequest = ecalloc(1, sizeof(*php_owsrequest) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_owsrequest->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_owsrequest->zobj, ce);
+
+ php_owsrequest->zobj.handlers = &mapscript_owsrequest_object_handlers;
+
+ return &php_owsrequest->zobj;
+}
+
+static void mapscript_owsrequest_free_object(zend_object *object)
+{
+ php_owsrequest_object *php_owsrequest;
+
+ php_owsrequest = (php_owsrequest_object *)((char *)object - XtOffsetOf(php_owsrequest_object, zobj));
+
+ cgirequestObj_destroy(php_owsrequest->cgirequest);
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(owsrequest)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "OWSRequestObj", owsrequest_functions);
+ mapscript_ce_owsrequest = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_owsrequest->create_object = mapscript_owsrequest_create_object;
+ mapscript_ce_owsrequest->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_owsrequest_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_owsrequest_object_handlers));
+ mapscript_owsrequest_object_handlers.free_obj = mapscript_owsrequest_free_object;
+ mapscript_owsrequest_object_handlers.offset = XtOffsetOf(php_owsrequest_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_owsrequest_object_destroy(void *object TSRMLS_DC)
{
php_owsrequest_object *php_owsrequest = (php_owsrequest_object *)object;
@@ -455,4 +577,4 @@ PHP_MINIT_FUNCTION(owsrequest)
return SUCCESS;
}
-
+#endif
diff --git a/mapscript/php/php_mapscript.c b/mapscript/php/php_mapscript.c
index 5ef38461f..37aa1ddea 100644
--- a/mapscript/php/php_mapscript.c
+++ b/mapscript/php/php_mapscript.c
@@ -197,9 +197,9 @@ PHP_FUNCTION(ms_newLayerObj)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *)zend_object_store_get_object(zmap TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zmap);
if (zlayer)
- php_layer = (php_layer_object *)zend_object_store_get_object(zlayer TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zlayer);
if ((layer = layerObj_new(php_map->map)) == NULL) {
mapscript_throw_mapserver_exception("" TSRMLS_CC);
@@ -260,7 +260,7 @@ PHP_FUNCTION(ms_newRectObj)
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
object_init_ex(return_value, mapscript_ce_rect);
- php_rect = (php_rect_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_rect = MAPSCRIPT_OBJ_P(php_rect_object, return_value);
if ((php_rect->rect = rectObj_new()) == NULL) {
mapscript_throw_exception("Unable to construct rectObj." TSRMLS_CC);
@@ -314,7 +314,7 @@ PHP_FUNCTION(ms_newLineObj)
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
object_init_ex(return_value, mapscript_ce_line);
- php_line = (php_line_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_line = MAPSCRIPT_OBJ_P(php_line_object, return_value);
if ((php_line->line = lineObj_new()) == NULL) {
mapscript_throw_exception("Unable to construct lineObj." TSRMLS_CC);
@@ -342,9 +342,9 @@ PHP_FUNCTION(ms_newStyleObj)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_class = (php_class_object *)zend_object_store_get_object(zclass TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zclass);
if (zstyle)
- php_style = (php_style_object *)zend_object_store_get_object(zstyle TSRMLS_CC);
+ php_style = MAPSCRIPT_OBJ_P(php_style_object, zstyle);
if ((style = styleObj_new(php_class->class, (zstyle ? php_style->style : NULL))) == NULL) {
mapscript_throw_mapserver_exception("" TSRMLS_CC);
@@ -375,9 +375,9 @@ PHP_FUNCTION(ms_newClassObj)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zlayer TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zlayer);
if (zclass)
- php_class = (php_class_object *) zend_object_store_get_object(zclass TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zclass);
if ((class = classObj_new(php_layer->layer, (zclass ? php_class->class:NULL))) == NULL) {
@@ -409,7 +409,7 @@ PHP_FUNCTION(ms_newSymbolObj)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_map = (php_map_object *)zend_object_store_get_object(zmap TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zmap);
retval = msAddNewSymbol(php_map->map, symbolName);
@@ -433,7 +433,7 @@ PHP_FUNCTION(ms_newShapeObj)
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
object_init_ex(return_value, mapscript_ce_shape);
- php_shape = (php_shape_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, return_value);
if ((php_shape->shape = shapeObj_new(type)) == NULL) {
mapscript_throw_exception("Unable to construct shapeObj." TSRMLS_CC);
@@ -441,7 +441,7 @@ PHP_FUNCTION(ms_newShapeObj)
}
MAKE_STD_ZVAL(php_shape->values);
- array_init(php_shape->values);
+ mapscript_array_init(php_shape->values);
}
/* }}} */
@@ -462,7 +462,7 @@ PHP_FUNCTION(ms_shapeObjFromWkt)
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
object_init_ex(return_value, mapscript_ce_shape);
- php_shape = (php_shape_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, return_value);
if ((php_shape->shape = msShapeFromWKT(wkt)) == NULL) {
mapscript_throw_exception("Unable to construct shapeObj." TSRMLS_CC);
@@ -470,7 +470,7 @@ PHP_FUNCTION(ms_shapeObjFromWkt)
}
MAKE_STD_ZVAL(php_shape->values);
- array_init(php_shape->values);
+ mapscript_array_init(php_shape->values);
}
/* }}} */
@@ -538,7 +538,7 @@ PHP_FUNCTION(ms_newGridObj)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_layer = (php_layer_object *) zend_object_store_get_object(zlayer TSRMLS_CC);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zlayer);
php_layer->layer->connectiontype = MS_GRATICULE;
@@ -550,19 +550,29 @@ PHP_FUNCTION(ms_newGridObj)
php_layer->layer->grid = (graticuleObj *)malloc( sizeof( graticuleObj ) );
initGrid(php_layer->layer->grid);
- if (php_layer->grid && (Z_TYPE_P(php_layer->grid) == IS_OBJECT)) {
- php_grid = (php_grid_object *) zend_object_store_get_object(php_layer->grid TSRMLS_CC);
+ if (ZVAL_NOT_UNDEF(php_layer->grid) && (MAPSCRIPT_TYPE(php_layer->grid) == IS_OBJECT)) {
+ php_grid = MAPSCRIPT_OBJ(php_grid_object, php_layer->grid);
php_grid->parent.child_ptr = NULL;
+#if PHP_VERSION_ID < 70000
zend_objects_store_del_ref(php_layer->grid TSRMLS_CC);
+#else
+ MAPSCRIPT_DELREF(php_layer->grid);
+#endif
}
MAKE_STD_ZVAL(php_layer->grid);
MAPSCRIPT_MAKE_PARENT(zlayer, &php_layer->grid);
+#if PHP_VERSION_ID < 70000
mapscript_create_grid((graticuleObj *)(php_layer->layer->grid), parent, php_layer->grid TSRMLS_CC);
zend_objects_store_add_ref(php_layer->grid TSRMLS_CC);
*return_value = *(php_layer->grid);
+#else
+ mapscript_create_grid((graticuleObj *)(php_layer->layer->grid), parent, &php_layer->grid TSRMLS_CC);
+
+ ZVAL_COPY_VALUE(return_value, &php_layer->grid);
+#endif
}
/* }}} */
@@ -616,7 +626,7 @@ PHP_FUNCTION(ms_GetVersion)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- RETURN_STRING(msGetVersion(), 1);
+ MAPSCRIPT_RETURN_STRING(msGetVersion(), 1);
}
/************************************************************************/
@@ -685,7 +695,7 @@ PHP_FUNCTION(ms_ioGetStdoutBufferString)
buffer = (char *) (buf->data);
- RETURN_STRINGL(buffer, buf->data_offset, 1);
+ MAPSCRIPT_RETURN_STRINGL(buffer, buf->data_offset, 1);
}
@@ -732,12 +742,35 @@ PHP_FUNCTION(ms_ioStripStdoutBufferContentType)
buf = msIO_stripStdoutBufferContentType();
if (buf) {
- RETURN_STRING((char *)buf, 1);
+ MAPSCRIPT_RETURN_STRING((char *)buf, 1);
} else {
RETURN_FALSE;
}
}
+PHP_FUNCTION(ms_ioGetAndStripStdoutBufferMimeHeaders)
+{
+ hashTableObj *hashtable;
+ char *value, *key = NULL;
+
+ if((hashtable = msIO_getAndStripStdoutBufferMimeHeaders())) {
+
+ array_init(return_value);
+
+ while((key = hashTableObj_nextKey(hashtable, key))) {
+ value = (char *) hashTableObj_get(hashtable, key);
+#if PHP_VERSION_ID < 70000
+ add_assoc_string(return_value, key, value, 1);
+#else
+ add_assoc_string(return_value, key, value);
+#endif
+ }
+ free(hashtable);
+ }
+ else
+ RETURN_FALSE;
+}
+
PHP_FUNCTION(ms_ioStripStdoutBufferContentHeaders)
{
msIO_stripStdoutBufferContentHeaders();
@@ -783,7 +816,7 @@ PHP_FUNCTION(ms_getCwd)
RETURN_FALSE;
}
- RETURN_STRING(buffer, 1);
+ MAPSCRIPT_RETURN_STRING(buffer, 1);
}
PHP_FUNCTION(ms_getPid)
@@ -824,7 +857,7 @@ PHP_FUNCTION(ms_getScale)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_geoRefExt = (php_rect_object *)zend_object_store_get_object(zgeoRefExt TSRMLS_CC);
+ php_geoRefExt = MAPSCRIPT_OBJ_P(php_rect_object, zgeoRefExt);
if (msCalculateScale(*(php_geoRefExt->rect), unit, width, height, resolution, &dfScale) != MS_SUCCESS) {
mapscript_throw_mapserver_exception("" TSRMLS_CC);
@@ -870,7 +903,11 @@ PHP_FUNCTION(ms_tokenizeMap)
}
for (i=0; i<numtokens; i++) {
+#if PHP_VERSION_ID < 70000
add_next_index_string(return_value, tokens[i], 1);
+#else
+ add_next_index_string(return_value, tokens[i]);
+#endif
}
msFreeCharArray(tokens, numtokens);
@@ -909,6 +946,7 @@ zend_function_entry mapscript_functions[] = {
PHP_FE(ms_ioResetHandlers, NULL)
PHP_FE(ms_ioStripStdoutBufferContentType, NULL)
PHP_FE(ms_ioStripStdoutBufferContentHeaders, NULL)
+ PHP_FE(ms_ioGetAndStripStdoutBufferMimeHeaders, NULL)
PHP_FE(ms_ioGetStdoutBufferBytes, NULL) {
NULL, NULL, NULL
}
diff --git a/mapscript/php/php_mapscript.h b/mapscript/php/php_mapscript.h
index d961fb930..740aa4899 100644
--- a/mapscript/php/php_mapscript.h
+++ b/mapscript/php/php_mapscript.h
@@ -61,6 +61,71 @@
#define MAPSCRIPT_VERSION "($Revision$ $Date$)"
+#define MAPSCRIPT_VERSION "($Revision$ $Date$)"
+
+#if PHP_VERSION_ID >= 70000
+#define MAPSCRIPT_ZVAL zval
+#define MAPSCRIPT_ZVAL_P zval*
+
+#define Z_DVAL_PP(zv) Z_DVAL_P(zv)
+#define Z_LVAL_PP(zv) Z_LVAL_P(zv)
+#define Z_STRVAL_PP(zv) Z_STRVAL_P(zv)
+
+#define MAPSCRIPT_OBJ_P(t, o) (t *)((char *)(Z_OBJ_P(o)) - XtOffsetOf(t, zobj))
+#define MAPSCRIPT_OBJ(t, o) (t *)((char *)(Z_OBJ(o)) - XtOffsetOf(t, zobj))
+#define MAPSCRIPT_RETURN_STRINGL(a, b, c) RETURN_STRINGL(a, b)
+#define MAPSCRIPT_RETURN_STRING(a, b) RETURN_STRING(a)
+#define MAPSCRIPT_RETVAL_STRING(a, b) RETVAL_STRING(a)
+#define MAPSCRIPT_RETURN_STRINGL(a, b, c) RETURN_STRINGL(a, b)
+#define MAPSCRIPT_ZVAL_STRING(a, b, c) ZVAL_STRING(a, b)
+
+#define mapscript_is_auto_global(s, l) zend_is_auto_global_str(s, l)
+#define mapscript_array_init(zv) array_init(&zv)
+#define mapscript_add_next_index_string(a, b, c) add_next_index_string(a, b)
+#define mapscript_add_assoc_string(zv, b, c, d) add_assoc_string(&zv, b, c)
+#define mapscript_hash_get_current_key(a, b, c, d) zend_hash_get_current_key(a, b, c)
+#define mapscript_hash_update(ht, keyname, data) \
+ zend_hash_str_update(ht, keyname, strlen(keyname)+1, &data);
+
+#define MAPSCRIPT_TYPE(zv) Z_TYPE(zv)
+#define MAPSCRIPT_OBJCE(zv) Z_OBJCE(zv)
+#define MAKE_STD_ZVAL(zv) ZVAL_UNDEF(&zv)
+#define ZVAL_NOT_UNDEF(zv) !(Z_ISUNDEF(zv))
+#define ZVAL_IS_UNDEF(zv) (Z_ISUNDEF(zv))
+#define ZVAL_SET_UNDEF(zv) ZVAL_UNDEF(&zv)
+#define INIT_ZVAL(zv)
+#define INIT_PZVAL(a)
+
+#else
+
+#define MAPSCRIPT_ZVAL zval*
+#define MAPSCRIPT_ZVAL_P zval**
+
+#define MAPSCRIPT_OBJ_P(t, o) (t *) zend_object_store_get_object(o TSRMLS_CC)
+#define MAPSCRIPT_OBJ(t, o) (t *) zend_object_store_get_object(o TSRMLS_CC)
+#define MAPSCRIPT_RETURN_STRINGL(a, b, c) RETURN_STRINGL(a, b, c)
+#define MAPSCRIPT_RETURN_STRING(a, b) RETURN_STRING(a, b)
+#define MAPSCRIPT_RETVAL_STRING(a, b) RETVAL_STRING(a, b)
+#define MAPSCRIPT_RETVAL_STRINGL(a, b, c) RETURN_STRINGL(a, b, c)
+#define MAPSCRIPT_ZVAL_STRING(a, b, c) ZVAL_STRING(a, b, c)
+
+#define mapscript_is_auto_global(s, l) zend_is_auto_global(s, l)
+#define mapscript_array_init(zv) array_init(zv)
+#define mapscript_add_next_index_string(a, b, c) add_next_index_string(a, b, c)
+#define mapscript_add_assoc_string(a, b, c, d) add_assoc_string(a, b, c, d)
+#define mapscript_hash_get_current_key(a, b, c, d) zend_hash_get_current_key(a, b, c, d)
+#define mapscript_hash_update(ht, key, data) \
+ zend_hash_update(Z_ARRVAL_P(return_value), key, strlen(key)+1, &data, sizeof(data), NULL)
+
+#define MAPSCRIPT_TYPE(zv) Z_TYPE_P(zv)
+#define MAPSCRIPT_OBJCE(zv) Z_OBJCE_P(zv)
+#define ZVAL_NOT_UNDEF(zv) (zv != NULL)
+#define ZVAL_IS_UNDEF(zv) (zv == NULL)
+#define ZVAL_SET_UNDEF(zv) zv = NULL
+
+#endif
+
+
extern zend_module_entry mapscript_module_entry;
#define phpext_mapscript_ptr &mapscript_module_entry
@@ -104,6 +169,252 @@ extern zend_module_entry mapscript_module_entry;
#endif
/* MapScript objects */
+#if PHP_VERSION_ID >= 70000
+typedef struct _parent_object {
+ zval val; // the zval of the parent
+ zval *child_ptr; // a ptr to a parent property, which is the zval of the child object.
+ // should be set to NULL when the child is destroyed
+} parent_object;
+
+typedef struct _php_color_object {
+ parent_object parent;
+ colorObj *color;
+ zend_object zobj;
+} php_color_object;
+
+typedef struct _php_rect_object {
+ parent_object parent;
+ int is_ref;
+ rectObj *rect;
+ zend_object zobj;
+} php_rect_object;
+
+typedef struct _php_hashtable_object {
+ parent_object parent;
+ hashTableObj *hashtable;
+ zend_object zobj;
+} php_hashtable_object;
+
+typedef struct _php_symbol_object {
+ parent_object parent;
+ symbolObj *symbol;
+ zend_object zobj;
+} php_symbol_object;
+
+typedef struct _php_class_object {
+ parent_object parent; //old layer
+ zval metadata;
+ zval leader;
+ classObj *class;
+ zend_object zobj;
+} php_class_object;
+
+typedef struct _php_image_object {
+ imageObj *image;
+ zend_object zobj;
+} php_image_object;
+
+typedef struct _php_web_object {
+ parent_object parent;
+ zval extent;
+ zval metadata;
+ zval validation;
+ webObj *web;
+ zend_object zobj;
+} php_web_object;
+
+typedef struct _php_legend_object {
+ parent_object parent;
+ zval outlinecolor;
+ zval label;
+ zval imagecolor;
+ legendObj *legend;
+ zend_object zobj;
+} php_legend_object;
+
+typedef struct _php_outputformat_object {
+ parent_object parent;
+ int is_ref;
+ outputFormatObj *outputformat;
+ zend_object zobj;
+} php_outputformat_object;
+
+typedef struct _php_querymap_object {
+ parent_object parent;
+ zval color;
+ queryMapObj *querymap;
+ zend_object zobj;
+} php_querymap_object;
+
+typedef struct _php_grid_object {
+ parent_object parent;
+ graticuleObj *grid;
+ zend_object zobj;
+} php_grid_object;
+
+typedef struct _php_error_object {
+ errorObj *error;
+ zend_object zobj;
+} php_error_object;
+
+typedef struct _php_referencemap_object {
+ parent_object parent;
+ zval extent;
+ zval color;
+ zval outlinecolor;
+ referenceMapObj *referencemap;
+ zend_object zobj;
+} php_referencemap_object;
+
+typedef struct _php_label_object {
+ parent_object parent;
+ int is_ref;
+ zval color;
+ zval outlinecolor;
+ zval shadowcolor;
+ zval backgroundcolor;
+ zval backgroundshadowcolor;
+ zval leader;
+ labelObj *label;
+ zend_object zobj;
+} php_label_object;
+
+typedef struct _php_style_object {
+ parent_object parent;
+ zval color;
+ zval outlinecolor;
+ zval backgroundcolor;
+ zval mincolor;
+ zval maxcolor;
+ styleObj *style;
+ zend_object zobj;
+} php_style_object;
+
+typedef struct _php_projection_object {
+ parent_object parent;
+ int is_ref;
+ projectionObj *projection;
+ zend_object zobj;
+} php_projection_object;
+
+typedef struct _php_point_object {
+ parent_object parent;
+ int is_ref;
+ pointObj *point;
+ zend_object zobj;
+} php_point_object;
+
+typedef struct _php_line_object {
+ parent_object parent;
+ int is_ref;
+ lineObj *line;
+ zend_object zobj;
+} php_line_object;
+
+typedef struct _php_shape_object {
+ parent_object parent;
+ zval bounds;
+ zval values;
+ int is_ref;
+ shapeObj *shape;
+ zend_object zobj;
+} php_shape_object;
+
+typedef struct _php_shapefile_object {
+ zval bounds;
+ shapefileObj *shapefile;
+ zend_object zobj;
+} php_shapefile_object;
+
+#ifdef disabled
+typedef struct _php_labelcache_object {
+ parent_object parent;
+ labelCacheObj *labelcache;
+ zend_object zobj;
+} php_labelcache_object;
+#endif
+
+typedef struct _php_labelleader_object {
+ parent_object parent;
+ labelLeaderObj *labelleader;
+ zend_object zobj;
+} php_labelleader_object;
+
+#ifdef disabled
+typedef struct _php_labelcachemember_object {
+ parent_object parent;
+ zval labels; /* should be immutable */
+ zval point; /* should be immutable */
+ zval styles; /* should be immutable */
+ zval poly; /* should be immutable */
+ labelCacheMemberObj *labelcachemember;
+ zend_object zobj;
+} php_labelcachemember_object;
+#endif
+
+typedef struct _php_result_object {
+ parent_object parent;
+ resultObj *result;
+ zend_object zobj;
+} php_result_object;
+
+typedef struct _php_scalebar_object {
+ parent_object parent;
+ zval color;
+ zval backgroundcolor;
+ zval outlinecolor;
+ zval label;
+ zval imagecolor;
+ scalebarObj *scalebar;
+ zend_object zobj;
+} php_scalebar_object;
+
+typedef struct _php_owsrequest_object {
+ cgiRequestObj *cgirequest;
+ zend_object zobj;
+} php_owsrequest_object;
+
+typedef struct _php_layer_object {
+ parent_object parent; //old map
+ zval offsite;
+ zval grid;
+ zval metadata;
+ zval bindvals;
+ zval projection;
+ zval cluster;
+ zval extent;
+ int is_ref;
+ layerObj *layer;
+ zend_object zobj;
+} php_layer_object;
+
+typedef struct _php_map_object {
+ zval outputformat;
+ zval extent;
+ zval web;
+ zval reference;
+ zval imagecolor;
+ zval scalebar;
+ zval legend;
+ zval querymap;
+#ifdef disabled
+ zval labelcache;
+#endif
+ zval projection;
+ zval metadata;
+ zval configoptions;
+ mapObj *map;
+ zend_object zobj;
+} php_map_object;
+
+typedef struct _php_cluster_object {
+ parent_object parent;
+ int is_ref;
+ clusterObj *cluster;
+ zend_object zobj;
+} php_cluster_object;
+#else
+/* PHP5 object structs */
typedef struct _parent_object {
zval *val; // the zval of the parent
zval **child_ptr; // a ptr to a parent property, which point to the child object.
@@ -347,6 +658,7 @@ typedef struct _php_cluster_object {
int is_ref;
clusterObj *cluster;
} php_cluster_object;
+#endif
/* Lifecyle functions*/
PHP_MINIT_FUNCTION(mapscript);
@@ -403,6 +715,7 @@ PHP_FUNCTION(ms_ioGetStdoutBufferString);
PHP_FUNCTION(ms_ioResetHandlers);
PHP_FUNCTION(ms_ioStripStdoutBufferContentType);
PHP_FUNCTION(ms_ioStripStdoutBufferContentHeaders);
+PHP_FUNCTION(ms_ioGetAndStripStdoutBufferMimeHeaders);
PHP_FUNCTION(ms_ioGetStdoutBufferBytes);
/* object constructors */
@@ -457,14 +770,17 @@ extern zend_class_entry *mapscript_ce_layer;
extern zend_class_entry *mapscript_ce_map;
extern zend_class_entry *mapscript_ce_cluster;
+#if PHP_VERSION_ID < 70000
/* PHP Object constructors */
extern zend_object_value mapscript_object_new(zend_object *zobj, zend_class_entry *ce,
void (*zend_objects_free_object) TSRMLS_DC);
extern zend_object_value mapscript_object_new_ex(zend_object *zobj, zend_class_entry *ce,
void (*zend_objects_free_object),
zend_object_handlers *object_handlers TSRMLS_DC);
+#endif /* PHP_VERSION_ID < 70000 */
+
extern void mapscript_fetch_object(zend_class_entry *ce, zval* zval_parent, php_layer_object* layer,
- void *internal_object, zval **php_object_storage TSRMLS_DC);
+ void *internal_object, MAPSCRIPT_ZVAL_P php_object_storage TSRMLS_DC);
extern void mapscript_create_color(colorObj *color, parent_object parent, zval *return_value TSRMLS_DC);
extern void mapscript_create_rect(rectObj *rect, parent_object php_parent, zval *return_value TSRMLS_DC);
extern void mapscript_create_hashtable(hashTableObj *hashtable, parent_object parent, zval *return_value TSRMLS_DC);
@@ -504,9 +820,17 @@ extern void mapscript_create_cluster(clusterObj *cluster, parent_object php_pare
/* Exported functions for PHP Mapscript API */
/* throw a MapScriptException */
+#if PHP_VERSION_ID >= 70000
+extern zend_object * mapscript_throw_exception(char *format TSRMLS_DC, ...);
+#else
extern zval * mapscript_throw_exception(char *format TSRMLS_DC, ...);
+#endif
/* print all MapServer errors (as Warning) and throw a MapScriptException */
+#if PHP_VERSION_ID >= 70000
+extern zend_object* mapscript_throw_mapserver_exception(char *format TSRMLS_DC, ...);
+#else
extern zval* mapscript_throw_mapserver_exception(char *format TSRMLS_DC, ...);
+#endif
extern void mapscript_report_mapserver_error(int error_type TSRMLS_DC);
extern void mapscript_report_php_error(int error_type, char *format TSRMLS_DC, ...);
diff --git a/mapscript/php/php_mapscript_util.c b/mapscript/php/php_mapscript_util.c
index fc681bd7e..eaa83b21a 100644
--- a/mapscript/php/php_mapscript_util.c
+++ b/mapscript/php/php_mapscript_util.c
@@ -31,7 +31,7 @@
#include "php_mapscript_util.h"
#include "../../maperror.h"
-
+#if PHP_VERSION_ID < 70000
zend_object_value mapscript_object_new(zend_object *zobj,
zend_class_entry *ce,
void (*zend_objects_free_object) TSRMLS_DC)
@@ -78,22 +78,37 @@ zend_object_value mapscript_object_new_ex(zend_object *zobj,
retval.handlers = object_handlers;
return retval;
}
+#endif /* PHP_VERSION_ID < 70000 */
int mapscript_extract_associative_array(HashTable *php, char **array)
{
- zval **value;
+ MAPSCRIPT_ZVAL_P value;
+#if PHP_VERSION_ID < 70000
char *string_key = NULL;
ulong num_key;
+#else
+ zend_string *string_key = NULL;
+ zend_ulong num_key;
+#endif
+
int i = 0;
for(zend_hash_internal_pointer_reset(php);
zend_hash_has_more_elements(php) == SUCCESS;
zend_hash_move_forward(php)) {
+#if PHP_VERSION_ID < 70000
zend_hash_get_current_data(php, (void **)&value);
+#else
+ value = zend_hash_get_current_data(php);
+#endif
- switch (zend_hash_get_current_key(php, &string_key, &num_key, 1)) {
+ switch (mapscript_hash_get_current_key(php, &string_key, &num_key, 1)) {
case HASH_KEY_IS_STRING:
+#if PHP_VERSION_ID < 70000
array[i++] = string_key;
+#else
+ array[i++] = ZSTR_VAL(string_key);
+#endif
array[i++] = Z_STRVAL_PP(value);
break;
}
@@ -107,64 +122,70 @@ int mapscript_extract_associative_array(HashTable *php, char **array)
otherwise it creates it */
void mapscript_fetch_object(zend_class_entry *ce, zval* zval_parent, php_layer_object* layer,
void *internal_object,
- zval **php_object_storage TSRMLS_DC)
+ MAPSCRIPT_ZVAL_P php_object_storage TSRMLS_DC)
{
parent_object p;
// create the parent struct
+#if PHP_VERSION_ID < 70000
p.val = zval_parent;
+ #define mapscript_fetch_object_return_value *php_object_storage
+#else
+ p.val = *zval_parent;
+ #define mapscript_fetch_object_return_value php_object_storage
+#endif
p.child_ptr = &*php_object_storage;
MAKE_STD_ZVAL(*php_object_storage);
if (ce == mapscript_ce_outputformat)
- mapscript_create_outputformat((outputFormatObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_outputformat((outputFormatObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_color)
- mapscript_create_color((colorObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_color((colorObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_rect)
- mapscript_create_rect((rectObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_rect((rectObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_class)
- mapscript_create_class((classObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_class((classObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_hashtable)
- mapscript_create_hashtable((hashTableObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_hashtable((hashTableObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_label)
- mapscript_create_label((labelObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_label((labelObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_style)
- mapscript_create_style((styleObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_style((styleObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_symbol)
- mapscript_create_symbol((symbolObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_symbol((symbolObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
#ifdef disabled
else if (ce == mapscript_ce_labelcachemember)
- mapscript_create_labelcachemember((labelCacheMemberObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_labelcachemember((labelCacheMemberObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_labelcache)
- mapscript_create_labelcache((labelCacheObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_labelcache((labelCacheObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
#endif
else if (ce == mapscript_ce_result)
- mapscript_create_result((resultObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_result((resultObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_scalebar)
- mapscript_create_scalebar((scalebarObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_scalebar((scalebarObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_web)
- mapscript_create_web((webObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_web((webObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_legend)
- mapscript_create_legend((legendObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_legend((legendObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_querymap)
- mapscript_create_querymap((queryMapObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_querymap((queryMapObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_grid)
- mapscript_create_grid((graticuleObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_grid((graticuleObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_referencemap)
- mapscript_create_referencemap((referenceMapObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_referencemap((referenceMapObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_point)
- mapscript_create_point((pointObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_point((pointObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_projection)
- mapscript_create_projection((projectionObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_projection((projectionObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_line)
- mapscript_create_line((lineObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_line((lineObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_shape)
- mapscript_create_shape((shapeObj*)internal_object, p, layer, *php_object_storage TSRMLS_CC);
+ mapscript_create_shape((shapeObj*)internal_object, p, layer, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_layer)
- mapscript_create_layer((layerObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_layer((layerObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_cluster)
- mapscript_create_cluster((clusterObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_cluster((clusterObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
else if (ce == mapscript_ce_labelleader)
- mapscript_create_labelleader((labelLeaderObj*)internal_object, p, *php_object_storage TSRMLS_CC);
+ mapscript_create_labelleader((labelLeaderObj*)internal_object, p, mapscript_fetch_object_return_value TSRMLS_CC);
}
diff --git a/mapscript/php/php_mapscript_util.h b/mapscript/php/php_mapscript_util.h
index 73ae02df6..bccfd169b 100644
--- a/mapscript/php/php_mapscript_util.h
+++ b/mapscript/php/php_mapscript_util.h
@@ -36,6 +36,8 @@
#include "php_globals.h"
#include "php_mapscript.h"
+#if PHP_VERSION_ID < 70000
+
#if ZEND_MODULE_API_NO < 20010901
#define TSRMLS_D void
#define TSRMLS_DC
@@ -141,9 +143,30 @@ static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isre
#define MAPSCRIPT_FREE_OBJECT(zobj) \
zend_hash_destroy(zobj->std.properties); \
FREE_HASHTABLE(zobj->std.properties);
+#endif /* PHP_VERSION_ID < 70000 */
+#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
+#if PHP_VERSION_ID >= 70000
+#ifndef _zval_dtor_func_for_ptr
+//use _zval_dtor_func in PHP7.1 instead
+#define _zval_dtor_func_for_ptr _zval_dtor_func
+#endif
+#define MAPSCRIPT_DELREF(zv) \
+ if (!(Z_ISUNDEF(zv))) \
+ { \
+ zend_refcounted *_gc = Z_COUNTED_P(&zv); \
+ if(--GC_REFCOUNT(_gc) == 0) \
+ _zval_dtor_func_for_ptr(_gc); \
+ ZVAL_UNDEF(&zv); \
+ }
+#else
#define MAPSCRIPT_DELREF(zobj) \
if (zobj) \
{ \
@@ -155,11 +178,25 @@ static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isre
} \
zobj = NULL; \
}
+#endif
+
+#if PHP_VERSION_ID >= 70000
+#define MAPSCRIPT_FREE_PARENT(parent) \
+ if (parent.child_ptr) \
+ ZVAL_UNDEF(parent.child_ptr); \
+ MAPSCRIPT_DELREF(parent.val);
+#define MAPSCRIPT_MAKE_PARENT(zobj, ptr) \
+ if(zobj == NULL) \
+ ZVAL_UNDEF(&parent.val); \
+ else \
+ ZVAL_COPY_VALUE(&parent.val, zobj); \
+ parent.child_ptr = ptr;
#define MAPSCRIPT_INIT_PARENT(parent) \
- parent.val = NULL; \
+ ZVAL_UNDEF(&parent.val); \
parent.child_ptr = NULL;
+#else
#define MAPSCRIPT_FREE_PARENT(parent) \
if (parent.child_ptr) \
@@ -170,12 +207,35 @@ static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isre
parent.val = zobj; \
parent.child_ptr = ptr;
+#define MAPSCRIPT_INIT_PARENT(parent) \
+ parent.val = NULL; \
+ parent.child_ptr = NULL;
+#endif
+
+#if PHP_VERSION_ID >= 70000
+
+#define MAPSCRIPT_CALL_METHOD_1(zobj, function_name, retval, arg1) \
+ zend_call_method_with_1_params(&zobj, Z_OBJCE(zobj), NULL, function_name, &retval, arg1);
+
+#define MAPSCRIPT_CALL_METHOD_2(zobj, function_name, retval, arg1, arg2) \
+ zend_call_method_with_2_params(&zobj, Z_OBJCE(zobj), NULL, function_name, &retval, arg1, arg2);
+
+#define MAPSCRIPT_CALL_METHOD_2_P(zobj, function_name, retval, arg1, arg2) \
+ zend_call_method_with_2_params(zobj, Z_OBJCE_P(zobj), NULL, function_name, &retval, arg1, arg2);
+
+#else
+
#define MAPSCRIPT_CALL_METHOD_1(zobj, function_name, retval, arg1) \
zend_call_method_with_1_params(&zobj, Z_OBJCE_P(zobj), NULL, function_name, &retval, arg1);
#define MAPSCRIPT_CALL_METHOD_2(zobj, function_name, retval, arg1, arg2) \
zend_call_method_with_2_params(&zobj, Z_OBJCE_P(zobj), NULL, function_name, &retval, arg1, arg2);
+#define MAPSCRIPT_CALL_METHOD_2_P(zobj, function_name, retval, arg1, arg2) \
+ MAPSCRIPT_CALL_METHOD_2(zobj, function_name, retval, arg1, arg2)
+
+#endif /* PHP_VERSION_ID */
+
#define STRING_EQUAL(string1, string2) \
strcmp(string1, string2) == 0
@@ -183,7 +243,7 @@ static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isre
#define IF_GET_STRING(property_name, value) \
if (strcmp(property, property_name)==0) \
{ \
- RETVAL_STRING( (value ? value:"") , 1); \
+ MAPSCRIPT_RETVAL_STRING( (value ? value:"") , 1); \
} \
#define IF_GET_LONG(property_name, value) \
@@ -198,6 +258,17 @@ static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isre
RETVAL_DOUBLE(value); \
} \
+#if PHP_VERSION_ID >= 70000
+#define IF_GET_OBJECT(property_name, mapscript_ce, php_object_storage, internal_object) \
+ if (strcmp(property, property_name)==0) \
+ { \
+ if (Z_ISUNDEF(php_object_storage)) { \
+ mapscript_fetch_object(mapscript_ce, zobj, NULL, (void*)internal_object, \
+ &php_object_storage TSRMLS_CC); \
+ } \
+ RETURN_ZVAL(&php_object_storage, 1, 0); \
+ }
+#else
#define IF_GET_OBJECT(property_name, mapscript_ce, php_object_storage, internal_object) \
if (strcmp(property, property_name)==0) \
{ \
@@ -207,12 +278,21 @@ static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isre
} \
RETURN_ZVAL(php_object_storage, 1, 0); \
}
+#endif
+#if PHP_VERSION_ID >= 70000
#define CHECK_OBJECT(mapscript_ce, php_object_storage, internal_object) \
- if (!php_object_storage) { \
+ if (Z_ISUNDEF(php_object_storage)) { \
mapscript_fetch_object(mapscript_ce, zobj, NULL, (void*)internal_object, \
&php_object_storage TSRMLS_CC); \
}
+#else
+#define CHECK_OBJECT(mapscript_ce, php_object_storage, internal_object) \
+ if (!php_object_storage) { \
+ mapscript_fetch_object(mapscript_ce, zobj, NULL, (void*)internal_object, \
+ &php_object_storage TSRMLS_CC); \
+ }
+#endif
/* helpers for setters */
#define IF_SET_STRING(property_name, internal, value) \
@@ -257,10 +337,11 @@ static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isre
internal = Z_LVAL_P(value); \
}
-
+#if PHP_VERSION_ID < 70000
zend_object_value mapscript_object_new(zend_object *zobj,
zend_class_entry *ce,
void (*zend_objects_free_object) TSRMLS_DC);
+#endif /* PHP_VERSION_ID < 70000 */
int mapscript_extract_associative_array(HashTable *php, char **array);
diff --git a/mapscript/php/point.c b/mapscript/php/point.c
index 5e6299fa8..719ffd7ae 100644
--- a/mapscript/php/point.c
+++ b/mapscript/php/point.c
@@ -32,6 +32,9 @@
#include "php_mapscript.h"
zend_class_entry *mapscript_ce_point;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_point_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(point___get_args, 0, 0, 1)
ZEND_ARG_INFO(0, property)
@@ -94,7 +97,7 @@ PHP_METHOD(pointObj, __construct)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_point = (php_point_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, getThis());
if ((php_point->point = pointObj_new()) == NULL) {
mapscript_throw_exception("Unable to construct pointObj." TSRMLS_CC);
@@ -125,7 +128,7 @@ PHP_METHOD(pointObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_point = (php_point_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, zobj);
IF_GET_DOUBLE("x", php_point->point->x)
else IF_GET_DOUBLE("y", php_point->point->y)
@@ -154,7 +157,7 @@ PHP_METHOD(pointObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_point = (php_point_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, zobj);
IF_SET_DOUBLE("x", php_point->point->x, value)
else IF_SET_DOUBLE("y", php_point->point->y, value)
@@ -184,7 +187,7 @@ PHP_METHOD(pointObj, setXY)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_point = (php_point_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, zobj);
php_point->point->x = x;
php_point->point->y = y;
@@ -216,7 +219,7 @@ PHP_METHOD(pointObj, setXYZ)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_point = (php_point_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, zobj);
php_point->point->x = x;
php_point->point->y = y;
@@ -253,9 +256,9 @@ PHP_METHOD(pointObj, project)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_point = (php_point_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_proj_in = (php_projection_object *) zend_object_store_get_object(zobj_proj_in TSRMLS_CC);
- php_proj_out = (php_projection_object *) zend_object_store_get_object(zobj_proj_out TSRMLS_CC);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, zobj);
+ php_proj_in = MAPSCRIPT_OBJ_P(php_projection_object, zobj_proj_in);
+ php_proj_out = MAPSCRIPT_OBJ_P(php_projection_object, zobj_proj_out);
status = pointObj_project(php_point->point, php_proj_in->projection, php_proj_out->projection);
if (status != MS_SUCCESS) {
@@ -283,8 +286,8 @@ PHP_METHOD(pointObj, distanceToPoint)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_point = (php_point_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_point2 = (php_point_object *) zend_object_store_get_object(zobj_point2 TSRMLS_CC);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, zobj);
+ php_point2 = MAPSCRIPT_OBJ_P(php_point_object, zobj_point2);
distance = pointObj_distanceToPoint(php_point->point, php_point2->point);
@@ -311,9 +314,9 @@ PHP_METHOD(pointObj, distanceToLine)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_point = (php_point_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_line_point = (php_point_object *) zend_object_store_get_object(zobj_line_point TSRMLS_CC);
- php_line_point2 = (php_point_object *) zend_object_store_get_object(zobj_line_point2 TSRMLS_CC);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, zobj);
+ php_line_point = MAPSCRIPT_OBJ_P(php_point_object, zobj_line_point);
+ php_line_point2 = MAPSCRIPT_OBJ_P(php_point_object, zobj_line_point2);
distance = pointObj_distanceToLine(php_point->point, php_line_point->point, php_line_point2->point);
@@ -339,8 +342,8 @@ PHP_METHOD(pointObj, distanceToShape)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_point = (php_point_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, zobj);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
distance = pointObj_distanceToShape(php_point->point, php_shape->shape);
@@ -374,10 +377,10 @@ PHP_METHOD(pointObj, draw)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_point = (php_point_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_map = (php_map_object *) zend_object_store_get_object(zmap TSRMLS_CC);
- php_layer = (php_layer_object *) zend_object_store_get_object(zlayer TSRMLS_CC);
- php_image = (php_image_object *) zend_object_store_get_object(zimage TSRMLS_CC);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, zobj);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zmap);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zlayer);
+ php_image = MAPSCRIPT_OBJ_P(php_image_object, zimage);
if ((status = pointObj_draw(php_point->point, php_map->map, php_layer->layer, php_image->image,
classIndex, text)) != MS_SUCCESS) {
@@ -410,16 +413,91 @@ void mapscript_create_point(pointObj *point, parent_object parent, zval *return_
{
php_point_object * php_point;
object_init_ex(return_value, mapscript_ce_point);
- php_point = (php_point_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, return_value);
php_point->point = point;
- if (parent.val)
+ if (ZVAL_NOT_UNDEF(parent.val))
php_point->is_ref = 1;
php_point->parent = parent;
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_point_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_point_object *php_point;
+
+ php_point = ecalloc(1, sizeof(*php_point) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_point->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_point->zobj, ce);
+
+ php_point->zobj.handlers = &mapscript_point_object_handlers;
+
+ php_point->is_ref = 0;
+ MAPSCRIPT_INIT_PARENT(php_point->parent);
+
+ return &php_point->zobj;
+}
+
+static void mapscript_point_free_object(zend_object *object)
+{
+ php_point_object *php_point;
+
+ php_point = (php_point_object *)((char *)object - XtOffsetOf(php_point_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_point->parent);
+
+ if (php_point->point && !php_point->is_ref) {
+ pointObj_destroy(php_point->point);
+ }
+
+ zend_object_std_dtor(object);
+}
+
+static zend_object* mapscript_point_clone_object(zval *zobj)
+{
+ php_point_object *php_point_old, *php_point_new;
+ zend_object* zobj_new;
+
+ php_point_old = MAPSCRIPT_OBJ_P(php_point_object, zobj);
+
+ zobj_new = mapscript_point_create_object(mapscript_ce_point);
+ php_point_new = (php_point_object *)((char *)zobj_new - XtOffsetOf(php_point_object, zobj));
+
+ zend_objects_clone_members(&php_point_new->zobj, &php_point_old->zobj);
+
+ if ((php_point_new->point = pointObj_new()) == NULL) {
+ mapscript_throw_exception("Unable to construct pointObj." TSRMLS_CC);
+ return NULL;
+ }
+ memcpy(php_point_new->point, php_point_old->point, sizeof(pointObj));
+
+ return zobj_new;
+}
+
+PHP_MINIT_FUNCTION(point)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "pointObj", point_functions);
+ mapscript_ce_point = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_point->create_object = mapscript_point_create_object;
+ mapscript_ce_point->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_point_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_point_object_handlers));
+ mapscript_point_object_handlers.free_obj = mapscript_point_free_object;
+ mapscript_point_object_handlers.clone_obj = mapscript_point_clone_object;
+ mapscript_point_object_handlers.offset = XtOffsetOf(php_point_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
+
static void mapscript_point_object_destroy(void *object TSRMLS_DC)
{
php_point_object *php_point = (php_point_object *)object;
@@ -464,3 +542,4 @@ PHP_MINIT_FUNCTION(point)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/projection.c b/mapscript/php/projection.c
index 46b74c165..d7e9c1633 100644
--- a/mapscript/php/projection.c
+++ b/mapscript/php/projection.c
@@ -57,7 +57,7 @@ PHP_METHOD(projectionObj, __construct)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_projection = (php_projection_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
+ php_projection = MAPSCRIPT_OBJ_P(php_projection_object, getThis());
if ((php_projection->projection = projectionObj_new(projString)) == NULL) {
mapscript_throw_mapserver_exception("Unable to construct projectionObj." TSRMLS_CC);
@@ -82,7 +82,7 @@ PHP_METHOD(projectionObj, setWKTProjection)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_projection = (php_projection_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
+ php_projection = MAPSCRIPT_OBJ_P(php_projection_object, getThis());
RETURN_LONG(msOGCWKT2ProjectionObj(wkt, php_projection->projection, MS_FALSE));
}
@@ -101,7 +101,7 @@ PHP_METHOD(projectionObj, getUnits)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_projection = (php_projection_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
+ php_projection = MAPSCRIPT_OBJ_P(php_projection_object, getThis());
RETURN_LONG(projectionObj_getUnits(php_projection->projection));
}
@@ -120,16 +120,86 @@ void mapscript_create_projection(projectionObj *projection, parent_object parent
{
php_projection_object * php_projection;
object_init_ex(return_value, mapscript_ce_projection);
- php_projection = (php_projection_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_projection = MAPSCRIPT_OBJ_P(php_projection_object, return_value);
php_projection->projection = projection;
- if (parent.val)
+ if (ZVAL_NOT_UNDEF(parent.val))
php_projection->is_ref = 1;
php_projection->parent = parent;
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_projection_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_projection_object *php_projection;
+
+ php_projection = ecalloc(1, sizeof(*php_projection) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_projection->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_projection->zobj, ce);
+
+ php_projection->zobj.handlers = &mapscript_projection_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_projection->parent);
+ php_projection->is_ref = 0;
+
+ return &php_projection->zobj;
+}
+
+static void mapscript_projection_free_object(zend_object *object)
+{
+ php_projection_object *php_projection;
+
+ php_projection = (php_projection_object *)((char *)object - XtOffsetOf(php_projection_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_projection->parent);
+
+ if (php_projection->projection && !php_projection->is_ref) {
+ projectionObj_destroy(php_projection->projection);
+ }
+
+ zend_object_std_dtor(object);
+}
+
+static zend_object* mapscript_projection_clone_object(zval *zobj)
+{
+ php_projection_object *php_projection_old, *php_projection_new;
+ zend_object* zobj_new;
+
+ php_projection_old = MAPSCRIPT_OBJ_P(php_projection_object, zobj);
+
+ zobj_new = mapscript_projection_create_object(mapscript_ce_projection);
+ php_projection_new = (php_projection_object *)((char *)zobj_new - XtOffsetOf(php_projection_object, zobj));
+
+ zend_objects_clone_members(&php_projection_new->zobj, &php_projection_old->zobj);
+
+ php_projection_new->projection = projectionObj_clone(php_projection_old->projection);
+
+ return zobj_new;
+}
+
+PHP_MINIT_FUNCTION(projection)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "projectionObj", projection_functions);
+ mapscript_ce_projection = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_projection->create_object = mapscript_projection_create_object;
+ mapscript_ce_projection->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_projection_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_projection_object_handlers));
+ mapscript_projection_object_handlers.free_obj = mapscript_projection_free_object;
+ mapscript_projection_object_handlers.clone_obj = mapscript_projection_clone_object;
+ mapscript_projection_object_handlers.offset = XtOffsetOf(php_projection_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_projection_object_destroy(void *object TSRMLS_DC)
{
php_projection_object *php_projection = (php_projection_object *)object;
@@ -175,7 +245,7 @@ static zend_object_value mapscript_projection_object_clone(zval *zobj TSRMLS_DC)
php_projection_object *php_projection_old, *php_projection_new;
zend_object_value new_ov;
- php_projection_old = (php_projection_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_projection_old = MAPSCRIPT_OBJ_P(php_projection_object, zobj);
new_ov = mapscript_projection_object_new_ex(mapscript_ce_projection, &php_projection_new TSRMLS_CC);
zend_objects_clone_members(&php_projection_new->std, new_ov, &php_projection_old->std, Z_OBJ_HANDLE_P(zobj) TSRMLS_CC);
@@ -201,3 +271,4 @@ PHP_MINIT_FUNCTION(projection)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/querymap.c b/mapscript/php/querymap.c
index a76962b98..bd29d2a8c 100644
--- a/mapscript/php/querymap.c
+++ b/mapscript/php/querymap.c
@@ -32,6 +32,9 @@
#include "php_mapscript.h"
zend_class_entry *mapscript_ce_querymap;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_querymap_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(querymap___get_args, 0, 0, 1)
ZEND_ARG_INFO(0, property)
@@ -69,7 +72,7 @@ PHP_METHOD(queryMapObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_querymap = (php_querymap_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_querymap = MAPSCRIPT_OBJ_P(php_querymap_object, zobj);
IF_GET_LONG("width", php_querymap->querymap->width)
else IF_GET_LONG("height", php_querymap->querymap->height)
@@ -97,7 +100,7 @@ PHP_METHOD(queryMapObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_querymap = (php_querymap_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_querymap = MAPSCRIPT_OBJ_P(php_querymap_object, zobj);
IF_SET_LONG("width", php_querymap->querymap->width, value)
else IF_SET_LONG("height", php_querymap->querymap->height, value)
@@ -128,7 +131,7 @@ PHP_METHOD(queryMapObj, updateFromString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_querymap = (php_querymap_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_querymap = MAPSCRIPT_OBJ_P(php_querymap_object, zobj);
status = queryMapObj_updateFromString(php_querymap->querymap, snippet);
@@ -156,14 +159,14 @@ PHP_METHOD(queryMapObj, convertToString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_querymap = (php_querymap_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_querymap = MAPSCRIPT_OBJ_P(php_querymap_object, zobj);
value = queryMapObj_convertToString(php_querymap->querymap);
if (value == NULL)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -182,7 +185,7 @@ PHP_METHOD(queryMapObj, free)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_querymap = (php_querymap_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_querymap = MAPSCRIPT_OBJ_P(php_querymap_object, zobj);
MAPSCRIPT_DELREF(php_querymap->color);
}
@@ -204,7 +207,7 @@ void mapscript_create_querymap(queryMapObj *querymap, parent_object parent, zval
{
php_querymap_object * php_querymap;
object_init_ex(return_value, mapscript_ce_querymap);
- php_querymap = (php_querymap_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_querymap = MAPSCRIPT_OBJ_P(php_querymap_object, return_value);
php_querymap->querymap = querymap;
php_querymap->parent = parent;
@@ -212,6 +215,59 @@ void mapscript_create_querymap(queryMapObj *querymap, parent_object parent, zval
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_querymap_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_querymap_object *php_querymap;
+
+ php_querymap = ecalloc(1, sizeof(*php_querymap) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_querymap->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_querymap->zobj, ce);
+
+ php_querymap->zobj.handlers = &mapscript_querymap_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_querymap->parent);
+ ZVAL_UNDEF(&php_querymap->color);
+
+ return &php_querymap->zobj;
+}
+
+static void mapscript_querymap_free_object(zend_object *object)
+{
+ php_querymap_object *php_querymap;
+
+ php_querymap = (php_querymap_object *)((char *)object - XtOffsetOf(php_querymap_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_querymap->parent);
+
+ MAPSCRIPT_FREE_PARENT(php_querymap->parent);
+ MAPSCRIPT_DELREF(php_querymap->color);
+
+ /* We don't need to free the queryMapObj */
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(querymap)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "queryMapObj", querymap_functions);
+ mapscript_ce_querymap = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_querymap->create_object = mapscript_querymap_create_object;
+ mapscript_ce_querymap->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_querymap_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_querymap_object_handlers));
+ mapscript_querymap_object_handlers.free_obj = mapscript_querymap_free_object;
+ mapscript_querymap_object_handlers.offset = XtOffsetOf(php_querymap_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_querymap_object_destroy(void *object TSRMLS_DC)
{
php_querymap_object *php_querymap = (php_querymap_object *)object;
@@ -255,3 +311,4 @@ PHP_MINIT_FUNCTION(querymap)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/rect.c b/mapscript/php/rect.c
index abf44dcfc..e72a86a89 100644
--- a/mapscript/php/rect.c
+++ b/mapscript/php/rect.c
@@ -32,6 +32,9 @@
#include "php_mapscript.h"
zend_class_entry *mapscript_ce_rect;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_rect_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(rect___get_args, 0, 0, 1)
ZEND_ARG_INFO(0, property)
@@ -80,7 +83,7 @@ PHP_METHOD(rectObj, __construct)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_rect = (php_rect_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
+ php_rect = MAPSCRIPT_OBJ_P(php_rect_object, getThis());
if ((php_rect->rect = rectObj_new()) == NULL) {
mapscript_throw_exception("Unable to construct rectObj." TSRMLS_CC);
@@ -104,7 +107,7 @@ PHP_METHOD(rectObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_rect = (php_rect_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_rect = MAPSCRIPT_OBJ_P(php_rect_object, zobj);
IF_GET_DOUBLE("minx", php_rect->rect->minx)
else IF_GET_DOUBLE("miny", php_rect->rect->miny)
@@ -141,10 +144,10 @@ PHP_METHOD(rectObj, draw)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_rect = (php_rect_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_map = (php_map_object *) zend_object_store_get_object(zmap TSRMLS_CC);
- php_layer = (php_layer_object *) zend_object_store_get_object(zlayer TSRMLS_CC);
- php_image = (php_image_object *) zend_object_store_get_object(zimage TSRMLS_CC);
+ php_rect = MAPSCRIPT_OBJ_P(php_rect_object, zobj);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zmap);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zlayer);
+ php_image = MAPSCRIPT_OBJ_P(php_image_object, zimage);
if ((status = rectObj_draw(php_rect->rect, php_map->map, php_layer->layer, php_image->image,
classIndex, text)) != MS_SUCCESS) {
@@ -172,7 +175,7 @@ PHP_METHOD(rectObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_rect = (php_rect_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_rect = MAPSCRIPT_OBJ_P(php_rect_object, zobj);
IF_SET_DOUBLE("minx", php_rect->rect->minx, value)
else IF_SET_DOUBLE("miny", php_rect->rect->miny, value)
@@ -202,9 +205,9 @@ PHP_METHOD(rectObj, project)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_rect = (php_rect_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_proj_in = (php_projection_object *) zend_object_store_get_object(zobj_proj_in TSRMLS_CC);
- php_proj_out = (php_projection_object *) zend_object_store_get_object(zobj_proj_out TSRMLS_CC);
+ php_rect = MAPSCRIPT_OBJ_P(php_rect_object, zobj);
+ php_proj_in = MAPSCRIPT_OBJ_P(php_projection_object, zobj_proj_in);
+ php_proj_out = MAPSCRIPT_OBJ_P(php_projection_object, zobj_proj_out);
status = rectObj_project(php_rect->rect, php_proj_in->projection, php_proj_out->projection);
if (status != MS_SUCCESS) {
@@ -231,7 +234,7 @@ PHP_METHOD(rectObj, setExtent)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_rect = (php_rect_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_rect = MAPSCRIPT_OBJ_P(php_rect_object, zobj);
php_rect->rect->minx = minx;
php_rect->rect->miny = miny;
@@ -259,7 +262,7 @@ PHP_METHOD(rectObj, fit)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_rect = (php_rect_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_rect = MAPSCRIPT_OBJ_P(php_rect_object, zobj);
retval = rectObj_fit(php_rect->rect, width, height);
@@ -282,7 +285,7 @@ PHP_METHOD(rectObj, getCenter)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_rect = (php_rect_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
+ php_rect = MAPSCRIPT_OBJ_P(php_rect_object, getThis());
center = (pointObj *)calloc(1, sizeof(pointObj));
if (!center) {
@@ -318,16 +321,90 @@ void mapscript_create_rect(rectObj *rect, parent_object parent, zval *return_val
{
php_rect_object * php_rect;
object_init_ex(return_value, mapscript_ce_rect);
- php_rect = (php_rect_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_rect = MAPSCRIPT_OBJ_P(php_rect_object, return_value);
php_rect->rect = rect;
- if (parent.val)
+ if(ZVAL_NOT_UNDEF(parent.val))
php_rect->is_ref = 1;
php_rect->parent = parent;
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_rect_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_rect_object *php_rect;
+
+ php_rect = ecalloc(1, sizeof(*php_rect) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_rect->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_rect->zobj, ce);
+
+ php_rect->zobj.handlers = &mapscript_rect_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_rect->parent);
+ php_rect->is_ref = 0;
+
+ return &php_rect->zobj;
+}
+
+static void mapscript_rect_free_object(zend_object *object)
+{
+ php_rect_object *php_rect;
+
+ php_rect = (php_rect_object *)((char *)object - XtOffsetOf(php_rect_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_rect->parent);
+
+ if (php_rect->rect && !php_rect->is_ref) {
+ rectObj_destroy(php_rect->rect);
+ }
+
+ zend_object_std_dtor(object);
+}
+
+static zend_object* mapscript_rect_clone_object(zval *zobj)
+{
+ php_rect_object *php_rect_old, *php_rect_new;
+ zend_object* zobj_new;
+
+ php_rect_old = MAPSCRIPT_OBJ_P(php_rect_object, zobj);
+
+ zobj_new = mapscript_rect_create_object(mapscript_ce_rect);
+ php_rect_new = (php_rect_object *)((char *)zobj_new - XtOffsetOf(php_rect_object, zobj));
+
+ zend_objects_clone_members(&php_rect_new->zobj, &php_rect_old->zobj);
+
+ if ((php_rect_new->rect = rectObj_new()) == NULL) {
+ mapscript_throw_exception("Unable to construct rectObj." TSRMLS_CC);
+ return NULL;
+ }
+ memcpy(php_rect_new->rect, php_rect_old->rect, sizeof(rectObj));
+
+ return zobj_new;
+}
+
+PHP_MINIT_FUNCTION(rect)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "rectObj", rect_functions);
+ mapscript_ce_rect = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_rect->create_object = mapscript_rect_create_object;
+ mapscript_ce_rect->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_rect_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_rect_object_handlers));
+ mapscript_rect_object_handlers.free_obj = mapscript_rect_free_object;
+ mapscript_rect_object_handlers.clone_obj = mapscript_rect_clone_object;
+ mapscript_rect_object_handlers.offset = XtOffsetOf(php_rect_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_rect_object_destroy(void *object TSRMLS_DC)
{
php_rect_object *php_rect = (php_rect_object *)object;
@@ -372,3 +449,4 @@ PHP_MINIT_FUNCTION(rect)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/referencemap.c b/mapscript/php/referencemap.c
index bb0b7074b..86d0afebe 100644
--- a/mapscript/php/referencemap.c
+++ b/mapscript/php/referencemap.c
@@ -32,6 +32,9 @@
#include "php_mapscript.h"
zend_class_entry *mapscript_ce_referencemap;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_referencemap_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(referenceMap___get_args, 0, 0, 1)
ZEND_ARG_INFO(0, property)
@@ -69,7 +72,7 @@ PHP_METHOD(referenceMapObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_referencemap = (php_referencemap_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_referencemap = MAPSCRIPT_OBJ_P(php_referencemap_object, zobj);
IF_GET_STRING("image", php_referencemap->referencemap->image)
else IF_GET_LONG("width", php_referencemap->referencemap->width)
@@ -104,7 +107,7 @@ PHP_METHOD(referenceMapObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_referencemap = (php_referencemap_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_referencemap = MAPSCRIPT_OBJ_P(php_referencemap_object, zobj);
IF_SET_STRING("image", php_referencemap->referencemap->image, value)
else IF_SET_LONG("width", php_referencemap->referencemap->width, value)
@@ -142,7 +145,7 @@ PHP_METHOD(referenceMapObj, updateFromString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_referencemap = (php_referencemap_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_referencemap = MAPSCRIPT_OBJ_P(php_referencemap_object, zobj);
status = referenceMapObj_updateFromString(php_referencemap->referencemap, snippet);
@@ -170,14 +173,14 @@ PHP_METHOD(referenceMapObj, convertToString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_referencemap = (php_referencemap_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_referencemap = MAPSCRIPT_OBJ_P(php_referencemap_object, zobj);
value = referenceMapObj_convertToString(php_referencemap->referencemap);
if (value == NULL)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -196,7 +199,7 @@ PHP_METHOD(referenceMapObj, free)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_referencemap = (php_referencemap_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_referencemap = MAPSCRIPT_OBJ_P(php_referencemap_object, zobj);
MAPSCRIPT_DELREF(php_referencemap->extent);
MAPSCRIPT_DELREF(php_referencemap->color);
@@ -220,13 +223,68 @@ void mapscript_create_referencemap(referenceMapObj *referencemap, parent_object
{
php_referencemap_object * php_referencemap;
object_init_ex(return_value, mapscript_ce_referencemap);
- php_referencemap = (php_referencemap_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_referencemap = MAPSCRIPT_OBJ_P(php_referencemap_object, return_value);
php_referencemap->referencemap = referencemap;
php_referencemap->parent = parent;
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_referencemap_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_referencemap_object *php_referencemap;
+
+ php_referencemap = ecalloc(1, sizeof(*php_referencemap) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_referencemap->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_referencemap->zobj, ce);
+
+ php_referencemap->zobj.handlers = &mapscript_referencemap_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_referencemap->parent);
+ ZVAL_UNDEF(&php_referencemap->extent);
+ ZVAL_UNDEF(&php_referencemap->color);
+ ZVAL_UNDEF(&php_referencemap->outlinecolor);
+
+ return &php_referencemap->zobj;
+}
+
+static void mapscript_referencemap_free_object(zend_object *object)
+{
+ php_referencemap_object *php_referencemap;
+
+ php_referencemap = (php_referencemap_object *)((char *)object - XtOffsetOf(php_referencemap_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_referencemap->parent);
+ MAPSCRIPT_DELREF(php_referencemap->extent);
+ MAPSCRIPT_DELREF(php_referencemap->color);
+ MAPSCRIPT_DELREF(php_referencemap->outlinecolor);
+
+ /* We don't need to free the referenceMapObj */
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(referencemap)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "referenceMapObj", referencemap_functions);
+ mapscript_ce_referencemap = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_referencemap->create_object = mapscript_referencemap_create_object;
+ mapscript_ce_referencemap->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_referencemap_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_referencemap_object_handlers));
+ mapscript_referencemap_object_handlers.free_obj = mapscript_referencemap_free_object;
+ mapscript_referencemap_object_handlers.offset = XtOffsetOf(php_referencemap_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_referencemap_object_destroy(void *object TSRMLS_DC)
{
php_referencemap_object *php_referencemap = (php_referencemap_object *)object;
@@ -274,3 +332,4 @@ PHP_MINIT_FUNCTION(referencemap)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/result.c b/mapscript/php/result.c
index 994b0596d..a0748b786 100644
--- a/mapscript/php/result.c
+++ b/mapscript/php/result.c
@@ -30,6 +30,9 @@
**********************************************************************/
#include "php_mapscript.h"
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_result_object_handlers;
+#endif
zend_class_entry *mapscript_ce_result;
@@ -62,7 +65,7 @@ PHP_METHOD(resultObj, __construct)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_result = (php_result_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
+ php_result = MAPSCRIPT_OBJ_P(php_result_object, getThis());
if ((php_result->result = resultObj_new()) == NULL) {
mapscript_throw_exception("Unable to construct resultObj." TSRMLS_CC);
@@ -88,7 +91,7 @@ PHP_METHOD(resultObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_result = (php_result_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_result = MAPSCRIPT_OBJ_P(php_result_object, zobj);
IF_GET_LONG("shapeindex", php_result->result->shapeindex)
else IF_GET_LONG("tileindex", php_result->result->tileindex)
@@ -136,13 +139,62 @@ void mapscript_create_result(resultObj *result, parent_object parent,
{
php_result_object * php_result;
object_init_ex(return_value, mapscript_ce_result);
- php_result = (php_result_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_result = MAPSCRIPT_OBJ_P(php_result_object, return_value);
php_result->result = result;
php_result->parent = parent;
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_result_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_result_object *php_result;
+
+ php_result = ecalloc(1, sizeof(*php_result) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_result->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_result->zobj, ce);
+
+ php_result->zobj.handlers = &mapscript_result_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_result->parent);
+
+ return &php_result->zobj;
+}
+
+static void mapscript_result_free_object(zend_object *object)
+{
+ php_result_object *php_result;
+
+ php_result = (php_result_object *)((char *)object - XtOffsetOf(php_result_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_result->parent);
+
+ /* We don't need to free the resultObj */
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(result)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "resultObj", result_functions);
+ mapscript_ce_result = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_result->create_object = mapscript_result_create_object;
+ mapscript_ce_result->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_result_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_result_object_handlers));
+ mapscript_result_object_handlers.free_obj = mapscript_result_free_object;
+ mapscript_result_object_handlers.offset = XtOffsetOf(php_result_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_result_object_destroy(void *object TSRMLS_DC)
{
php_result_object *php_result = (php_result_object *)object;
@@ -184,3 +236,4 @@ PHP_MINIT_FUNCTION(result)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/scalebar.c b/mapscript/php/scalebar.c
index 21b04664d..cb879266d 100644
--- a/mapscript/php/scalebar.c
+++ b/mapscript/php/scalebar.c
@@ -32,6 +32,9 @@
#include "php_mapscript.h"
zend_class_entry *mapscript_ce_scalebar;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_scalebar_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(scalebar___get_args, 0, 0, 1)
ZEND_ARG_INFO(0, property)
@@ -75,7 +78,7 @@ PHP_METHOD(scalebarObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_scalebar = (php_scalebar_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_scalebar = MAPSCRIPT_OBJ_P(php_scalebar_object, zobj);
IF_GET_LONG("height", php_scalebar->scalebar->height)
else IF_GET_LONG("width", php_scalebar->scalebar->width)
@@ -112,7 +115,7 @@ PHP_METHOD(scalebarObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_scalebar = (php_scalebar_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_scalebar = MAPSCRIPT_OBJ_P(php_scalebar_object, zobj);
IF_SET_LONG("height", php_scalebar->scalebar->height, value)
else IF_SET_LONG("width", php_scalebar->scalebar->width, value)
@@ -152,7 +155,7 @@ PHP_METHOD(scalebarObj, updateFromString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_scalebar = (php_scalebar_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_scalebar = MAPSCRIPT_OBJ_P(php_scalebar_object, zobj);
status = scalebarObj_updateFromString(php_scalebar->scalebar, snippet);
@@ -180,14 +183,14 @@ PHP_METHOD(scalebarObj, convertToString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_scalebar = (php_scalebar_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_scalebar = MAPSCRIPT_OBJ_P(php_scalebar_object, zobj);
value = scalebarObj_convertToString(php_scalebar->scalebar);
if (value == NULL)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -208,7 +211,7 @@ PHP_METHOD(scalebarObj, setImageColor)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_scalebar = (php_scalebar_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_scalebar = MAPSCRIPT_OBJ_P(php_scalebar_object, zobj);
if (red < 0 || red > 255 || green < 0 || green > 255 || blue < 0 || blue > 255)
RETURN_LONG(MS_FAILURE);
@@ -235,7 +238,7 @@ PHP_METHOD(scalebarObj, free)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_scalebar = (php_scalebar_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_scalebar = MAPSCRIPT_OBJ_P(php_scalebar_object, zobj);
MAPSCRIPT_DELREF(php_scalebar->color);
MAPSCRIPT_DELREF(php_scalebar->backgroundcolor);
@@ -262,13 +265,72 @@ void mapscript_create_scalebar(scalebarObj *scalebar, parent_object parent, zval
{
php_scalebar_object * php_scalebar;
object_init_ex(return_value, mapscript_ce_scalebar);
- php_scalebar = (php_scalebar_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_scalebar = MAPSCRIPT_OBJ_P(php_scalebar_object, return_value);
php_scalebar->scalebar = scalebar;
php_scalebar->parent = parent;
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_scalebar_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_scalebar_object *php_scalebar;
+
+ php_scalebar = ecalloc(1, sizeof(*php_scalebar) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_scalebar->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_scalebar->zobj, ce);
+
+ php_scalebar->zobj.handlers = &mapscript_scalebar_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_scalebar->parent);
+ ZVAL_UNDEF(&php_scalebar->color);
+ ZVAL_UNDEF(&php_scalebar->backgroundcolor);
+ ZVAL_UNDEF(&php_scalebar->outlinecolor);
+ ZVAL_UNDEF(&php_scalebar->imagecolor);
+ ZVAL_UNDEF(&php_scalebar->label);
+
+ return &php_scalebar->zobj;
+}
+
+static void mapscript_scalebar_free_object(zend_object *object)
+{
+ php_scalebar_object *php_scalebar;
+
+ php_scalebar = (php_scalebar_object *)((char *)object - XtOffsetOf(php_scalebar_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_scalebar->parent);
+ MAPSCRIPT_DELREF(php_scalebar->color);
+ MAPSCRIPT_DELREF(php_scalebar->backgroundcolor);
+ MAPSCRIPT_DELREF(php_scalebar->outlinecolor);
+ MAPSCRIPT_DELREF(php_scalebar->imagecolor);
+ MAPSCRIPT_DELREF(php_scalebar->label);
+
+ /* We don't need to free the scalebarObj */
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(scalebar)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "scalebarObj", scalebar_functions);
+ mapscript_ce_scalebar = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_scalebar->create_object = mapscript_scalebar_create_object;
+ mapscript_ce_scalebar->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_scalebar_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_scalebar_object_handlers));
+ mapscript_scalebar_object_handlers.free_obj = mapscript_scalebar_free_object;
+ mapscript_scalebar_object_handlers.offset = XtOffsetOf(php_scalebar_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_scalebar_object_destroy(void *object TSRMLS_DC)
{
php_scalebar_object *php_scalebar = (php_scalebar_object *)object;
@@ -320,3 +382,4 @@ PHP_MINIT_FUNCTION(scalebar)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/shape.c b/mapscript/php/shape.c
index 7bf474bad..a2be5f94e 100644
--- a/mapscript/php/shape.c
+++ b/mapscript/php/shape.c
@@ -32,6 +32,9 @@
#include "php_mapscript.h"
zend_class_entry *mapscript_ce_shape;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_shape_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(shape___construct_args, 0, 0, 1)
ZEND_ARG_INFO(0, type)
@@ -166,7 +169,7 @@ PHP_METHOD(shapeObj, __construct)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *)zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
if ((php_shape->shape = shapeObj_new(type)) == NULL) {
mapscript_throw_exception("Unable to construct shapeObj." TSRMLS_CC);
@@ -174,7 +177,7 @@ PHP_METHOD(shapeObj, __construct)
}
MAKE_STD_ZVAL(php_shape->values);
- array_init(php_shape->values);
+ mapscript_array_init(php_shape->values);
}
/* }}} */
@@ -193,7 +196,7 @@ PHP_METHOD(shapeObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
IF_GET_STRING("text", php_shape->shape->text)
else IF_GET_LONG("classindex", php_shape->shape->classindex)
@@ -226,7 +229,7 @@ PHP_METHOD(shapeObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
IF_SET_STRING("text", php_shape->shape->text, value)
else IF_SET_LONG("classindex", php_shape->shape->classindex, value)
@@ -262,8 +265,8 @@ PHP_METHOD(shapeObj, add)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_line = (php_line_object *) zend_object_store_get_object(zline TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_line = MAPSCRIPT_OBJ_P(php_line_object, zline);
retval = shapeObj_add(php_shape->shape, php_line->line);
@@ -288,7 +291,7 @@ PHP_METHOD(shapeObj, line)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
if (index < 0 || index >= php_shape->shape->numlines) {
@@ -318,8 +321,8 @@ PHP_METHOD(shapeObj, contains)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_point = (php_point_object *) zend_object_store_get_object(zpoint TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, zpoint);
if (!shapeObj_contains(php_shape->shape, php_point->point))
RETURN_FALSE;
@@ -344,8 +347,8 @@ PHP_METHOD(shapeObj, intersects)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape2 = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_shape2 = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
if (!shapeObj_intersects(php_shape->shape, php_shape2->shape))
RETURN_FALSE;
@@ -373,9 +376,9 @@ PHP_METHOD(shapeObj, project)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_proj_in = (php_projection_object *) zend_object_store_get_object(zobj_proj_in TSRMLS_CC);
- php_proj_out = (php_projection_object *) zend_object_store_get_object(zobj_proj_out TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_proj_in = MAPSCRIPT_OBJ_P(php_projection_object, zobj_proj_in);
+ php_proj_out = MAPSCRIPT_OBJ_P(php_projection_object, zobj_proj_out);
status = shapeObj_project(php_shape->shape, php_proj_in->projection, php_proj_out->projection);
if (status != MS_SUCCESS) {
@@ -405,7 +408,7 @@ PHP_METHOD(shapeObj, getPointUsingMeasure)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
point = shapeObj_getpointusingmeasure(php_shape->shape, measure);
if (point == NULL)
@@ -437,8 +440,8 @@ PHP_METHOD(shapeObj, getMeasureUsingPoint)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_point = (php_point_object *) zend_object_store_get_object(zpoint TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, zpoint);
intersection = shapeObj_getmeasureusingpoint(php_shape->shape, php_point->point);
if (intersection == NULL)
@@ -470,15 +473,15 @@ PHP_METHOD(shapeObj, getValue)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_layer = (php_layer_object *) zend_object_store_get_object(zlayer TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zlayer);
if (php_shape->shape->numvalues != php_layer->layer->numitems)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
for(i=0; i<php_layer->layer->numitems; i++) {
if (strcasecmp(php_layer->layer->items[i], fieldName)==0) {
- RETURN_STRING(php_shape->shape->values[i], 1);
+ MAPSCRIPT_RETURN_STRING(php_shape->shape->values[i], 1);
}
}
}
@@ -503,7 +506,7 @@ PHP_METHOD(shapeObj, buffer)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
shape = shapeObj_buffer(php_shape->shape, width);
if (shape == NULL)
@@ -531,7 +534,7 @@ PHP_METHOD(shapeObj, convexhull)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
shape = shapeObj_convexHull(php_shape->shape);
if (shape == NULL)
@@ -559,7 +562,7 @@ PHP_METHOD(shapeObj, boundary)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
shape = shapeObj_boundary(php_shape->shape);
if (shape == NULL)
@@ -587,8 +590,8 @@ PHP_METHOD(shapeObj, containsShape)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape2 = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_shape2 = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
if (shapeObj_contains_geos(php_shape->shape, php_shape2->shape)) {
RETURN_TRUE;
@@ -617,8 +620,8 @@ PHP_METHOD(shapeObj, union)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape2 = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_shape2 = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
shape = shapeObj_Union(php_shape->shape, php_shape2->shape);
@@ -649,8 +652,8 @@ PHP_METHOD(shapeObj, intersection)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape2 = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_shape2 = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
shape = shapeObj_intersection(php_shape->shape, php_shape2->shape);
@@ -681,8 +684,8 @@ PHP_METHOD(shapeObj, difference)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape2 = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_shape2 = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
shape = shapeObj_difference(php_shape->shape, php_shape2->shape);
@@ -713,8 +716,8 @@ PHP_METHOD(shapeObj, symdifference)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape2 = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_shape2 = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
shape = shapeObj_symdifference(php_shape->shape, php_shape2->shape);
@@ -743,8 +746,8 @@ PHP_METHOD(shapeObj, overlaps)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape2 = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_shape2 = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
if (shapeObj_overlaps(php_shape->shape, php_shape2->shape)) {
RETURN_TRUE;
@@ -770,8 +773,8 @@ PHP_METHOD(shapeObj, within)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape2 = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_shape2 = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
if (shapeObj_within(php_shape->shape, php_shape2->shape)) {
RETURN_TRUE;
@@ -798,8 +801,8 @@ PHP_METHOD(shapeObj, crosses)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape2 = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_shape2 = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
if (shapeObj_crosses(php_shape->shape, php_shape2->shape)) {
RETURN_TRUE;
@@ -825,8 +828,8 @@ PHP_METHOD(shapeObj, touches)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape2 = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_shape2 = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
if (shapeObj_touches(php_shape->shape, php_shape2->shape)) {
RETURN_TRUE;
@@ -852,8 +855,8 @@ PHP_METHOD(shapeObj, equals)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape2 = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_shape2 = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
if (shapeObj_equals(php_shape->shape, php_shape2->shape)) {
RETURN_TRUE;
@@ -879,8 +882,8 @@ PHP_METHOD(shapeObj, disjoint)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape2 = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_shape2 = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
if (shapeObj_disjoint(php_shape->shape, php_shape2->shape)) {
RETURN_TRUE;
@@ -905,7 +908,7 @@ PHP_METHOD(shapeObj, getCentroid)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
point = shapeObj_getcentroid(php_shape->shape);
@@ -932,7 +935,7 @@ PHP_METHOD(shapeObj, getArea)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
area = shapeObj_getarea(php_shape->shape);
@@ -955,7 +958,7 @@ PHP_METHOD(shapeObj, getLength)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
length = shapeObj_getlength(php_shape->shape);
@@ -979,7 +982,7 @@ PHP_METHOD(shapeObj, getLabelPoint)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
point = shapeObj_getLabelPoint(php_shape->shape);
@@ -1006,16 +1009,16 @@ PHP_METHOD(shapeObj, toWkt)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
wkt = msShapeToWKT(php_shape->shape);
if (wkt) {
- RETVAL_STRING(wkt, 1);
+ MAPSCRIPT_RETVAL_STRING(wkt, 1);
msFree(wkt);
return;
}
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
}
/* }}} */
@@ -1035,7 +1038,7 @@ PHP_METHOD(shapeObj, setBounds)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
shapeObj_setBounds(php_shape->shape);
@@ -1062,7 +1065,7 @@ PHP_METHOD(shapeObj, simplify)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
shape = shapeObj_simplify(php_shape->shape, tolerance);
if (shape == NULL)
@@ -1092,7 +1095,7 @@ PHP_METHOD(shapeObj, topologyPreservingSimplify)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
shape = shapeObj_topologypreservingsimplify(php_shape->shape, tolerance);
if (shape == NULL)
@@ -1125,10 +1128,10 @@ PHP_METHOD(shapeObj, draw)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_map = (php_map_object *) zend_object_store_get_object(zmap TSRMLS_CC);
- php_layer = (php_layer_object *) zend_object_store_get_object(zlayer TSRMLS_CC);
- php_image = (php_image_object *) zend_object_store_get_object(zimage TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zmap);
+ php_layer = MAPSCRIPT_OBJ_P(php_layer_object, zlayer);
+ php_image = MAPSCRIPT_OBJ_P(php_image_object, zimage);
if ((status = shapeObj_draw(php_shape->shape, php_map->map, php_layer->layer,
php_image->image)) != MS_SUCCESS) {
@@ -1154,7 +1157,7 @@ PHP_METHOD(shapeObj, free)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
MAPSCRIPT_DELREF(php_shape->bounds);
}
@@ -1177,8 +1180,8 @@ PHP_METHOD(shapeObj, distanceToPoint)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_point = (php_point_object *) zend_object_store_get_object(zpoint TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, zpoint);
RETURN_DOUBLE(msDistancePointToShape(php_point->point, php_shape->shape));
}
@@ -1201,8 +1204,8 @@ PHP_METHOD(shapeObj, distanceToShape)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shape = (php_shape_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape2 = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zobj);
+ php_shape2 = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
RETURN_DOUBLE(msGEOSDistance(php_shape->shape, php_shape2->shape));
}
@@ -1259,17 +1262,17 @@ void mapscript_create_shape(shapeObj *shape, parent_object parent, php_layer_obj
int i;
object_init_ex(return_value, mapscript_ce_shape);
- php_shape = (php_shape_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, return_value);
php_shape->shape = shape;
MAKE_STD_ZVAL(php_shape->values);
- array_init(php_shape->values);
+ mapscript_array_init(php_shape->values);
if (php_layer) {
if ((php_shape->shape->numvalues == php_layer->layer->numitems) ||
(php_shape->shape->numvalues == 0 && php_layer->layer->numitems == -1)) {
for(i=0; i<php_shape->shape->numvalues; i++) {
- add_assoc_string(php_shape->values, php_layer->layer->items[i], php_shape->shape->values[i], 1);
+ mapscript_add_assoc_string(php_shape->values, php_layer->layer->items[i], php_shape->shape->values[i], 1);
}
} else {
mapscript_throw_exception("Assertion failed, Could not set shape values: %d, %d" TSRMLS_CC,
@@ -1278,13 +1281,70 @@ void mapscript_create_shape(shapeObj *shape, parent_object parent, php_layer_obj
}
}
- if (parent.val)
+ if (ZVAL_NOT_UNDEF(parent.val))
php_shape->is_ref = 1;
php_shape->parent = parent;
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_shape_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_shape_object *php_shape;
+
+ php_shape = ecalloc(1, sizeof(*php_shape) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_shape->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_shape->zobj, ce);
+
+ php_shape->zobj.handlers = &mapscript_shape_object_handlers;
+
+ php_shape->is_ref = 0;
+ MAPSCRIPT_INIT_PARENT(php_shape->parent);
+ ZVAL_UNDEF(&php_shape->bounds);
+ ZVAL_UNDEF(&php_shape->values);
+
+
+ return &php_shape->zobj;
+}
+
+static void mapscript_shape_free_object(zend_object *object)
+{
+ php_shape_object *php_shape;
+
+ php_shape = (php_shape_object *)((char *)object - XtOffsetOf(php_shape_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_shape->parent);
+ MAPSCRIPT_DELREF(php_shape->bounds);
+ MAPSCRIPT_DELREF(php_shape->values);
+
+ if (php_shape->shape && !php_shape->is_ref) {
+ shapeObj_destroy(php_shape->shape);
+ }
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(shape)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "shapeObj", shape_functions);
+ mapscript_ce_shape = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_shape->create_object = mapscript_shape_create_object;
+ mapscript_ce_shape->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_shape_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_shape_object_handlers));
+ mapscript_shape_object_handlers.free_obj = mapscript_shape_free_object;
+ mapscript_shape_object_handlers.offset = XtOffsetOf(php_shape_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_shape_object_destroy(void *object TSRMLS_DC)
{
php_shape_object *php_shape = (php_shape_object *)object;
@@ -1333,3 +1393,4 @@ PHP_MINIT_FUNCTION(shape)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/shapefile.c b/mapscript/php/shapefile.c
index 89aceff2a..233809840 100644
--- a/mapscript/php/shapefile.c
+++ b/mapscript/php/shapefile.c
@@ -32,6 +32,9 @@
#include "php_mapscript.h"
zend_class_entry *mapscript_ce_shapefile;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_shapefile_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(shapefile___construct_args, 0, 0, 2)
ZEND_ARG_INFO(0, filename)
@@ -90,7 +93,7 @@ PHP_METHOD(shapeFileObj, __construct)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shapefile = (php_shapefile_object *)zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shapefile = MAPSCRIPT_OBJ_P(php_shapefile_object, zobj);
php_shapefile->shapefile = shapefileObj_new(filename, type);
@@ -116,7 +119,7 @@ PHP_METHOD(shapeFileObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shapefile = (php_shapefile_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shapefile = MAPSCRIPT_OBJ_P(php_shapefile_object, zobj);
IF_GET_LONG("numshapes", php_shapefile->shapefile->numshapes)
else IF_GET_LONG("type", php_shapefile->shapefile->type)
@@ -173,7 +176,7 @@ PHP_METHOD(shapeFileObj, getShape)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shapefile = (php_shapefile_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shapefile = MAPSCRIPT_OBJ_P(php_shapefile_object, zobj);
/* Create a new shapeObj to hold the result
* Note that the type used to create the shape (MS_NULL) does not matter
@@ -213,7 +216,7 @@ PHP_METHOD(shapeFileObj, getPoint)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shapefile = (php_shapefile_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shapefile = MAPSCRIPT_OBJ_P(php_shapefile_object, zobj);
/* Create a new shapeObj to hold the result
* Note that the type used to create the shape (MS_NULL) does not matter
@@ -256,7 +259,7 @@ PHP_METHOD(shapeFileObj, getExtent)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shapefile = (php_shapefile_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shapefile = MAPSCRIPT_OBJ_P(php_shapefile_object, zobj);
/* Create a new rectObj to hold the result */
if ((rect = rectObj_new()) == NULL) {
@@ -293,8 +296,8 @@ PHP_METHOD(shapeFileObj, addShape)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shapefile = (php_shapefile_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_shape = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+ php_shapefile = MAPSCRIPT_OBJ_P(php_shapefile_object, zobj);
+ php_shape = MAPSCRIPT_OBJ_P(php_shape_object, zshape);
retval = shapefileObj_add(php_shapefile->shapefile, php_shape->shape);
@@ -320,8 +323,8 @@ PHP_METHOD(shapeFileObj, addPoint)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shapefile = (php_shapefile_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_point = (php_point_object *) zend_object_store_get_object(zpoint TSRMLS_CC);
+ php_shapefile = MAPSCRIPT_OBJ_P(php_shapefile_object, zobj);
+ php_point = MAPSCRIPT_OBJ_P(php_point_object, zpoint);
retval = shapefileObj_addPoint(php_shapefile->shapefile, php_point->point);
@@ -349,8 +352,8 @@ PHP_METHOD(shapeFileObj, getTransformed)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shapefile = (php_shapefile_object *) zend_object_store_get_object(zobj TSRMLS_CC);
- php_map = (php_map_object *) zend_object_store_get_object(zmap TSRMLS_CC);
+ php_shapefile = MAPSCRIPT_OBJ_P(php_shapefile_object, zobj);
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zmap);
/* Create a new shapeObj to hold the result
* Note that the type used to create the shape (MS_NULL) does not matter
@@ -389,7 +392,7 @@ PHP_METHOD(shapeFileObj, free)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_shapefile = (php_shapefile_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_shapefile = MAPSCRIPT_OBJ_P(php_shapefile_object, zobj);
MAPSCRIPT_DELREF(php_shapefile->bounds);
}
@@ -416,10 +419,59 @@ void mapscript_create_shapefile(shapefileObj *shapefile, zval *return_value TSRM
php_shapefile_object * php_shapefile;
object_init_ex(return_value, mapscript_ce_shapefile);
- php_shapefile = (php_shapefile_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_shapefile = MAPSCRIPT_OBJ_P(php_shapefile_object, return_value);
php_shapefile->shapefile = shapefile;
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_shapefile_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_shapefile_object *php_shapefile;
+
+ php_shapefile = ecalloc(1, sizeof(*php_shapefile) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_shapefile->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_shapefile->zobj, ce);
+
+ php_shapefile->zobj.handlers = &mapscript_shapefile_object_handlers;
+
+ ZVAL_UNDEF(&php_shapefile->bounds);
+
+ return &php_shapefile->zobj;
+}
+
+static void mapscript_shapefile_free_object(zend_object *object)
+{
+ php_shapefile_object *php_shapefile;
+
+ php_shapefile = (php_shapefile_object *)((char *)object - XtOffsetOf(php_shapefile_object, zobj));
+
+ MAPSCRIPT_DELREF(php_shapefile->bounds);
+
+ shapefileObj_destroy(php_shapefile->shapefile);
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(shapefile)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "shapefileObj", shapefile_functions);
+ mapscript_ce_shapefile = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_shapefile->create_object = mapscript_shapefile_create_object;
+ mapscript_ce_shapefile->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_shapefile_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_shapefile_object_handlers));
+ mapscript_shapefile_object_handlers.free_obj = mapscript_shapefile_free_object;
+ mapscript_shapefile_object_handlers.offset = XtOffsetOf(php_shapefile_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_shapefile_object_destroy(void *object TSRMLS_DC)
{
php_shapefile_object *php_shapefile = (php_shapefile_object *)object;
@@ -461,3 +513,4 @@ PHP_MINIT_FUNCTION(shapefile)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/style.c b/mapscript/php/style.c
index b5a53f179..963718b9e 100644
--- a/mapscript/php/style.c
+++ b/mapscript/php/style.c
@@ -94,19 +94,19 @@ PHP_METHOD(styleObj, __construct)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_style = (php_style_object *)zend_object_store_get_object(zobj TSRMLS_CC);
+ php_style = MAPSCRIPT_OBJ_P(php_style_object, zobj);
if (Z_TYPE_P(zparent) == IS_OBJECT && Z_OBJCE_P(zparent) == mapscript_ce_class)
- php_class = (php_class_object *)zend_object_store_get_object(zparent TSRMLS_CC);
+ php_class = MAPSCRIPT_OBJ_P(php_class_object, zparent);
else if (Z_TYPE_P(zparent) == IS_OBJECT && Z_OBJCE_P(zparent) == mapscript_ce_label)
- php_label = (php_label_object *)zend_object_store_get_object(zparent TSRMLS_CC);
+ php_label = MAPSCRIPT_OBJ_P(php_label_object, zparent);
else {
mapscript_throw_mapserver_exception("Invalid argument 1: should be a classObj or labelObj" TSRMLS_CC);
return;
}
if (zstyle)
- php_style2 = (php_style_object *)zend_object_store_get_object(zstyle TSRMLS_CC);
+ php_style2 = MAPSCRIPT_OBJ_P(php_style_object, zstyle);
if (php_class) {
if ((style = styleObj_new(php_class->class, (zstyle ? php_style2->style : NULL))) == NULL) {
@@ -124,7 +124,7 @@ PHP_METHOD(styleObj, __construct)
MAPSCRIPT_MAKE_PARENT(zparent, NULL);
php_style->parent = parent;
- MAPSCRIPT_ADDREF(zparent);
+ MAPSCRIPT_ADDREF_P(zparent);
}
/* }}} */
@@ -143,7 +143,7 @@ PHP_METHOD(styleObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_style = (php_style_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_style = MAPSCRIPT_OBJ_P(php_style_object, zobj);
IF_GET_LONG("symbol", php_style->style->symbol)
else IF_GET_STRING("symbolname", php_style->style->symbolname)
@@ -207,7 +207,7 @@ PHP_METHOD(styleObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_style = (php_style_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_style = MAPSCRIPT_OBJ_P(php_style_object, zobj);
IF_SET_LONG("symbol", php_style->style->symbol, value)
else IF_SET_DOUBLE("size", php_style->style->size, value)
@@ -259,24 +259,24 @@ PHP_METHOD(styleObj, __set)
php_style->style->symbolname = strdup(Z_STRVAL_P(value));
/* The parent can be a classObj or a labelCacheMemberObj */
- if (Z_OBJCE_P(php_style->parent.val) == mapscript_ce_class) {
- php_class = (php_class_object *) zend_object_store_get_object(php_style->parent.val TSRMLS_CC);
+ if (MAPSCRIPT_OBJCE(php_style->parent.val) == mapscript_ce_class) {
+ php_class = MAPSCRIPT_OBJ(php_class_object, php_style->parent.val);
/* Can a class have no layer object ? */
- php_layer = (php_layer_object *) zend_object_store_get_object(php_class->parent.val TSRMLS_CC);
- if (!php_layer->parent.val) {
+ php_layer = MAPSCRIPT_OBJ(php_layer_object, php_class->parent.val);
+ if (ZVAL_IS_UNDEF(php_layer->parent.val)) {
mapscript_throw_exception("No map object associated with this style object." TSRMLS_CC);
return;
}
- php_map = (php_map_object *) zend_object_store_get_object(php_layer->parent.val TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ(php_map_object, php_layer->parent.val);
#ifdef disabled
- } else if (Z_OBJCE_P(php_style->parent.val) == mapscript_ce_labelcachemember) {
+ } else if (MAPSCRIPT_OBJCE(php_style->parent.val) == mapscript_ce_labelcachemember) {
/* The parent is always a map */
- php_labelcachemember = (php_labelcachemember_object *) zend_object_store_get_object(php_style->parent.val TSRMLS_CC);
- if (!php_labelcachemember->parent.val) {
+ php_labelcachemember = MAPSCRIPT_OBJ(php_labelcachemember_object, php_style->parent.val);
+ if (ZVAL_NOT_UNDEF(php_labelcachemember->parent.val)) {
mapscript_throw_exception("No map object associated with this style object." TSRMLS_CC);
return;
}
- php_map = (php_map_object *) zend_object_store_get_object(php_labelcachemember->parent.val TSRMLS_CC);
+ php_map = MAPSCRIPT_OBJ(php_map_object, php_labelcachemember->parent.val);
#endif
}
@@ -308,7 +308,7 @@ PHP_METHOD(styleObj, updateFromString)
char *snippet;
long snippet_len = 0;
int status = MS_FAILURE;
- zval *retval;
+ MAPSCRIPT_ZVAL retval;
zval property_name, value;
php_style_object *php_style;
@@ -320,7 +320,7 @@ PHP_METHOD(styleObj, updateFromString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_style = (php_style_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_style = MAPSCRIPT_OBJ_P(php_style_object, zobj);
if ((status = styleObj_updateFromString(php_style->style, snippet)) != MS_SUCCESS) {
mapscript_throw_mapserver_exception("" TSRMLS_CC);
@@ -331,9 +331,9 @@ PHP_METHOD(styleObj, updateFromString)
if (php_style->style->symbolname) {
INIT_ZVAL(property_name);
INIT_ZVAL(value);
- ZVAL_STRING(&property_name, "symbolname", 1);
- ZVAL_STRING(&value, php_style->style->symbolname, 1);
- MAPSCRIPT_CALL_METHOD_2(zobj, "__set", retval, &property_name, &value);
+ MAPSCRIPT_ZVAL_STRING(&property_name, "symbolname", 1);
+ MAPSCRIPT_ZVAL_STRING(&value, php_style->style->symbolname, 1);
+ MAPSCRIPT_CALL_METHOD_2_P(zobj, "__set", retval, &property_name, &value);
}
RETURN_LONG(status);
@@ -355,14 +355,14 @@ PHP_METHOD(styleObj, convertToString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_style = (php_style_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_style = MAPSCRIPT_OBJ_P(php_style_object, zobj);
value = styleObj_convertToString(php_style->style);
if (value == NULL)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -385,7 +385,7 @@ PHP_METHOD(styleObj, setBinding)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_style = (php_style_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_style = MAPSCRIPT_OBJ_P(php_style_object, zobj);
if (bindingId < 0 || bindingId > MS_STYLE_BINDING_LENGTH) {
mapscript_throw_exception("Invalid binding id." TSRMLS_CC);
@@ -428,7 +428,7 @@ PHP_METHOD(styleObj, getBinding)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_style = (php_style_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_style = MAPSCRIPT_OBJ_P(php_style_object, zobj);
if (bindingId < 0 || bindingId > MS_STYLE_BINDING_LENGTH) {
mapscript_throw_exception("Invalid binding id." TSRMLS_CC);
@@ -436,7 +436,7 @@ PHP_METHOD(styleObj, getBinding)
}
if( (value = php_style->style->bindings[bindingId].item) != NULL) {
- RETURN_STRING(value, 1);
+ MAPSCRIPT_RETURN_STRING(value, 1);
}
RETURN_NULL();
@@ -460,7 +460,7 @@ PHP_METHOD(styleObj, removeBinding)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_style = (php_style_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_style = MAPSCRIPT_OBJ_P(php_style_object, zobj);
if (bindingId < 0 || bindingId > MS_STYLE_BINDING_LENGTH) {
mapscript_throw_exception("Invalid binding id." TSRMLS_CC);
@@ -494,7 +494,7 @@ PHP_METHOD(styleObj, free)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_style = (php_style_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_style = MAPSCRIPT_OBJ_P(php_style_object, zobj);
MAPSCRIPT_DELREF(php_style->color);
MAPSCRIPT_DELREF(php_style->outlinecolor);
@@ -516,13 +516,13 @@ PHP_METHOD(styleObj, getGeomTransform)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_style = (php_style_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_style = MAPSCRIPT_OBJ_P(php_style_object, zobj);
if (php_style->style->_geomtransform.type == MS_GEOMTRANSFORM_NONE ||
!php_style->style->_geomtransform.string)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETURN_STRING(php_style->style->_geomtransform.string, 1);
+ MAPSCRIPT_RETURN_STRING(php_style->style->_geomtransform.string, 1);
}
/* }}} */
@@ -543,7 +543,7 @@ PHP_METHOD(styleObj, setGeomTransform)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_style = (php_style_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_style = MAPSCRIPT_OBJ_P(php_style_object, zobj);
styleObj_setGeomTransform(php_style->style, transform);
}
@@ -553,7 +553,8 @@ PHP_METHOD(styleObj, setGeomTransform)
Set the pattern of the style ) */
PHP_METHOD(styleObj, setPattern)
{
- zval *zpattern, **ppzval;
+ zval *zpattern;
+ MAPSCRIPT_ZVAL_P ppzval;
HashTable *pattern_hash = NULL;
zval *zobj = getThis();
int index = 0, numelements = 0;
@@ -567,7 +568,7 @@ PHP_METHOD(styleObj, setPattern)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_style = (php_style_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_style = MAPSCRIPT_OBJ_P(php_style_object, zobj);
pattern_hash = Z_ARRVAL_P(zpattern);
numelements = zend_hash_num_elements(pattern_hash);
@@ -581,9 +582,15 @@ PHP_METHOD(styleObj, setPattern)
zend_hash_has_more_elements(pattern_hash) == SUCCESS;
zend_hash_move_forward(pattern_hash)) {
+#if PHP_VERSION_ID < 70000
zend_hash_get_current_data(pattern_hash, (void **)&ppzval);
if (Z_TYPE_PP(ppzval) != IS_LONG)
convert_to_long(*ppzval);
+#else
+ ppzval = zend_hash_get_current_data(pattern_hash);
+ if (Z_TYPE_P(ppzval) != IS_DOUBLE)
+ convert_to_double(ppzval);
+#endif
php_style->style->pattern[index] = Z_LVAL_PP(ppzval);
index++;
@@ -610,7 +617,7 @@ PHP_METHOD(styleObj, getPatternArray)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_style = (php_style_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_style = MAPSCRIPT_OBJ_P(php_style_object, zobj);
array_init(return_value);
@@ -646,7 +653,7 @@ void mapscript_create_style(styleObj *style, parent_object parent, zval *return_
{
php_style_object * php_style;
object_init_ex(return_value, mapscript_ce_style);
- php_style = (php_style_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_style = MAPSCRIPT_OBJ_P(php_style_object, return_value);
php_style->style = style;
php_style->parent = parent;
@@ -654,6 +661,79 @@ void mapscript_create_style(styleObj *style, parent_object parent, zval *return_
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_style_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_style_object *php_style;
+
+ php_style = ecalloc(1, sizeof(*php_style) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_style->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_style->zobj, ce);
+
+ php_style->zobj.handlers = &mapscript_style_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_style->parent);
+ ZVAL_UNDEF(&php_style->color);
+ ZVAL_UNDEF(&php_style->outlinecolor);
+ ZVAL_UNDEF(&php_style->backgroundcolor);
+
+ return &php_style->zobj;
+}
+
+static void mapscript_style_free_object(zend_object *object)
+{
+ php_style_object *php_style;
+
+ php_style = (php_style_object *)((char *)object - XtOffsetOf(php_style_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_style->parent);
+ MAPSCRIPT_DELREF(php_style->color);
+ MAPSCRIPT_DELREF(php_style->outlinecolor);
+ MAPSCRIPT_DELREF(php_style->backgroundcolor);
+
+ /* We don't need to free the styleObj, the mapObj will do it */
+
+ zend_object_std_dtor(object);
+}
+
+static zend_object* mapscript_style_clone_object(zval *zobj)
+{
+ php_style_object *php_style_old, *php_style_new;
+ zend_object* zobj_new;
+
+ php_style_old = MAPSCRIPT_OBJ_P(php_style_object, zobj);
+
+ zobj_new = mapscript_style_create_object(mapscript_ce_style);
+ php_style_new = (php_style_object *)((char *)zobj_new - XtOffsetOf(php_style_object, zobj));
+
+ zend_objects_clone_members(&php_style_new->zobj, &php_style_old->zobj);
+
+ php_style_new->style = styleObj_clone(php_style_old->style);
+
+ return zobj_new;
+}
+
+PHP_MINIT_FUNCTION(style)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "styleObj", style_functions);
+ mapscript_ce_style = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_style->create_object = mapscript_style_create_object;
+ mapscript_ce_style->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_style_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_style_object_handlers));
+ mapscript_style_object_handlers.free_obj = mapscript_style_free_object;
+ mapscript_style_object_handlers.clone_obj = mapscript_style_clone_object;
+ mapscript_style_object_handlers.offset = XtOffsetOf(php_style_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_style_object_destroy(void *object TSRMLS_DC)
{
php_style_object *php_style = (php_style_object *)object;
@@ -701,7 +781,7 @@ static zend_object_value mapscript_style_object_clone(zval *zobj TSRMLS_DC)
php_style_object *php_style_old, *php_style_new;
zend_object_value new_ov;
- php_style_old = (php_style_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_style_old = MAPSCRIPT_OBJ_P(php_style_object, zobj);
new_ov = mapscript_style_object_new_ex(mapscript_ce_style, &php_style_new TSRMLS_CC);
zend_objects_clone_members(&php_style_new->std, new_ov, &php_style_old->std, Z_OBJ_HANDLE_P(zobj) TSRMLS_CC);
@@ -727,4 +807,4 @@ PHP_MINIT_FUNCTION(style)
return SUCCESS;
}
-
+#endif
diff --git a/mapscript/php/symbol.c b/mapscript/php/symbol.c
index 8b53ec9b5..6928e1168 100644
--- a/mapscript/php/symbol.c
+++ b/mapscript/php/symbol.c
@@ -32,6 +32,9 @@
#include "php_mapscript.h"
zend_class_entry *mapscript_ce_symbol;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_symbol_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(symbol___construct_args, 0, 0, 2)
ZEND_ARG_OBJ_INFO(0, map, mapObj, 0)
@@ -84,8 +87,8 @@ PHP_METHOD(symbolObj, __construct)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_symbol = (php_symbol_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
- php_map = (php_map_object *)zend_object_store_get_object(zmap TSRMLS_CC);
+ php_symbol = MAPSCRIPT_OBJ_P(php_symbol_object, getThis());
+ php_map = MAPSCRIPT_OBJ_P(php_map_object, zmap);
symbolId = msAddNewSymbol(php_map->map, symbolName);
@@ -98,7 +101,7 @@ PHP_METHOD(symbolObj, __construct)
MAPSCRIPT_MAKE_PARENT(zmap, NULL);
php_symbol->parent = parent;
- MAPSCRIPT_ADDREF(zmap);
+ MAPSCRIPT_ADDREF_P(zmap);
}
/* }}} */
@@ -117,7 +120,7 @@ PHP_METHOD(symbolObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_symbol = (php_symbol_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_symbol = MAPSCRIPT_OBJ_P(php_symbol_object, zobj);
IF_GET_STRING("name", php_symbol->symbol->name)
else IF_GET_LONG("type", php_symbol->symbol->type)
@@ -158,7 +161,7 @@ PHP_METHOD(symbolObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_symbol = (php_symbol_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_symbol = MAPSCRIPT_OBJ_P(php_symbol_object, zobj);
IF_SET_STRING("name", php_symbol->symbol->name, value)
else IF_SET_LONG("type", php_symbol->symbol->type, value)
@@ -188,7 +191,8 @@ PHP_METHOD(symbolObj, __set)
Set the points of the symbol ) */
PHP_METHOD(symbolObj, setPoints)
{
- zval *zpoints, **ppzval;
+ zval *zpoints;
+ MAPSCRIPT_ZVAL_P ppzval;
HashTable *points_hash = NULL;
zval *zobj = getThis();
int index = 0, flag = 0, numelements = 0;
@@ -202,7 +206,7 @@ PHP_METHOD(symbolObj, setPoints)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_symbol = (php_symbol_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_symbol = MAPSCRIPT_OBJ_P(php_symbol_object, zobj);
points_hash = Z_ARRVAL_P(zpoints);
numelements = zend_hash_num_elements(points_hash);
@@ -217,9 +221,15 @@ PHP_METHOD(symbolObj, setPoints)
zend_hash_has_more_elements(points_hash) == SUCCESS;
zend_hash_move_forward(points_hash)) {
+#if PHP_VERSION_ID < 70000
zend_hash_get_current_data(points_hash, (void **)&ppzval);
if (Z_TYPE_PP(ppzval) != IS_DOUBLE)
convert_to_double(*ppzval);
+#else
+ ppzval = zend_hash_get_current_data(points_hash);
+ if (Z_TYPE_P(ppzval) != IS_DOUBLE)
+ convert_to_double(ppzval);
+#endif
if (!flag) {
php_symbol->symbol->points[index].x = Z_DVAL_PP(ppzval);
@@ -254,7 +264,7 @@ PHP_METHOD(symbolObj, getPointsArray)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_symbol = (php_symbol_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_symbol = MAPSCRIPT_OBJ_P(php_symbol_object, zobj);
array_init(return_value);
@@ -287,7 +297,7 @@ PHP_METHOD(symbolObj, setImagePath)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_symbol = (php_symbol_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_symbol = MAPSCRIPT_OBJ_P(php_symbol_object, zobj);
status = msLoadImageSymbol(php_symbol->symbol, filename);
@@ -316,8 +326,8 @@ PHP_METHOD(symbolObj, setImage)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_symbol = (php_symbol_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
- php_image = (php_image_object *)zend_object_store_get_object(zimage TSRMLS_CC);
+ php_symbol = MAPSCRIPT_OBJ_P(php_symbol_object, getThis());
+ php_image = MAPSCRIPT_OBJ_P(php_image_object, zimage);
RETURN_LONG(symbolObj_setImage(php_symbol->symbol, php_image->image));
}
@@ -341,9 +351,9 @@ PHP_METHOD(symbolObj, getImage)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_symbol = (php_symbol_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
- php_map = (php_map_object *) zend_object_store_get_object(php_symbol->parent.val TSRMLS_CC);
- php_outputformat = (php_outputformat_object *)zend_object_store_get_object(zoutputformat TSRMLS_CC);
+ php_symbol = MAPSCRIPT_OBJ_P(php_symbol_object, getThis());
+ php_map = MAPSCRIPT_OBJ(php_map_object, php_symbol->parent.val);
+ php_outputformat = MAPSCRIPT_OBJ_P(php_outputformat_object, zoutputformat);
image = symbolObj_getImage(php_symbol->symbol, php_outputformat->outputformat);
if (image == NULL) {
@@ -360,7 +370,7 @@ PHP_METHOD(symbolObj, getImage)
} /* }}} */
zend_function_entry symbol_functions[] = {
- PHP_ME(symbolObj, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
+ PHP_ME(symbolObj, __construct, symbol___construct_args, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(symbolObj, __get, symbol___get_args, ZEND_ACC_PUBLIC)
PHP_ME(symbolObj, __set, symbol___set_args, ZEND_ACC_PUBLIC)
PHP_MALIAS(symbolObj, set, __set, NULL, ZEND_ACC_PUBLIC)
@@ -377,7 +387,7 @@ void mapscript_create_symbol(symbolObj *symbol, parent_object parent, zval *retu
{
php_symbol_object * php_symbol;
object_init_ex(return_value, mapscript_ce_symbol);
- php_symbol = (php_symbol_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_symbol = MAPSCRIPT_OBJ_P(php_symbol_object, return_value);
php_symbol->symbol = symbol;
php_symbol->parent = parent;
@@ -385,6 +395,55 @@ void mapscript_create_symbol(symbolObj *symbol, parent_object parent, zval *retu
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_symbol_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_symbol_object *php_symbol;
+
+ php_symbol = ecalloc(1, sizeof(*php_symbol) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_symbol->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_symbol->zobj, ce);
+
+ php_symbol->zobj.handlers = &mapscript_symbol_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_symbol->parent);
+
+ return &php_symbol->zobj;
+}
+
+static void mapscript_symbol_free_object(zend_object *object)
+{
+ php_symbol_object *php_symbol;
+
+ php_symbol = (php_symbol_object *)((char *)object - XtOffsetOf(php_symbol_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_symbol->parent);
+
+ /* We don't need to free the symbolObj */
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(symbol)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "symbolObj", symbol_functions);
+ mapscript_ce_symbol = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_symbol->create_object = mapscript_symbol_create_object;
+ mapscript_ce_symbol->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_symbol_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_symbol_object_handlers));
+ mapscript_symbol_object_handlers.free_obj = mapscript_symbol_free_object;
+ mapscript_symbol_object_handlers.offset = XtOffsetOf(php_symbol_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_symbol_object_destroy(void *object TSRMLS_DC)
{
php_symbol_object *php_symbol = (php_symbol_object *)object;
@@ -426,3 +485,4 @@ PHP_MINIT_FUNCTION(symbol)
return SUCCESS;
}
+#endif
diff --git a/mapscript/php/web.c b/mapscript/php/web.c
index 51ec72f36..41f7c7cff 100644
--- a/mapscript/php/web.c
+++ b/mapscript/php/web.c
@@ -32,6 +32,9 @@
#include "php_mapscript.h"
zend_class_entry *mapscript_ce_web;
+#if PHP_VERSION_ID >= 70000
+zend_object_handlers mapscript_web_object_handlers;
+#endif
ZEND_BEGIN_ARG_INFO_EX(web___get_args, 0, 0, 1)
ZEND_ARG_INFO(0, property)
@@ -69,7 +72,7 @@ PHP_METHOD(webObj, __get)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_web = (php_web_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_web = MAPSCRIPT_OBJ_P(php_web_object, zobj);
IF_GET_STRING("log", php_web->web->log)
else IF_GET_STRING("imagepath", php_web->web->imagepath)
@@ -111,7 +114,7 @@ PHP_METHOD(webObj, __set)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_web = (php_web_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_web = MAPSCRIPT_OBJ_P(php_web_object, zobj);
IF_SET_STRING("log", php_web->web->log, value)
else IF_SET_STRING("imagepath", php_web->web->imagepath, value)
@@ -157,7 +160,7 @@ PHP_METHOD(webObj, updateFromString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_web = (php_web_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_web = MAPSCRIPT_OBJ_P(php_web_object, zobj);
status = webObj_updateFromString(php_web->web, snippet);
@@ -185,14 +188,14 @@ PHP_METHOD(webObj, convertToString)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_web = (php_web_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_web = MAPSCRIPT_OBJ_P(php_web_object, zobj);
value = webObj_convertToString(php_web->web);
if (value == NULL)
- RETURN_STRING("", 1);
+ MAPSCRIPT_RETURN_STRING("", 1);
- RETVAL_STRING(value, 1);
+ MAPSCRIPT_RETVAL_STRING(value, 1);
free(value);
}
/* }}} */
@@ -211,7 +214,7 @@ PHP_METHOD(webObj, free)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
- php_web = (php_web_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+ php_web = MAPSCRIPT_OBJ_P(php_web_object, zobj);
MAPSCRIPT_DELREF(php_web->extent);
MAPSCRIPT_DELREF(php_web->metadata);
@@ -235,13 +238,68 @@ void mapscript_create_web(webObj *web, parent_object parent, zval *return_value
{
php_web_object * php_web;
object_init_ex(return_value, mapscript_ce_web);
- php_web = (php_web_object *)zend_object_store_get_object(return_value TSRMLS_CC);
+ php_web = MAPSCRIPT_OBJ_P(php_web_object, return_value);
php_web->web = web;
php_web->parent = parent;
MAPSCRIPT_ADDREF(parent.val);
}
+#if PHP_VERSION_ID >= 70000
+/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
+static zend_object *mapscript_web_create_object(zend_class_entry *ce TSRMLS_DC)
+{
+ php_web_object *php_web;
+
+ php_web = ecalloc(1, sizeof(*php_web) + zend_object_properties_size(ce));
+
+ zend_object_std_init(&php_web->zobj, ce TSRMLS_CC);
+ object_properties_init(&php_web->zobj, ce);
+
+ php_web->zobj.handlers = &mapscript_web_object_handlers;
+
+ MAPSCRIPT_INIT_PARENT(php_web->parent);
+ ZVAL_UNDEF(&php_web->extent);
+ ZVAL_UNDEF(&php_web->metadata);
+ ZVAL_UNDEF(&php_web->validation);
+
+ return &php_web->zobj;
+}
+
+static void mapscript_web_free_object(zend_object *object)
+{
+ php_web_object *php_web;
+
+ php_web = (php_web_object *)((char *)object - XtOffsetOf(php_web_object, zobj));
+
+ MAPSCRIPT_FREE_PARENT(php_web->parent);
+ MAPSCRIPT_DELREF(php_web->extent);
+ MAPSCRIPT_DELREF(php_web->metadata);
+ MAPSCRIPT_DELREF(php_web->validation);
+
+ /* We don't need to free the webObj */
+
+ zend_object_std_dtor(object);
+}
+
+PHP_MINIT_FUNCTION(web)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "webObj", web_functions);
+ mapscript_ce_web = zend_register_internal_class(&ce TSRMLS_CC);
+
+ mapscript_ce_web->create_object = mapscript_web_create_object;
+ mapscript_ce_web->ce_flags |= ZEND_ACC_FINAL;
+
+ memcpy(&mapscript_web_object_handlers, &mapscript_std_object_handlers, sizeof(mapscript_web_object_handlers));
+ mapscript_web_object_handlers.free_obj = mapscript_web_free_object;
+ mapscript_web_object_handlers.offset = XtOffsetOf(php_web_object, zobj);
+
+ return SUCCESS;
+}
+#else
+/* PHP5 */
static void mapscript_web_object_destroy(void *object TSRMLS_DC)
{
php_web_object *php_web = (php_web_object *)object;
@@ -289,3 +347,4 @@ PHP_MINIT_FUNCTION(web)
return SUCCESS;
}
+#endif
From f54ce3a08f9a735b32b648b8be7dabd848965c88 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Boldt?= <mapscript@pixaweb.net>
Date: Fri, 10 Nov 2017 14:43:20 +0100
Subject: [PATCH 2/5] Fix bug in msQueryByFilter()
Mapserver crashes in msQueryByFilter() if an error occurs (e.g. filteritem name is not a column name of the shape). We have to restore lp->filteritem and lp->filter. Why was this commented out?
---
mapquery.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mapquery.c b/mapquery.c
index a0766911d..3ff0ff6e1 100644
--- a/mapquery.c
+++ b/mapquery.c
@@ -864,10 +864,10 @@ int msQueryByFilter(mapObj *map)
query_error:
// msFree(lp->filteritem);
- // lp->filteritem = old_filteritem;
- // msCopyExpression(&lp->filter, &old_filter); /* restore old filter */
- // msFreeExpression(&old_filter);
- // msLayerClose(lp);
+ lp->filteritem = old_filteritem;
+ msCopyExpression(&lp->filter, &old_filter); /* restore old filter */
+ msFreeExpression(&old_filter);
+ msLayerClose(lp);
return MS_FAILURE;
}
From a5049b7ba8b2ab4c278cca1993566b3ef1b4cb9b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Boldt?= <mapscript@pixaweb.net>
Date: Fri, 10 Nov 2017 15:16:14 +0100
Subject: [PATCH 3/5] Update mapquery.c
---
mapquery.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mapquery.c b/mapquery.c
index 3ff0ff6e1..34b483221 100644
--- a/mapquery.c
+++ b/mapquery.c
@@ -736,7 +736,7 @@ int msQueryByFilter(mapObj *map)
paging = msLayerGetPaging(lp);
msLayerClose(lp); /* reset */
status = msLayerOpen(lp);
- if(status != MS_SUCCESS) goto query_error;
+ if(status != MS_SUCCESS) return MS_FAILURE;
msLayerEnablePaging(lp, paging);
/* disable driver paging */
From 54256aa1611a6c21e1a7e50ceaaaf9735bdbb7a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Boldt?= <mapscript@pixaweb.net>
Date: Tue, 27 Mar 2018 10:07:21 +0200
Subject: [PATCH 4/5] Moving function mapscript_create_legend
Fixing error "undefined symbol: mapscript_create_legend" in PHP7
---
mapscript/php/legend.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/mapscript/php/legend.c b/mapscript/php/legend.c
index 29e080df7..742cc0c00 100644
--- a/mapscript/php/legend.c
+++ b/mapscript/php/legend.c
@@ -220,6 +220,17 @@ zend_function_entry legend_functions[] = {
}
};
+void mapscript_create_legend(legendObj *legend, parent_object parent, zval *return_value TSRMLS_DC)
+{
+ php_legend_object * php_legend;
+ object_init_ex(return_value, mapscript_ce_legend);
+ php_legend = MAPSCRIPT_OBJ_P(php_legend_object, return_value);
+ php_legend->legend = legend;
+
+ php_legend->parent = parent;
+ MAPSCRIPT_ADDREF(parent.val);
+}
+
#if PHP_VERSION_ID >= 70000
/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
@@ -276,17 +287,6 @@ PHP_MINIT_FUNCTION(legend)
}
#else
/* PHP5 */
-void mapscript_create_legend(legendObj *legend, parent_object parent, zval *return_value TSRMLS_DC)
-{
- php_legend_object * php_legend;
- object_init_ex(return_value, mapscript_ce_legend);
- php_legend = MAPSCRIPT_OBJ_P(php_legend_object, return_value);
- php_legend->legend = legend;
-
- php_legend->parent = parent;
- MAPSCRIPT_ADDREF(parent.val);
-}
-
static void mapscript_legend_object_destroy(void *object TSRMLS_DC)
{
php_legend_object *php_legend = (php_legend_object *)object;
From fd3cbf6cb23c7a558893e7e11cde419049ea4fdf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Boldt?= <mapscript@pixaweb.net>
Date: Tue, 27 Mar 2018 15:24:51 +0200
Subject: [PATCH 5/5] Moving function void mapscript_create_grid
---
mapscript/php/grid.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/mapscript/php/grid.c b/mapscript/php/grid.c
index c13f54bc3..f57e91fe5 100644
--- a/mapscript/php/grid.c
+++ b/mapscript/php/grid.c
@@ -176,6 +176,17 @@ zend_function_entry grid_functions[] = {
}
};
+void mapscript_create_grid(graticuleObj *grid, parent_object parent, zval *return_value TSRMLS_DC)
+{
+ php_grid_object * php_grid;
+ object_init_ex(return_value, mapscript_ce_grid);
+ php_grid = MAPSCRIPT_OBJ_P(php_grid_object, return_value);
+ php_grid->grid = grid;
+
+ php_grid->parent = parent;
+ MAPSCRIPT_ADDREF(parent.val);
+}
+
#if PHP_VERSION_ID >= 70000
/* PHP7 - Modification by Bjoern Boldt <mapscript@pixaweb.net> */
static zend_object *mapscript_grid_create_object(zend_class_entry *ce TSRMLS_DC)
@@ -225,17 +236,6 @@ PHP_MINIT_FUNCTION(grid)
}
#else
/* PHP5 */
-void mapscript_create_grid(graticuleObj *grid, parent_object parent, zval *return_value TSRMLS_DC)
-{
- php_grid_object * php_grid;
- object_init_ex(return_value, mapscript_ce_grid);
- php_grid = MAPSCRIPT_OBJ_P(php_grid_object, return_value);
- php_grid->grid = grid;
-
- php_grid->parent = parent;
- MAPSCRIPT_ADDREF(parent.val);
-}
-
static void mapscript_grid_object_destroy(void *object TSRMLS_DC)
{
php_grid_object *php_grid = (php_grid_object *)object;
@@ -277,4 +277,4 @@ PHP_MINIT_FUNCTION(grid)
return SUCCESS;
}
-#endif
\ No newline at end of file
+#endif