Using Object Pascal or RIDL Syntax

From RAD Studio
Jump to: navigation, search

Go Up to Using the Type Library Editor


The Code page of the Type Library editor displays your type information in RIDL format (Restricted Interface Definition Language). The format resembles the Microsoft IDL syntax. However, RIDL supports only a subset of IDL. Like Delphi applications in general, identifiers in type libraries are case-insensitive. Identifiers can be as many as 255 characters long, and for maximum portability, they should begin with a letter or an underscore (_).

Attribute specifications

Types declared in a RIDL file may contain attributes. Attribute specifications appear enclosed in square brackets and separated by commas. Each attribute specification consists of an attribute name followed (if appropriate) by a value.

The following table lists the attribute names and their corresponding values:

Attribute syntax

Attribute name Example Applies to

aggregatable

[aggregatable]

typeinfo

appobject

[appobject]

CoClass typeinfo

bindable

[bindable]

members except CoClass members

control

[control]

type library, typeinfo

custom

[custom '{7B5687A1-F4E9-11D1-92A8-00C04F8C8FC4}' 0]

anything

default

[default]

CoClass members

defaultbind

[defaultbind]

members except CoClass members

defaultcollection

[defaultcollection]

members except CoClass members

dispid

[dispid]

members except CoClass members

displaybind

[displaybind]

members except CoClass members

dllname

[dllname 'Helper.dll']

module typeinfo

dual

[dual]

interface typeinfo

helpfile

[helpfile 'c:\help\myhelp.chm'] [helpfile 'c:\help\myhelp.hlp']

type library

helpstringdll

[helpstringdll 'c:\help\myhelp.dll']

type library

helpcontext

[helpcontext 2005]

anything except CoClass members and parameters

helpstring

[helpstring 'payroll interface']

anything except CoClass members and parameters

helpstringcontext

[helpstringcontext $17]

anything except CoClass members and parameters

hidden

[hidden]

anything except parameters

lcid

[lcid $324]

type library

licensed

[licensed]

type library, CoClass typeinfo

nonbrowsable

[nonbrowsable]

members except CoClass members

nonextensible

[nonextensible]

interface typeinfo

oleautomation

[oleautomation]

interface typeinfo

predeclid

[predeclid]

typeinfo

propget

[propget]

members except CoClass members

propput

[propput]

members except CoClass members

propputref

[propputref]

members except CoClass members

public

[public]

alias typeinfo

readonly

[readonly]

members except CoClass members

replaceable

[replaceable]

anything except CoClass members and parameters

requestedit

[requestedit]

members except CoClass members

restricted

[restricted]

anything except parameters

source

[source]

all members

uidefault

[uidefault]

members except CoClass members

usesgetlasterror

[usesgetlasterror]

members except CoClass members

uuid

[uuid '{7B5687A1-F4E9-11D1-92A8-00C04F8C8FC4}' ]

type library, typeinfo (required)

vararg

[vararg]

members except CoClass members

version

[version 1.1]

type library, typeinfo

Interface syntax

The Delphi syntax for declaring interface type information has the form

interfacename = interface[(baseinterface)] [attributes]
functionlist
[propertymethodlist]
end;

For example, the following text declares an interface with two methods and one property:

Interface1 = interface (IDispatch)
  [uuid '{7B5687A1-F4E9-11D1-92A8-00C04F8C8FC4}', version 1.0]
  function Calculate(optional seed:Integer=0): Integer;
  procedure Reset;
  procedure PutRange(Range: Integer) [propput, dispid $00000005]; stdcall;
  function GetRange: Integer;[propget, dispid $00000005]; stdcall;
end;

The corresponding syntax in Microsoft IDL is

[uuid '{5FD36EEF-70E5-11D1-AA62-00C04FB16F42}',version 1.0]
interface Interface1 :IDispatch
{
  long Calculate([in, optional, defaultvalue(0)] long seed);
  void Reset(void);
  [propput, id(0x00000005)] void _stdcall PutRange([in] long Value);
  [propput, id(0x00000005)] void _stdcall getRange([out, retval] long *Value);
};

Dispatch interface syntax

The Delphi syntax for declaring dispinterface type information has the form

dispinterfacename = dispinterface [attributes]
functionlist
[propertylist]
end;

