Discussion:
[Swig-devel] Facing issue while executing interface file using swig TCL which has Rinside.h
Harika Parakala
2017-04-19 01:42:25 UTC
Permalink
Hello Team,

Below are the commands I have used to execute interface file

C:\swigwin-3.0.12\Examples\r\Z>swig -c++ -tcl Rinside.i
Rinside.h(69) : Warning 325: Nested class not currently supported (Proxy
ignored)
Rinside.h(90) : Warning 503: Can't wrap 'operator []' unless renamed to a
valid identifier.
My interface file is as below

%module Rinside
%{
/* Includes the header in the wrapper code */
#include "Rinside.h"
%}
/* Parse the header file to generate wrappers */
%include "Rinside.h"
My Rinside.h file is as below

#ifndef RINSIDE_RINSIDE_H
#define RINSIDE_RINSIDE_H
#include <RInsideCommon.h>
class RInside {
private:
MemBuf mb_m;
Rcpp::Environment* global_env_m;

bool verbose_m; // switch toggled by constructor,
or setter
bool interactive_m; // switch set by constructor only

void init_tempdir(void);
void init_rand(void);
void autoloads(void);

void initialize(const int argc, const char* const argv[],
const bool loadRcpp, const bool verbose, const bool
interactive);

static RInside* instance_m ;

#ifdef RINSIDE_CALLBACKS
Callbacks* callbacks ;
friend void RInside_ShowMessage( const char* message);
friend void RInside_WriteConsoleEx( const char* message, int len, int oType
);
friend int RInside_ReadConsole(const char *prompt, unsigned char *buf, int
len, int addtohistory);
friend void RInside_ResetConsole();
friend void RInside_FlushConsole();
friend void RInside_ClearerrConsole();
friend void RInside_Busy(int which);
#endif
public: **// Nested class error--- Need to fix this**
class Proxy {
public:
Proxy(SEXP xx): x(xx) { };

template <typename T>
operator T() {
return ::Rcpp::as<T>(x);
}
private:
Rcpp::RObject x;
};

int parseEval(const std::string &line, SEXP &ans); // parse line, return
in ans; error code rc
void parseEvalQ(const std::string &line); // parse line, no
return (throws on error)
void parseEvalQNT(const std::string &line); // parse line, no
return (no throw)
Proxy parseEval(const std::string &line); // parse line, return
SEXP (throws on error)
Proxy parseEvalNT(const std::string &line); // parse line, return
SEXP (no throw)

template <typename T>
void assign(const T& object, const std::string& nam) {
global_env_m->assign( nam, object ) ;
}

RInside() ;
RInside(const int argc, const char* const argv[],
const bool loadRcpp=true, // overridden in code,
cannot be set to false
const bool verbose=false, const bool interactive=false);
~RInside();

void setVerbose(const bool verbose) { verbose_m = verbose; }

Rcpp::Environment::Binding operator[]( const std::string& name );

static RInside& instance();
static RInside* instancePtr();

#ifdef RINSIDE_CALLBACKS
void set_callbacks(Callbacks* callbacks_) ;
void repl() ;
#endif

};

#endif
My Cpp Program which I want to compile is as below

#include <RInside.h>
int main(int argc, char *argv[]) {
RInside R(argc, argv); // create an embedded R instance

std::string txt = "Hello, world!\n";// assign a standard C++ string to 'txt'
R["txt"] = txt; // assign string var to R variable 'txt'

std::string evalstr = "cat(txt)";
for (int i=0; i<1e1; i++) {
R.parseEvalQ(evalstr); // eval the init string, ignoring any
returns
}
evalstr = "txt <- \"foo\\n\"";
for (int i=0; i<1e1; i++) {
R.parseEvalQ(evalstr); // eval the init string, ignoring any
returns
}
evalstr = "cat(txt)";
for (int i=0; i<1e1; i++) {
R.parseEvalQ(evalstr); // eval the init string, ignoring any
returns
}
exit(0);
}
I want to fix the warnings since the wrapper is used in creating the shared
library for dll file creation. I need to fix the nested class for sure to
be used in the downstream I mean. Can Some one please help me with writing
the interface file so that the above two warnings can ignored.



Thanks,
Harika

Loading...