From a98088877fc638ce9f068aaaa5fa4c7f883a1a87 Mon Sep 17 00:00:00 2001 From: Hugo Lima Date: Thu, 12 Nov 2009 17:38:09 -0200 Subject: APIExtractor is a huge amount of legacy code inherited from QtScriptGenerator, but QtScriptGenerator itself isn't a library, this explains why libapiextractor does not care about things that every library SHOULD care, symbol visibility and binary compatibility. This commit adds symbol visibility rules to libapiextractor as the first step to make libapiextractor aware of binary compatibility. This is also needed if we want to be able to compile and use libapiextractor under Windows. Note: Not all symbols were made public, just the symbols needed by shiboken, boostpython and doc generators, because IMHO libapiextractor needs some love and a API review. More symbols could be added later if needed. Reviewed by Renato Araujo --- CMakeLists.txt | 3 ++- abstractmetabuilder.h | 2 +- abstractmetalang.h | 18 ++++++++---------- apiextractor.h | 3 ++- apiextractormacros.h | 20 ++++++++++++++++++++ docparser.h | 3 +-- fileout.h | 3 ++- qtdocparser.h | 2 +- reporthandler.h | 3 ++- typesystem.h | 19 ++++++++++--------- 10 files changed, 49 insertions(+), 27 deletions(-) create mode 100644 apiextractormacros.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 08eee62e9..db08bf512 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ find_package(Qt4 4.5.0 REQUIRED) find_package(LibXml2 2.6.32 REQUIRED) find_package(LibXslt 1.1.19 REQUIRED) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -DAPIEXTRACTOR_ENABLE_DUPLICATE_ENUM_VALUES") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -DAPIEXTRACTOR_ENABLE_DUPLICATE_ENUM_VALUES -DAPIEXTRACTOR_BUILD -fvisibility=hidden") set(apiextractor_MAJOR_VERSION 0) set(apiextractor_MINOR_VERSION 3) @@ -92,6 +92,7 @@ add_custom_target(dist WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) set(root_HEADERS +apiextractormacros.h abstractmetalang.h apiextractor.h reporthandler.h diff --git a/abstractmetabuilder.h b/abstractmetabuilder.h index 18ee74365..ca4593e1e 100644 --- a/abstractmetabuilder.h +++ b/abstractmetabuilder.h @@ -31,7 +31,7 @@ #include -class AbstractMetaBuilder +class APIEXTRACTOR_API AbstractMetaBuilder { public: enum RejectReason { diff --git a/abstractmetalang.h b/abstractmetalang.h index 5ea94642d..cafe39bf9 100644 --- a/abstractmetalang.h +++ b/abstractmetalang.h @@ -42,7 +42,7 @@ class AbstractMetaEnumValue; class AbstractMetaEnum; class QPropertySpec; -class Documentation +class APIEXTRACTOR_API Documentation { public: enum Format { @@ -80,7 +80,7 @@ private: typedef QList AbstractMetaFieldList; typedef QList AbstractMetaArgumentList; typedef QList AbstractMetaFunctionList; -class AbstractMetaClassList : public QList +class APIEXTRACTOR_API AbstractMetaClassList : public QList { public: AbstractMetaClass *findClass(const QString &name) const; @@ -89,9 +89,7 @@ public: }; - - -class AbstractMetaAttributes +class APIEXTRACTOR_API AbstractMetaAttributes { public: AbstractMetaAttributes() : m_attributes(0) {}; @@ -305,7 +303,7 @@ private: }; -class AbstractMetaType +class APIEXTRACTOR_API AbstractMetaType { public: enum TypeUsagePattern { @@ -610,7 +608,7 @@ private: uint m_reserved : 25; // unused }; -class AbstractMetaVariable +class APIEXTRACTOR_API AbstractMetaVariable { public: AbstractMetaVariable() : m_type(0) {} @@ -651,7 +649,7 @@ private: -class AbstractMetaArgument : public AbstractMetaVariable +class APIEXTRACTOR_API AbstractMetaArgument : public AbstractMetaVariable { public: AbstractMetaArgument() : m_argumentIndex(0) {}; @@ -736,7 +734,7 @@ private: }; -class AbstractMetaFunction : public AbstractMetaAttributes +class APIEXTRACTOR_API AbstractMetaFunction : public AbstractMetaAttributes { public: enum FunctionType { @@ -1255,7 +1253,7 @@ private: typedef QList AbstractMetaEnumList; -class AbstractMetaClass : public AbstractMetaAttributes +class APIEXTRACTOR_API AbstractMetaClass : public AbstractMetaAttributes { public: enum FunctionQueryOption { diff --git a/apiextractor.h b/apiextractor.h index b745a91c0..1c729cf6f 100644 --- a/apiextractor.h +++ b/apiextractor.h @@ -26,12 +26,13 @@ #include "reporthandler.h" #include "abstractmetalang.h" +#include "apiextractormacros.h" #include class AbstractMetaBuilder; class QIODevice; -class ApiExtractor +class APIEXTRACTOR_API ApiExtractor { public: ApiExtractor(); diff --git a/apiextractormacros.h b/apiextractormacros.h new file mode 100644 index 000000000..b2cb4b0a6 --- /dev/null +++ b/apiextractormacros.h @@ -0,0 +1,20 @@ +#ifndef APIEXTRACTORMACROS_H +#define APIEXTRACTORMACROS_H + + +// APIEXTRACTOR_API is used for the public API symbols. +#if defined _WIN32 || defined __CYGWIN__ + #if APIEXTRACTOR_BUILD + #define APIEXTRACTOR_API __declspec(dllimport) + #else + #define APIEXTRACTOR_API __declspec(dllexport) + #endif +#else + #if __GNUC__ >= 4 + #define APIEXTRACTOR_API __attribute__ ((visibility("default"))) + #else + #define APIEXTRACTOR_API + #endif +#endif + +#endif diff --git a/docparser.h b/docparser.h index ecc3204e9..ab5dc9fa3 100644 --- a/docparser.h +++ b/docparser.h @@ -25,7 +25,6 @@ #include #include -// #include #include "abstractmetalang.h" @@ -33,7 +32,7 @@ class QDomDocument; class QDomNode; class QXmlQuery; -class DocParser +class APIEXTRACTOR_API DocParser { public: DocParser(); diff --git a/fileout.h b/fileout.h index d5c9e29c5..1429b3365 100644 --- a/fileout.h +++ b/fileout.h @@ -27,8 +27,9 @@ #include #include #include +#include "apiextractormacros.h" -class FileOut : public QObject +class APIEXTRACTOR_API FileOut : public QObject { private: QByteArray tmp; diff --git a/qtdocparser.h b/qtdocparser.h index e4b7089d7..e2115f991 100644 --- a/qtdocparser.h +++ b/qtdocparser.h @@ -26,7 +26,7 @@ #include "docparser.h" -class QtDocParser : public DocParser +class APIEXTRACTOR_API QtDocParser : public DocParser { public: QtDocParser() {} diff --git a/reporthandler.h b/reporthandler.h index e13d3562f..1f70046ce 100644 --- a/reporthandler.h +++ b/reporthandler.h @@ -27,6 +27,7 @@ #include #include #include +#include "apiextractormacros.h" class ProgressAnimation { @@ -75,7 +76,7 @@ private: } }; -class ReportHandler +class APIEXTRACTOR_API ReportHandler { public: enum DebugLevel { NoDebug, SparseDebug, MediumDebug, FullDebug }; diff --git a/typesystem.h b/typesystem.h index 589196208..dc8344f6e 100644 --- a/typesystem.h +++ b/typesystem.h @@ -29,6 +29,7 @@ #include #include #include +#include "apiextractormacros.h" class Indentor; @@ -46,7 +47,7 @@ extern QString stringsJavaLang; extern QString strings_jchar; extern QString strings_jobject; -struct Include +struct APIEXTRACTOR_API Include { enum IncludeType { IncludePath, @@ -144,7 +145,7 @@ struct ArgumentOwner int index; }; -class CodeSnipFragment +class APIEXTRACTOR_API CodeSnipFragment { private: const QString m_code; @@ -161,7 +162,7 @@ public: QString code() const; }; -class CodeSnipAbstract +class APIEXTRACTOR_API CodeSnipAbstract { public: QString code() const; @@ -231,7 +232,7 @@ private: }; -class CodeSnip : public CodeSnipAbstract +class APIEXTRACTOR_API CodeSnip : public CodeSnipAbstract { public: enum Position { @@ -449,7 +450,7 @@ typedef QList FieldModificationList; * This info will be used later to create a fake AbstractMetaFunction which * will be inserted into the right AbstractMetaClass. */ -struct AddedFunction +struct APIEXTRACTOR_API AddedFunction { /// Function access types. enum Access { @@ -582,7 +583,7 @@ private: typedef QList DocModificationList; -class TypeEntry +class APIEXTRACTOR_API TypeEntry { public: enum Type { @@ -1010,7 +1011,7 @@ private: }; -class PrimitiveTypeEntry : public TypeEntry +class APIEXTRACTOR_API PrimitiveTypeEntry : public TypeEntry { public: PrimitiveTypeEntry(const QString &name) @@ -1316,7 +1317,7 @@ private: }; -class ComplexTypeEntry : public TypeEntry +class APIEXTRACTOR_API ComplexTypeEntry : public TypeEntry { public: enum TypeFlag { @@ -1842,7 +1843,7 @@ struct TypeRejection QString enum_name; }; -class TypeDatabase +class APIEXTRACTOR_API TypeDatabase { TypeDatabase(); TypeDatabase(const TypeDatabase&); -- cgit v1.2.3