[rkward-cvs] SF.net SVN: rkward:[2997] trunk/rkward/rkward/rbackend/rembedinternal.cpp
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Sat Sep 4 13:22:33 UTC 2010
Revision: 2997
http://rkward.svn.sourceforge.net/rkward/?rev=2997&view=rev
Author: tfry
Date: 2010-09-04 13:22:33 +0000 (Sat, 04 Sep 2010)
Log Message:
-----------
Small cleanup
Modified Paths:
--------------
trunk/rkward/rkward/rbackend/rembedinternal.cpp
Modified: trunk/rkward/rkward/rbackend/rembedinternal.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rembedinternal.cpp 2010-09-04 13:14:53 UTC (rev 2996)
+++ trunk/rkward/rkward/rbackend/rembedinternal.cpp 2010-09-04 13:22:33 UTC (rev 2997)
@@ -126,7 +126,7 @@
QString *SEXPToStringList (SEXP from_exp, unsigned int *count);
QString SEXPToString (SEXP from_exp);
int *SEXPToIntArray (SEXP from_exp, unsigned int *count);
-int SEXPToInt (SEXP from_exp);
+int SEXPToInt (SEXP from_exp, int def_value = INT_MIN);
// ############## R Standard callback overrides BEGIN ####################
void RSuicide (const char* message) {
@@ -291,14 +291,12 @@
RK_TRACE (RBACKEND);
// this function would be much shorter, if SEXPToStringList would simply return a QStringList...
- unsigned int files_count, titles_count, wtitle_count, del_count;
+ unsigned int files_count, titles_count;
QString *file_strings = SEXPToStringList (files, &files_count);
QString *title_strings = SEXPToStringList (titles, &titles_count);
- QString *wtitle_strings = SEXPToStringList (wtitle, &wtitle_count);
- int *del_bools = SEXPToIntArray (del, &del_count);
+ QString wtitle_string = SEXPToString (wtitle);
+ bool del_files = SEXPToInt (del, 0) != 0;
- RK_ASSERT (wtitle_count <= 1);
- RK_ASSERT (del_count <= 1);
RK_ASSERT (files_count == titles_count);
RK_ASSERT (files_count >= 1);
@@ -310,17 +308,11 @@
files_list.append (file_strings[i]);
titles_list.append (title_strings[i]);
}
- QString wtitle_string;
- if (wtitle_count) wtitle_string = wtitle_strings[0];
- bool del_files = false;
- if (del_count) del_files = (del_bools[0] != 0);
REditFilesHelper (files_list, titles_list, wtitle_string, edit, del_files);
delete [] file_strings;
delete [] title_strings;
- delete [] wtitle_strings;
- delete [] del_bools;
return (R_NilValue);
}
@@ -538,7 +530,7 @@
R_ToplevelExec (processX11EventsWorker, 0);
}
-// converts SEXP to strings, and returns the first string (or QString(), if SEXP contains no strings)
+/** converts SEXP to strings, and returns the first string (or QString(), if SEXP contains no strings) */
QString SEXPToString (SEXP from_exp) {
RK_TRACE (RBACKEND);
@@ -619,11 +611,11 @@
return integers;
}
-// converts SEXP to integers, and returns the first int (INT_MIN, if SEXP contains no ints)
-int SEXPToInt (SEXP from_exp) {
+/** converts SEXP to integers, and returns the first int (def_value, if SEXP contains no ints) */
+int SEXPToInt (SEXP from_exp, int def_value) {
RK_TRACE (RBACKEND);
- int ret = INT_MIN;
+ int ret = def_value;
unsigned int count;
int *integers = SEXPToIntArray (from_exp, &count);
if (count >= 1) ret = integers[0];
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