Bug 492139 - Expose the Variant publicly so consumers can also use it
authorShawn Wilsher <sdwilsh@shawnwilsher.com>
Thu, 11 Jun 2009 13:18:58 -0700
changeset 29094 3d731633296e34c8b2a6bb47fa97067eeceb270d
parent 29093 251582c0b6deca11ce20da555e8b6873b64d06f6
child 29095 90ac3a21ea497a0275f0c57ef3b07ecb601e1922
push idunknown
push userunknown
push dateunknown
bugs492139
milestone1.9.2a1pre
Bug 492139 - Expose the Variant publicly so consumers can also use it Actually makes this usable to things outside of the storage module. r=bsmedberg
storage/src/Makefile.in
storage/src/Variant.cpp
storage/src/Variant.h
storage/src/Variant_inl.h
--- a/storage/src/Makefile.in
+++ b/storage/src/Makefile.in
@@ -58,34 +58,36 @@ REQUIRES = xpcom \
            sqlite3 \
            js \
            xpconnect \
            necko \
            $(NULL)
 
 EXPORTS_NAMESPACES = mozilla/storage
 
-EXPORTS_mozilla/storage = Variant.h
+EXPORTS_mozilla/storage = \
+  Variant.h \
+  Variant_inl.h \
+  $(NULL)
 
 CPPSRCS = \
   mozStorageService.cpp \
   mozStorageConnection.cpp \
   mozStorageStatement.cpp \
   mozStorageStatementWrapper.cpp \
   mozStorageStatementParams.cpp \
   mozStorageStatementRow.cpp \
   mozStorageArgValueArray.cpp \
   mozStorageSQLFunctions.cpp \
   mozStorageRow.cpp \
   mozStorageResultSet.cpp \
   mozStorageError.cpp \
   mozStorageAsyncStatementExecution.cpp \
   mozStorageStatementJSHelper.cpp \
   mozStoragePrivateHelpers.cpp \
-  Variant.cpp \
   $(NULL)
 
 LOCAL_INCLUDES = \
 	$(SQLITE_CFLAGS)
 
 # This is the default value.  If we ever change it when compiling sqlite, we
 # will need to change it here as well.
 DEFINES += -DSQLITE_MAX_LIKE_PATTERN_LENGTH=50000
--- a/storage/src/Variant.h
+++ b/storage/src/Variant.h
@@ -32,18 +32,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#ifndef __mozStorageVariant_h__
-#define __mozStorageVariant_h__
+#ifndef mozilla_storage_Variant_h__
+#define mozilla_storage_Variant_h__
 
 #include <utility>
 
 #include "nsIVariant.h"
 #include "nsString.h"
 #include "nsTArray.h"
 
 /**
@@ -361,9 +361,11 @@ typedef Variant<double> FloatVariant;
 typedef Variant<nsString> TextVariant;
 typedef Variant<nsCString> UTF8TextVariant;
 typedef Variant<PRUint8[]> BlobVariant;
 typedef Variant_base NullVariant;
 
 } // namespace storage
 } // namespace mozilla
 
-#endif // __mozStorageVariant_h__
+#include "Variant_inl.h"
+
+#endif // mozilla_storage_Variant_h__
rename from storage/src/Variant.cpp
rename to storage/src/Variant_inl.h
--- a/storage/src/Variant.cpp
+++ b/storage/src/Variant_inl.h
@@ -32,188 +32,222 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "Variant.h"
+/**
+ * Note: This file is included by Variant.h.
+ */
+
+#ifndef mozilla_storage_Variant_h__
+#error "Do not include this file directly!"
+#endif
 
 namespace mozilla {
 namespace storage {
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Variant_base
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(
+inline NS_IMPL_THREADSAFE_ADDREF(Variant_base)
+inline NS_IMPL_THREADSAFE_RELEASE(Variant_base)
+inline NS_IMPL_THREADSAFE_QUERY_INTERFACE1(
   Variant_base,
   nsIVariant
 )
 
 ////////////////////////////////////////////////////////////////////////////////
 //// nsIVariant
 
+inline
 NS_IMETHODIMP
 Variant_base::GetDataType(PRUint16 *_type)
 {
   *_type = nsIDataType::VTYPE_EMPTY;
   return NS_OK;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsInt32(PRInt32 *)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsInt64(PRInt64 *)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsDouble(double *)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsAUTF8String(nsACString &)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsAString(nsAString &)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsArray(PRUint16 *,
                          nsIID *,
                          PRUint32 *,
                          void **)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsInt8(PRUint8 *)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsInt16(PRInt16 *)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsUint8(PRUint8 *)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsUint16(PRUint16 *)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsUint32(PRUint32 *)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsUint64(PRUint64 *)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsFloat(float *)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsBool(PRBool *)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsChar(char *)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsWChar(PRUnichar *)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsID(nsID *)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsDOMString(nsAString &)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsString(char **)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsWString(PRUnichar **)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsISupports(nsISupports **)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsInterface(nsIID **,
                              void **)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsACString(nsACString &)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsStringWithSize(PRUint32 *,
                                   char **)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
+inline
 NS_IMETHODIMP
 Variant_base::GetAsWStringWithSize(PRUint32 *,
                                    PRUnichar **)
 {
   return NS_ERROR_CANNOT_CONVERT_DATA;
 }
 
 } // namespace storage