DataTypeLib Class Reference

#include <datatypelib.h>

Detailed Description

DataTypeLib declares some static functions needed for the DataType system.

Static Public Member Functions

static MAXON_METHOD const DataTypeGetDataTypeType ()
 
static MAXON_METHOD const DataTypeGetVoidType ()
 
static MAXON_METHOD const DataTypeGetNullptrType ()
 
static MAXON_METHOD const DataTypeGetGenericType ()
 
static MAXON_METHOD const DataTypeGetGenericArithmeticType ()
 
static MAXON_METHOD const DataTypeGetParametricTypeType ()
 
static MAXON_METHOD const DataTypeGetComponentDescriptorType ()
 
static MAXON_METHOD const DataTypeGetEllipsisType ()
 
static MAXON_METHOD const DataTypeGetInvalidType ()
 
static MAXON_METHOD Result< DataTypeSubstitute (const DataType &orig, const Delegate< Result< DataType >(const DataType &)> &replace)
 
static MAXON_METHOD Result< DataTypeGetRuntimeDataType (const DataType &orig)
 
static MAXON_METHOD const Block< const Int > & GetTupleMemberOffsets (const TupleDataType &type)
 
static MAXON_METHOD const Block< const Int > & GetMemberOrder (const DataType &bundleOrContainerType)
 
static MAXON_METHOD Result< DelegateDataTypeGetDelegateType (const DataType &returnType, const Block< const DataType > &paramTypes, reflection::DelegateFunctionPointer function, void *handlerStub)
 
static MAXON_METHOD Result< DelegateDataTypeGetDelegateType (const Result< DataType > &returnType, const Block< const Result< DataType >> &paramTypes, reflection::DelegateFunctionPointer function, void *handlerStub)
 
static MAXON_METHOD Result< void > InvokeDelegate (const DelegateDataType &delegateType, const DelegateBase &delegate, void *result, const Block< reflection::Argument > &arguments)
 
static MAXON_METHOD Result< DelegateBaseCreateDelegate (const DelegateDataType &delegateType, reflection::DelegateHandler &&handler)
 
static MAXON_METHOD const DataTypeGetDelegateReturnType (const DelegateDataType &delegateType)
 
static MAXON_METHOD const Block< const DataType > & GetDelegateParameterTypes (const DelegateDataType &delegateType)
 
static MAXON_METHOD Result< EnumDataTypeGetEnumType (const DataType &underlyingType, const Block< const Tuple< Id, Data >> &enumerators)
 
static MAXON_METHOD const Block< const Tuple< Id, Data > > & GetEnumerators (const DataType &enumType)
 
static MAXON_METHOD Result< void > RegisterEnumType (DataTypeImpl &type, const Id &typeId, Int size, Bool isSigned, Bool flags, const UInt64 *enumValues, const Char *enumValueNames)
 
static MAXON_METHOD Result< DataTypeGetDataTypeOfInterfaces (const Block< const InterfaceReference *const > &interfaces)
 
static MAXON_METHOD Result< DataTypeGetReferenceType (const DataType &type, EntityBase::FLAGS refFlags)
 
static MAXON_METHOD Result< Tuple< DataType, const Char * > > ParseDataType (const Char *str)
 
static MAXON_METHOD Result< Tuple< Member, const Char * > > ParseMember (const Char *str)
 
static MAXON_METHOD Result< Tuple< Int64, const Char * > > ParseInt (const Char *str)
 
static MAXON_METHOD Result< DataTypeGetDataType (const Id &typeId)
 
static MAXON_METHOD const IdGetNumberedId (Int number)
 
static MAXON_METHOD Result< const MemberMap * > GetMemberMap (Block< const Int > block)
 
static MAXON_METHOD Result< const MemberMap * > GetIdentityMemberMap (Int length)
 
static MAXON_METHOD Result< const MemberMap * > ConcatMemberMap (const MemberMap *first, const MemberMap *second)
 
static MAXON_METHOD Result< const MemberMap * > GetMemberMap (const DataTypeImpl *containerType, const DataTypeImpl *runtimeType)
 
static MAXON_METHOD Result< DataTypeGetDataTypeForData (const DataType &valueType)
 
