Skip to content
Snippets Groups Projects
Commit 5c612e48 authored by Lukas Stadler's avatar Lukas Stadler
Browse files

implement R_chk_free, vmaxget/set and DUPLICATE_ATTRIB

parent c2cf642c
No related branches found
No related tags found
No related merge requests found
......@@ -76,15 +76,24 @@ void *R_chk_realloc(void *p, size_t size) {
}
void R_chk_free(void *p) {
unimplemented("R_chk_free");
if(p) {
free(p);
}
}
int VMAX_MAGIC = 1234;
void* vmaxget(void) {
unimplemented("vmaxget");
// unimplemented("vmaxget");
// ignored
return &VMAX_MAGIC;
}
void vmaxset(const void * x) {
unimplemented("vmaxget");
// unimplemented("vmaxget");
if (x != &VMAX_MAGIC) {
unimplemented("vmaxset with different value");
}
}
void R_gc(void) {
......@@ -95,3 +104,4 @@ int R_gc_running() {
unimplemented("R_gc_running");
return 0;
}
......@@ -25,16 +25,18 @@
static jclass SEXPTYPEClass;
static jmethodID gnuRCodeForObjectMethodID;
static jmethodID NAMED_MethodID;
static jmethodID DUPLICATE_ATTRIB_MethodID;
void init_attrib(JNIEnv *env) {
SEXPTYPEClass = checkFindClass(env, "com/oracle/truffle/r/runtime/gnur/SEXPTYPE");
gnuRCodeForObjectMethodID = checkGetMethodID(env, SEXPTYPEClass, "gnuRCodeForObject", "(Ljava/lang/Object;)I", 1);
NAMED_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "NAMED", "(Ljava/lang/Object;)I", 1);
DUPLICATE_ATTRIB_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "DUPLICATE_ATTRIB", "(Ljava/lang/Object;Ljava/lang/Object;)V", 1);
}
int TYPEOF(SEXP x) {
JNIEnv *thisenv = getEnv();
return (*thisenv)->CallStaticIntMethod(thisenv, SEXPTYPEClass, gnuRCodeForObjectMethodID, x);
JNIEnv *thisenv = getEnv();
return (*thisenv)->CallStaticIntMethod(thisenv, SEXPTYPEClass, gnuRCodeForObjectMethodID, x);
}
SEXP ATTRIB(SEXP x){
......@@ -79,6 +81,7 @@ void SET_ATTRIB(SEXP x, SEXP v){
}
void DUPLICATE_ATTRIB(SEXP to, SEXP from){
unimplemented("DUPLICATE_ATTRIB");
JNIEnv *thisenv = getEnv();
(*thisenv)->CallStaticVoidMethod(thisenv, CallRFFIHelperClass, DUPLICATE_ATTRIB_MethodID, to, from);
}
......@@ -472,6 +472,15 @@ public class CallRFFIHelper {
}
}
static void DUPLICATE_ATTRIB(Object to, Object from) {
if (from instanceof RAttributable) {
guaranteeInstanceOf(to, RAttributable.class);
RAttributes attributes = ((RAttributable) from).getAttributes();
((RAttributable) to).initAttributes(attributes == null ? null : attributes.copy());
}
// TODO: copy OBJECT? and S4 attributes
}
// Checkstyle: resume method name check
static Object validate(Object x) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment