2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
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"
|
2002-08-27 01:20:34 +04:00
|
|
|
#include "nsDependentString.h"
|
|
|
|
#include "nsReadableUtils.h"
|
|
|
|
#include "nsPromiseFlatString.h"
|
1999-08-04 10:57:38 +04:00
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2008-02-21 23:39:20 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsIDImpl, nsISupportsID, nsISupportsPrimitive)
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
nsSupportsIDImpl::nsSupportsIDImpl()
|
2012-07-30 18:20:58 +04:00
|
|
|
: mData(nullptr)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsIDImpl::GetType(uint16_t *aType)
|
2001-03-23 06:09:49 +03:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
*aData = nullptr;
|
2002-01-04 02:47:55 +03:00
|
|
|
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
|
2012-07-30 18:20:58 +04:00
|
|
|
mData = nullptr;
|
1999-08-04 10:57:38 +04:00
|
|
|
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
|
|
|
/*****************************************************************************
|
2002-08-06 04:53:19 +04:00
|
|
|
* nsSupportsCStringImpl
|
2001-05-10 06:44:35 +04:00
|
|
|
*****************************************************************************/
|
1999-08-04 10:57:38 +04:00
|
|
|
|
2008-02-21 23:39:20 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsCStringImpl, nsISupportsCString,
|
|
|
|
nsISupportsPrimitive)
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsCStringImpl::GetType(uint16_t *aType)
|
2001-03-23 06:09:49 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
|
2002-08-06 04:53:19 +04:00
|
|
|
*aType = TYPE_CSTRING;
|
2001-03-23 06:09:49 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-08-27 01:20:34 +04:00
|
|
|
NS_IMETHODIMP nsSupportsCStringImpl::GetData(nsACString& aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
2002-08-27 01:20:34 +04:00
|
|
|
aData = mData;
|
|
|
|
return NS_OK;
|
1999-08-04 10:57:38 +04:00
|
|
|
}
|
|
|
|
|
2002-08-06 04:53:19 +04:00
|
|
|
NS_IMETHODIMP nsSupportsCStringImpl::ToString(char **_retval)
|
1999-08-06 13:42:12 +04:00
|
|
|
{
|
2002-08-27 01:20:34 +04:00
|
|
|
*_retval = ToNewCString(mData);
|
2001-05-10 06:44:35 +04:00
|
|
|
|
2002-08-27 01:20:34 +04:00
|
|
|
if (!*_retval)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
return NS_OK;
|
2001-05-10 06:44:35 +04:00
|
|
|
}
|
|
|
|
|
2002-08-27 01:20:34 +04:00
|
|
|
NS_IMETHODIMP nsSupportsCStringImpl::SetData(const nsACString& aData)
|
2001-05-10 06:44:35 +04:00
|
|
|
{
|
|
|
|
mData = aData;
|
1999-12-01 01:06:05 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-05-10 06:44:35 +04:00
|
|
|
/*****************************************************************************
|
2002-08-06 04:53:19 +04:00
|
|
|
* nsSupportsStringImpl
|
2001-05-10 06:44:35 +04:00
|
|
|
*****************************************************************************/
|
1999-08-04 10:57:38 +04:00
|
|
|
|
2008-02-21 23:39:20 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsStringImpl, nsISupportsString,
|
|
|
|
nsISupportsPrimitive)
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsStringImpl::GetType(uint16_t *aType)
|
2001-03-23 06:09:49 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
|
2002-08-06 04:53:19 +04:00
|
|
|
*aType = TYPE_STRING;
|
2001-03-23 06:09:49 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-08-27 01:20:34 +04:00
|
|
|
NS_IMETHODIMP nsSupportsStringImpl::GetData(nsAString& aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
2002-08-27 01:20:34 +04:00
|
|
|
aData = mData;
|
|
|
|
return NS_OK;
|
1999-12-01 01:06:05 +03:00
|
|
|
}
|
|
|
|
|
2002-08-06 04:53:19 +04:00
|
|
|
NS_IMETHODIMP nsSupportsStringImpl::ToString(PRUnichar **_retval)
|
1999-12-01 01:06:05 +03:00
|
|
|
{
|
2002-08-27 01:20:34 +04:00
|
|
|
*_retval = ToNewUnicode(mData);
|
|
|
|
|
|
|
|
if (!*_retval)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
return NS_OK;
|
2001-05-10 06:44:35 +04:00
|
|
|
}
|
|
|
|
|
2002-08-27 01:20:34 +04:00
|
|
|
NS_IMETHODIMP nsSupportsStringImpl::SetData(const nsAString& aData)
|
2001-05-10 06:44:35 +04:00
|
|
|
{
|
|
|
|
mData = aData;
|
1999-08-04 10:57:38 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2013-07-19 06:31:26 +04:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsPRBoolImpl, nsISupportsPRBool,
|
|
|
|
nsISupportsPrimitive)
|
2008-02-21 23:39:20 +03:00
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
nsSupportsPRBoolImpl::nsSupportsPRBoolImpl()
|
2011-10-17 18:59:28 +04:00
|
|
|
: mData(false)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRBoolImpl::GetType(uint16_t *aType)
|
2001-03-23 06:09:49 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_PRBOOL;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRBoolImpl::GetData(bool *aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRBoolImpl::SetData(bool aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
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,
|
2002-02-20 09:38:38 +03:00
|
|
|
(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
|
|
|
/***************************************************************************/
|
|
|
|
|
2008-02-21 23:39:20 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsPRUint8Impl, nsISupportsPRUint8,
|
|
|
|
nsISupportsPrimitive)
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
nsSupportsPRUint8Impl::nsSupportsPRUint8Impl()
|
|
|
|
: mData(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint8Impl::GetType(uint16_t *aType)
|
2001-03-23 06:09:49 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_PRUINT8;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint8Impl::GetData(uint8_t *aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint8Impl::SetData(uint8_t aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
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
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
PR_snprintf(buf, size, "%u", (uint16_t) mData);
|
1999-08-06 13:42:12 +04:00
|
|
|
|
2000-06-03 13:46:12 +04:00
|
|
|
char* result = (char*) nsMemory::Clone(buf,
|
2002-02-20 09:38:38 +03:00
|
|
|
(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
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2008-02-21 23:39:20 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsPRUint16Impl, nsISupportsPRUint16,
|
|
|
|
nsISupportsPrimitive)
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
nsSupportsPRUint16Impl::nsSupportsPRUint16Impl()
|
|
|
|
: mData(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint16Impl::GetType(uint16_t *aType)
|
2001-03-23 06:09:49 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_PRUINT16;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint16Impl::GetData(uint16_t *aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint16Impl::SetData(uint16_t aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
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,
|
2002-02-20 09:38:38 +03:00
|
|
|
(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
|
|
|
/***************************************************************************/
|
|
|
|
|
2008-02-21 23:39:20 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsPRUint32Impl, nsISupportsPRUint32,
|
|
|
|
nsISupportsPrimitive)
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
nsSupportsPRUint32Impl::nsSupportsPRUint32Impl()
|
|
|
|
: mData(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint32Impl::GetType(uint16_t *aType)
|
2001-03-23 06:09:49 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_PRUINT32;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint32Impl::GetData(uint32_t *aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint32Impl::SetData(uint32_t aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
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,
|
2002-02-20 09:38:38 +03:00
|
|
|
(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
|
|
|
/***************************************************************************/
|
|
|
|
|
2008-02-21 23:39:20 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsPRUint64Impl, nsISupportsPRUint64,
|
|
|
|
nsISupportsPrimitive)
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
nsSupportsPRUint64Impl::nsSupportsPRUint64Impl()
|
2012-10-26 03:25:59 +04:00
|
|
|
: mData(0)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint64Impl::GetType(uint16_t *aType)
|
2001-03-23 06:09:49 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_PRUINT64;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint64Impl::GetData(uint64_t *aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRUint64Impl::SetData(uint64_t aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
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,
|
2002-02-20 09:38:38 +03:00
|
|
|
(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
|
|
|
/***************************************************************************/
|
|
|
|
|
2008-02-21 23:39:20 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsPRTimeImpl, nsISupportsPRTime,
|
|
|
|
nsISupportsPrimitive)
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
nsSupportsPRTimeImpl::nsSupportsPRTimeImpl()
|
2012-10-26 03:25:59 +04:00
|
|
|
: mData(0)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRTimeImpl::GetType(uint16_t *aType)
|
2001-03-23 06:09:49 +03:00
|
|
|
{
|
|
|
|
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,
|
2002-02-20 09:38:38 +03:00
|
|
|
(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
|
|
|
/***************************************************************************/
|
|
|
|
|
2008-02-21 23:39:20 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsCharImpl, nsISupportsChar,
|
|
|
|
nsISupportsPrimitive)
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
nsSupportsCharImpl::nsSupportsCharImpl()
|
|
|
|
: mData(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsCharImpl::GetType(uint16_t *aType)
|
2001-03-23 06:09:49 +03:00
|
|
|
{
|
|
|
|
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
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
if(nullptr != (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
|
|
|
/***************************************************************************/
|
|
|
|
|
2008-02-21 23:39:20 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsPRInt16Impl, nsISupportsPRInt16,
|
|
|
|
nsISupportsPrimitive)
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
nsSupportsPRInt16Impl::nsSupportsPRInt16Impl()
|
|
|
|
: mData(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt16Impl::GetType(uint16_t *aType)
|
2001-03-23 06:09:49 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_PRINT16;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt16Impl::GetData(int16_t *aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt16Impl::SetData(int16_t aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
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,
|
2002-02-20 09:38:38 +03:00
|
|
|
(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
|
|
|
/***************************************************************************/
|
|
|
|
|
2008-02-21 23:39:20 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsPRInt32Impl, nsISupportsPRInt32,
|
|
|
|
nsISupportsPrimitive)
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
nsSupportsPRInt32Impl::nsSupportsPRInt32Impl()
|
|
|
|
: mData(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt32Impl::GetType(uint16_t *aType)
|
2001-03-23 06:09:49 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_PRINT32;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt32Impl::GetData(int32_t *aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt32Impl::SetData(int32_t aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
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,
|
2002-02-20 09:38:38 +03:00
|
|
|
(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
|
|
|
/***************************************************************************/
|
|
|
|
|
2008-02-21 23:39:20 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsPRInt64Impl, nsISupportsPRInt64,
|
|
|
|
nsISupportsPrimitive)
|
|
|
|
|
1999-08-04 10:57:38 +04:00
|
|
|
nsSupportsPRInt64Impl::nsSupportsPRInt64Impl()
|
2012-10-26 03:25:59 +04:00
|
|
|
: mData(0)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt64Impl::GetType(uint16_t *aType)
|
2001-03-23 06:09:49 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_PRINT64;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt64Impl::GetData(int64_t *aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsPRInt64Impl::SetData(int64_t aData)
|
1999-08-04 10:57:38 +04:00
|
|
|
{
|
|
|
|
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,
|
2002-02-20 09:38:38 +03:00
|
|
|
(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
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2008-02-21 23:39:20 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsFloatImpl, nsISupportsFloat,
|
|
|
|
nsISupportsPrimitive)
|
|
|
|
|
1999-08-06 13:42:12 +04:00
|
|
|
nsSupportsFloatImpl::nsSupportsFloatImpl()
|
|
|
|
: mData(float(0.0))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsFloatImpl::GetType(uint16_t *aType)
|
2001-03-23 06:09:49 +03:00
|
|
|
{
|
|
|
|
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,
|
2002-02-20 09:38:38 +03:00
|
|
|
(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
|
|
|
/***************************************************************************/
|
|
|
|
|
2008-02-21 23:39:20 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsDoubleImpl, nsISupportsDouble,
|
|
|
|
nsISupportsPrimitive)
|
|
|
|
|
1999-08-06 13:42:12 +04:00
|
|
|
nsSupportsDoubleImpl::nsSupportsDoubleImpl()
|
|
|
|
: mData(double(0.0))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsDoubleImpl::GetType(uint16_t *aType)
|
2001-03-23 06:09:49 +03:00
|
|
|
{
|
|
|
|
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,
|
2002-02-20 09:38:38 +03:00
|
|
|
(strlen(buf)+1)*sizeof(char));
|
1999-08-20 07:14:46 +04:00
|
|
|
*_retval = result;
|
|
|
|
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
|
2013-07-19 06:31:26 +04:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsVoidImpl, nsISupportsVoid,
|
|
|
|
nsISupportsPrimitive)
|
2008-02-21 23:39:20 +03:00
|
|
|
|
1999-08-20 07:14:46 +04:00
|
|
|
nsSupportsVoidImpl::nsSupportsVoidImpl()
|
2012-07-30 18:20:58 +04:00
|
|
|
: mData(nullptr)
|
1999-08-20 07:14:46 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsVoidImpl::GetType(uint16_t *aType)
|
2001-03-23 06:09:49 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aType, "Bad pointer");
|
|
|
|
*aType = TYPE_VOID;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-04-04 16:28:22 +04:00
|
|
|
NS_IMETHODIMP nsSupportsVoidImpl::GetData(void * *aData)
|
1999-08-20 07:14:46 +04:00
|
|
|
{
|
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
|
|
|
|
|
|
|
|
2013-07-19 06:31:26 +04:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsInterfacePointerImpl,
|
|
|
|
nsISupportsInterfacePointer,
|
|
|
|
nsISupportsPrimitive)
|
2008-02-21 23:39:20 +03:00
|
|
|
|
2001-04-10 07:56:48 +04:00
|
|
|
nsSupportsInterfacePointerImpl::nsSupportsInterfacePointerImpl()
|
2012-07-30 18:20:58 +04:00
|
|
|
: mIID(nullptr)
|
2001-04-10 07:56:48 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSupportsInterfacePointerImpl::~nsSupportsInterfacePointerImpl()
|
|
|
|
{
|
|
|
|
if (mIID) {
|
|
|
|
nsMemory::Free(mIID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHODIMP nsSupportsInterfacePointerImpl::GetType(uint16_t *aType)
|
2001-04-10 07:56:48 +04:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
*aIID = nullptr;
|
2002-01-04 02:47:55 +03:00
|
|
|
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
|
2012-07-30 18:20:58 +04:00
|
|
|
mIID = nullptr;
|
2001-04-10 07:56:48 +04:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************/
|
2003-06-18 15:26:27 +04:00
|
|
|
|
2008-02-21 23:39:20 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSupportsDependentCString,nsISupportsCString,nsISupportsPrimitive)
|
|
|
|
|
2003-06-18 15:26:27 +04:00
|
|
|
nsSupportsDependentCString::nsSupportsDependentCString(const char* aStr)
|
|
|
|
: mData(aStr)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSupportsDependentCString::GetType(uint16_t *aType)
|
2003-06-18 15:26:27 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aType);
|
|
|
|
|
|
|
|
*aType = TYPE_CSTRING;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSupportsDependentCString::GetData(nsACString& aData)
|
|
|
|
{
|
|
|
|
aData = mData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSupportsDependentCString::ToString(char **_retval)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(_retval);
|
|
|
|
|
|
|
|
*_retval = ToNewCString(mData);
|
|
|
|
if (!*_retval)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSupportsDependentCString::SetData(const nsACString& aData)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|