cvs: php-gtk /ext/gtk+ php_gtk+_types.c /generator arg_types.php /main php_gtk.h

[email protected] ("Andrei Zmievski")
Newsgroups php.gtk
Message-ID <cvsandrei996613952@cvsserver>
andrei		Tue Jul 31 17:12:32 2001 EDT

  Modified files:              
    /php-gtk/ext/gtk+	php_gtk+_types.c 
    /php-gtk/generator	arg_types.php 
    /php-gtk/main	php_gtk.h 
  Log:
  Fixed bug with GtkStyle::copy() that could cause crash in certain cases
  depending on where the result was used.
  
  
Index: php-gtk/ext/gtk+/php_gtk+_types.c
diff -u php-gtk/ext/gtk+/php_gtk+_types.c:1.8 php-gtk/ext/gtk+/php_gtk+_types.c:1.9
--- php-gtk/ext/gtk+/php_gtk+_types.c:1.8	Tue Jul 31 01:27:00 2001
+++ php-gtk/ext/gtk+/php_gtk+_types.c	Tue Jul 31 17:12:31 2001
@@ -18,7 +18,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/* $Id: php_gtk+_types.c,v 1.8 2001/07/31 05:27:00 andrei Exp $ */
+/* $Id: php_gtk+_types.c,v 1.9 2001/07/31 21:12:31 andrei Exp $ */
 
 #include "php_gtk.h"
 
@@ -1927,6 +1927,7 @@
 PHP_FUNCTION(gtk_style_copy)
 {
 	GtkStyle *style;
+	zval *ret;
 
 	NOT_STATIC_METHOD();
 
@@ -1934,7 +1935,7 @@
 		return;
 
 	style = gtk_style_copy(PHP_GTK_STYLE_GET(this_ptr));
-	*return_value = *php_gtk_style_new(style);
+	PHP_GTK_SEPARATE_RETURN(return_value, php_gtk_style_new(style));
 	gtk_style_unref(style);
 }
 
Index: php-gtk/generator/arg_types.php
diff -u php-gtk/generator/arg_types.php:1.26 php-gtk/generator/arg_types.php:1.27
--- php-gtk/generator/arg_types.php:1.26	Tue Jul 31 01:27:00 2001
+++ php-gtk/generator/arg_types.php	Tue Jul 31 17:12:32 2001
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/* $Id: arg_types.php,v 1.26 2001/07/31 05:27:00 andrei Exp $ */
+/* $Id: arg_types.php,v 1.27 2001/07/31 21:12:32 andrei Exp $ */
 
 /*======================================================================*\
 	Function: convert_typename
@@ -412,11 +412,13 @@
 	
 	function write_return($type, &$var_list, $separate)
 	{
-		$var_list->add('zval', '*ret');
-		return 	"	ret = php_gtk_new((GtkObject *)%s);\n" .
-				($separate ?  "	SEPARATE_ZVAL(&ret);\n" : "") .
-				"	*return_value = *ret;\n" .
-				"%s	return;";
+		if ($separate) {
+			return 	"	PHP_GTK_SEPARATE_RETURN(return_value, php_gtk_new((GtkObject *)%s));\n" .
+					"%s	return;";
+		} else {
+			return 	"	*return_value = *php_gtk_new((GtkObject *)%s);\n" .
+					"%s	return;";
+		}
 	}
 }
 
@@ -492,11 +494,13 @@
 
 	function write_return($type, &$var_list, $separate)
 	{
-		$var_list->add('zval', '*ret');
-		return "	ret = php_" . $this->php_type . "_new(%s);\n" .
-			   ($separate ? "	SEPARATE_ZVAL(&ret);\n" : "") .
-			   "	*return_value = *ret;\n" .
-			   "%s	return;";
+		if ($separate) {
+			return 	"	PHP_GTK_SEPARATE_RETURN(return_value, php_" . $this->php_type . "_new(%s));\n" .
+					"%s	return;";
+		} else {
+			return 	"	*return_value = *php_" . $this->php_type . "_new(%s);\n" .
+					"%s	return;";
+		}
 	}
 }
 
@@ -508,6 +512,8 @@
 	}
 }
 
+/* This is a hack -- the $default handling doesn't work, neither does
+   write_return(). */ 
 class Drawable_Arg extends Arg_Type {
 	var $type = 'GdkDrawable';
 
Index: php-gtk/main/php_gtk.h
diff -u php-gtk/main/php_gtk.h:1.47 php-gtk/main/php_gtk.h:1.48
--- php-gtk/main/php_gtk.h:1.47	Tue Jul 31 01:27:01 2001
+++ php-gtk/main/php_gtk.h	Tue Jul 31 17:12:32 2001
@@ -18,7 +18,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
  
-/* $Id: php_gtk.h,v 1.47 2001/07/31 05:27:01 andrei Exp $: */
+/* $Id: php_gtk.h,v 1.48 2001/07/31 21:12:32 andrei Exp $: */
 
 #ifndef _PHP_GTK_H
 #define _PHP_GTK_H
@@ -30,6 +30,14 @@
 #define PHP_GTK_EXPORT_CE(ce) zend_class_entry *ce
 #define PHP_GTK_EXPORT_FUNC(func) func
 #define PHP_GTK_GET_GENERIC(w, type, le) ((type)php_gtk_get_object(w, le))
+#define PHP_GTK_SEPARATE_RETURN(return_value, result)			\
+	{															\
+		zval *ret;												\
+																\
+		ret = result;											\
+		SEPARATE_ZVAL(&ret);									\
+		*return_value = *ret;									\
+	}
 
 #undef PG_ERROR
 #define PG_ERROR -2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.