diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-07-25 20:49:46 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-07-25 20:49:46 +0100 |
commit | fdfc360fa9af398ba4bad0b6b75789708e3742cb (patch) | |
tree | 331b7714482208a2fe8af0d62bd7572f2cc81925 | |
parent | Replace system(diff..) with a function (diff) | |
download | slicer-1.0.3.tar.bz2 slicer-1.0.3.tar.xz slicer-1.0.3.zip |
Visibility hiddenslicer-1.0.3
-rw-r--r-- | slicer/json/Jamfile.jam | 2 | ||||
-rw-r--r-- | slicer/json/serializer.h | 12 | ||||
-rw-r--r-- | slicer/slicer/Jamfile.jam | 2 | ||||
-rw-r--r-- | slicer/slicer/metadata.h | 2 | ||||
-rw-r--r-- | slicer/slicer/modelParts.h | 57 | ||||
-rw-r--r-- | slicer/slicer/parser.cpp | 32 | ||||
-rw-r--r-- | slicer/slicer/parser.h | 7 | ||||
-rw-r--r-- | slicer/test/preprocessor.cpp | 2 | ||||
-rw-r--r-- | slicer/tool/Jamfile.jam | 2 | ||||
-rw-r--r-- | slicer/xml/Jamfile.jam | 2 | ||||
-rw-r--r-- | slicer/xml/serializer.h | 12 |
11 files changed, 79 insertions, 53 deletions
diff --git a/slicer/json/Jamfile.jam b/slicer/json/Jamfile.jam index beb6679..3e047ee 100644 --- a/slicer/json/Jamfile.jam +++ b/slicer/json/Jamfile.jam @@ -21,6 +21,8 @@ lib slicer-json : <library>jsonpp <library>glibmm <library>../slicer//slicer + <cflags>-fvisibility=hidden + <variant>release:<cflags>-flto : : <library>jsonpp ; diff --git a/slicer/json/serializer.h b/slicer/json/serializer.h index 6e87071..a1c75bd 100644 --- a/slicer/json/serializer.h +++ b/slicer/json/serializer.h @@ -4,6 +4,10 @@ #include <slicer/serializer.h> #include <jsonpp.h> +#ifndef DLL_PUBLIC +#define DLL_PUBLIC __attribute__ ((visibility ("default"))) +#endif + namespace Slicer { class JsonSerializer : public Serializer { protected: @@ -14,7 +18,7 @@ namespace Slicer { class JsonFileSerializer : public JsonSerializer { public: - JsonFileSerializer(const boost::filesystem::path &); + DLL_PUBLIC JsonFileSerializer(const boost::filesystem::path &); virtual void Serialize(ModelPartPtr) override; @@ -24,7 +28,7 @@ namespace Slicer { class JsonValueSerializer : public JsonSerializer { public: - JsonValueSerializer(json::Value &); + DLL_PUBLIC JsonValueSerializer(json::Value &); virtual void Serialize(ModelPartPtr) override; @@ -34,7 +38,7 @@ namespace Slicer { class JsonFileDeserializer : public Deserializer { public: - JsonFileDeserializer(const boost::filesystem::path &); + DLL_PUBLIC JsonFileDeserializer(const boost::filesystem::path &); virtual void Deserialize(ModelPartPtr) override; @@ -44,7 +48,7 @@ namespace Slicer { class JsonValueDeserializer : public Deserializer { public: - JsonValueDeserializer(const json::Value &); + DLL_PUBLIC JsonValueDeserializer(const json::Value &); virtual void Deserialize(ModelPartPtr) override; diff --git a/slicer/slicer/Jamfile.jam b/slicer/slicer/Jamfile.jam index 18acae6..8b477c0 100644 --- a/slicer/slicer/Jamfile.jam +++ b/slicer/slicer/Jamfile.jam @@ -11,6 +11,8 @@ lib slicer : <library>boost_system <library>boost_filesystem <include>.. + <cflags>-fvisibility=hidden + <variant>release:<cflags>-flto : : <include>.. <library>boost_system diff --git a/slicer/slicer/metadata.h b/slicer/slicer/metadata.h index 2ed26b8..b14803c 100644 --- a/slicer/slicer/metadata.h +++ b/slicer/slicer/metadata.h @@ -6,6 +6,7 @@ #include <vector> #include <boost/optional.hpp> +#pragma GCC visibility push(default) namespace Slicer { // Flags bool metaDataFlagSet(const std::list<std::string> &, const std::string & flag); @@ -15,6 +16,7 @@ namespace Slicer { std::list<std::string> metaDataValues(const std::string & prefix, const std::list<std::string> & metadata); std::vector<std::string> metaDataSplit(const std::string & metadata); } +#pragma GCC visibility pop #endif diff --git a/slicer/slicer/modelParts.h b/slicer/slicer/modelParts.h index 97f7037..cc32cac 100644 --- a/slicer/slicer/modelParts.h +++ b/slicer/slicer/modelParts.h @@ -11,6 +11,9 @@ #include <boost/function.hpp> #include <boost/bimap.hpp> #include <vector> +#ifndef DLL_PUBLIC +#define DLL_PUBLIC __attribute__ ((visibility ("default"))) +#endif namespace Slicer { // This allows IceUtil::Handle to play nicely with boost::things @@ -21,17 +24,17 @@ namespace Slicer { return p.get(); } - class IncorrectElementName : public std::invalid_argument { + class DLL_PUBLIC IncorrectElementName : public std::invalid_argument { public: IncorrectElementName(const std::string & n); }; - class UnknownType : public std::invalid_argument { + class DLL_PUBLIC UnknownType : public std::invalid_argument { public: UnknownType(const std::string & n); }; - class InvalidEnumerationValue : public std::invalid_argument { + class DLL_PUBLIC InvalidEnumerationValue : public std::invalid_argument { public: InvalidEnumerationValue(const std::string & n, const std::string & e); InvalidEnumerationValue(::Ice::Int n, const std::string & e); @@ -101,9 +104,9 @@ namespace Slicer { typedef boost::function<ModelPartPtr(void *)> ClassRef; typedef boost::function<bool(HookCommonPtr)> HookFilter; typedef std::map<std::string, ClassRef> ClassRefMap; - ClassRefMap * & classRefMap(); + DLL_PUBLIC ClassRefMap * & classRefMap(); typedef boost::bimap<std::string, std::string> ClassNameMap; - ClassNameMap * & classNameMap(); + DLL_PUBLIC ClassNameMap * & classNameMap(); typedef std::list<std::string> Metadata; enum ModelPartType { mpt_Null, @@ -121,16 +124,16 @@ namespace Slicer { }; #define templateMODELPARTFOR(Type) \ - template <class T> ModelPartPtr ModelPartFor(Type & t); \ - template <class T> ModelPartPtr ModelPartFor(Type * t); + template <class T> ModelPartPtr DLL_PUBLIC ModelPartFor(Type & t); \ + template <class T> ModelPartPtr DLL_PUBLIC ModelPartFor(Type * t); #define MODELPARTFOR(Type) \ - ModelPartPtr ModelPartFor(Type & t); \ - ModelPartPtr ModelPartFor(Type * t); + ModelPartPtr DLL_PUBLIC ModelPartFor(Type & t); \ + ModelPartPtr DLL_PUBLIC ModelPartFor(Type * t); templateMODELPARTFOR(IceInternal::Handle<T>); templateMODELPARTFOR(std::vector<T>); templateMODELPARTFOR(std::list<T>); - template <class K, class V> ModelPartPtr ModelPartFor(std::map<K, V> & t); - template <class K, class V> ModelPartPtr ModelPartFor(std::map<K, V> * t); + template <class K, class V> ModelPartPtr DLL_PUBLIC ModelPartFor(std::map<K, V> & t); + template <class K, class V> ModelPartPtr DLL_PUBLIC ModelPartFor(std::map<K, V> * t); MODELPARTFOR(std::string); MODELPARTFOR(bool); MODELPARTFOR(Ice::Float); @@ -149,7 +152,7 @@ namespace Slicer { virtual const Metadata & ChildMetaData() const = 0; }; typedef IceUtil::Handle<ChildRef> ChildRefPtr; - class ImplicitChildRef : public ChildRef { + class DLL_PUBLIC ImplicitChildRef : public ChildRef { public: ImplicitChildRef(ModelPartPtr); @@ -159,7 +162,7 @@ namespace Slicer { private: ModelPartPtr mpp; }; - class MemberChildRef : public ChildRef { + class DLL_PUBLIC MemberChildRef : public ChildRef { public: MemberChildRef(ModelPartPtr, const Metadata &); @@ -171,7 +174,7 @@ namespace Slicer { const Metadata & mdr; }; - class ModelPart : public IceUtil::Shared { + class DLL_PUBLIC ModelPart : public IceUtil::Shared { public: virtual ~ModelPart() = default; @@ -196,7 +199,7 @@ namespace Slicer { }; template<typename T> - class ModelPartForSimple : public ModelPart { + class DLL_PUBLIC ModelPartForSimple : public ModelPart { public: typedef T element_type; @@ -221,7 +224,7 @@ namespace Slicer { }; template<typename T, typename M, T M::* MV> - class ModelPartForConverted : public ModelPart { + class DLL_PUBLIC ModelPartForConverted : public ModelPart { public: typedef T element_type; @@ -246,7 +249,7 @@ namespace Slicer { }; template<typename T> - class ModelPartForOptional : public ModelPart { + class DLL_PUBLIC ModelPartForOptional : public ModelPart { public: ModelPartForOptional(IceUtil::Optional< typename T::element_type > & h) : OptionalMember(h) @@ -328,7 +331,7 @@ namespace Slicer { }; template<typename T> - class ModelPartForComplex : public ModelPart { + class DLL_PUBLIC ModelPartForComplex : public ModelPart { public: class HookBase : public HookCommon { public: @@ -409,7 +412,7 @@ namespace Slicer { }; template<typename T> - class ModelPartForClass : public ModelPartForComplex<typename T::element_type> { + class DLL_PUBLIC ModelPartForClass : public ModelPartForComplex<typename T::element_type> { public: typedef T element_type; @@ -454,7 +457,7 @@ namespace Slicer { }; template<typename T> - class ModelPartForStruct : public ModelPartForComplex<T> { + class DLL_PUBLIC ModelPartForStruct : public ModelPartForComplex<T> { public: typedef T element_type; @@ -480,7 +483,7 @@ namespace Slicer { }; template<typename T> - class ModelPartForRoot : public ModelPart { + class DLL_PUBLIC ModelPartForRoot : public ModelPart { public: ModelPartForRoot() : ModelObject(new T()), @@ -539,11 +542,11 @@ namespace Slicer { T * ModelObject; bool owned; ModelPartPtr mp; - static std::string rootName; + DLL_PUBLIC static std::string rootName; }; template<typename T> - class ModelPartForEnum : public ModelPart { + class DLL_PUBLIC ModelPartForEnum : public ModelPart { public: typedef T element_type; typedef boost::bimap<T, std::string> Enumerations; @@ -581,7 +584,7 @@ namespace Slicer { }; template<typename T> - class ModelPartForSequence : public ModelPart { + class DLL_PUBLIC ModelPartForSequence : public ModelPart { public: typedef T element_type; @@ -625,7 +628,7 @@ namespace Slicer { }; template<typename T> - class ModelPartForDictionaryElement : public ModelPartForComplex<ModelPartForDictionaryElement<T> > { + class DLL_PUBLIC ModelPartForDictionaryElement : public ModelPartForComplex<ModelPartForDictionaryElement<T> > { public: ModelPartForDictionaryElement(typename T::key_type * k, typename T::mapped_type * v) : key(k), @@ -645,7 +648,7 @@ namespace Slicer { }; template<typename T> - class ModelPartForDictionaryElementInserter : public ModelPartForDictionaryElement<T> { + class DLL_PUBLIC ModelPartForDictionaryElementInserter : public ModelPartForDictionaryElement<T> { public: ModelPartForDictionaryElementInserter(T & d) : ModelPartForDictionaryElement<T>(&key, &value), @@ -663,7 +666,7 @@ namespace Slicer { }; template<typename T> - class ModelPartForDictionary : public ModelPart { + class DLL_PUBLIC ModelPartForDictionary : public ModelPart { public: typedef T element_type; diff --git a/slicer/slicer/parser.cpp b/slicer/slicer/parser.cpp index 825d59b..8193c9d 100644 --- a/slicer/slicer/parser.cpp +++ b/slicer/slicer/parser.cpp @@ -90,8 +90,8 @@ namespace Slicer { fprintf(cpp, "#include <%s>\n\n", fs::change_extension(topLevelFile.filename(), ".h").string().c_str()); fprintf(cpp, "#include <slicer/modelParts.h>\n\n"); fprintf(cpp, "#define templateMODELPARTFOR(Type, ModelPart) \\\n"); - fprintf(cpp, "template <> ModelPartPtr ModelPartFor(Type & t) { return new ModelPart< Type >(t); } \\\n"); - fprintf(cpp, "template <> ModelPartPtr ModelPartFor(Type * t) { return new ModelPart< Type >(t); }\n\n"); + fprintf(cpp, "template <> ModelPartPtr DLL_PUBLIC ModelPartFor(Type & t) { return new ModelPart< Type >(t); } \\\n"); + fprintf(cpp, "template <> ModelPartPtr DLL_PUBLIC ModelPartFor(Type * t) { return new ModelPart< Type >(t); }\n\n"); fprintf(cpp, "namespace Slicer {\n"); return true; } @@ -129,7 +129,7 @@ namespace Slicer { Slicer::defineRootName(const std::string & type, const std::string & name) const { fprintf(cpp, "template<>\n"); - fprintf(cpp, "std::string ModelPartForRoot< %s >::rootName(\"%s\");\n\n", + fprintf(cpp, "DLL_PUBLIC std::string ModelPartForRoot< %s >::rootName(\"%s\");\n\n", type.c_str(), name.c_str()); } @@ -149,7 +149,7 @@ namespace Slicer { fprintf(cpp, "template<>\n"); auto typeId = metaDataValue("slicer:typeid:", c->getMetaData()); - fprintf(cpp, "std::string ModelPartForClass< %s >::typeIdProperty(\"%s\");\n\n", + fprintf(cpp, "DLL_PUBLIC std::string ModelPartForClass< %s >::typeIdProperty(\"%s\");\n\n", typeToString(decl).c_str(), typeId ? typeId->c_str() : "slicer-typeid"); @@ -179,13 +179,13 @@ namespace Slicer { } fprintf(cpp, "}\n\n"); - fprintf(cpp, "template<>\nTypeId\nModelPartForClass< %s >::GetTypeId() const\n{\n", + fprintf(cpp, "template<>\nDLL_PUBLIC TypeId\nModelPartForClass< %s >::GetTypeId() const\n{\n", typeToString(decl).c_str()); fprintf(cpp, "\tauto id = ModelObject->ice_id();\n"); fprintf(cpp, "\treturn (id == \"%s\") ? TypeId() : ModelPart::ToExchangeTypeName(id);\n}\n\n", c->scoped().c_str()); - fprintf(cpp, "template<>\nMetadata ModelPartForComplex< %s >::metadata ", + fprintf(cpp, "template<>\nDLL_PUBLIC Metadata ModelPartForComplex< %s >::metadata ", c->scoped().c_str()); copyMetadata(c->getMetaData()); @@ -212,7 +212,7 @@ namespace Slicer { auto name = metaDataValue("slicer:root:", c->getMetaData()); defineRootName(c->scoped(), name ? *name : c->name()); - fprintf(cpp, "template<>\nMetadata ModelPartForComplex< %s >::metadata ", + fprintf(cpp, "template<>\nDLL_PUBLIC Metadata ModelPartForComplex< %s >::metadata ", c->scoped().c_str()); copyMetadata(c->getMetaData()); @@ -228,7 +228,7 @@ namespace Slicer { if (!cpp) return; fprintf(cpp, "template<>\n"); - fprintf(cpp, "ModelPartForComplex< %s >::Hooks ", + fprintf(cpp, "DLL_PUBLIC ModelPartForComplex< %s >::Hooks ", it->scoped().c_str()); fprintf(cpp, "ModelPartForComplex< %s >::hooks {\n", it->scoped().c_str()); @@ -351,7 +351,7 @@ namespace Slicer { fprintf(cpp, "// Sequence %s\n", s->name().c_str()); fprintf(cpp, "template<>\n"); - fprintf(cpp, "ChildRefPtr ModelPartForSequence< %s >::GetChildRef(const std::string & name, const HookFilter & flt)\n{\n", + fprintf(cpp, "DLL_PUBLIC ChildRefPtr ModelPartForSequence< %s >::GetChildRef(const std::string & name, const HookFilter & flt)\n{\n", s->scoped().c_str()); auto iname = metaDataValue("slicer:item:", s->getMetaData()); if (iname) { @@ -364,7 +364,7 @@ namespace Slicer { fprintf(cpp, "\treturn GetAnonChildRef(flt);\n}\n\n"); fprintf(cpp, "template<>\n"); - fprintf(cpp, "ModelPartPtr\n"); + fprintf(cpp, "DLL_PUBLIC ModelPartPtr\n"); fprintf(cpp, "ModelPartForSequence< %s >::elementModelPart(typename %s::value_type & e) const {\n", s->scoped().c_str(), s->scoped().c_str()); @@ -372,14 +372,14 @@ namespace Slicer { fprintf(cpp, "template<>\n"); auto ename = metaDataValue("slicer:element:", s->getMetaData()); - fprintf(cpp, "std::string ModelPartForSequence< %s >::elementName(\"%s\");\n\n", + fprintf(cpp, "DLL_PUBLIC std::string ModelPartForSequence< %s >::elementName(\"%s\");\n\n", s->scoped().c_str(), ename ? ename->c_str() : "element"); auto name = metaDataValue("slicer:root:", s->getMetaData()); defineRootName(s->scoped(), name ? *name : s->name()); - fprintf(cpp, "template<>\nMetadata ModelPartForSequence< %s >::metadata ", + fprintf(cpp, "template<>\nDLL_PUBLIC Metadata ModelPartForSequence< %s >::metadata ", s->scoped().c_str()); copyMetadata(s->getMetaData()); @@ -399,12 +399,12 @@ namespace Slicer { fprintf(cpp, "// Dictionary %s\n", d->name().c_str()); auto iname = metaDataValue("slicer:item:", d->getMetaData()); fprintf(cpp, "template<>\n"); - fprintf(cpp, "std::string ModelPartForDictionary< %s >::pairName(\"%s\");\n\n", + fprintf(cpp, "DLL_PUBLIC std::string ModelPartForDictionary< %s >::pairName(\"%s\");\n\n", d->scoped().c_str(), iname ? iname->c_str() : "element"); fprintf(cpp, "template<>\n"); - fprintf(cpp, "ModelPartForComplex< ModelPartForDictionaryElement< %s > >::Hooks ", + fprintf(cpp, "DLL_PUBLIC ModelPartForComplex< ModelPartForDictionaryElement< %s > >::Hooks ", d->scoped().c_str()); fprintf(cpp, "ModelPartForComplex< ModelPartForDictionaryElement< %s > >::hooks {\n", d->scoped().c_str()); @@ -434,11 +434,11 @@ namespace Slicer { fprintf(cpp, "\t};\n"); fprintf(cpp, "\n"); - fprintf(cpp, "template<>\nMetadata ModelPartForDictionary< %s >::metadata ", + fprintf(cpp, "template<>\nDLL_PUBLIC Metadata ModelPartForDictionary< %s >::metadata ", d->scoped().c_str()); copyMetadata(d->getMetaData()); - fprintf(cpp, "template<>\nMetadata ModelPartForComplex<ModelPartForDictionaryElement< %s > >::metadata ", + fprintf(cpp, "template<>\nDLL_PUBLIC Metadata ModelPartForComplex<ModelPartForDictionaryElement< %s > >::metadata ", d->scoped().c_str()); copyMetadata(d->getMetaData()); diff --git a/slicer/slicer/parser.h b/slicer/slicer/parser.h index 702393e..f5baef6 100644 --- a/slicer/slicer/parser.h +++ b/slicer/slicer/parser.h @@ -4,11 +4,14 @@ #include <Slice/Parser.h> #include <boost/optional.hpp> #include <boost/filesystem/path.hpp> +#ifndef DLL_PUBLIC +#define DLL_PUBLIC __attribute__ ((visibility ("default"))) +#endif namespace Slicer { typedef boost::shared_ptr<FILE> FilePtr; - class Slicer : public Slice::ParserVisitor { + class DLL_PUBLIC Slicer : public Slice::ParserVisitor { public: class ConversionSpec { public: @@ -19,12 +22,14 @@ namespace Slicer { typedef std::vector<ConversionSpec> Conversions; typedef std::vector<std::string> Args; +#pragma GCC visibility push(default) Slicer(FILE * c); static unsigned int Apply(const boost::filesystem::path & ice, const boost::filesystem::path & cpp); static unsigned int Apply(const boost::filesystem::path & ice, FILE *); static unsigned int Apply(const boost::filesystem::path & ice, const boost::filesystem::path & cpp, const Args &); static unsigned int Apply(const boost::filesystem::path & ice, FILE *, const Args &); +#pragma GCC visibility pop virtual bool visitUnitStart(const Slice::UnitPtr&) override; diff --git a/slicer/test/preprocessor.cpp b/slicer/test/preprocessor.cpp index ed67661..641f78b 100644 --- a/slicer/test/preprocessor.cpp +++ b/slicer/test/preprocessor.cpp @@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE( slicer_test_ice ) const fs::path obj = fs::change_extension(tmp / base, ".o"); const std::string compile = stringbf( - "g++ -Os -fPIC -c -std=c++0x -I tmp -I /usr/include/Ice -I /usr/include/IceUtil -I %s -I %s -I %s %s -o %s", + "g++ -Os -fPIC -c -std=c++0x -fvisibility=hidden -I tmp -I /usr/include/Ice -I /usr/include/IceUtil -I %s -I %s -I %s %s -o %s", root / bjamout, included / bjamout, root / "..", diff --git a/slicer/tool/Jamfile.jam b/slicer/tool/Jamfile.jam index 16942a0..ea557d1 100644 --- a/slicer/tool/Jamfile.jam +++ b/slicer/tool/Jamfile.jam @@ -5,4 +5,6 @@ exe slicer : : <library>../slicer//slicer <library>po + <cflags>-fvisibility=hidden + <variant>release:<cflags>-flto ; diff --git a/slicer/xml/Jamfile.jam b/slicer/xml/Jamfile.jam index e959b64..74a5a05 100644 --- a/slicer/xml/Jamfile.jam +++ b/slicer/xml/Jamfile.jam @@ -14,6 +14,8 @@ lib slicer-xml : <library>IceUtil <library>libxmlpp <library>../slicer//slicer + <cflags>-fvisibility=hidden + <variant>release:<cflags>-flto : : <library>libxmlpp ; diff --git a/slicer/xml/serializer.h b/slicer/xml/serializer.h index 1e5cc5f..2a21e57 100644 --- a/slicer/xml/serializer.h +++ b/slicer/xml/serializer.h @@ -4,6 +4,10 @@ #include <slicer/serializer.h> #include <libxml++/document.h> +#ifndef DLL_PUBLIC +#define DLL_PUBLIC __attribute__ ((visibility ("default"))) +#endif + namespace Slicer { class XmlSerializer : public Serializer { protected: @@ -17,7 +21,7 @@ namespace Slicer { class XmlFileSerializer : public XmlSerializer { public: - XmlFileSerializer(const boost::filesystem::path &); + DLL_PUBLIC XmlFileSerializer(const boost::filesystem::path &); virtual void Serialize(ModelPartPtr) override; @@ -27,7 +31,7 @@ namespace Slicer { class XmlDocumentSerializer : public XmlSerializer { public: - XmlDocumentSerializer(xmlpp::Document * &); + DLL_PUBLIC XmlDocumentSerializer(xmlpp::Document * &); virtual void Serialize(ModelPartPtr) override; @@ -43,7 +47,7 @@ namespace Slicer { class XmlFileDeserializer : public XmlDeserializer { public: - XmlFileDeserializer(const boost::filesystem::path &); + DLL_PUBLIC XmlFileDeserializer(const boost::filesystem::path &); virtual void Deserialize(ModelPartPtr) override; @@ -53,7 +57,7 @@ namespace Slicer { class XmlDocumentDeserializer : public XmlDeserializer { public: - XmlDocumentDeserializer(const xmlpp::Document *); + DLL_PUBLIC XmlDocumentDeserializer(const xmlpp::Document *); virtual void Deserialize(ModelPartPtr) override; |