[sword-devel] (Perl) Getting list of modules

Christian Renz sword-devel@crosswire.org
Sat, 28 Jun 2003 23:02:03 +0200


Joachim,

my Sword.pm has neither ->moduleCount nor ->getModuleAt !? I'm using
version 1.5.5 of the API. (The Perl module files are at
www.crosswire.org:/home/sword/ipkgmaker/Sword-1.5.5)

I'd rewrite your code as

    # untested
    my $mgr = Sword::SWMgr->new();

    @names = map { $mgr->getModuleAt($_)->Name() }
        1..$mgr->moduleCount();


to make it more perlish. Seems not too complicated to me to use.
I'm not very familiar with Swig (last time I looked at it was 1.5
years ago), but AFAIK it might be easier to just write the method in
Perl and add it to the Swig files rather than trying to get it done in
C. A method like

  sub modules { 
      my $self = shift;

      return map { $self->getModuleAt($_) } 1..$self->moduleCount();
  }

should do the trick. Now how to add Perl code to the Swig files I
don't know :).

Greetings,
   Christian

-- 
crenz@web42.com - http://www.web42.com/crenz/ - http://www.web42.com/

"What we call Man's power over Nature turns out to be a power exercised
by some men over other men with Nature as its instrument."
    -- C.S. Lewis, The Abolition of Man