digging into enums and flags

From: Date: Wed, 14 Sep 2005 12:02:57 +0000
Subject: digging into enums and flags
Groups: php.gtk.dev 
Request: Send a blank email to php-gtk-dev+get-1646@lists.php.net to get a copy of this message
Andrei, I think the weird behaviour I reported earlier was probably just down to me getting confused - I can't find the particular script that provoked one request for a string from the PHP side and another for an int from the GTK side, but I do know how it happened now. Here's a short test script from my ever-increasing hello.php: <?php /* tricksy params - and can the final param work at all if local_files is set to TRUE by default? */ $fcdialog = new GtkFileChooserDialog('GtkFileChooserDialog', null, Gtk::FILE_CHOOSER_ACTION_OPEN, array('first', Gtk::RESPONSE_CANCEL, 'second', Gtk::RESPONSE_ACCEPT, 'third', Gtk::RESPONSE_OK, '_fourth', Gtk::RESPONSE_APPLY), 'tmp://'); $fcdialog->connect_object('destroy', array('gtk', 'main_quit')); $fcdialog->show_all(); ?> Now in PHP-GTK 2 you need to type stuff like: Gtk::FILE_CHOOSER_ACTION_OPEN rather than version 1's: GTK_FILE_CHOOSER_ACTION_OPEN thanks to the g_typing. But if you don't know this in advance and do it the old fashioned way, you get something like "Notice: Use of undefined constant GTK_RESPONSE_ACCEPT - assumed 'GTK_RESPONSE_ACCEPT' in C:\php5\hello.php on line 4". In some cases that actually works - submitting the string 'GTK_FILE_CHOOSER_ACTION_OPEN' appears to, presumably because it evaluates to 0 - but submitting 'GTK_RESPONSE_ACCEPT' will cause a PhpGtkConstructException to be thrown. Warning: GtkFileChooserDialog::__construct(): each pair in button list has to string/number in C:\php5\hello.php on line 4 Fatal error: Uncaught exception 'PhpGtkConstructException' with message 'could not construct GtkDialog object' in C:\php5\hello.php:4 Stack trace: #0 C:\php5\hello.php(4): GtkFileChooserDialog->__construct('GtkFileChooserD...', NULL, 0, Array, 'tmp://') #1 {main} thrown in C:\php5\hello.php on line 4 You can see how I got confused. OK so this is a documentation issue at heart, but is there any way to give a saner E_NOTICE than the one thrown by PHP? - Steph NB This means we can eliminate misbehaviour in enums from the 'u' issue, in the sense I meant it at least.

« previous php.gtk.dev (#1646) next »