# Class: com.pnfsoftware.jeb.core.units.code.asm.type.TypeUtil

Utility routines for native types.

## Static Field: CPP_PACKAGE_SEPARATOR
Type: `java.lang.String`

Constant value: `::`
Description: C\+\+ package separator.

## Static Field: CPP_TEMPLATE_REGEXP
Type: `java.util.regex.Pattern`
Description: C\+\+ template detection pattern.

## Static Field: TYPESOURCE_ALL
Type: `int`

Constant value: `3`
Description: Retrieve all available types.

## Static Field: TYPESOURCE_INUSE
Type: `int`

Constant value: `1`
Description: Retrieve types currently in use.

## Static Field: TYPESOURCE_TYPELIBS
Type: `int`

Constant value: `2`
Description: Retrieve types from loaded type libraries.

## Static Field: keywords
Type: `java.util.Set<java.lang.String>`
Description: Reserved native type keywords.

## Static Method: areBitfielTypesEquivalent
- parameter: `a`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- parameter: `b`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine if two bitfield types are equivalent.
parameter: a: first type
parameter: b: second type
return: true if equivalent

## Static Method: buildArrayType
- parameter: `typeman`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.ITypeManager`
- parameter: `lowestElementSignature`, type: `java.lang.String`
- parameter: `dimensions`, type: `int[]`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`

Description: Convenience routine to create an array type, possibly multi\-dimensional.
parameter: typeman: type manager
parameter: lowestElementSignature: finest element type \(ideally, should be a non\-array\)
parameter: dimensions: highest dimensions first, eg, \(2, 3, 4\) \-\> type\[2\]\[3\]\[4\]
return: the type

## Static Method: buildFullyQualifiedTypeNameFromElements
- parameter: `elements`, type: `java.util.List<java.lang.String>`
- return type: `java.lang.String`

Description: Build a fully qualified type name from name elements.
parameter: elements: name elements
return: fully qualified type name

## Static Method: buildQuick
- parameter: `typeman`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.ITypeManager`
- parameter: `signature`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`

Description: Build a type or prototype from a simple signature.
parameter: typeman: type manager
parameter: signature: type or prototype signature
return: native type, or null

## Static Method: buildQuickPrototype
- parameter: `typeman`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.ITypeManager`
- parameter: `protoString`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.type.IPrototypeItem`

