ExternalArray-class: Classes for representing referencs to native C/C++ arrays

ExternalArray-classR Documentation

Classes for representing referencs to native C/C++ arrays

Description

These classes and methods provide the foundation for working with native arrays in C/C++ code as if they were vectors, matrices and arrays in R. The idea is that we have the address of or a reference to the native object and we have information about the dimensions of that object. We then create an R object that has that information and with this, we can access individual elements or collections of elements, and assign values from R to elements of the native array.

Instances of these classes can be used without knowing the dimensions of the native arrays. In this case, the R programmer/user has to ensure that the indices are appropriate. Errors in this can cause R to crash.

Objects from the Class

Objects can be created by calls of the form new("ExternalArray", ...). Typically, such objects will be created in programmatically generated code that provides an interface between R and existing native C/C++ code. Sometimes, we will have an external pointer object in R that we know refers to a native array and then we can create an instance of ExternalArray in R using that reference. But this is less robust as the user must ensure that the dimensions are correct. This should be computed from the native code.

Slots

elementSize:

Object of class "integer" the size of each element in bytes

ref:

Object of class "externalptr" the address of the native object

classes:

Object of class "character" a collection of class names for this object, typically corresponding to the native type.

Extends

Class "RC++Reference", directly.

Methods

No methods defined with class "ExternalArray" in the signature.

Author(s)

Duncan Temple Lang

Examples

showClass("ExternalArray")

omegahat/RAutoGenRunTime documentation built on Jan. 12, 2023, 9:19 p.m.