R - SF #3168676 Fix %rename not working for member variables and methods. Add new simple rename testcase with runtime tests for C# and R

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12432 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2011-02-04 23:42:06 +00:00
commit f4c74bc500
6 changed files with 79 additions and 1 deletions

View file

@ -287,6 +287,7 @@ CPP_TEST_CASES += \
rename3 \
rename4 \
rename_scope \
rename_simple \
rename_strip_encoder \
rename_pcre_encoder \
rename_pcre_enum \

View file

@ -0,0 +1,30 @@
using System;
using rename_simpleNamespace;
public class rename_simple_runme {
public static void Main() {
NewStruct s = new NewStruct();
check(111, s.NewInstanceVariable, "NewInstanceVariable");
check(222, s.NewInstanceMethod(), "NewInstanceMethod");
check(333, NewStruct.NewStaticMethod(), "NewStaticMethod");
check(444, NewStruct.NewStaticVariable, "NewStaticVariable");
check(555, rename_simple.NewFunction(), "NewFunction");
check(666, rename_simple.NewGlobalVariable, "NewGlobalVariable");
s.NewInstanceVariable = 1111;
NewStruct.NewStaticVariable = 4444;
rename_simple.NewGlobalVariable = 6666;
check(1111, s.NewInstanceVariable, "NewInstanceVariable");
check(4444, NewStruct.NewStaticVariable, "NewStaticVariable");
check(6666, rename_simple.NewGlobalVariable, "NewGlobalVariable");
}
public static void check(int expected, int actual, string msg) {
if (expected != actual)
throw new Exception("Failed: Expected: " + expected + " actual: " + actual + " " + msg);
}
}

View file

@ -0,0 +1,20 @@
source("unittest.R")
dyn.load(paste("rename_simple", .Platform$dynlib.ext, sep=""))
source("rename_simple.R")
cacheMetaData(1)
s <- NewStruct();
unittest(111, s$NewInstanceVariable)
unittest(222, s$NewInstanceMethod())
unittest(333, NewStruct_NewStaticMethod())
unittest(444, NewStruct_NewStaticVariable())
unittest(555, NewFunction())
unittest(666, NewGlobalVariable())
s$NewInstanceVariable <- 1111
NewStruct_NewStaticVariable(4444)
NewGlobalVariable(6666)
unittest(1111, s$NewInstanceVariable)
unittest(4444, NewStruct_NewStaticVariable())
unittest(6666, NewGlobalVariable())

View file

@ -0,0 +1,24 @@
%module rename_simple
%rename(NewStruct) OldStruct;
%rename(NewVariable) OldVariable;
%rename(NewInstanceMethod) OldInstanceMethod;
%rename(NewInstanceVariable) OldInstanceVariable;
%rename(NewStaticMethod) OldStaticMethod;
%rename(NewStaticVariable) OldStaticVariable;
%rename(NewFunction) OldFunction;
%rename(NewGlobalVariable) OldGlobalVariable;
%inline %{
struct OldStruct {
OldStruct() : OldInstanceVariable(111) {}
int OldInstanceVariable;
int OldInstanceMethod() { return 222; }
static int OldStaticVariable;
static int OldStaticMethod() { return 333; }
};
int OldStruct::OldStaticVariable = 444;
int OldFunction() { return 555; }
int OldGlobalVariable = 666;
%}