Description: Generate a simple prototype item from a prototype string. Complex prototypes cannot be parsed by this routine. Prototypes attributes other than var\-arg \(via \`...\`\) are not supported either. Refer to [TypeStringParser](TypeStringParser) for a full\-blown C type and prototype parser. 

 Format: 

```

 [<calling-convention\>]returnType([param1Type[, param2Type[, ...]]])
 
```
 Examples: 

```

 void()
 int()
 unsigned int(char)
 <cdecl\>char(int, int, int)
 
```
parameter: typeman: type manager
parameter: protoString: see format above
return: a prototype item, null on error
see also: TypeStringParser

## Static Method: buildQuickType
- parameter: `typeman`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.ITypeManager`
- parameter: `signature`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`

Description: Create an array or reference type using an existing base type. This method is for convenience only, and by no means exhaustive. Proper type building requires adequate parsing; refer to [TLGen](TLGen). \(TODO: bindings to support string type parsing provided by [TLGen](TLGen)\).
parameter: typeman: type manager
parameter: signature: accepted signatures: abc, abc\*, abc\*\*, abc\[6\], abc\*\[10\], abc\*\*\[20\]; other            type signatures are not accepted \(eg, abc\[2\]\[4\], abc\[4\]\*, abc\*\*\[12\], etc.\)
return: the type item, null on error

## Static Method: checkAliasedType
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- parameter: `expectedType`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Check if a type aliases another type.
parameter: t: the type to be checked
parameter: expectedType: the other type, supposedly aliased by the first parameter
return: true or false

## Static Method: clearCache

Description: Clear internal caches.

## Static Method: collectTypes
- parameter: `proto`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.IPrototypeItem`
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.type.INativeType>`

Description: Collect the native types referenced by a prototype.
parameter: proto: prototype
return: return and parameter types

## Static Method: containsCppSeparator
- parameter: `name`, type: `java.lang.String`
- return type: `boolean`

Description: Fast check, equivalent to `string.contains(CPP_PACKAGE_SEPARATOR)`.
parameter: name: Potential CPP name with pacakges
return: true if string contains a CPP package separator. See [#splitCppName(String)](#splitCppName(String)) to         retrieve CPP elements.

## Static Method: findShorterForm
- parameter: `_t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`

Description: Attempt to retrieve a type equivalent to the provided input type, but whose string representation is shorter.
parameter: _t: an input type
return: shorter form of the type \(e.g. an existing alias\), or the same input type if nothing         was found

## Static Method: findType
- parameter: `types`, type: `java.util.Collection<? extends com.pnfsoftware.jeb.core.units.code.asm.type.INativeType>`
- parameter: `pattern`, type: `java.lang.String`
- parameter: `earlyExitOnFirstMatch`, type: `boolean`
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.type.INativeType>`

Description: Find a type by pattern \(partial name or signature, original or effective\). Does not include primitives.
parameter: types: input types
parameter: pattern: type "pattern" \(partial name or signature\)
parameter: earlyExitOnFirstMatch: exit on first match: the returned list will contain one element
return: the list of candidates, possibly empty

## Static Method: generateRoutineSignature
- parameter: `name`, type: `java.lang.String`
- parameter: `proto`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.IPrototypeItem`
- return type: `java.lang.String`

Description: Generate a routine signature given a prototype and a routine name.
parameter: name: routine name
parameter: proto: routine prototype
return: routine signature

## Static Method: getBaseType
- parameter: `type`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`

Description: Provide the base type of a type. The base type of a pointer type is its non\-pointer type; the base type of an array type is its dimension\-less type. Primitive, class, structure, union, enumeration and alias types, as well as prototypes, are all considered base types.
parameter: type: type
return: the base type of type

## Static Method: getFirstSimpleType
- parameter: `type`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`

Description: Get the first simple type embedded in the given type.
parameter: type: type
return: first simple type, or null

## Static Method: getLayoutInfo
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.type.TypeLayoutInfo`

Description: Get type layout information.
parameter: t: type
return: layout information

## Static Method: getNonAlias
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`

Description: Retrieve the non\-aliased type.
parameter: t: type
return: non\-aliased type

## Static Method: getNonAlias
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- parameter: `expected`, type: `java.lang.Class<T>`
- return type: `T`

Description: Retrieve the non\-aliased type and cast it to an expected type.
parameter: T: expected type
parameter: t: type
parameter: expected: expected class
return: non\-aliased type

## Static Method: getStructureField
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- parameter: `fieldName`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.type.IStructureTypeField`

Description: Given a structure type \(or an alias to one\), retrieve the field with the provided name.
parameter: t: a type whose non\-alias should be a structure
parameter: fieldName: a field name
return: null if not found or on error

## Static Method: getStructureField
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- parameter: `fieldStartOffset`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.type.IStructureTypeField`

Description: Given a structure type \(or an alias to one\), retrieve the field at the provided offset.
parameter: t: a type whose non\-alias should be a structure
parameter: fieldStartOffset: a field offset
return: null if not found or on error

## Static Method: isAlias
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine if a type is an alias.
parameter: t: type
return: true if alias

## Static Method: isBitfieldCompatible
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine if a type can be used for bitfields.
parameter: t: type
return: true if bitfield\-compatible

## Static Method: isCharacter
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine if a type is a character type.
parameter: t: type
return: true if character

## Static Method: isCompositeType
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine if the \(unaliased\) type is an array or a structure type.
parameter: t: type
return: true if the type is composite

## Static Method: isFloat
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine if a type is a floating\-point type.
parameter: t: type
return: true if floating\-point

## Static Method: isFunctionPointer
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine if the provided type is a function pointer, that is, a reference \(aliased or not\) to a prototype item.
parameter: t: type
return: true if the type is a function pointer

## Static Method: isFunctionPointer
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- parameter: `aproto`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.IPrototypeItem[]`
- return type: `boolean`

Description: Determine if the provided type is a function pointer, that is, a reference \(aliased or not\) to a prototype item.
parameter: t: input type
parameter: aproto: optional 1\-element array receiving the prototype object on success
return: success indicator

## Static Method: isInteger
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine if a type is an integer type.
parameter: t: type
return: true if integer

## Static Method: isKeyword
- parameter: `s`, type: `java.lang.String`
- return type: `boolean`

Description: Determine whether a string is a reserved keyword.
parameter: s: string to test
return: true if the string is a keyword

## Static Method: isPointer
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine if the \(unaliased\) type is a reference type.
parameter: t: type
return: true if the type is a pointer

## Static Method: isPointerToPointer
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine if the \(unaliased\) type is a reference to a reference type.
parameter: t: type
return: true if the type is a pointer to pointer

## Static Method: isPrimitive
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine if a type is primitive.
parameter: t: type
return: true if primitive

## Static Method: isPrototype
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine if a type is a prototype.
parameter: t: type
return: true if prototype

## Static Method: isReference
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine if a type is a reference.
parameter: t: type
return: true if reference

## Static Method: isReservedLiteral
- parameter: `s`, type: `java.lang.String`
- return type: `boolean`

Description: Determine whether a string is a reserved literal.
parameter: s: string to test
return: true if the string is reserved

## Static Method: isSignedInteger
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine if a type is a signed integer type.
parameter: t: type
return: true if signed integer

## Static Method: isSimple
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine if a type is a simple type.
parameter: t: type
return: true if primitive, reference, or prototype

## Static Method: isUnsignedInteger
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine if a type is an unsigned integer type.
parameter: t: type
return: true if unsigned integer

## Static Method: isValidFullyQualifiedName
- parameter: `basesig`, type: `java.lang.String`
- parameter: `elements`, type: `java.util.List<java.lang.String>`
- parameter: `aname`, type: `java.lang.String[]`
- return type: `boolean`

Description: Parse and validate the elements of a normalized signature \(aka fully\-qualified name\).
parameter: basesig: normalized signature, dimension\-less, reference\-less
parameter: elements: optional \(output elements\)
parameter: aname: optional \(output name\)
return: true if the name is valid

## Static Method: isValidPackageName
- parameter: `s`, type: `java.lang.String`
- return type: `boolean`

Description: Determine whether a package name is valid.
parameter: s: package name
return: true if the package name is valid

## Static Method: isValidTypeName
- parameter: `s`, type: `java.lang.String`
- return type: `boolean`

Description: Determine whether a type name is valid.
parameter: s: type name
return: true if the type name is valid

## Static Method: isVoid
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine if a type is void.
parameter: t: type
return: true if void

## Static Method: isVoidPointer
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine if a type is a pointer to void.
parameter: t: type
return: true if pointer to void

## Static Method: normalizeSignature
- parameter: `alreadyPreNormalized`, type: `boolean`
- parameter: `signature`, type: `java.lang.String`
- parameter: `elements`, type: `java.util.List<java.lang.String>`
- parameter: `counts`, type: `int[]`
- return type: `java.lang.String`

Description: Normalize a type signature \(including reference types\). 

 What it does: Make sure the type separator is `#CPP_PACKAGE_SEPARATOR` \(not '.' or '/'\). Remove header and trailer whitespace. Remove header `#CPP_PACKAGE_SEPARATOR` if any. Validate signature elements.
parameter: alreadyPreNormalized: true if the signature has been            [pre\-normalized](#preNormalizeSignature(String))
parameter: signature: a non\-canonical type signature
parameter: elements: optional output list to hold the signature elements of the base type            signature
parameter: counts: optional output two\-element array, will hold the reference count and the            dimension count of the provided signature; refer to            [#processSignature(String, int[])](#processSignature(String, int[]))
return: the normalized signature, null on error

## Static Method: preNormalizeSignature
- parameter: `signature`, type: `java.lang.String`
- return type: `java.lang.String`

Description: Normalize a signature for quick parsing.
parameter: signature: signature to normalize
return: never return null

## Static Method: processSignature
- parameter: `signature`, type: `java.lang.String`
- parameter: `counts`, type: `int[]`
- return type: `java.lang.String`

Description: Process non array or single\-dimension arrays of reference or non\-reference types.
parameter: signature: a pre\-normalized signature of the type
parameter: counts: optional output array, contains the reference count \(0 if none\) and the            single\-dimension array count \(\-1 if none\)
return: the base signature \(reference\-less, dimension\-less\) of the base type; null on error

## Static Method: retrieveAvailableTypes
- parameter: `unit`, type: `com.pnfsoftware.jeb.core.units.INativeCodeUnit<?>`
- parameter: `sourceFlags`, type: `int`
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.type.INativeType>`

Description: Retrieve available types.
parameter: unit: native code unit
parameter: sourceFlags: type source flags
return: available types

## Static Method: retrieveAvailableTypes
- parameter: `unit`, type: `com.pnfsoftware.jeb.core.units.INativeCodeUnit<?>`
- parameter: `sourceFlags`, type: `int`
- parameter: `filter`, type: `com.pnfsoftware.jeb.util.base.ISimpleFilter<com.pnfsoftware.jeb.core.units.code.asm.type.INativeType>`
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.type.INativeType>`

Description: Retrieve available types.
parameter: unit: native code unit
parameter: sourceFlags: type source flags
parameter: filter: optional type filter
return: available types

## Static Method: same
- parameter: `a`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- parameter: `b`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Determine whether two types are equal after alias resolution.
parameter: a: first type
parameter: b: second type
return: true if the types are the same

## Static Method: splitCppName
- parameter: `fullName`, type: `java.lang.String`
- return type: `java.util.List<java.lang.String>`

Description: Split a C\+\+ name using [#CPP_PACKAGE_SEPARATOR](#CPP_PACKAGE_SEPARATOR) as separator. 

 For example, `'std<int>::pkg:titi'` will be split into `[std<int>, pkg, titi]`
parameter: fullName: full C\+\+ name
return: list of names, never null

## Static Method: splitCppParameters
- parameter: `parameters`, type: `java.lang.String`
- return type: `java.util.List<java.lang.String>`

Description: Split a list of C\+\+ parameters separated by comma. Start/End Parentheses are optional. 

 For example, `'std<int>::pkg:titi, long'` will be split into `[std<int>::pkg:titi, long]`
parameter: parameters: C\+\+ parameter list
return: list of parameters, never null

## Static Method: structureInStructure
- parameter: `structType`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.IStructureType`
- parameter: `type`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.INativeType`
- return type: `boolean`

Description: Detect structure cycles: Determine if the second parameter type is or contains the structure type provided as the first parameter.
parameter: structType: the input structure
parameter: type: the type to be vetted against the provided structure
return: true if a cycle was detected \(the test type contains the structure type\); false         otherwise

