logo       

cvs: php-gtk /main php_gtk.c php_gtk.h phpg_gtype.c phpg_gvalue.c: msg#00009

Subject: cvs: php-gtk /main php_gtk.c php_gtk.h phpg_gtype.c phpg_gvalue.c
andrei          Thu Apr  7 17:08:53 2005 EDT

  Modified files:              
    /php-gtk/main       php_gtk.c php_gtk.h phpg_gtype.c phpg_gvalue.c 
  Log:
  - Better detection of valid GTypes in phpg_gtype_from_zval().
  
  
http://cvs.php.net/diff.php/php-gtk/main/php_gtk.c?r1=1.46&r2=1.47&ty=u
Index: php-gtk/main/php_gtk.c
diff -u php-gtk/main/php_gtk.c:1.46 php-gtk/main/php_gtk.c:1.47
--- php-gtk/main/php_gtk.c:1.46 Wed Apr  6 23:02:52 2005
+++ php-gtk/main/php_gtk.c      Thu Apr  7 17:08:51 2005
@@ -18,7 +18,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
  
-/* $Id: php_gtk.c,v 1.46 2005/04/07 03:02:52 andrei Exp $: */
+/* $Id: php_gtk.c,v 1.47 2005/04/07 21:08:51 andrei Exp $: */
 
 #include "php_gtk.h"
 #include "SAPI.h"
@@ -43,7 +43,7 @@
 
 const gchar *phpg_class_id = "phpg_class";
 GQuark phpg_class_key = 0;
