diff --git a/src/db/db/dbHash.h b/src/db/db/dbHash.h index 4422dc45b..fb900ca78 100644 --- a/src/db/db/dbHash.h +++ b/src/db/db/dbHash.h @@ -30,6 +30,7 @@ namespace std_ext = __gnu_cxx; # define DB_HASH_NAMESPACE __gnu_cxx #else +# define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS # include # include namespace std_ext = std; diff --git a/src/db/db/dbLibraryManager.cc b/src/db/db/dbLibraryManager.cc index 24e4f2798..f3fb61b2f 100644 --- a/src/db/db/dbLibraryManager.cc +++ b/src/db/db/dbLibraryManager.cc @@ -31,12 +31,6 @@ #include -namespace tl -{ - template<> DB_PUBLIC tl::Registrar *tl::Registrar::instance = 0; - template class DB_PUBLIC tl::RegisteredClass; -} - namespace db { diff --git a/src/db/db/dbPath.cc b/src/db/db/dbPath.cc index 4db578db1..7b50e1ccd 100644 --- a/src/db/db/dbPath.cc +++ b/src/db/db/dbPath.cc @@ -97,7 +97,7 @@ path::area () const } template -DB_PUBLIC std::string +std::string path::to_string () const { std::string s = "("; diff --git a/src/db/db/dbStream.cc b/src/db/db/dbStream.cc index b4861e761..a6b84c9aa 100644 --- a/src/db/db/dbStream.cc +++ b/src/db/db/dbStream.cc @@ -27,12 +27,6 @@ #include -namespace tl -{ - template<> DB_PUBLIC tl::Registrar *tl::Registrar::instance = 0; - template class DB_PUBLIC tl::RegisteredClass; -} - namespace db { diff --git a/src/db/db/dbTechnology.cc b/src/db/db/dbTechnology.cc index 50e27f7e3..bb9bac46c 100644 --- a/src/db/db/dbTechnology.cc +++ b/src/db/db/dbTechnology.cc @@ -27,12 +27,6 @@ #include -namespace tl -{ - template<> DB_PUBLIC tl::Registrar *tl::Registrar::instance = 0; - template class DB_PUBLIC tl::RegisteredClass; -} - namespace db { diff --git a/src/db/db/dbTypes.h b/src/db/db/dbTypes.h index 83ff37789..11df2b7a9 100644 --- a/src/db/db/dbTypes.h +++ b/src/db/db/dbTypes.h @@ -25,6 +25,7 @@ #define HDR_dbTypes #include +#define _USE_MATH_DEFINES // for MSVC #include #include #include diff --git a/src/db/db/dbUserObject.cc b/src/db/db/dbUserObject.cc index 93eae07be..09297e2a0 100644 --- a/src/db/db/dbUserObject.cc +++ b/src/db/db/dbUserObject.cc @@ -24,14 +24,6 @@ #include "dbUserObject.h" #include "tlClassRegistry.h" -namespace tl -{ - template<> DB_PUBLIC tl::Registrar > *tl::Registrar >::instance = 0; - template class DB_PUBLIC tl::RegisteredClass >; - template<> DB_PUBLIC tl::Registrar > *tl::Registrar >::instance = 0; - template class DB_PUBLIC tl::RegisteredClass >; -} - namespace db { static unsigned int s_class_id = 1; diff --git a/src/gsi/gsi/gsiEnums.h b/src/gsi/gsi/gsiEnums.h index dcde774dc..cbddb56a3 100644 --- a/src/gsi/gsi/gsiEnums.h +++ b/src/gsi/gsi/gsiEnums.h @@ -195,14 +195,14 @@ public: return std::string ("(not a valid enum value)"); } - static std::string enum_to_string (const E *e) + static std::string enum_to_string_ext (const E *e) { const Enum *ecls = dynamic_cast *> (cls_decl ()); tl_assert (ecls != 0); return ecls->enum_to_string (*e); } - static std::string enum_to_string_inspect (const E *e) + static std::string enum_to_string_inspect_ext (const E *e) { const Enum *ecls = dynamic_cast *> (cls_decl ()); tl_assert (ecls != 0); @@ -246,8 +246,8 @@ public: gsi::Methods m = gsi::constructor ("new", &new_enum_from_int, gsi::arg("i"), "@brief Creates an enum from an integer value") + gsi::constructor ("new", &new_enum_from_string, gsi::arg("s"), "@brief Creates an enum from a string value") + - gsi::method_ext ("to_s", &enum_to_string, "@brief Gets the symbolic string from an enum") + - gsi::method_ext ("inspect", &enum_to_string_inspect, "@brief Converts an enum to a visual string") + + gsi::method_ext ("to_s", &enum_to_string_ext, "@brief Gets the symbolic string from an enum") + + gsi::method_ext ("inspect", &enum_to_string_inspect_ext, "@brief Converts an enum to a visual string") + gsi::method_ext ("to_i", &enum_to_i, "@brief Gets the integer value from the enum") + gsi::method_ext ("==", &enum_eq, gsi::arg("other"), "@brief Compares two enums") + gsi::method_ext ("!=", &enum_ne, gsi::arg("other"), "@brief Compares two enums for inequality") + diff --git a/src/gsi/gsi/gsiInterpreter.cc b/src/gsi/gsi/gsiInterpreter.cc index ab5db9869..a750690dc 100644 --- a/src/gsi/gsi/gsiInterpreter.cc +++ b/src/gsi/gsi/gsiInterpreter.cc @@ -22,11 +22,6 @@ #include "gsiInterpreter.h" -namespace tl -{ - template<> GSI_PUBLIC tl::Registrar *tl::Registrar::instance = 0; -} - namespace gsi { diff --git a/src/gsiqt/qtbasic/gsiQt.h b/src/gsiqt/qtbasic/gsiQt.h index e48e94197..a7eb0b434 100644 --- a/src/gsiqt/qtbasic/gsiQt.h +++ b/src/gsiqt/qtbasic/gsiQt.h @@ -572,6 +572,13 @@ struct pair_decl // warning: #define __SUPPRESS_UNUSED_WARNING(x) (void)(x) +// HACK: the Qt binding code takes __null instead of NULL, but +// MS defines it as empty in sal.h ... better __null was NULL again. +#if defined(__null) +# undef __null +# define __null 0 +#endif + } #endif diff --git a/src/gsiqt/qtbasic/gsiQtGuiExternals.h b/src/gsiqt/qtbasic/gsiQtGuiExternals.h index 2773c3da4..924bd51b4 100644 --- a/src/gsiqt/qtbasic/gsiQtGuiExternals.h +++ b/src/gsiqt/qtbasic/gsiQtGuiExternals.h @@ -21,7 +21,9 @@ */ #if QT_VERSION >= 0x050000 +# include "../qt5/QtGui/gsiDeclQtGuiTypeTraits.h" # include "../qt5/QtGui/gsiQtExternals.h" #else +# include "../qt4/QtGui/gsiDeclQtGuiTypeTraits.h" # include "../qt4/QtGui/gsiQtExternals.h" #endif diff --git a/src/gsiqt/qtbasic/gsiQtWidgetsExternals.h b/src/gsiqt/qtbasic/gsiQtWidgetsExternals.h index 5188b45a6..118040b22 100644 --- a/src/gsiqt/qtbasic/gsiQtWidgetsExternals.h +++ b/src/gsiqt/qtbasic/gsiQtWidgetsExternals.h @@ -21,6 +21,7 @@ */ #if QT_VERSION >= 0x050000 +# include "../qt5/QtWidgets/gsiDeclQtWidgetsTypeTraits.h" # include "../qt5/QtWidgets/gsiQtExternals.h" #else // no present in Qt4 diff --git a/src/klayout.pri b/src/klayout.pri index 1358e3809..05b59e514 100644 --- a/src/klayout.pri +++ b/src/klayout.pri @@ -61,16 +61,31 @@ equals(HAVE_RUBY, "1") { QMAKE_RPATHDIR += $$RPATH } -QMAKE_CXXFLAGS_WARN_ON += \ - -pedantic \ - -Woverloaded-virtual \ - -Wsign-promo \ - -Wsynth \ - -Wno-deprecated \ - -Wno-long-long \ - -Wno-strict-aliasing \ - -Wno-deprecated-declarations \ - -Wno-reserved-user-defined-literal \ +msvc { + + INCLUDEPATH += \ + $$THIRD_PARTY/zlib/1.2.11/include \ + + QMAKE_CXXFLAGS += -bigobj + + QMAKE_CXXFLAGS_WARN_ON += \ + +} + +!msvc { + + QMAKE_CXXFLAGS_WARN_ON += \ + -pedantic \ + -Woverloaded-virtual \ + -Wsign-promo \ + -Wsynth \ + -Wno-deprecated \ + -Wno-long-long \ + -Wno-strict-aliasing \ + -Wno-deprecated-declarations \ + -Wno-reserved-user-defined-literal \ + +} equals(HAVE_QT, "0") { @@ -79,7 +94,7 @@ equals(HAVE_QT, "0") { } else { DEFINES += HAVE_QT - QT += network xml sql + QT += core network xml sql equals(HAVE_QT5, "1") { QT += designer printsupport @@ -94,10 +109,14 @@ equals(HAVE_QT, "0") { } # only support the required symbols for shared object load performance -win32 { - QMAKE_LFLAGS += -Wl,--exclude-all-symbols +msvc { + # ... } else { - QMAKE_CXXFLAGS += -fvisibility=hidden + win32 { + QMAKE_LFLAGS += -Wl,--exclude-all-symbols + } else { + QMAKE_CXXFLAGS += -fvisibility=hidden + } } VERSION_STRING = $$KLAYOUT_VERSION diff --git a/src/laybasic/laybasic/gsiDeclLayDialogs.cc b/src/laybasic/laybasic/gsiDeclLayDialogs.cc index 95a1503cc..f64e14598 100644 --- a/src/laybasic/laybasic/gsiDeclLayDialogs.cc +++ b/src/laybasic/laybasic/gsiDeclLayDialogs.cc @@ -36,7 +36,6 @@ #if defined(HAVE_QTBINDINGS) # include "gsiQtGuiExternals.h" # include "gsiQtWidgetsExternals.h" - FORCE_LINK_GSI_QTGUI FORCE_LINK_GSI_QTWIDGETS // for Qt5 diff --git a/src/laybasic/laybasic/gsiDeclLayPlugin.cc b/src/laybasic/laybasic/gsiDeclLayPlugin.cc index 2049ecbdb..131897874 100644 --- a/src/laybasic/laybasic/gsiDeclLayPlugin.cc +++ b/src/laybasic/laybasic/gsiDeclLayPlugin.cc @@ -43,8 +43,6 @@ namespace tl template <> struct type_traits : public type_traits { typedef tl::false_tag has_copy_constructor; }; - - template <> Registrar *Registrar::instance = 0; } namespace gsi diff --git a/src/laybasic/laybasic/layCellView.cc b/src/laybasic/laybasic/layCellView.cc index 2647e3537..d8e3eb877 100644 --- a/src/laybasic/laybasic/layCellView.cc +++ b/src/laybasic/laybasic/layCellView.cc @@ -112,7 +112,7 @@ LayoutHandle::layout_changed () } void -LayoutHandle::rename (const std::string &name, bool force) throw (tl::Exception) +LayoutHandle::rename (const std::string &name, bool force) { std::string n (name); diff --git a/src/laybasic/laybasic/layCellView.h b/src/laybasic/laybasic/layCellView.h index 497c1d1c8..2f5d9e436 100644 --- a/src/laybasic/laybasic/layCellView.h +++ b/src/laybasic/laybasic/layCellView.h @@ -83,7 +83,7 @@ public: * If "force" is set to true, the layout will be given that name, irregardless if * the name already is being used. If "force" is false, a new unique name is created. */ - void rename (const std::string &name, bool force = false) throw (tl::Exception); + void rename (const std::string &name, bool force = false); /** * @brief Gets the name of the handle diff --git a/src/laybasic/laybasic/layPlugin.cc b/src/laybasic/laybasic/layPlugin.cc index f59f597e7..7271bccef 100644 --- a/src/laybasic/laybasic/layPlugin.cc +++ b/src/laybasic/laybasic/layPlugin.cc @@ -589,9 +589,3 @@ PluginRoot::instance () } } - -namespace tl -{ - template<> LAYBASIC_PUBLIC Registrar *tl::Registrar::instance = 0; - template class LAYBASIC_PUBLIC tl::RegisteredClass; -} diff --git a/src/laybasic/laybasic/layTechnology.cc b/src/laybasic/laybasic/layTechnology.cc index 89e141731..b7a8783e7 100644 --- a/src/laybasic/laybasic/layTechnology.cc +++ b/src/laybasic/laybasic/layTechnology.cc @@ -22,17 +22,5 @@ #include "layTechnology.h" -#include "layPlugin.h" -#include "layStream.h" - -#include - -#include -#include - -namespace tl -{ - template<> LAYBASIC_PUBLIC tl::Registrar *tl::Registrar::instance = 0; - template class LAYBASIC_PUBLIC tl::RegisteredClass; -} +// .. nothing yet .. diff --git a/src/lib_ut.pri b/src/lib_ut.pri index c86bcc725..92abe0854 100644 --- a/src/lib_ut.pri +++ b/src/lib_ut.pri @@ -7,7 +7,7 @@ TEMPLATE = lib # $(DESTDIR) and $(TARGET) win32 { - QMAKE_POST_LINK += $(COPY) $(DESTDIR_TARGET) $$DESTDIR_UT/$${TARGET}.ut + QMAKE_POST_LINK += $(COPY) $(DESTDIR_TARGET) $$shell_path($$DESTDIR_UT/$${TARGET}.ut) # to avoid the major version being appended to the dll name - in this case -lxyz won't link it again # because the library is called xyx0.dll. diff --git a/src/lym/lym/lymMacroInterpreter.cc b/src/lym/lym/lymMacroInterpreter.cc index 7a120f141..5bfc494a0 100644 --- a/src/lym/lym/lymMacroInterpreter.cc +++ b/src/lym/lym/lymMacroInterpreter.cc @@ -122,9 +122,3 @@ MacroInterpreter::suffix (const std::string &dsl_name) } } - -namespace tl -{ - template<> LYM_PUBLIC tl::Registrar *Registrar::instance = 0; - template class LYM_PUBLIC tl::RegisteredClass; -} diff --git a/src/rdb/rdb/rdbFile.cc b/src/rdb/rdb/rdbFile.cc index 757685862..f0c0d9b33 100644 --- a/src/rdb/rdb/rdbFile.cc +++ b/src/rdb/rdb/rdbFile.cc @@ -192,11 +192,3 @@ class StandardFormatDeclaration static tl::RegisteredClass format_decl (new StandardFormatDeclaration (), 0, "KLayout-RDB"); } - -// ------------------------------------------------------------- - -namespace tl -{ - template<> RDB_PUBLIC tl::Registrar *tl::Registrar::instance = 0; - template class RDB_PUBLIC tl::RegisteredClass; -} diff --git a/src/tl/tl/tl.pro b/src/tl/tl/tl.pro index e13891ebd..c796f7e9a 100644 --- a/src/tl/tl/tl.pro +++ b/src/tl/tl/tl.pro @@ -6,7 +6,16 @@ include($$PWD/../../lib.pri) DEFINES += MAKE_TL_LIBRARY -LIBS += -lz +!msvc { + LIBS += -lz +} + +msvc { + + LIBS += \ + -L$$THIRD_PARTY/zlib/1.2.11/lib -lzlib + +} equals(HAVE_QT, "0") { LIBS += -lpthread @@ -152,6 +161,3 @@ equals(HAVE_CURL, "1") { } -INCLUDEPATH = -DEPENDPATH = - diff --git a/src/tl/tl/tlClassRegistry.cc b/src/tl/tl/tlClassRegistry.cc index 2f49938f3..3fa5b39c9 100644 --- a/src/tl/tl/tlClassRegistry.cc +++ b/src/tl/tl/tlClassRegistry.cc @@ -23,3 +23,39 @@ #include "tlClassRegistry.h" +#include + +namespace tl +{ + +struct ti_compare_f +{ + bool operator() (const std::type_info *a, const std::type_info *b) const + { + return a->before (*b); + } +}; + +typedef std::map inst_map_type; +static inst_map_type s_inst_map; + +TL_PUBLIC void set_registrar_instance_by_type (const std::type_info &ti, RegistrarBase *rb) +{ + if (rb) { + s_inst_map[&ti] = rb; + } else { + s_inst_map.erase (&ti); + } +} + +TL_PUBLIC RegistrarBase *registrar_instance_by_type (const std::type_info &ti) +{ + inst_map_type::const_iterator im = s_inst_map.find (&ti); + if (im != s_inst_map.end ()) { + return im->second; + } else { + return 0; + } +} + +} diff --git a/src/tl/tl/tlClassRegistry.h b/src/tl/tl/tlClassRegistry.h index bd8401287..fa4a360a7 100644 --- a/src/tl/tl/tlClassRegistry.h +++ b/src/tl/tl/tlClassRegistry.h @@ -27,6 +27,7 @@ #include "tlCommon.h" #include "tlLog.h" +#include namespace tl { @@ -93,10 +94,12 @@ public: RegisteredClass (X *inst, int position = 0, const char *name = "", bool owned = true) : m_owned (owned) { - if (! Registrar::instance) { - Registrar::instance = new Registrar (); + Registrar *instance = Registrar::get_instance (); + if (! instance) { + instance = new Registrar (); + Registrar::set_instance (instance); } - mp_node = Registrar::instance->insert (inst, owned, position, name); + mp_node = instance->insert (inst, owned, position, name); if (tl::verbosity () >= 40) { tl::info << "Registered object '" << name << "' with priority " << position; @@ -105,13 +108,18 @@ public: ~RegisteredClass () { - // remove the associated object - Registrar::instance->remove (mp_node); + Registrar *instance = Registrar::get_instance (); + if (instance) { + + // remove the associated object + instance->remove (mp_node); + + if (instance->begin () == instance->end ()) { + // no more registered objects left - remove registrar + delete instance; + Registrar::set_instance (0); + } - if (Registrar::instance->begin () == Registrar::instance->end ()) { - // no more registered objects left - remove registrar - delete Registrar::instance; - Registrar::instance = 0; } } @@ -120,6 +128,22 @@ private: bool m_owned; }; +/** + * @brief A base class for the registrar types + */ +class RegistrarBase { }; + +/** + * @brief Sets the registrar instance by type + */ +TL_PUBLIC void set_registrar_instance_by_type (const std::type_info &ti, RegistrarBase *rb); + +/** + * @brief Gets the registrar instance by type + * Returns 0 if no registrar instance is set by this type; + */ +TL_PUBLIC RegistrarBase *registrar_instance_by_type (const std::type_info &ti); + /** * @brief The registrar capable of registering objects of type Y derived from X * @@ -131,6 +155,7 @@ private: */ template class Registrar + : public RegistrarBase { public: class iterator @@ -220,15 +245,18 @@ public: static Registrar *get_instance () { - return instance; + return static_cast *> (registrar_instance_by_type (typeid (X))); + } + + static void set_instance (Registrar *instance) + { + set_registrar_instance_by_type (typeid (X), instance); } private: friend class iterator; template friend class RegisteredClass; - static Registrar *instance; - RegistrarNode *insert (X *cls, bool owned, int position, const std::string &name) { RegistrarNode **link = &mp_first; diff --git a/src/tl/tl/tlCommandLineParser.cc b/src/tl/tl/tlCommandLineParser.cc index ab6d4992d..c30eb5657 100644 --- a/src/tl/tl/tlCommandLineParser.cc +++ b/src/tl/tl/tlCommandLineParser.cc @@ -23,6 +23,7 @@ #include "tlLog.h" #include "tlCommandLineParser.h" #include "tlFileUtils.h" +#include "tlString.h" namespace tl { diff --git a/src/tl/tl/tlEvents.cc b/src/tl/tl/tlEvents.cc index a6e5a053d..a282a483d 100644 --- a/src/tl/tl/tlEvents.cc +++ b/src/tl/tl/tlEvents.cc @@ -28,14 +28,14 @@ namespace tl { -TL_PUBLIC void handle_event_exception (tl::Exception &ex) +void handle_event_exception (tl::Exception &ex) { // Exceptions have unpredicable side effects for events so we just log // them here. tl::warn << ex.msg (); } -TL_PUBLIC void handle_event_exception (std::exception &ex) +void handle_event_exception (std::exception &ex) { // Exceptions have unpredicable side effects for events so we just log // them here. diff --git a/src/tl/tl/tlEvents.h b/src/tl/tl/tlEvents.h index 12fa2e8bb..8a1c9a00e 100644 --- a/src/tl/tl/tlEvents.h +++ b/src/tl/tl/tlEvents.h @@ -36,12 +36,12 @@ namespace tl /** * @brief A helper function to handle event exceptions of tl::Exception type */ -void handle_event_exception (tl::Exception &ex); +TL_PUBLIC void handle_event_exception (tl::Exception &ex); /** * @brief A helper function to handle event exceptions of std::exception type */ -void handle_event_exception (std::exception &ex); +TL_PUBLIC void handle_event_exception (std::exception &ex); /** * @brief A framework of observer and observables diff --git a/src/tl/tl/tlExpression.cc b/src/tl/tl/tlExpression.cc index 217949315..65a8590df 100644 --- a/src/tl/tl/tlExpression.cc +++ b/src/tl/tl/tlExpression.cc @@ -31,6 +31,7 @@ #include #include #include +#define _USE_MATH_DEFINES // for MSVC #include #include #include diff --git a/src/tl/tl/tlFileUtils.cc b/src/tl/tl/tlFileUtils.cc index 39bcd7125..f9fc0e20b 100644 --- a/src/tl/tl/tlFileUtils.cc +++ b/src/tl/tl/tlFileUtils.cc @@ -27,19 +27,36 @@ #include -#include -#include -#include +#if defined(_MSC_VER) -#if defined(_WIN32) +# include +# include +# include +# include + +#elif defined(_WIN32) + +# include +# include +# include # include -# include -#elif defined(__APPLE__) -# include -#endif +# include -#if !defined(_WIN32) +#elif defined(__APPLE__) + +# include +# include +# include +# include # include + +#else + +# include +# include +# include +# include + #endif namespace tl @@ -664,13 +681,21 @@ bool file_exists (const std::string &p) bool is_writable (const std::string &p) { stat_struct st; +#if defined(_MSC_VER) + return stat_func (p, st) == 0 && (st.st_mode & _S_IWRITE) != 0; +#else return stat_func (p, st) == 0 && (st.st_mode & S_IWUSR) != 0; +#endif } bool is_readable (const std::string &p) { stat_struct st; +#if defined(_MSC_VER) + return stat_func (p, st) == 0 && (st.st_mode & _S_IREAD) != 0; +#else return stat_func (p, st) == 0 && (st.st_mode & S_IRUSR) != 0; +#endif } bool is_dir (const std::string &p) @@ -679,7 +704,11 @@ bool is_dir (const std::string &p) if (stat_func (p, st) != 0) { return false; } else { +#if defined(_MSC_VER) + return !(st.st_mode & _S_IFREG); +#else return !S_ISREG (st.st_mode); +#endif } } diff --git a/src/tl/tl/tlLog.cc b/src/tl/tl/tlLog.cc index 1c8cace45..4c954df15 100644 --- a/src/tl/tl/tlLog.cc +++ b/src/tl/tl/tlLog.cc @@ -25,7 +25,9 @@ #include "tlString.h" #include -#include +#if !defined(_MSC_VER) +# include +#endif #include #if defined(_WIN32) @@ -250,7 +252,11 @@ ChannelProxy::ChannelProxy (const ChannelProxy &d) static bool can_colorize (FILE *stream) { +#if defined(_MSC_VER) + return false; +#else return isatty (fileno (stream)); +#endif } #define ANSI_RED "\033[31;1m" diff --git a/src/tl/tl/tlString.cc b/src/tl/tl/tlString.cc index ec17ef659..245e8f94a 100644 --- a/src/tl/tl/tlString.cc +++ b/src/tl/tl/tlString.cc @@ -721,7 +721,7 @@ from_string (const std::string &s, const unsigned char * &result) } void -from_string (const std::string &s, double &v) throw (tl::Exception) +from_string (const std::string &s, double &v) { const char *cp = s.c_str (); while (*cp && isspace (*cp)) { @@ -743,7 +743,7 @@ from_string (const std::string &s, double &v) throw (tl::Exception) template void -convert_string_to_int (const std::string &s, T &v) throw (tl::Exception) +convert_string_to_int (const std::string &s, T &v) { double x; // HACK: this should be some real string-to-int conversion @@ -761,43 +761,43 @@ convert_string_to_int (const std::string &s, T &v) throw (tl::Exception) } void -from_string (const std::string &s, int &v) throw (tl::Exception) +from_string (const std::string &s, int &v) { convert_string_to_int (s, v); } void -from_string (const std::string &s, long &v) throw (tl::Exception) +from_string (const std::string &s, long &v) { convert_string_to_int (s, v); } void -from_string (const std::string &s, long long &v) throw (tl::Exception) +from_string (const std::string &s, long long &v) { convert_string_to_int (s, v); } void -from_string (const std::string &s, unsigned int &v) throw (tl::Exception) +from_string (const std::string &s, unsigned int &v) { convert_string_to_int (s, v); } void -from_string (const std::string &s, unsigned long &v) throw (tl::Exception) +from_string (const std::string &s, unsigned long &v) { convert_string_to_int (s, v); } void -from_string (const std::string &s, unsigned long long &v) throw (tl::Exception) +from_string (const std::string &s, unsigned long long &v) { convert_string_to_int (s, v); } void -from_string (const std::string &s, bool &b) throw (tl::Exception) +from_string (const std::string &s, bool &b) { std::string t (tl::trim (s)); if (t == "true") { diff --git a/src/tl/tl/tlString.h b/src/tl/tl/tlString.h index e4a2ecb53..c96a7096a 100644 --- a/src/tl/tl/tlString.h +++ b/src/tl/tl/tlString.h @@ -757,14 +757,14 @@ private: TL_PUBLIC void from_string (const std::string &s, const char * &result); TL_PUBLIC void from_string (const std::string &s, const unsigned char * &result); -TL_PUBLIC void from_string (const std::string &s, double &v) throw (tl::Exception); -TL_PUBLIC void from_string (const std::string &s, int &v) throw (tl::Exception); -TL_PUBLIC void from_string (const std::string &s, long &v) throw (tl::Exception); -TL_PUBLIC void from_string (const std::string &s, long long &v) throw (tl::Exception); -TL_PUBLIC void from_string (const std::string &s, unsigned int &v) throw (tl::Exception); -TL_PUBLIC void from_string (const std::string &s, unsigned long &v) throw (tl::Exception); -TL_PUBLIC void from_string (const std::string &s, unsigned long long &v) throw (tl::Exception); -TL_PUBLIC void from_string (const std::string &s, bool &b) throw (tl::Exception); +TL_PUBLIC void from_string (const std::string &s, double &v); +TL_PUBLIC void from_string (const std::string &s, int &v); +TL_PUBLIC void from_string (const std::string &s, long &v); +TL_PUBLIC void from_string (const std::string &s, long long &v); +TL_PUBLIC void from_string (const std::string &s, unsigned int &v); +TL_PUBLIC void from_string (const std::string &s, unsigned long &v); +TL_PUBLIC void from_string (const std::string &s, unsigned long long &v); +TL_PUBLIC void from_string (const std::string &s, bool &b); inline void from_string (const std::string &s, std::string &v) { v = s; } diff --git a/src/tl/tl/tlThreads.h b/src/tl/tl/tlThreads.h index f8d88263e..41f92be41 100644 --- a/src/tl/tl/tlThreads.h +++ b/src/tl/tl/tlThreads.h @@ -180,7 +180,7 @@ private: #if defined(HAVE_QT) template -class TL_PUBLIC ThreadStorage +class ThreadStorage : public QThreadStorage { public: diff --git a/src/tl/tl/tlTimer.cc b/src/tl/tl/tlTimer.cc index 197fbd19a..a65379ea4 100644 --- a/src/tl/tl/tlTimer.cc +++ b/src/tl/tl/tlTimer.cc @@ -32,46 +32,52 @@ #include -#ifndef _MSC_VER // not available on MS VC++ +#if !defined(_MSC_VER) // not available on MS VC++ # include #endif +#if defined(_MSC_VER) +# include +#endif + #if defined(__MACH__) -#include -#include +# include +# include #endif namespace tl { // ------------------------------------------------------------- +// Gets the current time in ms from epoch -void current_utc_time (struct timespec *ts) +static int64_t ms_time () { - #if defined(__MACH__) + clock_serv_t cclock; mach_timespec_t mts; host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); clock_get_time(cclock, &mts); mach_port_deallocate(mach_task_self(), cclock); - ts->tv_sec = mts.tv_sec; - ts->tv_nsec = mts.tv_nsec; + + return int64_t (mts.tv_sec) * 1000 + int64_t (0.5 + mts.tv_nsec / 1.0e6); + +#elif defined(_MSC_VER) + + FILETIME ft; + GetSystemTimeAsFileTime (&ft); + // device by 8192 -> should fit into a 64bit type + uint64_t t = (uint64_t (ft.dwHighDateTime) << (64 - 13)) | (uint64_t (ft.dwLowDateTime) >> 13); + return int64_t (0.5 + t / 0.8192); + #else + + timespec ts; clock_gettime(CLOCK_REALTIME, ts); + return int64_t (ts.tv_sec) * 1000 + int64_t (0.5 + ts.tv_nsec / 1.0e6); + #endif - -} - -// ------------------------------------------------------------- -// Gets the current time in ms from epoch - -static int64_t ms_time () -{ - struct timespec spec; - current_utc_time (&spec); - - return int64_t (spec.tv_sec) * 1000 + int64_t (0.5 + spec.tv_nsec / 1.0e6); } // ------------------------------------------------------------- @@ -100,9 +106,6 @@ Timer::start () m_sys_ms += (timer_t) ((clks.tms_stime + clks.tms_cstime) * clk2msec + 0.5); #endif - struct timespec spec; - current_utc_time (&spec); - m_wall_ms += ms_time (); } diff --git a/src/tl/tl/tlUnitTest.h b/src/tl/tl/tlUnitTest.h index a596f4f3a..9f1860bc7 100644 --- a/src/tl/tl/tlUnitTest.h +++ b/src/tl/tl/tlUnitTest.h @@ -456,7 +456,7 @@ protected: } private: - virtual void execute (tl::TestBase *_this) throw (tl::Exception) = 0; + virtual void execute (tl::TestBase *_this) = 0; void write_detailed_diff (std::ostream &os, const std::string &subject, const std::string &ref); @@ -496,11 +496,11 @@ struct TestImpl##NAME \ : public tl::TestBase \ { \ TestImpl##NAME () : TestBase (__FILE__, #NAME) { } \ - virtual void execute (tl::TestBase *_this) throw (tl::Exception); \ + virtual void execute (tl::TestBase *_this); \ }; \ static TestImpl##NAME TestImpl_Inst##NAME; \ } \ - void TestImpl##NAME::execute (tl::TestBase *_this) throw (tl::Exception) + void TestImpl##NAME::execute (tl::TestBase *_this) #define EXPECT_EQ(WHAT,EQUALS) \ _this->checkpoint (__FILE__, __LINE__); \ diff --git a/src/tl/unit_tests/tlClassRegistry.cc b/src/tl/unit_tests/tlClassRegistry.cc index e6f581f87..4ee757488 100644 --- a/src/tl/unit_tests/tlClassRegistry.cc +++ b/src/tl/unit_tests/tlClassRegistry.cc @@ -20,7 +20,6 @@ */ - #include "tlClassRegistry.h" #include "tlUnitTest.h" @@ -39,13 +38,13 @@ public: class Y : public X { public: - virtual const char *name () const { return "Y"; }; + virtual const char *name () const { return "Y"; } }; class Z : public X { public: - virtual const char *name () const { return "Z"; }; + virtual const char *name () const { return "Z"; } }; @@ -59,12 +58,12 @@ public: class B : public A { - virtual const char *name () const { return "B"; }; + virtual const char *name () const { return "B"; } }; class C : public A { - virtual const char *name () const { return "C"; }; + virtual const char *name () const { return "C"; } }; @@ -112,10 +111,3 @@ TEST(3) } } - -namespace tl -{ - template <> tl::Registrar *Registrar::instance = 0; - template <> tl::Registrar *Registrar::instance = 0; -} - diff --git a/src/tl/unit_tests/tlExpression.cc b/src/tl/unit_tests/tlExpression.cc index 178fee5f5..7c539cb9c 100644 --- a/src/tl/unit_tests/tlExpression.cc +++ b/src/tl/unit_tests/tlExpression.cc @@ -26,6 +26,7 @@ #include "tlUnitTest.h" #include +#define _USE_MATH_DEFINES // for MSVC #include // basics diff --git a/src/tl/unit_tests/tlString.cc b/src/tl/unit_tests/tlString.cc index 13e2f064b..b8911b9f4 100644 --- a/src/tl/unit_tests/tlString.cc +++ b/src/tl/unit_tests/tlString.cc @@ -25,7 +25,8 @@ #include "tlTimer.h" #include "tlUnitTest.h" -#include +#define _USE_MATH_DEFINES // for MSVC +#include #include using namespace tl; diff --git a/src/tl/unit_tests/tlThreads.cc b/src/tl/unit_tests/tlThreads.cc index 82301eeeb..632f0824b 100644 --- a/src/tl/unit_tests/tlThreads.cc +++ b/src/tl/unit_tests/tlThreads.cc @@ -26,7 +26,7 @@ #include #if defined(WIN32) -#include +#include inline void usleep(long us) { Sleep(us / 1000);