From fdfc360fa9af398ba4bad0b6b75789708e3742cb Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 25 Jul 2015 20:49:46 +0100 Subject: Visibility hidden --- slicer/json/Jamfile.jam | 2 ++ slicer/json/serializer.h | 12 ++++++---- slicer/slicer/Jamfile.jam | 2 ++ slicer/slicer/metadata.h | 2 ++ slicer/slicer/modelParts.h | 57 +++++++++++++++++++++++--------------------- slicer/slicer/parser.cpp | 32 ++++++++++++------------- slicer/slicer/parser.h | 7 +++++- slicer/test/preprocessor.cpp | 2 +- slicer/tool/Jamfile.jam | 2 ++ slicer/xml/Jamfile.jam | 2 ++ 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 : jsonpp glibmm ../slicer//slicer + -fvisibility=hidden + release:-flto : : 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 #include +#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 : boost_system boost_filesystem .. + -fvisibility=hidden + release:-flto : : .. 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 #include +#pragma GCC visibility push(default) namespace Slicer { // Flags bool metaDataFlagSet(const std::list &, const std::string & flag); @@ -15,6 +16,7 @@ namespace Slicer { std::list metaDataValues(const std::string & prefix, const std::list & metadata); std::vector 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 #include #include +#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 ClassRef; typedef boost::function HookFilter; typedef std::map ClassRefMap; - ClassRefMap * & classRefMap(); + DLL_PUBLIC ClassRefMap * & classRefMap(); typedef boost::bimap ClassNameMap; - ClassNameMap * & classNameMap(); + DLL_PUBLIC ClassNameMap * & classNameMap(); typedef std::list Metadata; enum ModelPartType { mpt_Null, @@ -121,16 +124,16 @@ namespace Slicer { }; #define templateMODELPARTFOR(Type) \ - template ModelPartPtr ModelPartFor(Type & t); \ - template ModelPartPtr ModelPartFor(Type * t); + template ModelPartPtr DLL_PUBLIC ModelPartFor(Type & t); \ + template 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); templateMODELPARTFOR(std::vector); templateMODELPARTFOR(std::list); - template ModelPartPtr ModelPartFor(std::map & t); - template ModelPartPtr ModelPartFor(std::map * t); + template ModelPartPtr DLL_PUBLIC ModelPartFor(std::map & t); + template ModelPartPtr DLL_PUBLIC ModelPartFor(std::map * t); MODELPARTFOR(std::string); MODELPARTFOR(bool); MODELPARTFOR(Ice::Float); @@ -149,7 +152,7 @@ namespace Slicer { virtual const Metadata & ChildMetaData() const = 0; }; typedef IceUtil::Handle 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 - class ModelPartForSimple : public ModelPart { + class DLL_PUBLIC ModelPartForSimple : public ModelPart { public: typedef T element_type; @@ -221,7 +224,7 @@ namespace Slicer { }; template - class ModelPartForConverted : public ModelPart { + class DLL_PUBLIC ModelPartForConverted : public ModelPart { public: typedef T element_type; @@ -246,7 +249,7 @@ namespace Slicer { }; template - 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 - class ModelPartForComplex : public ModelPart { + class DLL_PUBLIC ModelPartForComplex : public ModelPart { public: class HookBase : public HookCommon { public: @@ -409,7 +412,7 @@ namespace Slicer { }; template - class ModelPartForClass : public ModelPartForComplex { + class DLL_PUBLIC ModelPartForClass : public ModelPartForComplex { public: typedef T element_type; @@ -454,7 +457,7 @@ namespace Slicer { }; template - class ModelPartForStruct : public ModelPartForComplex { + class DLL_PUBLIC ModelPartForStruct : public ModelPartForComplex { public: typedef T element_type; @@ -480,7 +483,7 @@ namespace Slicer { }; template - 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 - class ModelPartForEnum : public ModelPart { + class DLL_PUBLIC ModelPartForEnum : public ModelPart { public: typedef T element_type; typedef boost::bimap Enumerations; @@ -581,7 +584,7 @@ namespace Slicer { }; template - class ModelPartForSequence : public ModelPart { + class DLL_PUBLIC ModelPartForSequence : public ModelPart { public: typedef T element_type; @@ -625,7 +628,7 @@ namespace Slicer { }; template - class ModelPartForDictionaryElement : public ModelPartForComplex > { + class DLL_PUBLIC ModelPartForDictionaryElement : public ModelPartForComplex > { public: ModelPartForDictionaryElement(typename T::key_type * k, typename T::mapped_type * v) : key(k), @@ -645,7 +648,7 @@ namespace Slicer { }; template - class ModelPartForDictionaryElementInserter : public ModelPartForDictionaryElement { + class DLL_PUBLIC ModelPartForDictionaryElementInserter : public ModelPartForDictionaryElement { public: ModelPartForDictionaryElementInserter(T & d) : ModelPartForDictionaryElement(&key, &value), @@ -663,7 +666,7 @@ namespace Slicer { }; template - 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 \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 >::metadata ", + fprintf(cpp, "template<>\nDLL_PUBLIC Metadata ModelPartForComplex >::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 #include #include +#ifndef DLL_PUBLIC +#define DLL_PUBLIC __attribute__ ((visibility ("default"))) +#endif namespace Slicer { typedef boost::shared_ptr 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 Conversions; typedef std::vector 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 : : ../slicer//slicer po + -fvisibility=hidden + release:-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 : IceUtil libxmlpp ../slicer//slicer + -fvisibility=hidden + release:-flto : : 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 #include +#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; -- cgit v1.2.3