Last active
September 22, 2019 23:44
-
-
Save Non-Contradiction/bb13480fc5f283976bca9e8f03957a63 to your computer and use it in GitHub Desktop.
package wrap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
julia_function <- function(func_name, pkg_name = "Main", | |
env = emptyenv()){ | |
fname <- paste0(pkg_name, ".", func_name) | |
force(fname) | |
f <- function(..., | |
need_return = c("R", "Julia", "None"), | |
show_value = FALSE){ | |
if (!isTRUE(env$initialized)) { | |
env$setup() | |
} | |
JuliaCall::julia_do.call(func_name = fname, list(...), | |
need_return = match.arg(need_return), | |
show_value = show_value) | |
} | |
force(f) | |
env[[func_name]] <- f | |
} | |
julia_pkg_import <- function(pkg_name, func_list){ | |
env <- new.env(parent = emptyenv()) | |
env$setup <- function(...){ | |
JuliaCall::julia_setup(...) | |
JuliaCall::julia_library(pkg_name) | |
env$initialized <- TRUE | |
} | |
for (fname in func_list) { | |
julia_function(func_name = fname, | |
pkg_name = pkg_name, | |
env = env) | |
} | |
env | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment