Using IDL types with ColdFusion variables



ColdFusion supports specific CORBA data types and converts between CORBA types and ColdFusion data.

IDL support

The following table shows which CORBA IDL types ColdFusion supports, and whether they can be used as parameters or return variables. (NA means not applicable.)

CORBA IDL type

General support

As parameters

As return value

constants

No

No

No

attributes

Yes (for properties)

NA

NA

enum

Yes (as an integer)

Yes

Yes

union

No

No

No

sequence

Yes

Yes

Yes

array

Yes

Yes

Yes

interface

Yes

Yes

Yes

typedef

Yes

NA

NA

struct

Yes

Yes

Yes

module

Yes

NA

NA

exception

Yes

NA

NA

any

No

No

No

boolean

Yes

Yes

Yes

char

Yes

Yes

Yes

wchar

Yes

Yes

Yes

string

Yes

Yes

Yes

wstring

Yes

Yes

Yes

octet

Yes

Yes

Yes

short

Yes

Yes

Yes

long

Yes

Yes

Yes

float

Yes

Yes

Yes

double

Yes

Yes

Yes

unsigned short

Yes

Yes

Yes

unsigned long

Yes

Yes

Yes

longlong

No

No

No

unsigned longlong

No

No

No

void

Yes

NA

Yes

Data type conversion

The following table lists IDL data types and the corresponding ColdFusion data types:

IDL type

ColdFusion type

boolean

Boolean

char

One-character string

wchar

One-character string

string

String

wstring

String

octet

One-character string

short

Integer

long

Integer

float

Real number

double

Real number

unsigned short

Integer

unsigned long

Integer

void

Not applicable (returned as an empty string)

struct

Structure

enum

Integer, where 0 corresponds to the first enumerator in the enum type

array

Array (must match the array size specified in the IDL)

sequence

Array

interface

An object reference

module

Not supported (cannot dereference by module name)

exception

ColdFusion throws an exception of type coldfusion.runtime.corba.CorbaUserException

attribute

Object reference using dot notation

Boolean data considerations

ColdFusion treats any of the following as Boolean values:

True

"yes", "true", or 1

False

"no", "false", or 0

You can use any of these values with CORBA methods that take Boolean parameters, as the following code shows:

IDL

module Tester 
{ 
interface TManager 
{ 
void testBoolean(in boolean a); 
void testOutBoolean(out boolean a); 
void testInoutBoolean(inout boolean a); 
boolean returnBoolean(); 
} 
}

CFML

<cfset handle = CreateObject("CORBA", "d:\temp\tester.ior", "IOR", "") > 
<cfset ret = handle.testboolean("yes")> 
<cfset mybool = True> 
<cfset ret = handle.testoutboolean("mybool")> 
<cfoutput>#mybool#</cfoutput> 
<cfset mybool = 0> 
<cfset ret = handle.testinoutboolean("mybool")> 
<cfoutput>#mybool#</cfoutput> 
<cfset ret = handle.returnboolean()> 
<cfoutput>#ret#</cfoutput>

Struct data type considerations

For IDL struct types, use ColdFusion structures. You can prevent errors by using the same case for structure key names in ColdFusion as you do for the corresponding IDL struct field names.

Enum type considerations

ColdFusion treats the enum IDL type as an integer with the index starting at 0. As a result, the first enumerator corresponds to 0, the second to 1, and so on. In the following example, the IDL enumerator a corresponds to 0, b to 1 and c to 2:

IDL

module Tester 
{ 
enum EnumType {a, b, c}; 
interface TManager 
{ 
void testEnum(in EnumType a); 
void testOutEnum(out EnumType a); 
void testInoutEnum(inout EnumType a); 
EnumType returnEnum(); 
} 
}

CFML

<cfset handle = CreateObject("CORBA", "d:\temp\tester.ior", "IOR", "") > 
<cfset ret = handle.testEnum(1)>

In this example, the CORBA object gets called with the second (not first) entry in the enumerator.

Double-byte character considerations

If you are using an ORB that supports CORBA later than version 2.0, you do not have to do anything to support double-byte characters. Strings and characters in ColdFusion convert appropriately to wstring and wchar data when they are used. However, the CORBA 2.0 IDL specification does not support the wchar and wstring types, and uses the 8-bit Latin-1 character set to represent string data. In this case, you cannot pass parameters containing those characters, however, you can call parameters with char and string types using ColdFusion string data.