IDL Syntax and Components - Prof. James Fawcett, Study notes of Engineering

An overview of idl (interface definition language) syntax, attributes, statement types, idl types, decorations, and interfaces. Idl is used to define interfaces for com (component object model) components in windows and win32 programming. It recognizes base types, allows importing definitions from other idl files, and uses preprocessor directives. Interfaces in idl are defined with specific qualifiers, pointer defaults, and method parameters with decorations.

Typology: Study notes

Pre 2010

Uploaded on 08/09/2009

koofers-user-pf0
koofers-user-pf0 🇺🇸

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
IDL Syntax
[attribute, …] statement name [:BaseInterfaceName]
{
[attribute, …] statementBlock;
};
attribute
1. Endpoint
specifies a “well-known” port on which servers of the interface listen
2. Helpstring
human readable comment string, e.g., helpstring(“this is a help string”)
3. Local
generate header files only – stubs are not generated
4. Object
identifies a custom COM interface – must be followed by a uuid
5. pointer_default
pointer attribute to be applied to an unattributed pointer specification
ptr full pointer functionality
ref a reference, never null, always points to valid storage, can
not be reset
unique can be null and can be reset, but can not be used as aliases,
e.g., data referenced by the pointer is unique to the pointer
6. uuid
text representation of a universally unique identifier
7. version
specifies version of the interface, e.g., version(1.1)
statement name:
1. coclass
specify a list of intefaces supported by a COM component
2. dispinterface
generate an interface derived from idispatch, used for automation
3. interface
used to generate a COM interface
4. library
generate a type library from the statement block
5. module
defines a set of functions when generating a DLL
6. enum, typedef, struct, union
C-like language declarations, used to describe interface parameters
pf3
pf4

Partial preview of the text

Download IDL Syntax and Components - Prof. James Fawcett and more Study notes Engineering in PDF only on Docsity!

IDL Syntax

[attribute, …] statement name [:BaseInterfaceName]

[attribute, …] statementBlock;

attribute

  1. Endpoint specifies a “well-known” port on which servers of the interface listen
  2. Helpstring human readable comment string, e.g., helpstring(“this is a help string”)
  3. Local generate header files only – stubs are not generated
  4. Object identifies a custom COM interface – must be followed by a uuid
  5. pointer_default pointer attribute to be applied to an unattributed pointer specification  ptr full pointer functionality  ref a reference, never null, always points to valid storage, can not be reset  unique can be null and can be reset, but can not be used as aliases, e.g., data referenced by the pointer is unique to the pointer
  6. uuid text representation of a universally unique identifier
  7. version specifies version of the interface, e.g., version(1.1)

statement name:

  1. coclass specify a list of intefaces supported by a COM component
  2. dispinterface generate an interface derived from idispatch, used for automation
  3. interface used to generate a COM interface
  4. library generate a type library from the statement block
  5. module defines a set of functions when generating a DLL
  6. enum, typedef, struct, union C-like language declarations, used to describe interface parameters

Interfaces

An interface defined in IDL takes the form: [ object, uuid(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx), pointer_default(unique) ] interface IanInterface : IUnknown { HRESULT transform([in] long, [in] long, [out, retval] long); HRESULT getProperty([out] long); HRESULT setProperty([in] long); };

  1. The qualifier object specifies that the interface belongs to a COM object.
  2. uuid(arg) identifies its argument as the GUID associated with this interface
  3. pointer_default(arg) identifies its argument as the default type for unattributed pointers
  4. the unique argument describes the default pointer is having no aliases. That is, it can be null, be set to any address, but there will only be one pointer for any given memory allocation, e.g., the pointer is unique.
  5. The decorations on method parameters help COM marshal data efficiently, and have the following meanings:  in describes the parameter as sending data to the method, but returning nothing  out declares the parameter to have no significant input value, but will return data to the client  retval specifies that Visual Basic and Java implementations of this interface will send this data to the client as a method return type. It has no signficance for C or C++ (the value is returned as a side effect of the argument)
  6. All user defined interface methods should return HRESULT to identify success or failure and failure mode. Clients should test for success with the macros SUCEEDED(hr) and FAILED(hr).