You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



IDL Author's Guide - Generated Headers

Simple interface
    /* starting interface nsIFoo */
    class nsIFoo {
     public: 
    };
        
Interface parent declaration
    /* starting interface nsIFoo */
    class nsIFoo : public nsIParent {
     public: 
    };
        
Interfaces with IIDs
    /* starting interface nsIFoo */
    
    /* {00000000-0000-0000-c000-000000000046} */
    #define NS_IFOO_IID_STR "00000000-0000-0000-c000-000000000046"
    #define NS_IFOO_IID \
      {0x00000000, 0x0000, 0x0000, \
        { 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }}
    
    class nsIFoo : public nsIParent {
     public: 
      static const nsIID& IID() {
        static nsIID iid = NS_IFOO_IID;
        return iid;
      }
    };
        
Forward interface declarations
    class nsIForward; /* forward decl */
        
Method and attribute
    /* starting interface nsIFoo */
    class nsIFoo {
     public: 
    
      /* attribute long attr; */
      NS_IMETHOD GetAttr(PRInt32 *aAttr) = 0;
      NS_IMETHOD SetAttr(PRInt32 aAttr) = 0;
    
      /* void fun (); */
      NS_IMETHOD Fun() = 0;
    };
        
Method types
    /* starting interface nsIStringStuff */
    class nsIStringStuff {
     public: 
    
      /* void findStringLength (in string str, out long l); */
      NS_IMETHOD FindStringLength(char *str, PRInt32 *l) = 0;
    
      /* void concatenateStrings (in string str1, in string str2, out string result); */
      NS_IMETHOD ConcatenateStrings(char *str1, char *str2, char **result) = 0;
    
      /* void replaceChar (inout string str, in char from, in char to, in boolean foldCase); */
      NS_IMETHOD ReplaceChar(char **str, char from, char to, PRBool foldCase) = 0;
    };
        
Non-void return types
    /* starting interface nsINonVoidReturn */
    class nsINonVoidReturn {
     public: 
    
      /* string gimmeString (in string str, in long count); */
      NS_IMETHOD GimmeString(char *str, PRInt32 count, char **_retval) = 0;
    
      /* long gimmeLong (in boolean prime); */
      NS_IMETHOD GimmeLong(PRBool prime, PRInt32 *_retval) = 0;
    };
        
readonly attributes
    /* starting interface nsIThing */
    class nsIThing {
     public: 
    
      /* readonly attribute string lookButDontTouch; */
      NS_IMETHOD GetLookButDontTouch(char * *aLookButDontTouch) = 0;
    };
        

Mike Shaver
Last modified: Tue Oct 5 15:33:12 PDT 1999