Version 6.3.8 for Windows
 —  Operations  —

Type Information

This document covers the following topics:


Overview

Type information is a means to completely describe a class along with all of its interfaces, down to the names and types of the methods. It contains the necessary information about classes and their interfaces, for example, which interfaces exist on which classes, which member functions exist in those interfaces, and which argument those functions require.

This information is used by clients to find out details about a class and its methods, for example, by type-information browsers to present available objects, interfaces, methods and properties to an end user.

Another important area for using type information is the widely-used OLE automation technique which is also used by NaturalX.

There are several ways to store type information. A common way is generating the type information in type library (.TLB) files.

Top of page

NaturalX and Type Information

Creating Type Information

For each Natural class, a type library file is created when the class is registered.

The type library is generated in the $NATDIR/$NATVERS/etc/<serverid>/<classname>/<version> directory and connected to the class via an entry in the registry.

The name of the class module is used, and the ".tlb" extension is appended unless the type library file name conflicts with an existing name. Then a number is attached to the class module name.

Top of page

Using Type Information

Each interface defined in a Natural class is seen by clients as a dynamic interface (also called a "dispatch interface"). Each method of an interface is seen by clients under the name defined in the METHOD statement.

The first interface in a Natural class is marked as the default dispatch interface.

The support of type information also makes it possible to define multiple interfaces with identical method/property names. The Natural client simply addresses the corresponding method by using the interface name (as defined in the Natural class) as the prefix of the method name, as shown in the following example:

CREATE OBJECT #O3 OF CLASS "DepartmentList"
SEND "Iterate.PositionTo" TO #O3 WITH "C" RETURN #DEPT

Natural clients use type information to find out to which interface a method or property belongs.

Note:
Natural clients do not use type information at catalog time to perform syntax checks.

Data Type Conversions

The following topics are covered below:

Natural Data Formats to OLE Types

In order to receive data from clients or to pass data to classes written in different programming languages, the Natural data formats are converted to so-called OLE Automation-compatible types. This table shows how COM clients see the method parameters or properties of a Natural class. For example, if a Natural class has a method parameter or a property with the format A, this is seen by a COM client as VT_BSTR.

Natural Data Format Automation-Compatible Type
A VT_BSTR
B1 VT_UI1
B2 VT_UI2
B4 VT_UI4
Bn (n != 1, 2, 4) SAFEARRAY of VT_UI1
C not supported
D VT_DATE
F4 VT_R4
F8 VT_R8
I1 VT_I2
I2 VT_I2
I4 VT_I4
HANDLE OF GUI not supported
HANDLE OF OBJECT VT_DISPATCH
L VT_BOOL
N15.4 VT_CY
Nn.m (n.m != 15.4) VT_R8
P15.4 VT_CY
Pn.m (n.m != 15.4) VT_R8
T VT_DATE
U VT_BSTR

An array of a given Natural data format is mapped to a SAFEARRAY of the corresponding "VT" type.

There are, however, some special cases:

OLE Types to Natural Data Formats

This table shows how parameters or properties of an external class can be addressed by Natural. For example, if an external class has a method parameter or property with type VT_R4, this parameter or property can be addressed in Natural as F4 or with a format that is MOVE-compatible to F4.

Automation -Compatible Type Natural Data Format
VT_BOOL L
VT_BSTR A or U
VT_CY P15.4
VT_DATE T
VT_DISPATCH HANDLE OF OBJECT
VT_UNKNOWN HANDLE OF OBJECT
VT_I1 I1
VT_I2 I2
VT_I4 I4
VT_INT I4
VT_R4 F4
VT_R8 F8
VT_U1 B1
VT_U2 B2
VT_U4 B4
VT_UINT B4

A SAFEARRAY of up to three dimensions is converted into a Natural array with the same dimension count and the corresponding format. SAFEARRAYs with more than three dimensions cannot be used from within Natural.

There are, however, some special cases:

Top of page