File: getDynLib.R

package info (click to toggle)
r-cran-inline 0.3.6-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 148 kB
  • sloc: makefile: 1
file content (27 lines) | stat: -rw-r--r-- 614 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
setGeneric("getDynLib", function(x, ...) standardGeneric("getDynLib") )

setMethod( "getDynLib", signature( x = "character" ), 
function( x ){
	dlls <- getLoadedDLLs()
	if( x %in% names( dlls ) ){
		dlls[[ x ]]
	} else {
		stop( sprintf( "dll %s not loaded" ) )	
	}
} )

setMethod( "getDynLib", signature( x = "CFunc" ), 
function( x ){
	env <- environment( x@.Data )
	f <- get( "f", env )
	dlls <- getLoadedDLLs()
	dll <- if( ! f %in% names(dlls) ){
		dyn.load( get( "libLFile", env ) )
	} else{
		dlls[[ f ]]
	}
	dll
} )

setMethod( "getDynLib", signature( x = "CFuncList" ), function(x) getDynLib( x[[1L]] ) )