Index: include/parrot/dynext.h
===================================================================
RCS file: /cvs/public/parrot/include/parrot/dynext.h,v
retrieving revision 1.5
diff -u -2 -r1.5 dynext.h
--- include/parrot/dynext.h	22 Apr 2004 08:55:05 -0000	1.5
+++ include/parrot/dynext.h	13 Aug 2004 21:36:19 -0000
@@ -13,4 +13,10 @@
 PMC *Parrot_load_lib(Interp *interpreter, STRING *lib, PMC *initializer);
 
+/* dynamic lib/oplib/PMC init */
+PMC *
+Parrot_init_lib(Interp *interpreter,
+                PMC *(*load_func)(Interp *),
+                void (*init_func)(Interp *, PMC *));
+
 #endif /* PARROT_DYNEXT_H_GUARD */
 
Index: src/dynext.c
===================================================================
RCS file: /cvs/public/parrot/src/dynext.c,v
retrieving revision 1.26
diff -u -2 -r1.26 dynext.c
--- src/dynext.c	26 May 2004 13:04:07 -0000	1.26
+++ src/dynext.c	13 Aug 2004 21:36:23 -0000
@@ -227,4 +227,39 @@
 
 PMC *
+Parrot_init_lib(Interp *interpreter,
+                PMC *(*load_func)(Interp *),
+                void (*init_func)(Interp *, PMC *))
+{
+    STRING *type;
+    PMC *lib_pmc;
+
+    if (!load_func) {
+        /* seems to be a native/NCI lib */
+        /*
+         * this PMC should better be constant, but then all the contents
+         * and the metadata have to be constant too
+         * s. also build_tools/ops2c.pl and lib/Parrot/Pmc2c.pm
+         */
+        lib_pmc = pmc_new(interpreter, enum_class_ParrotLibrary);
+        type = const_string(interpreter, "NCI");
+    }
+    else {
+        lib_pmc = (*load_func)(interpreter);
+        /* we could set a private flag in the PMC header too
+         * but currently only ops files have struct_val set
+         */
+        type = const_string(interpreter,
+                PMC_struct_val(lib_pmc) ? "Ops" : "PMC");
+    }
+    /*
+     *  call init, if it exists
+     */
+    if (init_func)
+        (init_func)(interpreter, lib_pmc);
+
+    return lib_pmc;
+}
+
+PMC *
 Parrot_load_lib(Interp *interpreter, STRING *lib, PMC *initializer)
 {
@@ -265,4 +300,5 @@
         return lib_pmc;
     }
+    /* get load_func */
     load_func_name = Parrot_sprintf_c(interpreter, "Parrot_lib_%Ss_load", lib);
     cload_func_name = string_to_cstring(interpreter, load_func_name);
@@ -270,25 +306,5 @@
                 cload_func_name));
     string_cstring_free(cload_func_name);
-    if (!load_func) {
-        /* seems to be a native/NCI lib */
-        /*
-         * this PMC should better be constant, but then all the contents
-         * and the metadata have to be constant too
-         * s. also build_tools/ops2c.pl and lib/Parrot/Pmc2c.pm
-         */
-        lib_pmc = pmc_new(interpreter, enum_class_ParrotLibrary);
-        type = const_string(interpreter, "NCI");
-    }
-    else {
-        lib_pmc = (*load_func)(interpreter);
-        /* we could set a private flag in the PMC header too
-         * but currently only ops files have struct_val set
-         */
-        type = const_string(interpreter,
-                PMC_struct_val(lib_pmc) ? "Ops" : "PMC");
-    }
-    /*
-     *  call init, if it exists
-     */
+    /* get init_func */
     init_func_name = Parrot_sprintf_c(interpreter, "Parrot_lib_%Ss_init", lib);
     cinit_func_name = string_to_cstring(interpreter, init_func_name);
@@ -296,6 +312,7 @@
                 cinit_func_name));
     string_cstring_free(cinit_func_name);
-    if (init_func)
-        (init_func)(interpreter, lib_pmc);
+
+    lib_pmc = Parrot_init_lib(interpreter, load_func, init_func);
+
     PMC_data(lib_pmc) = handle;
     /*
