[rkward-cvs] SF.net SVN: rkward: [2355] trunk/rkward/rkward/rbackend/rembedinternal.cpp
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Thu Apr 10 12:17:40 UTC 2008
Revision: 2355
http://rkward.svn.sourceforge.net/rkward/?rev=2355&view=rev
Author: tfry
Date: 2008-04-10 05:17:40 -0700 (Thu, 10 Apr 2008)
Log Message:
-----------
Adjust for R 2.7
Modified Paths:
--------------
trunk/rkward/rkward/rbackend/rembedinternal.cpp
Modified: trunk/rkward/rkward/rbackend/rembedinternal.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rembedinternal.cpp 2008-03-12 19:42:41 UTC (rev 2354)
+++ trunk/rkward/rkward/rbackend/rembedinternal.cpp 2008-04-10 12:17:40 UTC (rev 2355)
@@ -43,27 +43,7 @@
//#include <unistd.h>
#include <math.h>
-extern "C" {
-#define R_INTERFACE_PTRS 1
-
-// needed to detect CHARSXP encoding
-#define USE_RINTERNALS 1
-#define UTF8_MASK (1<<3)
-#define IS_UTF8(x) ((x)->sxpinfo.gp & UTF8_MASK)
-#define LATIN1_MASK (1<<2)
-#define IS_LATIN1(x) ((x)->sxpinfo.gp & LATIN1_MASK)
-// end
-
-#include "Rdefines.h"
-#include "R_ext/Rdynload.h"
-#include "R_ext/eventloop.h"
-#include "R_ext/Callbacks.h"
-#include "R.h"
-#include "Rinternals.h"
-#include "Rinterface.h"
-#include "Rdevices.h"
#include "Rversion.h"
-#include "R_ext/Parse.h"
#if (R_VERSION > R_Version(2, 2, 9))
#define R_2_3
@@ -81,6 +61,36 @@
#define R_2_6
#endif
+#if (R_VERSION > R_Version(2, 6, 9))
+#define R_2_7
+#endif
+
+extern "C" {
+#define R_INTERFACE_PTRS 1
+
+// needed to detect CHARSXP encoding
+#ifdef R_2_7
+# define IS_UTF8(x) (Rf_getCharCE(x) == CE_UTF8)
+# define IS_LATIN1(x) (Rf_getCharCE(x) == CE_LATIN1)
+#else
+# define USE_RINTERNALS 1
+# define UTF8_MASK (1<<3)
+# define IS_UTF8(x) ((x)->sxpinfo.gp & UTF8_MASK)
+# define LATIN1_MASK (1<<2)
+# define IS_LATIN1(x) ((x)->sxpinfo.gp & LATIN1_MASK)
+#endif
+// end
+
+#include "Rdefines.h"
+#include "R_ext/Rdynload.h"
+#include "R_ext/eventloop.h"
+#include "R_ext/Callbacks.h"
+#include "R.h"
+#include "Rinternals.h"
+#include "Rinterface.h"
+#include "Rdevices.h"
+#include "R_ext/Parse.h"
+
#ifdef R_2_4
#define USE_R_REPLDLLDO1
#endif
@@ -141,27 +151,39 @@
SEXP RKWard_RData_Tag;
// ############## R Standard callback overrides BEGIN ####################
+#ifdef R_2_7
+void RSuicide (const char* message) {
+#else
void RSuicide (char* message) {
+#endif
RK_TRACE (RBACKEND);
RCallbackArgs args;
args.type = RCallbackArgs::RSuicide;
- args.chars_a = &message;
+ args.chars_a = const_cast<char**>(&message);
REmbedInternal::this_pointer->handleStandardCallback (&args);
REmbedInternal::this_pointer->shutdown (true);
Rf_error ("Backend dead"); // this jumps us out of the REPL.
}
+#ifdef R_2_7
+void RShowMessage (const char* message) {
+#else
void RShowMessage (char* message) {
+#endif
RK_TRACE (RBACKEND);
RCallbackArgs args;
args.type = RCallbackArgs::RShowMessage;
- args.chars_a = &message;
+ args.chars_a = const_cast<char**>(&message);
REmbedInternal::this_pointer->handleStandardCallback (&args);
}
+#ifdef R_2_7
+int RReadConsole (const char* prompt, unsigned char* buf, int buflen, int hist) {
+#else
int RReadConsole (char* prompt, unsigned char* buf, int buflen, int hist) {
+#endif
RK_TRACE (RBACKEND);
#ifdef USE_R_REPLDLLDO1
@@ -191,7 +213,7 @@
// here, we handle readline calls and such, i.e. not the regular prompt for code
RCallbackArgs args;
args.type = RCallbackArgs::RReadConsole;
- args.chars_a = &prompt;
+ args.chars_a = const_cast<char**> (&prompt);
args.chars_b = (char **) (&buf);
args.int_a = buflen;
args.int_b = hist; // actually, we ignore hist
@@ -208,7 +230,11 @@
}
#ifdef R_2_5
+# ifdef R_2_7
+void RWriteConsoleEx (const char *buf, int buflen, int type) {
+# else
void RWriteConsoleEx (char *buf, int buflen, int type) {
+# endif
RK_TRACE (RBACKEND);
REmbedInternal::this_pointer->handleOutput (REmbedInternal::this_pointer->current_locale_codec->toUnicode (buf, buflen), buflen, type == 0);
@@ -268,16 +294,20 @@
Rf_error ("Backend dead"); // this jumps us out of the REPL.
}
+#ifdef R_2_7
+int RShowFiles (int nfile, const char **file, const char **headers, const char *wtitle, Rboolean del, const char *pager) {
+#else
int RShowFiles (int nfile, char **file, char **headers, char *wtitle, Rboolean del, char *pager) {
+#endif
RK_TRACE (RBACKEND);
RCallbackArgs args;
args.type = RCallbackArgs::RShowFiles;
args.int_a = nfile;
- args.chars_a = file;
- args.chars_b = headers; // what exactly are the "headers"?!?
- args.chars_c = &wtitle;
- args.chars_d = &pager; // we ingnore the pager-parameter for now.
+ args.chars_a = const_cast<char**> (file);
+ args.chars_b = const_cast<char**> (headers); // what exactly are the "headers"?!?
+ args.chars_c = const_cast<char**> (&wtitle);
+ args.chars_d = const_cast<char**> (&pager); // we ingnore the pager-parameter for now.
args.int_b = del;
REmbedInternal::this_pointer->handleStandardCallback (&args);
@@ -301,15 +331,15 @@
return args.int_c;
}
-int REditFiles (int nfile, char **file, char **title, char *editor) {
+int REditFiles (int nfile, const char **file, const char **title, const char *editor) {
RK_TRACE (RBACKEND);
RCallbackArgs args;
args.type = RCallbackArgs::REditFiles;
args.int_a = nfile;
- args.chars_a = file;
- args.chars_b = title;
- args.chars_c = &editor;
+ args.chars_a = const_cast<char**> (file);
+ args.chars_b = const_cast<char**> (title);
+ args.chars_c = const_cast<char**> (&editor);
REmbedInternal::this_pointer->handleStandardCallback (&args);
@@ -317,15 +347,18 @@
return (nfile <= 0);
}
+#ifdef R_2_7
+int REditFile (const char *buf) {
+#else
int REditFile (char *buf) {
+#endif
RK_TRACE (RBACKEND);
-// REditFiles (below) is takes non-const char** parameters, although it actually treats them as consts. TODO: fix this up, one day
- char *editor = (char *) "none";
- char *title = (char *) "";
+ const char *editor = "none";
+ const char *title = "";
// does not exist in standard R 2.1.0, so no idea what to return.
- return REditFiles (1, &buf, &title, editor);
+ return REditFiles (1, const_cast<const char**> (&buf), &title, editor);
}
#ifdef USE_R_REPLDLLDO1
@@ -421,7 +454,7 @@
#endif
/* close all the graphics devices */
- if (!suicidal) KillAllDevices ();
+ if (!suicidal) Rf_KillAllDevices ();
fpu_setup ((Rboolean) FALSE);
}
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