[sword-svn] r2158 - in trunk/bindings/swig: . package

benpmorgan at www.crosswire.org benpmorgan at www.crosswire.org
Tue May 13 19:36:59 MST 2008


Author: benpmorgan
Date: 2008-05-13 19:36:58 -0700 (Tue, 13 May 2008)
New Revision: 2158

Added:
   trunk/bindings/swig/stringmgr.i
   trunk/bindings/swig/utilxml.i
Modified:
   trunk/bindings/swig/directors.i
   trunk/bindings/swig/localemgr.i
   trunk/bindings/swig/markupfiltmgr.i
   trunk/bindings/swig/package/Makefile.am
   trunk/bindings/swig/package/configure.ac
   trunk/bindings/swig/package/sword.m4
   trunk/bindings/swig/rawcom.i
   trunk/bindings/swig/rawgenbook.i
   trunk/bindings/swig/rawld.i
   trunk/bindings/swig/rawld4.i
   trunk/bindings/swig/rawtext.i
   trunk/bindings/swig/swbuf.i
   trunk/bindings/swig/swmgr.i
   trunk/bindings/swig/sword.i
   trunk/bindings/swig/templates.i
   trunk/bindings/swig/treekeyidx.i
   trunk/bindings/swig/versekey.i
   trunk/bindings/swig/versetreekey.i
   trunk/bindings/swig/zcom.i
   trunk/bindings/swig/zld.i
   trunk/bindings/swig/ztext.i
Log:
Added XmlTag support and subclassable stringmgr support.
Allowed casting to subtypes of SWModule and SWKey without going through
intermediate stages. (e.g. SWModule -> RawLD4, instead of SWModule -> SWLD ->
RawLD)

Wrapped setLocale and builtin_abbrevs, as well as added methods on 
the abbreviation to allow iterating through them. Set sbook and abbrevs
members to be immutable to remove warnings.

Wrapped some StringList's directly, in addition to the Vector methods
For example, SWMgr.getGlobalOptions can be called directly, rather than using
SWMgr.getGlobalOptionsVector.

Fixed installmgr wrapping so that it works again.

Fixed python setup to be able to be run from the python directory properly
Updated version number to 1.5.11



Modified: trunk/bindings/swig/directors.i
===================================================================
--- trunk/bindings/swig/directors.i	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/directors.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -6,6 +6,9 @@
 available for all target languages, though it should be for the main ones
 */
 %feature("director") sword::SWLog::logMessage;
+%feature("director") PyStringMgr;
+%feature("nodirector") PyStringMgr::upperUTF8;
+%feature("nodirector") PyStringMgr::upperLatin1;
 
 %feature("director") RenderCallback;
 %feature("director") MarkupCallback;

Modified: trunk/bindings/swig/localemgr.i
===================================================================
--- trunk/bindings/swig/localemgr.i	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/localemgr.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -2,8 +2,6 @@
 #include <localemgr.h>
 %}
 