static MAXON_METHOD Result< void > ConvertToData (Data &result, const DataType &dataType, const DataType &valueType, const Generic &value)
 
static MAXON_METHOD Result< void > MoveFromData (const DataType &valueType, Generic &value, Bool createDefaultPointees, Data &data, BaseArray< Data > &storage)
 
static MAXON_METHOD Bool PrivateIsBaseOfOrSame (const DataTypeImpl *type, const DataTypeImpl *other, DataType::BASE_OF_MODE mode)
 
static MAXON_METHOD Result< StrongRef< TypeArguments > > CreateTypeArguments (Int cnt)
 
static MAXON_METHOD Result< StrongRef< TypeArguments > > CreateTypeArguments (const Block< const Member > &args)
 
static MAXON_METHOD ResultMem FinalizeTypeArguments (TypeArguments &args)
 
static MAXON_METHOD void PrivateHandleUnreferencedType (DataTypeImpl *type)
 
static MAXON_METHOD const DataTypePrivateGetPrimaryDataTypeType ()
 
static MAXON_METHOD void AddLeakingInstantiatedType (DataTypeImpl *type)
 
static MAXON_METHOD void PrivateGetNamedTupleMembers (Binary &binary, NamedTupleMembers *mem, std::add_pointer< Int(void *)>::type constructor)
 

Static Public Attributes

static const Int NUMBERED_ID_COUNT
 

Private Member Functions

 MAXON_INTERFACE_NONVIRTUAL (DataTypeLib, MAXON_REFERENCE_NONE, "net.maxon.interface.datatypelib")
 

Member Function Documentation

◆ MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( DataTypeLib  ,
MAXON_REFERENCE_NONE  ,
"net.maxon.interface.datatypelib"   
)
private

◆ GetDataTypeType()

static MAXON_METHOD const DataType& GetDataTypeType ( )
static

Returns the DataType for DataType itself.

Returns
DataType of DataType.

◆ GetVoidType()

static MAXON_METHOD const DataType& GetVoidType ( )
static

Returns the DataType for void.

Returns
DataType of void.

◆ GetNullptrType()

static MAXON_METHOD const DataType& GetNullptrType ( )
static

Returns the DataType for std::nullptr_t.

Returns
DataType of void.

◆ GetGenericType()

static MAXON_METHOD const DataType& GetGenericType ( )
static

Returns the DataType for the Generic type. All operations on a Generic value will fail.

Returns
DataType of Generic.

◆ GetGenericArithmeticType()

static MAXON_METHOD const DataType& GetGenericArithmeticType ( )
static

Returns the DataType for the generic arithmetic type. All operations on a Generic value will fail.

Returns
Abstract base type of all arithmetic types.

◆ GetParametricTypeType()

static MAXON_METHOD const DataType& GetParametricTypeType ( )
static

Returns the DataType for ParametricType.

Returns
DataType of ParametricType.

◆ GetComponentDescriptorType()

static MAXON_METHOD const DataType& GetComponentDescriptorType ( )
static

◆ GetEllipsisType()

static MAXON_METHOD const DataType& GetEllipsisType ( )
static

Returns the DataType which represents an arbitrary number of members for container types.

Returns
DataType for the ellipsis of container types.

◆ GetInvalidType()

static MAXON_METHOD const DataType& GetInvalidType ( )
static

Returns the DataType of InvalidType.

Returns
DataType of InvalidType.

◆ Substitute()

static MAXON_METHOD Result<DataType> Substitute ( const DataType orig,
const Delegate< Result< DataType >(const DataType &)> &  replace 
)
static

Applies the substitutions given be replace to orig and its nested types. For example, if replace maps Float to Float64, then Float gets transformed into Float64, but also Tuple<Bool, Float, Vector, BaseArray<Float>> gets transformed into Tuple<Bool, Float64, Vector64, BaseArray<Float64>>.

Parameters
[in]origOriginal DataType.
[in]replaceThis delegate is called for each DataType found in orig. It has to return the replacement for the passed DataType, or the passed DataType itself if no immediate replacement shall be done. In both cases, if the returned type is an instance of a parametric type, the substitution recurses into the type parameters and re-instantiates the parametric type for the substituted type arguments.
Returns
DataType where the substitutions given by #replace have been applied.

