Skip to content

Commit a980888

Browse files
hugoplMarcelo Lira
authored and
Marcelo Lira
committed
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 <[email protected]>
1 parent 9deca0a commit a980888

10 files changed

+49
-27
lines changed

CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ find_package(Qt4 4.5.0 REQUIRED)
88
find_package(LibXml2 2.6.32 REQUIRED)
99
find_package(LibXslt 1.1.19 REQUIRED)
1010

11-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -DAPIEXTRACTOR_ENABLE_DUPLICATE_ENUM_VALUES")
11+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -DAPIEXTRACTOR_ENABLE_DUPLICATE_ENUM_VALUES -DAPIEXTRACTOR_BUILD -fvisibility=hidden")
1212

1313
set(apiextractor_MAJOR_VERSION 0)
1414
set(apiextractor_MINOR_VERSION 3)
@@ -92,6 +92,7 @@ add_custom_target(dist
9292
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
9393

9494
set(root_HEADERS
95+
apiextractormacros.h
9596
abstractmetalang.h
9697
apiextractor.h
9798
reporthandler.h

abstractmetabuilder.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#include <QtCore/QSet>
3333

34-
class AbstractMetaBuilder
34+
class APIEXTRACTOR_API AbstractMetaBuilder
3535
{
3636
public:
3737
enum RejectReason {

abstractmetalang.h

+8-10
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class AbstractMetaEnumValue;
4242
class AbstractMetaEnum;
4343
class QPropertySpec;
4444

45-
class Documentation
45+
class APIEXTRACTOR_API Documentation
4646
{
4747
public:
4848
enum Format {
@@ -80,7 +80,7 @@ class Documentation
8080
typedef QList<AbstractMetaField *> AbstractMetaFieldList;
8181
typedef QList<AbstractMetaArgument *> AbstractMetaArgumentList;
8282
typedef QList<AbstractMetaFunction *> AbstractMetaFunctionList;
83-
class AbstractMetaClassList : public QList<AbstractMetaClass *>
83+
class APIEXTRACTOR_API AbstractMetaClassList : public QList<AbstractMetaClass *>
8484
{
8585
public:
8686
AbstractMetaClass *findClass(const QString &name) const;
@@ -89,9 +89,7 @@ class AbstractMetaClassList : public QList<AbstractMetaClass *>
8989

9090
};
9191

92-
93-
94-
class AbstractMetaAttributes
92+
class APIEXTRACTOR_API AbstractMetaAttributes
9593
{
9694
public:
9795
AbstractMetaAttributes() : m_attributes(0) {};
@@ -305,7 +303,7 @@ class AbstractMetaAttributes
305303
};
306304

307305

308-
class AbstractMetaType
306+
class APIEXTRACTOR_API AbstractMetaType
309307
{
310308
public:
311309
enum TypeUsagePattern {
@@ -610,7 +608,7 @@ class AbstractMetaType
610608
uint m_reserved : 25; // unused
611609
};
612610

613-
class AbstractMetaVariable
611+
class APIEXTRACTOR_API AbstractMetaVariable
614612
{
615613
public:
616614
AbstractMetaVariable() : m_type(0) {}
@@ -651,7 +649,7 @@ class AbstractMetaVariable
651649

652650

653651

654-
class AbstractMetaArgument : public AbstractMetaVariable
652+
class APIEXTRACTOR_API AbstractMetaArgument : public AbstractMetaVariable
655653
{
656654
public:
657655
AbstractMetaArgument() : m_argumentIndex(0) {};
@@ -736,7 +734,7 @@ class AbstractMetaField : public AbstractMetaVariable, public AbstractMetaAttrib
736734
};
737735

738736

739-
class AbstractMetaFunction : public AbstractMetaAttributes
737+
class APIEXTRACTOR_API AbstractMetaFunction : public AbstractMetaAttributes
740738
{
741739
public:
742740
enum FunctionType {
@@ -1255,7 +1253,7 @@ class AbstractMetaEnum : public AbstractMetaAttributes
12551253

12561254
typedef QList<AbstractMetaEnum *> AbstractMetaEnumList;
12571255

1258-
class AbstractMetaClass : public AbstractMetaAttributes
1256+
class APIEXTRACTOR_API AbstractMetaClass : public AbstractMetaAttributes
12591257
{
12601258
public:
12611259
enum FunctionQueryOption {

apiextractor.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@
2626

2727
#include "reporthandler.h"
2828
#include "abstractmetalang.h"
29+
#include "apiextractormacros.h"
2930
#include <QStringList>
3031

3132
class AbstractMetaBuilder;
3233
class QIODevice;
3334

34-
class ApiExtractor
35+
class APIEXTRACTOR_API ApiExtractor
3536
{
3637
public:
3738
ApiExtractor();

apiextractormacros.h

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#ifndef APIEXTRACTORMACROS_H
2+
#define APIEXTRACTORMACROS_H
3+
4+
5+
// APIEXTRACTOR_API is used for the public API symbols.
6+
#if defined _WIN32 || defined __CYGWIN__
7+
#if APIEXTRACTOR_BUILD
8+
#define APIEXTRACTOR_API __declspec(dllimport)
9+
#else
10+
#define APIEXTRACTOR_API __declspec(dllexport)
11+
#endif
12+
#else
13+
#if __GNUC__ >= 4
14+
#define APIEXTRACTOR_API __attribute__ ((visibility("default")))
15+
#else
16+
#define APIEXTRACTOR_API
17+
#endif
18+
#endif
19+
20+
#endif

docparser.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@
2525

2626
#include <QString>
2727
#include <QDir>
28-
// #include <QtCore/QMap>
2928

3029
#include "abstractmetalang.h"
3130

3231
class QDomDocument;
3332
class QDomNode;
3433
class QXmlQuery;
3534

36-
class DocParser
35+
class APIEXTRACTOR_API DocParser
3736
{
3837
public:
3938
DocParser();

fileout.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
#include <QtCore/QObject>
2828
#include <QtCore/QFile>
2929
#include <QtCore/QTextStream>
30+
#include "apiextractormacros.h"
3031

31-
class FileOut : public QObject
32+
class APIEXTRACTOR_API FileOut : public QObject
3233
{
3334
private:
3435
QByteArray tmp;

qtdocparser.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include "docparser.h"
2828

29-
class QtDocParser : public DocParser
29+
class APIEXTRACTOR_API QtDocParser : public DocParser
3030
{
3131
public:
3232
QtDocParser() {}

reporthandler.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <QtCore/QString>
2828
#include <QtCore/QSet>
2929
#include <cstring>
30+
#include "apiextractormacros.h"
3031

3132
class ProgressAnimation
3233
{
@@ -75,7 +76,7 @@ class ProgressAnimation
7576
}
7677
};
7778

78-
class ReportHandler
79+
class APIEXTRACTOR_API ReportHandler
7980
{
8081
public:
8182
enum DebugLevel { NoDebug, SparseDebug, MediumDebug, FullDebug };

typesystem.h

+10-9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <QtCore/QStringList>
3030
#include <QtCore/QMap>
3131
#include <QtCore/QDebug>
32+
#include "apiextractormacros.h"
3233

3334
class Indentor;
3435

@@ -46,7 +47,7 @@ extern QString stringsJavaLang;
4647
extern QString strings_jchar;
4748
extern QString strings_jobject;
4849

49-
struct Include
50+
struct APIEXTRACTOR_API Include
5051
{
5152
enum IncludeType {
5253
IncludePath,
@@ -144,7 +145,7 @@ struct ArgumentOwner
144145
int index;
145146
};
146147

147-
class CodeSnipFragment
148+
class APIEXTRACTOR_API CodeSnipFragment
148149
{
149150
private:
150151
const QString m_code;
@@ -161,7 +162,7 @@ class CodeSnipFragment
161162
QString code() const;
162163
};
163164

164-
class CodeSnipAbstract
165+
class APIEXTRACTOR_API CodeSnipAbstract
165166
{
166167
public:
167168
QString code() const;
@@ -231,7 +232,7 @@ class TemplateInstance
231232
};
232233

233234

234-
class CodeSnip : public CodeSnipAbstract
235+
class APIEXTRACTOR_API CodeSnip : public CodeSnipAbstract
235236
{
236237
public:
237238
enum Position {
@@ -449,7 +450,7 @@ typedef QList<FieldModification> FieldModificationList;
449450
* This info will be used later to create a fake AbstractMetaFunction which
450451
* will be inserted into the right AbstractMetaClass.
451452
*/
452-
struct AddedFunction
453+
struct APIEXTRACTOR_API AddedFunction
453454
{
454455
/// Function access types.
455456
enum Access {
@@ -582,7 +583,7 @@ class DocModification
582583

583584
typedef QList<DocModification> DocModificationList;
584585

585-
class TypeEntry
586+
class APIEXTRACTOR_API TypeEntry
586587
{
587588
public:
588589
enum Type {
@@ -1010,7 +1011,7 @@ class ArrayTypeEntry : public TypeEntry
10101011
};
10111012

10121013

1013-
class PrimitiveTypeEntry : public TypeEntry
1014+
class APIEXTRACTOR_API PrimitiveTypeEntry : public TypeEntry
10141015
{
10151016
public:
10161017
PrimitiveTypeEntry(const QString &name)
@@ -1316,7 +1317,7 @@ class FlagsTypeEntry : public TypeEntry
13161317
};
13171318

13181319

1319-
class ComplexTypeEntry : public TypeEntry
1320+
class APIEXTRACTOR_API ComplexTypeEntry : public TypeEntry
13201321
{
13211322
public:
13221323
enum TypeFlag {
@@ -1842,7 +1843,7 @@ struct TypeRejection
18421843
QString enum_name;
18431844
};
18441845

1845-
class TypeDatabase
1846+
class APIEXTRACTOR_API TypeDatabase
18461847
{
18471848
TypeDatabase();
18481849
TypeDatabase(const TypeDatabase&);

0 commit comments

Comments
 (0)