[rkward/frameworks] rkward: Assorted fixes for compiling with MSVC on Windows.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Sat Feb 27 11:31:24 UTC 2016


Git commit b45bb9fe98ae110995acc7c04284f67fd89856b3 by Thomas Friedrichsmeier.
Committed on 27/02/2016 at 11:30.
Pushed by tfry into branch 'frameworks'.

Assorted fixes for compiling with MSVC on Windows.

M  +6    -2    rkward/rbackend/rkrbackend.cpp
M  +2    -2    rkward/rbackend/rkreventloop.cpp
M  +3    -2    rkward/rbackend/rkstructuregetter.h
M  +7    -7    rkward/rkward_startup_wrapper.cpp

http://commits.kde.org/rkward/b45bb9fe98ae110995acc7c04284f67fd89856b3

diff --git a/rkward/rbackend/rkrbackend.cpp b/rkward/rbackend/rkrbackend.cpp
index 6f0f600..8e2f311 100644
--- a/rkward/rbackend/rkrbackend.cpp
+++ b/rkward/rbackend/rkrbackend.cpp
@@ -323,7 +323,7 @@ int RReadConsole (const char* prompt, unsigned char* buf, int buflen, int hist)
 					}
 					if (incomplete) RKRBackend::this_pointer->current_command->status |= RCommand::Failed | RCommand::ErrorIncomplete;
 					RKRBackend::repl_status.user_command_status = RKRBackend::RKReplStatus::ReplIterationKilled;
-					if (RKRBackend::RKRBackend::repl_status.user_command_parsed_up_to <= 0) RKRBackend::this_pointer->startOutputCapture ();	// HACK: No capture active, but commandFinished() will try to end one
+					if (RKRBackend::repl_status.user_command_parsed_up_to <= 0) RKRBackend::this_pointer->startOutputCapture ();	// HACK: No capture active, but commandFinished() will try to end one
 					Rf_error ("");	// to discard the buffer
 				} else {
 					RKTransmitNextUserCommandChunk (buf, buflen);
@@ -332,7 +332,7 @@ int RReadConsole (const char* prompt, unsigned char* buf, int buflen, int hist)
 			} else if (RKRBackend::repl_status.user_command_status == RKRBackend::RKReplStatus::UserCommandSyntaxError) {
 				RKRBackend::this_pointer->current_command->status |= RCommand::Failed | RCommand::ErrorSyntax;
 				RKRBackend::repl_status.user_command_status = RKRBackend::RKReplStatus::NoUserCommand;
-				if (RKRBackend::RKRBackend::repl_status.user_command_parsed_up_to <= 0) RKRBackend::this_pointer->startOutputCapture ();	// HACK: No capture active, but commandFinished() will try to end one
+				if (RKRBackend::repl_status.user_command_parsed_up_to <= 0) RKRBackend::this_pointer->startOutputCapture ();	// HACK: No capture active, but commandFinished() will try to end one
 				RKRBackend::this_pointer->commandFinished ();
 			} else if (RKRBackend::repl_status.user_command_status == RKRBackend::RKReplStatus::UserCommandRunning) {
 				// This can mean three different things:
@@ -838,7 +838,11 @@ RKRBackend::~RKRBackend () {
 	RK_TRACE (RBACKEND);
 }
 
+#ifdef _MSC_VER
+extern "C" int R_interrupts_pending;
+#else
 LibExtern int R_interrupts_pending;
+#endif
 SEXP doError (SEXP call) {
 	RK_TRACE (RBACKEND);
 
diff --git a/rkward/rbackend/rkreventloop.cpp b/rkward/rbackend/rkreventloop.cpp
index cf81787..7723d00 100644
--- a/rkward/rbackend/rkreventloop.cpp
+++ b/rkward/rbackend/rkreventloop.cpp
@@ -67,10 +67,10 @@ void RKREventLoop::processX11Events() {
 	if (!RKRBackend::this_pointer->r_running) return;
 	if (RKRBackend::this_pointer->isKilled ()) return;
 
-	RKRBackend::RKRBackend::repl_status.eval_depth++;
+	RKRBackend::repl_status.eval_depth++;
 // In case an error (or user interrupt) is caught inside processX11EventsWorker, we don't want to long-jump out.
 	R_ToplevelExec (processX11EventsWorker, 0);
-	RKRBackend::RKRBackend::repl_status.eval_depth--;
+	RKRBackend::repl_status.eval_depth--;
 }
 
 static void (* RK_eventHandlerFunction)() = 0;
diff --git a/rkward/rbackend/rkstructuregetter.h b/rkward/rbackend/rkstructuregetter.h
index 77e0ce9..6743745 100644
--- a/rkward/rbackend/rkstructuregetter.h
+++ b/rkward/rbackend/rkstructuregetter.h
@@ -18,10 +18,11 @@
 #ifndef RKSTRUCTUREGETTER_H
 #define RKSTRUCTUREGETTER_H
 
-#include <Rinternals.h>
-
 #include <QString>
 
+#define R_NO_REMAP 1
+#include <Rinternals.h>
+
 class RData;
 
 /** Low level helper class for getting the structure of R objects (.rk.get.structure). */
diff --git a/rkward/rkward_startup_wrapper.cpp b/rkward/rkward_startup_wrapper.cpp
index f3c5071..069c05c 100644
--- a/rkward/rkward_startup_wrapper.cpp
+++ b/rkward/rkward_startup_wrapper.cpp
@@ -63,13 +63,13 @@ QString quoteCommand (const QString &orig) {
 #ifdef Q_OS_WIN
 // Get short path name as a safe way to pass all sort of commands on the Windows shell
 // credits to http://erasmusjam.wordpress.com/2012/10/01/get-8-3-windows-short-path-names-in-a-qt-application/
-	wchar_t input[orig.size()+1];
-	orig.toWCharArray (input);
-	input[orig.size ()] = L'\0'; // terminate string
-	long length = GetShortPathName (input, NULL, 0);
-	wchar_t output[length];
-	GetShortPathName (input, output, length);
-	return QString::fromWCharArray (output, length-1);
+	QByteArray input (sizeof (wchar_t) * (orig.size()+1), '\0');
+	// wchar_t input[orig.size()+1]; -- No: MSVC (2013) does not support variable length arrays. Oh dear...
+	orig.toWCharArray ((wchar_t*) input.data ());
+	long length = GetShortPathName ((wchar_t*) input.data (), NULL, 0);
+	QByteArray output (sizeof (wchar_t) * (length), '\0');
+	GetShortPathName ((wchar_t*) input.data (), (wchar_t*) output.data (), length);
+	return QString::fromWCharArray ((wchar_t*) output.data (), length-1);
 #else
 	return orig;
 #endif



More information about the rkward-tracker mailing list