createCOMSClass: Generate S class mirroring COM class

View source: R/autoInterface.S

createCOMSClassR Documentation

Generate S class mirroring COM class

Description

This generates a simple S class that provides structured access to a corresponding COM class. This function is used to “compile” COM classes for S. Using the type information for the COM class, we generate methods for the $ and $<- operators which provide controlled and efficient access to COM objects of this class. These methods have information about the properties and methods of the COM class and can detect errors on the client side of the interface before making calls to the COM server. Additionally, the operators use the name-identifier mappings from the type information to avoid an extra round-trip for each .COM call. Also, the operators know which elements of the COM class are properties and which are methods and so one can use the $ operator to access both types of elements rather than using [[ for properties and $ for methods.

This defines a new S4 class that is a simple extension of the COMIDispatch-class class in the RDCOMClient package. The new class is used primarily to support methods that know the specific details of the COM class. Objects of this new class can be created manually or implicitly in the RDCOMClient conversion mechanism that creates COM objects from C++ IDispatch objects. In the latter case, the createCOMReference function must be able to map the UUID of the COM object to an S4 class name that extends COMIDispatch-class. This createCOMSClass function writes this information into the global character vector .COMSClassMap.

Usage

createCOMSClass(libEntry, className, where = NULL)

Arguments

libEntry

the ITypeInfo-class object describing the COM class.

className

the name to use for the new S class that is created

where

unused at present.

Value

The name of the new S4 class.

Author(s)

Duncan Temple Lang <duncan@wald.ucdavis.edu>

References

http://msdn.microsoft.com/library http://www.omegahat.org/SWinTypeLibs

See Also

computeFunctionInformation generateOperators getTypeInfo LoadTypeLib createCOMReference

Examples

## Not run: 
lib = LoadTypeLib("C:\\Program Files\\Microsoft Office\\Office\\EXCEL9.OLB")
createCOMSClass(lib[["_Application"]], "ExcelApplication")

 library(RDCOMClient)
 e = COMCreate("Excel.Application")
 e = as(e, "ExcelApplication")
 e$Visible
 e$Visible = TRUE
 e$Workbooks$Add()
 e$CheckSpelling("Is this okey?")

## End(Not run)

omegahat/SWinTypeLibs documentation built on Jan. 17, 2024, 6:40 p.m.