Initializing help system before first use

gettypeprop

gettypeprop


Purpose
Get a property of a type.
Synopsis
int gettypeprop(XPRMcontext ctx, int type, int prop, XPRMalltypes *value);
Arguments
ctx 
Mosel's execution context
type 
Code of a type
prop 
Property to retrieve. Possible values:
XPRM_TPROP_NAME 
Name of the type
XPRM_TPROP_FEAT 
Encoded features
XPRM_TPROP_EXP 
Expanded type
XPRM_TPROP_PBID 
Problem index (negative if the type is not a problem)
XPRM_TPROP_ITYPS 
Array of field types for a constant reference containing a record
value 
Pointer to an area where the type property is returned
Return value
0 if successful, -1 if type is not valid and 1 if prop is not supported.
Further information
1. This function returns a property of an external type (types provided by modules or user defined). For the property XPRM_TPROP_NAME, the type name is returned in value->string, for the 3 other properties, the result is returned in value->integer.
2. The type features are bit encoded as follows:
XPRM_MTP_CREAT 
Creation function available for this type
XPRM_MTP_DELET 
Deletion function available for this type
XPRM_MTP_TOSTR 
Type can be converted to a string
XPRM_MTP_FRSTR 
Type can be initialized from a string
XPRM_MTP_PRTBL 
Type can be converted to a string after execution
XPRM_MTP_RFCNT 
Type implements reference count
XPRM_MTP_COPY 
Type implements copy: it may be used in assignments
XPRM_MTP_APPND 
The copy function of this type supports appending
XPRM_MTP_ORSET 
The copy function of this type can only be used to reset an object
XPRM_MTP_PROB 
Type is a problem
XPRM_MTP_CMP 
Test of equality is supported by this type
XPRM_MTP_SHARE 
An entity of this type can be declared as shared
XPRM_MTP_TFBIN 
Type supports export/import in binary format
XPRM_MTP_ORD 
Type supports comparison
XPRM_MTP_CONST 
Type supports constant definition

3. The expanded type is available for user defined types only: it corresponds to the actual type (including structure information) associated to a user defined type code. For instance, assuming the type myset is defined as a set of integer, getting the type expansion for the code associated to myset will give XPRM_STR_SET|XPRM_TYP_INT indicating that a reference to an entity of type myset has to be handled with functions for sets.
4. Trying to get the expanded type of a module type or the features of a user defined type is an error: the function returns 1. This can be used to identify module types.
5. A user type which expanded value is XPRM_STR_REC is a record type. The public fields of a record type may be enumerated with getnextfield.
6. A user type which expanded value is XPRM_STR_PROB is a problem type. The components of a problem type may be enumerated with getnextpbcomp. Note that problem types are also implemented as native types. In this case, the flag XPRM_MTP_PROB will be set in the type features.
7. If a type refers to a native or record constant the expanded type has structure XPRM_STR_CSREF. The function csrtoref might be used to retrieve the actual object associated to a constant. The property XPRM_TPROP_ITYPS is an array of integers describing the types of the fields of a constant record (it is NULL if the referenced type is not a record). The first cell of this array is the number of fields and each following entry is the type of the corresponding field (this information is required when implementing an IO driver supporting initialisations blocks).
Related topics