Gecko:Obsolete API: Difference between revisions
(→Proposed Obsolete API: NS_NewAtom) |
|||
Line 17: | Line 17: | ||
= Proposed Obsolete API = | = Proposed Obsolete API = | ||
* NS_GET_IID | * NS_GET_IID, NS_DEFINE_IID, and T::GetIID, except when NS_GET_IID is used on a template parameter. | ||
** Instead, use function templates (like CallQueryInterface) or nsCOMPtr_helpers (like do_QueryInterface) to tie the XPCOM and C++ type systems together rather than casting between the two type systems. | ** Instead, use function templates (like CallQueryInterface) or nsCOMPtr_helpers (like do_QueryInterface) to tie the XPCOM and C++ type systems together rather than casting between the two type systems. | ||
* nsA[C]String | * nsA[C]String |
Revision as of 17:28, 11 October 2006
APIs that are declared as obsolete, by virtue of being on this list have their days numbered in the codebase. They will be removed at some point in the future. Because of this, no new code is allowed to use any of the classes, functions, or types that appear on this list, except if they must conform to an older interface that demands the usage of an obsolete type. Reviewers and superreviewers should become familiar with this list for this reason.
If at all possible, please provide a) a suggested alternate class or function that provides similar functionality; and b) a link to a bug for removing the obsolete API from the codebase. The bug should contain rationale for obsoleting that API. To propose an API for obsolescence, please file a bug and add it to the proposed obsolete API section.
Obsolete API
- nsIFileSpec, nsFileSpec
- FileSpec has various issues, including being limited to the system character set for filenames.
- Use nsIFile/nsILocalFile/nsILocalFile{In,Out}putStream
- https://bugzilla.mozilla.org/show_bug.cgi?id=38122
- nsIPref
- Use nsIPrefService/nsIPrefBranch/nsIPrefBranch2
- https://bugzilla.mozilla.org/show_bug.cgi?id=175193
- ns(I)SupportsArray, nsIEnumerator
- nsSupportsArray is very inefficient and has a bad API
- Use any of the arrays in The Mozilla Array Guide, or use nsTArray (which is missing from the guide)
Proposed Obsolete API
- NS_GET_IID, NS_DEFINE_IID, and T::GetIID, except when NS_GET_IID is used on a template parameter.
- Instead, use function templates (like CallQueryInterface) or nsCOMPtr_helpers (like do_QueryInterface) to tie the XPCOM and C++ type systems together rather than casting between the two type systems.
- nsA[C]String
- use ns[C]Substring when nsA[C]String is not required by existing APIs (although it is still required by XPCOM interfaces)
- NS_NewAtom, NS_NewPermanentAtom
- use do_GetAtom, do_GetPermanentAtom instead