Skip to content
Snippets Groups Projects
Commit 6ac671cb authored by Tomas Stupka's avatar Tomas Stupka
Browse files

adjusted to changes in .fastr.interop builtin names

parent ee32e015
No related branches found
No related tags found
No related merge requests found
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
.jnew <- function (class, ..., check = TRUE, silent = !check) .jnew <- function (class, ..., check = TRUE, silent = !check)
{ {
class <- gsub("/", ".", as.character(class)) class <- gsub("/", ".", as.character(class))
co <- .fastr.java.class(class) co <- new.java.class(class)
o <- .fastr.interop.new(co, ...) o <- new.external(co, ...)
invisible(o) invisible(o)
} }
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
{ {
if(is.character(obj)) { if(is.character(obj)) {
obj <- gsub("/", ".", as.character(obj)) obj <- gsub("/", ".", as.character(obj))
co <- .fastr.java.class(obj) co <- new.java.class(obj)
r <- co[method](...) r <- co[method](...)
} else { } else {
r <- obj[method](...) r <- obj[method](...)
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
.jfield <- function (obj, sig = NULL, name, true.class = is.null(sig), convert = TRUE) .jfield <- function (obj, sig = NULL, name, true.class = is.null(sig), convert = TRUE)
{ {
if(is.character(obj)) { if(is.character(obj)) {
co <- .fastr.java.class(obj) co <- new.java.class(obj)
r <- co[name] r <- co[name]
} else { } else {
r <- obj[name] r <- obj[name]
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
#' @export #' @export
.jarray <- function (x, contents.class = NULL, dispatch = FALSE) .jarray <- function (x, contents.class = NULL, dispatch = FALSE)
{ {
.fastr.java.toArray(x, ,TRUE) as.java.array(x, ,TRUE)
} }
#' @export #' @export
...@@ -60,35 +60,35 @@ ...@@ -60,35 +60,35 @@
#' @export #' @export
.jbyte <- function (x) .jbyte <- function (x)
{ {
x <- .fastr.interop.toByte(x) x <- as.external.byte(x)
invisible(x) invisible(x)
} }
#' @export #' @export
.jchar <- function (x) .jchar <- function (x)
{ {
x <- .fastr.interop.toChar(x) x <- as.external.char(x)
invisible(x) invisible(x)
} }
#' @export #' @export
.jshort <- function (x) .jshort <- function (x)
{ {
x <- .fastr.interop.toShort(x) x <- as.external.short(x)
invisible(x) invisible(x)
} }
#' @export #' @export
.jlong <- function (x) .jlong <- function (x)
{ {
x <- .fastr.interop.toLong(x) x <- as.external.long(x)
invisible(x) invisible(x)
} }
#' @export #' @export
.jfloat <- function (x) .jfloat <- function (x)
{ {
x <- .fastr.interop.toFloat(x) x <- as.external.float(x)
invisible(x) invisible(x)
} }
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
J <- function (class, method, ...) J <- function (class, method, ...)
{ {
class <- gsub("/", ".", as.character(class)) class <- gsub("/", ".", as.character(class))
javaClass <- .fastr.java.class(class) javaClass <- new.java.class(class)
if (nargs() == 1L && missing(method)) { if (nargs() == 1L && missing(method)) {
javaClass javaClass
} else { } else {
......
...@@ -11,27 +11,27 @@ test_that(testName, { ...@@ -11,27 +11,27 @@ test_that(testName, {
cat(paste0(testName, "\n")) cat(paste0(testName, "\n"))
a <- .jarray(c(1.1, 2.1, 3.1)) a <- .jarray(c(1.1, 2.1, 3.1))
expect_true(.fastr.interop.isArray(a)) expect_true(is.external.array(a))
expect_equal(length(a), 3) expect_equal(length(a), 3)
expect_equal(a[1], c(1.1)) expect_equal(a[1], c(1.1))
expect_equal(a[2], c(2.1)) expect_equal(a[2], c(2.1))
expect_equal(a[3], c(3.1)) expect_equal(a[3], c(3.1))
a <- .jarray(c(1L, 2L, 3L)) a <- .jarray(c(1L, 2L, 3L))
expect_true(.fastr.interop.isArray(a)) expect_true(is.external.array(a))
expect_equal(length(a), 3) expect_equal(length(a), 3)
expect_equal(a[1], c(1)) expect_equal(a[1], c(1))
expect_equal(a[2], c(2)) expect_equal(a[2], c(2))
expect_equal(a[3], c(3)) expect_equal(a[3], c(3))
a <- .jarray(c(TRUE, FALSE)) a <- .jarray(c(TRUE, FALSE))
expect_true(.fastr.interop.isArray(a)) expect_true(is.external.array(a))
expect_equal(length(a), 2) expect_equal(length(a), 2)
expect_equal(a[1], TRUE) expect_equal(a[1], TRUE)
expect_equal(a[2], FALSE) expect_equal(a[2], FALSE)
a <- .jarray(c(.jbyte(1), .jchar("a"), .jfloat(1.1), .jlong(2), .jshort(123))) a <- .jarray(c(.jbyte(1), .jchar("a"), .jfloat(1.1), .jlong(2), .jshort(123)))
expect_true(.fastr.interop.isArray(a)) expect_true(is.external.array(a))
expect_equal(length(a), 5) expect_equal(length(a), 5)
expect_equal(a[1], 1) expect_equal(a[1], 1)
expect_equal(a[2], "a") expect_equal(a[2], "a")
...@@ -41,21 +41,20 @@ test_that(testName, { ...@@ -41,21 +41,20 @@ test_that(testName, {
to <- .jnew('java.util.ArrayList') to <- .jnew('java.util.ArrayList')
a <- .jarray(to) a <- .jarray(to)
expect_true(.fastr.interop.isArray(a)) expect_true(is.external.array(a))
expect_equal(length(a), 1) expect_equal(length(a), 1)
# fails at the moment expect_equal(a[1], to)
# expect_equal(a[1], to)
to <- .jnew('java.util.ArrayList') to <- .jnew('java.util.ArrayList')
a <- .jarray(c(to, to)) a <- .jarray(c(to, to))
expect_true(.fastr.interop.isArray(a)) expect_true(is.external.array(a))
expect_equal(length(a), 2)
# fails at the moment # fails at the moment
# expect_equal(length(a), 2)
# expect_equal(a[1], to) # expect_equal(a[1], to)
# expect_equal(a[2], to) # expect_equal(a[2], to)
a <- .jarray(list(1, 2, 3)) a <- .jarray(list(1, 2, 3))
expect_true(.fastr.interop.isArray(a)) expect_true(is.external.array(a))
expect_equal(length(a), 3) expect_equal(length(a), 3)
expect_equal(a[1], 1) expect_equal(a[1], 1)
expect_equal(a[2], 2) expect_equal(a[2], 2)
...@@ -72,7 +71,7 @@ test_that(testName, { ...@@ -72,7 +71,7 @@ test_that(testName, {
Char=list("character", "a", "b", "c"), Char=list("character", "a", "b", "c"),
Double=list("double",1.1, 2.1, 3.1), Double=list("double",1.1, 2.1, 3.1),
Float=list("double", 1.1, 2.1, 3.1), Float=list("double", 1.1, 2.1, 3.1),
Int=list("integer",1,2,3), Integer=list("integer",1,2,3),
Long=list("double", 1,2,3), Long=list("double", 1,2,3),
Short=list("integer",1,2,3), Short=list("integer",1,2,3),
String=list("character", "a", "b", "c")) String=list("character", "a", "b", "c"))
...@@ -85,7 +84,7 @@ test_that(testName, { ...@@ -85,7 +84,7 @@ test_that(testName, {
arrayType <- ev[[1]] arrayType <- ev[[1]]
arrayLength <- length(ev) - 1 arrayLength <- length(ev) - 1
a<-t[fieldName] a<-t[fieldName]
expect_true(.fastr.interop.isArray(a), info=paste0("the array was returned for ", fieldName), label=".fastr.interop.isArray") expect_true(is.external.array(a), info=paste0("the array was returned for ", fieldName), label="is.external.array")
ae<-.jevalArray(a) ae<-.jevalArray(a)
expect_true(is.vector(ae), info=paste0("the array was returned for ", fieldName), label="is.vector") expect_true(is.vector(ae), info=paste0("the array was returned for ", fieldName), label="is.vector")
expect_equal(typeof(ae), arrayType, info=paste0("the array was returned for ", fieldName), label="typeof") expect_equal(typeof(ae), arrayType, info=paste0("the array was returned for ", fieldName), label="typeof")
......
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