Difference between revisions of "Researching XPIDL and IDL Technologies"

From CDOT Wiki
Jump to: navigation, search
(Interfaces)
(Methods)
Line 21: Line 21:
 
   attribute long attr;
 
   attribute long attr;
 
   void fun();
 
   void fun();
 +
};
 +
 +
Methods can have any number of in, out or inout parameters, with a variety of types.
 +
 +
In this example many parameters of different types and in an out specifications are seen
 +
 +
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);
 +
};
 +
 +
Attributes can be made read-only, by placing the read-only keyword infront of the the definition 
 +
interface nsIThing {
 +
  readonly attribute string lookButDontTouch;
 
  };
 
  };

Revision as of 13:05, 4 October 2006

Introduction

XPIDL stands for XP Interface Description Language. It is a specification for XPCOM which is a cross platform adapter description language. An adapter description language is used to describe an adapter which unrelated with its machine language. The description of the adapter can use specialized tools to handle automatoc generation of language that is unrelated to the adapter's specifications. Typically XPIDL is frequently used to generate C++ header files and typelib information.

Language

Interfaces

  An interface is declared with the interface keyword, and the simplest possible interface is  
 interface nsToolbar {
 };

To specify an interface's parent, follow the interface name with a colon and the parent name

interface nsIToolbar : nsIParent {
};

Methods

An interface can have both methods and attributes. Attributes are properties of interface objects that can be read and optionally set. The following example - Attributes, properties of interface objects, can be read and optionally set. - This is an example of an interface with one method (no return value, no parameters) named fun and an integer-valued attribute named attr

interface nsIFoo {
  attribute long attr;
  void fun();
};

Methods can have any number of in, out or inout parameters, with a variety of types.

In this example many parameters of different types and in an out specifications are seen

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);
};

Attributes can be made read-only, by placing the read-only keyword infront of the the definition

interface nsIThing {
  readonly attribute string lookButDontTouch;
};