[perl-Glib-Object-Introspection] Put library loading into a separate function



commit 6e067ea39ca4640728a92fedf93416ead5104529
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date:   Sat Oct 16 15:14:11 2010 +0200

    Put library loading into a separate function
    
    Move the library loading out of register_types into the new
    load_library.  The latter now also accepts a 'search_path' parameter.

 GObjectIntrospection.xs          |   23 +++++++++++++++++------
 lib/Glib/Object/Introspection.pm |    5 ++++-
 2 files changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/GObjectIntrospection.xs b/GObjectIntrospection.xs
index 550717e..ea1a322 100644
--- a/GObjectIntrospection.xs
+++ b/GObjectIntrospection.xs
@@ -1516,23 +1516,34 @@ store_methods (HV *namespaced_functions, GIBaseInfo *info, GIInfoType info_type)
 MODULE = Glib::Object::Introspection	PACKAGE = Glib::Object::Introspection
 
 void
-register_types (class, namespace, version, package)
+load_library (class, namespace, version, search_path=NULL)
 	const gchar *namespace
 	const gchar *version
-	const gchar *package
+	const gchar *search_path
     PREINIT:
 	GIRepository *repository;
 	GError *error = NULL;
-	gint number, i;
-	AV *global_functions;
-	HV *namespaced_functions;
-    PPCODE:
+    CODE:
+	if (search_path)
+		g_irepository_prepend_search_path (search_path);
 	repository = g_irepository_get_default ();
 	g_irepository_require (repository, namespace, version, 0, &error);
 	if (error) {
 		gperl_croak_gerror (NULL, error);
 	}
 
+void
+register_types (class, namespace, package)
+	const gchar *namespace
+	const gchar *package
+    PREINIT:
+	GIRepository *repository;
+	gint number, i;
+	AV *global_functions;
+	HV *namespaced_functions;
+    PPCODE:
+	repository = g_irepository_get_default ();
+
 	global_functions = newAV ();
 	namespaced_functions = newHV ();
 
diff --git a/lib/Glib/Object/Introspection.pm b/lib/Glib/Object/Introspection.pm
index 3a62d9b..fbde152 100644
--- a/lib/Glib/Object/Introspection.pm
+++ b/lib/Glib/Object/Introspection.pm
@@ -30,13 +30,16 @@ sub setup {
   my $basename = $params{basename};
   my $version = $params{version};
   my $package = $params{package};
+  my $search_path = $params{search_path} || undef;
   my $name_corrections = $params{name_corrections} || {};
   my $class_static_methods = $params{class_static_methods} || [];
 
   my %shift_package_name_for = map { $_ => 1 } @$class_static_methods;
 
+  __PACKAGE__->load_library($basename, $version, $search_path);
+
   my $functions =
-    __PACKAGE__->register_types($basename, $version, $package);
+    __PACKAGE__->register_types($basename, $package);
 
   no strict 'refs';
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]