no bug - Import translations from android-l10n r=release a=l10n CLOSED TREE
[gecko.git] / js / xpconnect / tests / components / native / xpctest_attributes.cpp
blob180c1f76067e3d46d0d6ed732657b175b1e8967c
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() {
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;
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;
28 NS_IMETHODIMP xpcTestObjectReadOnly ::GetBoolReadOnly(bool* aBoolReadOnly) {
29 *aBoolReadOnly = boolProperty;
30 return NS_OK;
32 NS_IMETHODIMP xpcTestObjectReadOnly ::GetShortReadOnly(
33 int16_t* aShortReadOnly) {
34 *aShortReadOnly = shortProperty;
35 return NS_OK;
37 NS_IMETHODIMP xpcTestObjectReadOnly ::GetLongReadOnly(int32_t* aLongReadOnly) {
38 *aLongReadOnly = longProperty;
39 return NS_OK;
41 NS_IMETHODIMP xpcTestObjectReadOnly ::GetFloatReadOnly(float* aFloatReadOnly) {
42 *aFloatReadOnly = floatProperty;
43 return NS_OK;
45 NS_IMETHODIMP xpcTestObjectReadOnly ::GetCharReadOnly(char* aCharReadOnly) {
46 *aCharReadOnly = charProperty;
47 return NS_OK;
49 NS_IMETHODIMP xpcTestObjectReadOnly ::GetTimeReadOnly(PRTime* aTimeReadOnly) {
50 *aTimeReadOnly = timeProperty;
51 return NS_OK;
54 NS_IMPL_ISUPPORTS(xpcTestObjectReadWrite, nsIXPCTestObjectReadWrite)
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;
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);
76 return NS_OK;
78 NS_IMETHODIMP xpcTestObjectReadWrite ::SetStringProperty(
79 const char* aStringProperty) {
80 free(stringProperty);
81 stringProperty = moz_xstrdup(aStringProperty);
82 return NS_OK;
85 NS_IMETHODIMP xpcTestObjectReadWrite ::GetBooleanProperty(
86 bool* aBooleanProperty) {
87 *aBooleanProperty = boolProperty;
88 return NS_OK;
90 NS_IMETHODIMP xpcTestObjectReadWrite ::SetBooleanProperty(
91 bool aBooleanProperty) {
92 boolProperty = aBooleanProperty;
93 return NS_OK;
95 NS_IMETHODIMP xpcTestObjectReadWrite ::GetShortProperty(
96 int16_t* aShortProperty) {
97 *aShortProperty = shortProperty;
98 return NS_OK;
100 NS_IMETHODIMP xpcTestObjectReadWrite ::SetShortProperty(
101 int16_t aShortProperty) {
102 shortProperty = aShortProperty;
103 return NS_OK;
105 NS_IMETHODIMP xpcTestObjectReadWrite ::GetLongProperty(int32_t* aLongProperty) {
106 *aLongProperty = longProperty;
107 return NS_OK;
109 NS_IMETHODIMP xpcTestObjectReadWrite ::SetLongProperty(int32_t aLongProperty) {
110 longProperty = aLongProperty;
111 return NS_OK;
113 NS_IMETHODIMP xpcTestObjectReadWrite ::GetFloatProperty(float* aFloatProperty) {
114 *aFloatProperty = floatProperty;
115 return NS_OK;
117 NS_IMETHODIMP xpcTestObjectReadWrite ::SetFloatProperty(float aFloatProperty) {
118 floatProperty = aFloatProperty;
119 return NS_OK;
121 NS_IMETHODIMP xpcTestObjectReadWrite ::GetCharProperty(char* aCharProperty) {
122 *aCharProperty = charProperty;
123 return NS_OK;
125 NS_IMETHODIMP xpcTestObjectReadWrite ::SetCharProperty(char aCharProperty) {
126 charProperty = aCharProperty;
127 return NS_OK;
129 NS_IMETHODIMP xpcTestObjectReadWrite ::GetTimeProperty(PRTime* aTimeProperty) {
130 *aTimeProperty = timeProperty;
131 return NS_OK;
133 NS_IMETHODIMP xpcTestObjectReadWrite ::SetTimeProperty(PRTime aTimeProperty) {
134 timeProperty = aTimeProperty;
135 return NS_OK;