gecko/js/xpconnect/tests/components/native/xpctest_attributes.cpp
Ehsan Akhgari 8c296bbcd4 Bug 579517 - Part 1: Automated conversion of NSPR numeric types to stdint types in Gecko; r=bsmedberg
This patch was generated by a script.  Here's the source of the script for
future reference:

function convert() {
echo "Converting $1 to $2..."
find . ! -wholename "*nsprpub*" \
       ! -wholename "*security/nss*" \
       ! -wholename "*/.hg*" \
       ! -wholename "obj-ff-dbg*" \
       ! -name nsXPCOMCID.h \
       ! -name prtypes.h \
         -type f \
      \( -iname "*.cpp" \
         -o -iname "*.h" \
         -o -iname "*.c" \
         -o -iname "*.cc" \
         -o -iname "*.idl" \
         -o -iname "*.ipdl" \
         -o -iname "*.ipdlh" \
         -o -iname "*.mm" \) | \
    xargs -n 1 sed -i -e "s/\b$1\b/$2/g"
}

convert PRInt8 int8_t
convert PRUint8 uint8_t
convert PRInt16 int16_t
convert PRUint16 uint16_t
convert PRInt32 int32_t
convert PRUint32 uint32_t
convert PRInt64 int64_t
convert PRUint64 uint64_t

convert PRIntn int
convert PRUintn unsigned

convert PRSize size_t

convert PROffset32 int32_t
convert PROffset64 int64_t

convert PRPtrdiff ptrdiff_t

convert PRFloat64 double
2012-08-22 11:56:38 -04:00

140 lines
4.7 KiB
C++

/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/. */
#include "xpctest_private.h"
NS_IMPL_ISUPPORTS1(xpcTestObjectReadOnly, nsIXPCTestObjectReadOnly)
xpcTestObjectReadOnly :: xpcTestObjectReadOnly() {
boolProperty = true;
shortProperty = 32767;
longProperty = 2147483647;
floatProperty = 5.5f;
charProperty = 'X';
// timeProperty is PRTime and signed type.
// So it has to allow negative value.
timeProperty = -1;
}
NS_IMETHODIMP xpcTestObjectReadOnly :: GetStrReadOnly(char * *aStrReadOnly){
char aString[] = "XPConnect Read-Only String";
if (!aStrReadOnly)
return NS_ERROR_NULL_POINTER;
*aStrReadOnly = (char*) nsMemory::Clone(aString,
sizeof(char)*(strlen(aString)+1));
return *aStrReadOnly ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
NS_IMETHODIMP xpcTestObjectReadOnly :: GetBoolReadOnly(bool *aBoolReadOnly) {
*aBoolReadOnly = boolProperty;
return NS_OK;
}
NS_IMETHODIMP xpcTestObjectReadOnly :: GetShortReadOnly(int16_t *aShortReadOnly){
*aShortReadOnly = shortProperty;
return NS_OK;
}
NS_IMETHODIMP xpcTestObjectReadOnly :: GetLongReadOnly(int32_t *aLongReadOnly){
*aLongReadOnly = longProperty;
return NS_OK;
}
NS_IMETHODIMP xpcTestObjectReadOnly :: GetFloatReadOnly(float *aFloatReadOnly){
*aFloatReadOnly = floatProperty;
return NS_OK;
}
NS_IMETHODIMP xpcTestObjectReadOnly :: GetCharReadOnly(char *aCharReadOnly){
*aCharReadOnly = charProperty;
return NS_OK;
}
NS_IMETHODIMP xpcTestObjectReadOnly :: GetTimeReadOnly(PRTime *aTimeReadOnly){
*aTimeReadOnly = timeProperty;
return NS_OK;
}
NS_IMPL_ISUPPORTS1(xpcTestObjectReadWrite, nsIXPCTestObjectReadWrite)
xpcTestObjectReadWrite :: xpcTestObjectReadWrite() {
const char s[] = "XPConnect Read-Writable String";
stringProperty = (char*) nsMemory::Clone(s, sizeof(char)*(strlen(s)+1));
boolProperty = true;
shortProperty = 32767;
longProperty = 2147483647;
floatProperty = 5.5f;
charProperty = 'X';
// timeProperty is PRTime and signed type.
// So it has to allow negative value.
timeProperty = -1;
}
xpcTestObjectReadWrite :: ~xpcTestObjectReadWrite()
{
nsMemory::Free(stringProperty);
}
NS_IMETHODIMP xpcTestObjectReadWrite :: GetStringProperty(char * *aStringProperty) {
if (!aStringProperty)
return NS_ERROR_NULL_POINTER;
*aStringProperty = (char*) nsMemory::Clone(stringProperty,
sizeof(char)*(strlen(stringProperty)+1));
return *aStringProperty ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
NS_IMETHODIMP xpcTestObjectReadWrite :: SetStringProperty(const char * aStringProperty) {
nsMemory::Free(stringProperty);
stringProperty = (char*) nsMemory::Clone(aStringProperty,
sizeof(char)*(strlen(aStringProperty)+1));
return NS_OK;
}
NS_IMETHODIMP xpcTestObjectReadWrite :: GetBooleanProperty(bool *aBooleanProperty) {
*aBooleanProperty = boolProperty;
return NS_OK;
}
NS_IMETHODIMP xpcTestObjectReadWrite :: SetBooleanProperty(bool aBooleanProperty) {
boolProperty = aBooleanProperty;
return NS_OK;
}
NS_IMETHODIMP xpcTestObjectReadWrite :: GetShortProperty(int16_t *aShortProperty) {
*aShortProperty = shortProperty;
return NS_OK;
}
NS_IMETHODIMP xpcTestObjectReadWrite :: SetShortProperty(int16_t aShortProperty) {
shortProperty = aShortProperty;
return NS_OK;
}
NS_IMETHODIMP xpcTestObjectReadWrite :: GetLongProperty(int32_t *aLongProperty) {
*aLongProperty = longProperty;
return NS_OK;
}
NS_IMETHODIMP xpcTestObjectReadWrite :: SetLongProperty(int32_t aLongProperty) {
longProperty = aLongProperty;
return NS_OK;
}
NS_IMETHODIMP xpcTestObjectReadWrite :: GetFloatProperty(float *aFloatProperty) {
*aFloatProperty = floatProperty;
return NS_OK;
}
NS_IMETHODIMP xpcTestObjectReadWrite :: SetFloatProperty(float aFloatProperty) {
floatProperty = aFloatProperty;
return NS_OK;
}
NS_IMETHODIMP xpcTestObjectReadWrite :: GetCharProperty(char *aCharProperty) {
*aCharProperty = charProperty;
return NS_OK;
}
NS_IMETHODIMP xpcTestObjectReadWrite :: SetCharProperty(char aCharProperty) {
charProperty = aCharProperty;
return NS_OK;
}
NS_IMETHODIMP xpcTestObjectReadWrite :: GetTimeProperty(PRTime *aTimeProperty) {
*aTimeProperty = timeProperty;
return NS_OK;
}
NS_IMETHODIMP xpcTestObjectReadWrite :: SetTimeProperty(PRTime aTimeProperty) {
timeProperty = aTimeProperty;
return NS_OK;
}