1 : /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 : *
3 : * ***** BEGIN LICENSE BLOCK *****
4 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 : *
6 : * The contents of this file are subject to the Mozilla Public License Version
7 : * 1.1 (the "License"); you may not use this file except in compliance with
8 : * the License. You may obtain a copy of the License at
9 : * http://www.mozilla.org/MPL/
10 : *
11 : * Software distributed under the License is distributed on an "AS IS" basis,
12 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 : * for the specific language governing rights and limitations under the
14 : * License.
15 : *
16 : * The Original Code is Mozilla Communicator client code, released
17 : * March 31, 1998.
18 : *
19 : * The Initial Developer of the Original Code is
20 : * Netscape Communications Corporation.
21 : * Portions created by the Initial Developer are Copyright (C) 1998
22 : * the Initial Developer. All Rights Reserved.
23 : *
24 : * Contributor(s):
25 : * John Bandhauer <jband@netscape.com>
26 : *
27 : * Alternatively, the contents of this file may be used under the terms of
28 : * either of the GNU General Public License Version 2 or later (the "GPL"),
29 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 : * in which case the provisions of the GPL or the LGPL are applicable instead
31 : * of those above. If you wish to allow use of your version of this file only
32 : * under the terms of either the GPL or the LGPL, and not to allow others to
33 : * use your version of this file under the terms of the MPL, indicate your
34 : * decision by deleting the provisions above and replace them with the notice
35 : * and other provisions required by the GPL or the LGPL. If you do not delete
36 : * the provisions above, a recipient may use your version of this file under
37 : * the terms of any one of the MPL, the GPL or the LGPL.
38 : *
39 : * ***** END LICENSE BLOCK ***** */
40 :
41 : #include "xpctest_private.h"
42 :
43 18 : NS_IMPL_ISUPPORTS1(xpcTestObjectReadOnly, nsIXPCTestObjectReadOnly)
44 :
45 1 : xpcTestObjectReadOnly :: xpcTestObjectReadOnly() {
46 1 : boolProperty = true;
47 1 : shortProperty = 32767;
48 1 : longProperty = 2147483647;
49 1 : floatProperty = 5.5f;
50 1 : charProperty = 'X';
51 1 : }
52 :
53 1 : NS_IMETHODIMP xpcTestObjectReadOnly :: GetStrReadOnly(char * *aStrReadOnly){
54 1 : char aString[] = "XPConnect Read-Only String";
55 :
56 1 : if (!aStrReadOnly)
57 0 : return NS_ERROR_NULL_POINTER;
58 : *aStrReadOnly = (char*) nsMemory::Clone(aString,
59 1 : sizeof(char)*(strlen(aString)+1));
60 1 : return *aStrReadOnly ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
61 : }
62 :
63 1 : NS_IMETHODIMP xpcTestObjectReadOnly :: GetBoolReadOnly(bool *aBoolReadOnly) {
64 1 : *aBoolReadOnly = boolProperty;
65 1 : return NS_OK;
66 : }
67 1 : NS_IMETHODIMP xpcTestObjectReadOnly :: GetShortReadOnly(PRInt16 *aShortReadOnly){
68 1 : *aShortReadOnly = shortProperty;
69 1 : return NS_OK;
70 : }
71 1 : NS_IMETHODIMP xpcTestObjectReadOnly :: GetLongReadOnly(PRInt32 *aLongReadOnly){
72 1 : *aLongReadOnly = longProperty;
73 1 : return NS_OK;
74 : }
75 2 : NS_IMETHODIMP xpcTestObjectReadOnly :: GetFloatReadOnly(float *aFloatReadOnly){
76 2 : *aFloatReadOnly = floatProperty;
77 2 : return NS_OK;
78 : }
79 1 : NS_IMETHODIMP xpcTestObjectReadOnly :: GetCharReadOnly(char *aCharReadOnly){
80 1 : *aCharReadOnly = charProperty;
81 1 : return NS_OK;
82 : }
83 :
84 18 : NS_IMPL_ISUPPORTS1(xpcTestObjectReadWrite, nsIXPCTestObjectReadWrite)
85 :
86 1 : xpcTestObjectReadWrite :: xpcTestObjectReadWrite() {
87 1 : const char s[] = "XPConnect Read-Writable String";
88 1 : stringProperty = (char*) nsMemory::Clone(s, sizeof(char)*(strlen(s)+1));
89 1 : boolProperty = true;
90 1 : shortProperty = 32767;
91 1 : longProperty = 2147483647;
92 1 : floatProperty = 5.5f;
93 1 : charProperty = 'X';
94 1 : }
95 :
96 1 : xpcTestObjectReadWrite :: ~xpcTestObjectReadWrite()
97 : {
98 1 : nsMemory::Free(stringProperty);
99 1 : }
100 :
101 2 : NS_IMETHODIMP xpcTestObjectReadWrite :: GetStringProperty(char * *aStringProperty) {
102 2 : if (!aStringProperty)
103 0 : return NS_ERROR_NULL_POINTER;
104 : *aStringProperty = (char*) nsMemory::Clone(stringProperty,
105 2 : sizeof(char)*(strlen(stringProperty)+1));
106 2 : return *aStringProperty ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
107 :
108 : }
109 1 : NS_IMETHODIMP xpcTestObjectReadWrite :: SetStringProperty(const char * aStringProperty) {
110 1 : nsMemory::Free(stringProperty);
111 : stringProperty = (char*) nsMemory::Clone(aStringProperty,
112 1 : sizeof(char)*(strlen(aStringProperty)+1));
113 1 : return NS_OK;
114 : }
115 :
116 9 : NS_IMETHODIMP xpcTestObjectReadWrite :: GetBooleanProperty(bool *aBooleanProperty) {
117 9 : *aBooleanProperty = boolProperty;
118 9 : return NS_OK;
119 : }
120 8 : NS_IMETHODIMP xpcTestObjectReadWrite :: SetBooleanProperty(bool aBooleanProperty) {
121 8 : boolProperty = aBooleanProperty;
122 8 : return NS_OK;
123 : }
124 2 : NS_IMETHODIMP xpcTestObjectReadWrite :: GetShortProperty(PRInt16 *aShortProperty) {
125 2 : *aShortProperty = shortProperty;
126 2 : return NS_OK;
127 : }
128 1 : NS_IMETHODIMP xpcTestObjectReadWrite :: SetShortProperty(PRInt16 aShortProperty) {
129 1 : shortProperty = aShortProperty;
130 1 : return NS_OK;
131 : }
132 2 : NS_IMETHODIMP xpcTestObjectReadWrite :: GetLongProperty(PRInt32 *aLongProperty) {
133 2 : *aLongProperty = longProperty;
134 2 : return NS_OK;
135 : }
136 1 : NS_IMETHODIMP xpcTestObjectReadWrite :: SetLongProperty(PRInt32 aLongProperty) {
137 1 : longProperty = aLongProperty;
138 1 : return NS_OK;
139 : }
140 4 : NS_IMETHODIMP xpcTestObjectReadWrite :: GetFloatProperty(float *aFloatProperty) {
141 4 : *aFloatProperty = floatProperty;
142 4 : return NS_OK;
143 : }
144 1 : NS_IMETHODIMP xpcTestObjectReadWrite :: SetFloatProperty(float aFloatProperty) {
145 1 : floatProperty = aFloatProperty;
146 1 : return NS_OK;
147 : }
148 2 : NS_IMETHODIMP xpcTestObjectReadWrite :: GetCharProperty(char *aCharProperty) {
149 2 : *aCharProperty = charProperty;
150 2 : return NS_OK;
151 : }
152 1 : NS_IMETHODIMP xpcTestObjectReadWrite :: SetCharProperty(char aCharProperty) {
153 1 : charProperty = aCharProperty;
154 1 : return NS_OK;
155 : }
|