diff --git a/aegisub/configure.in b/aegisub/configure.in index 5e4a66cb8..0874a6aa8 100644 --- a/aegisub/configure.in +++ b/aegisub/configure.in @@ -346,6 +346,7 @@ AC_SUBST(with_openmp) AC_SUBST(OPENMP_CXXFLAGS) AC_CHECK_HEADERS([sys/time.h]) +AC_CHECK_SIZEOF([time_t]) ############################## diff --git a/aegisub/libaegisub/common/cajun/elements.cpp b/aegisub/libaegisub/common/cajun/elements.cpp index 3d2f32eeb..a1ae1a8dd 100644 --- a/aegisub/libaegisub/common/cajun/elements.cpp +++ b/aegisub/libaegisub/common/cajun/elements.cpp @@ -84,36 +84,28 @@ private: ElementTypeT m_Element; }; -UnknownElement::UnknownElement() : m_pImp( new Imp_T( Null() ) ) {} -UnknownElement::UnknownElement(const UnknownElement& unknown) : m_pImp( unknown.m_pImp->Clone()) {} -UnknownElement::UnknownElement(const Object& object) : m_pImp( new Imp_T(object) ) {} -UnknownElement::UnknownElement(const Array& array) : m_pImp( new Imp_T(array) ) {} -UnknownElement::UnknownElement(double number) : m_pImp( new Imp_T(number) ) {} -UnknownElement::UnknownElement(int number) : m_pImp( new Imp_T(number) ) {} -UnknownElement::UnknownElement(int64_t number) : m_pImp( new Imp_T(number) ) {} -UnknownElement::UnknownElement(long number) : m_pImp( new Imp_T(number) ) {} -UnknownElement::UnknownElement(bool boolean) : m_pImp( new Imp_T(boolean) ) {} -UnknownElement::UnknownElement(const char *string) : m_pImp( new Imp_T(string) ) {} -UnknownElement::UnknownElement(const String& string) : m_pImp( new Imp_T(string) ) {} -UnknownElement::UnknownElement(const Null& null) : m_pImp( new Imp_T(null) ) {} +UnknownElement::UnknownElement() : m_pImp(new Imp_T(Null())) {} +UnknownElement::UnknownElement(const UnknownElement& unknown) : m_pImp(unknown.m_pImp->Clone()) {} +UnknownElement::UnknownElement(int number) : m_pImp(new Imp_T(number)) {} +UnknownElement::UnknownElement(const char *string) : m_pImp(new Imp_T(string)) {} +#if SIZEOF_TIME_T+0 == 4 +UnknownElement::UnknownElement(time_t number) : m_pImp(new Imp_T(number)) {} +#endif -UnknownElement::~UnknownElement() { delete m_pImp; } +UnknownElement::~UnknownElement() { delete m_pImp; } -UnknownElement::operator Object const&() const { return CastTo(); } -UnknownElement::operator Array const&() const { return CastTo(); } -UnknownElement::operator Integer const&() const { return CastTo(); } -UnknownElement::operator Double const&() const { return CastTo(); } -UnknownElement::operator Boolean const&() const { return CastTo(); } -UnknownElement::operator String const&() const { return CastTo(); } -UnknownElement::operator Null const&() const { return CastTo(); } +#define DEFINE_UE_TYPE(Type) \ + UnknownElement::UnknownElement(Type const& val) : m_pImp(new Imp_T(val)) { } \ + UnknownElement::operator Type const&() const { return CastTo(); } \ + UnknownElement::operator Type&() { return CastTo(); } -UnknownElement::operator Object&() { return CastTo(); } -UnknownElement::operator Array&() { return CastTo(); } -UnknownElement::operator Integer&() { return CastTo(); } -UnknownElement::operator Double&() { return CastTo(); } -UnknownElement::operator Boolean&() { return CastTo(); } -UnknownElement::operator String&() { return CastTo(); } -UnknownElement::operator Null&() { return CastTo(); } +DEFINE_UE_TYPE(Object); +DEFINE_UE_TYPE(Array); +DEFINE_UE_TYPE(Integer); +DEFINE_UE_TYPE(Double); +DEFINE_UE_TYPE(Boolean); +DEFINE_UE_TYPE(String); +DEFINE_UE_TYPE(Null); UnknownElement& UnknownElement::operator =(const UnknownElement& unknown) { diff --git a/aegisub/libaegisub/include/libaegisub/cajun/elements.h b/aegisub/libaegisub/include/libaegisub/cajun/elements.h index 0862da173..6b790a881 100644 --- a/aegisub/libaegisub/include/libaegisub/cajun/elements.h +++ b/aegisub/libaegisub/include/libaegisub/cajun/elements.h @@ -69,15 +69,18 @@ public: UnknownElement(const UnknownElement& unknown); UnknownElement(const Object& object); UnknownElement(const Array& array); - UnknownElement(double number); + UnknownElement(double const& number); UnknownElement(int number); - UnknownElement(long number); - UnknownElement(int64_t number); - UnknownElement(bool boolean); + UnknownElement(int64_t const& number); + UnknownElement(bool const& boolean); UnknownElement(const char *string); UnknownElement(const String& string); UnknownElement(const Null& null); +#if SIZEOF_TIME_T+0 == 4 + UnknownElement(time_t number); +#endif + ~UnknownElement(); UnknownElement& operator = (const UnknownElement& unknown);