![]() |
IDL Best PracticesWe're currently working on this documentation. New stuff will be added on an ongoing basis. Please send any questions or comments to netscape.public.mozilla.xpcom. enums and consts
Any interface that contains native or raw C++ types cannot be made scriptable. The XPIDL compiler will treat it as an error if an interface or method is marked as scriptable and it contains native or raw C++ types. Individual methods in an interface may be marked as not scriptable by using the [noscript] attribute before the problem method. Methods marked with [noscript] will not be available for use from scripting languages.
All strings that are returned through out parameters in C++ must be allocated using the nsIAllocator so that the string's lifetime can be managed by XPConnect. If a string is not allocated with nsIAllocator, then the string will get lost, resulting in a memory leak or crash. See the XPConnect FAQ item "How do I make 'out string' work right?" for details on how to properly pass strings out of a method. When choosing method names in your interface, it's best to use the interCaps style - leading lower case, subsequent units within the identifier capitalized. This matches existing JavaScript convention and will look natural to scripters. The dominant C++ method name convention within Mozilla is to use InterCaps style (leading upper case.) To support this, the xpidl compiler capitalizes method names when generating C++ headers. Even if you're creating IDL for an existing interface with an InterCaps C++ implementation, it's still best if you use interCaps. It'll look familiar to JavaScript authors, and your C++ will still work. [Rules and Syntax] [Best Practices] [Keywords] Mike Ang Mike McCabe Last modified: Tue Oct 5 14:45:25 PDT 1999 |
|||||||||||
|
Copyright © 1998-2000 The Mozilla Organization.
Last modified October 5, 1999. |
|||||||||||