[rkward-cvs] SF.net SVN: rkward: [1381] trunk/rkward/rkward/rbackend

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Feb 12 15:08:00 UTC 2007


Revision: 1381
          http://svn.sourceforge.net/rkward/?rev=1381&view=rev
Author:   tfry
Date:     2007-02-12 07:08:00 -0800 (Mon, 12 Feb 2007)

Log Message:
-----------
Found a way to bring Qt and R includes together. NOT FOR 0.4.6

Modified Paths:
--------------
    trunk/rkward/rkward/rbackend/rembedinternal.cpp
    trunk/rkward/rkward/rbackend/rthread.cpp

Modified: trunk/rkward/rkward/rbackend/rembedinternal.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rembedinternal.cpp	2007-02-12 10:46:47 UTC (rev 1380)
+++ trunk/rkward/rkward/rbackend/rembedinternal.cpp	2007-02-12 15:08:00 UTC (rev 1381)
@@ -21,6 +21,13 @@
 // static
 REmbedInternal *REmbedInternal::this_pointer = 0; 
 
+#define QT_NO_COMPAT
+#define TRUE (const bool)0
+#define FALSE (const bool)!0
+#include <qstring.h>
+#undef TRUE
+#undef FALSE
+
 extern "C" {
 #define R_INTERFACE_PTRS 1
 
@@ -365,8 +372,6 @@
 
 /** This function is the R side wrapper around stringsToStringList */
 QString *SEXPToStringList (SEXP from_exp, unsigned int *count) {
-	char **strings = 0;
-	
 	// bad format? coerce the vector first
 	if (TYPEOF (from_exp) != STRSXP) {
 		SEXP strexp;
@@ -378,23 +383,21 @@
 
 	// format already good? Avoid coercion (and associated copying)
 	*count = length (from_exp);
-	strings = new char* [*count];
+	QString *list = new QString[*count];
 	unsigned int i = 0;
 	for (; i < *count; ++i) {
 		SEXP dummy = VECTOR_ELT (from_exp, i);
 
 		if (TYPEOF (dummy) != CHARSXP) {
-			strings[i] = strdup ("not defined");	// can this ever happen?
+			list[i] = QString::fromLocal8Bit ("not defined");	// can this ever happen?
 		} else {
 			if (dummy == NA_STRING) {
-				strings[i] = REmbedInternal::na_char_internal;
+				list[i] = QString::null;
 			} else {
-				strings[i] = (char *) STRING_PTR (dummy);
+				list[i] = QString::fromLocal8Bit ((char *) STRING_PTR (dummy));
 			}
 		}
 	}
-	QString *list = stringsToStringList (strings, i);
-	delete [] strings;
 
 	return list;
 }
@@ -492,7 +495,7 @@
 	unsigned int count;
 	QString *strings = SEXPToStringList (call, &count);
 	REmbedInternal::this_pointer->handleError (strings, count);
-	deleteQStringArray (strings);
+	delete [] strings;
 	return R_NilValue;
 }
 
@@ -508,7 +511,7 @@
 	unsigned int count;
 	QString *strings = SEXPToStringList (call, &count);
 	REmbedInternal::this_pointer->handleSubstackCall (strings, count);
-	deleteQStringArray (strings);
+	delete [] strings;
 	return R_NilValue;
 }
 

Modified: trunk/rkward/rkward/rbackend/rthread.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.cpp	2007-02-12 10:46:47 UTC (rev 1380)
+++ trunk/rkward/rkward/rbackend/rthread.cpp	2007-02-12 15:08:00 UTC (rev 1381)
@@ -569,16 +569,3 @@
 	}
 
 }
-
-QString *stringsToStringList (char **strings, int count) {
-	QString *list = new QString[count];
-	for (int i=0; i < count; ++i) {
-		if (strings[i] == REmbedInternal::na_char_internal) list[i] = QString::null;
-		else list[i] = (QString::fromLocal8Bit (strings[i]));
-	}
-	return list;
-}
-
-void deleteQStringArray (QString *strings) {
-	delete [] strings;
-}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list