From be92a29bdefbd1dd20b9923435e10b34b7ee0297 Mon Sep 17 00:00:00 2001 From: Markus Frank <Markus.Frank@cern.ch> Date: Thu, 3 Nov 2016 19:41:37 +0100 Subject: [PATCH] First round of fixing Clang compiler and linker problems --- DDCore/CMakeLists.txt | 3 +- DDCore/src/ToStream.cpp | 38 ------------------ DDCore/src/parsers/Evaluators.cpp | 66 +++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 39 deletions(-) create mode 100644 DDCore/src/parsers/Evaluators.cpp diff --git a/DDCore/CMakeLists.txt b/DDCore/CMakeLists.txt index 5d4e85b3d..aa8906bc5 100644 --- a/DDCore/CMakeLists.txt +++ b/DDCore/CMakeLists.txt @@ -36,12 +36,13 @@ dd4hep_add_dictionary( G__DD4hep dd4hep_add_package_library ( DDParsers INCLUDE_DIRS LINK_LIBRARIES + SOURCES src/Evaluator/*.cpp OPTIONAL [BOOST SOURCES src/parsers/*.cpp] ) #---Generate DDCore Library------------------------------------------------------- dd4hep_add_package_library ( DDCore - SOURCES src/*.cpp src/Evaluator/*.cpp src/XML/*.cpp + SOURCES src/*.cpp src/XML/*.cpp GENERATED G__DD4hep.cxx INCLUDE_DIRS ${GaudiPluginService_INCLUDE_DIRS} LINK_LIBRARIES DDParsers ${GaudiPluginService_LIBRARIES} diff --git a/DDCore/src/ToStream.cpp b/DDCore/src/ToStream.cpp index b1d0838cc..4567f7f05 100644 --- a/DDCore/src/ToStream.cpp +++ b/DDCore/src/ToStream.cpp @@ -26,44 +26,6 @@ #include "DD4hep/ToStream.h" #endif -#include "XML/Evaluator.h" - -// C/C++ include files -#include <stdexcept> - -namespace DD4hep { - XmlTools::Evaluator& g4Evaluator(); -} -namespace { - XmlTools::Evaluator& eval(DD4hep::g4Evaluator()); -} - -//============================================================================== -namespace DD4hep { namespace Parsers { - template <typename T> T evaluate_string(const std::string& /* value */) { - throw "Bad undefined call"; - } - - template <> double evaluate_string<double>(const std::string& value) { - double result = eval.evaluate(value.c_str()); - if (eval.status() != XmlTools::Evaluator::OK) { - std::cerr << value << ": "; - eval.print_error(); - throw std::runtime_error("DD4hep::Properties: Severe error during expression evaluation of " + value); - } - return result; - } - template <> float evaluate_string<float>(const std::string& value) { - double result = eval.evaluate(value.c_str()); - if (eval.status() != XmlTools::Evaluator::OK) { - std::cerr << value << ": "; - eval.print_error(); - throw std::runtime_error("DD4hep::Properties: Severe error during expression evaluation of " + value); - } - return (float) result; - } - } -} #ifndef DD4HEP_PARSERS_NO_ROOT diff --git a/DDCore/src/parsers/Evaluators.cpp b/DDCore/src/parsers/Evaluators.cpp new file mode 100644 index 000000000..247c1be26 --- /dev/null +++ b/DDCore/src/parsers/Evaluators.cpp @@ -0,0 +1,66 @@ +// $Id: $ +//========================================================================== +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//========================================================================== + +// Framework include files +#if defined(DD4HEP_PARSER_HEADER) + +#define DD4HEP_NEED_EVALUATOR +// This is the case, if the parsers are externalized +// and the DD4hep namespace is renamed! +#include DD4HEP_PARSER_HEADER + +#else + +// Standard DD4hep parser handling +#include "DD4hep/ToStream.h" + +#endif +#include "XML/Evaluator.h" + +// C/C++ include files +#include <stdexcept> + +namespace DD4hep { + XmlTools::Evaluator& g4Evaluator(); +} +namespace { + XmlTools::Evaluator& eval(DD4hep::g4Evaluator()); +} + +//============================================================================== +namespace DD4hep { namespace Parsers { + template <typename T> T evaluate_string(const std::string& /* value */) { + throw "Bad undefined call"; + } + + template <> double evaluate_string<double>(const std::string& value) { + double result = eval.evaluate(value.c_str()); + if (eval.status() != XmlTools::Evaluator::OK) { + std::cerr << value << ": "; + eval.print_error(); + throw std::runtime_error("DD4hep::Properties: Severe error during expression evaluation of " + value); + } + return result; + } + template <> float evaluate_string<float>(const std::string& value) { + double result = eval.evaluate(value.c_str()); + if (eval.status() != XmlTools::Evaluator::OK) { + std::cerr << value << ": "; + eval.print_error(); + throw std::runtime_error("DD4hep::Properties: Severe error during expression evaluation of " + value); + } + return (float) result; + } + } +} -- GitLab