Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/xpcom/ds/nsSupportsPrimitives.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
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 "nsSupportsPrimitives.h"
8
#include "nsMemory.h"
9
#include "mozilla/Assertions.h"
10
#include "mozilla/IntegerPrintfMacros.h"
11
#include "mozilla/Sprintf.h"
12
#include <algorithm>
13
14
template<typename T>
15
static char*
16
DataToString(const char* aFormat, T aData)
17
0
{
18
0
  static const int size = 32;
19
0
  char buf[size];
20
0
21
0
  SprintfLiteral(buf, aFormat, aData);
22
0
23
0
  return moz_xstrdup(buf);
24
0
}
Unexecuted instantiation: Unified_cpp_xpcom_ds1.cpp:char* DataToString<unsigned int>(char const*, unsigned int)
Unexecuted instantiation: Unified_cpp_xpcom_ds1.cpp:char* DataToString<unsigned long>(char const*, unsigned long)
Unexecuted instantiation: Unified_cpp_xpcom_ds1.cpp:char* DataToString<long>(char const*, long)
Unexecuted instantiation: Unified_cpp_xpcom_ds1.cpp:char* DataToString<int>(char const*, int)
Unexecuted instantiation: Unified_cpp_xpcom_ds1.cpp:char* DataToString<double>(char const*, double)
25
26
/***************************************************************************/
27
28
NS_IMPL_ISUPPORTS(nsSupportsID, nsISupportsID, nsISupportsPrimitive)
29
30
nsSupportsID::nsSupportsID()
31
  : mData(nullptr)
32
0
{
33
0
}
34
35
NS_IMETHODIMP
36
nsSupportsID::GetType(uint16_t* aType)
37
0
{
38
0
  NS_ASSERTION(aType, "Bad pointer");
39
0
  *aType = TYPE_ID;
40
0
  return NS_OK;
41
0
}
42
43
NS_IMETHODIMP
44
nsSupportsID::GetData(nsID** aData)
45
0
{
46
0
  NS_ASSERTION(aData, "Bad pointer");
47
0
48
0
  *aData = mData ? mData->Clone() : nullptr;
49
0
  return NS_OK;
50
0
}
51
52
NS_IMETHODIMP
53
nsSupportsID::SetData(const nsID* aData)
54
0
{
55
0
  if (mData) {
56
0
    free(mData);
57
0
  }
58
0
59
0
  mData = aData ? aData->Clone() : nullptr;
60
0
  return NS_OK;
61
0
}
62
63
NS_IMETHODIMP
64
nsSupportsID::ToString(char** aResult)
65
0
{
66
0
  NS_ASSERTION(aResult, "Bad pointer");
67
0
68
0
  if (mData) {
69
0
    *aResult = mData->ToString();
70
0
  } else {
71
0
    *aResult = moz_xstrdup("null");
72
0
  }
73
0
74
0
  return NS_OK;
75
0
}
76
77
/*****************************************************************************
78
 * nsSupportsCString
79
 *****************************************************************************/
80
81
NS_IMPL_ISUPPORTS(nsSupportsCString, nsISupportsCString,
82
                  nsISupportsPrimitive)
83
84
NS_IMETHODIMP
85
nsSupportsCString::GetType(uint16_t* aType)
86
0
{
87
0
  NS_ASSERTION(aType, "Bad pointer");
88
0
  *aType = TYPE_CSTRING;
89
0
  return NS_OK;
90
0
}
91
92
NS_IMETHODIMP
93
nsSupportsCString::GetData(nsACString& aData)
94
0
{
95
0
  aData = mData;
96
0
  return NS_OK;
97
0
}
98
99
NS_IMETHODIMP
100
nsSupportsCString::ToString(char** aResult)
101
0
{
102
0
  *aResult = ToNewCString(mData);
103
0
  if (!*aResult) {
104
0
    return NS_ERROR_OUT_OF_MEMORY;
105
0
  }
106
0
107
0
  return NS_OK;
108
0
}
109
110
NS_IMETHODIMP
111
nsSupportsCString::SetData(const nsACString& aData)
112
0
{
113
0
  bool ok = mData.Assign(aData, mozilla::fallible);
114
0
  if (!ok) {
115
0
    return NS_ERROR_OUT_OF_MEMORY;
116
0
  }
117
0
118
0
  return NS_OK;
119
0
}
120
121
/*****************************************************************************
122
 * nsSupportsString
123
 *****************************************************************************/
