com gtk/php-gtk: Forgot to commit phpg_gpointer.c: main /phpg_gpointer.c

[email protected] (David Soria Parra) Sat, 01 Oct 2005 22:44:51 +0000
Newsgroups php.gtk.cvs
Message-ID <[email protected]>
Commit:    3e1b3e866d12464ff26d1fdc69cf291859f8f90f=0AAuthor:    Andrei Zmi=
evski <[email protected]>         Sat, 1 Oct 2005 22:44:51 +0000=0AParents:   =
cbf79bfbd31fccd672be7049a4aa16a905d3eca8=0ABranches:  master=0A=0ALink:    =
   http://git.php.net/?p=3Dgtk/php-gtk.git;a=3Dcommitdiff;h=3D3e1b3e866d124=
64ff26d1fdc69cf291859f8f90f=0A=0ALog:=0AForgot to commit phpg_gpointer.c=0A=
=0AChanged paths:=0A  A  main/phpg_gpointer.c=0A=0A=0ADiff:=0A3e1b3e866d124=
64ff26d1fdc69cf291859f8f90f=0Adiff --git a/main/phpg_gpointer.c b/main/phpg=
_gpointer.c=0Anew file mode 100644=0Aindex 0000000..3a85773=0A--- /dev/null=
=0A+++ b/main/phpg_gpointer.c=0A@@ -0,0 +1,102 @@=0A+/*=0A+ * PHP-GTK - The=
 PHP language bindings for GTK+=0A+ *=0A+ * Copyright (C) 2001-2004 Andrei =
Zmievski <[email protected]>=0A+ *=0A+ * This library is free software; you ca=
n redistribute it and/or=0A+ * modify it under the terms of the GNU Lesser =
General Public=0A+ * License as published by the Free Software Foundation; =
either=0A+ * version 2.1 of the License, or (at your option) any later vers=
ion.=0A+ * =0A+ * This library is distributed in the hope that it will be u=
seful,=0A+ * but WITHOUT ANY WARRANTY; without even the implied warranty of=
=0A+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU=0A=
+ * Lesser General Public License for more details.=0A+ * =0A+ * You should=
 have received a copy of the GNU Lesser General Public=0A+ * License along =
with this library; if not, write to the Free Software=0A+ * Foundation, Inc=
., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA=0A+ */=0A+=0A+#i=
nclude "php_gtk.h"=0A+=0A+#if HAVE_PHP_GTK=0A+=0A+/*=0A+ * GPointer API and=
 helper functions=0A+ */=0A+PHP_GTK_EXPORT_CE(gpointer_ce) =3D NULL;=0A+=0A=
+static function_entry gpointer_methods[] =3D {=0A+    PHP_ME_MAPPING(__con=
struct, no_direct_constructor, NULL)=0A+    { NULL, NULL, NULL }=0A+};=0A+=
=0A+/* {{{ static phpg_free_gpointer_storage() */=0A+static void phpg_free_=
gpointer_storage(phpg_gpointer_t *object TSRMLS_DC)=0A+{=0A+=09zend_hash_de=
stroy(object->zobj.properties);=0A+=09FREE_HASHTABLE(object->zobj.propertie=
s);=0A+=09efree(object);=0A+}=0A+/* }}} */=0A+=0A+/* {{{ PHP_GTK_API phpg_c=
reate_gpointer() */=0A+PHP_GTK_API zend_object_value phpg_create_gpointer(z=
end_class_entry *ce TSRMLS_DC)=0A+{=0A+=09zend_object_value zov;=0A+=09phpg=
_gpointer_t *object;=0A+=0A+=09object =3D emalloc(sizeof(phpg_gpointer_t));=
=0A+=09phpg_init_object(object, ce);=0A+=0A+=09object->pointer =3D NULL;=0A=
+=09object->gtype =3D 0;=0A+=0A+=09zov.handlers =3D &php_gtk_handlers;=0A+=
=09zov.handle =3D zend_objects_store_put(object, (zend_objects_store_dtor_t=
) zend_objects_destroy_object, (zend_objects_free_object_storage_t) phpg_fr=
ee_gpointer_storage, NULL TSRMLS_CC);=0A+=0A+=09return zov;=0A+}=0A+/* }}} =
*/=0A+=0A+/* {{{ PHP_GTK_API phpg_gpointer_new() */=0A+PHP_GTK_API void php=
g_gpointer_new(zval **zobj, GType gtype, gpointer pointer TSRMLS_DC)=0A+{=
=0A+    zend_class_entry *ce =3D NULL;=0A+    phpg_gpointer_t *pobj =3D NUL=
L;=0A+=0A+    assert(zobj !=3D NULL);=0A+    if (*zobj =3D=3D NULL) {=0A+  =
      MAKE_STD_ZVAL(*zobj);=0A+    }=0A+    ZVAL_NULL(*zobj);=0A+=0A+    ph=
pg_return_if_fail(gtype !=3D 0);=0A+    phpg_return_if_fail(pointer !=3D NU=
LL);=0A+=0A+    ce =3D g_type_get_qdata(gtype, phpg_class_key);=0A+    if (=
!ce) {=0A+        ce =3D gpointer_ce;=0A+    }=0A+    object_init_ex(*zobj,=
 ce);=0A+=0A+    pobj =3D zend_object_store_get_object(*zobj TSRMLS_CC);=0A=
+    pobj->gtype =3D gtype;=0A+    pobj->pointer =3D pointer;=0A+}=0A+/* }}=
} */=0A+=0A+/* {{{ phpg_gpointer_register_self() */=0A+void phpg_gpointer_r=
egister_self(TSRMLS_D)=0A+{=0A+=09if (gpointer_ce) return;=0A+=0A+=09gpoint=
er_ce =3D phpg_register_class("GPointer", gpointer_methods, NULL, 0, NULL, =
phpg_create_gpointer, G_TYPE_POINTER TSRMLS_CC);=0A+    phpg_register_int_c=
onstant(gpointer_ce, "gtype", sizeof("gtype")-1, G_TYPE_BOXED);=0A+}=0A+/* =
}}} */=0A+=0A+#endif /* HAVE_PHP_GTK */=0A+=0A+/* vim: set fdm=3Dmarker et =
sts=3D4: */=0A