[perl-Glib-Object-Introspection] Hook up the generic Glib::Boxed constructor on load, not in setup()
- From: Torsten Schönfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Glib-Object-Introspection] Hook up the generic Glib::Boxed constructor on load, not in setup()
- Date: Sat, 21 Mar 2015 19:36:10 +0000 (UTC)
commit 36f40d290188c17b3a2032aadc72ba07046f857e
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date: Fri Mar 6 17:37:20 2015 +0100
Hook up the generic Glib::Boxed constructor on load, not in setup()
It is not useful to call it before setup(), but conceptually it is independent
of setup().
lib/Glib/Object/Introspection.pm | 38 +++++++++++++++++++-------------------
1 files changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/lib/Glib/Object/Introspection.pm b/lib/Glib/Object/Introspection.pm
index f1af35f..c03fffa 100644
--- a/lib/Glib/Object/Introspection.pm
+++ b/lib/Glib/Object/Introspection.pm
@@ -153,25 +153,6 @@ sub setup {
}
}
- # Monkey-patch Glib with a generic constructor for boxed types. Glib cannot
- # provide this on its own because it does not know how big the struct of a
- # boxed type is. FIXME: This sort of violates encapsulation.
- {
- if (! defined &{Glib::Boxed::new}) {
- *{Glib::Boxed::new} = sub {
- my ($class, @rest) = @_;
- my $boxed = Glib::Object::Introspection->_construct_boxed ($class);
- my $fields = 1 == @rest ? $rest[0] : { @rest };
- foreach my $field (keys %$fields) {
- if ($boxed->can ($field)) {
- $boxed->$field ($fields->{$field});
- }
- }
- return $boxed;
- }
- }
- }
-
foreach my $name (@{$interfaces}) {
my $adder_name = $package . '::' . $name . '::_ADD_INTERFACE';
*{$adder_name} = sub {
@@ -256,6 +237,25 @@ sub INIT {
@OBJECT_PACKAGES_WITH_VFUNCS = ();
}
+# Monkey-patch Glib with a generic constructor for boxed types. Glib cannot
+# provide this on its own because it does not know how big the struct of a
+# boxed type is. FIXME: This sort of violates encapsulation.
+{
+ if (! defined &{Glib::Boxed::new}) {
+ *{Glib::Boxed::new} = sub {
+ my ($class, @rest) = @_;
+ my $boxed = Glib::Object::Introspection->_construct_boxed ($class);
+ my $fields = 1 == @rest ? $rest[0] : { @rest };
+ foreach my $field (keys %$fields) {
+ if ($boxed->can ($field)) {
+ $boxed->$field ($fields->{$field});
+ }
+ }
+ return $boxed;
+ }
+ }
+}
+
package Glib::Object::Introspection::_FuncWrapper;
use overload
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]