-GType G_TYPE_PHP_OBJECT = 0;
+GType G_TYPE_PHP_VALUE = 0;
 
 zend_module_entry gtk_module_entry = {
 #if ZEND_MODULE_API_NO >= 20010901
@@ -167,7 +167,7 @@
        phpg_gobject_register_self(TSRMLS_C);
        phpg_gboxed_register_self(TSRMLS_C);
 
-       G_TYPE_PHP_OBJECT = g_boxed_type_register_static("PhpObject", 
php_object_copy, php_object_release);
+       G_TYPE_PHP_VALUE = g_boxed_type_register_static("PhpValue", 
php_object_copy, php_object_release);
 
        if (php_gtk_startup_all_extensions(module_number) == FAILURE) {
                php_error(E_WARNING, "Unable to start internal extensions");
http://cvs.php.net/diff.php/php-gtk/main/php_gtk.h?r1=1.109&r2=1.110&ty=u
Index: php-gtk/main/php_gtk.h
diff -u php-gtk/main/php_gtk.h:1.109 php-gtk/main/php_gtk.h:1.110
--- php-gtk/main/php_gtk.h:1.109        Wed Apr  6 23:02:52 2005
+++ php-gtk/main/php_gtk.h      Thu Apr  7 17:08:51 2005
@@ -18,7 +18,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
  
-/* $Id: php_gtk.h,v 1.109 2005/04/07 03:02:52 andrei Exp $: */
+/* $Id: php_gtk.h,v 1.110 2005/04/07 21:08:51 andrei Exp $: */
 
 #ifndef _PHP_GTK_H
 #define _PHP_GTK_H
@@ -193,7 +193,7 @@
 /* IDs for type identification */
 extern const gchar *phpg_class_id;
 extern GQuark phpg_class_key;
-extern GType G_TYPE_PHP_OBJECT;
+extern GType G_TYPE_PHP_VALUE;
 
 /* Exceptions */
 extern PHP_GTK_API zend_class_entry *phpg_generic_exception;
http://cvs.php.net/diff.php/php-gtk/main/phpg_gtype.c?r1=1.13&r2=1.14&ty=u
Index: php-gtk/main/phpg_gtype.c
diff -u php-gtk/main/phpg_gtype.c:1.13 php-gtk/main/phpg_gtype.c:1.14
--- php-gtk/main/phpg_gtype.c:1.13      Wed Apr  6 23:02:53 2005
+++ php-gtk/main/phpg_gtype.c   Thu Apr  7 17:08:51 2005
@@ -115,14 +115,19 @@
                        return G_TYPE_NONE;
 
                /*
-                * We check if the number corresponds to a valid GType. 
Returning the
+                * We check if the number corresponds to a valid GType. Return 
the
                 * corresponding type, if it does, assume a G_TYPE_INT 
otherwise.
                 */
                case IS_LONG:
                {
                        GTypeQuery tq;
-                       g_type_query(Z_LVAL_P(value), &tq);
-                       return tq.type ? tq.type : G_TYPE_INT;
+
+                       if (G_TYPE_IS_FUNDAMENTAL(Z_LVAL_P(value)) ||
+                               G_TYPE_IS_CLASSED(Z_LVAL_P(value)) ||
+                               G_TYPE_FUNDAMENTAL(Z_LVAL_P(value)) == 
G_TYPE_BOXED) {
+                               return Z_LVAL_P(value);
+                       }
+                       return G_TYPE_INT;
                }
 
                case IS_DOUBLE:
@@ -143,6 +148,9 @@
                case IS_BOOL:
                        return G_TYPE_BOOLEAN;
 
+               case IS_ARRAY:
+                       return G_TYPE_PHP_VALUE;
+
                case IS_OBJECT:
                        if (Z_OBJCE_P(value) == gtype_ce) {
                                phpg_gtype_t *object = 
zend_object_store_get_object(value TSRMLS_CC);
@@ -160,9 +168,9 @@
                                                return Z_LVAL_PP(gtype);
                                } else {
                                        /*
-                                        * Or it's a regular PHP object, but 
with our own GType.
+                                        * Or it's a regular PHP value, but 
with our own GType.
                                         */
-                                       return G_TYPE_PHP_OBJECT;
+                                       return G_TYPE_PHP_VALUE;
                                }
                        }
                        break;
http://cvs.php.net/diff.php/php-gtk/main/phpg_gvalue.c?r1=1.18&r2=1.19&ty=u
Index: php-gtk/main/phpg_gvalue.c
diff -u php-gtk/main/phpg_gvalue.c:1.18 php-gtk/main/phpg_gvalue.c:1.19
--- php-gtk/main/phpg_gvalue.c:1.18     Wed Apr  6 23:02:53 2005
+++ php-gtk/main/phpg_gvalue.c  Thu Apr  7 17:08:51 2005
@@ -124,13 +124,14 @@
         {
             phpg_gboxed_marshal_t *gbm;
 
-            if (G_VALUE_HOLDS(gval, G_TYPE_PHP_OBJECT)) {
+            if (G_VALUE_HOLDS(gval, G_TYPE_PHP_VALUE)) {
                 zval *object = (zval *) g_value_dup_boxed(gval);
+                MAKE_ZVAL_IF_NULL(*value);
                 if (object) {
-                    *value = object;
+                    REPLACE_ZVAL_VALUE(value, object, 1);
+                    zval_ptr_dtor(&object);
                     return SUCCESS;
                 } else {
-                    MAKE_ZVAL_IF_NULL(*value);
                     ZVAL_NULL(*value);
                     return FAILURE;
                 }
@@ -250,7 +251,7 @@
 
             if (Z_TYPE_P(value) == IS_NULL) {
                 g_value_set_boxed(gval, NULL);
-            } else if (G_VALUE_HOLDS(gval, G_TYPE_PHP_OBJECT) && 
phpg_gtype_from_zval(value) == G_TYPE_PHP_OBJECT) {
+            } else if (G_VALUE_HOLDS(gval, G_TYPE_PHP_VALUE) && 
phpg_gtype_from_zval(value) == G_TYPE_PHP_VALUE) {
                 g_value_set_boxed(gval, value);
             } else if (Z_TYPE_P(value) == IS_OBJECT
                        && instanceof_function(Z_OBJCE_P(value), gboxed_ce 
TSRMLS_CC)



-- 
PHP-GTK CVS Mailing List (http://gtk.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe