Home  |  Linux  | Mysql  | PHP  | XML
From:Gopal Vijayaraghavan Date:Fri Aug 22 09:09:53 2008
Subject:cvs: pecl /hidef frozenarray.c /hidef/tests hidef_004.phpt
gopalv		Fri Aug 22 15:09:53 2008 UTC

  Modified files:              
    /pecl/hidef	frozenarray.c 
    /pecl/hidef/tests	hidef_004.phpt 
  Log:
  implement FrozenArray::__toString()
  
http://cvs.php.net/viewvc.cgi/pecl/hidef/frozenarray.c?r1=1.5&r2=1.6&diff_format=u
Index: pecl/hidef/frozenarray.c
diff -u pecl/hidef/frozenarray.c:1.5 pecl/hidef/frozenarray.c:1.6
--- pecl/hidef/frozenarray.c:1.5	Wed Aug 20 18:09:01 2008
+++ pecl/hidef/frozenarray.c	Fri Aug 22 15:09:53 2008
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: frozenarray.c,v 1.5 2008/08/20 18:09:01 gopalv Exp $ */
+/* $Id: frozenarray.c,v 1.6 2008/08/22 15:09:53 gopalv Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -27,6 +27,7 @@
 #include "zend_interfaces.h"
 #include "php_streams.h"
 #include "ext/standard/php_var.h"
+#include "ext/standard/php_smart_str.h"
 
 #include "php_hidef.h"
 #include "frozenarray.h"
@@ -261,6 +262,24 @@
 	/* throw exception */
 }
 
+FROZEN_METHOD(__toString)
+{
+	smart_str str = {0,};
+	zval *object = getThis();
+	frozen_array_object *intern = (frozen_array_object*)zend_object_store_get_object(object TSRMLS_CC);
+	HashTable *data = Z_ARRVAL_P(intern->data);
+
+	smart_str_appends(&str, "FrozenArray[");
+	smart_str_append_unsigned(&str, data->nNumOfElements);
+	smart_str_appends(&str, "]");
+	smart_str_0(&str);
+
+	RETVAL_STRING(str.c, 1);
+
+	smart_str_free(&str);
+	return;
+}
+
 static
 ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetGet, 0, 0, 1)
 	ZEND_ARG_INFO(0, index)
@@ -277,7 +296,7 @@
 	PHP_ME(FrozenArray, offsetGet,    arginfo_offsetGet, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
 	PHP_ME(FrozenArray, offsetSet,    arginfo_offsetSet, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
 	PHP_ME(FrozenArray, offsetUnset,  arginfo_offsetGet, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
-	PHP_ME(FrozenArray, offsetUnset,  arginfo_offsetGet, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
+	PHP_ME(FrozenArray, __toString,   NULL,              ZEND_ACC_PUBLIC)
 	{ NULL, NULL, NULL}
 };
 
http://cvs.php.net/viewvc.cgi/pecl/hidef/tests/hidef_004.phpt?r1=1.1&r2=1.2&diff_format=u
Index: pecl/hidef/tests/hidef_004.phpt
diff -u pecl/hidef/tests/hidef_004.phpt:1.1 pecl/hidef/tests/hidef_004.phpt:1.2
--- pecl/hidef/tests/hidef_004.phpt:1.1	Wed Aug 20 18:09:30 2008
+++ pecl/hidef/tests/hidef_004.phpt	Fri Aug 22 15:09:53 2008
@@ -8,6 +8,8 @@
 <?php
 $a = hidef_fetch("array2");
 
+echo $a."\n";
+
 echo '"0" => '.$a[0]."\n";
 echo '"1" => '.$a[1]."\n";
 echo '"2" => '.$a[2]."\n";
@@ -17,6 +19,8 @@
 
 $sub = $a[6];
 
+echo $sub."\n";
+
 echo '"one" => '.$sub["one"]."\n";
 echo '"two" => '.$sub["two"]."\n";
 echo '"three" => '.$sub["three"]."\n";
@@ -24,12 +28,14 @@
 ===DONE===
 <?php exit(0); ?>
 --EXPECTF--
+FrozenArray[7]
 "0" => 1
 "1" => 
 "2" => 0
 "3" => 1
 "4" => 3.14
 "5" => hello world
+FrozenArray[3]
 "one" => 1
 "two" => 2
 "three" => 3


Navigate in group php.pecl.cvs at sever news.php.net
Previous Next




  
© No Copyright
You are free to use Anything
Site Maintained by PHP Developer
Powered By PHP Consultants