slang-users mailing list

[2004 Date Index] [2004 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

[slang-users] Re: new slang 2 development snapshot released


"John E. Davis" <davis@xxxxxxxxxxxxx> wrote:
> Joerg Sommer <joerg@xxxxxxxxxxxx> wrote:
>>did you ever get my patch for auto loading files upton namespace request?
>>I send it three or more times to you per mail and one time I posted it in
>>alt.lang.s-lang.
>
> I have the patch but do not want to add it until I rework the
> namespace functions.  There are related issues that I would like to
> correct such as this one:
>
>    import ("mymodule", "foo");
>    import ("mymodule", "bar");
>
> You will find that although mymodule will get loaded into the foo
> namespace, it will not get loaded into the bar namespace.  When I
> address this problem, I will also look at your patch.

The problem is caused in line 112 in slimport.c.

   if (NULL != find_handle (name))
     return 0;			       /* already loaded */

There is a check, if the module is already loaded. This is the case, if
you have loaded it under the namespace foo. If you define name a little
bit better, it should work.

#v+
--- slang-1.4.9/src/slimport.c  2003-03-23 08:06:40.000000000 +0100
+++ /home/joerg/programmieren/slang-1.4.9/src/slimport.c        2004-11-26 17:35:53.206291240 +0100
@@ -207,6 +207,7 @@
 static void import_module (void)
 {
 #define MAX_MODULE_NAME_SIZE 256
+   char name[MAX_MODULE_NAME_SIZE];
    char module_name[MAX_MODULE_NAME_SIZE];
    char symbol_name[MAX_MODULE_NAME_SIZE];
    char deinit_name[MAX_MODULE_NAME_SIZE];
@@ -236,6 +237,7 @@
        return;
      }
    
+   _SLsnprintf (name, sizeof(name), "%s.%s", ns, module);
    _SLsnprintf (symbol_name, sizeof(symbol_name), "init_%s_module", module);
    _SLsnprintf (module_name, sizeof(module_name), "%s-module.so", module);
    _SLsnprintf (deinit_name, sizeof(deinit_name), "deinit_%s_module", module);
@@ -254,7 +256,7 @@
 
    if (file != NULL)
      {
-       (void) import_from_library (symbol_name, symbol_name, deinit_name, file, ns, ns_init_name);
+       (void) import_from_library (name, symbol_name, deinit_name, file, ns, ns_init_name);
        SLfree (file);
      }
    else
#v-

I tested it with a modified version of varray.sl and it works.

#v+
--- slang-1.4.9/modules/varray.sl       2003-03-23 08:06:40.000000000 +0100
+++ /home/joerg/programmieren/slang-1.4.9/modules/varray.sl     2004-11-26 17:13:00.249009928 +0100
@@ -1,6 +1,9 @@
+set_import_module_path("/home/joerg/programmieren/slang-1.4.9/modules");
+
 % This file shows how to use the varray-module to treat a file as an
 % array of objects.
-import ("varray");
+import ("varray", "foo");
+import ("varray", "bar");
 
 % First of all, create an array of doubles
 static variable x = [1:1000.0:1.0];
@@ -21,7 +24,7 @@
 }
 
 % Now associate an array with the file
-variable y = mmap_array (file, 0, _typeof(x), length(x));
+variable y = bar->mmap_array (file, 0, _typeof(x), length(x));
 
 if (length (where (y != x)))
 {
#v-

HTH, Joerg.

-- 
And 1.1.81 is officially BugFree(tm), so if you receive any bug-reports
on it, you know they are just evil lies.
         -- Linus Torvalds

_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html


[2004 date index] [2004 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]