File: fixNativeSymbol.R

package info (click to toggle)
r-cran-jsonlite 1.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,340 kB
  • sloc: ansic: 3,792; sh: 9; makefile: 6
file content (25 lines) | stat: -rw-r--r-- 784 bytes parent folder | download | duplicates (6)
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
fixNativeSymbol <- function(symbol) {
  if (is(symbol, "NativeSymbolInfo")) {
    # method depends on version
    rVersion <- getRversion()

    if (rVersion >= "3.0") {
      # in R 3.0 determine the dll that the symbol lives in
      name <- ifelse(is.null(symbol$package), symbol$dll[["name"]], symbol$package[["name"]])

      # load package if not yet loaded
      try(getNamespace(name))
      pkgDLL <- getLoadedDLLs()[[name]]

      # reconstruct the native symbol address
      newsymbol <- getNativeSymbolInfo(name = symbol$name, PACKAGE = pkgDLL,
        withRegistrationInfo = TRUE)
      symbol$address <- newsymbol$address
      return(symbol)
    } else if (rVersion >= "2.14") {
      return(getNativeSymbolInfo(symbol$name))
    }
  } else {
    return(symbol)
  }
}