cvsuser     03/09/30 03:22:02

  Modified:    .        MANIFEST dynext.c
               classes  pmc2c.pl
               languages/imcc parser_util.c
               library  ncurses.pasm
               t/pmc    nci.t
  Log:
  cleanup and polish loadlib;
  make the NCI struff work again
  the .so extension should not given any more to dynamic libs
  
  Revision  Changes    Path
  1.435     +1 -0      parrot/MANIFEST
  
  Index: MANIFEST
  ===================================================================
  RCS file: /cvs/public/parrot/MANIFEST,v
  retrieving revision 1.434
  retrieving revision 1.435
  diff -u -w -r1.434 -r1.435
  --- MANIFEST  29 Sep 2003 14:04:13 -0000      1.434
  +++ MANIFEST  30 Sep 2003 10:21:50 -0000      1.435
  @@ -147,6 +147,7 @@
   config/init/hints/cygwin.pl                       []
   config/init/hints/darwin.pl                       []
   config/init/hints/mswin32.pl                      []
  +config/init/hints/linux.pl                        []
   config/init/hints/os2.pl                          []
   config/init/hints/vms.pl                          []
   config/init/manifest.pl                           []
  
  
  
  1.7       +33 -11    parrot/dynext.c
  
  Index: dynext.c
  ===================================================================
  RCS file: /cvs/public/parrot/dynext.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -r1.6 -r1.7
  --- dynext.c  30 Sep 2003 09:29:38 -0000      1.6
  +++ dynext.c  30 Sep 2003 10:21:50 -0000      1.7
  @@ -1,7 +1,7 @@
   /* dynext.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: dynext.c,v 1.6 2003/09/30 09:29:38 leo Exp $
  + *     $Id: dynext.c,v 1.7 2003/09/30 10:21:50 leo Exp $
    *  Overview:
    *     Dynamic extension stuff
    *  Data Structure and Algorithms:
  @@ -43,31 +43,53 @@
   #  define SO_EXTENSION ".so"
   #endif
   
  +    /*
  +     * first look in current dir
  +     */
  +    path = Parrot_sprintf_c(interpreter, "%Ss%s",
  +            lib,
  +            SO_EXTENSION);
  +    cpath = string_to_cstring(interpreter, path);
  +    handle = Parrot_dlopen(cpath);
  +    if (!handle) {
  +        /*
  +         * then in runtime/ ...
  +         */
  +        /* TODO only if not an absolute path */
  +        string_cstring_free(cpath);
       path = Parrot_sprintf_c(interpreter, "%s%Ss%s",
               RUNTIME_DYNEXT,
               lib,
               SO_EXTENSION);
       cpath = string_to_cstring(interpreter, path);
       handle = Parrot_dlopen(cpath);
  +    }
       if (!handle) {
           const char * err = Parrot_dlerror();
           fprintf(stderr, "Couldn't load '%s': %s\n", cpath, err ? err : "unknow 
reason");
  +        /*
  +         * XXX internal_exception? return a PerlUndef?
  +         */
  +        string_cstring_free(cpath);
           return NULL;
       }
       string_cstring_free(cpath);
       load_func_name = Parrot_sprintf_c(interpreter, "Parrot_lib_%Ss_load", lib);
       cload_func_name = string_to_cstring(interpreter, load_func_name);
       load_func = (PMC * (*)(Interp *))D2FPTR(Parrot_dlsym(handle, cload_func_name));
  +    string_cstring_free(cload_func_name);
       if (!load_func) {
  -        fprintf(stderr, "Failed to find symbol '%s' in native library\n",
  -                cload_func_name);
  -        return NULL;
  +        /* seems to be a native/NCI lib */
  +        lib_pmc = new_pmc_header(interpreter);
  +        add_pmc_ext(interpreter, lib_pmc);
  +        PMC_data(lib_pmc) = handle;
       }
  -    string_cstring_free(cload_func_name);
  +    else {
       lib_pmc = (*load_func)(interpreter);
       /*
        * TODO call init, if it exists
        */
  +    }
       return lib_pmc;
   }
   
  
  
  
  1.47      +2 -2      parrot/classes/pmc2c.pl
  
  Index: pmc2c.pl
  ===================================================================
  RCS file: /cvs/public/parrot/classes/pmc2c.pl,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -w -r1.46 -r1.47
  --- pmc2c.pl  30 Sep 2003 09:29:36 -0000      1.46
  +++ pmc2c.pl  30 Sep 2003 10:21:55 -0000      1.47
  @@ -818,7 +818,7 @@
    */
   #include "parrot/dynext.h"
   
  -int Parrot_lib_${lc_classname}_load(Interp *interpreter)
  +PMC* Parrot_lib_${lc_classname}_load(Interp *interpreter)
   {
       STRING *whoami;
       PMC *pmc;
  @@ -829,7 +829,6 @@
        */
       pmc = new_pmc_header(interpreter);
       add_pmc_ext(interpreter, pmc);
  -    string_init();    /* default type/encoding */
   
       /* for all PMCs we want to register:
       */
  @@ -837,6 +836,7 @@
       type = pmc_register(interpreter, whoami);
       /* do class_init code */
       $initname(interpreter, type);
  +    return pmc;
   }
   
   EOC
  
  
  
  1.37      +1 -1      parrot/languages/imcc/parser_util.c
  
  Index: parser_util.c
  ===================================================================
  RCS file: /cvs/public/parrot/languages/imcc/parser_util.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -w -r1.36 -r1.37
  --- parser_util.c     30 Sep 2003 09:29:42 -0000      1.36
  +++ parser_util.c     30 Sep 2003 10:21:57 -0000      1.37
  @@ -219,7 +219,7 @@
               /* emit a debug seg, if this op is seen */
               PARROT_WARNINGS_on(interpreter, PARROT_WARNINGS_ALL_FLAG);
           }
  -        if (!strcmp(name, "loadlib")) {
  +        else if (!strcmp(name, "loadlib")) {
               SymReg *r1 = r[1];   /* lib name */
               STRING *lib = string_from_cstring(interpreter, r1->name + 1,
                   strlen(r1->name) - 2);
  
  
  
  1.5       +2 -2      parrot/library/ncurses.pasm
  
  Index: ncurses.pasm
  ===================================================================
  RCS file: /cvs/public/parrot/library/ncurses.pasm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -r1.4 -r1.5
  --- ncurses.pasm      25 Sep 2003 15:39:57 -0000      1.4
  +++ ncurses.pasm      30 Sep 2003 10:21:59 -0000      1.5
  @@ -1,5 +1,5 @@
   saveall
  -loadlib P1, 'libform.so'
  +loadlib P1, 'libform'
   dlfunc P2, P1, 'new_field', 'piiiiii'
   store_global 'ncurses::new_field', P2
   dlfunc P2, P1, 'dup_field', 'ppii'
  @@ -116,7 +116,7 @@
   store_global 'ncurses::data_ahead', P2
   dlfunc P2, P1, 'data_behind', 'lp'
   store_global 'ncurses::data_behind', P2
  -loadlib P1, 'libncurses.so'
  +loadlib P1, 'libncurses'
   dlfunc P2, P1, 'keybound', 'tii'
   store_global 'ncurses::keybound', P2
   dlfunc P2, P1, 'curses_version', 't'
  
  
  
  1.14      +22 -28    parrot/t/pmc/nci.t
  
  Index: nci.t
  ===================================================================
  RCS file: /cvs/public/parrot/t/pmc/nci.t,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -w -r1.13 -r1.14
  --- nci.t     23 Sep 2003 07:09:38 -0000      1.13
  +++ nci.t     30 Sep 2003 10:22:02 -0000      1.14
  @@ -13,14 +13,8 @@
            Test::Builder->expected_tests());
   }
   
  -sub gen_test($) {
  -  local $_ = shift;
  -  s/\.so/$PConfig{so}/;
  -  $_;
  -}
  -
  -output_is(gen_test(<<'CODE'), <<'OUTPUT', "nci_d_d");
  -  loadlib P1, "libnci.so"
  +output_is(<<'CODE', <<'OUTPUT', "nci_d_d");
  +  loadlib P1, "libnci"
     print "loaded\n"
     dlfunc P0, P1, "nci_dd", "dd"
     print "dlfunced\n"
  @@ -50,8 +44,8 @@
   ok 2
   OUTPUT
   
  -output_is(gen_test(<<'CODE'), <<'OUTPUT', "nci_f_ff");
  -  loadlib P1, "libnci.so"
  +output_is(<<'CODE', <<'OUTPUT', "nci_f_ff");
  +  loadlib P1, "libnci"
     print "loaded\n"
     dlfunc P0, P1, "nci_fff", "fff"
     print "dlfunced\n"
  @@ -82,8 +76,8 @@
   ok 2
   OUTPUT
   
  -output_is(gen_test(<<'CODE'), <<'OUTPUT', "nci_i_sc");
  -  loadlib P1, "libnci.so"
  +output_is(<<'CODE', <<'OUTPUT', "nci_i_sc");
  +  loadlib P1, "libnci"
     print "loaded\n"
     dlfunc P0, P1, "nci_isc", "isc"
     print "dlfunced\n"
  @@ -115,8 +109,8 @@
   OUTPUT
   
   
  -output_is(gen_test(<<'CODE'), <<'OUTPUT', "nci_s_sc");
  -  loadlib P1, "libnci.so"
  +output_is(<<'CODE', <<'OUTPUT', "nci_s_sc");
  +  loadlib P1, "libnci"
     print "loaded\n"
     dlfunc P0, P1, "nci_ssc", "ssc"
     print "dlfunced\n"
  @@ -147,8 +141,8 @@
   ok 2
   OUTPUT
   
  -output_is(gen_test(<<'CODE'), <<'OUTPUT', "nci_c_sc");
  -  loadlib P1, "libnci.so"
  +output_is(<<'CODE', <<'OUTPUT', "nci_c_sc");
  +  loadlib P1, "libnci"
     print "loaded\n"
     dlfunc P0, P1, "nci_csc", "csc"
     print "dlfunced\n"
  @@ -180,8 +174,8 @@
   OUTPUT
   
   
  -output_is(gen_test(<<'CODE'), <<'OUTPUT', "nci_i_t");
  -  loadlib P1, "libnci.so"
  +output_is(<<'CODE', <<'OUTPUT', "nci_i_t");
  +  loadlib P1, "libnci"
     printerr "loaded\n"
     dlfunc P0, P1, "nci_it", "it"
     printerr "dlfunced\n"
  @@ -210,8 +204,8 @@
   ok 2
   OUTPUT
   
  -output_is(gen_test(<<'CODE'), <<'OUTPUT', "nci_t_t");
  -  loadlib P1, "libnci.so"
  +output_is(<<'CODE', <<'OUTPUT', "nci_t_t");
  +  loadlib P1, "libnci"
     print "loaded\n"
     dlfunc P0, P1, "nci_tt", "tt"
     print "dlfunced\n"
  @@ -240,8 +234,8 @@
   ok 2
   OUTPUT
   
  -output_is(gen_test(<<'CODE'), <<'OUTPUT', "nci_d_d - stress test");
  -  loadlib P1, "libnci.so"
  +output_is(<<'CODE', <<'OUTPUT', "nci_d_d - stress test");
  +  loadlib P1, "libnci"
     print "loaded\n"
     set I10, 100000
     print "dlfunced\n"
  @@ -275,8 +269,8 @@
   ok 2
   OUTPUT
   
  -output_is(gen_test(<<'CODE'), <<'OUTPUT', "nci_d_d - clone");
  -  loadlib P1, "libnci.so"
  +output_is(<<'CODE', <<'OUTPUT', "nci_d_d - clone");
  +  loadlib P1, "libnci"
     print "loaded\n"
     dlfunc P0, P1, "nci_dd", "dd"
     print "dlfunced\n"
  @@ -317,8 +311,8 @@
   ok 4
   OUTPUT
   
  -output_is(gen_test(<<'CODE'), <<'OUTPUT', "nci_i_iii");
  -  loadlib P1, "libnci.so"
  +output_is(<<'CODE', <<'OUTPUT', "nci_i_iii");
  +  loadlib P1, "libnci"
     dlfunc P0, P1, "nci_iiii", "iiii"
     set I0, 1  # prototype used - unchecked
     set I1, 0  # items on stack - unchecked
  @@ -334,8 +328,8 @@
   2
   OUTPUT
   
  -output_is(gen_test(<<'CODE'), <<'OUTPUT', "nci_i_4i");
  -  loadlib P1, "libnci.so"
  +output_is(<<'CODE', <<'OUTPUT', "nci_i_4i");
  +  loadlib P1, "libnci"
     dlfunc P0, P1, "nci_i4i", "i4i"
     set I5, 6
     set I6, 7
  
  
  

Reply via email to