cvs: php-gtk / NEWS /build2 build2.mk /ext/gtk+ Makefile.in gdk.defs gtk-extrafuncs.defs gtk.defs gtk.overrides php_gtk+.h php_gtk+_types.c /generator arg_types.php definitions.php generator.php scheme.php templates.php /main php_gtk.h /test scribble.php
[email protected] ("Andrei Zmievski")
| Newsgroups | php.gtk |
|---|---|
| Message-ID | <cvsandrei996557221@cvsserver> |
andrei Tue Jul 31 01:27:01 2001 EDT
Modified files:
/php-gtk NEWS
/php-gtk/build2 build2.mk
/php-gtk/ext/gtk+ Makefile.in gdk.defs gtk-extrafuncs.defs gtk.defs
gtk.overrides php_gtk+.h php_gtk+_types.c
/php-gtk/generator arg_types.php definitions.php generator.php
scheme.php templates.php
/php-gtk/main php_gtk.h
/php-gtk/test scribble.php
Log:
- Fix config.h.in generation.
- Changed GtkWidget::state() method to GtkWidget->state property.
- Removed GtkWidget::get_allocation(), it is redundant with GtkWidget->allocation
property present.
- Implemented support for struct based classes (GdkRectable, GtkAllocation,
GtkRequisition, etc).
0.1 is on the horizon.
andrei-20010731012701.txt
(text/plain, 21 KB)
Index: php-gtk/NEWS
diff -u php-gtk/NEWS:1.31 php-gtk/NEWS:1.32
--- php-gtk/NEWS:1.31 Mon Jul 30 01:11:15 2001
+++ php-gtk/NEWS Tue Jul 31 01:27:00 2001
@@ -1,3 +1,5 @@
+ - implemented support for struct based classes (GdkRectangle, GtkAllocation,
+ GtkRequisition, etc). (Andrei)
- finished drag-n-drop support. (Andrei)
- ported Scribble example from C. (Andrei)
- modified GdkWindow::get_pointer() to be simpler, without XInput support.
Index: php-gtk/build2/build2.mk
diff -u php-gtk/build2/build2.mk:1.2 php-gtk/build2/build2.mk:1.3
--- php-gtk/build2/build2.mk:1.2 Tue Jul 10 17:19:03 2001
+++ php-gtk/build2/build2.mk Tue Jul 31 01:27:00 2001
@@ -1,15 +1,15 @@
-# $Id: build2.mk,v 1.2 2001/07/10 21:19:03 andrei Exp $
+# $Id: build2.mk,v 1.3 2001/07/31 05:27:00 andrei Exp $
#
include build2/generated_lists
-all: configure config.h
+all: configure config.h.in
configure: aclocal.m4 config.m4 php_gtk.m4 configure.in $(config_m4_files)
@echo rebuilding $@
@autoconf
-config.h: configure
+config.h.in: configure
# explicitly remove target since autoheader does not seem to work
# correctly otherwise (timestamps are not updated)
@echo rebuilding $@
Index: php-gtk/ext/gtk+/Makefile.in
diff -u php-gtk/ext/gtk+/Makefile.in:1.2 php-gtk/ext/gtk+/Makefile.in:1.3
--- php-gtk/ext/gtk+/Makefile.in:1.2 Tue Jul 10 14:27:47 2001
+++ php-gtk/ext/gtk+/Makefile.in Tue Jul 31 01:27:00 2001
@@ -6,7 +6,7 @@
include $(top_srcdir)/build/dynlib.mk
-php_gtk+.o php_gtk+.lo php_gtk+.slo: gen_ce_gtk.h
+php_gtk+.o php_gtk+.lo php_gtk+.slo: gen_gtk.h
gen_gtk.c: gtk.defs gtk-extrafuncs.defs gtk.overrides
php -q $(top_srcdir)/generator/generator.php -o ext/gtk%2b/gtk.overrides -p gtk ext/gtk%2b/gtk.defs > gen_gtk.c
@@ -14,6 +14,6 @@
gen_gdk.c: gdk.defs gdk.overrides
php -q $(top_srcdir)/generator/generator.php -o ext/gtk%2b/gdk.overrides -p gdk ext/gtk%2b/gdk.defs > gen_gdk.c
-gen_ce_gtk.h: gen_gtk.c gen_gdk.c
- grep -h "^PHP_GTK_EXPORT_CE" gen_gtk.c gen_gdk.c | sed -e "s!^!extern !" > gen_ce_gtk.h
-
+gen_gtk.h: gen_gtk.c gen_gdk.c
+ grep -h "^PHP_GTK_EXPORT_CE" gen_gtk.c gen_gdk.c | sed -e "s!^!extern !" > gen_gtk.h
+ grep -h "PHP_GTK_EXPORT_FUNC" gen_gtk.c gen_gdk.c | sed -e 's!$$!;!' >> gen_gtk.h
Index: php-gtk/ext/gtk+/gdk.defs
diff -u php-gtk/ext/gtk+/gdk.defs:1.2 php-gtk/ext/gtk+/gdk.defs:1.3
--- php-gtk/ext/gtk+/gdk.defs:1.2 Tue Jul 10 14:27:48 2001
+++ php-gtk/ext/gtk+/gdk.defs Tue Jul 31 01:27:00 2001
@@ -1,4 +1,15 @@
;; -*- scheme -*-
+;; Structs
+
+(struct Rectangle
+ (in-module Gdk)
+ (c-name GdkRectangle)
+ (field (type-and-name gint16 x))
+ (field (type-and-name gint16 y))
+ (field (type-and-name guint16 width))
+ (field (type-and-name guint16 height))
+)
+
;; Enumerations and flags ...
(flags ColorInfoFlags
Index: php-gtk/ext/gtk+/gtk-extrafuncs.defs
diff -u php-gtk/ext/gtk+/gtk-extrafuncs.defs:1.3 php-gtk/ext/gtk+/gtk-extrafuncs.defs:1.4
--- php-gtk/ext/gtk+/gtk-extrafuncs.defs:1.3 Thu Jul 19 01:24:16 2001
+++ php-gtk/ext/gtk+/gtk-extrafuncs.defs Tue Jul 31 01:27:00 2001
@@ -19,15 +19,3 @@
(return-type none)
(parameter (type-and-name guint flags))
)
-
-(method state
- (of-object Widget (Gtk))
- (c-name GTK_WIDGET_STATE)
- (return-type guint)
-)
-
-(method get_allocation
- (of-object Widget (Gtk))
- (c-name gtk_widget_get_allocation)
- (return-type GtkAllocation)
-)
Index: php-gtk/ext/gtk+/gtk.defs
diff -u php-gtk/ext/gtk+/gtk.defs:1.4 php-gtk/ext/gtk+/gtk.defs:1.5
--- php-gtk/ext/gtk+/gtk.defs:1.4 Thu Jul 19 01:24:16 2001
+++ php-gtk/ext/gtk+/gtk.defs Tue Jul 31 01:27:00 2001
@@ -43,6 +43,7 @@
(field (type-and-name GtkStyle* style))
(field (type-and-name GdkWindow* window))
(field (type-and-name GtkAllocation allocation))
+ (field (type-and-name guint state))
)
(object Separator
@@ -640,6 +641,24 @@
(in-module Gtk)
(parent Frame (Gtk))
(c-name GtkAspectFrame)
+)
+
+;; Structs
+
+(struct Allocation
+ (in-module Gtk)
+ (c-name GtkAllocation)
+ (field (type-and-name gint16 x))
+ (field (type-and-name gint16 y))
+ (field (type-and-name guint16 width))
+ (field (type-and-name guint16 height))
+)
+
+(struct Requisition
+ (in-module Gtk)
+ (c-name GtkRequisition)
+ (field (type-and-name gint16 width))
+ (field (type-and-name gint16 height))
)
;; Enumerations and flags ...
Index: php-gtk/ext/gtk+/gtk.overrides
diff -u php-gtk/ext/gtk+/gtk.overrides:1.7 php-gtk/ext/gtk+/gtk.overrides:1.8
--- php-gtk/ext/gtk+/gtk.overrides:1.7 Mon Jul 30 20:37:00 2001
+++ php-gtk/ext/gtk+/gtk.overrides Tue Jul 31 01:27:00 2001
@@ -2024,15 +2024,6 @@
RETURN_LONG(pos);
}
%%
-getprop GtkWidget allocation
- GtkWidget *widget = GTK_WIDGET(PHP_GTK_GET(object));
-
- object_init_ex(return_value, gtk_allocation_ce);
- add_property_long(return_value, "x", widget->allocation.x);
- add_property_long(return_value, "y", widget->allocation.y);
- add_property_long(return_value, "width", widget->allocation.width);
- add_property_long(return_value, "height", widget->allocation.height);
-%%
override gtk_drag_dest_set
PHP_FUNCTION(wrap_gtk_drag_dest_set)
{
Index: php-gtk/ext/gtk+/php_gtk+.h
diff -u php-gtk/ext/gtk+/php_gtk+.h:1.7 php-gtk/ext/gtk+/php_gtk+.h:1.8
--- php-gtk/ext/gtk+/php_gtk+.h:1.7 Mon Jul 30 20:37:00 2001
+++ php-gtk/ext/gtk+/php_gtk+.h Tue Jul 31 01:27:00 2001
@@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: php_gtk+.h,v 1.7 2001/07/31 00:37:00 fmk Exp $: */
+/* $Id: php_gtk+.h,v 1.8 2001/07/31 05:27:00 andrei Exp $: */
#ifndef _PHP_GTK_PLUS_H
#define _PHP_GTK_PLUS_H
@@ -43,7 +43,7 @@
extern int le_gtk_accel_group;
extern int le_gtk_style;
-inline GdkAtom php_gdk_atom_get(zval *wrapper)
+static inline GdkAtom php_gdk_atom_get(zval *wrapper)
{
zval **atom;
@@ -90,7 +90,7 @@
extern PHP_GTK_EXPORT_CE(gtk_clist_row_ce);
extern PHP_GTK_EXPORT_CE(gtk_allocation_ce);
-#include "gen_ce_gtk.h"
+#include "gen_gtk.h"
zval *php_gtk_new(GtkObject *obj);
zval *php_gdk_event_new(GdkEvent *event);
Index: php-gtk/ext/gtk+/php_gtk+_types.c
diff -u php-gtk/ext/gtk+/php_gtk+_types.c:1.7 php-gtk/ext/gtk+/php_gtk+_types.c:1.8
--- php-gtk/ext/gtk+/php_gtk+_types.c:1.7 Mon Jul 30 20:37:00 2001
+++ php-gtk/ext/gtk+/php_gtk+_types.c Tue Jul 31 01:27:00 2001
@@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: php_gtk+_types.c,v 1.7 2001/07/31 00:37:00 fmk Exp $ */
+/* $Id: php_gtk+_types.c,v 1.8 2001/07/31 05:27:00 andrei Exp $ */
#include "php_gtk.h"
@@ -59,7 +59,6 @@
PHP_GTK_EXPORT_CE(gtk_box_child_ce);
PHP_GTK_EXPORT_CE(gtk_fixed_child_ce);
PHP_GTK_EXPORT_CE(gtk_clist_row_ce);
-PHP_GTK_EXPORT_CE(gtk_allocation_ce);
/* GdkEvent */
static function_entry php_gdk_event_functions[] = {
@@ -98,13 +97,7 @@
break;
case GDK_EXPOSE:
- MAKE_STD_ZVAL(value);
- object_init_ex(value, gtk_allocation_ce);
- add_property_long(value, "x", event->expose.area.x);
- add_property_long(value, "y", event->expose.area.y);
- add_property_long(value, "width", event->expose.area.width);
- add_property_long(value, "height", event->expose.area.height);
- zend_hash_update(Z_OBJPROP_P(result), "area", sizeof("area"), &value, sizeof(zval *), NULL);
+ add_property_zval(result, "area", php_gdk_rectangle_new(&event->expose.area));
add_property_long(result, "count", event->expose.count);
break;
@@ -2573,9 +2566,6 @@
INIT_OVERLOADED_CLASS_ENTRY(ce, "gtkclistrow", NULL, NULL, php_gtk_get_property, php_gtk_set_property);
gtk_clist_row_ce = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC);
php_gtk_register_prop_getter(gtk_clist_row_ce, gtk_clist_row_get_property);
-
- INIT_CLASS_ENTRY(ce, "gtkallocation", NULL);
- gtk_allocation_ce = zend_register_internal_class_ex(&ce, &zend_standard_class_def, NULL TSRMLS_CC);
}
#endif
Index: php-gtk/generator/arg_types.php
diff -u php-gtk/generator/arg_types.php:1.25 php-gtk/generator/arg_types.php:1.26
--- php-gtk/generator/arg_types.php:1.25 Mon Jul 30 20:38:41 2001
+++ php-gtk/generator/arg_types.php Tue Jul 31 01:27:00 2001
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: arg_types.php,v 1.25 2001/07/31 00:38:41 fmk Exp $ */
+/* $Id: arg_types.php,v 1.26 2001/07/31 05:27:00 andrei Exp $ */
/*======================================================================*\
Function: convert_typename
@@ -86,6 +86,16 @@
{
trigger_error("This is an abstract class", E_USER_ERROR);
}
+
+ function write_to_prop($obj, $name, $source)
+ {
+ trigger_error("This is an abstract class", E_USER_ERROR);
+ }
+
+ function write_from_prop($name)
+ {
+ trigger_error("This is an abstract class", E_USER_ERROR);
+ }
}
class None_Arg extends Arg_Type {
@@ -113,7 +123,9 @@
$arg_list[] = 'utf8_' . $name;
$extra_post_code[] = "\tg_free(utf8_$name);\n";
$extra_pre_code[] = "\tutf8_$name = g_convert($name, strlen($name), \"UTF-8\", \"CP1252\", NULL, NULL, NULL);\n";
- }
+ } else
+ $arg_list[] = $name;
+
return 's';
}
@@ -181,6 +193,20 @@
return " php_retval = %s;\n" .
"%s RETURN_LONG(php_retval);";
}
+
+ function write_to_prop($obj, $name, $source)
+ {
+ return " add_property_long($obj, \"$name\", $source);\n";
+ }
+
+ function write_from_prop($name)
+ {
+ return " if (zend_hash_find(Z_OBJPROP_P(wrapper), \"$name\", sizeof(\"$name\"), (void **)&item) == SUCCESS && Z_TYPE_PP(item) == IS_LONG)\n" .
+ " obj->$name = Z_LVAL_PP(item);\n" .
+ " else\n" .
+ " return 0;\n\n";
+
+ }
}
class Bool_Arg extends Arg_Type {
@@ -299,6 +325,39 @@
}
}
+class Struct_Arg extends Arg_Type {
+ var $struct_name = null;
+
+ function Struct_Arg($struct_name)
+ {
+ $this->struct_name = $struct_name;
+ $this->struct_tpl = " if (!php_%s_get(php_%s, &%s)) {\n" .
+ " %sreturn;\n" .
+ " }\n\n";
+ }
+
+ function write_param($type, $name, $default, $null_ok, &$var_list,
+ &$parse_list, &$arg_list, &$extra_pre_code, &$extra_post_code, $in_constructor)
+ {
+ $var_list->add('zval', '*php_' . $name);
+ $var_list->add($this->struct_name, $name);
+ $typename = strtolower(substr(convert_typename($this->struct_name), 1));
+ $parse_list[] = '&php_' . $name . ', ' . $typename . '_ce';
+ $arg_list[] = '&' . $name;
+ $extra_pre_code[] = sprintf($this->struct_tpl, $typename, $name, $name,
+ $in_constructor ? "php_gtk_invalidate(this_ptr);\n\t\t" : "");
+
+ return 'O';
+ }
+
+ function write_return($type, &$var_list, $separate)
+ {
+ $typename = strtolower(substr(convert_typename($this->struct_name), 1));
+ return " *return_value = *php_{$typename}_new(&%s);\n" .
+ " return;";
+ }
+}
+
class Object_Arg extends Arg_Type {
var $obj_name = null;
var $cast = null;
@@ -548,6 +607,13 @@
function register_flag($type)
{
$this->arg_types[$type] = new Flags_Arg($type);
+ }
+
+ function register_struct($type)
+ {
+ $struct_arg = new Struct_Arg($type);
+ $this->register($type, $struct_arg);
+ $this->register($type . '*', $struct_arg);
}
function register_object($type)
Index: php-gtk/generator/definitions.php
diff -u php-gtk/generator/definitions.php:1.5 php-gtk/generator/definitions.php:1.6
--- php-gtk/generator/definitions.php:1.5 Tue Mar 13 00:38:42 2001
+++ php-gtk/generator/definitions.php Tue Jul 31 01:27:01 2001
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: definitions.php,v 1.5 2001/03/13 05:38:42 andrei Exp $ */
+/* $Id: definitions.php,v 1.6 2001/07/31 05:27:01 andrei Exp $ */
class Enum_Def {
var $def_type = 'enum';
@@ -200,6 +200,42 @@
} else if ($arg[0] == 'varargs')
$this->varargs = $arg[1] == 't';
}
+ }
+}
+
+class Struct_Def {
+ var $def_type = 'struct';
+ var $name = null;
+ var $in_module = null;
+ var $c_name = null;
+ var $ce = null;
+ var $fields = array();
+
+ function Struct_Def($args)
+ {
+ $this->name = array_shift($args);
+
+ foreach ($args as $arg) {
+ if (!is_array($arg) || count($arg) < 2)
+ continue;
+
+ if ($arg[0] == 'in-module')
+ $this->in_module = $arg[1];
+ else if ($arg[0] == 'c-name')
+ $this->c_name = $arg[1];
+ else if ($arg[0] == 'field') {
+ $field_type = null;
+ $field_name = null;
+ foreach (array_slice($arg, 1) as $field_arg) {
+ if ($field_arg[0] == 'type-and-name') {
+ $field_type = $field_arg[1];
+ $field_name = $field_arg[2];
+ }
+ }
+ $this->fields[] = array($field_type, $field_name);
+ }
+ }
+ $this->ce = strtolower($this->in_module . '_' . $this->name . '_ce');
}
}
Index: php-gtk/generator/generator.php
diff -u php-gtk/generator/generator.php:1.25 php-gtk/generator/generator.php:1.26
--- php-gtk/generator/generator.php:1.25 Mon Jul 30 20:38:41 2001
+++ php-gtk/generator/generator.php Tue Jul 31 01:27:01 2001
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: generator.php,v 1.25 2001/07/31 00:38:41 fmk Exp $ */
+/* $Id: generator.php,v 1.26 2001/07/31 05:27:01 andrei Exp $ */
/*
* Significant portions of this generator are based on the pygtk code generator
@@ -59,6 +59,9 @@
if (!$parser)
$parser = $this->parser;
+ foreach ($parser->structs as $struct)
+ $matcher->register_struct($struct->c_name);
+
foreach ($parser->objects as $object)
$matcher->register_object($object->c_name);
@@ -252,6 +255,10 @@
false);
}
+ if ($function->name == 'gtk_rc_parse') {
+ var_dump($arg_list); exit;
+ }
+
$arg_list = implode(', ', $arg_list);
$parse_list = implode(', ', $parse_list);
$extra_pre_code = implode('', $extra_pre_code);
@@ -326,6 +333,90 @@
$prop_checks));
}
+ function write_structs($fp)
+ {
+ global $struct_class_tpl,
+ $struct_init_tpl,
+ $struct_construct_tpl,
+ $struct_get_tpl,
+ $register_class_tpl,
+ $functions_decl_tpl,
+ $function_entry_tpl,
+ $matcher;
+
+ foreach ($this->parser->structs as $struct) {
+ $struct_module = strtolower($struct->in_module);
+ $struct_lname = strtolower($struct->name);
+ fwrite($fp, "\n/* struct $struct->c_name */\n");
+
+ $this->register_classes .= sprintf($struct_class_tpl,
+ $struct_module . $struct_lname,
+ $struct_module . '_' . $struct_lname);
+ $this->register_classes .= sprintf($register_class_tpl, $struct->ce, 'NULL');
+
+ $init_prop_code = array();
+ $construct_prop_code = array();
+ $get_prop_code = array();
+ $specs = '';
+ $var_list = new Var_List();
+ $parse_list = array('');
+ $arg_list = array();
+ $extra_pre_code = array();
+ $extra_post_code = array();
+
+ foreach ($struct->fields as $field_def) {
+ list($field_type, $field_name) = $field_def;
+ $handler = &$matcher->get($field_type);
+ if ($handler === null) {
+ error_log("Could not write struct $struct->c_name '$field_name' field (field type $field_type)");
+ return;
+ }
+
+ $init_prop_code[] = $handler->write_to_prop('result', $field_name, "obj->$field_name");
+ $get_prop_code[] = $handler->write_from_prop($field_name);
+ $construct_prop_code[] = $handler->write_to_prop('this_ptr', $field_name, $field_name);
+
+ $specs .= $handler->write_param($field_type,
+ $field_name,
+ null,
+ false,
+ $var_list,
+ $parse_list,
+ $arg_list,
+ $extra_pre_code,
+ $extra_post_code,
+ true);
+ }
+
+ /* write the initializer */
+ fwrite($fp, sprintf($struct_init_tpl,
+ $struct_module . '_' . $struct_lname,
+ $struct->in_module . $struct->name,
+ $struct->ce, implode('', $init_prop_code)));
+
+ /* write getter */
+ fwrite($fp, sprintf($struct_get_tpl,
+ $struct_module . '_' . $struct_lname,
+ $struct->in_module . $struct->name,
+ $struct->ce, implode('', $get_prop_code)));
+
+ /* write the constructor */
+ fwrite($fp, sprintf($struct_construct_tpl,
+ strtolower($struct->c_name),
+ $var_list->to_string(),
+ $specs,
+ implode(', ', $parse_list),
+ implode('', $construct_prop_code)));
+ $functions_decl = sprintf($functions_decl_tpl, $struct_module . '_' . $struct_lname);
+ $functions_decl .= sprintf($function_entry_tpl,
+ $struct_module . $struct_lname,
+ strtolower($struct->c_name),
+ 'NULL');
+ $functions_decl .= $this->functions_decl_end;
+ fwrite($fp, $functions_decl);
+ }
+ }
+
function write_objects($fp)
{
global $function_entry_tpl,
@@ -493,6 +584,8 @@
global $class_entry_tpl;
fwrite($fp, sprintf($class_entry_tpl, $this->prefix . '_ce'));
+ foreach ($this->parser->structs as $struct)
+ fwrite($fp, sprintf($class_entry_tpl, $struct->ce));
foreach ($this->parser->objects as $object)
fwrite($fp, sprintf($class_entry_tpl, $object->ce));
foreach ($this->overrides->get_register_classes() as $ce => $rest)
@@ -510,6 +603,7 @@
$this->write_constants($fp);
$this->write_class_entries($fp);
$this->write_functions($fp);
+ $this->write_structs($fp);
$this->write_objects($fp);
fwrite($fp, sprintf($register_classes_tpl,
$this->prefix,
Index: php-gtk/generator/scheme.php
diff -u php-gtk/generator/scheme.php:1.7 php-gtk/generator/scheme.php:1.8
--- php-gtk/generator/scheme.php:1.7 Tue Jul 10 14:27:51 2001
+++ php-gtk/generator/scheme.php Tue Jul 31 01:27:01 2001
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: scheme.php,v 1.7 2001/07/10 18:27:51 andrei Exp $ */
+/* $Id: scheme.php,v 1.8 2001/07/31 05:27:01 andrei Exp $ */
require "definitions.php";
@@ -73,6 +73,7 @@
var $constructors = array(); // object constructors
var $methods = array(); // object methods
var $enums = array(); // enums and flags
+ var $structs = array(); // structures
var $c_name = array(); // C names of entities
@@ -157,6 +158,13 @@
$object_def = &new Object_Def($arg);
$this->objects[] = &$object_def;
$this->c_name[] = &$object_def->c_name;
+ }
+
+ function handle_struct($arg)
+ {
+ $struct_def = &new Struct_Def($arg);
+ $this->structs[] = &$struct_def;
+ $this->c_name[] = &$struct_def->c_name;
}
function handle_include($arg)
Index: php-gtk/generator/templates.php
diff -u php-gtk/generator/templates.php:1.14 php-gtk/generator/templates.php:1.15
--- php-gtk/generator/templates.php:1.14 Mon Jul 30 20:37:46 2001
+++ php-gtk/generator/templates.php Tue Jul 31 01:27:01 2001
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: templates.php,v 1.14 2001/07/31 00:37:46 fmk Exp $ */
+/* $Id: templates.php,v 1.15 2001/07/31 05:27:01 andrei Exp $ */
$function_tpl = "
PHP_FUNCTION(wrap_%s)
@@ -93,6 +93,9 @@
$init_class_tpl = "
INIT_OVERLOADED_CLASS_ENTRY(ce, \"%s\", php_%s_functions, NULL, %s, php_gtk_set_property);\n";
+$struct_class_tpl = "
+ INIT_CLASS_ENTRY(ce, \"%s\", php_%s_functions);\n";
+
$get_type_tpl = "
PHP_FUNCTION(wrap_%s_get_type)
{
@@ -114,5 +117,47 @@
$register_class_tpl = "\t%s = zend_register_internal_class_ex(&ce, %s, NULL TSRMLS_CC);\n";
$class_entry_tpl = "PHP_GTK_EXPORT_CE(%s);\n";
+
+$struct_init_tpl = "
+zval *PHP_GTK_EXPORT_FUNC(php_%s_new)(%s *obj)
+{
+ zval *result;
+
+ if (!obj) {
+ MAKE_STD_ZVAL(result);
+ ZVAL_NULL(result);
+ return result;
+ }
+
+ MAKE_STD_ZVAL(result);
+ object_init_ex(result, %s);
+
+%s
+ return result;
+}\n\n";
+
+$struct_construct_tpl = "
+PHP_FUNCTION(wrap_%s)
+{
+%s NOT_STATIC_METHOD();
+
+ if (!php_gtk_parse_args(ZEND_NUM_ARGS(), \"%s\"%s)) {
+ php_gtk_invalidate(this_ptr);
+ return;
+ }
+
+%s}\n\n";
+
+$struct_get_tpl = "
+zend_bool PHP_GTK_EXPORT_FUNC(php_%s_get)(zval *wrapper, %s *obj)
+{
+ zval **item;
+
+ if (!php_gtk_check_class(wrapper, %s))
+ return 0;
+
+%s
+ return 1;
+}\n\n";
?>
Index: php-gtk/main/php_gtk.h
diff -u php-gtk/main/php_gtk.h:1.46 php-gtk/main/php_gtk.h:1.47
--- php-gtk/main/php_gtk.h:1.46 Mon Jul 30 20:38:58 2001
+++ php-gtk/main/php_gtk.h Tue Jul 31 01:27:01 2001
@@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: php_gtk.h,v 1.46 2001/07/31 00:38:58 fmk Exp $: */
+/* $Id: php_gtk.h,v 1.47 2001/07/31 05:27:01 andrei Exp $: */
#ifndef _PHP_GTK_H
#define _PHP_GTK_H
@@ -28,6 +28,7 @@
#if HAVE_PHP_GTK
#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))
#undef PG_ERROR
Index: php-gtk/test/scribble.php
diff -u php-gtk/test/scribble.php:1.3 php-gtk/test/scribble.php:1.4
--- php-gtk/test/scribble.php:1.3 Mon Jul 30 01:11:15 2001
+++ php-gtk/test/scribble.php Tue Jul 31 01:27:01 2001
@@ -1,5 +1,5 @@
<?php
-/* $Id: scribble.php,v 1.3 2001/07/30 05:11:15 andrei Exp $ */
+/* $Id: scribble.php,v 1.4 2001/07/31 05:27:01 andrei Exp $ */
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
dl('php_gtk.dll');
@@ -31,7 +31,7 @@
global $pixmap;
gdk::draw_pixmap($widget->window,
- $widget->style->fg_gc[$widget->state()],
+ $widget->style->fg_gc[$widget->state],
$pixmap,
$event->area->x, $event->area->y,
$event->area->x, $event->area->y,