XPIDL keywords
XPIDL defines many keywords, some of which must appear as annotations inside square brackets ([]).
Keyword | Purpose | Example |
---|---|---|
interface | declare interface | interface foo : public nsISupports { }; |
attribute | for 'properties' (generates getter and setter) | inteface foo { attribute short bar; |
readonly | Modify attribute to not be settable. No setter signature is generated in C++ and the attribute is not settable from JavaScript. |
readonly attribute short myAttribute; |
[uuid()] | associate uuid with interface.
Note: uuids must be generated by uuidgen or guidgen. Do not cut and paste uuids. | [uuid(00000000-0000-0000-c000-000000000046)] interface foo { }; |
[scriptable] | mark interface as scriptable | [scriptable] interface foo { }; |
const | Declares a constant value inside an interface. | interface foo { const short bar = 5; }; |
[const] | Marks a parameter as const | void foo([const] in voidStar bar); |
native | Used to declare native types | native myName(nsFileSpec); |
[ptr] | Used in native decl to make it a pointer type |
[ptr] native nsFileSpecPtr(nsFileSpec); |
[ref] | Used in native decl to make it a C++ reference type |
[ref] native nsNativeFileRef(nsFileSpec); |
[nsid] | Used in native decl to say that this is an nsID |
From nsrootidl.idl
[ref, nsid] native nsIDRef(nsID); |
[retval] | declare that an out parameter is the
"return value" for the method. This information can be used by connection
technologies such as XPConnect so that calls to the method return the value
passed out through this parameter.
The only way to tag a return value with other annotations is to use [retval] combined with the other annotation. |
QueryInterface in
nsISupports.idl:interface nsISupports { void QueryInterface(in nsIIDRef uuid, [iid_is(uuid),retval] out nsQIResult result); [...] }; |
[shared] | Used to indicate that this pointer type out param does not follow the normal transfer of ownership rules. | |
[iid_is] | Used to declare that some other param indicates (at runtime) the interface type for this out param. You almost certainly won't need to use this. |
QueryInterface in
nsISupports.idl:interface nsISupports { void QueryInterface(in nsIIDRef uuid, [iid_is(uuid),retval] out nsQIResult result); [...] }; |
[notxpcom] | Indicates that this method does not return an nsresult. Use of this annotation implies that you are breaking the rules of XPCOM, and
hence use of this annotation is discouraged.
|
AddRef and Release in
nsISupports.idl:interface nsISupports { [...] [noscript, notxpcom] nsrefcnt AddRef(); [noscript, notxpcom] nsrefcnt Release(); }; |
[noscript] | Marks a method as not scriptable. This must be used on those methods that cannot be scripted (due to the use of native types, for example), when an interface has be marked as scriptable. | |
in | Marks an "in" parameter. | |
out | Marks an "out" parameter. | |
inout | Marks an "inout" parameter. | |
%{C++ %} | The text inside the %{C++ %} escape sequence is copied directly into the C++ header file. The start and end sequences "%{C++" and "%}" must occur alone at the beginning of separate lines. | %{C++ // This text is copied into the generated .h file %} |
[Rules and Syntax] [Best Practices] [Keywords]
Mike Ang Last modified: Fri Aug 20 13:40:43 PDT 1999