For example, the following text declares a dispinterface with the same methods and property as the previous interface:

MyDispObj = dispinterface
[uuid '{5FD36EEF-70E5-11D1-AA62-00C04FB16F42}',
  version 1.0,
  helpstring 'dispatch interface for MyObj'
  function Calculate(seed:Integer): Integer [dispid 1];
  procedure Reset [dispid 2];
  property Range: Integer [dispid 3];
end;

The corresponding syntax in Microsoft IDL is

[uuid '{5FD36EEF-70E5-11D1-AA62-00C04FB16F42}',
  version 1.0,
  helpstring "dispatch interface for MyObj"
dispinterface Interface1
{
  methods:
    [id(1)] int Calculate([in] int seed);
    [id(2)] void Reset(void);
  properties:
    [id(3)] int Value;
};

CoClass syntax

The Delphi syntax for declaring CoClass type information has the form

classname = coclass(interfacename[interfaceattributes], ...); [attributes];

For example, the following text declares a coclass for the interface IMyInt and dispinterface DmyInt:

myapp = coclass(IMyInt [source], DMyInt);
[uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
  version 1.0,
  helpstring 'A class',
  appobject]

The corresponding syntax in Microsoft IDL is

[uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
  version 1.0,
  helpstring "A class",
  appobject]
coclass myapp
{
  methods:
  [source] interface IMyInt);
  dispinterface DMyInt;
};

Enum syntax

The Delphi syntax for declaring Enum type information has the form

enumname = ([attributes] enumlist);

For example, the following text declares an enumerated type with three values:

location = ([uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
         helpstring 'location of booth']
  Inside = 1 [helpstring 'Inside the pavillion'];
  Outside = 2 [helpstring 'Outside the pavillion'];
  Offsite = 3 [helpstring 'Not near the pavillion'];);

The corresponding syntax in Microsoft IDL is

[uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
        helpstring "location of booth"]
typedef enum
{
  [helpstring "Inside the pavillion"] Inside = 1,
  [helpstring "Outside the pavillion"] Outside = 2,
  [helpstring "Not near the pavillion"] Offsite = 3
} location;

Alias syntax

The Delphi syntax for declaring Alias type information has the form

aliasname = basetype[attributes];

For example, the following text declares DWORD as an alias for integer:

DWORD = Integer [uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}'];

The corresponding syntax in Microsoft IDL is

[uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}'] typedef long DWORD;

Record syntax

The Delphi syntax for declaring Record type information has the form

recordname = record [attributes] fieldlist end;

For example, the following text declares a record:

Tasks = record [uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
                helpstring 'Task description']
  ID: Integer;
  StartDate: TDate;
  EndDate: TDate;
  Ownername: WideString;
  Subtasks: safearray of Integer;
end;

The corresponding syntax in Microsoft IDL is

[uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
        helpstring "Task description"]
typedef struct
{
  long ID;
  DATE StartDate;
  DATE EndDate;
  BSTR Ownername;
  SAFEARRAY (int) Subtasks;
} Tasks;

Union syntax

The Delphi syntax for declaring Union type information has the form

unionname = record [attributes]
case Integer of
  0: field1;
  1: field2;
  ...
end;

For example, the following text declares a union:

MyUnion = record [uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
                  helpstring "item description"]
case Integer of
  0: (Name: WideString);
  1: (ID: Integer);
  3: (Value: Double);
end;

The corresponding syntax in Microsoft IDL is

[uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
        helpstring "item description"]
typedef union
{
  BSTR Name;
  long ID;
  double Value;
  } MyUnion;

Module syntax

The Delphi syntax for declaring Module type information has the form

modulename = module constants entrypoints end;

For example, the following text declares the type information for a module:

MyModule = module [uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
                   dllname 'circle.dll']
  PI: Double = 3.14159;
  function area(radius: Double): Double [ entry 1 ]; stdcall;
  function circumference(radius: Double): Double [ entry 2 ]; stdcall;
end;

The corresponding syntax in Microsoft IDL is

[uuid '{2MD36ABF-90E3-11D1-AA75-02C04FB73F42}',
        dllname("circle.dll")]
module MyModule
{
  double PI = 3.14159;
  [entry(1)] double _stdcall area([in] double radius);
  [entry(2)] double _stdcall circumference([in] double radius);
};

Topics

See Also