![]() |
|
|
IDL Author's Guide - Rules and Syntax .
Interfaces
:
interface nsIFoo {
};
To specify an interface's parent, follow the interface name
with a colon and the parent name :
interface nsIFoo : nsIParent {
};
In XPCOM, all interfaces have an associated IID. Use the
identifier attribute syntax to
specify the uuid attribute:![]()
[
uuid(00000000-0000-0000-c000-000000000046)
]
interface nsIFoo : nsIParent {
};
If you wish to have a forward declaration for an interface,
simply omit the interface definition and all parent and
attribute data:![]()
interface nsIForward;
Methods and Attributes
:
interface nsIFoo {
attribute long attr;
void fun();
};
Methods can have any number of in, out or
inout parameters, with a variety of
types. The following interface
shows parameters of different types and
``in-out-ness''2 :
interface nsIStringStuff {
void FindStringLength(in string str, out long l);
void ConcatenateStrings(in string str1, in string str2,
out string result);
void ReplaceChar(inout string str, in char from, in char to,
in boolean foldCase);
};
You can specify a non-void return type for your
method, but you should be aware of the code-generation rules.
A non-void return type is converted to a trailing
out parameter when the C++ is generated :
interface nsINonVoidReturn {
string GimmeString(in string str, in long count);
long GimmeLong(in boolean prime);
};
Attributes can be made read-only, by prepending the
readonly keyword to the definition :
interface nsIThing {
readonly attribute string LookButDontTouch;
};
1: ``XP'' stands for ``cross-platform'', of course. 2: I crave a better name for this. Mike Shaver Last modified: Tue Feb 16 07:04:13 EST 1999
|
|||||||
| Copyright © 1998 The Mozilla Organization. | ||||||||