diff --git a/xpcom/ds/MANIFEST b/xpcom/ds/MANIFEST index e10cae7d8de7..b1b81578063a 100644 --- a/xpcom/ds/MANIFEST +++ b/xpcom/ds/MANIFEST @@ -21,6 +21,7 @@ nsQuickSort.h nsStr.h nsString.h nsString2.h +nsSupportsPrimitives.h nsTime.h nsUnitConversion.h nsVector.h diff --git a/xpcom/ds/Makefile.in b/xpcom/ds/Makefile.in index 3885bd8cd308..b96ff6c74011 100644 --- a/xpcom/ds/Makefile.in +++ b/xpcom/ds/Makefile.in @@ -36,6 +36,7 @@ XPIDLSRCS = \ nsIObserver.idl \ nsIObserverService.idl \ nsISupportsArray.idl \ + nsISupportsPrimitives.idl \ $(NULL) CPPSRCS = \ @@ -63,6 +64,7 @@ CPPSRCS = \ nsString2.cpp \ nsSupportsArray.cpp \ nsSupportsArrayEnumerator.cpp \ + nsSupportsPrimitives.cpp \ nsUnicharBuffer.cpp \ nsVariant.cpp \ nsVoidArray.cpp \ @@ -94,6 +96,7 @@ EXPORTS = \ nsStr.h \ nsString.h \ nsString2.h \ + nsSupportsPrimitives.h \ nsTime.h \ nsUnitConversion.h \ nsVector.h \ diff --git a/xpcom/ds/makefile.win b/xpcom/ds/makefile.win index ce93cc59e8b2..24b38353fa71 100644 --- a/xpcom/ds/makefile.win +++ b/xpcom/ds/makefile.win @@ -47,6 +47,7 @@ EXPORTS = \ nsStr.h \ nsString.h \ nsString2.h \ + nsSupportsPrimitives.h \ nsTime.h \ nsUnitConversion.h \ nsVector.h \ @@ -63,6 +64,7 @@ XPIDLSRCS = \ .\nsIObserver.idl \ .\nsIObserverService.idl \ .\nsISupportsArray.idl \ + .\nsISupportsPrimitives.idl \ $(NULL) ################################################################################ @@ -103,6 +105,7 @@ CPP_OBJS = \ .\$(OBJDIR)\nsString2.obj \ .\$(OBJDIR)\nsSupportsArray.obj \ .\$(OBJDIR)\nsSupportsArrayEnumerator.obj \ + .\$(OBJDIR)\nsSupportsPrimitives.obj \ .\$(OBJDIR)\nsUnicharBuffer.obj \ .\$(OBJDIR)\nsVariant.obj \ .\$(OBJDIR)\nsVoidArray.obj \ diff --git a/xpcom/ds/nsISupportsPrimitives.idl b/xpcom/ds/nsISupportsPrimitives.idl new file mode 100644 index 000000000000..8f4dcf22067f --- /dev/null +++ b/xpcom/ds/nsISupportsPrimitives.idl @@ -0,0 +1,218 @@ +/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +/* nsISupports wrappers for single primitive pieces of data. */ + +#include "nsISupports.idl" + +/** + * These first three are pointer types and do data copying + * using the nsIAllocator. Be careful! + */ + +[scriptable, uuid(d18290a0-4a1c-11d3-9890-006008962422)] +interface nsISupportsID : nsISupports +{ + attribute nsIDPtr data; +}; + +[scriptable, uuid(d65ff270-4a1c-11d3-9890-006008962422)] +interface nsISupportsString : nsISupports +{ + attribute string data; +}; + +[scriptable, uuid(d79dc970-4a1c-11d3-9890-006008962422)] +interface nsISupportsWString : nsISupports +{ + attribute wstring data; +}; + +/** + * The rest are truly primitive and are passed by value + */ + +[scriptable, uuid(ddc3b490-4a1c-11d3-9890-006008962422)] +interface nsISupportsPRBool : nsISupports +{ + attribute PRBool data; +}; + +[scriptable, uuid(dec2e4e0-4a1c-11d3-9890-006008962422)] +interface nsISupportsPRUint8 : nsISupports +{ + attribute PRUint8 data; +}; + +[scriptable, uuid(df403240-4a1c-11d3-9890-006008962422)] +interface nsISupportsPRUnichar : nsISupports +{ + attribute PRUnichar data; +}; + +[scriptable, uuid(dfacb090-4a1c-11d3-9890-006008962422)] +interface nsISupportsPRUint16 : nsISupports +{ + attribute PRUint16 data; +}; + +[scriptable, uuid(e01dc470-4a1c-11d3-9890-006008962422)] +interface nsISupportsPRUint32 : nsISupports +{ + attribute PRUint32 data; +}; + +[scriptable, uuid(e13567c0-4a1c-11d3-9890-006008962422)] +interface nsISupportsPRUint64 : nsISupports +{ + attribute PRUint64 data; +}; + +[scriptable, uuid(e2563630-4a1c-11d3-9890-006008962422)] +interface nsISupportsPRTime : nsISupports +{ + attribute PRTime data; +}; + +[scriptable, uuid(e2b05e40-4a1c-11d3-9890-006008962422)] +interface nsISupportsChar : nsISupports +{ + attribute char data; +}; + +[scriptable, uuid(e30d94b0-4a1c-11d3-9890-006008962422)] +interface nsISupportsPRInt16 : nsISupports +{ + attribute PRInt16 data; +}; + +[scriptable, uuid(e36c5250-4a1c-11d3-9890-006008962422)] +interface nsISupportsPRInt32 : nsISupports +{ + attribute PRInt32 data; +}; + +[scriptable, uuid(e3cb0ff0-4a1c-11d3-9890-006008962422)] +interface nsISupportsPRInt64 : nsISupports +{ + attribute PRInt64 data; +}; + +///////////////////////////////////////////////////////////////////////// + +%{C++ +// {ACF8DC40-4A25-11d3-9890-006008962422} +#define NS_SUPPORTS_ID_CID \ +{ 0xacf8dc40, 0x4a25, 0x11d3, \ + { 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } } +#define NS_SUPPORTS_ID_PROGID "component://netscape/supports-id" +#define NS_SUPPORTS_ID_CLASSNAME "Supports ID" + + +// {ACF8DC41-4A25-11d3-9890-006008962422} +#define NS_SUPPORTS_STRING_CID \ +{ 0xacf8dc41, 0x4a25, 0x11d3, \ + { 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } } +#define NS_SUPPORTS_STRING_PROGID "component://netscape/supports-string" +#define NS_SUPPORTS_STRING_CLASSNAME "Supports String" + +// {ACF8DC42-4A25-11d3-9890-006008962422} +#define NS_SUPPORTS_WSTRING_CID \ +{ 0xacf8dc42, 0x4a25, 0x11d3, \ + { 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } } +#define NS_SUPPORTS_WSTRING_PROGID "component://netscape/supports-wstring" +#define NS_SUPPORTS_WSTRING_CLASSNAME "Supports WString" + +// {ACF8DC43-4A25-11d3-9890-006008962422} +#define NS_SUPPORTS_PRBOOL_CID \ +{ 0xacf8dc43, 0x4a25, 0x11d3, \ + { 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } } +#define NS_SUPPORTS_PRBOOL_PROGID "component://netscape/supports-PRBool" +#define NS_SUPPORTS_PRBOOL_CLASSNAME "Supports PRBool" + +// {ACF8DC44-4A25-11d3-9890-006008962422} +#define NS_SUPPORTS_PRUINT8_CID \ +{ 0xacf8dc44, 0x4a25, 0x11d3, \ + { 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } } +#define NS_SUPPORTS_PRUINT8_PROGID "component://netscape/supports-PRUint8" +#define NS_SUPPORTS_PRUINT8_CLASSNAME "Supports PRUint8" + +// {ACF8DC45-4A25-11d3-9890-006008962422} +#define NS_SUPPORTS_PRUNICHAR_CID \ +{ 0xacf8dc45, 0x4a25, 0x11d3, \ + { 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } } +#define NS_SUPPORTS_PRUNICHAR_PROGID "component://netscape/supports-PRUnichar" +#define NS_SUPPORTS_PRUNICHAR_CLASSNAME "Supports PRUnichar" + +// {ACF8DC46-4A25-11d3-9890-006008962422} +#define NS_SUPPORTS_PRUINT16_CID \ +{ 0xacf8dc46, 0x4a25, 0x11d3, \ + { 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } } +#define NS_SUPPORTS_PRUINT16_PROGID "component://netscape/supports-PRUint16" +#define NS_SUPPORTS_PRUINT16_CLASSNAME "Supports PRUint16" + +// {ACF8DC47-4A25-11d3-9890-006008962422} +#define NS_SUPPORTS_PRUINT32_CID \ +{ 0xacf8dc47, 0x4a25, 0x11d3, \ + { 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } } +#define NS_SUPPORTS_PRUINT32_PROGID "component://netscape/supports-PRUint32" +#define NS_SUPPORTS_PRUINT32_CLASSNAME "Supports PRUint32" + +// {ACF8DC48-4A25-11d3-9890-006008962422} +#define NS_SUPPORTS_PRUINT64_CID \ +{ 0xacf8dc48, 0x4a25, 0x11d3, \ + { 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } } +#define NS_SUPPORTS_PRUINT64_PROGID "component://netscape/supports-PRUint64" +#define NS_SUPPORTS_PRUINT64_CLASSNAME "Supports PRUint64" + +// {ACF8DC49-4A25-11d3-9890-006008962422} +#define NS_SUPPORTS_PRTIME_CID \ +{ 0xacf8dc49, 0x4a25, 0x11d3, \ + { 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } } +#define NS_SUPPORTS_PRTIME_PROGID "component://netscape/supports-PRTime" +#define NS_SUPPORTS_PRTIME_CLASSNAME "Supports PRTime" + +// {ACF8DC4A-4A25-11d3-9890-006008962422} +#define NS_SUPPORTS_CHAR_CID \ +{ 0xacf8dc4a, 0x4a25, 0x11d3, \ + { 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } } +#define NS_SUPPORTS_CHAR_PROGID "component://netscape/supports-Char" +#define NS_SUPPORTS_CHAR_CLASSNAME "Supports Char" + +// {ACF8DC4B-4A25-11d3-9890-006008962422} +#define NS_SUPPORTS_PRInt16_CID \ +{ 0xacf8dc4b, 0x4a25, 0x11d3, \ + { 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } } +#define NS_SUPPORTS_PRInt16_PROGID "component://netscape/supports-PRInt16" +#define NS_SUPPORTS_PRInt16_CLASSNAME "Supports PRInt16" + +// {ACF8DC4C-4A25-11d3-9890-006008962422} +#define NS_SUPPORTS_PRInt32_CID \ +{ 0xacf8dc4c, 0x4a25, 0x11d3, \ + { 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } } +#define NS_SUPPORTS_PRInt32_PROGID "component://netscape/supports-PRInt32" +#define NS_SUPPORTS_PRInt32_CLASSNAME "Supports PRInt32" + +// {ACF8DC4D-4A25-11d3-9890-006008962422} +#define NS_SUPPORTS_PRInt64_CID \ +{ 0xacf8dc4d, 0x4a25, 0x11d3, \ + { 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } } +#define NS_SUPPORTS_PRInt64_PROGID "component://netscape/supports-PRInt64" +#define NS_SUPPORTS_PRInt64_CLASSNAME "Supports PRInt64" +%} + diff --git a/xpcom/ds/nsSupportsPrimitives.cpp b/xpcom/ds/nsSupportsPrimitives.cpp new file mode 100644 index 000000000000..3001887e208f --- /dev/null +++ b/xpcom/ds/nsSupportsPrimitives.cpp @@ -0,0 +1,499 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsSupportsPrimitives.h" +#include "nsCRT.h" +#include "nsIAllocator.h" + +/***************************************************************************/ + +NS_IMPL_ISUPPORTS(nsSupportsIDImpl, NS_GET_IID(nsISupportsID)) + +nsSupportsIDImpl::nsSupportsIDImpl() + : mData(nsnull) +{ + NS_INIT_ISUPPORTS(); + NS_ADDREF_THIS(); +} + +nsSupportsIDImpl::~nsSupportsIDImpl() +{ + if(mData) + nsAllocator::Free(mData); +} + +NS_IMETHODIMP nsSupportsIDImpl::GetData(nsID **aData) +{ + if(!aData) + { + NS_ASSERTION(0,"Bad pointer"); + return NS_ERROR_NULL_POINTER; + } + if(mData) + { + *aData = (nsID*) nsAllocator::Clone(mData, sizeof(nsID)); + return *aData ? NS_OK : NS_ERROR_OUT_OF_MEMORY; + } + else + { + *aData = nsnull; + return NS_OK; + } +} + +NS_IMETHODIMP nsSupportsIDImpl::SetData(nsID *aData) +{ + if(mData) + nsAllocator::Free(mData); + if(aData) + mData = (nsID*) nsAllocator::Clone(aData, sizeof(nsID)); + else + mData = nsnull; + return NS_OK; +} + +/***************************************************************************/ + +NS_IMPL_ISUPPORTS(nsSupportsStringImpl, NS_GET_IID(nsISupportsString)) + +nsSupportsStringImpl::nsSupportsStringImpl() + : mData(nsnull) +{ + NS_INIT_ISUPPORTS(); + NS_ADDREF_THIS(); +} + +nsSupportsStringImpl::~nsSupportsStringImpl() +{ + if(mData) + nsAllocator::Free(mData); +} + +NS_IMETHODIMP nsSupportsStringImpl::GetData(char **aData) +{ + if(!aData) + { + NS_ASSERTION(0,"Bad pointer"); + return NS_ERROR_NULL_POINTER; + } + if(mData) + { + *aData = (char*) nsAllocator::Clone(mData, + (nsCRT::strlen(mData)+1)*sizeof(char)); + return *aData ? NS_OK : NS_ERROR_OUT_OF_MEMORY; + } + else + { + *aData = nsnull; + return NS_OK; + } +} + +NS_IMETHODIMP nsSupportsStringImpl::SetData(char *aData) +{ + if(mData) + nsAllocator::Free(mData); + if(aData) + mData = (char*) nsAllocator::Clone(aData, + (nsCRT::strlen(aData)+1)*sizeof(char)); + else + mData = nsnull; + return NS_OK; +} + +/***************************************************************************/ + +NS_IMPL_ISUPPORTS(nsSupportsWStringImpl, NS_GET_IID(nsISupportsWString)) + +nsSupportsWStringImpl::nsSupportsWStringImpl() + : mData(nsnull) +{ + NS_INIT_ISUPPORTS(); + NS_ADDREF_THIS(); +} + +nsSupportsWStringImpl::~nsSupportsWStringImpl() +{ + if(mData) + nsAllocator::Free(mData); +} + +NS_IMETHODIMP nsSupportsWStringImpl::GetData(PRUnichar **aData) +{ + if(!aData) + { + NS_ASSERTION(0,"Bad pointer"); + return NS_ERROR_NULL_POINTER; + } + if(mData) + { + *aData = (PRUnichar*) nsAllocator::Clone(mData, + (nsCRT::strlen(mData)+1)*sizeof(PRUnichar)); + return *aData ? NS_OK : NS_ERROR_OUT_OF_MEMORY; + } + else + { + *aData = nsnull; + return NS_OK; + } +} + +NS_IMETHODIMP nsSupportsWStringImpl::SetData(PRUnichar *aData) +{ + if(mData) + nsAllocator::Free(mData); + if(aData) + mData = (PRUnichar*) nsAllocator::Clone(aData, + (nsCRT::strlen(aData)+1)*sizeof(PRUnichar)); + else + mData = nsnull; + return NS_OK; +} + +/***************************************************************************/ + +NS_IMPL_ISUPPORTS(nsSupportsPRBoolImpl, NS_GET_IID(nsISupportsPRBool)) + +nsSupportsPRBoolImpl::nsSupportsPRBoolImpl() + : mData(PR_FALSE) +{ + NS_INIT_ISUPPORTS(); + NS_ADDREF_THIS(); +} + +nsSupportsPRBoolImpl::~nsSupportsPRBoolImpl() {} + +NS_IMETHODIMP nsSupportsPRBoolImpl::GetData(PRBool *aData) +{ + if(!aData) + { + NS_ASSERTION(0,"Bad pointer"); + return NS_ERROR_NULL_POINTER; + } + *aData = mData; + return NS_OK; +} + +NS_IMETHODIMP nsSupportsPRBoolImpl::SetData(PRBool aData) +{ + mData = aData; + return NS_OK; +} + +/***************************************************************************/ + +NS_IMPL_ISUPPORTS(nsSupportsPRUint8Impl, NS_GET_IID(nsISupportsPRUint8)) + +nsSupportsPRUint8Impl::nsSupportsPRUint8Impl() + : mData(0) +{ + NS_INIT_ISUPPORTS(); + NS_ADDREF_THIS(); +} + +nsSupportsPRUint8Impl::~nsSupportsPRUint8Impl() {} + +NS_IMETHODIMP nsSupportsPRUint8Impl::GetData(PRUint8 *aData) +{ + if(!aData) + { + NS_ASSERTION(0,"Bad pointer"); + return NS_ERROR_NULL_POINTER; + } + *aData = mData; + return NS_OK; +} + +NS_IMETHODIMP nsSupportsPRUint8Impl::SetData(PRUint8 aData) +{ + mData = aData; + return NS_OK; +} + +/***************************************************************************/ + +NS_IMPL_ISUPPORTS(nsSupportsPRUnicharImpl, NS_GET_IID(nsISupportsPRUnichar)) + +nsSupportsPRUnicharImpl::nsSupportsPRUnicharImpl() + : mData(0) +{ + NS_INIT_ISUPPORTS(); + NS_ADDREF_THIS(); +} + +nsSupportsPRUnicharImpl::~nsSupportsPRUnicharImpl() {} + +NS_IMETHODIMP nsSupportsPRUnicharImpl::GetData(PRUint16 *aData) +{ + if(!aData) + { + NS_ASSERTION(0,"Bad pointer"); + return NS_ERROR_NULL_POINTER; + } + *aData = mData; + return NS_OK; +} + +NS_IMETHODIMP nsSupportsPRUnicharImpl::SetData(PRUint16 aData) +{ + mData = aData; + return NS_OK; +} + +/***************************************************************************/ + +NS_IMPL_ISUPPORTS(nsSupportsPRUint16Impl, NS_GET_IID(nsISupportsPRUint16)) + +nsSupportsPRUint16Impl::nsSupportsPRUint16Impl() + : mData(0) +{ + NS_INIT_ISUPPORTS(); + NS_ADDREF_THIS(); +} + +nsSupportsPRUint16Impl::~nsSupportsPRUint16Impl() {} + +NS_IMETHODIMP nsSupportsPRUint16Impl::GetData(PRUint16 *aData) +{ + if(!aData) + { + NS_ASSERTION(0,"Bad pointer"); + return NS_ERROR_NULL_POINTER; + } + *aData = mData; + return NS_OK; +} + +NS_IMETHODIMP nsSupportsPRUint16Impl::SetData(PRUint16 aData) +{ + mData = aData; + return NS_OK; +} + +/***************************************************************************/ + +NS_IMPL_ISUPPORTS(nsSupportsPRUint32Impl, NS_GET_IID(nsISupportsPRUint32)) + +nsSupportsPRUint32Impl::nsSupportsPRUint32Impl() + : mData(0) +{ + NS_INIT_ISUPPORTS(); + NS_ADDREF_THIS(); +} + +nsSupportsPRUint32Impl::~nsSupportsPRUint32Impl() {} + +NS_IMETHODIMP nsSupportsPRUint32Impl::GetData(PRUint32 *aData) +{ + if(!aData) + { + NS_ASSERTION(0,"Bad pointer"); + return NS_ERROR_NULL_POINTER; + } + *aData = mData; + return NS_OK; +} + +NS_IMETHODIMP nsSupportsPRUint32Impl::SetData(PRUint32 aData) +{ + mData = aData; + return NS_OK; +} + +/***************************************************************************/ + +NS_IMPL_ISUPPORTS(nsSupportsPRUint64Impl, NS_GET_IID(nsISupportsPRUint64)) + +nsSupportsPRUint64Impl::nsSupportsPRUint64Impl() + : mData(0) +{ + NS_INIT_ISUPPORTS(); + NS_ADDREF_THIS(); +} + +nsSupportsPRUint64Impl::~nsSupportsPRUint64Impl() {} + +NS_IMETHODIMP nsSupportsPRUint64Impl::GetData(PRUint64 *aData) +{ + if(!aData) + { + NS_ASSERTION(0,"Bad pointer"); + return NS_ERROR_NULL_POINTER; + } + *aData = mData; + return NS_OK; +} + +NS_IMETHODIMP nsSupportsPRUint64Impl::SetData(PRUint64 aData) +{ + mData = aData; + return NS_OK; +} + +/***************************************************************************/ + +NS_IMPL_ISUPPORTS(nsSupportsPRTimeImpl, NS_GET_IID(nsISupportsPRTime)) + +nsSupportsPRTimeImpl::nsSupportsPRTimeImpl() + : mData(0) +{ + NS_INIT_ISUPPORTS(); + NS_ADDREF_THIS(); +} + +nsSupportsPRTimeImpl::~nsSupportsPRTimeImpl() {} + +NS_IMETHODIMP nsSupportsPRTimeImpl::GetData(PRTime *aData) +{ + if(!aData) + { + NS_ASSERTION(0,"Bad pointer"); + return NS_ERROR_NULL_POINTER; + } + *aData = mData; + return NS_OK; +} + +NS_IMETHODIMP nsSupportsPRTimeImpl::SetData(PRTime aData) +{ + mData = aData; + return NS_OK; +} + +/***************************************************************************/ + +NS_IMPL_ISUPPORTS(nsSupportsCharImpl, NS_GET_IID(nsISupportsChar)) + +nsSupportsCharImpl::nsSupportsCharImpl() + : mData(0) +{ + NS_INIT_ISUPPORTS(); + NS_ADDREF_THIS(); +} + +nsSupportsCharImpl::~nsSupportsCharImpl() {} + +NS_IMETHODIMP nsSupportsCharImpl::GetData(char *aData) +{ + if(!aData) + { + NS_ASSERTION(0,"Bad pointer"); + return NS_ERROR_NULL_POINTER; + } + *aData = mData; + return NS_OK; +} + +NS_IMETHODIMP nsSupportsCharImpl::SetData(char aData) +{ + mData = aData; + return NS_OK; +} + +/***************************************************************************/ + +NS_IMPL_ISUPPORTS(nsSupportsPRInt16Impl, NS_GET_IID(nsISupportsPRInt16)) + +nsSupportsPRInt16Impl::nsSupportsPRInt16Impl() + : mData(0) +{ + NS_INIT_ISUPPORTS(); + NS_ADDREF_THIS(); +} + +nsSupportsPRInt16Impl::~nsSupportsPRInt16Impl() {} + +NS_IMETHODIMP nsSupportsPRInt16Impl::GetData(PRInt16 *aData) +{ + if(!aData) + { + NS_ASSERTION(0,"Bad pointer"); + return NS_ERROR_NULL_POINTER; + } + *aData = mData; + return NS_OK; +} + +NS_IMETHODIMP nsSupportsPRInt16Impl::SetData(PRInt16 aData) +{ + mData = aData; + return NS_OK; +} + +/***************************************************************************/ + +NS_IMPL_ISUPPORTS(nsSupportsPRInt32Impl, NS_GET_IID(nsISupportsPRInt32)) + +nsSupportsPRInt32Impl::nsSupportsPRInt32Impl() + : mData(0) +{ + NS_INIT_ISUPPORTS(); + NS_ADDREF_THIS(); +} + +nsSupportsPRInt32Impl::~nsSupportsPRInt32Impl() {} + +NS_IMETHODIMP nsSupportsPRInt32Impl::GetData(PRInt32 *aData) +{ + if(!aData) + { + NS_ASSERTION(0,"Bad pointer"); + return NS_ERROR_NULL_POINTER; + } + *aData = mData; + return NS_OK; +} + +NS_IMETHODIMP nsSupportsPRInt32Impl::SetData(PRInt32 aData) +{ + mData = aData; + return NS_OK; +} + +/***************************************************************************/ + +NS_IMPL_ISUPPORTS(nsSupportsPRInt64Impl, NS_GET_IID(nsISupportsPRInt64)) + +nsSupportsPRInt64Impl::nsSupportsPRInt64Impl() + : mData(0) +{ + NS_INIT_ISUPPORTS(); + NS_ADDREF_THIS(); +} + +nsSupportsPRInt64Impl::~nsSupportsPRInt64Impl() {} + +NS_IMETHODIMP nsSupportsPRInt64Impl::GetData(PRInt64 *aData) +{ + if(!aData) + { + NS_ASSERTION(0,"Bad pointer"); + return NS_ERROR_NULL_POINTER; + } + *aData = mData; + return NS_OK; +} + +NS_IMETHODIMP nsSupportsPRInt64Impl::SetData(PRInt64 aData) +{ + mData = aData; + return NS_OK; +} + +/***************************************************************************/ + diff --git a/xpcom/ds/nsSupportsPrimitives.h b/xpcom/ds/nsSupportsPrimitives.h new file mode 100644 index 000000000000..8861f1fc99fd --- /dev/null +++ b/xpcom/ds/nsSupportsPrimitives.h @@ -0,0 +1,263 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsSupportsPrimitives_h__ +#define nsSupportsPrimitives_h__ + +#include "nsISupportsPrimitives.h" + +class nsSupportsIDImpl : public nsISupportsID +{ +public: + NS_DECL_ISUPPORTS + + NS_IMETHOD GetData(nsID **aData); + NS_IMETHOD SetData(nsID *aData); + + nsSupportsIDImpl(); + virtual ~nsSupportsIDImpl(); + +private: + nsID *mData; +}; + +/***************************************************************************/ + +class nsSupportsStringImpl : public nsISupportsString +{ +public: + NS_DECL_ISUPPORTS + + NS_IMETHOD GetData(char **aData); + NS_IMETHOD SetData(char *aData); + + nsSupportsStringImpl(); + virtual ~nsSupportsStringImpl(); + +private: + char *mData; +}; + +/***************************************************************************/ + +class nsSupportsWStringImpl : public nsISupportsWString +{ +public: + NS_DECL_ISUPPORTS + + NS_IMETHOD GetData(PRUnichar **aData); + NS_IMETHOD SetData(PRUnichar *aData); + + nsSupportsWStringImpl(); + virtual ~nsSupportsWStringImpl(); + +private: + PRUnichar *mData; +}; + +/***************************************************************************/ + +class nsSupportsPRBoolImpl : public nsISupportsPRBool +{ +public: + NS_DECL_ISUPPORTS + + NS_IMETHOD GetData(PRBool *aData); + NS_IMETHOD SetData(PRBool aData); + + nsSupportsPRBoolImpl(); + virtual ~nsSupportsPRBoolImpl(); + +private: + PRBool mData; +}; + +/***************************************************************************/ + +class nsSupportsPRUint8Impl : public nsISupportsPRUint8 +{ +public: + NS_DECL_ISUPPORTS + + NS_IMETHOD GetData(PRUint8 *aData); + NS_IMETHOD SetData(PRUint8 aData); + + nsSupportsPRUint8Impl(); + virtual ~nsSupportsPRUint8Impl(); + +private: + PRUint8 mData; +}; + +/***************************************************************************/ + +class nsSupportsPRUnicharImpl : public nsISupportsPRUnichar +{ +public: + NS_DECL_ISUPPORTS + + NS_IMETHOD GetData(PRUint16 *aData); + NS_IMETHOD SetData(PRUint16 aData); + + nsSupportsPRUnicharImpl(); + virtual ~nsSupportsPRUnicharImpl(); + +private: + PRUint16 mData; +}; + +/***************************************************************************/ + +class nsSupportsPRUint16Impl : public nsISupportsPRUint16 +{ +public: + NS_DECL_ISUPPORTS + + NS_IMETHOD GetData(PRUint16 *aData); + NS_IMETHOD SetData(PRUint16 aData); + + nsSupportsPRUint16Impl(); + virtual ~nsSupportsPRUint16Impl(); + +private: + PRUint16 mData; +}; + +/***************************************************************************/ + +class nsSupportsPRUint32Impl : public nsISupportsPRUint32 +{ +public: + NS_DECL_ISUPPORTS + + NS_IMETHOD GetData(PRUint32 *aData); + NS_IMETHOD SetData(PRUint32 aData); + + nsSupportsPRUint32Impl(); + virtual ~nsSupportsPRUint32Impl(); + +private: + PRUint32 mData; +}; + +/***************************************************************************/ + +class nsSupportsPRUint64Impl : public nsISupportsPRUint64 +{ +public: + NS_DECL_ISUPPORTS + + NS_IMETHOD GetData(PRUint64 *aData); + NS_IMETHOD SetData(PRUint64 aData); + + nsSupportsPRUint64Impl(); + virtual ~nsSupportsPRUint64Impl(); + +private: + PRUint64 mData; +}; + +/***************************************************************************/ + +class nsSupportsPRTimeImpl : public nsISupportsPRTime +{ +public: + NS_DECL_ISUPPORTS + + NS_IMETHOD GetData(PRTime *aData); + NS_IMETHOD SetData(PRTime aData); + + nsSupportsPRTimeImpl(); + virtual ~nsSupportsPRTimeImpl(); + +private: + PRTime mData; +}; + +/***************************************************************************/ + +class nsSupportsCharImpl : public nsISupportsChar +{ +public: + NS_DECL_ISUPPORTS + + NS_IMETHOD GetData(char *aData); + NS_IMETHOD SetData(char aData); + + nsSupportsCharImpl(); + virtual ~nsSupportsCharImpl(); + +private: + char mData; +}; + +/***************************************************************************/ + +class nsSupportsPRInt16Impl : public nsISupportsPRInt16 +{ +public: + NS_DECL_ISUPPORTS + + NS_IMETHOD GetData(PRInt16 *aData); + NS_IMETHOD SetData(PRInt16 aData); + + nsSupportsPRInt16Impl(); + virtual ~nsSupportsPRInt16Impl(); + +private: + PRInt16 mData; +}; + +/***************************************************************************/ + +class nsSupportsPRInt32Impl : public nsISupportsPRInt32 +{ +public: + NS_DECL_ISUPPORTS + + NS_IMETHOD GetData(PRInt32 *aData); + NS_IMETHOD SetData(PRInt32 aData); + + nsSupportsPRInt32Impl(); + virtual ~nsSupportsPRInt32Impl(); + +private: + PRInt32 mData; +}; + +/***************************************************************************/ + +class nsSupportsPRInt64Impl : public nsISupportsPRInt64 +{ +public: + NS_DECL_ISUPPORTS + + NS_IMETHOD GetData(PRInt64 *aData); + NS_IMETHOD SetData(PRInt64 aData); + + nsSupportsPRInt64Impl(); + virtual ~nsSupportsPRInt64Impl(); + +private: + PRInt64 mData; +}; + + + + +#endif /* nsSupportsPrimitives_h__ */