34 #include <nsStringAPI.h>
38 #include <nsAutoLock.h>
55 PRIntn decpt, sign, numdigits;
61 num = (
char*)malloc(bufsz);
66 if (PR_dtoa(fval, 2, prcsn, &decpt, &sign, &endnum, num, bufsz)
71 numdigits = endnum -
num;
80 if (sign && fval < 0.0f) {
85 while ((*bufp++ = *nump++) != 0) {}
89 if (decpt > (prcsn+1) || decpt < -(prcsn-1) || decpt < -5) {
95 while (*nump !=
'\0') {
99 PR_snprintf(bufp, bufsz - (bufp - buf),
"%+d", decpt-1);
101 else if (decpt >= 0) {
117 while (*nump !=
'\0') {
123 else if (decpt < 0) {
130 while (*nump !=
'\0') {
142 double value = PR_strtod(aString, &next);
144 return NS_ERROR_CANNOT_CONVERT_DATA;
151 char* pChars = ToNewCString(NS_ConvertUTF16toUTF8(aString));
153 return NS_ERROR_OUT_OF_MEMORY;
166 return String2Double(PromiseFlatCString(aString).
get(), retval);
180 #define CASE__NUMBER_INT32(type_, member_) \
181 case nsIDataType :: type_ : \
182 outData->u.mInt32Value = inData.u. member_ ; \
183 outData->mType = nsIDataType::VTYPE_INT32; \
195 #undef CASE__NUMBER_INT32
199 case nsIDataType::VTYPE_UINT32:
201 outData->
mType = nsIDataType::VTYPE_INT32;
206 case nsIDataType::VTYPE_INT64:
207 case nsIDataType::VTYPE_UINT64:
211 outData->
mType = nsIDataType::VTYPE_DOUBLE;
213 case nsIDataType::VTYPE_FLOAT:
215 outData->
mType = nsIDataType::VTYPE_DOUBLE;
217 case nsIDataType::VTYPE_DOUBLE:
219 outData->
mType = nsIDataType::VTYPE_DOUBLE;
221 case nsIDataType::VTYPE_CHAR_STR:
222 case nsIDataType::VTYPE_STRING_SIZE_IS:
226 outData->
mType = nsIDataType::VTYPE_DOUBLE;
228 case nsIDataType::VTYPE_DOMSTRING:
229 case nsIDataType::VTYPE_ASTRING:
233 outData->
mType = nsIDataType::VTYPE_DOUBLE;
235 case nsIDataType::VTYPE_UTF8STRING:
240 outData->
mType = nsIDataType::VTYPE_DOUBLE;
242 case nsIDataType::VTYPE_CSTRING:
247 outData->
mType = nsIDataType::VTYPE_DOUBLE;
249 case nsIDataType::VTYPE_WCHAR_STR:
250 case nsIDataType::VTYPE_WSTRING_SIZE_IS:
255 outData->
mType = nsIDataType::VTYPE_DOUBLE;
260 case nsIDataType::VTYPE_VOID:
261 case nsIDataType::VTYPE_ID:
262 case nsIDataType::VTYPE_INTERFACE:
263 case nsIDataType::VTYPE_INTERFACE_IS:
264 case nsIDataType::VTYPE_ARRAY:
265 case nsIDataType::VTYPE_EMPTY_ARRAY:
266 case nsIDataType::VTYPE_EMPTY:
268 return NS_ERROR_CANNOT_CONVERT_DATA;
277 NS_ASSERTION(data->
mType == nsIDataType::VTYPE_ARRAY,
"bad FreeArray call");
278 NS_ASSERTION(data->
u.
array.mArrayValue,
"bad array");
279 NS_ASSERTION(data->
u.
array.mArrayCount,
"bad array count");
281 #define CASE__FREE_ARRAY_PTR(type_, ctype_) \
282 case nsIDataType:: type_ : \
284 ctype_ ** p = (ctype_ **) data->u.array.mArrayValue; \
285 for(PRUint32 i = data->u.array.mArrayCount; i > 0; p++, i--) \
287 NS_Free((char*)*p); \
291 #define CASE__FREE_ARRAY_IFACE(type_, ctype_) \
292 case nsIDataType:: type_ : \
294 ctype_ ** p = (ctype_ **) data->u.array.mArrayValue; \
295 for(PRUint32 i = data->u.array.mArrayCount; i > 0; p++, i--) \
301 switch(data->
u.
array.mArrayType)
303 case nsIDataType::VTYPE_INT8:
304 case nsIDataType::VTYPE_INT16:
305 case nsIDataType::VTYPE_INT32:
306 case nsIDataType::VTYPE_INT64:
307 case nsIDataType::VTYPE_UINT8:
308 case nsIDataType::VTYPE_UINT16:
309 case nsIDataType::VTYPE_UINT32:
310 case nsIDataType::VTYPE_UINT64:
311 case nsIDataType::VTYPE_FLOAT:
312 case nsIDataType::VTYPE_DOUBLE:
313 case nsIDataType::VTYPE_BOOL:
314 case nsIDataType::VTYPE_CHAR:
315 case nsIDataType::VTYPE_WCHAR:
326 case nsIDataType::VTYPE_VOID:
327 case nsIDataType::VTYPE_ASTRING:
328 case nsIDataType::VTYPE_DOMSTRING:
329 case nsIDataType::VTYPE_UTF8STRING:
330 case nsIDataType::VTYPE_CSTRING:
331 case nsIDataType::VTYPE_WSTRING_SIZE_IS:
332 case nsIDataType::VTYPE_STRING_SIZE_IS:
333 case nsIDataType::VTYPE_ARRAY:
334 case nsIDataType::VTYPE_EMPTY_ARRAY:
335 case nsIDataType::VTYPE_EMPTY:
337 NS_ERROR(
"bad type in array!");
342 NS_Free((
char*)data->
u.
array.mArrayValue);
344 #undef CASE__FREE_ARRAY_PTR
345 #undef CASE__FREE_ARRAY_IFACE
348 static nsresult
CloneArray(PRUint16 inType,
const nsIID* inIID,
349 PRUint32 inCount,
void* inValue,
350 PRUint16* outType, nsIID* outIID,
351 PRUint32* outCount,
void** outValue)
353 NS_ASSERTION(inCount,
"bad param");
354 NS_ASSERTION(inValue,
"bad param");
355 NS_ASSERTION(outType,
"bad param");
356 NS_ASSERTION(outCount,
"bad param");
357 NS_ASSERTION(outValue,
"bad param");
359 PRUint32 allocatedValueCount = 0;
370 case nsIDataType::VTYPE_INT8:
371 elementSize =
sizeof(PRInt8);
373 case nsIDataType::VTYPE_INT16:
374 elementSize =
sizeof(PRInt16);
376 case nsIDataType::VTYPE_INT32:
377 elementSize =
sizeof(PRInt32);
379 case nsIDataType::VTYPE_INT64:
380 elementSize =
sizeof(PRInt64);
382 case nsIDataType::VTYPE_UINT8:
383 elementSize =
sizeof(PRUint8);
385 case nsIDataType::VTYPE_UINT16:
386 elementSize =
sizeof(PRUint16);
388 case nsIDataType::VTYPE_UINT32:
389 elementSize =
sizeof(PRUint32);
391 case nsIDataType::VTYPE_UINT64:
392 elementSize =
sizeof(PRUint64);
394 case nsIDataType::VTYPE_FLOAT:
395 elementSize =
sizeof(float);
397 case nsIDataType::VTYPE_DOUBLE:
398 elementSize =
sizeof(double);
400 case nsIDataType::VTYPE_BOOL:
401 elementSize =
sizeof(PRBool);
403 case nsIDataType::VTYPE_CHAR:
404 elementSize =
sizeof(char);
406 case nsIDataType::VTYPE_WCHAR:
407 elementSize =
sizeof(PRUnichar);
411 case nsIDataType::VTYPE_ID:
412 case nsIDataType::VTYPE_CHAR_STR:
413 case nsIDataType::VTYPE_WCHAR_STR:
414 case nsIDataType::VTYPE_INTERFACE:
415 case nsIDataType::VTYPE_INTERFACE_IS:
416 elementSize =
sizeof(
void*);
420 case nsIDataType::VTYPE_ASTRING:
421 case nsIDataType::VTYPE_DOMSTRING:
422 case nsIDataType::VTYPE_UTF8STRING:
423 case nsIDataType::VTYPE_CSTRING:
424 case nsIDataType::VTYPE_STRING_SIZE_IS:
425 case nsIDataType::VTYPE_WSTRING_SIZE_IS:
426 case nsIDataType::VTYPE_VOID:
427 case nsIDataType::VTYPE_ARRAY:
428 case nsIDataType::VTYPE_EMPTY_ARRAY:
429 case nsIDataType::VTYPE_EMPTY:
431 NS_ERROR(
"bad type in array!");
432 return NS_ERROR_CANNOT_CONVERT_DATA;
438 allocSize = inCount * elementSize;
439 *outValue = NS_Alloc(allocSize);
441 return NS_ERROR_OUT_OF_MEMORY;
447 case nsIDataType::VTYPE_INT8:
448 case nsIDataType::VTYPE_INT16:
449 case nsIDataType::VTYPE_INT32:
450 case nsIDataType::VTYPE_INT64:
451 case nsIDataType::VTYPE_UINT8:
452 case nsIDataType::VTYPE_UINT16:
453 case nsIDataType::VTYPE_UINT32:
454 case nsIDataType::VTYPE_UINT64:
455 case nsIDataType::VTYPE_FLOAT:
456 case nsIDataType::VTYPE_DOUBLE:
457 case nsIDataType::VTYPE_BOOL:
458 case nsIDataType::VTYPE_CHAR:
459 case nsIDataType::VTYPE_WCHAR:
460 memcpy(*outValue, inValue, allocSize);
463 case nsIDataType::VTYPE_INTERFACE_IS:
467 case nsIDataType::VTYPE_INTERFACE:
469 memcpy(*outValue, inValue, allocSize);
472 for(i = inCount; i > 0; p++, i--)
479 case nsIDataType::VTYPE_ID:
481 nsID** inp = (nsID**) inValue;
482 nsID** outp = (nsID**) *outValue;
483 for(i = inCount; i > 0; i--)
485 nsID* idp = *(inp++);
488 if(nsnull == (*(outp++) = (nsID*)
494 allocatedValueCount++;
499 case nsIDataType::VTYPE_CHAR_STR:
501 char** inp = (
char**) inValue;
502 char** outp = (
char**) *outValue;
503 for(i = inCount; i > 0; i--)
505 char*
str = *(inp++);
508 if(nsnull == (*(outp++) = (
char*)
514 allocatedValueCount++;
519 case nsIDataType::VTYPE_WCHAR_STR:
521 PRUnichar** inp = (PRUnichar**) inValue;
522 PRUnichar** outp = (PRUnichar**) *outValue;
523 for(i = inCount; i > 0; i--)
525 PRUnichar*
str = *(inp++);
528 if(nsnull == (*(outp++) = (PRUnichar*)
530 (nsCRT::strlen(str)+1)*
sizeof(PRUnichar))))
535 allocatedValueCount++;
541 case nsIDataType::VTYPE_VOID:
542 case nsIDataType::VTYPE_ARRAY:
543 case nsIDataType::VTYPE_EMPTY_ARRAY:
544 case nsIDataType::VTYPE_EMPTY:
545 case nsIDataType::VTYPE_ASTRING:
546 case nsIDataType::VTYPE_DOMSTRING:
547 case nsIDataType::VTYPE_UTF8STRING:
548 case nsIDataType::VTYPE_CSTRING:
549 case nsIDataType::VTYPE_STRING_SIZE_IS:
550 case nsIDataType::VTYPE_WSTRING_SIZE_IS:
552 NS_ERROR(
"bad type in array!");
553 return NS_ERROR_CANNOT_CONVERT_DATA;
563 char**
p = (
char**) *outValue;
564 for(i = allocatedValueCount; i > 0; p++, i--)
567 NS_Free((
char*)*outValue);
575 #define TRIVIAL_DATA_CONVERTER(type_, data_, member_, retval_) \
576 if(data_.mType == nsIDataType :: type_) { \
577 *retval_ = data_.u.member_; \
581 #define NUMERIC_CONVERSION_METHOD_BEGIN(type_, Ctype_, name_) \
583 sbVariant::ConvertTo##name_ (const nsDiscriminatedUnion& data, \
586 TRIVIAL_DATA_CONVERTER(type_, data, m##name_##Value, _retval) \
587 nsDiscriminatedUnion tempData; \
588 sbVariant::Initialize(&tempData); \
589 nsresult rv = ToManageableNumber(data, &tempData); \
597 switch(tempData.mType) \
600 #define CASE__NUMERIC_CONVERSION_INT32_JUST_CAST(Ctype_) \
601 case nsIDataType::VTYPE_INT32: \
602 *_retval = ( Ctype_ ) tempData.u.mInt32Value; \
605 #define CASE__NUMERIC_CONVERSION_INT32_MIN_MAX(Ctype_, min_, max_) \
606 case nsIDataType::VTYPE_INT32: \
608 PRInt32 value = tempData.u.mInt32Value; \
609 if(value < min_ || value > max_) \
610 return NS_ERROR_LOSS_OF_SIGNIFICANT_DATA; \
611 *_retval = ( Ctype_ ) value; \
615 #define CASE__NUMERIC_CONVERSION_UINT32_JUST_CAST(Ctype_) \
616 case nsIDataType::VTYPE_UINT32: \
617 *_retval = ( Ctype_ ) tempData.u.mUint32Value; \
620 #define CASE__NUMERIC_CONVERSION_UINT32_MAX(Ctype_, max_) \
621 case nsIDataType::VTYPE_UINT32: \
623 PRUint32 value = tempData.u.mUint32Value; \
625 return NS_ERROR_LOSS_OF_SIGNIFICANT_DATA; \
626 *_retval = ( Ctype_ ) value; \
630 #define CASE__NUMERIC_CONVERSION_DOUBLE_JUST_CAST(Ctype_) \
631 case nsIDataType::VTYPE_DOUBLE: \
632 *_retval = ( Ctype_ ) tempData.u.mDoubleValue; \
635 #define CASE__NUMERIC_CONVERSION_DOUBLE_MIN_MAX(Ctype_, min_, max_) \
636 case nsIDataType::VTYPE_DOUBLE: \
638 double value = tempData.u.mDoubleValue; \
639 if(value < min_ || value > max_) \
640 return NS_ERROR_LOSS_OF_SIGNIFICANT_DATA; \
641 *_retval = ( Ctype_ ) value; \
645 #define CASE__NUMERIC_CONVERSION_DOUBLE_MIN_MAX_INT(Ctype_, min_, max_) \
646 case nsIDataType::VTYPE_DOUBLE: \
648 double value = tempData.u.mDoubleValue; \
649 if(value < min_ || value > max_) \
650 return NS_ERROR_LOSS_OF_SIGNIFICANT_DATA; \
651 *_retval = ( Ctype_ ) value; \
652 return (0.0 == fmod(value,1.0)) ? \
653 rv : NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA; \
656 #define CASES__NUMERIC_CONVERSION_NORMAL(Ctype_, min_, max_) \
657 CASE__NUMERIC_CONVERSION_INT32_MIN_MAX(Ctype_, min_, max_) \
658 CASE__NUMERIC_CONVERSION_UINT32_MAX(Ctype_, max_) \
659 CASE__NUMERIC_CONVERSION_DOUBLE_MIN_MAX_INT(Ctype_, min_, max_)
661 #define NUMERIC_CONVERSION_METHOD_END \
663 NS_ERROR("bad type returned from ToManageableNumber"); \
664 return NS_ERROR_CANNOT_CONVERT_DATA; \
668 #define NUMERIC_CONVERSION_METHOD_NORMAL(type_, Ctype_, name_, min_, max_) \
669 NUMERIC_CONVERSION_METHOD_BEGIN(type_, Ctype_, name_) \
670 CASES__NUMERIC_CONVERSION_NORMAL(Ctype_, min_, max_) \
671 NUMERIC_CONVERSION_METHOD_END
721 #undef NUMERIC_CONVERSION_METHOD_BEGIN
722 #undef CASE__NUMERIC_CONVERSION_INT32_JUST_CAST
723 #undef CASE__NUMERIC_CONVERSION_INT32_MIN_MAX
724 #undef CASE__NUMERIC_CONVERSION_UINT32_JUST_CAST
725 #undef CASE__NUMERIC_CONVERSION_UINT32_MIN_MAX
726 #undef CASE__NUMERIC_CONVERSION_DOUBLE_JUST_CAST
727 #undef CASE__NUMERIC_CONVERSION_DOUBLE_MIN_MAX
728 #undef CASE__NUMERIC_CONVERSION_DOUBLE_MIN_MAX_INT
729 #undef CASES__NUMERIC_CONVERSION_NORMAL
730 #undef NUMERIC_CONVERSION_METHOD_END
731 #undef NUMERIC_CONVERSION_METHOD_NORMAL
747 *_retval = 0.0 !=
val;
764 switch(tempData.
mType)
766 case nsIDataType::VTYPE_INT32:
769 case nsIDataType::VTYPE_UINT32:
772 case nsIDataType::VTYPE_DOUBLE:
777 NS_ERROR(
"bad type returned from ToManageableNumber");
778 return NS_ERROR_CANNOT_CONVERT_DATA;
792 nsAutoString tempString;
797 case nsIDataType::VTYPE_CHAR_STR:
798 case nsIDataType::VTYPE_STRING_SIZE_IS:
799 return pid->Parse(data.
u.
str.mStringValue);
800 case nsIDataType::VTYPE_CSTRING:
801 return pid->Parse(PromiseFlatCString(*data.
u.
mCStringValue).get());
802 case nsIDataType::VTYPE_UTF8STRING:
804 case nsIDataType::VTYPE_ASTRING:
805 case nsIDataType::VTYPE_DOMSTRING:
808 case nsIDataType::VTYPE_WCHAR_STR:
809 case nsIDataType::VTYPE_WSTRING_SIZE_IS:
810 tempString.Assign(data.
u.
wstr.mWStringValue);
811 pString = &tempString;
814 NS_ERROR(
"bad type in call to String2ID");
818 char* pChars = ToNewCString(NS_LossyConvertUTF16toASCII(*pString));
821 PRBool result = pid->Parse(pChars);
833 case nsIDataType::VTYPE_ID:
836 case nsIDataType::VTYPE_INTERFACE:
839 case nsIDataType::VTYPE_INTERFACE_IS:
840 *_retval = data.
u.
iface.mInterfaceID;
842 case nsIDataType::VTYPE_ASTRING:
843 case nsIDataType::VTYPE_DOMSTRING:
844 case nsIDataType::VTYPE_UTF8STRING:
845 case nsIDataType::VTYPE_CSTRING:
846 case nsIDataType::VTYPE_CHAR_STR:
847 case nsIDataType::VTYPE_WCHAR_STR:
848 case nsIDataType::VTYPE_STRING_SIZE_IS:
849 case nsIDataType::VTYPE_WSTRING_SIZE_IS:
851 return NS_ERROR_CANNOT_CONVERT_DATA;
855 return NS_ERROR_CANNOT_CONVERT_DATA;
862 nsACString & outString)
869 case nsIDataType::VTYPE_ASTRING:
870 case nsIDataType::VTYPE_DOMSTRING:
871 case nsIDataType::VTYPE_UTF8STRING:
872 case nsIDataType::VTYPE_CSTRING:
873 case nsIDataType::VTYPE_CHAR_STR:
874 case nsIDataType::VTYPE_WCHAR_STR:
875 case nsIDataType::VTYPE_STRING_SIZE_IS:
876 case nsIDataType::VTYPE_WSTRING_SIZE_IS:
877 case nsIDataType::VTYPE_WCHAR:
878 NS_ERROR(
"ToString being called for a string type - screwy logic!");
883 case nsIDataType::VTYPE_VOID:
884 case nsIDataType::VTYPE_EMPTY:
885 outString.Truncate();
886 outString.SetIsVoid(
true);
889 case nsIDataType::VTYPE_EMPTY_ARRAY:
890 case nsIDataType::VTYPE_ARRAY:
891 case nsIDataType::VTYPE_INTERFACE:
892 case nsIDataType::VTYPE_INTERFACE_IS:
894 return NS_ERROR_CANNOT_CONVERT_DATA;
898 case nsIDataType::VTYPE_ID:
901 return NS_ERROR_OUT_OF_MEMORY;
902 outString.Assign(ptr);
907 #define CASE__APPENDFLOAT_NUMBER(type_, member_) \
908 case nsIDataType :: type_ : \
911 Modified_cnvtf(buf, sizeof(buf), 6, data.u. member_); \
912 outString.Assign(buf); \
916 #define CASE__APPENDDOUBLE_NUMBER(type_, member_) \
917 case nsIDataType :: type_ : \
920 Modified_cnvtf(buf, sizeof(buf), 15, data.u. member_); \
921 outString.Assign(buf); \
928 #undef CASE__APPENDFLOAT_NUMBER
929 #undef CASE__APPENDDOUBLE_NUMBER
933 #define CASE__SMPRINTF_NUMBER(type_, format_, cast_, member_) \
934 case nsIDataType :: type_ : \
935 ptr = PR_smprintf( format_ , (cast_) data.u. member_ ); \
953 #undef CASE__SMPRINTF_NUMBER
957 return NS_ERROR_OUT_OF_MEMORY;
958 outString.Assign(ptr);
959 PR_smprintf_free(ptr);
969 case nsIDataType::VTYPE_ASTRING:
970 case nsIDataType::VTYPE_DOMSTRING:
973 case nsIDataType::VTYPE_CSTRING:
976 case nsIDataType::VTYPE_UTF8STRING:
979 case nsIDataType::VTYPE_CHAR_STR:
980 CopyASCIItoUTF16(nsDependentCString(data.
u.
str.mStringValue), _retval);
982 case nsIDataType::VTYPE_WCHAR_STR:
983 _retval.Assign(data.
u.
wstr.mWStringValue);
985 case nsIDataType::VTYPE_STRING_SIZE_IS:
986 CopyASCIItoUTF16(nsDependentCString(data.
u.
str.mStringValue,
987 data.
u.
str.mStringLength),
990 case nsIDataType::VTYPE_WSTRING_SIZE_IS:
991 _retval.Assign(data.
u.
wstr.mWStringValue, data.
u.
wstr.mWStringLength);
993 case nsIDataType::VTYPE_WCHAR:
998 nsCAutoString tempCString;
999 nsresult rv =
ToString(data, tempCString);
1002 CopyASCIItoUTF16(tempCString, _retval);
1010 nsACString & _retval)
1014 case nsIDataType::VTYPE_ASTRING:
1015 case nsIDataType::VTYPE_DOMSTRING:
1018 case nsIDataType::VTYPE_CSTRING:
1021 case nsIDataType::VTYPE_UTF8STRING:
1028 case nsIDataType::VTYPE_CHAR_STR:
1029 _retval.Assign(*data.
u.
str.mStringValue);
1031 case nsIDataType::VTYPE_WCHAR_STR:
1032 LossyCopyUTF16toASCII(nsDependentString(data.
u.
wstr.mWStringValue),
1035 case nsIDataType::VTYPE_STRING_SIZE_IS:
1036 _retval.Assign(data.
u.
str.mStringValue, data.
u.
str.mStringLength);
1038 case nsIDataType::VTYPE_WSTRING_SIZE_IS:
1039 LossyCopyUTF16toASCII(nsDependentString(data.
u.
wstr.mWStringValue,
1040 data.
u.
wstr.mWStringLength), _retval);
1042 case nsIDataType::VTYPE_WCHAR:
1045 LossyCopyUTF16toASCII(Substring(str, str + 1), _retval);
1059 case nsIDataType::VTYPE_ASTRING:
1060 case nsIDataType::VTYPE_DOMSTRING:
1063 case nsIDataType::VTYPE_CSTRING:
1069 case nsIDataType::VTYPE_UTF8STRING:
1072 case nsIDataType::VTYPE_CHAR_STR:
1075 CopyUTF16toUTF8(NS_ConvertASCIItoUTF16(data.
u.
str.mStringValue),
1078 case nsIDataType::VTYPE_WCHAR_STR:
1079 CopyUTF16toUTF8(nsDependentString(data.
u.
wstr.mWStringValue), _retval);
1081 case nsIDataType::VTYPE_STRING_SIZE_IS:
1084 CopyUTF16toUTF8(NS_ConvertASCIItoUTF16(
1085 nsDependentCString(data.
u.
str.mStringValue,
1086 data.
u.
str.mStringLength)), _retval);
1088 case nsIDataType::VTYPE_WSTRING_SIZE_IS:
1089 CopyUTF16toUTF8(nsDependentString(data.
u.
wstr.mWStringValue,
1090 data.
u.
wstr.mWStringLength),
1093 case nsIDataType::VTYPE_WCHAR:
1096 CopyUTF16toUTF8(Substring(str, str + 1), _retval);
1101 nsCAutoString tempCString;
1102 nsresult rv =
ToString(data, tempCString);
1107 CopyUTF16toUTF8(NS_ConvertASCIItoUTF16(tempCString), _retval);
1129 PRUint32 *size,
char **
str)
1131 nsAutoString tempString;
1132 nsCAutoString tempCString;
1137 case nsIDataType::VTYPE_ASTRING:
1138 case nsIDataType::VTYPE_DOMSTRING:
1141 *str = ToNewCString(NS_ConvertUTF16toUTF8(tempString));
1143 case nsIDataType::VTYPE_CSTRING:
1146 *str = ToNewCString(tempCString);
1148 case nsIDataType::VTYPE_UTF8STRING:
1157 *size = tempString.Length();
1160 *str = ToNewCString(tempCString );
1163 case nsIDataType::VTYPE_CHAR_STR:
1165 nsDependentCString cString(data.
u.
str.mStringValue);
1166 *size = cString.Length();
1167 *str = ToNewCString(cString);
1170 case nsIDataType::VTYPE_WCHAR_STR:
1172 nsDependentString
string(data.
u.
wstr.mWStringValue);
1173 *size =
string.Length();
1174 *str = ToNewCString(NS_ConvertUTF16toUTF8(
string));
1177 case nsIDataType::VTYPE_STRING_SIZE_IS:
1179 nsDependentCString cString(data.
u.
str.mStringValue,
1180 data.
u.
str.mStringLength);
1181 *size = cString.Length();
1182 *str = ToNewCString(cString);
1185 case nsIDataType::VTYPE_WSTRING_SIZE_IS:
1187 nsDependentString
string(data.
u.
wstr.mWStringValue,
1188 data.
u.
wstr.mWStringLength);
1189 *size =
string.Length();
1190 *str = ToNewCString(NS_ConvertUTF16toUTF8(
string));
1193 case nsIDataType::VTYPE_WCHAR:
1195 *size = tempString.Length();
1196 *str = ToNewCString(NS_ConvertUTF16toUTF8(tempString));
1202 *size = tempCString.Length();
1203 *str = ToNewCString(tempCString);
1207 return *str ?
NS_OK : NS_ERROR_OUT_OF_MEMORY;
1211 PRUint32 *size, PRUnichar **
str)
1213 nsAutoString tempString;
1214 nsCAutoString tempCString;
1219 case nsIDataType::VTYPE_ASTRING:
1220 case nsIDataType::VTYPE_DOMSTRING:
1224 case nsIDataType::VTYPE_CSTRING:
1226 *str = ToNewUnicode(NS_ConvertUTF8toUTF16(*data.
u.
mCStringValue));
1228 case nsIDataType::VTYPE_UTF8STRING:
1233 case nsIDataType::VTYPE_CHAR_STR:
1235 nsDependentCString cString(data.
u.
str.mStringValue);
1236 *size = cString.Length();
1237 *str = ToNewUnicode(NS_ConvertUTF8toUTF16(cString));
1240 case nsIDataType::VTYPE_WCHAR_STR:
1242 nsDependentString
string(data.
u.
wstr.mWStringValue);
1243 *size =
string.Length();
1244 *str = ToNewUnicode(
string);
1247 case nsIDataType::VTYPE_STRING_SIZE_IS:
1249 nsDependentCString cString(data.
u.
str.mStringValue,
1250 data.
u.
str.mStringLength);
1251 *size = cString.Length();
1252 *str = ToNewUnicode(NS_ConvertUTF8toUTF16(cString));
1255 case nsIDataType::VTYPE_WSTRING_SIZE_IS:
1257 nsDependentString
string(data.
u.
wstr.mWStringValue,
1258 data.
u.
wstr.mWStringLength);
1259 *size =
string.Length();
1260 *str = ToNewUnicode(
string);
1263 case nsIDataType::VTYPE_WCHAR:
1265 *size = tempString.Length();
1266 *str = ToNewUnicode(tempString);
1272 *size = tempCString.Length();
1273 *str = ToNewUnicode(NS_ConvertUTF8toUTF16(tempCString));
1277 return *str ?
NS_OK : NS_ERROR_OUT_OF_MEMORY;
1286 case nsIDataType::VTYPE_INTERFACE:
1287 case nsIDataType::VTYPE_INTERFACE_IS:
1288 if (data.
u.
iface.mInterfaceValue) {
1289 return data.
u.
iface.mInterfaceValue->
1296 return NS_ERROR_CANNOT_CONVERT_DATA;
1308 case nsIDataType::VTYPE_INTERFACE:
1311 case nsIDataType::VTYPE_INTERFACE_IS:
1312 piid = &data.
u.
iface.mInterfaceID;
1315 return NS_ERROR_CANNOT_CONVERT_DATA;
1320 return NS_ERROR_OUT_OF_MEMORY;
1322 if (data.
u.
iface.mInterfaceValue) {
1323 return data.
u.
iface.mInterfaceValue->QueryInterface(*piid, iface);
1332 nsIID* iid, PRUint32 *
count,
void * *ptr)
1338 if(data.
mType == nsIDataType::VTYPE_ARRAY)
1341 type, iid, count, ptr);
1342 return NS_ERROR_CANNOT_CONVERT_DATA;
1348 #define DATA_SETTER_PROLOGUE(data_) \
1349 sbVariant::Cleanup(data_);
1351 #define DATA_SETTER_EPILOGUE(data_, type_) \
1352 data_->mType = nsIDataType :: type_; \
1355 #define DATA_SETTER(data_, type_, member_, value_) \
1356 DATA_SETTER_PROLOGUE(data_) \
1357 data_->u.member_ = value_; \
1358 DATA_SETTER_EPILOGUE(data_, type_)
1360 #define DATA_SETTER_WITH_CAST(data_, type_, member_, cast_, value_) \
1361 DATA_SETTER_PROLOGUE(data_) \
1362 data_->u.member_ = cast_ value_; \
1363 DATA_SETTER_EPILOGUE(data_, type_)
1368 #define CASE__SET_FROM_VARIANT_VTYPE_PROLOGUE(type_) \
1371 #define CASE__SET_FROM_VARIANT_VTYPE__GETTER(member_, name_) \
1372 rv = aValue->GetAs##name_ (&(data->u. member_ ));
1374 #define CASE__SET_FROM_VARIANT_VTYPE__GETTER_CAST(cast_, member_, name_) \
1375 rv = aValue->GetAs##name_ ( cast_ &(data->u. member_ ));
1377 #define CASE__SET_FROM_VARIANT_VTYPE_EPILOGUE(type_) \
1378 if(NS_SUCCEEDED(rv)) \
1380 data->mType = nsIDataType :: type_ ; \
1385 #define CASE__SET_FROM_VARIANT_TYPE(type_, member_, name_) \
1386 case nsIDataType :: type_ : \
1387 CASE__SET_FROM_VARIANT_VTYPE_PROLOGUE(type_) \
1388 CASE__SET_FROM_VARIANT_VTYPE__GETTER(member_, name_) \
1389 CASE__SET_FROM_VARIANT_VTYPE_EPILOGUE(type_)
1391 #define CASE__SET_FROM_VARIANT_VTYPE_CAST(type_, cast_, member_, name_) \
1392 case nsIDataType :: type_ : \
1393 CASE__SET_FROM_VARIANT_VTYPE_PROLOGUE(type_) \
1394 CASE__SET_FROM_VARIANT_VTYPE__GETTER_CAST(cast_, member_, name_) \
1395 CASE__SET_FROM_VARIANT_VTYPE_EPILOGUE(type_)
1406 rv = aValue->GetDataType(&type);
1426 case nsIDataType::VTYPE_ASTRING:
1427 case nsIDataType::VTYPE_DOMSTRING:
1428 case nsIDataType::VTYPE_WCHAR_STR:
1429 case nsIDataType::VTYPE_WSTRING_SIZE_IS:
1433 return NS_ERROR_OUT_OF_MEMORY;
1442 case nsIDataType::VTYPE_CSTRING:
1446 return NS_ERROR_OUT_OF_MEMORY;
1455 case nsIDataType::VTYPE_UTF8STRING:
1459 return NS_ERROR_OUT_OF_MEMORY;
1468 case nsIDataType::VTYPE_CHAR_STR:
1469 case nsIDataType::VTYPE_STRING_SIZE_IS:
1471 rv = aValue->GetAsStringWithSize(&data->
u.
str.mStringLength,
1472 &data->
u.
str.mStringValue);
1475 case nsIDataType::VTYPE_INTERFACE:
1476 case nsIDataType::VTYPE_INTERFACE_IS:
1480 rv = aValue->GetAsInterface(&iid, (
void**)&data->
u.
iface.mInterfaceValue);
1481 if(NS_SUCCEEDED(rv))
1483 data->
u.
iface.mInterfaceID = *iid;
1484 NS_Free((
char*)iid);
1488 case nsIDataType::VTYPE_ARRAY:
1490 rv = aValue->GetAsArray(&data->
u.
array.mArrayType,
1491 &data->
u.
array.mArrayInterfaceID,
1492 &data->
u.
array.mArrayCount,
1493 &data->
u.
array.mArrayValue);
1496 case nsIDataType::VTYPE_VOID:
1499 case nsIDataType::VTYPE_EMPTY_ARRAY:
1502 case nsIDataType::VTYPE_EMPTY:
1506 NS_ERROR(
"bad type in variant!");
1507 rv = NS_ERROR_FAILURE;
1521 DATA_SETTER(data, VTYPE_INT16, mInt16Value, aValue)
1526 DATA_SETTER(data, VTYPE_INT32, mInt32Value, aValue)
1531 DATA_SETTER(data, VTYPE_INT64, mInt64Value, aValue)
1536 DATA_SETTER(data, VTYPE_UINT8, mUint8Value, aValue)
1541 DATA_SETTER(data, VTYPE_UINT16, mUint16Value, aValue)
1546 DATA_SETTER(data, VTYPE_UINT32, mUint32Value, aValue)
1551 DATA_SETTER(data, VTYPE_UINT64, mUint64Value, aValue)
1556 DATA_SETTER(data, VTYPE_FLOAT, mFloatValue, aValue)
1561 DATA_SETTER(data, VTYPE_DOUBLE, mDoubleValue, aValue)
1576 DATA_SETTER(data, VTYPE_WCHAR, mWCharValue, aValue)
1588 return NS_ERROR_OUT_OF_MEMORY;
1594 const nsACString &
aValue)
1598 return NS_ERROR_OUT_OF_MEMORY;
1608 return NS_ERROR_OUT_OF_MEMORY;
1617 return NS_ERROR_NULL_POINTER;
1625 return NS_ERROR_NULL_POINTER;
1638 NS_IF_ADDREF(aValue);
1640 data->
u.
iface.mInterfaceID = iid;
1648 if(!aValue || !count)
1649 return NS_ERROR_NULL_POINTER;
1651 nsresult rv =
CloneArray(type, iid, count, aValue,
1652 &data->
u.
array.mArrayType,
1653 &data->
u.
array.mArrayInterfaceID,
1654 &data->
u.
array.mArrayCount,
1655 &data->
u.
array.mArrayValue);
1665 return NS_ERROR_NULL_POINTER;
1666 if(!(data->
u.
str.mStringValue =
1668 return NS_ERROR_OUT_OF_MEMORY;
1669 data->
u.
str.mStringLength = size;
1677 return NS_ERROR_NULL_POINTER;
1678 if(!(data->
u.
wstr.mWStringValue =
1679 (PRUnichar*)
SB_CloneMemory(aValue, (size+1)*
sizeof(PRUnichar))))
1680 return NS_ERROR_OUT_OF_MEMORY;
1681 data->
u.
wstr.mWStringLength = size;
1708 data->
mType = nsIDataType::VTYPE_EMPTY;
1717 case nsIDataType::VTYPE_INT8:
1718 case nsIDataType::VTYPE_INT16:
1719 case nsIDataType::VTYPE_INT32:
1720 case nsIDataType::VTYPE_INT64:
1721 case nsIDataType::VTYPE_UINT8:
1722 case nsIDataType::VTYPE_UINT16:
1723 case nsIDataType::VTYPE_UINT32:
1724 case nsIDataType::VTYPE_UINT64:
1725 case nsIDataType::VTYPE_FLOAT:
1726 case nsIDataType::VTYPE_DOUBLE:
1727 case nsIDataType::VTYPE_BOOL:
1728 case nsIDataType::VTYPE_CHAR:
1729 case nsIDataType::VTYPE_WCHAR:
1730 case nsIDataType::VTYPE_VOID:
1731 case nsIDataType::VTYPE_ID:
1733 case nsIDataType::VTYPE_ASTRING:
1734 case nsIDataType::VTYPE_DOMSTRING:
1741 case nsIDataType::VTYPE_CSTRING:
1748 case nsIDataType::VTYPE_UTF8STRING:
1755 case nsIDataType::VTYPE_CHAR_STR:
1756 case nsIDataType::VTYPE_STRING_SIZE_IS:
1757 NS_Free((
char*)data->
u.
str.mStringValue);
1759 case nsIDataType::VTYPE_WCHAR_STR:
1760 case nsIDataType::VTYPE_WSTRING_SIZE_IS:
1761 NS_Free((
char*)data->
u.
wstr.mWStringValue);
1763 case nsIDataType::VTYPE_INTERFACE:
1764 case nsIDataType::VTYPE_INTERFACE_IS:
1765 NS_IF_RELEASE(data->
u.
iface.mInterfaceValue);
1767 case nsIDataType::VTYPE_ARRAY:
1770 case nsIDataType::VTYPE_EMPTY_ARRAY:
1771 case nsIDataType::VTYPE_EMPTY:
1774 NS_ERROR(
"bad type in variant!");
1778 data->
mType = nsIDataType::VTYPE_EMPTY;
1792 , mWritable(PR_TRUE)
1795 mDataLock = nsAutoLock::NewLock(
"sbVariant::mLock");
1796 NS_WARN_IF_FALSE(mDataLock,
"Failed to create data lock.");
1802 struct THE_TYPES {PRUint16 a; PRUint16 b;};
1803 static const THE_TYPES
array[] = {
1804 {nsIDataType::VTYPE_INT8 , TD_INT8 },
1805 {nsIDataType::VTYPE_INT16 , TD_INT16 },
1806 {nsIDataType::VTYPE_INT32 , TD_INT32 },
1807 {nsIDataType::VTYPE_INT64 , TD_INT64 },
1808 {nsIDataType::VTYPE_UINT8 , TD_UINT8 },
1809 {nsIDataType::VTYPE_UINT16 , TD_UINT16 },
1810 {nsIDataType::VTYPE_UINT32 , TD_UINT32 },
1811 {nsIDataType::VTYPE_UINT64 , TD_UINT64 },
1812 {nsIDataType::VTYPE_FLOAT , TD_FLOAT },
1813 {nsIDataType::VTYPE_DOUBLE , TD_DOUBLE },
1814 {nsIDataType::VTYPE_BOOL , TD_BOOL },
1815 {nsIDataType::VTYPE_CHAR , TD_CHAR },
1816 {nsIDataType::VTYPE_WCHAR , TD_WCHAR },
1817 {nsIDataType::VTYPE_VOID , TD_VOID },
1818 {nsIDataType::VTYPE_ID , TD_PNSIID },
1819 {nsIDataType::VTYPE_DOMSTRING , TD_DOMSTRING },
1820 {nsIDataType::VTYPE_CHAR_STR , TD_PSTRING },
1821 {nsIDataType::VTYPE_WCHAR_STR , TD_PWSTRING },
1822 {nsIDataType::VTYPE_INTERFACE , TD_INTERFACE_TYPE },
1823 {nsIDataType::VTYPE_INTERFACE_IS , TD_INTERFACE_IS_TYPE},
1824 {nsIDataType::VTYPE_ARRAY , TD_ARRAY },
1825 {nsIDataType::VTYPE_STRING_SIZE_IS , TD_PSTRING_SIZE_IS },
1826 {nsIDataType::VTYPE_WSTRING_SIZE_IS , TD_PWSTRING_SIZE_IS },
1827 {nsIDataType::VTYPE_UTF8STRING , TD_UTF8STRING },
1828 {nsIDataType::VTYPE_CSTRING , TD_CSTRING },
1829 {nsIDataType::VTYPE_ASTRING , TD_ASTRING }
1831 static const int length =
sizeof(
array)/
sizeof(array[0]);
1832 static PRBool inited = PR_FALSE;
1835 for(
int i = 0;
i < length;
i++)
1836 NS_ASSERTION(array[
i].a == array[
i].b,
"bad const declaration");
1843 sbVariant::~sbVariant()
1855 NS_IMETHODIMP sbVariant::GetDataType(PRUint16 *aDataType)
1863 NS_IMETHODIMP sbVariant::GetAsInt8(PRUint8 *_retval)
1870 NS_IMETHODIMP sbVariant::GetAsInt16(PRInt16 *_retval)
1877 NS_IMETHODIMP sbVariant::GetAsInt32(PRInt32 *_retval)
1884 NS_IMETHODIMP sbVariant::GetAsInt64(PRInt64 *_retval)
1891 NS_IMETHODIMP sbVariant::GetAsUint8(PRUint8 *_retval)
1898 NS_IMETHODIMP sbVariant::GetAsUint16(PRUint16 *_retval)
1905 NS_IMETHODIMP sbVariant::GetAsUint32(PRUint32 *_retval)
1912 NS_IMETHODIMP sbVariant::GetAsUint64(PRUint64 *_retval)
1919 NS_IMETHODIMP sbVariant::GetAsFloat(
float *_retval)
1926 NS_IMETHODIMP sbVariant::GetAsDouble(
double *_retval)
1933 NS_IMETHODIMP sbVariant::GetAsBool(PRBool *_retval)
1940 NS_IMETHODIMP sbVariant::GetAsChar(
char *_retval)
1947 NS_IMETHODIMP sbVariant::GetAsWChar(PRUnichar *_retval)
1956 nsAutoLock lock(mDataLock);
1961 NS_IMETHODIMP sbVariant::GetAsAString(nsAString & _retval)
1968 NS_IMETHODIMP sbVariant::GetAsDOMString(nsAString & _retval)
1978 NS_IMETHODIMP sbVariant::GetAsACString(nsACString & _retval)
1985 NS_IMETHODIMP sbVariant::GetAsAUTF8String(
nsAUTF8String & _retval)
1992 NS_IMETHODIMP sbVariant::GetAsString(
char **_retval)
1999 NS_IMETHODIMP sbVariant::GetAsWString(PRUnichar **_retval)
2006 NS_IMETHODIMP sbVariant::GetAsISupports(
nsISupports **_retval)
2013 NS_IMETHODIMP sbVariant::GetAsInterface(nsIID * *iid,
void * *iface)
2022 nsAutoLock lock(mDataLock);
2027 NS_IMETHODIMP sbVariant::GetAsStringWithSize(PRUint32 *size,
char **
str)
2034 NS_IMETHODIMP sbVariant::GetAsWStringWithSize(PRUint32 *size, PRUnichar **
str)
2043 NS_IMETHODIMP sbVariant::GetWritable(PRBool *aWritable)
2049 NS_IMETHODIMP sbVariant::SetWritable(PRBool aWritable)
2053 return NS_ERROR_FAILURE;
2064 NS_IMETHODIMP sbVariant::SetAsInt8(PRUint8
aValue)
2067 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2072 NS_IMETHODIMP sbVariant::SetAsInt16(PRInt16 aValue)
2075 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2080 NS_IMETHODIMP sbVariant::SetAsInt32(PRInt32 aValue)
2083 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2088 NS_IMETHODIMP sbVariant::SetAsInt64(PRInt64 aValue)
2091 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2096 NS_IMETHODIMP sbVariant::SetAsUint8(PRUint8 aValue)
2099 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2104 NS_IMETHODIMP sbVariant::SetAsUint16(PRUint16 aValue)
2107 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2112 NS_IMETHODIMP sbVariant::SetAsUint32(PRUint32 aValue)
2115 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2120 NS_IMETHODIMP sbVariant::SetAsUint64(PRUint64 aValue)
2123 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2128 NS_IMETHODIMP sbVariant::SetAsFloat(
float aValue)
2131 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2136 NS_IMETHODIMP sbVariant::SetAsDouble(
double aValue)
2139 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2144 NS_IMETHODIMP sbVariant::SetAsBool(PRBool aValue)
2147 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2152 NS_IMETHODIMP sbVariant::SetAsChar(
char aValue)
2155 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2160 NS_IMETHODIMP sbVariant::SetAsWChar(PRUnichar aValue)
2163 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2168 NS_IMETHODIMP sbVariant::SetAsID(
const nsID & aValue)
2171 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2176 NS_IMETHODIMP sbVariant::SetAsAString(
const nsAString & aValue)
2179 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2184 NS_IMETHODIMP sbVariant::SetAsDOMString(
const nsAString & aValue)
2187 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2191 return NS_ERROR_OUT_OF_MEMORY;
2196 NS_IMETHODIMP sbVariant::SetAsACString(
const nsACString & aValue)
2199 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2204 NS_IMETHODIMP sbVariant::SetAsAUTF8String(
const nsAUTF8String & aValue)
2207 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2212 NS_IMETHODIMP sbVariant::SetAsString(
const char *aValue)
2215 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2220 NS_IMETHODIMP sbVariant::SetAsWString(
const PRUnichar *aValue)
2223 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2228 NS_IMETHODIMP sbVariant::SetAsISupports(
nsISupports *aValue)
2231 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2236 NS_IMETHODIMP sbVariant::SetAsInterface(
const nsIID & iid,
void * iface)
2239 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2244 NS_IMETHODIMP sbVariant::SetAsArray(PRUint16 type,
const nsIID * iid, PRUint32
count,
void * ptr)
2247 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2252 NS_IMETHODIMP sbVariant::SetAsStringWithSize(PRUint32 size,
const char *
str)
2255 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2260 NS_IMETHODIMP sbVariant::SetAsWStringWithSize(PRUint32 size,
const PRUnichar *str)
2263 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2268 NS_IMETHODIMP sbVariant::SetAsVoid()
2271 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2276 NS_IMETHODIMP sbVariant::SetAsEmpty()
2279 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2284 NS_IMETHODIMP sbVariant::SetAsEmptyArray()
2287 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
2295 if(!
mWritable)
return NS_ERROR_OBJECT_IS_IMMUTABLE;
static nsresult ACString2Double(const nsACString &aString, double *retval)
static nsresult ConvertToInt64(const nsDiscriminatedUnion &data, PRInt64 *_retval)
static nsresult SetFromInterface(nsDiscriminatedUnion *data, const nsIID &iid, nsISupports *aValue)
void * SB_CloneMemory(const void *ptr, PRSize size)
Clone a block of contiguous memory.
#define CASE__NUMBER_INT32(type_, member_)
static nsresult ConvertToString(nsDiscriminatedUnion &data, char **_retval)
static nsresult ConvertToFloat(const nsDiscriminatedUnion &data, float *_retval)
static nsresult SetFromWStringWithSize(nsDiscriminatedUnion *data, PRUint32 size, const PRUnichar *aValue)
#define CASE__NUMERIC_CONVERSION_UINT32_JUST_CAST(Ctype_)
static nsresult SetFromUint32(nsDiscriminatedUnion *data, PRUint32 aValue)
#define CASE__SET_FROM_VARIANT_VTYPE_CAST(type_, cast_, member_, name_)
#define CASE__NUMERIC_CONVERSION_INT32_JUST_CAST(Ctype_)
struct nsDiscriminatedUnion::@10::@11 iface
nsDiscriminatedUnion mData
static nsresult AString2Double(const nsAString &aString, double *retval)
#define CASE__SET_FROM_VARIANT_VTYPE_EPILOGUE(type_)
#define CASE__APPENDDOUBLE_NUMBER(type_, member_)
static nsresult ConvertToStringWithSize(nsDiscriminatedUnion &data, PRUint32 *size, char **str)
static nsresult SetFromStringWithSize(nsDiscriminatedUnion *data, PRUint32 size, const char *aValue)
#define DATA_SETTER(data_, type_, member_, value_)
#define CASE__FREE_ARRAY_PTR(type_, ctype_)
static nsresult SetToVoid(nsDiscriminatedUnion *data)
struct nsDiscriminatedUnion::@10::@12 array
static nsresult SetFromAUTF8String(nsDiscriminatedUnion *data, const nsACString &aValue)
static void Modified_cnvtf(char *buf, int bufsz, int prcsn, double fval)
static nsresult SetFromISupports(nsDiscriminatedUnion *data, nsISupports *aValue)
static nsresult ConvertToWString(const nsDiscriminatedUnion &data, PRUnichar **_retval)
#define CASE__NUMERIC_CONVERSION_DOUBLE_JUST_CAST(Ctype_)
static nsresult SetFromChar(nsDiscriminatedUnion *data, char aValue)
#define CASE__FREE_ARRAY_IFACE(type_, ctype_)
static nsresult SetFromInt32(nsDiscriminatedUnion *data, PRInt32 aValue)
static nsresult SetToEmpty(nsDiscriminatedUnion *data)
static nsresult ConvertToID(const nsDiscriminatedUnion &data, nsID *_retval)
static nsresult ToManageableNumber(const nsDiscriminatedUnion &inData, nsDiscriminatedUnion *outData)
sbOSDControlService prototype QueryInterface
static nsresult SetFromFloat(nsDiscriminatedUnion *data, float aValue)
static nsresult ConvertToInterface(const nsDiscriminatedUnion &data, nsIID **iid, void **iface)
static nsresult ConvertToChar(const nsDiscriminatedUnion &data, char *_retval)
static nsresult ToString(const nsDiscriminatedUnion &data, nsACString &outString)
#define CASE__SET_FROM_VARIANT_VTYPE_PROLOGUE(type_)
#define DATA_SETTER_WITH_CAST(data_, type_, member_, cast_, value_)
#define DATA_SETTER_PROLOGUE(data_)
static nsresult SetFromUint16(nsDiscriminatedUnion *data, PRUint16 aValue)
#define CASE__NUMERIC_CONVERSION_INT32_MIN_MAX(Ctype_, min_, max_)
static nsresult String2Double(const char *aString, double *retval)
#define CASE__NUMERIC_CONVERSION_UINT32_MAX(Ctype_, max_)
static nsresult SetFromID(nsDiscriminatedUnion *data, const nsID &aValue)
static nsresult ConvertToArray(const nsDiscriminatedUnion &data, PRUint16 *type, nsIID *iid, PRUint32 *count, void **ptr)
nsACString * mUTF8StringValue
static nsresult SetFromBool(nsDiscriminatedUnion *data, PRBool aValue)
static nsresult SetFromInt16(nsDiscriminatedUnion *data, PRInt16 aValue)
static nsresult ConvertToUint32(const nsDiscriminatedUnion &data, PRUint32 *_retval)
static nsresult SetFromWChar(nsDiscriminatedUnion *data, PRUnichar aValue)
#define NUMERIC_CONVERSION_METHOD_BEGIN(type_, Ctype_, name_)
static nsresult SetFromAString(nsDiscriminatedUnion *data, const nsAString &aValue)
static nsresult ConvertToISupports(const nsDiscriminatedUnion &data, nsISupports **_retval)
static nsresult ConvertToACString(const nsDiscriminatedUnion &data, nsACString &_retval)
this _dialogInput val(dateText)
nsAString * mAStringValue
static nsresult ConvertToInt16(const nsDiscriminatedUnion &data, PRInt16 *_retval)
static nsresult SetFromUint8(nsDiscriminatedUnion *data, PRUint8 aValue)
#define NUMERIC_CONVERSION_METHOD_END
#define TRIVIAL_DATA_CONVERTER(type_, data_, member_, retval_)
nsACString * mCStringValue
NS_IMETHODIMP_(nsresult) sbVariant
union nsDiscriminatedUnion::@10 u
struct nsDiscriminatedUnion::@10::@14 wstr
static nsresult Initialize(nsDiscriminatedUnion *data)
static nsresult SetFromArray(nsDiscriminatedUnion *data, PRUint16 type, const nsIID *iid, PRUint32 count, void *aValue)
#define PromiseFlatUTF8String
static nsresult SetFromString(nsDiscriminatedUnion *data, const char *aValue)
static nsresult ConvertToUint16(const nsDiscriminatedUnion &data, PRUint16 *_retval)
static nsresult Cleanup(nsDiscriminatedUnion *data)
#define CASE__NUMERIC_CONVERSION_DOUBLE_MIN_MAX_INT(Ctype_, min_, max_)
static nsresult ConvertToInt32(const nsDiscriminatedUnion &data, PRInt32 *_retval)
static nsresult SetFromACString(nsDiscriminatedUnion *data, const nsACString &aValue)
static nsresult SetFromInt8(nsDiscriminatedUnion *data, PRUint8 aValue)
static nsresult ConvertToWStringWithSize(const nsDiscriminatedUnion &data, PRUint32 *size, PRUnichar **str)
#define CASE__APPENDFLOAT_NUMBER(type_, member_)
static nsresult ConvertToBool(const nsDiscriminatedUnion &data, PRBool *_retval)
static nsresult ConvertToUint64(const nsDiscriminatedUnion &data, PRUint64 *_retval)
#define DATA_SETTER_EPILOGUE(data_, type_)
static void FreeArray(nsDiscriminatedUnion *data)
static nsresult SetFromUint64(nsDiscriminatedUnion *data, PRUint64 aValue)
static nsresult SetFromDouble(nsDiscriminatedUnion *data, double aValue)
static nsresult ConvertToUint8(const nsDiscriminatedUnion &data, PRUint8 *_retval)
static nsresult SetToEmptyArray(nsDiscriminatedUnion *data)
static nsresult ConvertToInt8(const nsDiscriminatedUnion &data, PRUint8 *_retval)
static PRBool String2ID(const nsDiscriminatedUnion &data, nsID *pid)
static nsresult CloneArray(PRUint16 inType, const nsIID *inIID, PRUint32 inCount, void *inValue, PRUint16 *outType, nsIID *outIID, PRUint32 *outCount, void **outValue)
#define NUMERIC_CONVERSION_METHOD_NORMAL(type_, Ctype_, name_, min_, max_)
static nsresult ConvertToAUTF8String(const nsDiscriminatedUnion &data, nsACString &_retval)
#define CASE__SMPRINTF_NUMBER(type_, format_, cast_, member_)
_getSelectedPageStyle s i
#define CASE__SET_FROM_VARIANT_TYPE(type_, member_, name_)
NS_IMPL_THREADSAFE_ISUPPORTS2(sbVariant, nsIVariant, nsIWritableVariant) sbVariant
static nsresult ConvertToDouble(const nsDiscriminatedUnion &data, double *_retval)
static nsresult SetFromVariant(nsDiscriminatedUnion *data, nsIVariant *aValue)
static nsresult ConvertToWChar(const nsDiscriminatedUnion &data, PRUnichar *_retval)
static nsresult ConvertToAString(const nsDiscriminatedUnion &data, nsAString &_retval)
struct nsDiscriminatedUnion::@10::@13 str
static nsresult AUTF8String2Double(const nsACString &aString, double *retval)
static nsresult SetFromWString(nsDiscriminatedUnion *data, const PRUnichar *aValue)
static nsresult SetFromInt64(nsDiscriminatedUnion *data, PRInt64 aValue)