124
125
NS_IMPL_ISUPPORTS(nsSupportsString, nsISupportsString,
126
                  nsISupportsPrimitive)
127
128
NS_IMETHODIMP
129
nsSupportsString::GetType(uint16_t* aType)
130
0
{
131
0
  NS_ASSERTION(aType, "Bad pointer");
132
0
  *aType = TYPE_STRING;
133
0
  return NS_OK;
134
0
}
135
136
NS_IMETHODIMP
137
nsSupportsString::GetData(nsAString& aData)
138
0
{
139
0
  aData = mData;
140
0
  return NS_OK;
141
0
}
142
143
NS_IMETHODIMP
144
nsSupportsString::ToString(char16_t** aResult)
145
0
{
146
0
  *aResult = ToNewUnicode(mData);
147
0
  if (!*aResult) {
148
0
    return NS_ERROR_OUT_OF_MEMORY;
149
0
  }
150
0
151
0
  return NS_OK;
152
0
}
153
154
NS_IMETHODIMP
155
nsSupportsString::SetData(const nsAString& aData)
156
0
{
157
0
  bool ok = mData.Assign(aData, mozilla::fallible);
158
0
  if (!ok) {
159
0
    return NS_ERROR_OUT_OF_MEMORY;
160
0
  }
161
0
162
0
  return NS_OK;
163
0
}
164
165
/***************************************************************************/
166
167
NS_IMPL_ISUPPORTS(nsSupportsPRBool, nsISupportsPRBool,
168
                  nsISupportsPrimitive)
169
170
nsSupportsPRBool::nsSupportsPRBool()
171
  : mData(false)
172
0
{
173
0
}
174
175
NS_IMETHODIMP
176
nsSupportsPRBool::GetType(uint16_t* aType)
177
0
{
178
0
  NS_ASSERTION(aType, "Bad pointer");
179
0
  *aType = TYPE_PRBOOL;
180
0
  return NS_OK;
181
0
}
182
183
NS_IMETHODIMP
184
nsSupportsPRBool::GetData(bool* aData)
185
0
{
186
0
  NS_ASSERTION(aData, "Bad pointer");
187
0
  *aData = mData;
188
0
  return NS_OK;
189
0
}
190
191
NS_IMETHODIMP
192
nsSupportsPRBool::SetData(bool aData)
193
0
{
194
0
  mData = aData;
195
0
  return NS_OK;
196
0
}
197
198
NS_IMETHODIMP
199
nsSupportsPRBool::ToString(char** aResult)
200
0
{
201
0
  NS_ASSERTION(aResult, "Bad pointer");
202
0
  *aResult = moz_xstrdup(mData ? "true" : "false");
203
0
  return NS_OK;
204
0
}
205
206
/***************************************************************************/
207
208
NS_IMPL_ISUPPORTS(nsSupportsPRUint8, nsISupportsPRUint8,
209
                  nsISupportsPrimitive)
210
211
nsSupportsPRUint8::nsSupportsPRUint8()
212
  : mData(0)
213
0
{
214
0
}
215
216
NS_IMETHODIMP
217
nsSupportsPRUint8::GetType(uint16_t* aType)
218
0
{
219
0
  NS_ASSERTION(aType, "Bad pointer");
220
0
  *aType = TYPE_PRUINT8;
221
0
  return NS_OK;
222
0
}
223
224
NS_IMETHODIMP
225
nsSupportsPRUint8::GetData(uint8_t* aData)
226
0
{
227
0
  NS_ASSERTION(aData, "Bad pointer");
228
0
  *aData = mData;
229
0
  return NS_OK;
230
0
}
231
232
NS_IMETHODIMP
233
nsSupportsPRUint8::SetData(uint8_t aData)
234
0
{
235
0
  mData = aData;
236
0
  return NS_OK;
237
0
}
238
239
NS_IMETHODIMP
240
nsSupportsPRUint8::ToString(char** aResult)
241
0
{
242
0
  NS_ASSERTION(aResult, "Bad pointer");
243
0
  *aResult = DataToString("%u", static_cast<unsigned int>(mData));
244
0
  return NS_OK;
245
0
}
246
247
/***************************************************************************/
248
249
NS_IMPL_ISUPPORTS(nsSupportsPRUint16, nsISupportsPRUint16,
250
                  nsISupportsPrimitive)
251
252
nsSupportsPRUint16::nsSupportsPRUint16()
253
  : mData(0)
