Back to index

lightning-sunbird  0.9+nobinonly
nsObsoleteAString.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* vim:set ts=2 sw=2 sts=2 et cindent: */
00003 /* ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is Mozilla.
00017  *
00018  * The Initial Developer of the Original Code is IBM Corporation.
00019  * Portions created by IBM Corporation are Copyright (C) 2003
00020  * IBM Corporation. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Darin Fisher <darin@meer.net>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #ifndef nsObsoleteAString_h___
00040 #define nsObsoleteAString_h___
00041 
00042 /*
00043     STRING INTERNALS
00044 
00045     This file defines nsObsoleteAString and nsObsoleteACString.  These are
00046     abstract classes (interfaces), containing only virtual functions
00047     corresponding to the FROZEN nsA[C]String classes.  They exist to provide
00048     the new non-abstract nsA[C]String classes with a mechanism to maintain
00049     backwards binary compatability.
00050 
00051     From a binary point-of-view, the new nsA[C]String classes appear to have a
00052     vtable pointer to the vtable of nsObsoleteA[C]StringThunk.
00053     nsObsoleteA[C]StringThunk is a subclass of nsObsoleteA[C]String that serves
00054     as a simple bridge between the virtual functions that make up the FROZEN
00055     nsA[C]String contract and the new ns[C]Substring, which is now our only
00056     subclass of nsA[C]String.
00057 
00058     The methods on the new nsA[C]String are now all non-virtual.  This reduces
00059     codesize at the callsite, and reduces the number of memory dereferences and
00060     jumps required to invoke a method on nsA[C]String.  The result is improved
00061     performance and reduced codesize.  However, to maintain binary
00062     compatibility, each method on nsA[C]String must check the value of its
00063     vtable to determine if it corresponds to the built-in implementation of
00064     nsObsoleteA[C]String (i.e., the address of the canonical vtable).  If it
00065     does, then the vtable can be ignored, and the nsA[C]String object (i.e.,
00066     |this|) can be cast to ns[C]Substring directly.  In which case, the
00067     nsA[C]String methods can be satisfied by invoking the corresponding methods
00068     directly on ns[C]Substring.  If the vtable address does not correspond to
00069     the built-in implementation, then the virtual functions on
00070     nsObsoleteA[C]String must be invoked instead.
00071 
00072     So, if a nsA[C]String reference corresponds to an external implementation
00073     (such as the old nsEmbed[C]String that shipped with previous versions of
00074     Mozilla), then methods invoked on that nsA[C]String will still act like
00075     virtual function calls.  This ensures binary compatibility while avoiding
00076     virtual function calls in most cases.
00077 
00078     Finally, nsObsoleteA[C]String (i.e., the FROZEN nsA[C]String vtable) is
00079     now a DEPRECATED interface.  See nsStringAPI.h and nsEmbedString.h for
00080     the new preferred way to access nsA[C]String references in an external
00081     component or Gecko embedding application.
00082                                                                              */
00083 
00084 #ifndef nsStringFwd_h___
00085 #include "nsStringFwd.h"
00086 #endif
00087 
00088 #ifndef nscore_h___
00089 #include "nscore.h"
00090 #endif
00091 
00092   // declare nsObsoleteAString
00093 #include "string-template-def-unichar.h"
00094 #include "nsTObsoleteAString.h"
00095 #include "string-template-undef.h"
00096 
00097   // declare nsObsoleteACString
00098 #include "string-template-def-char.h"
00099 #include "nsTObsoleteAString.h"
00100 #include "string-template-undef.h"
00101 
00102 #endif // !defined(nsObsoleteAString_h___)