Polymorphism in R wrappers fixed for C++ structs
This commit is contained in:
parent
cfd2557cda
commit
1d73341aa4
10 changed files with 68 additions and 8 deletions
|
|
@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
||||||
Version 4.1.0 (in progress)
|
Version 4.1.0 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2022-10-24: wsfulton
|
||||||
|
[R] Polymorphism in the wrappers was only working for C++ classes,
|
||||||
|
now this works for C++ structs too.
|
||||||
|
|
||||||
2022-10-19: olly
|
2022-10-19: olly
|
||||||
[Lua] #2126 Fix type resolution between multiple SWIG-wrapped
|
[Lua] #2126 Fix type resolution between multiple SWIG-wrapped
|
||||||
modules.
|
modules.
|
||||||
|
|
|
||||||
|
|
@ -28,4 +28,9 @@ func main() {
|
||||||
if x != "Grok::blah" {
|
if x != "Grok::blah" {
|
||||||
panic(x)
|
panic(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
x = d.Far()
|
||||||
|
if x != "Spam::far" {
|
||||||
|
panic(x)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,3 +21,7 @@ if (x != "Spam::blah")
|
||||||
x = typedef_inherit.do_blah2(d);
|
x = typedef_inherit.do_blah2(d);
|
||||||
if (x != "Grok::blah")
|
if (x != "Grok::blah")
|
||||||
print ("Whoa! Bad return" + x);
|
print ("Whoa! Bad return" + x);
|
||||||
|
|
||||||
|
x = d.far();
|
||||||
|
if (x != "Spam::far")
|
||||||
|
print ("Whoa! Bad return" + x);
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,6 @@ let _ =
|
||||||
assert (_do_blah (b) as string = "Bar::blah");
|
assert (_do_blah (b) as string = "Bar::blah");
|
||||||
let c = new_Spam '() and d = new_Grok '() in
|
let c = new_Spam '() and d = new_Grok '() in
|
||||||
assert (_do_blah2 (c) as string = "Spam::blah");
|
assert (_do_blah2 (c) as string = "Spam::blah");
|
||||||
assert (_do_blah2 (d) as string = "Grok::blah")
|
assert (_do_blah2 (d) as string = "Grok::blah");
|
||||||
|
assert (d -> far() as string = "Spam::far")
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
|
|
@ -30,3 +30,8 @@ x = typedef_inherit.do_blah2(d);
|
||||||
if (!strcmp(x,"Grok::blah"))
|
if (!strcmp(x,"Grok::blah"))
|
||||||
error("Whoa! Bad return", x)
|
error("Whoa! Bad return", x)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
x = d.far();
|
||||||
|
if (!strcmp(x,"Spam::far"))
|
||||||
|
error("Whoa! Bad return", x)
|
||||||
|
endif
|
||||||
|
|
|
||||||
|
|
@ -21,3 +21,7 @@ if x != "Spam::blah":
|
||||||
x = typedef_inherit.do_blah2(d)
|
x = typedef_inherit.do_blah2(d)
|
||||||
if x != "Grok::blah":
|
if x != "Grok::blah":
|
||||||
raise RuntimeError("Whoa! Bad return {}".format(x))
|
raise RuntimeError("Whoa! Bad return {}".format(x))
|
||||||
|
|
||||||
|
x = d.far()
|
||||||
|
if x != "Spam::far":
|
||||||
|
raise RuntimeError("Whoa! Bad return {}".format(x))
|
||||||
|
|
|
||||||
29
Examples/test-suite/r/typedef_inherit_runme.R
Normal file
29
Examples/test-suite/r/typedef_inherit_runme.R
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
clargs <- commandArgs(trailing=TRUE)
|
||||||
|
source(file.path(clargs[1], "unittest.R"))
|
||||||
|
|
||||||
|
dyn.load(paste("typedef_inherit", .Platform$dynlib.ext, sep=""))
|
||||||
|
source("typedef_inherit.R")
|
||||||
|
cacheMetaData(1)
|
||||||
|
|
||||||
|
|
||||||
|
a <- Foo()
|
||||||
|
b <- Bar()
|
||||||
|
|
||||||
|
x <- do_blah(a)
|
||||||
|
unittest(x, "Foo::blah")
|
||||||
|
|
||||||
|
x <- do_blah(b)
|
||||||
|
unittest(x, "Bar::blah")
|
||||||
|
|
||||||
|
c <- Spam()
|
||||||
|
d <- Grok()
|
||||||
|
|
||||||
|
x <- do_blah2(c)
|
||||||
|
unittest(x, "Spam::blah")
|
||||||
|
|
||||||
|
x <- do_blah2(d)
|
||||||
|
unittest(x, "Grok::blah")
|
||||||
|
|
||||||
|
unittest(d$far(), "Spam::far")
|
||||||
|
|
||||||
|
q(save="no")
|
||||||
|
|
@ -36,3 +36,9 @@ x = Typedef_inherit.do_blah2(d)
|
||||||
if x != "Grok::blah"
|
if x != "Grok::blah"
|
||||||
puts "Whoa! Bad return #{x}"
|
puts "Whoa! Bad return #{x}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
x = d.far
|
||||||
|
if x != "Spam::far"
|
||||||
|
puts "Whoa! Bad return #{x}"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,13 @@ typedef struct spam {
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual char *blah() {
|
virtual char *blah() {
|
||||||
return (char *) "Spam::blah";
|
return (char *) "Spam::blah";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *far() {
|
||||||
|
return "Spam::far";
|
||||||
|
}
|
||||||
} Spam;
|
} Spam;
|
||||||
|
|
||||||
struct Grok : public Spam {
|
struct Grok : public Spam {
|
||||||
|
|
|
||||||
|
|
@ -215,8 +215,7 @@ public:
|
||||||
|
|
||||||
int typedefHandler(Node *n);
|
int typedefHandler(Node *n);
|
||||||
|
|
||||||
static List *Swig_overload_rank(Node *n,
|
static List *Swig_overload_rank(Node *n, bool script_lang_wrapping);
|
||||||
bool script_lang_wrapping);
|
|
||||||
|
|
||||||
int memberfunctionHandler(Node *n) {
|
int memberfunctionHandler(Node *n) {
|
||||||
if (debugMode)
|
if (debugMode)
|
||||||
|
|
@ -2295,7 +2294,6 @@ int R::outputRegistrationRoutines(File *out) {
|
||||||
|
|
||||||
void R::registerClass(Node *n) {
|
void R::registerClass(Node *n) {
|
||||||
String *name = Getattr(n, "name");
|
String *name = Getattr(n, "name");
|
||||||
String *kind = Getattr(n, "kind");
|
|
||||||
|
|
||||||
if (debugMode)
|
if (debugMode)
|
||||||
Swig_print_node(n);
|
Swig_print_node(n);
|
||||||
|
|
@ -2304,7 +2302,7 @@ void R::registerClass(Node *n) {
|
||||||
Setattr(SClassDefs, sname, sname);
|
Setattr(SClassDefs, sname, sname);
|
||||||
String *base;
|
String *base;
|
||||||
|
|
||||||
if(Strcmp(kind, "class") == 0) {
|
if (CPlusPlus && (Strcmp(nodeType(n), "class") == 0)) {
|
||||||
base = NewString("");
|
base = NewString("");
|
||||||
List *l = Getattr(n, "bases");
|
List *l = Getattr(n, "bases");
|
||||||
if(Len(l)) {
|
if(Len(l)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue