1999-08-04 10:57:38 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:43:54 +03: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
|
|
|
*
|
1999-11-06 06:43:54 +03: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.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1999-08-04 10:57:38 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:43:54 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1999-08-04 10:57:38 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsSupportsPrimitives.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsIAllocator.h"
|
1999-08-06 13:42:12 +04:00
|
|
|
#include "prprf.h"
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
1999-08-23 14:14:16 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsSupportsIDImpl, nsISupportsID)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsIDImpl::nsSupportsIDImpl()
|
|
|
|
: mData(nsnull)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
nsAllocator::Free(mData);
|
|
|
|
if(aData)
|
|
|
|
mData = (nsID*) nsAllocator::Clone(aData, sizeof(nsID));
|
|
|
|
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
|
|
|
{
|
1999-08-20 07:14:46 +04:00
|
|
|
char* result = nsnull;
|
1999-08-06 13:42:12 +04:00
|
|
|
if(!_retval)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(0,"Bad pointer");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
if(mData)
|
|
|
|
{
|
|
|
|
char * str = mData->ToString();
|
|
|
|
if(str)
|
|
|
|
{
|
1999-08-20 07:14:46 +04:00
|
|
|
result = (char*) nsAllocator::Clone(str,
|
1999-08-06 13:42:12 +04:00
|
|
|
(nsCRT::strlen(str)+1)*sizeof(char));
|
|
|
|
delete [] str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
static const char nullStr[] = "null";
|
1999-08-20 07:14:46 +04:00
|
|
|
result = (char*) nsAllocator::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
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
/***************************************************************************/
|
|
|
|
|
1999-08-23 14:14:16 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsSupportsStringImpl, nsISupportsString)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsStringImpl::nsSupportsStringImpl()
|
|
|
|
: mData(nsnull)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-20 03:46:35 +04:00
|
|
|
NS_IMETHODIMP nsSupportsStringImpl::SetData(const char *aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
if(mData)
|
|
|
|
nsAllocator::Free(mData);
|
|
|
|
if(aData)
|
|
|
|
mData = (char*) nsAllocator::Clone(aData,
|
|
|
|
(nsCRT::strlen(aData)+1)*sizeof(char));
|
|
|
|
else
|
|
|
|
mData = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
/***************************************************************************/
|
|
|
|
|
1999-08-23 14:14:16 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsSupportsWStringImpl, nsISupportsWString)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsWStringImpl::nsSupportsWStringImpl()
|
|
|
|
: mData(nsnull)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-20 03:46:35 +04:00
|
|
|
NS_IMETHODIMP nsSupportsWStringImpl::SetData(const PRUnichar *aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
if(mData)
|
|
|
|
nsAllocator::Free(mData);
|
|
|
|
if(aData)
|
|
|
|
mData = (PRUnichar*) nsAllocator::Clone(aData,
|
|
|
|
(nsCRT::strlen(aData)+1)*sizeof(PRUnichar));
|
|
|
|
else
|
|
|
|
mData = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsWStringImpl::ToString(PRUnichar **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
|
|
|
return GetData(_retval);
|
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
/***************************************************************************/
|
|
|
|
|
1999-08-23 14:14:16 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsSupportsPRBoolImpl, nsISupportsPRBool)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsPRBoolImpl::nsSupportsPRBoolImpl()
|
|
|
|
: mData(PR_FALSE)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRBoolImpl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
|
|
|
if(!_retval)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(0,"Bad pointer");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
const char * str = mData ? "true" : "false";
|
1999-08-20 07:14:46 +04:00
|
|
|
char* result = (char*) nsAllocator::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
|
|
|
}
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
/***************************************************************************/
|
|
|
|
|
1999-08-23 14:14:16 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsSupportsPRUint8Impl, nsISupportsPRUint8)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsPRUint8Impl::nsSupportsPRUint8Impl()
|
|
|
|
: mData(0)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint8Impl::ToString(char **_retval)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
1999-08-06 13:42:12 +04:00
|
|
|
if(!_retval)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(0,"Bad pointer");
|
|
|
|
return NS_ERROR_NULL_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);
|
|
|
|
|
1999-08-20 07:14:46 +04:00
|
|
|
char* result = (char*) nsAllocator::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
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
1999-08-23 14:14:16 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsSupportsPRUint16Impl, nsISupportsPRUint16)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsPRUint16Impl::nsSupportsPRUint16Impl()
|
|
|
|
: mData(0)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint16Impl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
|
|
|
if(!_retval)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(0,"Bad pointer");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
static const int size = 8;
|
|
|
|
char buf[size];
|
|
|
|
|
|
|
|
PR_snprintf(buf, size, "%u", (int) mData);
|
|
|
|
|
1999-08-20 07:14:46 +04:00
|
|
|
char* result = (char*) nsAllocator::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
|
|
|
/***************************************************************************/
|
|
|
|
|
1999-08-23 14:14:16 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsSupportsPRUint32Impl, nsISupportsPRUint32)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsPRUint32Impl::nsSupportsPRUint32Impl()
|
|
|
|
: mData(0)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint32Impl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
|
|
|
if(!_retval)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(0,"Bad pointer");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
static const int size = 16;
|
|
|
|
char buf[size];
|
|
|
|
|
|
|
|
PR_snprintf(buf, size, "%lu", mData);
|
|
|
|
|
1999-08-20 07:14:46 +04:00
|
|
|
char* result = (char*) nsAllocator::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
|
|
|
/***************************************************************************/
|
|
|
|
|
1999-08-23 14:14:16 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsSupportsPRUint64Impl, nsISupportsPRUint64)
|
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() {}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint64Impl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
|
|
|
if(!_retval)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(0,"Bad pointer");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
static const int size = 32;
|
|
|
|
char buf[size];
|
|
|
|
|
|
|
|
PR_snprintf(buf, size, "%llu", mData);
|
|
|
|
|
1999-08-20 07:14:46 +04:00
|
|
|
char* result = (char*) nsAllocator::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
|
|
|
/***************************************************************************/
|
|
|
|
|
1999-08-23 14:14:16 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsSupportsPRTimeImpl, nsISupportsPRTime)
|
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() {}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRTimeImpl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
|
|
|
if(!_retval)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(0,"Bad pointer");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
static const int size = 32;
|
|
|
|
char buf[size];
|
|
|
|
|
|
|
|
PR_snprintf(buf, size, "%llu", mData);
|
|
|
|
|
1999-08-20 07:14:46 +04:00
|
|
|
char* result = (char*) nsAllocator::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
|
|
|
/***************************************************************************/
|
|
|
|
|
1999-08-23 14:14:16 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsSupportsCharImpl, nsISupportsChar)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsCharImpl::nsSupportsCharImpl()
|
|
|
|
: mData(0)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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;
|
1999-08-06 13:42:12 +04:00
|
|
|
if(!_retval)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(0,"Bad pointer");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
1999-08-20 07:14:46 +04:00
|
|
|
if(nsnull != (result = (char*) nsAllocator::Alloc(2*sizeof(char))))
|
|
|
|
{
|
|
|
|
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
|
|
|
/***************************************************************************/
|
|
|
|
|
1999-08-23 14:14:16 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsSupportsPRInt16Impl, nsISupportsPRInt16)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsPRInt16Impl::nsSupportsPRInt16Impl()
|
|
|
|
: mData(0)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt16Impl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
|
|
|
if(!_retval)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(0,"Bad pointer");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
static const int size = 8;
|
|
|
|
char buf[size];
|
|
|
|
|
|
|
|
PR_snprintf(buf, size, "%d", mData);
|
|
|
|
|
1999-08-20 07:14:46 +04:00
|
|
|
char* result = (char*) nsAllocator::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
|
|
|
/***************************************************************************/
|
|
|
|
|
1999-08-23 14:14:16 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsSupportsPRInt32Impl, nsISupportsPRInt32)
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
nsSupportsPRInt32Impl::nsSupportsPRInt32Impl()
|
|
|
|
: mData(0)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt32Impl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
|
|
|
if(!_retval)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(0,"Bad pointer");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
static const int size = 16;
|
|
|
|
char buf[size];
|
|
|
|
|
|
|
|
PR_snprintf(buf, size, "%ld", mData);
|
|
|
|
|
1999-08-20 07:14:46 +04:00
|
|
|
char* result = (char*) nsAllocator::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
|
|
|
/***************************************************************************/
|
|
|
|
|
1999-08-23 14:14:16 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsSupportsPRInt64Impl, nsISupportsPRInt64)
|
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() {}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt64Impl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
|
|
|
if(!_retval)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(0,"Bad pointer");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
static const int size = 32;
|
|
|
|
char buf[size];
|
|
|
|
|
|
|
|
PR_snprintf(buf, size, "%lld", mData);
|
|
|
|
|
1999-08-20 07:14:46 +04:00
|
|
|
char* result = (char*) nsAllocator::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-23 14:14:16 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsSupportsFloatImpl, nsISupportsFloat)
|
1999-08-06 13:42:12 +04:00
|
|
|
|
|
|
|
nsSupportsFloatImpl::nsSupportsFloatImpl()
|
|
|
|
: mData(float(0.0))
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsFloatImpl::~nsSupportsFloatImpl() {}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsFloatImpl::GetData(float *aData)
|
|
|
|
{
|
|
|
|
if(!aData)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(0,"Bad pointer");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
*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
|
|
|
{
|
|
|
|
if(!_retval)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(0,"Bad pointer");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
static const int size = 32;
|
|
|
|
char buf[size];
|
|
|
|
|
|
|
|
PR_snprintf(buf, size, "%f", (double) mData);
|
|
|
|
|
1999-08-20 07:14:46 +04:00
|
|
|
char* result = (char*) nsAllocator::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
|
|
|
/***************************************************************************/
|
|
|
|
|
1999-08-23 14:14:16 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsSupportsDoubleImpl, nsISupportsDouble)
|
1999-08-06 13:42:12 +04:00
|
|
|
|
|
|
|
nsSupportsDoubleImpl::nsSupportsDoubleImpl()
|
|
|
|
: mData(double(0.0))
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsDoubleImpl::~nsSupportsDoubleImpl() {}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsDoubleImpl::GetData(double *aData)
|
|
|
|
{
|
|
|
|
if(!aData)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(0,"Bad pointer");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
*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
|
|
|
{
|
|
|
|
if(!_retval)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(0,"Bad pointer");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
static const int size = 32;
|
|
|
|
char buf[size];
|
|
|
|
|
|
|
|
PR_snprintf(buf, size, "%f", mData);
|
|
|
|
|
1999-08-20 07:14:46 +04:00
|
|
|
char* result = (char*) nsAllocator::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-23 14:14:16 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsSupportsVoidImpl, nsISupportsVoid)
|
1999-08-20 07:14:46 +04:00
|
|
|
|
|
|
|
nsSupportsVoidImpl::nsSupportsVoidImpl()
|
|
|
|
: mData(nsnull)
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsVoidImpl::~nsSupportsVoidImpl() {}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsSupportsVoidImpl::GetData(const void * *aData)
|
|
|
|
{
|
|
|
|
if(!aData)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(0,"Bad pointer");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
*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
|
|
|
{
|
|
|
|
if(!_retval)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(0,"Bad pointer");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char str[] = "[raw data]";
|
|
|
|
char* result = (char*) nsAllocator::Clone(str, sizeof(str));
|
|
|
|
*_retval = result;
|
|
|
|
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
1999-08-06 13:42:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************/
|