xpctest_attributes.cpp (4173B)
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 * 3 * This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "xpctest_private.h" 8 9 NS_IMPL_ISUPPORTS(xpcTestObjectReadOnly, nsIXPCTestObjectReadOnly) 10 11 xpcTestObjectReadOnly ::xpcTestObjectReadOnly() { 12 boolProperty = true; 13 shortProperty = 32767; 14 longProperty = 2147483647; 15 floatProperty = 5.5f; 16 charProperty = 'X'; 17 // timeProperty is PRTime and signed type. 18 // So it has to allow negative value. 19 timeProperty = -1; 20 } 21 22 NS_IMETHODIMP xpcTestObjectReadOnly ::GetStrReadOnly(char** aStrReadOnly) { 23 if (!aStrReadOnly) return NS_ERROR_NULL_POINTER; 24 *aStrReadOnly = moz_xstrdup("XPConnect Read-Only String"); 25 return NS_OK; 26 } 27 28 NS_IMETHODIMP xpcTestObjectReadOnly ::GetBoolReadOnly(bool* aBoolReadOnly) { 29 *aBoolReadOnly = boolProperty; 30 return NS_OK; 31 } 32 NS_IMETHODIMP xpcTestObjectReadOnly ::GetShortReadOnly( 33 int16_t* aShortReadOnly) { 34 *aShortReadOnly = shortProperty; 35 return NS_OK; 36 } 37 NS_IMETHODIMP xpcTestObjectReadOnly ::GetLongReadOnly(int32_t* aLongReadOnly) { 38 *aLongReadOnly = longProperty; 39 return NS_OK; 40 } 41 NS_IMETHODIMP xpcTestObjectReadOnly ::GetFloatReadOnly(float* aFloatReadOnly) { 42 *aFloatReadOnly = floatProperty; 43 return NS_OK; 44 } 45 NS_IMETHODIMP xpcTestObjectReadOnly ::GetCharReadOnly(char* aCharReadOnly) { 46 *aCharReadOnly = charProperty; 47 return NS_OK; 48 } 49 NS_IMETHODIMP xpcTestObjectReadOnly ::GetTimeReadOnly(PRTime* aTimeReadOnly) { 50 *aTimeReadOnly = timeProperty; 51 return NS_OK; 52 } 53 54 NS_IMPL_ISUPPORTS(xpcTestObjectReadWrite, nsIXPCTestObjectReadWrite) 55 56 xpcTestObjectReadWrite ::xpcTestObjectReadWrite() { 57 stringProperty = moz_xstrdup("XPConnect Read-Writable String"); 58 boolProperty = true; 59 shortProperty = 32767; 60 longProperty = 2147483647; 61 floatProperty = 5.5f; 62 charProperty = 'X'; 63 // timeProperty is PRTime and signed type. 64 // So it has to allow negative value. 65 timeProperty = -1; 66 } 67 68 xpcTestObjectReadWrite ::~xpcTestObjectReadWrite() { free(stringProperty); } 69 70 NS_IMETHODIMP xpcTestObjectReadWrite ::GetStringProperty( 71 char** aStringProperty) { 72 if (!aStringProperty) { 73 return NS_ERROR_NULL_POINTER; 74 } 75 *aStringProperty = moz_xstrdup(stringProperty); 76 return NS_OK; 77 } 78 NS_IMETHODIMP xpcTestObjectReadWrite ::SetStringProperty( 79 const char* aStringProperty) { 80 free(stringProperty); 81 stringProperty = moz_xstrdup(aStringProperty); 82 return NS_OK; 83 } 84 85 NS_IMETHODIMP xpcTestObjectReadWrite ::GetBooleanProperty( 86 bool* aBooleanProperty) { 87 *aBooleanProperty = boolProperty; 88 return NS_OK; 89 } 90 NS_IMETHODIMP xpcTestObjectReadWrite ::SetBooleanProperty( 91 bool aBooleanProperty) { 92 boolProperty = aBooleanProperty; 93 return NS_OK; 94 } 95 NS_IMETHODIMP xpcTestObjectReadWrite ::GetShortProperty( 96 int16_t* aShortProperty) { 97 *aShortProperty = shortProperty; 98 return NS_OK; 99 } 100 NS_IMETHODIMP xpcTestObjectReadWrite ::SetShortProperty( 101 int16_t aShortProperty) { 102 shortProperty = aShortProperty; 103 return NS_OK; 104 } 105 NS_IMETHODIMP xpcTestObjectReadWrite ::GetLongProperty(int32_t* aLongProperty) { 106 *aLongProperty = longProperty; 107 return NS_OK; 108 } 109 NS_IMETHODIMP xpcTestObjectReadWrite ::SetLongProperty(int32_t aLongProperty) { 110 longProperty = aLongProperty; 111 return NS_OK; 112 } 113 NS_IMETHODIMP xpcTestObjectReadWrite ::GetFloatProperty(float* aFloatProperty) { 114 *aFloatProperty = floatProperty; 115 return NS_OK; 116 } 117 NS_IMETHODIMP xpcTestObjectReadWrite ::SetFloatProperty(float aFloatProperty) { 118 floatProperty = aFloatProperty; 119 return NS_OK; 120 } 121 NS_IMETHODIMP xpcTestObjectReadWrite ::GetCharProperty(char* aCharProperty) { 122 *aCharProperty = charProperty; 123 return NS_OK; 124 } 125 NS_IMETHODIMP xpcTestObjectReadWrite ::SetCharProperty(char aCharProperty) { 126 charProperty = aCharProperty; 127 return NS_OK; 128 } 129 NS_IMETHODIMP xpcTestObjectReadWrite ::GetTimeProperty(PRTime* aTimeProperty) { 130 *aTimeProperty = timeProperty; 131 return NS_OK; 132 } 133 NS_IMETHODIMP xpcTestObjectReadWrite ::SetTimeProperty(PRTime aTimeProperty) { 134 timeProperty = aTimeProperty; 135 return NS_OK; 136 }