[sword-svn] r2150 - trunk/bindings/swig
benpmorgan at www.crosswire.org
benpmorgan at www.crosswire.org
Sun Apr 27 22:00:30 MST 2008
Author: benpmorgan
Date: 2008-04-27 22:00:30 -0700 (Sun, 27 Apr 2008)
New Revision: 2150
Added:
trunk/bindings/swig/directors.i
trunk/bindings/swig/filemgr.i
trunk/bindings/swig/ftptrans.i
trunk/bindings/swig/swversion.i
trunk/bindings/swig/templates.i
Modified:
trunk/bindings/swig/installmgr.i
trunk/bindings/swig/localemgr.i
trunk/bindings/swig/osishtmlhref.i
trunk/bindings/swig/rendercallback.h
trunk/bindings/swig/swconfig.i
trunk/bindings/swig/swkey.i
trunk/bindings/swig/swmgr.i
trunk/bindings/swig/swmodule.i
trunk/bindings/swig/sword.i
Log:
Did a little restucturing of the SWIG bindings:
Moved director forward declarations in director.i
Moved all template declarations into template.i
Moved ftptrans into its own file
Added support for SWVersion, FileMgr, SWConfig
Added getAvailableLocalesVector to SWLocaleMgr
Added getConfigMap to SWModule
Removed quite a few ignores for operators which were actually translated
properly into Python code
Stopped OSISHTMLHREF from being a director class, as PyOSISHTMLHREF can handle
subclassing properly
More small changes
Added: trunk/bindings/swig/directors.i
===================================================================
--- trunk/bindings/swig/directors.i (rev 0)
+++ trunk/bindings/swig/directors.i 2008-04-28 05:00:30 UTC (rev 2150)
@@ -0,0 +1,29 @@
+/*
+This is a list of all the classes which have directors enabled.
+
+Directors allow virtual methods of classes to be overridden in a subclass in
+the target language. This may have performance implications, and is not
+available for all target languages, though it should be for the main ones
+*/
+%feature("director") sword::SWLog::logMessage;
+
+%feature("director") RenderCallback;
+%feature("director") MarkupCallback;
+
+%feature("director") SWSearcher;
+
+%feature("director") sword::StatusReporter;
+%feature("director") sword::FTPTransport;
+%feature("nodirector") sword::FTPTransport::getDirList;
+
+%feature("director:except") {
+ if ($error != NULL) {
+ throw Swig::DirectorMethodException();
+ }
+}
+
+%exception {
+ try { $action }
+ catch (Swig::DirectorException &e) { SWIG_fail; }
+}
+
Added: trunk/bindings/swig/filemgr.i
===================================================================
--- trunk/bindings/swig/filemgr.i (rev 0)
+++ trunk/bindings/swig/filemgr.i 2008-04-28 05:00:30 UTC (rev 2150)
@@ -0,0 +1,6 @@
+%{
+#include "filemgr.h"
+%}
+
+%include "filemgr.h"
+
Added: trunk/bindings/swig/ftptrans.i
===================================================================
--- trunk/bindings/swig/ftptrans.i (rev 0)
+++ trunk/bindings/swig/ftptrans.i 2008-04-28 05:00:30 UTC (rev 2150)
@@ -0,0 +1,6 @@
+%{
+#include "ftptrans.h"
+%}
+
+%include "ftptrans.h"
+
Modified: trunk/bindings/swig/installmgr.i
===================================================================
--- trunk/bindings/swig/installmgr.i 2008-03-31 04:44:30 UTC (rev 2149)
+++ trunk/bindings/swig/installmgr.i 2008-04-28 05:00:30 UTC (rev 2150)
@@ -1,24 +1,8 @@
-%include "std_map.i"
-%include "std_vector.i"
%ignore sword::InstallSource::userData;
-%ignore sword::FTPTransport::getDirList;
-//%ignore sword::InstallMgr::getModuleStatus;
%{
#include "installmgr.h"
-#include "ftptrans.h"
%}
-
-%template() std::pair<sword::SWBuf, sword::InstallSource*>;
-%template(InstallSourceMap) std::map<sword::SWBuf, sword::InstallSource*>;
-%template() std::pair<sword::SWModule *, int>;
-%template() std::map<sword::SWModule *, int>;
-//%ignore sword::InstallSource::MODSTAT_OLDER;
-
-
-
%include "installmgr.h"
-%include "ftptrans.h"
-
Modified: trunk/bindings/swig/localemgr.i
===================================================================
--- trunk/bindings/swig/localemgr.i 2008-03-31 04:44:30 UTC (rev 2149)
+++ trunk/bindings/swig/localemgr.i 2008-04-28 05:00:30 UTC (rev 2150)
@@ -6,3 +6,10 @@
%include "localemgr.h"
+%extend sword::LocaleMgr {
+ std::vector < sword::SWBuf > getAvailableLocalesVector() {
+ std::list<sword::SWBuf> l(self->getAvailableLocales());
+ return std::vector< sword::SWBuf >(l.begin(), l.end());
+ }
+}
+
Modified: trunk/bindings/swig/osishtmlhref.i
===================================================================
--- trunk/bindings/swig/osishtmlhref.i 2008-03-31 04:44:30 UTC (rev 2149)
+++ trunk/bindings/swig/osishtmlhref.i 2008-04-28 05:00:30 UTC (rev 2150)
@@ -1,6 +1,3 @@
-
-%feature("director") OSISHTMLHREF;
-
%{
#include <swbasicfilter.h>
#include <osishtmlhref.h>
Modified: trunk/bindings/swig/rendercallback.h
===================================================================
--- trunk/bindings/swig/rendercallback.h 2008-03-31 04:44:30 UTC (rev 2149)
+++ trunk/bindings/swig/rendercallback.h 2008-04-28 05:00:30 UTC (rev 2150)
@@ -49,8 +49,10 @@
public:
// Create a class which can be inherited externally
+#ifndef SWIG
using sword::OSISHTMLHREF::MyUserData;
- class MyOsisUserData : public MyUserData {};
+ class MyOsisUserData : public MyUserData {};
+#endif
PyOSISHTMLHREF(RenderCallback* callback)
{
@@ -114,8 +116,10 @@
RenderCallback* _callback;
public:
// Create a class which can be inherited externally
+#ifndef SWIG
using sword::ThMLHTMLHREF::MyUserData;
class MyThmlUserData : public MyUserData {};
+#endif
PyThMLHTMLHREF(RenderCallback* callback)
{
Modified: trunk/bindings/swig/swconfig.i
===================================================================
--- trunk/bindings/swig/swconfig.i 2008-03-31 04:44:30 UTC (rev 2149)
+++ trunk/bindings/swig/swconfig.i 2008-04-28 05:00:30 UTC (rev 2150)
@@ -17,5 +17,9 @@
const char* get(const char* group, const char* entry) {
return self->Sections[group][entry].c_str();
};
+ std::multimap < sword::SWBuf, std::map <sword::SWBuf, sword::SWBuf> >
+ *getSections() {
+ return (std::multimap < sword::SWBuf, std::map < sword::SWBuf, sword::SWBuf > > *) &self->Sections;
+ }
}
Modified: trunk/bindings/swig/swkey.i
===================================================================
--- trunk/bindings/swig/swkey.i 2008-03-31 04:44:30 UTC (rev 2149)
+++ trunk/bindings/swig/swkey.i 2008-04-28 05:00:30 UTC (rev 2150)
@@ -2,52 +2,8 @@
#include "swkey.h"
%}
-%ignore sword::SWKey::operator++;
-%ignore sword::SWKey::operator+=;
-%ignore sword::SWKey::operator--;
-%ignore sword::SWKey::operator-;
-%ignore sword::SWKey::operator-=;
-%ignore sword::SWKey::operator=;
-%ignore sword::SWKey::operator==;
-%ignore sword::SWKey::operator<;
-%ignore sword::SWKey::operator>;
-%ignore sword::SWKey::operator!=;
-%ignore sword::SWKey::operator>=;
-%ignore sword::SWKey::operator<=;
-%ignore sword::SWKey::operator const char *;
-
%ignore sword::SWKey::userData;
%rename (getPosition) sword::SW_POSITION::operator char;
%include "swkey.h"
-
-
-//%extend {
-// void setPersist(signed char persists) {
-// self->Persist(persists);
-// };
-//}
-
-
-//%extend {
-// /**
-// * Goes to the next key. Only useful for VerseKeys at the moment.
-// */
-// void next() {
-// (*self)++;
-// };
-// void prev() {
-// (*self)++;
-// };
-// void setKey(const SWKey* key) {
-// self->copyFrom(*key);
-// };
-//
-// /**
-// * We define here some casting functions since Perl etc. don't support casts of pointers.
-// */
-// VerseKey* toVerseKey() {
-// return dynamic_cast<VerseKey*>(self);
-// };
-//}
Modified: trunk/bindings/swig/swmgr.i
===================================================================
--- trunk/bindings/swig/swmgr.i 2008-03-31 04:44:30 UTC (rev 2149)
+++ trunk/bindings/swig/swmgr.i 2008-04-28 05:00:30 UTC (rev 2150)
@@ -1,10 +1,3 @@
-%include "std_map.i"
-%include "std_vector.i"
-
-%template() std::pair<sword::SWBuf, sword::SWModule*>;
-%template(ModuleMap) std::map<sword::SWBuf, sword::SWModule*>;
-%template(StringVector) std::vector < sword::SWBuf >;
-
%{
#include <swmgr.h>
%}
@@ -26,24 +19,24 @@
return std::vector< sword::SWBuf >(l.begin(), l.end());
}
- std::map<sword::SWBuf, sword::SWModule*> &getModules() {
- return self->Modules;
+ std::map<sword::SWBuf, sword::SWModule*> &getModules() {
+ return self->Modules;
+ }
+
+ SWModule* getModuleAt( const int pos ) {
+ if (pos < 0 || pos > self->Modules.size() )
+ return 0;
+
+ sword::ModMap::iterator it = self->Modules.begin();
+
+ for (int i = 0; i < pos; ++i) {
+ it++;
}
-
- SWModule* getModuleAt( const int pos ) {
- if (pos < 0 || pos > self->Modules.size() )
- return 0;
-
- sword::ModMap::iterator it = self->Modules.begin();
-
- for (int i = 0; i < pos; ++i) {
- it++;
- }
- if ( it != self->Modules.end() ) {
- return (*it).second;
- }
-
- return 0;
- }
+ if ( it != self->Modules.end() ) {
+ return (*it).second;
+ }
+
+ return 0;
+ }
}
Modified: trunk/bindings/swig/swmodule.i
===================================================================
--- trunk/bindings/swig/swmodule.i 2008-03-31 04:44:30 UTC (rev 2149)
+++ trunk/bindings/swig/swmodule.i 2008-04-28 05:00:30 UTC (rev 2150)
@@ -1,36 +1,9 @@
-%include "stl.i"
-%include "std_pair.i"
-%include "std_map.i"
-
-
-%inline %{
-typedef std::map< sword::SWBuf, sword::SWBuf > AttributeValueMap;
-typedef std::map< sword::SWBuf, AttributeValueMap> AttributeListMap;
-typedef std::map< sword::SWBuf, AttributeListMap> AttributetypeListMap;
-%}
-
-%template() std::pair <sword::SWBuf, sword::SWBuf>;
-%template(AttributeValueMap) std::map < sword::SWBuf, sword::SWBuf >;
-%template() std::pair <sword::SWBuf, AttributeValueMap>;
-%template(AttributeListMap) std::map < sword::SWBuf, AttributeValueMap>;
-%template() std::pair < sword::SWBuf, AttributeListMap>;
-%template(AttributeTypeListMap) std::map < sword::SWBuf, AttributeListMap>;
-
%{
#include "swmodule.h"
%}
-%warnfilter(401) sword::SWModule;
-
-%ignore sword::SWModule::operator const char *;
%ignore sword::SWModule::operator sword::SWKey &;
%ignore sword::SWModule::operator sword::SWKey *;
-%ignore sword::SWModule::operator +=;
-%ignore sword::SWModule::operator -=;
-%ignore sword::SWModule::operator <<;
-%ignore sword::SWModule::operator ++;
-%ignore sword::SWModule::operator --;
-%ignore sword::SWModule::operator =;
%ignore sword::SWModule::Search;
@@ -54,5 +27,9 @@
&getEntryAttributesMap() {
return self->getEntryAttributes();
}
+
+ std::map <sword::SWBuf, sword::SWBuf> *getConfigMap() {
+ return ( std::map < sword::SWBuf, sword::SWBuf > * ) &self->getConfig();
+ }
}
Modified: trunk/bindings/swig/sword.i
===================================================================
--- trunk/bindings/swig/sword.i 2008-03-31 04:44:30 UTC (rev 2149)
+++ trunk/bindings/swig/sword.i 2008-04-28 05:00:30 UTC (rev 2150)
@@ -1,35 +1,15 @@
-%include <stl.i>
-%include <std_map.i>
-
#define SWDLLEXPORT
+#define EXCLUDE_INSTALLMGR
%module "Sword"
%module(directors="1") Sword;
-%feature("director") sword::SWLog::logMessage;
+/* Ignore warnings about Unknown base class */
+%warnfilter(401);
-%feature("director") RenderCallback;
-%feature("director") MarkupCallback;
+%include "directors.i"
-%feature("director") SWSearcher;
-
-%feature("director") sword::StatusReporter;
-
-
-%feature("director:except") {
- if ($error != NULL) {
- throw Swig::DirectorMethodException();
- }
-}
-
-%exception {
- try { $action }
- catch (Swig::DirectorException &e) { SWIG_fail; }
-}
-
-
-
-
+/* Some generic ignores. These don't map into any Python operators */
%ignore *::operator=;
%ignore *::operator++;
%ignore *::operator--;
@@ -37,15 +17,16 @@
%ignore *::operator sword::SWKey &;
%ignore *::operator sword::SWKey *;
-
%include "defs.i"
-
%include "swbuf.i"
-%include "swconfig.i"
+/* Now include all the STL templates we are going to use */
+%include "templates.i"
+
%include "swobject.i"
+%include "swconfig.i"
+%include "swversion.i"
-
%include "swkey.i"
%include "listkey.i"
%include "versekey.i"
@@ -65,7 +46,9 @@
%include "swmodule.i"
+
%include "swmgr.i"
+%include "filemgr.h"
%include "encfiltmgr.i"
%include "markupfiltmgr.i"
@@ -101,5 +84,10 @@
%include "osishtmlhref.i"
%include "extras.i"
%include "swlog.i"
+
+%include "ftptrans.i"
+
+#ifndef EXCLUDE_INSTALLMGR
%include "installmgr.i"
+#endif
Added: trunk/bindings/swig/swversion.i
===================================================================
--- trunk/bindings/swig/swversion.i (rev 0)
+++ trunk/bindings/swig/swversion.i 2008-04-28 05:00:30 UTC (rev 2150)
@@ -0,0 +1,5 @@
+%{
+#include "swversion.h"
+%}
+
+%include "swversion.h"
Added: trunk/bindings/swig/templates.i
===================================================================
--- trunk/bindings/swig/templates.i (rev 0)
+++ trunk/bindings/swig/templates.i 2008-04-28 05:00:30 UTC (rev 2150)
@@ -0,0 +1,56 @@
+%include <stl.i>
+%include <std_map.i>
+%include <std_pair.i>
+%include <std_multimap.i>
+
+/*
+Include SWModule and DirEntry here, so that it will be able to appear below
+*/
+%{
+#include "swmodule.h"
+#include "filemgr.h"
+%}
+
+/*
+These are the stl templates that are used throughout Sword. Some have more
+than one name in Sword, depending on context. However, these are all wrapped with the one class.
+For example, sword::AttributeValueMap is the same as sword::ConfigEntMap
+Both are wrapped as the former, however
+*/
+%inline %{
+typedef std::map< sword::SWBuf, sword::SWBuf > AttributeValueMap;
+typedef std::map< sword::SWBuf, AttributeValueMap> AttributeListMap;
+typedef std::map< sword::SWBuf, AttributeListMap> AttributetypeListMap;
+%}
+
+/* Used by SWModule and SWConfig */
+%template() std::pair <sword::SWBuf, sword::SWBuf>;
+%template(AttributeValueMap) std::map < sword::SWBuf, sword::SWBuf >;
+
+/* Used by SWModule */
+%template() std::pair <sword::SWBuf, AttributeValueMap>;
+%template(AttributeListMap) std::map < sword::SWBuf, AttributeValueMap>;
+%template() std::pair < sword::SWBuf, AttributeListMap>;
+%template(AttributeTypeListMap) std::map < sword::SWBuf, AttributeListMap>;
+
+/* Used by SWConfig */
+%template(SectionMapMultiMap) std::multimap < sword::SWBuf, AttributeValueMap >;
+
+/* Used by SWMgr */
+%template() std::pair<sword::SWBuf, sword::SWModule*>;
+%template(ModuleMap) std::map<sword::SWBuf, sword::SWModule*>;
+
+/* Used by SWMgr and LocaleMgr */
+%template(StringVector) std::vector < sword::SWBuf >;
+
+/* Used by InstallMgr */
+#ifndef EXCLUDE_INSTALLMGR
+
+%template() std::pair<sword::SWBuf, sword::InstallSource*>;
+%template(InstallSourceMap) std::map<sword::SWBuf, sword::InstallSource*>;
+%template() std::pair<sword::SWModule *, int>;
+%template() std::map<sword::SWModule *, int>;
+#endif
+
+/* Used by DirEntry */
+%template(DirEntryVector) std::vector < sword::DirEntry > ;
More information about the sword-cvs
mailing list