254
0
{
255
0
}
256
257
NS_IMETHODIMP
258
nsSupportsPRUint16::GetType(uint16_t* aType)
259
0
{
260
0
  NS_ASSERTION(aType, "Bad pointer");
261
0
  *aType = TYPE_PRUINT16;
262
0
  return NS_OK;
263
0
}
264
265
NS_IMETHODIMP
266
nsSupportsPRUint16::GetData(uint16_t* aData)
267
0
{
268
0
  NS_ASSERTION(aData, "Bad pointer");
269
0
  *aData = mData;
270
0
  return NS_OK;
271
0
}
272
273
NS_IMETHODIMP
274
nsSupportsPRUint16::SetData(uint16_t aData)
275
0
{
276
0
  mData = aData;
277
0
  return NS_OK;
278
0
}
279
280
NS_IMETHODIMP
281
nsSupportsPRUint16::ToString(char** aResult)
282
0
{
283
0
  NS_ASSERTION(aResult, "Bad pointer");
284
0
  *aResult = DataToString("%u", static_cast<unsigned int>(mData));
285
0
  return NS_OK;
286
0
}
287
288
/***************************************************************************/
289
290
NS_IMPL_ISUPPORTS(nsSupportsPRUint32, nsISupportsPRUint32,
291
                  nsISupportsPrimitive)
292
293
nsSupportsPRUint32::nsSupportsPRUint32()
294
  : mData(0)
295
0
{
296
0
}
297
298
NS_IMETHODIMP
299
nsSupportsPRUint32::GetType(uint16_t* aType)
300
0
{
301
0
  NS_ASSERTION(aType, "Bad pointer");
302
0
  *aType = TYPE_PRUINT32;
303
0
  return NS_OK;
304
0
}
305
306
NS_IMETHODIMP
307
nsSupportsPRUint32::GetData(uint32_t* aData)
308
0
{
309
0
  NS_ASSERTION(aData, "Bad pointer");
310
0
  *aData = mData;
311
0
  return NS_OK;
312
0
}
313
314
NS_IMETHODIMP
315
nsSupportsPRUint32::SetData(uint32_t aData)
316
0
{
317
0
  mData = aData;
318
0
  return NS_OK;
319
0
}
320
321
NS_IMETHODIMP
322
nsSupportsPRUint32::ToString(char** aResult)
323
0
{
324
0
  NS_ASSERTION(aResult, "Bad pointer");
325
0
  *aResult = DataToString("%u", mData);
326
0
  return NS_OK;
327
0
}
328
329
/***************************************************************************/
330
331
NS_IMPL_ISUPPORTS(nsSupportsPRUint64, nsISupportsPRUint64,
332
                  nsISupportsPrimitive)
333
334
nsSupportsPRUint64::nsSupportsPRUint64()
335
  : mData(0)
336
0
{
337
0
}
338
339
NS_IMETHODIMP
340
nsSupportsPRUint64::GetType(uint16_t* aType)
341
0
{
342
0
  NS_ASSERTION(aType, "Bad pointer");
343
0
  *aType = TYPE_PRUINT64;
344
0
  return NS_OK;
345
0
}
346
347
NS_IMETHODIMP
348
nsSupportsPRUint64::GetData(uint64_t* aData)
349
0
{
350
0
  NS_ASSERTION(aData, "Bad pointer");
351
0
  *aData = mData;
352
0
  return NS_OK;
353
0
}
354
355
NS_IMETHODIMP
356
nsSupportsPRUint64::SetData(uint64_t aData)
357
0
{
358
0
  mData = aData;
359
0
  return NS_OK;
360
0
}
361
362
NS_IMETHODIMP
363
nsSupportsPRUint64::ToString(char** aResult)
364
0
{
365
0
  NS_ASSERTION(aResult, "Bad pointer");
366
0
  *aResult = DataToString("%llu", mData);
367
0
  return NS_OK;
368
0
}
369
370
/***************************************************************************/
371
372
NS_IMPL_ISUPPORTS(nsSupportsPRTime, nsISupportsPRTime,
373
                  nsISupportsPrimitive)
374
375
nsSupportsPRTime::nsSupportsPRTime()
376
  : mData(0)
