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

Utility routines for native types.

## Constructor: TypeUtil


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

Constant value: `::`

## Static Field: CPP_TEMPLATE_REGEXP
Type: `java.util.regex.Pattern`

## Static Field: TYPESOURCE_ALL
Type: `int`

Constant value: `3`

## Static Field: TYPESOURCE_INUSE
Type: `int`

Constant value: `1`

## Static Field: TYPESOURCE_TYPELIBS
Type: `int`

Constant value: `2`

## Static Field: keywords
Type: `java.util.Set<java.lang.String>`

## 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`


## 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: 
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`


## 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: 
parameter: typeman: 
parameter: signature: 
return: 

## 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: 
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: 
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


## 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>`


## 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: 
parameter: proto: 
return: 

## 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: 
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: 
return: 

## 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`


## 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`


## 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`


## 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`


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


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


## 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: 
return: 

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


## 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: 
return: 

## 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`


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


## 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: 
return: 

## 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: 
return: 

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


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


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


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


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


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


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


## 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: 

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


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


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


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


## 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: 
parameter: signature: 
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>`


## 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>`


## 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: 
parameter: a: 
parameter: b: 
return: 

## 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: 
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: 
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

