Default Coercion Handlers (original) (raw)
This appendix lists the type conversions performed by the default coercion handlers provided by the Mac OS. These handlers may be implemented by the Apple Event Manager, the Open Scripting framework, or other frameworks.
Support for the following coercions was added in Mac OS X version 10.4:
- Between these types:
typeStyledText
,typeUnicodeText
,typeUTF8Text
, andtypeUTF16ExternalRepresentation
and these types:typeType
,typeEnumerated
, and the numeric typestypeSInt16
,typeSInt32
,typeUInt32
,typeSInt64
,typeIEEE32BitFloatingPoint
,typeIEEE64BitFloatingPoint
, andtypeExtended
.
See table Table C-1 for a mapping between the preferred and non-preferred numeric constant names. - From
typeChar
totypeStyledText
.
Coercion Handler Tables
Table C-1 shows some older, non-preferred numeric constant names and their preferred equivalents. To find available coercions for a non-preferred name from Table C-1, look up its equivalent preferred name in Table C-2.
Table C-1 Older, non-preferred numeric types and their preferred types
Non-preferred numeric constant name | Preferred numeric constant name |
---|---|
typeSMInt, typeShortInteger | typeSInt16 |
typeInteger, typeLongInteger | typeSInt32 |
typeMagnitude | typeUInt32 |
typeComp | typeSInt64 |
typeSMFloat, typeShortFloat | typeIEEE32BitFloatingPoint |
typeFloat, typeLongFloat | typeIEEE64BitFloatingPoint |
Table C-2 lists the default coercions handled by the Apple Event Manager.
Table C-2 Default coercions provided by the Apple Event Manager
Coerce from descriptor type | To descriptor type | Comment |
---|---|---|
typeChartypeStyledTexttypeUnicodeTexttypeUTF8TexttypeUTF16ExternalRepresentation | typeSInt16typeSInt32typeSInt64typeIEEE32BitFloatingPointtypeIEEE64BitFloatingPointtypeExtended | Any string that is a valid representation of a number can be coerced into an equivalent numeric value. |
typeSInt16typeSInt32typeSInt64typeIEEE32BitFloatingPointtypeIEEE64BitFloatingPointtypeExtended | typeChartypeStyledTexttypeUnicodeTexttypeUTF8TexttypeUTF16ExternalRepresentation | Any numeric descriptor type can be coerced into the equivalent text string. |
typeSInt16typeSInt32typeSInt64typeIEEE32BitFloatingPointtypeIEEE64BitFloatingPointtypeExtended | typeSInt16typeSInt32typeSInt64typeIEEE32BitFloatingPointtypeIEEE64BitFloatingPointtypeExtended | Any numeric descriptor type can be coerced into any other numeric descriptor type. |
typeChartypeIntlTexttypeStyledTexttypeUnicodeTexttypeUTF8TexttypeUTF16ExternalRepresentation | typeChartypeIntlTexttypeStyledTexttypeUnicodeTexttypeUTF8TexttypeUTF16ExternalRepresentation | If the destination encoding cannot represent a character in the source text, the result is undefined. |
typeChartypeStyledTexttypeUnicodeTexttypeUTF8TexttypeUTF16ExternalRepresentation | typeTypetypeEnumeratedtypeKeywordtypeProperty | Any four-character string can be coerced to one of these descriptor types. |
typeEnumeratedtypeKeywordtypePropertytypeType | typeChartypeStyledTexttypeUnicodeTexttypeUTF8TexttypeUTF16ExternalRepresentation | Any of these descriptor types can be coerced to the equivalent text string. |
typeIntlText | typeChartypeStyledTexttypeUnicodeTexttypeUTF8TexttypeUTF16ExternalRepresentation | The result contains text only, without the script code or language code from the original descriptor. |
typeTrue | typeBoolean | The result is the Boolean value true. |
typeFalse | typeBoolean | The result is the Boolean value false. |
typeEnumerated | typeBoolean | The enumerated value 'true' becomes the Boolean value true. The enumerated value 'fals' becomes the Boolean value false. |
typeBoolean | typeEnumerated | The Boolean value false becomes the enumerated value 'fals'. The Boolean value true becomes the enumerated value 'true'. |
typeSInt16 | typeBoolean | A value of 1 becomes the Boolean value true. A value of 0 becomes the Boolean value false. |
typeBoolean | typeSInt16 | A value of false becomes 0. A value of true becomes 1. |
typeAlias | typeFSS | An alias is coerced into a file system specification. Not recommended—use typeFSRef instead. |
typeAlias | typeFSRef | An alias is coerced into a file system reference. |
typeAppleEvent | typeAppParameters | An Apple event is coerced into a list of application parameters for the LaunchParamBlockRec parameter block. |
any descriptor type | typeAEList | A descriptor is coerced into a descriptor list containing a single item. |
typeAEList | type of list item | A descriptor list containing a single descriptor is coerced into a descriptor. |