377
0
{
378
0
}
379
380
NS_IMETHODIMP
381
nsSupportsPRTime::GetType(uint16_t* aType)
382
0
{
383
0
  NS_ASSERTION(aType, "Bad pointer");
384
0
  *aType = TYPE_PRTIME;
385
0
  return NS_OK;
386
0
}
387
388
NS_IMETHODIMP
389
nsSupportsPRTime::GetData(PRTime* aData)
390
0
{
391
0
  NS_ASSERTION(aData, "Bad pointer");
392
0
  *aData = mData;
393
0
  return NS_OK;
394
0
}
395
396
NS_IMETHODIMP
397
nsSupportsPRTime::SetData(PRTime aData)
398
0
{
399
0
  mData = aData;
400
0
  return NS_OK;
401
0
}
402
403
NS_IMETHODIMP
404
nsSupportsPRTime::ToString(char** aResult)
405
0
{
406
0
  NS_ASSERTION(aResult, "Bad pointer");
407
0
  *aResult = DataToString("%" PRIu64, mData);
408
0
  return NS_OK;
409
0
}
410
411
/***************************************************************************/
412
413
NS_IMPL_ISUPPORTS(nsSupportsChar, nsISupportsChar,
414
                  nsISupportsPrimitive)
415
416
nsSupportsChar::nsSupportsChar()
417
  : mData(0)
418
0
{
419
0
}
420
421
NS_IMETHODIMP
422
nsSupportsChar::GetType(uint16_t* aType)
423
0
{
424
0
  NS_ASSERTION(aType, "Bad pointer");
425
0
  *aType = TYPE_CHAR;
426
0
  return NS_OK;
427
0
}
428
429
NS_IMETHODIMP
430
nsSupportsChar::GetData(char* aData)
431
0
{
432
0
  NS_ASSERTION(aData, "Bad pointer");
433
0
  *aData = mData;
434
0
  return NS_OK;
435
0
}
436
437
NS_IMETHODIMP
438
nsSupportsChar::SetData(char aData)
439
0
{
440
0
  mData = aData;
441
0
  return NS_OK;
442
0
}
443
444
NS_IMETHODIMP
445
nsSupportsChar::ToString(char** aResult)
446
0
{
447
0
  NS_ASSERTION(aResult, "Bad pointer");
448
0
  *aResult = static_cast<char*>(moz_xmalloc(2 * sizeof(char)));
449
0
  *aResult[0] = mData;
450
0
  *aResult[1] = '\0';
451
0
452
0
  return NS_OK;
453
0
}
454
455
/***************************************************************************/
456
457
NS_IMPL_ISUPPORTS(nsSupportsPRInt16, nsISupportsPRInt16,
458
                  nsISupportsPrimitive)
459
460
nsSupportsPRInt16::nsSupportsPRInt16()
461
  : mData(0)
462
0
{
463
0
}
464
465
NS_IMETHODIMP
466
nsSupportsPRInt16::GetType(uint16_t* aType)
467
0
{
468
0
  NS_ASSERTION(aType, "Bad pointer");
469
0
  *aType = TYPE_PRINT16;
470
0
  return NS_OK;
471
0
}
472
473
NS_IMETHODIMP
474
nsSupportsPRInt16::GetData(int16_t* aData)
475
0
{
476
0
  NS_ASSERTION(aData, "Bad pointer");
477
0
  *aData = mData;
478
0
  return NS_OK;
479
0
}
480
481
NS_IMETHODIMP
482
nsSupportsPRInt16::SetData(int16_t aData)
483
0
{
484
0
  mData = aData;
485
0
  return NS_OK;
486
0
}
487
488
NS_IMETHODIMP
489
nsSupportsPRInt16::ToString(char** aResult)
490
0
{
491
0
  NS_ASSERTION(aResult, "Bad pointer");
492
0
  *aResult = DataToString("%d", static_cast<int>(mData));
493
0
  return NS_OK;
494
0
}
495
496
/***************************************************************************/
497
498
NS_IMPL_ISUPPORTS(nsSupportsPRInt32, nsISupportsPRInt32,
499
                  nsISupportsPrimitive)
500
501
nsSupportsPRInt32::nsSupportsPRInt32()
502
  : mData(0)
