From ae886067fcd6929ef546eb37bbb6a0e58465132d Mon Sep 17 00:00:00 2001
From: Florian Angerer <florian.angerer@oracle.com>
Date: Wed, 12 Jul 2017 11:22:02 +0200
Subject: [PATCH] Replaced 'R_PreserveObject' by CPP macro assigning to its
 parameter.

---
 com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c       | 2 +-
 .../fficall/src/truffle_llvm/Rinternals.c                      | 2 +-
 .../fficall/src/truffle_nfi/Rinternals.c                       | 2 +-
 com.oracle.truffle.r.native/version.source                     | 2 +-
 mx.fastr/mx_fastr_edinclude.py                                 | 3 ++-
 5 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c b/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c
index 8afd991bc4..710affdd15 100644
--- a/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c
+++ b/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c
@@ -1562,7 +1562,7 @@ int R_check_class_etc (SEXP x, const char **valid) {
 	return R_check_class_etc_helper(x, valid, jniGetMethodsNamespace);
 }
 
-SEXP R_PreserveObject(SEXP x) {
+SEXP R_PreserveObject_FASTR(SEXP x) {
 	// convert to a JNI global ref until explicitly released
 	return createGlobalRef(getEnv(), x, 0);
 }
diff --git a/com.oracle.truffle.r.native/fficall/src/truffle_llvm/Rinternals.c b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/Rinternals.c
index 473de0261a..6d04555401 100644
--- a/com.oracle.truffle.r.native/fficall/src/truffle_llvm/Rinternals.c
+++ b/com.oracle.truffle.r.native/fficall/src/truffle_llvm/Rinternals.c
@@ -1085,7 +1085,7 @@ int R_check_class_etc (SEXP x, const char **valid) {
 	return (int) unimplemented("R_check_class_etc");
 }
 
-SEXP R_PreserveObject(SEXP x) {
+SEXP R_PreserveObject_FASTR(SEXP x) {
 	return unimplemented("R_PreserveObject");
 }
 
diff --git a/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Rinternals.c b/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Rinternals.c
index 6b5569d297..05e517b201 100644
--- a/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Rinternals.c
+++ b/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Rinternals.c
@@ -1168,7 +1168,7 @@ int R_check_class_etc (SEXP x, const char **valid) {
 	return R_check_class_etc_helper(x, valid, nfiGetMethodsNamespace);
 }
 
-SEXP R_PreserveObject(SEXP x) {
+SEXP R_PreserveObject_FASTR(SEXP x) {
     TruffleEnv* env = (*truffleContext)->getTruffleEnv(truffleContext);
 	return (*env)->newObjectRef(env, x);
 }
diff --git a/com.oracle.truffle.r.native/version.source b/com.oracle.truffle.r.native/version.source
index 9902f17848..f04c001f3f 100644
--- a/com.oracle.truffle.r.native/version.source
+++ b/com.oracle.truffle.r.native/version.source
@@ -1 +1 @@
-28
+29
diff --git a/mx.fastr/mx_fastr_edinclude.py b/mx.fastr/mx_fastr_edinclude.py
index bed40f5912..1ca1490bc0 100644
--- a/mx.fastr/mx_fastr_edinclude.py
+++ b/mx.fastr/mx_fastr_edinclude.py
@@ -84,7 +84,8 @@ use_internals_end = '''#endif
 
 '''
 preserveObject = '''#ifdef FASTR
-SEXP R_PreserveObject(SEXP);
+SEXP R_PreserveObject_FASTR(SEXP);
+#define R_PreserveObject(var) ((var) = R_PreserveObject_FASTR((var)))
 #else
 '''
 
-- 
GitLab