[sword-devel] SWIG for Sword!

Joachim Ansorg sword-devel@crosswire.org
Sat, 22 Jun 2002 02:35:52 +0200


Thank you for your kind words!

Now I extended the interface so you can write all sorts of modules (RawText, 
zText, RawLD, RawLD4, zLD, RawCom, RawGenBook etc.)! I think this is usefuil 
for module creation.

Is here some Automake expert? I need some help with the Makefile so it creates 
a shared lib from the SWIG file. I'd be glad for some help!

Joachim

> Wow,
> 	Even I can almost understand that Perl code!  Nice work.
>
> 	-Troy.
>
> Joachim Ansorg wrote:
> > Hi!
> >
> > Some time ago I read in the TWiki of Sword, that SWIG interface files for
> > Sword would be cool. I never heard about SWIG, but I decided to try
> > creating the necessary interface files after I read what SWIG is.
> >
> > Now I have a basic set working. I added the files to bindings/swig/. The
> > Makefile is not yet working properly with the automake system, but I hope
> > I can fix this soon. At the moment it's a default Makefile made on my
> > system, a perl module is created.
> > The interface files have to be refined in future, but they're working for
> > the basic things.
> >
> > For the curious: With the Swig interface files I can write the following
> > in perl:
> > --------------
> > $localemgr = sword::LocaleMgr::systemLocaleMgr();
> > $localemgr->setDefaultLocaleName("de");
> >
> > $mgr = new sword::SWMgr();
> > $module = $mgr->module("WEB");
> > print "Description of module ", $module->Name(), ": \n\t",
> > $module->Description(), "\n";
> >
> > $key = new sword::VerseKey("Matthew 3:16");
> > $key->setPersist(1);
> > $module->SetKey($key);
> >
> > for ($i = 0; $i < 15; $i++) {
> >   print "(", $module->KeyText() ,")\t", $module->StripText(), "\n";
> >   $key->next();
> > }
> >
> > $module->write("This is a test entry! This tests the write abilities of
> > the Sword Perl classes");
> > ----------------
> >
> > As you can see the API is almost like Sword's C++ API, but operators are
> > not supported. I renamed them (e.g. SWModule::operator << to
> > SWModule::write).
> >
> > The last call writes into the module! I hope you find the interface files
> > useful! I think we can even create bindings to Java, Phyton, Ruby etc.
> > using SWIG, although I have not yet tried this.
> >
> > Joachim