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:
parent
1918e2a844
commit
f4c74bc500
6 changed files with 79 additions and 1 deletions
|
|
@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
Version 2.0.2 (in progress)
|
Version 2.0.2 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2011-02-04: wsfulton
|
||||||
|
[R] SF #3168676 Fix %rename not working for member variables and methods.
|
||||||
|
|
||||||
2011-02-04: wsfulton
|
2011-02-04: wsfulton
|
||||||
[PHP] SF #3166423 Recent PHP versions no longer define zend_error_noreturn - calls to this
|
[PHP] SF #3166423 Recent PHP versions no longer define zend_error_noreturn - calls to this
|
||||||
have been replaced with zend_error.
|
have been replaced with zend_error.
|
||||||
|
|
|
||||||
|
|
@ -287,6 +287,7 @@ CPP_TEST_CASES += \
|
||||||
rename3 \
|
rename3 \
|
||||||
rename4 \
|
rename4 \
|
||||||
rename_scope \
|
rename_scope \
|
||||||
|
rename_simple \
|
||||||
rename_strip_encoder \
|
rename_strip_encoder \
|
||||||
rename_pcre_encoder \
|
rename_pcre_encoder \
|
||||||
rename_pcre_enum \
|
rename_pcre_enum \
|
||||||
|
|
|
||||||
30
Examples/test-suite/csharp/rename_simple_runme.cs
Normal file
30
Examples/test-suite/csharp/rename_simple_runme.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
20
Examples/test-suite/r/rename_simple_runme.R
Normal file
20
Examples/test-suite/r/rename_simple_runme.R
Normal 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())
|
||||||
24
Examples/test-suite/rename_simple.i
Normal file
24
Examples/test-suite/rename_simple.i
Normal 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;
|
||||||
|
%}
|
||||||
|
|
@ -300,7 +300,7 @@ public:
|
||||||
Printf(stderr, "<memberfunctionHandler> %s %s\n",
|
Printf(stderr, "<memberfunctionHandler> %s %s\n",
|
||||||
Getattr(n, "name"),
|
Getattr(n, "name"),
|
||||||
Getattr(n, "type"));
|
Getattr(n, "type"));
|
||||||
member_name = Getattr(n, "name");
|
member_name = Getattr(n, "sym:name");
|
||||||
processing_class_member_function = 1;
|
processing_class_member_function = 1;
|
||||||
int status = Language::memberfunctionHandler(n);
|
int status = Language::memberfunctionHandler(n);
|
||||||
processing_class_member_function = 0;
|
processing_class_member_function = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue