computeGlobalEnumConstants: Compute top-level enumeration definitions

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/constants.R

Description

This function processes the translation unit nodes and finds the enumeration definitions, i.e. the symbolic constants that are defined at the C/C++ level using the enum keyword. The result are named values of numerical values. In some cases, the enumeration collection has a name by way of a typedef. Additionally, some enumeration collections are simple "sequence" of values (some times not contiguous) which is used primarily to differentiate the values. It acts like a factor. In other cases, the values are intended to be OR'ed together in C to indicate one or more combined states. These are bitwise values. This function attempts to guess which type an enumeration definition falls into and returns the information in the appropriate class, i.e. EnumerationDefinition or BitwiseEnumerationDefinition.

The function then returns the collection of both named and anonymous enumeration collections which can be used to create corresponding variables for use in R.

Usage

1
2
3
computeGlobalEnumConstants(tu = NULL, enums = getEnumerations(tu, files),
                            files = character(),
                             defs = DefinitionContainer(tu), anonymousOnly = FALSE)

Arguments

tu

the translation unit nodes obtained from a call to parseTU

enums

the list of TU nodes that define the enumeration definitions of interest.

files

a character vector giving the names of the files in which the enumeration definitions of interest are located. This is used when calculating the default value of enums and is used to eliminate enumeration definitions for files such as system header files for which we do not want the definitions.

defs

a DefinitionContainer that is used for resolving the values of the different types and nodes with the TU.

anonymousOnly

a logical value indicating whether we only want the anonymous, i.e. not typedef'ed enumeration collection definitions.

Value

An object of class TopLevelEnumDefs. This is a list in which entry is an object of class EnumerationDefinition, with some being BitwiseEnumerationDefinition objects identifying bitwise enumerations.

Author(s)

Duncan Temple Lang

References

The GCC compiler suite

See Also

computeGlobalConstants

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
 tu = parseTU(system.file("examples", "distance.c.t00.tu", package = "RGCCTranslationUnit"))
 e = computeGlobalEnumConstants(tu)
 table(sapply(e, class))
 names(e)

 # the anonymous enums
 grep("^[.]", names(e), value = TRUE)

  # the named entries
 grep("^[^.]", names(e), value = TRUE)

omegahat/RGCCTranslationUnit documentation built on May 24, 2019, 1:53 p.m.