503
0
{
504
0
}
505
506
NS_IMETHODIMP
507
nsSupportsPRInt32::GetType(uint16_t* aType)
508
0
{
509
0
  NS_ASSERTION(aType, "Bad pointer");
510
0
  *aType = TYPE_PRINT32;
511
0
  return NS_OK;
512
0
}
513
514
NS_IMETHODIMP
515
nsSupportsPRInt32::GetData(int32_t* aData)
516
0
{
517
0
  NS_ASSERTION(aData, "Bad pointer");
518
0
  *aData = mData;
519
0
  return NS_OK;
520
0
}
521
522
NS_IMETHODIMP
523
nsSupportsPRInt32::SetData(int32_t aData)
524
0
{
525
0
  mData = aData;
526
0
  return NS_OK;
527
0
}
528
529
NS_IMETHODIMP
530
nsSupportsPRInt32::ToString(char** aResult)
531
0
{
532
0
  NS_ASSERTION(aResult, "Bad pointer");
533
0
  *aResult = DataToString("%d", mData);
534
0
  return NS_OK;
535
0
}
536
537
/***************************************************************************/
538
539
NS_IMPL_ISUPPORTS(nsSupportsPRInt64, nsISupportsPRInt64,
540
                  nsISupportsPrimitive)
541
542
nsSupportsPRInt64::nsSupportsPRInt64()
543
  : mData(0)
544
0
{
545
0
}
546
547
NS_IMETHODIMP
548
nsSupportsPRInt64::GetType(uint16_t* aType)
549
0
{
550
0
  NS_ASSERTION(aType, "Bad pointer");
551
0
  *aType = TYPE_PRINT64;
552
0
  return NS_OK;
553
0
}
554
555
NS_IMETHODIMP
556
nsSupportsPRInt64::GetData(int64_t* aData)
557
0
{
558
0
  NS_ASSERTION(aData, "Bad pointer");
559
0
  *aData = mData;
560
0
  return NS_OK;
561
0
}
562
563
NS_IMETHODIMP
564
nsSupportsPRInt64::SetData(int64_t aData)
565
0
{
566
0
  mData = aData;
567
0
  return NS_OK;
568
0
}
569
570
NS_IMETHODIMP
571
nsSupportsPRInt64::ToString(char** aResult)
572
0
{
573
0
  NS_ASSERTION(aResult, "Bad pointer");
574
0
  *aResult = DataToString("%" PRId64, mData);
575
0
  return NS_OK;
576
0
}
577
578
/***************************************************************************/
579
580
NS_IMPL_ISUPPORTS(nsSupportsFloat, nsISupportsFloat,
581
                  nsISupportsPrimitive)
582
583
nsSupportsFloat::nsSupportsFloat()
584
  : mData(float(0.0))
585
0
{
586
0
}
587
588
NS_IMETHODIMP
589
nsSupportsFloat::GetType(uint16_t* aType)
590
0
{
591
0
  NS_ASSERTION(aType, "Bad pointer");
592
0
  *aType = TYPE_FLOAT;
593
0
  return NS_OK;
594
0
}
595
596
NS_IMETHODIMP
597
nsSupportsFloat::GetData(float* aData)
598
0
{
599
0
  NS_ASSERTION(aData, "Bad pointer");
600
0
  *aData = mData;
601
0
  return NS_OK;
602
0
}
603
604
NS_IMETHODIMP
605
nsSupportsFloat::SetData(float aData)
606
0
{
607
0
  mData = aData;
608
0
  return NS_OK;
609
0
}
610
611
NS_IMETHODIMP
612
nsSupportsFloat::ToString(char** aResult)
613
0
{
614
0
  NS_ASSERTION(aResult, "Bad pointer");
615
0
  *aResult = DataToString("%f", static_cast<double>(mData));
616
0
  return NS_OK;
617
0
}
618
619
/***************************************************************************/
620
621
NS_IMPL_ISUPPORTS(nsSupportsDouble, nsISupportsDouble,
622
                  nsISupportsPrimitive)
623
624
nsSupportsDouble::nsSupportsDouble()
625
  : mData(double(0.0))
626
0
{
627
0
}
628
629
NS_IMETHODIMP
630
nsSupportsDouble::GetType(uint16_t* aType)
631
0
{
632
0
  NS_ASSERTION(aType, "Bad pointer");
633
0
  *aType = TYPE_DOUBLE;
634
0
  return NS_OK;
635
0
}
636
637
NS_IMETHODIMP
638
nsSupportsDouble::GetData(double* aData)
639
0
{
640
0
  NS_ASSERTION(aData, "Bad pointer");
641
0
  *aData = mData;
642
0
  return NS_OK;
643
0
}
644
645
NS_IMETHODIMP
646
nsSupportsDouble::SetData(double aData)
647
0
{
648
0
  mData = aData;
649
0
  return NS_OK;
650
0
}
651
652
NS_IMETHODIMP
653
nsSupportsDouble::ToString(char** aResult)
654
0
{
655
0
  NS_ASSERTION(aResult, "Bad pointer");
656
0
  *aResult = DataToString("%f", mData);
657
0
  return  NS_OK;
658
0
}
659
660
/***************************************************************************/
661
662
663
NS_IMPL_ISUPPORTS(nsSupportsInterfacePointer,
664
                  nsISupportsInterfacePointer,
665
                  nsISupportsPrimitive)
