[sword-svn] r2273 - trunk/bindings/swig

benpmorgan at crosswire.org benpmorgan at crosswire.org
Tue Mar 3 16:50:42 MST 2009


Author: benpmorgan
Date: 2009-03-03 16:50:42 -0700 (Tue, 03 Mar 2009)
New Revision: 2273

Modified:
   trunk/bindings/swig/swlocale.i
   trunk/bindings/swig/versekey.i
Log:
Update to work with SVN. 
A few methods have been removed from SWLocale, while VerseKey methods have
stayed but changed implementation to use VerseMgr code. 
Currently VerseMgr is not well wrapped as it is contains inner classes.



Modified: trunk/bindings/swig/swlocale.i
===================================================================
--- trunk/bindings/swig/swlocale.i	2009-03-03 23:46:37 UTC (rev 2272)
+++ trunk/bindings/swig/swlocale.i	2009-03-03 23:50:42 UTC (rev 2273)
@@ -7,7 +7,7 @@
 
 %include "swlocale.h"
 
-%extend sword::SWLocale {
+/*%extend sword::SWLocale {
         int getNumBookGroupings() {
                 return 2;
         }
@@ -28,4 +28,4 @@
 
                 return books[grouping][booknum];
         }
-};
+};*/

Modified: trunk/bindings/swig/versekey.i
===================================================================
--- trunk/bindings/swig/versekey.i	2009-03-03 23:46:37 UTC (rev 2272)
+++ trunk/bindings/swig/versekey.i	2009-03-03 23:50:42 UTC (rev 2273)
@@ -1,5 +1,6 @@
 %{
 #include "versekey.h"
+#include "versemgr.h"
 %}
 
 
@@ -18,6 +19,7 @@
 %immutable sword::abbrev::ab;
 
 %include "versekey.h"
+%include "versemgr.h"
 
 %extend sword::abbrev {
 	int getAbbrevCount() {
@@ -63,6 +65,14 @@
 	};
 
 
+    const int getBookCount(){
+        const sword::VerseMgr::System* system = sword::VerseMgr::getSystemVerseMgr()->getVersificationSystem(
+            self->getVersificationSystem()
+        );
+        return system->getBookCount();
+    }
+    
+        
 	/* Get name of book
 	* Returns the name of the booknumber in the givn testament.
 	* Testament may be 1 (OT) or 2 (NT)
@@ -70,15 +80,42 @@
 	*/
 	const char* bookName( const int testament, const int book ) {
 		if ( (testament < 1) || (testament > 2) ) {
-			return "";
+			return 0;
 		};
 		if ( (book < 1) || (book > self->BMAX[testament-1]) ) {
-			return "";
+			return 0;
 		}
 
-		return self->books[testament-1][book-1].name;
+        const sword::VerseMgr::System* system = sword::VerseMgr::getSystemVerseMgr()->getVersificationSystem(
+            self->getVersificationSystem()
+        );
+        
+        int book_num = (book - 1) + (
+            (testament == 2) ? self->BMAX[0] : 0
+        );
+
+        const sword::VerseMgr::Book* b = system->getBook(book_num);
+        if(!b) {
+            fprintf(stderr, "b is null for %d?!?\n", book_num);
+            return 0;
+        }
+        return b->getLongName();
+
+ 
 	};
 
+    const char* getOSISBookName( const int book ) {
+        const sword::VerseMgr::System* system = sword::VerseMgr::getSystemVerseMgr()->getVersificationSystem(
+            self->getVersificationSystem()
+        );
+   		if ( (book < 0) || (book >= system->getBookCount()))
+            return 0;
+
+        return system->getBook(book)->getOSISName();
+    }
+ 
+        
+
 	/* 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)
@@ -91,7 +128,21 @@
 			return 0;
 		}
 
-		return self->books[testament-1][book-1].chapmax;
+        const sword::VerseMgr::System* system = sword::VerseMgr::getSystemVerseMgr()->getVersificationSystem(
+            self->getVersificationSystem()
+        );
+        
+        int book_num = (book - 1) + (
+            (testament == 2) ? self->BMAX[0] : 0
+        );
+
+        const sword::VerseMgr::Book* b = system->getBook(book_num);
+        if(!b) {
+            fprintf(stderr, "b is null for %d?!?\n", book_num);
+            return 0;
+        }        
+
+        return b->getChapterMax();
 	};
 	/* Get number of verses in the given chapter of the given in the given testament,
 	* testament may be 1 (OT) or 2 (NT)
@@ -105,11 +156,25 @@
 		if ( (book < 1) || (book > self->BMAX[testament-1]) ) {
 			return 0;
 		}
-		if ( (chapter < 1) || (chapter > self->books[testament-1][book-1].chapmax) ) {
+
+        const sword::VerseMgr::System* system = sword::VerseMgr::getSystemVerseMgr()->getVersificationSystem(
+            self->getVersificationSystem()
+        );
+        
+        int book_num = (book - 1) + (
+            (testament == 2) ? self->BMAX[0] : 0
+        );
+
+        const sword::VerseMgr::Book* b = system->getBook(book_num);
+        if(!b) {
+            fprintf(stderr, "b is null for %d?!?\n", book_num);
+            return 0;
+        }
+		if ( (chapter < 1) || (chapter > b->getChapterMax()) ) {
 			return 0;
 		}
 
-		return self->books[testament-1][book-1].versemax[chapter-1];
+		return b->getVerseMax(chapter);
 
 	};
 };




More information about the sword-cvs mailing list