[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
gobject new arg count check
- From: Kevin Ryde <user42 zip com au>
- To: gtk-perl-list gnome org
- Subject: gobject new arg count check
- Date: Tue, 15 Jul 2008 09:40:00 +1000
I wonder if Glib::Object->new could check its arg count to detect
misuse or confusion with the various single-arg class specific "new"s.
I think currently it ignores a "key" without a value. There's even an
apparent stray type name (in place of a key) in the test suite.
--- GObject.xs 23 Jun 2008 09:08:35 +1000 1.75
+++ GObject.xs 14 Jul 2008 18:29:29 +1000
@@ -1108,6 +1108,9 @@
if (G_TYPE_IS_ABSTRACT (object_type))
croak ("cannot create instance of abstract (non-instantiatable)"
" type `%s'", g_type_name (object_type));
+ if (0 != ((items - 1) % 2))
+ croak ("new method expects name => value pairs "
+ "(odd number of arguments detected)");
if (items > FIRST_ARG) {
int i;
if (NULL == (oclass = g_type_class_ref (object_type)))
--- 2.t 30 Dec 2007 10:47:23 +1100 1.9
+++ 2.t 15 Jul 2008 09:26:41 +1000
@@ -18,7 +18,7 @@
#########################
-my $obj = new Glib::Object "Glib::Object";
+my $obj = Glib::Object::new "Glib::Object";
isa_ok ($obj, 'Glib::Object');
$obj->freeze_notify;
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]