-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstage14.mm
38 lines (31 loc) · 886 Bytes
/
stage14.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#import "Stage14Wrapper.h"
#import "RInside.h"
#import <iostream>
struct Stage14WrapperImpl {
RInside wrapped;
};
@implementation Stage14Wrapper
- (id)init {
self = [super init];
if (self) {
impl = new Stage14WrapperImpl;
}
return self;
}
- (void)dealloc {
delete impl;
[super dealloc];
}
- (NSString*)blep:(NSString*)foo {
std::string rfoo([foo UTF8String], [foo lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
std::ostringstream stm;
std::cout << "Stage 14: " << rfoo << std::endl;
stm << "[Stage 14: " << rfoo << "]";
impl->wrapped.parseEvalQ("source(\"stage15.r\")");
Rcpp::Function rblep = impl->wrapped["blep"];
SEXP rrv = rblep(rfoo);
std::string rv = Rcpp::as<std::string>(rrv);
std::cout << "Return value [14]: " << rv << std::endl;
return [NSString stringWithUTF8String:rv.c_str()];
}
@end