Skip to content

Commit 3b471f0

Browse files
committed
Export C++ symbols part 2
Signed-off-by: Darby Johnston <[email protected]>
1 parent 207d69f commit 3b471f0

File tree

3 files changed

+75
-12
lines changed

3 files changed

+75
-12
lines changed

src/opentimelineio/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ set(OPENTIMELINEIO_HEADER_FILES
1212
algo/editAlgorithm.h
1313
effect.h
1414
errorStatus.h
15+
export.h
1516
externalReference.h
1617
freezeFrame.h
1718
gap.h
@@ -107,6 +108,15 @@ if(BUILD_SHARED_LIBS)
107108
set_target_properties(opentimelineio PROPERTIES
108109
SOVERSION ${OTIO_SOVERSION}
109110
VERSION ${OTIO_VERSION})
111+
target_compile_definitions(
112+
opentimelineio
113+
PUBLIC
114+
OTIO_EXPORTS)
115+
else()
116+
target_compile_definitions(
117+
opentimelineio
118+
PUBLIC
119+
OTIO_STATIC)
110120
endif()
111121

112122
if(APPLE)

src/opentimelineio/anyDictionary.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#pragma once
55

6+
#include "opentimelineio/export.h"
67
#include "opentimelineio/version.h"
78

89
#include <any>
@@ -24,13 +25,13 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION {
2425
/// This allows us to hand out iterators that can be aware of mutation and moves
2526
/// and take steps to safe-guard themselves from causing a crash. (Yes, I'm
2627
/// talking to you, Python...)
27-
class AnyDictionary : private std::map<std::string, std::any>
28+
class OTIO_API AnyDictionary : private std::map<std::string, std::any>
2829
{
2930
public:
3031
using map::map;
3132

3233
/// @brief Create an empty dictionary.
33-
AnyDictionary()
34+
OTIO_API AnyDictionary()
3435
: map{}
3536
, _mutation_stamp{}
3637
{}
@@ -39,13 +40,13 @@ class AnyDictionary : private std::map<std::string, std::any>
3940
///
4041
/// To be safe, avoid brace-initialization so as to not trigger
4142
/// list initialization behavior in older compilers:
42-
AnyDictionary(const AnyDictionary& other)
43+
OTIO_API AnyDictionary(const AnyDictionary& other)
4344
: map(other)
4445
, _mutation_stamp{}
4546
{}
4647

4748
/// @brief Destructor.
48-
~AnyDictionary()
49+
OTIO_API ~AnyDictionary()
4950
{
5051
if (_mutation_stamp)
5152
{
@@ -55,15 +56,15 @@ class AnyDictionary : private std::map<std::string, std::any>
5556
}
5657

5758
/// @brief Copy operator.
58-
AnyDictionary& operator=(const AnyDictionary& other)
59+
OTIO_API AnyDictionary& operator=(const AnyDictionary& other)
5960
{
6061
mutate();
6162
map::operator=(other);
6263
return *this;
6364
}
6465

6566
/// @brief Move operator.
66-
AnyDictionary& operator=(AnyDictionary&& other)
67+
OTIO_API AnyDictionary& operator=(AnyDictionary&& other)
6768
{
6869
mutate();
6970
other.mutate();
@@ -72,7 +73,7 @@ class AnyDictionary : private std::map<std::string, std::any>
7273
}
7374

7475
/// @brief Copy operator.
75-
AnyDictionary& operator=(std::initializer_list<value_type> ilist)
76+
OTIO_API AnyDictionary& operator=(std::initializer_list<value_type> ilist)
7677
{
7778
mutate();
7879
map::operator=(ilist);
@@ -94,7 +95,7 @@ class AnyDictionary : private std::map<std::string, std::any>
9495
using map::rend;
9596

9697
/// @brief Clear the dictionary.
97-
void clear() noexcept
98+
OTIO_API void clear() noexcept
9899
{
99100
mutate();
100101
map::clear();
@@ -104,28 +105,28 @@ class AnyDictionary : private std::map<std::string, std::any>
104105
using map::insert;
105106

106107
/// @brief Erase an item.
107-
iterator erase(const_iterator pos)
108+
OTIO_API iterator erase(const_iterator pos)
108109
{
109110
mutate();
110111
return map::erase(pos);
111112
}
112113

113114
/// @brief Erase a range of items.
114-
iterator erase(const_iterator first, const_iterator last)
115+
OTIO_API iterator erase(const_iterator first, const_iterator last)
115116
{
116117
mutate();
117118
return map::erase(first, last);
118119
}
119120

120121
/// @brief Erase an item with the given key.
121-
size_type erase(const key_type& key)
122+
OTIO_API size_type erase(const key_type& key)
122123
{
123124
mutate();
124125
return map::erase(key);
125126
}
126127

127128
/// @brief Swap dictionaries.
128-
void swap(AnyDictionary& other)
129+
OTIO_API void swap(AnyDictionary& other)
129130
{
130131
mutate();
131132
other.mutate();

src/opentimelineio/export.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// Copyright Contributors to the OpenTimelineIO project
3+
4+
#pragma once
5+
6+
#if defined(_WINDOWS)
7+
# if defined(__GNUC__) && __GNUC__ >= 4 || defined(__clang__)
8+
# define ARCH_EXPORT __attribute__((dllexport))
9+
# define ARCH_IMPORT __attribute__((dllimport))
10+
# define ARCH_HIDDEN
11+
# define ARCH_EXPORT_TYPE
12+
# else
13+
# define ARCH_EXPORT __declspec(dllexport)
14+
# define ARCH_IMPORT __declspec(dllimport)
15+
# define ARCH_HIDDEN
16+
# define ARCH_EXPORT_TYPE
17+
# endif
18+
#elif defined(__GNUC__) && __GNUC__ >= 4 || defined(__clang__)
19+
# define ARCH_EXPORT __attribute__((visibility("default")))
20+
# define ARCH_IMPORT
21+
# define ARCH_HIDDEN __attribute__((visibility("hidden")))
22+
# if defined(__clang__)
23+
# define ARCH_EXPORT_TYPE __attribute__((type_visibility("default")))
24+
# else
25+
# define ARCH_EXPORT_TYPE __attribute__((visibility("default")))
26+
# endif
27+
#else
28+
# define ARCH_EXPORT
29+
# define ARCH_IMPORT
30+
# define ARCH_HIDDEN
31+
# define ARCH_EXPORT_TYPE
32+
#endif
33+
#define ARCH_EXPORT_TEMPLATE(type, ...)
34+
#define ARCH_IMPORT_TEMPLATE(type, ...) extern template type ARCH_IMPORT __VA_ARGS__
35+
36+
#if defined(OTIO_STATIC)
37+
# define OTIO_API
38+
# define OTIO_API_TEMPLATE_CLASS(...)
39+
# define OTIO_API_TEMPLATE_STRUCT(...)
40+
# define OTIO_LOCAL
41+
#else
42+
# if defined(OTIO_EXPORTS)
43+
# define OTIO_API ARCH_EXPORT
44+
# define OTIO_API_TEMPLATE_CLASS(...) ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__)
45+
# define OTIO_API_TEMPLATE_STRUCT(...) ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__)
46+
# else
47+
# define OTIO_API ARCH_IMPORT
48+
# define OTIO_API_TEMPLATE_CLASS(...) ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__)
49+
# define OTIO_API_TEMPLATE_STRUCT(...) ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__)
50+
# endif
51+
# define OTIO_LOCAL ARCH_HIDDEN
52+
#endif

0 commit comments

Comments
 (0)