◆ GetRuntimeDataType()

static MAXON_METHOD Result<DataType> GetRuntimeDataType ( const DataType orig)
static

Replaces types which depend on the architecture or the version by the concrete types for the current runtime:

  • The architecture-dependent types Int, UInt and Float are replaced by the corresponding runtime data types (Int32 or Int64, likewise for UInt and Float).
  • Unversioned interface types are replaced by the corresponding main version types.

The replacement is also done within instances of parametric types so that e.g. Vector gets replaced by Vector64. Internally GetRuntimeDataType() just uses Substitute().

Parameters
[in]origOriginal DataType.
Returns
DataType where all occurrences of Int, UInt and Float have been replaced by the corresponding runtime type.
See also
Substitute

◆ GetTupleMemberOffsets()

static MAXON_METHOD const Block<const Int>& GetTupleMemberOffsets ( const TupleDataType type)
static

Returns the byte offsets of the tuple members.

Parameters
[in]typeTuple data type.
Returns
Byte offsets of the member values.
Note
The memory layout of a TupleDataType is compatible with the C++ layout of standard-layout classes. Members with higher index have a higher offset.

◆ GetMemberOrder()

static MAXON_METHOD const Block<const Int>& GetMemberOrder ( const DataType bundleOrContainerType)
static

◆ GetDelegateType() [1/2]

static MAXON_METHOD Result<DelegateDataType> GetDelegateType ( const DataType returnType,
const Block< const DataType > &  paramTypes,
reflection::DelegateFunctionPointer  function,
void *  handlerStub 
)
static

◆ GetDelegateType() [2/2]

static MAXON_METHOD Result<DelegateDataType> GetDelegateType ( const Result< DataType > &  returnType,
const Block< const Result< DataType >> &  paramTypes,
reflection::DelegateFunctionPointer  function,
void *  handlerStub 
)
static

◆ InvokeDelegate()

static MAXON_METHOD Result<void> InvokeDelegate ( const DelegateDataType delegateType,
const DelegateBase delegate,
void *  result,
const Block< reflection::Argument > &  arguments 
)
static

◆ CreateDelegate()

static MAXON_METHOD Result<DelegateBase> CreateDelegate ( const DelegateDataType delegateType,
reflection::DelegateHandler &&  handler 
)
static

◆ GetDelegateReturnType()

static MAXON_METHOD const DataType& GetDelegateReturnType ( const DelegateDataType delegateType)
static

◆ GetDelegateParameterTypes()

static MAXON_METHOD const Block<const DataType>& GetDelegateParameterTypes ( const DelegateDataType delegateType)
static

◆ GetEnumType()

static MAXON_METHOD Result<EnumDataType> GetEnumType ( const DataType underlyingType,
const Block< const Tuple< Id, Data >> &  enumerators 
)
static

◆ GetEnumerators()

static MAXON_METHOD const Block<const Tuple<Id, Data> >& GetEnumerators ( const DataType enumType)
static

◆ RegisterEnumType()

static MAXON_METHOD Result<void> RegisterEnumType ( DataTypeImpl type,
const Id typeId,
Int  size,
Bool  isSigned,
Bool  flags,
const UInt64 enumValues,
const Char enumValueNames 
)
static

◆ GetDataTypeOfInterfaces()

static MAXON_METHOD Result<DataType> GetDataTypeOfInterfaces ( const Block< const InterfaceReference *const > &  interfaces)
static

Returns the DataType of an object which implements at least the given interfaces. On the first invocation for a specific set of interfaces, the data type will be constructed, later invocations will return the same data type object. The order of interfaces doesn't matter.

The identifier of the returned type is a comma-separated list of the identifiers of the interfaces, alphabetically sorted by their id and enclosed in {}-parentheses.

Parameters
[in]interfacesArray of virtual interfaces.
Returns
DataType for the given set of interfaces.

◆ GetReferenceType()

static MAXON_METHOD Result<DataType> GetReferenceType ( const DataType type,
EntityBase::FLAGS  refFlags 
)
static

◆ ParseDataType()

