1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 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/. */
7 #include "xpctest_private.h"
9 NS_IMPL_ISUPPORTS(xpcTestObjectReadOnly
, nsIXPCTestObjectReadOnly
)
11 xpcTestObjectReadOnly ::xpcTestObjectReadOnly() {
13 shortProperty
= 32767;
14 longProperty
= 2147483647;
17 // timeProperty is PRTime and signed type.
18 // So it has to allow negative value.
22 NS_IMETHODIMP
xpcTestObjectReadOnly ::GetStrReadOnly(char** aStrReadOnly
) {
23 if (!aStrReadOnly
) return NS_ERROR_NULL_POINTER
;
24 *aStrReadOnly
= moz_xstrdup("XPConnect Read-Only String");
28 NS_IMETHODIMP
xpcTestObjectReadOnly ::GetBoolReadOnly(bool* aBoolReadOnly
) {
29 *aBoolReadOnly
= boolProperty
;
32 NS_IMETHODIMP
xpcTestObjectReadOnly ::GetShortReadOnly(
33 int16_t* aShortReadOnly
) {
34 *aShortReadOnly
= shortProperty
;
37 NS_IMETHODIMP
xpcTestObjectReadOnly ::GetLongReadOnly(int32_t* aLongReadOnly
) {
38 *aLongReadOnly
= longProperty
;
41 NS_IMETHODIMP
xpcTestObjectReadOnly ::GetFloatReadOnly(float* aFloatReadOnly
) {
42 *aFloatReadOnly
= floatProperty
;
45 NS_IMETHODIMP
xpcTestObjectReadOnly ::GetCharReadOnly(char* aCharReadOnly
) {
46 *aCharReadOnly
= charProperty
;
49 NS_IMETHODIMP
xpcTestObjectReadOnly ::GetTimeReadOnly(PRTime
* aTimeReadOnly
) {
50 *aTimeReadOnly
= timeProperty
;
54 NS_IMPL_ISUPPORTS(xpcTestObjectReadWrite
, nsIXPCTestObjectReadWrite
)
56 xpcTestObjectReadWrite ::xpcTestObjectReadWrite() {
57 stringProperty
= moz_xstrdup("XPConnect Read-Writable String");
59 shortProperty
= 32767;
60 longProperty
= 2147483647;
63 // timeProperty is PRTime and signed type.
64 // So it has to allow negative value.
68 xpcTestObjectReadWrite ::~xpcTestObjectReadWrite() { free(stringProperty
); }
70 NS_IMETHODIMP
xpcTestObjectReadWrite ::GetStringProperty(
71 char** aStringProperty
) {
72 if (!aStringProperty
) {
73 return NS_ERROR_NULL_POINTER
;
75 *aStringProperty
= moz_xstrdup(stringProperty
);
78 NS_IMETHODIMP
xpcTestObjectReadWrite ::SetStringProperty(
79 const char* aStringProperty
) {
81 stringProperty
= moz_xstrdup(aStringProperty
);
85 NS_IMETHODIMP
xpcTestObjectReadWrite ::GetBooleanProperty(
86 bool* aBooleanProperty
) {
87 *aBooleanProperty
= boolProperty
;
90 NS_IMETHODIMP
xpcTestObjectReadWrite ::SetBooleanProperty(
91 bool aBooleanProperty
) {
92 boolProperty
= aBooleanProperty
;
95 NS_IMETHODIMP
xpcTestObjectReadWrite ::GetShortProperty(
96 int16_t* aShortProperty
) {
97 *aShortProperty
= shortProperty
;
100 NS_IMETHODIMP
xpcTestObjectReadWrite ::SetShortProperty(
101 int16_t aShortProperty
) {
102 shortProperty
= aShortProperty
;
105 NS_IMETHODIMP
xpcTestObjectReadWrite ::GetLongProperty(int32_t* aLongProperty
) {
106 *aLongProperty
= longProperty
;
109 NS_IMETHODIMP
xpcTestObjectReadWrite ::SetLongProperty(int32_t aLongProperty
) {
110 longProperty
= aLongProperty
;
113 NS_IMETHODIMP
xpcTestObjectReadWrite ::GetFloatProperty(float* aFloatProperty
) {
114 *aFloatProperty
= floatProperty
;
117 NS_IMETHODIMP
xpcTestObjectReadWrite ::SetFloatProperty(float aFloatProperty
) {
118 floatProperty
= aFloatProperty
;
121 NS_IMETHODIMP
xpcTestObjectReadWrite ::GetCharProperty(char* aCharProperty
) {
122 *aCharProperty
= charProperty
;
125 NS_IMETHODIMP
xpcTestObjectReadWrite ::SetCharProperty(char aCharProperty
) {
126 charProperty
= aCharProperty
;
129 NS_IMETHODIMP
xpcTestObjectReadWrite ::GetTimeProperty(PRTime
* aTimeProperty
) {
130 *aTimeProperty
= timeProperty
;
133 NS_IMETHODIMP
xpcTestObjectReadWrite ::SetTimeProperty(PRTime aTimeProperty
) {
134 timeProperty
= aTimeProperty
;