-%ignore sword::LocaleMgr::getAvailableLocales;
-
 %include "localemgr.h"
 
 %extend sword::LocaleMgr {

Modified: trunk/bindings/swig/markupfiltmgr.i
===================================================================
--- trunk/bindings/swig/markupfiltmgr.i	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/markupfiltmgr.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -7,7 +7,7 @@
 
 
 %extend sword::MarkupFilterMgr {
-	static sword::MarkupFilterMgr *castTo(sword::EncodingFilterMgr *o) {
+	static sword::MarkupFilterMgr *castTo(sword::SWFilterMgr *o) {
 		return dynamic_cast<sword::MarkupFilterMgr*>(o);
 	}
-}
\ No newline at end of file
+}

Modified: trunk/bindings/swig/package/Makefile.am
===================================================================
--- trunk/bindings/swig/package/Makefile.am	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/package/Makefile.am	2008-05-14 02:36:58 UTC (rev 2158)
@@ -72,7 +72,7 @@
 	$(SWIG) -tcl -c++ -namespace -pkgversion $(VERSION) -o tcl/Sword.cxx -I$(top_srcdir) $(SWORD_INCLUDES) $(top_srcdir)/sword.i
 
 python_make: python_makebuild
-	cd python && $(PYTHON) setup.py build_ext $(SWORD_INCLUDES):.. $(LIB_SWORD)
+	cd python && $(PYTHON) setup.py build_ext $(LIB_SWORD)
 
 pythonswig: sword.i
 	mkdir -p python
@@ -90,7 +90,7 @@
 	@echo "	maintainer_email = \"sword-devel at crosswire.org\"," >> python/setup.py
 	@echo "	url = \"http://www.crosswire.org/sword\"," >> python/setup.py
 	@echo "	py_modules = [\"Sword\"]," >> python/setup.py
-	@echo "	include_dirs=['$(SWORD_INCLUDES)']," >> python/setup.py
+	@echo "	include_dirs=['$(SWORD_INCLUDE_DIR)', '..', '../..']," >> python/setup.py
 	@echo "	ext_modules = [Extension(\"_Sword\", [\"Sword.cxx\"]," >> python/setup.py
 	@echo "	libraries=[('sword')], " >> python/setup.py
 	@echo "	define_macros=[('SWIG',1)])], " >> python/setup.py

Modified: trunk/bindings/swig/package/configure.ac
===================================================================
--- trunk/bindings/swig/package/configure.ac	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/package/configure.ac	2008-05-14 02:36:58 UTC (rev 2158)
@@ -1,11 +1,11 @@
 # ---------------------------------------------------------------------
 # Initialisation
 # ---------------------------------------------------------------------
-AC_INIT(swordbindings, 1.5.8, sword-bugs at crosswire.org)
+AC_INIT([swordbindings],[1.5.11],[sword-bugs at crosswire.org])
 AC_CONFIG_SRCDIR(sword.i)
-AC_PREREQ(2.52)
+AC_PREREQ(2.59)
 AC_REVISION($Revision: 1.2 $)
-AM_INIT_AUTOMAKE(swordbindings,1.5.8)
+AM_INIT_AUTOMAKE(swordbindings,1.5.11)
 
 # ---------------------------------------------------------------------
 # Check Programs

Modified: trunk/bindings/swig/package/sword.m4
===================================================================
--- trunk/bindings/swig/package/sword.m4	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/package/sword.m4	2008-05-14 02:36:58 UTC (rev 2158)
@@ -13,7 +13,7 @@
 
 dnl The option for the configure script
 AC_ARG_WITH(sword-dir,
-[  --with-sword-dir=DIR     Patch where Sword is being installed (default=/usr) ],
+[  --with-sword-dir=DIR     Path where Sword is being installed (default=/usr) ],
 [
   ac_sword_dir=$withval
 ],ac_sword_dir=/usr
@@ -75,7 +75,9 @@
 fi
 
 SWORD_INCLUDES="-I$ac_cv_sword_incdir"
+SWORD_INCLUDE_DIR="$ac_cv_sword_incdir"
 AC_SUBST(SWORD_INCLUDES)
+AC_SUBST(SWORD_INCLUDE_DIR)
 all_includes="$all_includes -I$ac_cv_sword_incdir"
 
 AC_MSG_RESULT([$ac_cv_sword_incdir])

Modified: trunk/bindings/swig/rawcom.i
===================================================================
--- trunk/bindings/swig/rawcom.i	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/rawcom.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -8,7 +8,7 @@
 
 
 %extend sword::RawCom {
-	static sword::RawCom *castTo(sword::SWCom *o) {
+	static sword::RawCom *castTo(sword::SWModule *o) {
 		return dynamic_cast<sword::RawCom*>(o);
 	}
-}
\ No newline at end of file
+}

Modified: trunk/bindings/swig/rawgenbook.i
===================================================================
--- trunk/bindings/swig/rawgenbook.i	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/rawgenbook.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -5,8 +5,8 @@
 %include "rawgenbook.h"
 
 %extend sword::RawGenBook {
-	static sword::RawGenBook *castTo(sword::SWGenBook *o) {
+	static sword::RawGenBook *castTo(sword::SWModule *o) {
 		return dynamic_cast<sword::RawGenBook*>(o);
 	}
 	
-}
\ No newline at end of file
+}

Modified: trunk/bindings/swig/rawld.i
===================================================================
--- trunk/bindings/swig/rawld.i	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/rawld.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -5,8 +5,8 @@
 %include "rawld.h"
 
 %extend sword::RawLD {
-	static sword::RawLD *castTo(sword::SWLD *o) {
+	static sword::RawLD *castTo(sword::SWModule *o) {
 		return dynamic_cast<sword::RawLD*>(o);
 	}
 
-}
\ No newline at end of file
+}

Modified: trunk/bindings/swig/rawld4.i
===================================================================
--- trunk/bindings/swig/rawld4.i	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/rawld4.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -5,8 +5,8 @@
 %include "rawld4.h"
 
 %extend sword::RawLD4 {
-	static sword::RawLD4 *castTo(sword::SWLD *o) {
+	static sword::RawLD4 *castTo(sword::SWModule *o) {
 		return dynamic_cast<sword::RawLD4*>(o);
 	}
 
-}
\ No newline at end of file
+}

Modified: trunk/bindings/swig/rawtext.i
===================================================================
--- trunk/bindings/swig/rawtext.i	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/rawtext.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -6,7 +6,7 @@
 
 
 %extend sword::RawText {
-	static sword::RawText *castTo(sword::SWText *o) {
+	static sword::RawText *castTo(sword::SWModule *o) {
 		return dynamic_cast<sword::RawText*>(o);
 	}	
-}
\ No newline at end of file
+}

Added: trunk/bindings/swig/stringmgr.i
===================================================================
--- trunk/bindings/swig/stringmgr.i	                        (rev 0)
+++ trunk/bindings/swig/stringmgr.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -0,0 +1,26 @@
+
+%{
+#include "stringmgr.h"
+class PyStringMgr : public sword::StringMgr
+{
+    public:
+       char *upperUTF8(char *text, unsigned int max = 0) const
+        {
+            sword::SWBuf buf=(const char*)text;
+            getUpper(&buf);
+            strncpy(text, buf.c_str(), (max) ? max : strlen(text));
+            return text;
+        }
+
+        virtual void getUpper(sword::SWBuf* test) const = 0;
+};
+%}
+
+%include "stringmgr.h"
+class PyStringMgr : public sword::StringMgr
+{
+    public:
+       char *upperUTF8(char *text, unsigned int max = 0) const;
+       virtual void getUpper(sword::SWBuf* test) const = 0;
+};
+

Modified: trunk/bindings/swig/swbuf.i
===================================================================
--- trunk/bindings/swig/swbuf.i	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/swbuf.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -19,6 +19,13 @@
 %ignore sword::SWBuf::operator--;
 %ignore sword::SWBuf::charAt(unsigned long);
 
+/* Ignore this horrible constructor.
+*  This would be the default for single character strings passed in. This can
+*  lead to changing of immutable strings!!!!
+*/
+%ignore sword::SWBuf::SWBuf(char, unsigned long);
+
+
 %include "swbuf.h"
 
 

Modified: trunk/bindings/swig/swmgr.i
===================================================================
--- trunk/bindings/swig/swmgr.i	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/swmgr.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -4,8 +4,6 @@
 
 %ignore sword::SWMgr::Modules;
 %ignore sword::SWMgr::findConfig;
-%ignore sword::SWMgr::getGlobalOptions;
-%ignore sword::SWMgr::getGlobalOptionValues;
 %include "swmgr.h"
 
 %extend sword::SWMgr {

Modified: trunk/bindings/swig/sword.i
===================================================================
--- trunk/bindings/swig/sword.i	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/sword.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -25,6 +25,7 @@
 %include "swobject.i"
 %include "swconfig.i"
 %include "swversion.i"
+%include "bases.i"
 
 %include "swkey.i"
 %include "listkey.i"
@@ -40,6 +41,7 @@
 %include "swfiltermgr.i"
 
 
+%include "stringmgr.i"
 %include "swsearchable.i"
 //%include "swcacher.i"
 %include "swmodule.i"
@@ -78,8 +80,8 @@
 %include "localemgr.i"
 
 %include "url.i"
+%include "utilxml.i"
 
-%include "bases.i"
 %include "osishtmlhref.i"
 %include "extras.i"
 %include "swlog.i"

Modified: trunk/bindings/swig/templates.i
===================================================================
--- trunk/bindings/swig/templates.i	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/templates.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -1,5 +1,7 @@
 %include <stl.i>
 %include <std_map.i>
+%include <std_list.i>
+
 %include <std_pair.i>
 %include <std_multimap.i>
 
@@ -43,9 +45,15 @@
 /* Used by SWMgr and LocaleMgr */
 %template(StringVector) std::vector < sword::SWBuf >;
 
+/* Used by xmltag */
+%template(StringList) std::list < sword::SWBuf >;
+
+
 /* Used by InstallMgr */
 #ifndef EXCLUDE_INSTALLMGR
-
+%{
+#include "installmgr.h"
+%}
 %template() std::pair<sword::SWBuf, sword::InstallSource*>;
 %template(InstallSourceMap) std::map<sword::SWBuf, sword::InstallSource*>;
 %template() std::pair<sword::SWModule *, int>;

Modified: trunk/bindings/swig/treekeyidx.i
===================================================================
--- trunk/bindings/swig/treekeyidx.i	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/treekeyidx.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -5,7 +5,7 @@
 %include "treekeyidx.h"
 
 %extend sword::TreeKeyIdx {
-	static sword::TreeKeyIdx *castTo(sword::TreeKey *o) {
+	static sword::TreeKeyIdx *castTo(sword::SWKey *o) {
 		return dynamic_cast<sword::TreeKeyIdx*>(o);
 	}
-}
\ No newline at end of file
+}

Added: trunk/bindings/swig/utilxml.i
===================================================================
--- trunk/bindings/swig/utilxml.i	                        (rev 0)
+++ trunk/bindings/swig/utilxml.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -0,0 +1,5 @@
+%{
+#include <utilxml.h>
+%}
+
+%include "utilxml.h"

Modified: trunk/bindings/swig/versekey.i
===================================================================
--- trunk/bindings/swig/versekey.i	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/versekey.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -3,23 +3,34 @@
 %}
 
 
-
 %ignore sword::sbook::versemax;
 %ignore sword::VerseKey::setBookAbbrevs;
 %ignore sword::VerseKey::setBooks;
-%ignore sword::VerseKey::setLocale;
-		
 
 %ignore sword::VerseKey::builtin_BMAX;
 %ignore sword::VerseKey::builtin_books;
-%ignore sword::VerseKey::builtin_abbrevs;
 %ignore sword::VerseKey::BMAX;
 %ignore sword::VerseKey::books;
-					
 
+%immutable sword::VerseKey::builtin_abbrevs;
+%immutable sword::sbook::name;
+%immutable sword::sbook::prefAbbrev;
+%immutable sword::abbrev::ab;
 
 %include "versekey.h"
 
+%extend sword::abbrev {
+	int getAbbrevCount() {
+		int abbrevsCnt;
+		for (abbrevsCnt = 0; *self[abbrevsCnt].ab; abbrevsCnt++) {}
+		return abbrevsCnt-1;
+	}
+
+	const struct sword::abbrev* getAbbrevData(int i) {
+		return &(self[i]);
+	}
+}
+
 %extend sword::sbook {
 	const int verseMax( int chapter ) {
 		if ( chapter > 0  && chapter < self->chapmax ) {

Modified: trunk/bindings/swig/versetreekey.i
===================================================================
--- trunk/bindings/swig/versetreekey.i	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/versetreekey.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -2,113 +2,11 @@
 #include "versetreekey.h"
 %}
 
-/*
-
-%ignore sword::sbook::versemax;
-%ignore sword::VerseKey::setBookAbbrevs;
-%ignore sword::VerseKey::setBooks;
-%ignore sword::VerseKey::setLocale;
-		
-
-%ignore sword::VerseKey::builtin_BMAX;
-%ignore sword::VerseKey::builtin_books;
-%ignore sword::VerseKey::builtin_abbrevs;
-%ignore sword::VerseKey::BMAX;
-%ignore sword::VerseKey::books;
-					
-*/
-
 %include "versetreekey.h"
 
-/*
-%extend sword::sbook {
-	const int verseMax( int chapter ) {
-		if ( chapter > 0  && chapter < self->chapmax ) {
-			return self->versemax[chapter-1];
-		} else {
-			return 0;
-		}
-	}
-};
-*/
-
-
 %extend sword::VerseTreeKey {
 	/* C++-style cast */
-	static sword::VerseTreeKey *castTo(sword::VerseKey *o) {
+	static sword::VerseTreeKey *castTo(sword::SWKey *o) {
 		return dynamic_cast<sword::VerseTreeKey*>(o);
 	}
-
-
-	/* Get number of books in the given testament
-	* testament may be 1 (OT) or 2 (NT)
-	*/
-
-/*        
-	const int bookCount( const int testament ) {
-		if ( (testament < 1) || (testament > 2) ) {
-			return 0;
-		};
-		return self->BMAX[testament-1];
-	};
-*/
-
-	/* Get name of book
-	* Returns the name of the booknumber in the givn testament.
-	* Testament may be 1 (OT) or 2 (NT)
-	* book may be in the range of 1 <= bookCount(testament)
-	*/
-
-	/*
-	const char* bookName( const int testament, const int book ) {
-		if ( (testament < 1) || (testament > 2) ) {
-			return "";
-		};
-		if ( (book < 1) || (book > self->BMAX[testament-1]) ) {
-			return "";
-		}
-
-		return self->books[testament-1][book-1].name;
-	};
-*/
-
-	/* Get number of chapters in the given testament and book number
-	* testament may be 1 (OT) or 2 (NT)
-	* book may be in the range 1 <= bookCount(testament)
-	*/
-/*
-const int chapterCount( const int testament, const int book ) {
-		if ( (testament < 1) || (testament > 2) ) {
-			return 0;
-		};
-		if ( (book < 1) || (book > self->BMAX[testament-1]) ) {
-			return 0;
-		}
-
-		return self->books[testament-1][book-1].chapmax;
-	};
-	*/
-
-	/* Get number of verses in the given chapter of the given in the given testament,
-	* testament may be 1 (OT) or 2 (NT)
-	* book may be in the range 1 <= bookCount(testament)
-	* chapter may be in the range 1 <= chapterCount(testament, book)
-	*/
-	
-	/*
-	const int verseCount( const int testament, const int book, const int chapter ) {
-		if ( (testament < 1) || (testament > 2) ) {
-			return 0;
-		};
-		if ( (book < 1) || (book > self->BMAX[testament-1]) ) {
-			return 0;
-		}
-		if ( (chapter < 1) || (chapter > self->books[testament-1][book-1].chapmax) ) {
-			return 0;
-		}
-
-		return self->books[testament-1][book-1].versemax[chapter-1];
-
-	};
-	*/
 };

Modified: trunk/bindings/swig/zcom.i
===================================================================
--- trunk/bindings/swig/zcom.i	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/zcom.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -6,7 +6,7 @@
 %include "zcom.h"
 
 %extend sword::zCom {
-	static sword::zCom *castTo(sword::SWCom *o) {
+	static sword::zCom *castTo(sword::SWModule *o) {
 		return dynamic_cast<sword::zCom*>(o);
 	}
-}
\ No newline at end of file
+}

Modified: trunk/bindings/swig/zld.i
===================================================================
--- trunk/bindings/swig/zld.i	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/zld.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -5,7 +5,7 @@
 %include "zld.h"
 
 %extend sword::zLD {
-	static sword::zLD *castTo(sword::SWLD *o) {
+	static sword::zLD *castTo(sword::SWModule *o) {
 		return dynamic_cast<sword::zLD*>(o);
 	}
-}
\ No newline at end of file
+}

Modified: trunk/bindings/swig/ztext.i
===================================================================
--- trunk/bindings/swig/ztext.i	2008-05-13 23:37:56 UTC (rev 2157)
+++ trunk/bindings/swig/ztext.i	2008-05-14 02:36:58 UTC (rev 2158)
@@ -5,7 +5,7 @@
 %include "ztext.h"
 
 %extend sword::zText {
-	static sword::zText *castTo(sword::SWText *o) {
+	static sword::zText *castTo(sword::SWModule *o) {
 		return dynamic_cast<sword::zText*>(o);
 	}
-}
\ No newline at end of file
+}




More information about the sword-cvs mailing list