Mercurial > pub > dyncall > bindings
comparison R/rdc/R/bind.R @ 0:0cfcc391201f
initial from svn dyncall-1745
author | Daniel Adler |
---|---|
date | Thu, 19 Mar 2015 22:26:28 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:0cfcc391201f |
---|---|
1 # | |
2 # bind library by import string | |
3 # | |
4 | |
5 eatws <- function(x) gsub("[ \n\t]*","",x) | |
6 | |
7 bind1 <- function(symbol, signature, libh, callvm, envir=parent.frame() ) | |
8 { | |
9 funcptr <- rdcFind(libh, symbol) | |
10 f <- function(...) NULL | |
11 body(f) <- substitute( dcCall( callvm, funcptr, signature, ... ), list(funcptr=funcptr, signature=signature) ) | |
12 assign( symbol, f, envir=envir ) | |
13 } | |
14 | |
15 rdcBind <- function(libname, sigs, callvm, envir=parent.frame() ) | |
16 { | |
17 libh <- rdcLoad(libname) | |
18 sigs <- eatws(sigs) | |
19 sigs <- strsplit(sigs, ";")[[1]] | |
20 sigs <- strsplit(sigs, "\\(") | |
21 for (i in seq(along=sigs)) bind1(sigs[[i]][[1]], sigs[[i]][[2]], libh, callvm, envir ) | |
22 } |