666
667
nsSupportsInterfacePointer::nsSupportsInterfacePointer()
668
  : mIID(nullptr)
669
0
{
670
0
}
671
672
nsSupportsInterfacePointer::~nsSupportsInterfacePointer()
673
0
{
674
0
  if (mIID) {
675
0
    free(mIID);
676
0
  }
677
0
}
678
679
NS_IMETHODIMP
680
nsSupportsInterfacePointer::GetType(uint16_t* aType)
681
0
{
682
0
  NS_ASSERTION(aType, "Bad pointer");
683
0
  *aType = TYPE_INTERFACE_POINTER;
684
0
  return NS_OK;
685
0
}
686
687
NS_IMETHODIMP
688
nsSupportsInterfacePointer::GetData(nsISupports** aData)
689
0
{
690
0
  NS_ASSERTION(aData, "Bad pointer");
691
0
  *aData = mData;
692
0
  NS_IF_ADDREF(*aData);
693
0
  return NS_OK;
694
0
}
695
696
NS_IMETHODIMP
697
nsSupportsInterfacePointer::SetData(nsISupports* aData)
698
0
{
699
0
  mData = aData;
700
0
  return NS_OK;
701
0
}
702
703
NS_IMETHODIMP
704
nsSupportsInterfacePointer::GetDataIID(nsID** aIID)
705
0
{
706
0
  NS_ASSERTION(aIID, "Bad pointer");
707
0
708
0
  *aIID = mIID ? mIID->Clone() : nullptr;
709
0
  return NS_OK;
710
0
}
711
712
NS_IMETHODIMP
713
nsSupportsInterfacePointer::SetDataIID(const nsID* aIID)
714
0
{
715
0
  if (mIID) {
716
0
    free(mIID);
717
0
  }
718
0
719
0
  mIID = aIID ? aIID->Clone() : nullptr;
720
0
  return NS_OK;
721
0
}
722
723
NS_IMETHODIMP
724
nsSupportsInterfacePointer::ToString(char** aResult)
725
0
{
726
0
  NS_ASSERTION(aResult, "Bad pointer");
727
0
728
0
  // jband sez: think about asking nsIInterfaceInfoManager whether
729
0
  // the interface has a known human-readable name
730
0
  *aResult = moz_xstrdup("[interface pointer]");
731
0
  return NS_OK;
732
0
}
733
734
/***************************************************************************/
735
736
NS_IMPL_ISUPPORTS(nsSupportsDependentCString, nsISupportsCString,
737
                  nsISupportsPrimitive)
738
739
nsSupportsDependentCString::nsSupportsDependentCString(const char* aStr)
740
  : mData(aStr)
741
0
{ }
742
743
NS_IMETHODIMP
744
nsSupportsDependentCString::GetType(uint16_t* aType)
745
0
{
746
0
  if (NS_WARN_IF(!aType)) {
747
0
    return NS_ERROR_INVALID_ARG;
748
0
  }
749
0
750
0
  *aType = TYPE_CSTRING;
751
0
  return NS_OK;
752
0
}
753
754
NS_IMETHODIMP
755
nsSupportsDependentCString::GetData(nsACString& aData)
756
0
{
757
0
  aData = mData;
758
0
  return NS_OK;
759
0
}
760
761
NS_IMETHODIMP
762
nsSupportsDependentCString::ToString(char** aResult)
763
0
{
764
0
  if (NS_WARN_IF(!aResult)) {
765
0
    return NS_ERROR_INVALID_ARG;
766
0
  }
767
0
768
0
  *aResult = ToNewCString(mData);
769
0
  if (!*aResult) {
770
0
    return NS_ERROR_OUT_OF_MEMORY;
771
0
  }
772
0
773
0
  return NS_OK;
774
0
}
775
776
NS_IMETHODIMP
777
nsSupportsDependentCString::SetData(const nsACString& aData)
778
0
{
779
0
  return NS_ERROR_NOT_IMPLEMENTED;
780
0
}