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
|
|
@ -28,4 +28,9 @@ func main() {
|
|||
if x != "Grok::blah" {
|
||||
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);
|
||||
if (x != "Grok::blah")
|
||||
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");
|
||||
let c = new_Spam '() and d = new_Grok '() in
|
||||
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"))
|
||||
error("Whoa! Bad return", x)
|
||||
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)
|
||||
if x != "Grok::blah":
|
||||
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"
|
||||
puts "Whoa! Bad return #{x}"
|
||||
end
|
||||
|
||||
x = d.far
|
||||
if x != "Spam::far"
|
||||
puts "Whoa! Bad return #{x}"
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -30,9 +30,13 @@ typedef struct spam {
|
|||
{
|
||||
}
|
||||
|
||||
virtual char *blah() {
|
||||
return (char *) "Spam::blah";
|
||||
}
|
||||
virtual char *blah() {
|
||||
return (char *) "Spam::blah";
|
||||
}
|
||||
|
||||
const char *far() {
|
||||
return "Spam::far";
|
||||
}
|
||||
} Spam;
|
||||
|
||||
struct Grok : public Spam {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue