[mapserver-commits] r10969 - trunk/mapserver/mapscript/php

svn at osgeo.org svn at osgeo.org
Tue Feb 8 13:27:04 EST 2011


Author: aboudreault
Date: 2011-02-08 10:27:04 -0800 (Tue, 08 Feb 2011)
New Revision: 10969

Modified:
   trunk/mapserver/mapscript/php/mapscript_i.c
   trunk/mapserver/mapscript/php/php_mapscript.h
   trunk/mapserver/mapscript/php/result.c
Log:
Modified resultObj to be instanciate iin PHP/MapScript

Modified: trunk/mapserver/mapscript/php/mapscript_i.c
===================================================================
--- trunk/mapserver/mapscript/php/mapscript_i.c	2011-02-08 05:59:32 UTC (rev 10968)
+++ trunk/mapserver/mapscript/php/mapscript_i.c	2011-02-08 18:27:04 UTC (rev 10969)
@@ -1536,3 +1536,12 @@
 char *hashTableObj_nextKey(hashTableObj *self, const char *previousKey) {
    return ((char *)msNextKeyFromHashTable(self, previousKey));
 }
+
+resultObj *resultObj_new() {
+    resultObj *r = (resultObj *) msSmallMalloc(sizeof(resultObj));
+    r->tileindex = -1;
+    r->shapeindex = -1;
+    r->resultindex = -1;
+    return r;
+}
+

Modified: trunk/mapserver/mapscript/php/php_mapscript.h
===================================================================
--- trunk/mapserver/mapscript/php/php_mapscript.h	2011-02-08 05:59:32 UTC (rev 10968)
+++ trunk/mapserver/mapscript/php/php_mapscript.h	2011-02-08 18:27:04 UTC (rev 10969)
@@ -760,4 +760,6 @@
 char *cgirequestObj_getValueByName(cgiRequestObj *self, const char *name);
 void cgirequestObj_destroy(cgiRequestObj *self);
 
+resultObj *resultObj_new();
+
 #endif /* PHP_MAPSCRIPT_H */

Modified: trunk/mapserver/mapscript/php/result.c
===================================================================
--- trunk/mapserver/mapscript/php/result.c	2011-02-08 05:59:32 UTC (rev 10968)
+++ trunk/mapserver/mapscript/php/result.c	2011-02-08 18:27:04 UTC (rev 10969)
@@ -33,6 +33,10 @@
 
 zend_class_entry *mapscript_ce_result;
 
+ZEND_BEGIN_ARG_INFO_EX(result___construct_args, 0, 0, 1)
+  ZEND_ARG_INFO(0, shapeindex)
+ZEND_END_ARG_INFO()
+
 ZEND_BEGIN_ARG_INFO_EX(result___get_args, 0, 0, 1)
   ZEND_ARG_INFO(0, property)
 ZEND_END_ARG_INFO()
@@ -42,11 +46,31 @@
   ZEND_ARG_INFO(0, value)
 ZEND_END_ARG_INFO()
 
+
 /* {{{ proto resultObj __construct()
-   resultObj CANNOT be instanciated, this will throw an exception on use */
+   Create a new resultObj instance */
 PHP_METHOD(resultObj, __construct)
 {
-    mapscript_throw_exception("resultObj cannot be constructed" TSRMLS_CC);
+    long shapeindex;
+    php_result_object *php_result;
+
+    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
+    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
+                              &shapeindex) == FAILURE) {
+        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
+        return;
+    }
+    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
+
+    php_result = (php_result_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
+    
+    if ((php_result->result = resultObj_new()) == NULL)
+    {
+        mapscript_throw_exception("Unable to construct resultObj." TSRMLS_CC);
+        return;
+    }
+    
+    php_result->result->shapeindex = shapeindex;
 }
 /* }}} */
 
@@ -109,7 +133,7 @@
 }
 
 zend_function_entry result_functions[] = {
-    PHP_ME(resultObj, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
+    PHP_ME(resultObj, __construct, result___construct_args, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
     PHP_ME(resultObj, __get, result___get_args, ZEND_ACC_PUBLIC)
     PHP_ME(resultObj, __set, result___set_args, ZEND_ACC_PUBLIC)
     {NULL, NULL, NULL}



More information about the mapserver-commits mailing list