зеркало из https://github.com/mozilla/gecko-dev.git
Bug 805416 - Refactor macros to avoid the need for empty macro arguments. r=Waldo, a=jlebar
This commit is contained in:
Родитель
721112c629
Коммит
234b57bbed
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
MFBT_API(uint32_t)
|
||||
uint32_t
|
||||
HashBytes(const void* bytes, size_t length)
|
||||
{
|
||||
uint32_t hash = 0;
|
||||
|
|
|
@ -351,7 +351,7 @@ HashString(const wchar_t* str, size_t length)
|
|||
* same result out of HashBytes as you would out of HashString.
|
||||
*/
|
||||
MOZ_WARN_UNUSED_RESULT
|
||||
extern MFBT_API(uint32_t)
|
||||
extern MFBT_API uint32_t
|
||||
HashBytes(const void* bytes, size_t length);
|
||||
|
||||
} /* namespace mozilla */
|
||||
|
|
|
@ -39,9 +39,9 @@ class SHA1Sum {
|
|||
|
||||
public:
|
||||
static const unsigned int HashSize = 20;
|
||||
MFBT_API() SHA1Sum();
|
||||
MFBT_API(void) update(const void* dataIn, uint32_t len);
|
||||
MFBT_API(void) finish(uint8_t hashout[20]);
|
||||
MFBT_API SHA1Sum();
|
||||
MFBT_API void update(const void* dataIn, uint32_t len);
|
||||
MFBT_API void finish(uint8_t hashout[20]);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
39
mfbt/Types.h
39
mfbt/Types.h
|
@ -45,8 +45,7 @@
|
|||
* methods or data used cross-file.
|
||||
*/
|
||||
#if defined(WIN32) || defined(XP_OS2)
|
||||
# define MOZ_EXPORT_API(type) __declspec(dllexport) type
|
||||
# define MOZ_EXPORT_DATA(type) __declspec(dllexport) type
|
||||
# define MOZ_EXPORT_DIRECTIVE __declspec(dllexport)
|
||||
#else /* Unix */
|
||||
# ifdef HAVE_VISIBILITY_ATTRIBUTE
|
||||
# define MOZ_EXTERNAL_VIS __attribute__((visibility("default")))
|
||||
|
@ -55,10 +54,12 @@
|
|||
# else
|
||||
# define MOZ_EXTERNAL_VIS
|
||||
# endif
|
||||
# define MOZ_EXPORT_API(type) MOZ_EXTERNAL_VIS type
|
||||
# define MOZ_EXPORT_DATA(type) MOZ_EXTERNAL_VIS type
|
||||
# define MOZ_EXPORT_DIRECTIVE MOZ_EXTERNAL_VIS
|
||||
#endif
|
||||
|
||||
#define MOZ_EXPORT_API(type) MOZ_EXPORT_DIRECTIVE type
|
||||
#define MOZ_EXPORT_DATA(type) MOZ_EXPORT_DIRECTIVE type
|
||||
|
||||
/*
|
||||
* Whereas implementers use MOZ_EXPORT_API and MOZ_EXPORT_DATA to declare and
|
||||
* define library symbols, users use MOZ_IMPORT_API and MOZ_IMPORT_DATA to
|
||||
|
@ -68,32 +69,36 @@
|
|||
*/
|
||||
#ifdef _WIN32
|
||||
# if defined(__MWERKS__)
|
||||
# define MOZ_IMPORT_API(x) x
|
||||
# define MOZ_IMPORT_API_DIRECTIVE /* nothing */
|
||||
# else
|
||||
# define MOZ_IMPORT_API(x) __declspec(dllimport) x
|
||||
# define MOZ_IMPORT_API_DIRECTIVE __declspec(dllimport)
|
||||
# endif
|
||||
#elif defined(XP_OS2)
|
||||
# define MOZ_IMPORT_API(x) __declspec(dllimport) x
|
||||
# define MOZ_IMPORT_API_DIRECTIVE __declspec(dllimport)
|
||||
#else
|
||||
# define MOZ_IMPORT_API(x) MOZ_EXPORT_API(x)
|
||||
# define MOZ_IMPORT_API_DIRECTIVE MOZ_EXPORT_DIRECTIVE
|
||||
#endif
|
||||
|
||||
#define MOZ_IMPORT_API(x) MOZ_IMPORT_API_DIRECTIVE x
|
||||
|
||||
#if defined(_WIN32) && !defined(__MWERKS__)
|
||||
# define MOZ_IMPORT_DATA(x) __declspec(dllimport) x
|
||||
# define MOZ_IMPORT_DATA_DIRECTIVE __declspec(dllimport)
|
||||
#elif defined(XP_OS2)
|
||||
# define MOZ_IMPORT_DATA(x) __declspec(dllimport) x
|
||||
# define MOZ_IMPORT_DATA_DIRECTIVE __declspec(dllimport)
|
||||
#else
|
||||
# define MOZ_IMPORT_DATA(x) MOZ_EXPORT_DATA(x)
|
||||
# define MOZ_IMPORT_DATA_DIRECTIVE MOZ_EXPORT_DIRECTIVE
|
||||
#endif
|
||||
|
||||
#define MOZ_IMPORT_DATA(x) MOZ_IMPORT_DATA_DIRECTIVE x
|
||||
|
||||
/*
|
||||
* Consistent with the above comment, the MFBT_API and MFBT_DATA macros expose
|
||||
* export mfbt declarations when building mfbt, and they expose import mfbt
|
||||
* declarations when using mfbt.
|
||||
*/
|
||||
#if defined(IMPL_MFBT)
|
||||
# define MFBT_API(type) MOZ_EXPORT_API(type)
|
||||
# define MFBT_DATA(type) MOZ_EXPORT_DATA(type)
|
||||
# define MFBT_API MOZ_EXPORT_DIRECTIVE
|
||||
# define MFBT_DATA MOZ_EXPORT_DIRECTIVE
|
||||
#else
|
||||
/*
|
||||
* On linux mozglue is linked in the program and we link libxul.so with
|
||||
|
@ -103,11 +108,11 @@
|
|||
* macros to exploit this.
|
||||
*/
|
||||
# if defined(MOZ_GLUE_IN_PROGRAM)
|
||||
# define MFBT_API(type) __attribute__((weak)) MOZ_IMPORT_API(type)
|
||||
# define MFBT_DATA(type) __attribute__((weak)) MOZ_IMPORT_DATA(type)
|
||||
# define MFBT_API __attribute__((weak)) MOZ_IMPORT_API_DIRECTIVE
|
||||
# define MFBT_DATA __attribute__((weak)) MOZ_IMPORT_DATA_DIRECTIVE
|
||||
# else
|
||||
# define MFBT_API(type) MOZ_IMPORT_API(type)
|
||||
# define MFBT_DATA(type) MOZ_IMPORT_DATA(type)
|
||||
# define MFBT_API MOZ_IMPORT_API_DIRECTIVE
|
||||
# define MFBT_DATA MOZ_IMPORT_DATA_DIRECTIVE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
diff --git a/mfbt/double-conversion/double-conversion.h b/mfbt/double-conversion/double-conversion.h
|
||||
index f98edae..e536a01 100644
|
||||
index f98edae..c62b16b 100644
|
||||
--- a/mfbt/double-conversion/double-conversion.h
|
||||
+++ b/mfbt/double-conversion/double-conversion.h
|
||||
@@ -28,6 +28,7 @@
|
||||
|
@ -15,7 +15,7 @@ index f98edae..e536a01 100644
|
|||
|
||||
// Returns a converter following the EcmaScript specification.
|
||||
- static const DoubleToStringConverter& EcmaScriptConverter();
|
||||
+ static MFBT_API(const DoubleToStringConverter&) EcmaScriptConverter();
|
||||
+ static MFBT_API const DoubleToStringConverter& EcmaScriptConverter();
|
||||
|
||||
// Computes the shortest string of digits that correctly represent the input
|
||||
// number. Depending on decimal_in_shortest_low and decimal_in_shortest_high
|
||||
|
@ -24,7 +24,7 @@ index f98edae..e536a01 100644
|
|||
// 1 + kMaxFixedDigitsBeforePoint + 1 + kMaxFixedDigitsAfterPoint characters
|
||||
// (one additional character for the sign, and one for the decimal point).
|
||||
- bool ToFixed(double value,
|
||||
+ MFBT_API(bool) ToFixed(double value,
|
||||
+ MFBT_API bool ToFixed(double value,
|
||||
int requested_digits,
|
||||
StringBuilder* result_builder) const;
|
||||
|
||||
|
@ -33,7 +33,7 @@ index f98edae..e536a01 100644
|
|||
// decimal point, the decimal point, the exponent character, the
|
||||
// exponent's sign, and at most 3 exponent digits).
|
||||
- bool ToExponential(double value,
|
||||
+ MFBT_API(bool) ToExponential(double value,
|
||||
+ MFBT_API bool ToExponential(double value,
|
||||
int requested_digits,
|
||||
StringBuilder* result_builder) const;
|
||||
|
||||
|
@ -42,7 +42,7 @@ index f98edae..e536a01 100644
|
|||
// kMaxPrecisionDigits + 7 characters (the sign, the decimal point, the
|
||||
// exponent character, the exponent's sign, and at most 3 exponent digits).
|
||||
- bool ToPrecision(double value,
|
||||
+ MFBT_API(bool) ToPrecision(double value,
|
||||
+ MFBT_API bool ToPrecision(double value,
|
||||
int precision,
|
||||
StringBuilder* result_builder) const;
|
||||
|
||||
|
@ -51,7 +51,7 @@ index f98edae..e536a01 100644
|
|||
// Note that DoubleToAscii null-terminates its input. So the given buffer
|
||||
// should be at least kBase10MaximalLength + 1 characters long.
|
||||
- static const int kBase10MaximalLength = 17;
|
||||
+ static const MFBT_DATA(int) kBase10MaximalLength = 17;
|
||||
+ static const MFBT_DATA int kBase10MaximalLength = 17;
|
||||
|
||||
// Converts the given double 'v' to ascii. 'v' must not be NaN, +Infinity, or
|
||||
// -Infinity. In SHORTEST_SINGLE-mode this restriction also applies to 'v'
|
||||
|
@ -60,7 +60,7 @@ index f98edae..e536a01 100644
|
|||
// The given length is only used in debug mode to ensure the buffer is big
|
||||
// enough.
|
||||
- static void DoubleToAscii(double v,
|
||||
+ static MFBT_API(void) DoubleToAscii(double v,
|
||||
+ static MFBT_API void DoubleToAscii(double v,
|
||||
DtoaMode mode,
|
||||
int requested_digits,
|
||||
char* buffer,
|
||||
|
@ -69,7 +69,7 @@ index f98edae..e536a01 100644
|
|||
private:
|
||||
// Implementation for ToShortest and ToShortestSingle.
|
||||
- bool ToShortestIeeeNumber(double value,
|
||||
+ MFBT_API(bool) ToShortestIeeeNumber(double value,
|
||||
+ MFBT_API bool ToShortestIeeeNumber(double value,
|
||||
StringBuilder* result_builder,
|
||||
DtoaMode mode) const;
|
||||
|
||||
|
@ -78,17 +78,17 @@ index f98edae..e536a01 100644
|
|||
// If either of them is NULL or the value is not special then the
|
||||
// function returns false.
|
||||
- bool HandleSpecialValues(double value, StringBuilder* result_builder) const;
|
||||
+ MFBT_API(bool) HandleSpecialValues(double value, StringBuilder* result_builder) const;
|
||||
+ MFBT_API bool HandleSpecialValues(double value, StringBuilder* result_builder) const;
|
||||
// Constructs an exponential representation (i.e. 1.234e56).
|
||||
// The given exponent assumes a decimal point after the first decimal digit.
|
||||
- void CreateExponentialRepresentation(const char* decimal_digits,
|
||||
+ MFBT_API(void) CreateExponentialRepresentation(const char* decimal_digits,
|
||||
+ MFBT_API void CreateExponentialRepresentation(const char* decimal_digits,
|
||||
int length,
|
||||
int exponent,
|
||||
StringBuilder* result_builder) const;
|
||||
// Creates a decimal representation (i.e 1234.5678).
|
||||
- void CreateDecimalRepresentation(const char* decimal_digits,
|
||||
+ MFBT_API(void) CreateDecimalRepresentation(const char* decimal_digits,
|
||||
+ MFBT_API void CreateDecimalRepresentation(const char* decimal_digits,
|
||||
int length,
|
||||
int decimal_point,
|
||||
int digits_after_point,
|
||||
|
|
|
@ -130,7 +130,7 @@ class DoubleToStringConverter {
|
|||
}
|
||||
|
||||
// Returns a converter following the EcmaScript specification.
|
||||
static MFBT_API(const DoubleToStringConverter&) EcmaScriptConverter();
|
||||
static MFBT_API const DoubleToStringConverter& EcmaScriptConverter();
|
||||
|
||||
// Computes the shortest string of digits that correctly represent the input
|
||||
// number. Depending on decimal_in_shortest_low and decimal_in_shortest_high
|
||||
|
@ -198,7 +198,7 @@ class DoubleToStringConverter {
|
|||
// The last two conditions imply that the result will never contain more than
|
||||
// 1 + kMaxFixedDigitsBeforePoint + 1 + kMaxFixedDigitsAfterPoint characters
|
||||
// (one additional character for the sign, and one for the decimal point).
|
||||
MFBT_API(bool) ToFixed(double value,
|
||||
MFBT_API bool ToFixed(double value,
|
||||
int requested_digits,
|
||||
StringBuilder* result_builder) const;
|
||||
|
||||
|
@ -230,7 +230,7 @@ class DoubleToStringConverter {
|
|||
// kMaxExponentialDigits + 8 characters (the sign, the digit before the
|
||||
// decimal point, the decimal point, the exponent character, the
|
||||
// exponent's sign, and at most 3 exponent digits).
|
||||
MFBT_API(bool) ToExponential(double value,
|
||||
MFBT_API bool ToExponential(double value,
|
||||
int requested_digits,
|
||||
StringBuilder* result_builder) const;
|
||||
|
||||
|
@ -268,7 +268,7 @@ class DoubleToStringConverter {
|
|||
// The last condition implies that the result will never contain more than
|
||||
// kMaxPrecisionDigits + 7 characters (the sign, the decimal point, the
|
||||
// exponent character, the exponent's sign, and at most 3 exponent digits).
|
||||
MFBT_API(bool) ToPrecision(double value,
|
||||
MFBT_API bool ToPrecision(double value,
|
||||
int precision,
|
||||
StringBuilder* result_builder) const;
|
||||
|
||||
|
@ -293,7 +293,7 @@ class DoubleToStringConverter {
|
|||
// kBase10MaximalLength.
|
||||
// Note that DoubleToAscii null-terminates its input. So the given buffer
|
||||
// should be at least kBase10MaximalLength + 1 characters long.
|
||||
static const MFBT_DATA(int) kBase10MaximalLength = 17;
|
||||
static const MFBT_DATA int kBase10MaximalLength = 17;
|
||||
|
||||
// Converts the given double 'v' to ascii. 'v' must not be NaN, +Infinity, or
|
||||
// -Infinity. In SHORTEST_SINGLE-mode this restriction also applies to 'v'
|
||||
|
@ -333,7 +333,7 @@ class DoubleToStringConverter {
|
|||
// terminating null-character when computing the maximal output size.
|
||||
// The given length is only used in debug mode to ensure the buffer is big
|
||||
// enough.
|
||||
static MFBT_API(void) DoubleToAscii(double v,
|
||||
static MFBT_API void DoubleToAscii(double v,
|
||||
DtoaMode mode,
|
||||
int requested_digits,
|
||||
char* buffer,
|
||||
|
@ -344,7 +344,7 @@ class DoubleToStringConverter {
|
|||
|
||||
private:
|
||||
// Implementation for ToShortest and ToShortestSingle.
|
||||
MFBT_API(bool) ToShortestIeeeNumber(double value,
|
||||
MFBT_API bool ToShortestIeeeNumber(double value,
|
||||
StringBuilder* result_builder,
|
||||
DtoaMode mode) const;
|
||||
|
||||
|
@ -352,15 +352,15 @@ class DoubleToStringConverter {
|
|||
// corresponding string using the configured infinity/nan-symbol.
|
||||
// If either of them is NULL or the value is not special then the
|
||||
// function returns false.
|
||||
MFBT_API(bool) HandleSpecialValues(double value, StringBuilder* result_builder) const;
|
||||
MFBT_API bool HandleSpecialValues(double value, StringBuilder* result_builder) const;
|
||||
// Constructs an exponential representation (i.e. 1.234e56).
|
||||
// The given exponent assumes a decimal point after the first decimal digit.
|
||||
MFBT_API(void) CreateExponentialRepresentation(const char* decimal_digits,
|
||||
MFBT_API void CreateExponentialRepresentation(const char* decimal_digits,
|
||||
int length,
|
||||
int exponent,
|
||||
StringBuilder* result_builder) const;
|
||||
// Creates a decimal representation (i.e 1234.5678).
|
||||
MFBT_API(void) CreateDecimalRepresentation(const char* decimal_digits,
|
||||
MFBT_API void CreateDecimalRepresentation(const char* decimal_digits,
|
||||
int length,
|
||||
int decimal_point,
|
||||
int digits_after_point,
|
||||
|
|
Загрузка…
Ссылка в новой задаче