R/onLoad.R

Defines functions .onLoad getTypeDefs

getTypeDefs =
function()
{
   types = .Call("R_getTypeDefinitions")
   names(types) = c("Void", "Label", "Float", "Double", "Int1", "Int8", "Int16", 
                     "Int32", "Int64", "FloatPtr", "DoublePtr", "Int32Ptr", "String")

      # Make the Type objects, not externalptr objects. Thanks to Christoph Klein (doktorschiwago)
      # for suggesting this.
   mapply(function(x, klass) new(klass, ref = x), types, c(rep("Type", length(types) - 1), "StringType"))
}

.onLoad =
function(...)
{
 if(getOption("Rllvm.autoInitialize", TRUE))
     InitializeNativeTarget()
    
  e = getNamespace("Rllvm")
  types = getTypeDefs()
 
  mapply(utils::assignInNamespace,
         paste(names(types), "Type", sep = ""),
         types, 
         MoreArgs = list(ns = e))

# The StructType class isn't available yet at this stage in loading the package.
#typeClass = getClass("StructType", .Force = TRUE, where = e)
#typeClass = getClass("PointerType", .Force = TRUE, where = e)
  tmp = makeSEXPTypes(rawPointer = TRUE)
  mapply(utils::assignInNamespace,
          c("SEXPType", sprintf("%sSXPType", names(tmp)[-1])),
          tmp, MoreArgs = list(ns = e))
}
duncantl/Rllvm documentation built on Nov. 23, 2023, 4:24 p.m.