static MAXON_METHOD Result<Tuple<DataType, const Char*> > ParseDataType ( const Char str)
static

◆ ParseMember()

static MAXON_METHOD Result<Tuple<Member, const Char*> > ParseMember ( const Char str)
static

◆ ParseInt()

static MAXON_METHOD Result<Tuple<Int64, const Char*> > ParseInt ( const Char str)
static

◆ GetDataType()

static MAXON_METHOD Result<DataType> GetDataType ( const Id typeId)
static

Returns the DataType identified by typeId. This supports primary data types as well as compound data types which are built by primary data types and array- and struct-compositions. E.g., the id "(int64,net.maxon.parametrictype.vec<3,float64>,{net.maxon.interface.function})[]" identifies an array of structs with Int64, Vector64 and object members where the object has to implement FunctionSignatureInterface and GenericFunctionInterface.

Parameters
[in]typeIdType identifier.
Returns
DataType for the given id.

◆ GetNumberedId()

static MAXON_METHOD const Id& GetNumberedId ( Int  number)
static

Returns an Id of the form _123, i.e., consisting of the character _ followed by the given #number in decimals.

Parameters
[in]numberThe number for the Id, has to be non-negative and below NUMBERED_ID_COUNT.
Returns
Id of the form _123.

◆ GetMemberMap() [1/2]

static MAXON_METHOD Result<const MemberMap*> GetMemberMap ( Block< const Int block)
static

◆ GetIdentityMemberMap()

static MAXON_METHOD Result<const MemberMap*> GetIdentityMemberMap ( Int  length)
static

Returns a MemberMap of the given length which maps each index onto itself.

Parameters
[in]lengthThe length of the MemberMap.
Returns
A MemberMap with the values 0, 1, ..., length-1.

◆ ConcatMemberMap()

static MAXON_METHOD Result<const MemberMap*> ConcatMemberMap ( const MemberMap first,
const MemberMap second 
)
static

◆ GetMemberMap() [2/2]

static MAXON_METHOD Result<const MemberMap*> GetMemberMap ( const DataTypeImpl containerType,
const DataTypeImpl runtimeType 
)
static

◆ GetDataTypeForData()

static MAXON_METHOD Result<DataType> GetDataTypeForData ( const DataType valueType)
static

◆ ConvertToData()

static MAXON_METHOD Result<void> ConvertToData ( Data result,
const DataType dataType,
const DataType valueType,
const Generic &  value 
)
static

◆ MoveFromData()

static MAXON_METHOD Result<void> MoveFromData ( const DataType valueType,
Generic &  value,
Bool  createDefaultPointees,
Data data,
BaseArray< Data > &  storage 
)
static

◆ PrivateIsBaseOfOrSame()

static MAXON_METHOD Bool PrivateIsBaseOfOrSame ( const DataTypeImpl type,
const DataTypeImpl other,
DataType::BASE_OF_MODE  mode 
)
static

◆ CreateTypeArguments() [1/2]

static MAXON_METHOD Result<StrongRef<TypeArguments> > CreateTypeArguments ( Int  cnt)
static

◆ CreateTypeArguments() [2/2]

static MAXON_METHOD Result<StrongRef<TypeArguments> > CreateTypeArguments ( const Block< const Member > &  args)
static

◆ FinalizeTypeArguments()

static MAXON_METHOD ResultMem FinalizeTypeArguments ( TypeArguments args)
static

◆ PrivateHandleUnreferencedType()

static MAXON_METHOD void PrivateHandleUnreferencedType ( DataTypeImpl type)
static

◆ PrivateGetPrimaryDataTypeType()

static MAXON_METHOD const DataType& PrivateGetPrimaryDataTypeType ( )
static

◆ AddLeakingInstantiatedType()

static MAXON_METHOD void AddLeakingInstantiatedType ( DataTypeImpl type)
static

◆ PrivateGetNamedTupleMembers()

static MAXON_METHOD void PrivateGetNamedTupleMembers ( Binary &  binary,
NamedTupleMembers mem,
std::add_pointer< Int(void *)>::type  constructor 
)
static

Member Data Documentation

◆ NUMBERED_ID_COUNT

const Int NUMBERED_ID_COUNT
static

The limit for GetNumberedId.