Symbolic Enumerations

One or more symbolic enums, similar to C++ enums, can now be added to an FPInterface's metadata, and individual int parameters and/or results for functions in that interface can be defined as TYPE_ENUM and associated with one of the enum lists. This allows metadata clients to support symbolic encodings for these parameters and results, which MAXScript now does.

Enums are defined in the FPInterface descriptor following the function and property definitions as sets of string/code pairs. Each enum list is identified by a unique integer, similar to function IDs, which is used to associated a TYPE_ENUM parameter or result with its enum. IDs for these would normally be defined somewhere near the function IDs for an interface. For example:

// function IDs
enum { bmm_getWidth, bmm_getHeight, bmm_getType, bmm_copyImage, ...};
 
// enum IDs
enum { bmm_type, bmm_copy_quality, ...};

might be some of the IDs for a possible bitmap manager interface. The two enums provide symbolic codes for the bitmap type and copyImage quality defines in the bitmap.h SDK header, such as BMM_PALETTED,BMM_TRUE_32, COPY_IMAGE_RESIZE_LO_QUALITY, etc. In the descriptor for the interface, any enum lists follow the function and property definitions. They are introduced by the special tag, 'enums', as in the following example:

static  FPInterfaceDesc bmmfpi (
   BMM_INTERFACE, _T("bmm"), IDS_BMMI, NULL, FP_CORE,
   //...
   bmm_copyImage, _T("copyImage"), //...
   _T("copyType"), IDS_COPYTYPE, TYPE_ENUM, bmm_copy_quality,
   //...
 
   properties,
     geo_getType, geo_setType, _T("type"), 0, TYPE_ENUM, bmm_type,
 
   enums,
     bmm_type, 7,
       "lineArt", BMM_LINE_ART,
       "paletted", BMM_PALETTED,
       "gray8", BMM_GRAY_8,
       "gray16", BMM_GRAY_16 ,
       "true16", BMM_TRUE_16,
       "true32", BMM_TRUE_32,
       "true24", BMM_TRUE_64,
     bmm_copy_quality, 4,
       "crop", COPY_IMAGE_CROP,
       "resizeLo", COPY_IMAGE_RESIZE_LO_QUALITY,
       "resizeHi", COPY_IMAGE_RESIZE_HI_QUALITY,
       "useCustom", COPY_IMAGE_USE_CUSTOM,
   end
);

In the above example, the enums are listed following the function & property definitions. They are introduced by the 'enums' tag and consist of an enum ID followed by a count of items, followed by that many string and code pairs. By attaching them to the interface like this, any number of functions and properties in the interface can use them.

The above example also has function and property definitions showing the use of TYPE_ENUM. The copyImage function takes a copyType parameter which uses the bmm_copy_quality enum and the type property uses the bmm_type enum. In all situations where TYPE_xxx types can be supplied in a descriptor, including the new property definitions, TYPE_ENUM can be used to indicate an int by-value type. TYPE_ENUM 's must always be followed by an enum ID. This is the only case in which the type is specified as a pair of values. TYPE_ENUM parameters and results show up in MAXScript as # names. For example, if a bmm interface was in the variable 'bm1' and the bitmap type was BMM_GRAY_16,

bm1.type

-> #gray16

bm1.type = #true32 --set it to #true24 (code is BMM_TRUE_24)
bm2 = bm1.copyImage #resizeHi

the integer TYPE_ENUM codes are translated back-and-forth to symbolic # names by MAXScript using the definitions in the FPInterface descriptor's enums. If you need to access the enum metadata in an FPInterfaceDesc, it is available in the 'enumerations' data member. This is a Tab<> of pointers to FPEnum class instances which themselves contain a Tab<> of name, code pairs. See class FPEnum in iFnPub.h for details.