2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1999-08-04 10:57:38 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
1999-08-04 10:57:38 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-08-04 10:57:38 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:43:54 +03:00
|
|
|
*
|
2001-05-10 06:44:35 +04:00
|
|
|
* Contributor(s):
|
|
|
|
* Dan Rosen <dr@netscape.com>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, 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 NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
#include "nsSupportsPrimitives.h"
|
|
|
|
#include "nsCRT.h"
|
2000-06-03 13:46:12 +04:00
|
|
|
#include "nsMemory.h"
|
1999-08-06 13:42:12 +04:00
|
|
|
#include "prprf.h"
|
2001-04-10 07:56:48 +04:00
|
|
|
#include "nsIInterfaceInfoManager.h"
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsIDImpl, nsISupportsID, nsISupportsPrimitive)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsIDImpl::nsSupportsIDImpl()
|
|
|
|
: mData(nsnull)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsIDImpl::~nsSupportsIDImpl()
|
|
|
|
{
|
|
|
|
if(mData)
|
2000-06-03 13:46:12 +04:00
|
|
|
nsMemory::Free(mData);
|
1999-08-04 10:57:38 +04:00
|
|
|
}
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMETHODIMP nsSupportsIDImpl::GetType(PRUint16 *aType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_ID;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsIDImpl::GetData(nsID **aData)
|
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(aData, "Bad pointer");
|
1999-08-04 10:57:38 +04:00
|
|
|
if(mData)
|
|
|
|
{
|
2000-06-03 13:46:12 +04:00
|
|
|
*aData = (nsID*) nsMemory::Clone(mData, sizeof(nsID));
|
1999-08-04 10:57:38 +04:00
|
|
|
return *aData ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2002-01-04 02:47:55 +03:00
|
|
|
*aData = nsnull;
|
|
|
|
return NS_OK;
|
1999-08-04 10:57:38 +04:00
|
|
|
}
|
|
|
|
|
1999-09-20 03:46:35 +04:00
|
|
|
NS_IMETHODIMP nsSupportsIDImpl::SetData(const nsID *aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
if(mData)
|
2000-06-03 13:46:12 +04:00
|
|
|
nsMemory::Free(mData);
|
1999-08-04 10:57:38 +04:00
|
|
|
if(aData)
|
2000-06-03 13:46:12 +04:00
|
|
|
mData = (nsID*) nsMemory::Clone(aData, sizeof(nsID));
|
1999-08-04 10:57:38 +04:00
|
|
|
else
|
|
|
|
mData = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsIDImpl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
2002-01-04 02:47:55 +03:00
|
|
|
char* result;
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(_retval, "Bad pointer");
|
1999-08-06 13:42:12 +04:00
|
|
|
if(mData)
|
|
|
|
{
|
2002-01-04 02:47:55 +03:00
|
|
|
result = mData->ToString();
|
1999-08-06 13:42:12 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-01-04 02:47:55 +03:00
|
|
|
static const char nullStr[] = "null";
|
|
|
|
result = (char*) nsMemory::Clone(nullStr, sizeof(nullStr));
|
1999-08-06 13:42:12 +04:00
|
|
|
}
|
1999-08-20 07:14:46 +04:00
|
|
|
|
|
|
|
*_retval = result;
|
|
|
|
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
1999-08-06 13:42:12 +04:00
|
|
|
}
|
|
|
|
|
2001-05-10 06:44:35 +04:00
|
|
|
/*****************************************************************************
|
|
|
|
* nsSupportsStringImpl
|
|
|
|
*****************************************************************************/
|
1999-08-04 10:57:38 +04:00
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsStringImpl, nsISupportsString,
|
|
|
|
nsISupportsPrimitive)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsStringImpl::nsSupportsStringImpl()
|
2001-05-11 03:05:44 +04:00
|
|
|
: mData(0), mLength(0)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsStringImpl::~nsSupportsStringImpl()
|
|
|
|
{
|
2001-05-10 06:44:35 +04:00
|
|
|
if (mData)
|
|
|
|
nsMemory::Free(mData);
|
1999-08-04 10:57:38 +04:00
|
|
|
}
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMETHODIMP nsSupportsStringImpl::GetType(PRUint16 *aType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
|
2001-05-10 06:44:35 +04:00
|
|
|
*aType = TYPE_STRING;
|
2001-03-23 06:09:49 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsStringImpl::GetData(char **aData)
|
|
|
|
{
|
2001-05-10 06:44:35 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
// copy the buffer
|
|
|
|
if (mData) {
|
|
|
|
size_t size((mLength + 1) * sizeof(char));
|
|
|
|
*aData = NS_STATIC_CAST(char*, nsMemory::Clone(mData, size));
|
|
|
|
if (!(*aData))
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
1999-08-04 10:57:38 +04:00
|
|
|
}
|
2002-01-04 02:47:55 +03:00
|
|
|
else
|
|
|
|
*aData = nsnull;
|
2001-05-10 06:44:35 +04:00
|
|
|
|
|
|
|
return rv;
|
1999-08-04 10:57:38 +04:00
|
|
|
}
|
|
|
|
|
1999-09-20 03:46:35 +04:00
|
|
|
NS_IMETHODIMP nsSupportsStringImpl::SetData(const char *aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
1999-12-01 01:06:05 +03:00
|
|
|
return SetDataWithLength(aData ? nsCRT::strlen(aData) : 0, aData);
|
1999-08-04 10:57:38 +04:00
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsStringImpl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
|
|
|
return GetData(_retval);
|
2001-05-10 06:44:35 +04:00
|
|
|
}
|
1999-08-06 13:42:12 +04:00
|
|
|
|
2001-05-10 10:30:39 +04:00
|
|
|
NS_IMETHODIMP nsSupportsStringImpl::SetDataWithLength(PRUint32 aLength,
|
2001-05-10 06:44:35 +04:00
|
|
|
const char *aData)
|
1999-12-01 01:06:05 +03:00
|
|
|
{
|
2001-05-10 06:44:35 +04:00
|
|
|
// if the new string length is the same as the old,
|
2001-05-11 03:05:44 +04:00
|
|
|
// just copy into the old buffer to avoid reallocating. we
|
|
|
|
// can further avoid reallocating by reusing the same
|
|
|
|
// buffer if aLength <= mLength, but there's high potential
|
|
|
|
// for bloat there. see bug 80097 for discussion.
|
|
|
|
if ((aLength == mLength) && aData && mData) {
|
2002-01-12 06:18:55 +03:00
|
|
|
memcpy(mData, aData, aLength * sizeof(char));
|
2001-05-10 06:44:35 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// otherwise, we'll have to allocate a new buffer, copy
|
|
|
|
// into that new buffer, and adopt it
|
2001-05-10 08:13:45 +04:00
|
|
|
char* newData = nsnull;
|
2001-05-10 06:44:35 +04:00
|
|
|
if (aData) {
|
|
|
|
// allocate a new buffer
|
|
|
|
size_t size((aLength + 1) * sizeof(char));
|
|
|
|
newData = NS_STATIC_CAST(char*, nsMemory::Alloc(size));
|
2002-01-04 02:47:55 +03:00
|
|
|
if (!newData)
|
2001-05-10 06:44:35 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2002-01-04 02:47:55 +03:00
|
|
|
// copy into that buffer if it was successfully allocated
|
2002-01-12 06:18:55 +03:00
|
|
|
memcpy(newData, aData, aLength * sizeof(char));
|
2001-05-10 06:44:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// if we've succeeded so far, adopt the new buffer. the adopt
|
|
|
|
// function handles the null buffer case
|
|
|
|
return AdoptDataWithLength(aLength, newData);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsStringImpl::AdoptData(char *aData)
|
|
|
|
{
|
|
|
|
return AdoptDataWithLength(aData ? nsCRT::strlen(aData) : 0, aData);
|
|
|
|
}
|
|
|
|
|
2001-05-10 10:30:39 +04:00
|
|
|
NS_IMETHODIMP nsSupportsStringImpl::AdoptDataWithLength(PRUint32 aLength,
|
2001-05-10 06:44:35 +04:00
|
|
|
char *aData)
|
|
|
|
{
|
|
|
|
// free current buffer
|
|
|
|
if (mData)
|
|
|
|
nsMemory::Free(mData);
|
|
|
|
|
|
|
|
// subsume new buffer, null or not
|
|
|
|
mData = aData;
|
|
|
|
|
|
|
|
if (mData) {
|
|
|
|
// set length of new buffer
|
|
|
|
mLength = aLength;
|
|
|
|
// always make sure we're null-terminated
|
2002-01-04 02:47:55 +03:00
|
|
|
mData[mLength] = '\0';
|
1999-12-01 01:06:05 +03:00
|
|
|
}
|
|
|
|
else
|
2001-05-10 06:44:35 +04:00
|
|
|
mLength = 0;
|
|
|
|
|
1999-12-01 01:06:05 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-05-10 06:44:35 +04:00
|
|
|
/*****************************************************************************
|
|
|
|
* nsSupportsWStringImpl
|
|
|
|
*****************************************************************************/
|
1999-08-04 10:57:38 +04:00
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsWStringImpl, nsISupportsWString,
|
|
|
|
nsISupportsPrimitive)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsWStringImpl::nsSupportsWStringImpl()
|
2001-05-11 03:05:44 +04:00
|
|
|
: mData(0), mLength(0)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsWStringImpl::~nsSupportsWStringImpl()
|
|
|
|
{
|
2001-05-10 06:44:35 +04:00
|
|
|
if (mData)
|
|
|
|
nsMemory::Free(mData);
|
1999-08-04 10:57:38 +04:00
|
|
|
}
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMETHODIMP nsSupportsWStringImpl::GetType(PRUint16 *aType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
|
2001-05-10 06:44:35 +04:00
|
|
|
*aType = TYPE_WSTRING;
|
2001-03-23 06:09:49 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsWStringImpl::GetData(PRUnichar **aData)
|
|
|
|
{
|
2001-05-10 06:44:35 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
// copy the buffer
|
|
|
|
if (mData) {
|
|
|
|
size_t size((mLength + 1) * sizeof(PRUnichar));
|
|
|
|
*aData = NS_STATIC_CAST(PRUnichar*, nsMemory::Clone(mData, size));
|
|
|
|
if (!(*aData))
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
1999-08-04 10:57:38 +04:00
|
|
|
}
|
2002-01-04 02:47:55 +03:00
|
|
|
else
|
|
|
|
*aData = nsnull;
|
2001-05-10 06:44:35 +04:00
|
|
|
|
|
|
|
return rv;
|
1999-08-04 10:57:38 +04:00
|
|
|
}
|
|
|
|
|
1999-09-20 03:46:35 +04:00
|
|
|
NS_IMETHODIMP nsSupportsWStringImpl::SetData(const PRUnichar *aData)
|
1999-12-01 01:06:05 +03:00
|
|
|
{
|
|
|
|
return SetDataWithLength(aData ? nsCRT::strlen(aData) : 0, aData);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsWStringImpl::ToString(PRUnichar **_retval)
|
|
|
|
{
|
|
|
|
return GetData(_retval);
|
2001-05-10 06:44:35 +04:00
|
|
|
}
|
1999-12-01 01:06:05 +03:00
|
|
|
|
2001-05-10 10:30:39 +04:00
|
|
|
NS_IMETHODIMP nsSupportsWStringImpl::SetDataWithLength(PRUint32 aLength,
|
2001-05-10 06:44:35 +04:00
|
|
|
const PRUnichar *aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
2001-05-10 06:44:35 +04:00
|
|
|
// if the new string length is the same as the old,
|
2001-05-11 03:05:44 +04:00
|
|
|
// just copy into the old buffer to avoid reallocating. we
|
|
|
|
// can further avoid reallocating by reusing the same
|
|
|
|
// buffer if aLength <= mLength, but there's high potential
|
|
|
|
// for bloat there. see bug 80097 for discussion.
|
|
|
|
if ((aLength == mLength) && aData && mData) {
|
2002-01-12 06:18:55 +03:00
|
|
|
memcpy(mData, aData, aLength * sizeof(PRUnichar));
|
2001-05-10 06:44:35 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// otherwise, we'll have to allocate a new buffer, copy
|
|
|
|
// into that new buffer, and adopt it
|
2001-05-10 08:13:45 +04:00
|
|
|
PRUnichar* newData = nsnull;
|
2001-05-10 06:44:35 +04:00
|
|
|
if (aData) {
|
|
|
|
// allocate a new buffer
|
|
|
|
size_t size((aLength + 1) * sizeof(PRUnichar));
|
|
|
|
newData = NS_STATIC_CAST(PRUnichar*, nsMemory::Alloc(size));
|
2002-01-04 02:47:55 +03:00
|
|
|
if (!newData)
|
2001-05-10 06:44:35 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2002-01-04 02:47:55 +03:00
|
|
|
// copy into that buffer if it was successfully allocated
|
2002-01-12 06:18:55 +03:00
|
|
|
memcpy(newData, aData, aLength * sizeof(PRUnichar));
|
2001-05-10 06:44:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// if we've succeeded so far, adopt the new buffer. the adopt
|
|
|
|
// function handles the null buffer case
|
|
|
|
return AdoptDataWithLength(aLength, newData);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsWStringImpl::AdoptData(PRUnichar *aData)
|
|
|
|
{
|
|
|
|
return AdoptDataWithLength(aData ? nsCRT::strlen(aData) : 0, aData);
|
|
|
|
}
|
|
|
|
|
2001-05-10 10:30:39 +04:00
|
|
|
NS_IMETHODIMP nsSupportsWStringImpl::AdoptDataWithLength(PRUint32 aLength,
|
2001-05-10 06:44:35 +04:00
|
|
|
PRUnichar *aData)
|
|
|
|
{
|
|
|
|
// free current buffer
|
|
|
|
if (mData)
|
|
|
|
nsMemory::Free(mData);
|
|
|
|
|
|
|
|
// subsume new buffer, null or not
|
|
|
|
mData = aData;
|
|
|
|
|
|
|
|
if (mData) {
|
|
|
|
// set length of new buffer
|
|
|
|
mLength = aLength;
|
|
|
|
// always make sure we're null-terminated
|
|
|
|
mData[mLength] = NS_STATIC_CAST(PRUnichar, 0);
|
1999-12-01 01:06:05 +03:00
|
|
|
}
|
1999-08-04 10:57:38 +04:00
|
|
|
else
|
2001-05-10 06:44:35 +04:00
|
|
|
mLength = 0;
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsPRBoolImpl, nsISupportsPRBool,
|
|
|
|
nsISupportsPrimitive)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsPRBoolImpl::nsSupportsPRBoolImpl()
|
|
|
|
: mData(PR_FALSE)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsPRBoolImpl::~nsSupportsPRBoolImpl() {}
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMETHODIMP nsSupportsPRBoolImpl::GetType(PRUint16 *aType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_PRBOOL;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRBoolImpl::GetData(PRBool *aData)
|
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(aData, "Bad pointer");
|
1999-08-04 10:57:38 +04:00
|
|
|
*aData = mData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsPRBoolImpl::SetData(PRBool aData)
|
|
|
|
{
|
|
|
|
mData = aData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRBoolImpl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(_retval, "Bad pointer");
|
1999-08-06 13:42:12 +04:00
|
|
|
const char * str = mData ? "true" : "false";
|
2000-06-03 13:46:12 +04:00
|
|
|
char* result = (char*) nsMemory::Clone(str,
|
1999-08-06 13:42:12 +04:00
|
|
|
(nsCRT::strlen(str)+1)*sizeof(char));
|
1999-08-20 07:14:46 +04:00
|
|
|
*_retval = result;
|
|
|
|
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
1999-08-06 13:42:12 +04:00
|
|
|
}
|
|
|
|
|
2000-04-12 04:46:58 +04:00
|
|
|
NS_COM nsresult
|
|
|
|
NS_NewISupportsPRBool (nsISupportsPRBool ** aResult)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER (aResult);
|
|
|
|
nsISupportsPRBool * rval = (nsISupportsPRBool *) (new nsSupportsPRBoolImpl ());
|
|
|
|
|
|
|
|
if (!rval)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
NS_ADDREF (rval);
|
|
|
|
*aResult = rval;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
/***************************************************************************/
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsPRUint8Impl, nsISupportsPRUint8,
|
|
|
|
nsISupportsPrimitive)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsPRUint8Impl::nsSupportsPRUint8Impl()
|
|
|
|
: mData(0)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsPRUint8Impl::~nsSupportsPRUint8Impl() {}
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint8Impl::GetType(PRUint16 *aType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_PRUINT8;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint8Impl::GetData(PRUint8 *aData)
|
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(aData, "Bad pointer");
|
1999-08-04 10:57:38 +04:00
|
|
|
*aData = mData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsPRUint8Impl::SetData(PRUint8 aData)
|
|
|
|
{
|
|
|
|
mData = aData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint8Impl::ToString(char **_retval)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(_retval, "Bad pointer");
|
1999-08-06 13:42:12 +04:00
|
|
|
static const int size = 8;
|
|
|
|
char buf[size];
|
1999-08-04 10:57:38 +04:00
|
|
|
|
1999-08-06 13:42:12 +04:00
|
|
|
PR_snprintf(buf, size, "%u", (PRUint16) mData);
|
|
|
|
|
2000-06-03 13:46:12 +04:00
|
|
|
char* result = (char*) nsMemory::Clone(buf,
|
1999-08-06 13:42:12 +04:00
|
|
|
(nsCRT::strlen(buf)+1)*sizeof(char));
|
1999-08-20 07:14:46 +04:00
|
|
|
*_retval = result;
|
|
|
|
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
1999-08-06 13:42:12 +04:00
|
|
|
}
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsPRUint16Impl, nsISupportsPRUint16,
|
|
|
|
nsISupportsPrimitive)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsPRUint16Impl::nsSupportsPRUint16Impl()
|
|
|
|
: mData(0)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsPRUint16Impl::~nsSupportsPRUint16Impl() {}
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint16Impl::GetType(PRUint16 *aType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_PRUINT16;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint16Impl::GetData(PRUint16 *aData)
|
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(aData, "Bad pointer");
|
1999-08-04 10:57:38 +04:00
|
|
|
*aData = mData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsPRUint16Impl::SetData(PRUint16 aData)
|
|
|
|
{
|
|
|
|
mData = aData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint16Impl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(_retval, "Bad pointer");
|
1999-08-06 13:42:12 +04:00
|
|
|
static const int size = 8;
|
|
|
|
char buf[size];
|
|
|
|
|
|
|
|
PR_snprintf(buf, size, "%u", (int) mData);
|
|
|
|
|
2000-06-03 13:46:12 +04:00
|
|
|
char* result = (char*) nsMemory::Clone(buf,
|
1999-08-06 13:42:12 +04:00
|
|
|
(nsCRT::strlen(buf)+1)*sizeof(char));
|
1999-08-20 07:14:46 +04:00
|
|
|
*_retval = result;
|
|
|
|
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
1999-08-06 13:42:12 +04:00
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
/***************************************************************************/
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsPRUint32Impl, nsISupportsPRUint32,
|
|
|
|
nsISupportsPrimitive)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsPRUint32Impl::nsSupportsPRUint32Impl()
|
|
|
|
: mData(0)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsPRUint32Impl::~nsSupportsPRUint32Impl() {}
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint32Impl::GetType(PRUint16 *aType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_PRUINT32;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint32Impl::GetData(PRUint32 *aData)
|
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(aData, "Bad pointer");
|
1999-08-04 10:57:38 +04:00
|
|
|
*aData = mData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsPRUint32Impl::SetData(PRUint32 aData)
|
|
|
|
{
|
|
|
|
mData = aData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint32Impl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(_retval, "Bad pointer");
|
1999-08-06 13:42:12 +04:00
|
|
|
static const int size = 16;
|
|
|
|
char buf[size];
|
|
|
|
|
|
|
|
PR_snprintf(buf, size, "%lu", mData);
|
|
|
|
|
2000-06-03 13:46:12 +04:00
|
|
|
char* result = (char*) nsMemory::Clone(buf,
|
1999-08-06 13:42:12 +04:00
|
|
|
(nsCRT::strlen(buf)+1)*sizeof(char));
|
1999-08-20 07:14:46 +04:00
|
|
|
*_retval = result;
|
|
|
|
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
1999-08-06 13:42:12 +04:00
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
/***************************************************************************/
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsPRUint64Impl, nsISupportsPRUint64,
|
|
|
|
nsISupportsPrimitive)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsPRUint64Impl::nsSupportsPRUint64Impl()
|
1999-08-04 11:45:38 +04:00
|
|
|
: mData(LL_ZERO)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsPRUint64Impl::~nsSupportsPRUint64Impl() {}
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint64Impl::GetType(PRUint16 *aType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_PRUINT64;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint64Impl::GetData(PRUint64 *aData)
|
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(aData, "Bad pointer");
|
1999-08-04 10:57:38 +04:00
|
|
|
*aData = mData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsPRUint64Impl::SetData(PRUint64 aData)
|
|
|
|
{
|
|
|
|
mData = aData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint64Impl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(_retval, "Bad pointer");
|
1999-08-06 13:42:12 +04:00
|
|
|
static const int size = 32;
|
|
|
|
char buf[size];
|
|
|
|
|
|
|
|
PR_snprintf(buf, size, "%llu", mData);
|
|
|
|
|
2000-06-03 13:46:12 +04:00
|
|
|
char* result = (char*) nsMemory::Clone(buf,
|
1999-08-06 13:42:12 +04:00
|
|
|
(nsCRT::strlen(buf)+1)*sizeof(char));
|
1999-08-20 07:14:46 +04:00
|
|
|
*_retval = result;
|
|
|
|
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
1999-08-06 13:42:12 +04:00
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
/***************************************************************************/
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsPRTimeImpl, nsISupportsPRTime,
|
|
|
|
nsISupportsPrimitive)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsPRTimeImpl::nsSupportsPRTimeImpl()
|
1999-08-04 11:45:38 +04:00
|
|
|
: mData(LL_ZERO)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsPRTimeImpl::~nsSupportsPRTimeImpl() {}
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMETHODIMP nsSupportsPRTimeImpl::GetType(PRUint16 *aType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_PRTIME;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRTimeImpl::GetData(PRTime *aData)
|
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(aData, "Bad pointer");
|
1999-08-04 10:57:38 +04:00
|
|
|
*aData = mData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsPRTimeImpl::SetData(PRTime aData)
|
|
|
|
{
|
|
|
|
mData = aData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRTimeImpl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(_retval, "Bad pointer");
|
1999-08-06 13:42:12 +04:00
|
|
|
static const int size = 32;
|
|
|
|
char buf[size];
|
|
|
|
|
|
|
|
PR_snprintf(buf, size, "%llu", mData);
|
|
|
|
|
2000-06-03 13:46:12 +04:00
|
|
|
char* result = (char*) nsMemory::Clone(buf,
|
1999-08-06 13:42:12 +04:00
|
|
|
(nsCRT::strlen(buf)+1)*sizeof(char));
|
1999-08-20 07:14:46 +04:00
|
|
|
*_retval = result;
|
|
|
|
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
1999-08-06 13:42:12 +04:00
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
/***************************************************************************/
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsCharImpl, nsISupportsChar,
|
|
|
|
nsISupportsPrimitive)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsCharImpl::nsSupportsCharImpl()
|
|
|
|
: mData(0)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsCharImpl::~nsSupportsCharImpl() {}
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMETHODIMP nsSupportsCharImpl::GetType(PRUint16 *aType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_CHAR;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsCharImpl::GetData(char *aData)
|
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(aData, "Bad pointer");
|
1999-08-04 10:57:38 +04:00
|
|
|
*aData = mData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsCharImpl::SetData(char aData)
|
|
|
|
{
|
|
|
|
mData = aData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsCharImpl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
1999-08-20 07:14:46 +04:00
|
|
|
char* result;
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(_retval, "Bad pointer");
|
1999-08-06 13:42:12 +04:00
|
|
|
|
2000-06-03 13:46:12 +04:00
|
|
|
if(nsnull != (result = (char*) nsMemory::Alloc(2*sizeof(char))))
|
1999-08-20 07:14:46 +04:00
|
|
|
{
|
|
|
|
result[0] = mData;
|
|
|
|
result[1] = '\0';
|
|
|
|
}
|
|
|
|
*_retval = result;
|
|
|
|
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
1999-08-06 13:42:12 +04:00
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
/***************************************************************************/
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsPRInt16Impl, nsISupportsPRInt16,
|
|
|
|
nsISupportsPrimitive)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsPRInt16Impl::nsSupportsPRInt16Impl()
|
|
|
|
: mData(0)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsPRInt16Impl::~nsSupportsPRInt16Impl() {}
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt16Impl::GetType(PRUint16 *aType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_PRINT16;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt16Impl::GetData(PRInt16 *aData)
|
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(aData, "Bad pointer");
|
1999-08-04 10:57:38 +04:00
|
|
|
*aData = mData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsPRInt16Impl::SetData(PRInt16 aData)
|
|
|
|
{
|
|
|
|
mData = aData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt16Impl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(_retval, "Bad pointer");
|
1999-08-06 13:42:12 +04:00
|
|
|
static const int size = 8;
|
|
|
|
char buf[size];
|
|
|
|
|
|
|
|
PR_snprintf(buf, size, "%d", mData);
|
|
|
|
|
2000-06-03 13:46:12 +04:00
|
|
|
char* result = (char*) nsMemory::Clone(buf,
|
1999-08-06 13:42:12 +04:00
|
|
|
(nsCRT::strlen(buf)+1)*sizeof(char));
|
1999-08-20 07:14:46 +04:00
|
|
|
*_retval = result;
|
|
|
|
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
1999-08-06 13:42:12 +04:00
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
/***************************************************************************/
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsPRInt32Impl, nsISupportsPRInt32,
|
|
|
|
nsISupportsPrimitive)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsPRInt32Impl::nsSupportsPRInt32Impl()
|
|
|
|
: mData(0)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsPRInt32Impl::~nsSupportsPRInt32Impl() {}
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt32Impl::GetType(PRUint16 *aType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_PRINT32;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt32Impl::GetData(PRInt32 *aData)
|
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(aData, "Bad pointer");
|
1999-08-04 10:57:38 +04:00
|
|
|
*aData = mData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsPRInt32Impl::SetData(PRInt32 aData)
|
|
|
|
{
|
|
|
|
mData = aData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt32Impl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(_retval, "Bad pointer");
|
1999-08-06 13:42:12 +04:00
|
|
|
static const int size = 16;
|
|
|
|
char buf[size];
|
|
|
|
|
|
|
|
PR_snprintf(buf, size, "%ld", mData);
|
|
|
|
|
2000-06-03 13:46:12 +04:00
|
|
|
char* result = (char*) nsMemory::Clone(buf,
|
1999-08-06 13:42:12 +04:00
|
|
|
(nsCRT::strlen(buf)+1)*sizeof(char));
|
1999-08-20 07:14:46 +04:00
|
|
|
*_retval = result;
|
|
|
|
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
1999-08-06 13:42:12 +04:00
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
/***************************************************************************/
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsPRInt64Impl, nsISupportsPRInt64,
|
|
|
|
nsISupportsPrimitive)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsPRInt64Impl::nsSupportsPRInt64Impl()
|
1999-08-04 11:45:38 +04:00
|
|
|
: mData(LL_ZERO)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsPRInt64Impl::~nsSupportsPRInt64Impl() {}
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt64Impl::GetType(PRUint16 *aType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_PRINT64;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt64Impl::GetData(PRInt64 *aData)
|
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(aData, "Bad pointer");
|
1999-08-04 10:57:38 +04:00
|
|
|
*aData = mData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsPRInt64Impl::SetData(PRInt64 aData)
|
|
|
|
{
|
|
|
|
mData = aData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt64Impl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(_retval, "Bad pointer");
|
1999-08-06 13:42:12 +04:00
|
|
|
static const int size = 32;
|
|
|
|
char buf[size];
|
|
|
|
|
|
|
|
PR_snprintf(buf, size, "%lld", mData);
|
|
|
|
|
2000-06-03 13:46:12 +04:00
|
|
|
char* result = (char*) nsMemory::Clone(buf,
|
1999-08-06 13:42:12 +04:00
|
|
|
(nsCRT::strlen(buf)+1)*sizeof(char));
|
1999-08-20 07:14:46 +04:00
|
|
|
*_retval = result;
|
|
|
|
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
1999-08-06 13:42:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsFloatImpl, nsISupportsFloat,
|
|
|
|
nsISupportsPrimitive)
|
1999-08-06 13:42:12 +04:00
|
|
|
|
|
|
|
nsSupportsFloatImpl::nsSupportsFloatImpl()
|
|
|
|
: mData(float(0.0))
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsFloatImpl::~nsSupportsFloatImpl() {}
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMETHODIMP nsSupportsFloatImpl::GetType(PRUint16 *aType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_FLOAT;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-06 13:42:12 +04:00
|
|
|
NS_IMETHODIMP nsSupportsFloatImpl::GetData(float *aData)
|
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(aData, "Bad pointer");
|
1999-08-06 13:42:12 +04:00
|
|
|
*aData = mData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsFloatImpl::SetData(float aData)
|
|
|
|
{
|
|
|
|
mData = aData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsFloatImpl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(_retval, "Bad pointer");
|
1999-08-06 13:42:12 +04:00
|
|
|
static const int size = 32;
|
|
|
|
char buf[size];
|
|
|
|
|
|
|
|
PR_snprintf(buf, size, "%f", (double) mData);
|
|
|
|
|
2000-06-03 13:46:12 +04:00
|
|
|
char* result = (char*) nsMemory::Clone(buf,
|
1999-08-06 13:42:12 +04:00
|
|
|
(nsCRT::strlen(buf)+1)*sizeof(char));
|
1999-08-20 07:14:46 +04:00
|
|
|
*_retval = result;
|
|
|
|
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
1999-08-06 13:42:12 +04:00
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
/***************************************************************************/
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsDoubleImpl, nsISupportsDouble,
|
|
|
|
nsISupportsPrimitive)
|
1999-08-06 13:42:12 +04:00
|
|
|
|
|
|
|
nsSupportsDoubleImpl::nsSupportsDoubleImpl()
|
|
|
|
: mData(double(0.0))
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsDoubleImpl::~nsSupportsDoubleImpl() {}
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMETHODIMP nsSupportsDoubleImpl::GetType(PRUint16 *aType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_DOUBLE;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-06 13:42:12 +04:00
|
|
|
NS_IMETHODIMP nsSupportsDoubleImpl::GetData(double *aData)
|
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(aData, "Bad pointer");
|
1999-08-06 13:42:12 +04:00
|
|
|
*aData = mData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsDoubleImpl::SetData(double aData)
|
|
|
|
{
|
|
|
|
mData = aData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsDoubleImpl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(_retval, "Bad pointer");
|
1999-08-06 13:42:12 +04:00
|
|
|
static const int size = 32;
|
|
|
|
char buf[size];
|
|
|
|
|
|
|
|
PR_snprintf(buf, size, "%f", mData);
|
|
|
|
|
2000-06-03 13:46:12 +04:00
|
|
|
char* result = (char*) nsMemory::Clone(buf,
|
1999-08-06 13:42:12 +04:00
|
|
|
(nsCRT::strlen(buf)+1)*sizeof(char));
|
1999-08-20 07:14:46 +04:00
|
|
|
*_retval = result;
|
|
|
|
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsVoidImpl, nsISupportsVoid,
|
|
|
|
nsISupportsPrimitive)
|
1999-08-20 07:14:46 +04:00
|
|
|
|
|
|
|
nsSupportsVoidImpl::nsSupportsVoidImpl()
|
|
|
|
: mData(nsnull)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsVoidImpl::~nsSupportsVoidImpl() {}
|
|
|
|
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_IMETHODIMP nsSupportsVoidImpl::GetType(PRUint16 *aType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_VOID;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-20 07:14:46 +04:00
|
|
|
NS_IMETHODIMP nsSupportsVoidImpl::GetData(const void * *aData)
|
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(aData, "Bad pointer");
|
1999-08-20 07:14:46 +04:00
|
|
|
*aData = mData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsVoidImpl::SetData(void * aData)
|
|
|
|
{
|
|
|
|
mData = aData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsVoidImpl::ToString(char **_retval)
|
1999-08-20 07:14:46 +04:00
|
|
|
{
|
2001-03-23 06:09:49 +03:00
|
|
|
NS_ASSERTION(_retval, "Bad pointer");
|
1999-08-20 07:14:46 +04:00
|
|
|
|
|
|
|
static const char str[] = "[raw data]";
|
2000-06-03 13:46:12 +04:00
|
|
|
char* result = (char*) nsMemory::Clone(str, sizeof(str));
|
1999-08-20 07:14:46 +04:00
|
|
|
*_retval = result;
|
|
|
|
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
1999-08-06 13:42:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************/
|
2001-04-10 07:56:48 +04:00
|
|
|
|
|
|
|
|
|
|
|
NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsInterfacePointerImpl,
|
|
|
|
nsISupportsInterfacePointer,
|
|
|
|
nsISupportsPrimitive)
|
|
|
|
|
|
|
|
nsSupportsInterfacePointerImpl::nsSupportsInterfacePointerImpl()
|
|
|
|
: mIID(nsnull)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsInterfacePointerImpl::~nsSupportsInterfacePointerImpl()
|
|
|
|
{
|
|
|
|
if (mIID) {
|
|
|
|
nsMemory::Free(mIID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsInterfacePointerImpl::GetType(PRUint16 *aType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_INTERFACE_POINTER;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsInterfacePointerImpl::GetData(nsISupports **aData)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aData,"Bad pointer");
|
|
|
|
|
|
|
|
*aData = mData;
|
|
|
|
NS_IF_ADDREF(*aData);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsInterfacePointerImpl::SetData(nsISupports * aData)
|
|
|
|
{
|
|
|
|
mData = aData;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsInterfacePointerImpl::GetDataIID(nsID **aIID)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aIID,"Bad pointer");
|
|
|
|
|
|
|
|
if(mIID)
|
|
|
|
{
|
|
|
|
*aIID = (nsID*) nsMemory::Clone(mIID, sizeof(nsID));
|
|
|
|
return *aIID ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2002-01-04 02:47:55 +03:00
|
|
|
*aIID = nsnull;
|
|
|
|
return NS_OK;
|
2001-04-10 07:56:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsInterfacePointerImpl::SetDataIID(const nsID *aIID)
|
|
|
|
{
|
|
|
|
if(mIID)
|
|
|
|
nsMemory::Free(mIID);
|
|
|
|
if(aIID)
|
|
|
|
mIID = (nsID*) nsMemory::Clone(aIID, sizeof(nsID));
|
|
|
|
else
|
|
|
|
mIID = nsnull;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsInterfacePointerImpl::ToString(char **_retval)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(_retval, "Bad pointer");
|
|
|
|
|
|
|
|
static const char str[] = "[interface pointer]";
|
|
|
|
|
|
|
|
// jband sez: think about asking nsIInterfaceInfoManager whether
|
|
|
|
// the interface has a known human-readable name
|
|
|
|
char* result = (char*) nsMemory::Clone(str, sizeof(str));
|
|
|
|
*_retval = result;
|
|
|
|
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************/
|