Skip to content

Commit 963be93

Browse files
authored
Update to OpenTimelineIO 0.17.0 and C++ 17 (#59)
* Update to otio v0.17.0 * Update package to allow for cxx17 * Work on otio to std any changes * Fix compilation * Purge any and optionalite targets, shims and references, and code. --------- Signed-off-by: vade <[email protected]>
1 parent 10973f2 commit 963be93

File tree

11 files changed

+58
-97
lines changed

11 files changed

+58
-97
lines changed

OpenTimelineIO

Package.swift

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.3
1+
// swift-tools-version:5.5
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33
//
44
// SPDX-License-Identifier: Apache-2.0
@@ -11,41 +11,19 @@ let package = Package(
1111
platforms: [.macOS(.v10_13),
1212
.iOS(.v11)],
1313
products: [
14-
.library(name: "any", targets: ["any"]),
1514
.library(name: "OpenTime_CXX", targets: ["OpenTime_CXX"]),
1615
.library(name: "OpenTimelineIO_CXX", targets: ["OpenTimelineIO_CXX"]),
1716
.library(name: "OpenTimelineIO", targets: ["OpenTimelineIO"])
1817
],
1918

2019
dependencies: [],
2120
targets: [
22-
.target(name: "any",
23-
path: ".",
24-
exclude: [
25-
"CONTRIBUTORS.md", "NOTICE.txt", "CONTRIBUTING.md", "LICENSE.txt", "CODE_OF_CONDUCT.md",
26-
"OTIO_CLA_Corporate.pdf", "OTIO_CLA_Individual.pdf",
27-
"README.md", "Sources/shims/optionallite-shim.cpp", "Sources/shims/otio_header_root-shim.cpp",
28-
"Examples", "OpenTimelineIO", "Tests", "Sources/objc", "Sources/swift"],
29-
sources: ["Sources/shims/any-shim.cpp"],
30-
publicHeadersPath:"OpenTimelineIO/src/deps"),
31-
32-
.target(name: "optionallite",
33-
path: ".",
34-
exclude: [
35-
"CONTRIBUTORS.md", "NOTICE.txt", "CONTRIBUTING.md", "LICENSE.txt", "CODE_OF_CONDUCT.md",
36-
"OTIO_CLA_Corporate.pdf", "OTIO_CLA_Individual.pdf",
37-
"README.md", "Sources/shims/any-shim.cpp", "Sources/shims/otio_header_root-shim.cpp",
38-
"Examples", "OpenTimelineIO", "Tests", "Sources/objc", "Sources/swift"],
39-
sources: ["Sources/shims/optionallite-shim.cpp"],
40-
publicHeadersPath:"OpenTimelineIO/src/deps/optional-lite/include"),
41-
4221
.target(name: "otio_header_root",
4322
path: ".",
4423
exclude: [
4524
"CONTRIBUTORS.md", "NOTICE.txt", "CONTRIBUTING.md", "LICENSE.txt", "CODE_OF_CONDUCT.md",
4625
"OTIO_CLA_Corporate.pdf", "OTIO_CLA_Individual.pdf",
47-
"README.md", "Sources/shims/any-shim.cpp", "Sources/shims/optionallite-shim.cpp",
48-
"Examples", "OpenTimelineIO", "Tests", "Sources/objc", "Sources/swift"],
26+
"README.md", "Examples", "OpenTimelineIO", "Tests", "Sources/objc", "Sources/swift"],
4927
sources: ["Sources/shims/otio_header_root-shim.cpp"],
5028
publicHeadersPath:"OpenTimelineIO/src"),
5129

@@ -58,13 +36,14 @@ let package = Package(
5836
cxxSettings: [ .headerSearchPath(".")]),
5937

6038
.target(name: "OpenTimelineIO_CXX",
61-
dependencies: ["OpenTime_CXX", "any", "optionallite"],
39+
dependencies: ["OpenTime_CXX"],
6240
path: "OpenTimelineIO/src/opentimelineio",
6341
exclude: ["CMakeLists.txt", "CORE_VERSION_MAP.last.cpp", "OpenTimelineIOConfig.cmake.in"],
6442
sources: ["."],
6543
publicHeadersPath: ".",
6644
cxxSettings: [
6745
.headerSearchPath("."),
46+
.headerSearchPath("../deps/any/"),
6847
.headerSearchPath("../deps/Imath/src/Imath"),
6948
.headerSearchPath("../../../Sources/cpp"),
7049
.headerSearchPath("../deps/rapidjson/include")]),
@@ -93,5 +72,5 @@ let package = Package(
9372
sources: ["OpenTimelineIOTests"],
9473
resources: [ .copy("data") ])
9574
],
96-
cxxLanguageStandard: CXXLanguageStandard.cxx14
75+
cxxLanguageStandard: CXXLanguageStandard.cxx17
9776
)

Sources/objc/CxxAny.mm

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,101 +11,101 @@
1111
#include <opentimelineio/stringUtils.h>
1212
#include <opentimelineio/serializableObject.h>
1313

14-
otio::any cxx_any_to_otio_any(CxxAny const& cxxAny) {
14+
std::any cxx_any_to_otio_any(CxxAny const& cxxAny) {
1515
switch(cxxAny.type_code) {
1616
case CxxAny::NONE:
17-
return otio::any();
17+
return std::any();
1818
case CxxAny::BOOL_:
19-
return otio::any(cxxAny.value.b);
19+
return std::any(cxxAny.value.b);
2020
case CxxAny::INT:
2121
if (cxxAny.value.i < -INT_MIN || cxxAny.value.i > INT_MAX) {
22-
return otio::any(cxxAny.value.i);
22+
return std::any(cxxAny.value.i);
2323
}
2424
else {
25-
return otio::any(int(cxxAny.value.i));
25+
return std::any(int(cxxAny.value.i));
2626
}
2727
case CxxAny::DOUBLE:
28-
return otio::any(cxxAny.value.d);
28+
return std::any(cxxAny.value.d);
2929
case CxxAny::STRING:
30-
return otio::any(std::string(cxxAny.value.s));
30+
return std::any(std::string(cxxAny.value.s));
3131
case CxxAny::SERIALIZABLE_OBJECT:
3232
{ auto so = reinterpret_cast<otio::SerializableObject*>(cxxAny.value.ptr);
33-
return otio::any(otio::SerializableObject::Retainer<>(so));
33+
return std::any(otio::SerializableObject::Retainer<>(so));
3434
}
3535
case CxxAny::RATIONAL_TIME:
36-
return otio::any(*((otio::RationalTime const*)(&cxxAny.value.rt)));
36+
return std::any(*((otio::RationalTime const*)(&cxxAny.value.rt)));
3737
case CxxAny::TIME_RANGE:
38-
return otio::any(*((otio::TimeRange const*)(&cxxAny.value.tr)));
38+
return std::any(*((otio::TimeRange const*)(&cxxAny.value.tr)));
3939
case CxxAny::TIME_TRANSFORM:
40-
return otio::any(*((otio::TimeTransform const*)(&cxxAny.value.tt)));
40+
return std::any(*((otio::TimeTransform const*)(&cxxAny.value.tt)));
4141
case CxxAny::VECTOR:
42-
return otio::any(*reinterpret_cast<otio::AnyVector*>(cxxAny.value.ptr));
42+
return std::any(*reinterpret_cast<otio::AnyVector*>(cxxAny.value.ptr));
4343
case CxxAny::DICTIONARY:
44-
return otio::any(*reinterpret_cast<otio::AnyDictionary*>(cxxAny.value.ptr));
44+
return std::any(*reinterpret_cast<otio::AnyDictionary*>(cxxAny.value.ptr));
4545
default:
4646
return otio::SerializableObject::UnknownType { opentime::string_printf("%s <Swift Type>", cxxAny.value.s) };
4747
}
4848
}
4949

5050
namespace {
5151
struct _ToCxxAny {
52-
std::map<std::type_index, std::function<void (otio::any const&, CxxAny*)>> function_map;
52+
std::map<std::type_index, std::function<void (std::any const&, CxxAny*)>> function_map;
5353

5454
_ToCxxAny() {
5555
auto& m = function_map;
56-
m[std::type_index(typeid(void))] = [](otio::any const& a, CxxAny* cxxAny) {
56+
m[std::type_index(typeid(void))] = [](std::any const& a, CxxAny* cxxAny) {
5757
cxxAny->type_code = CxxAny::NONE;
5858

5959
};
60-
m[std::type_index(typeid(bool))] = [](otio::any const& a, CxxAny* cxxAny) {
60+
m[std::type_index(typeid(bool))] = [](std::any const& a, CxxAny* cxxAny) {
6161
cxxAny->type_code = CxxAny::BOOL_;
62-
cxxAny->value.b = otio::any_cast<bool>(a);
62+
cxxAny->value.b = std::any_cast<bool>(a);
6363
};
64-
m[std::type_index(typeid(int))] = [](otio::any const& a, CxxAny* cxxAny) {
64+
m[std::type_index(typeid(int))] = [](std::any const& a, CxxAny* cxxAny) {
6565
cxxAny->type_code = CxxAny::INT;
66-
cxxAny->value.i = otio::any_cast<int>(a);
66+
cxxAny->value.i = std::any_cast<int>(a);
6767
};
68-
m[std::type_index(typeid(int64_t))] = [](otio::any const& a, CxxAny* cxxAny) {
68+
m[std::type_index(typeid(int64_t))] = [](std::any const& a, CxxAny* cxxAny) {
6969
cxxAny->type_code = CxxAny::INT;
70-
cxxAny->value.i = otio::any_cast<int64_t>(a);
70+
cxxAny->value.i = std::any_cast<int64_t>(a);
7171
};
72-
m[std::type_index(typeid(double))] = [](otio::any const& a, CxxAny* cxxAny) {
72+
m[std::type_index(typeid(double))] = [](std::any const& a, CxxAny* cxxAny) {
7373
cxxAny->type_code = CxxAny::DOUBLE;
74-
cxxAny->value.d = otio::any_cast<double>(a);
74+
cxxAny->value.d = std::any_cast<double>(a);
7575
};
76-
m[std::type_index(typeid(std::string))] = [](otio::any const& a, CxxAny* cxxAny) {
76+
m[std::type_index(typeid(std::string))] = [](std::any const& a, CxxAny* cxxAny) {
7777
cxxAny->type_code = CxxAny::STRING;
78-
cxxAny->value.s = otio::any_cast<std::string const&>(a).c_str();
78+
cxxAny->value.s = std::any_cast<std::string const&>(a).c_str();
7979
};
80-
m[std::type_index(typeid(otio::RationalTime))] = [](otio::any const& a, CxxAny* cxxAny) {
80+
m[std::type_index(typeid(otio::RationalTime))] = [](std::any const& a, CxxAny* cxxAny) {
8181
cxxAny->type_code = CxxAny::RATIONAL_TIME;
82-
cxxAny->value.rt = *((CxxRationalTime*)&otio::any_cast<otio::RationalTime const&>(a));
82+
cxxAny->value.rt = *((CxxRationalTime*)&std::any_cast<otio::RationalTime const&>(a));
8383
};
84-
m[std::type_index(typeid(otio::TimeRange))] = [](otio::any const& a, CxxAny* cxxAny) {
84+
m[std::type_index(typeid(otio::TimeRange))] = [](std::any const& a, CxxAny* cxxAny) {
8585
cxxAny->type_code = CxxAny::TIME_RANGE;
86-
cxxAny->value.tr = *((CxxTimeRange*)&otio::any_cast<otio::TimeRange const&>(a));
86+
cxxAny->value.tr = *((CxxTimeRange*)&std::any_cast<otio::TimeRange const&>(a));
8787
};
88-
m[std::type_index(typeid(otio::TimeTransform))] = [](otio::any const& a, CxxAny* cxxAny) {
88+
m[std::type_index(typeid(otio::TimeTransform))] = [](std::any const& a, CxxAny* cxxAny) {
8989
cxxAny->type_code = CxxAny::TIME_TRANSFORM;
90-
cxxAny->value.tt = *((CxxTimeTransform*)&otio::any_cast<otio::TimeTransform const&>(a));
90+
cxxAny->value.tt = *((CxxTimeTransform*)&std::any_cast<otio::TimeTransform const&>(a));
9191
};
92-
m[std::type_index(typeid(otio::SerializableObject::Retainer<>))] = [](otio::any const& a, CxxAny* cxxAny) {
92+
m[std::type_index(typeid(otio::SerializableObject::Retainer<>))] = [](std::any const& a, CxxAny* cxxAny) {
9393
cxxAny->type_code = CxxAny::SERIALIZABLE_OBJECT;
94-
cxxAny->value.ptr = otio::any_cast<otio::SerializableObject::Retainer<> const&>(a).value;
94+
cxxAny->value.ptr = std::any_cast<otio::SerializableObject::Retainer<> const&>(a).value;
9595
};
96-
m[std::type_index(typeid(otio::AnyVector))] = [](otio::any const& a, CxxAny* cxxAny) {
96+
m[std::type_index(typeid(otio::AnyVector))] = [](std::any const& a, CxxAny* cxxAny) {
9797
cxxAny->type_code = CxxAny::VECTOR;
98-
cxxAny->value.ptr = (void*) &otio::any_cast<otio::AnyVector const&>(a);
98+
cxxAny->value.ptr = (void*) &std::any_cast<otio::AnyVector const&>(a);
9999
};
100-
m[std::type_index(typeid(otio::AnyDictionary))] = [](otio::any const& a, CxxAny* cxxAny) {
100+
m[std::type_index(typeid(otio::AnyDictionary))] = [](std::any const& a, CxxAny* cxxAny) {
101101
cxxAny->type_code = CxxAny::DICTIONARY;
102-
cxxAny->value.ptr = (void*) &otio::any_cast<otio::AnyDictionary const&>(a);
102+
cxxAny->value.ptr = (void*) &std::any_cast<otio::AnyDictionary const&>(a);
103103
};
104104
}
105105
};
106106
}
107107

108-
void otio_any_to_cxx_any(otio::any const& a, CxxAny* cxxAny) {
108+
void otio_any_to_cxx_any(std::any const& a, CxxAny* cxxAny) {
109109
static auto toCxxAny = _ToCxxAny();
110110
auto e = toCxxAny.function_map.find(std::type_index(a.type()));
111111

Sources/objc/CxxAnyDictionaryIterator.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static bool lookup(CxxAnyDictionaryIterator* dictionaryIterator, T* result) {
1414
if (auto dict = ms->any_dictionary) {
1515
if (dictionaryIterator.iterator != dict->end()) {
1616
if (dictionaryIterator.iterator->second.type() == typeid(T)) {
17-
*result = otio::any_cast<T>(dictionaryIterator.iterator->second);
17+
*result = std::any_cast<T>(dictionaryIterator.iterator->second);
1818
return true;
1919
}
2020
}
@@ -90,7 +90,7 @@ - (void) store:(CxxAny) cxxAny {
9090
if (ms->stamp == self.startingStamp) {
9191
if (auto dict = ms->any_dictionary) {
9292
if (self.iterator != dict->end()) {
93-
otio::any a = cxx_any_to_otio_any(cxxAny);
93+
std::any a = cxx_any_to_otio_any(cxxAny);
9494
std::swap(self.iterator->second, a);
9595
}
9696
}

Sources/objc/CxxAnyDictionaryMutationStamp.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static bool lookup(otio::AnyDictionary::MutationStamp* mutationStamp, NSString*
1919
auto it = dict->find(std::string(key.UTF8String));
2020
if (it != dict->end()) {
2121
if (it->second.type() == typeid(T)) {
22-
*result = otio::any_cast<T>(it->second);
22+
*result = std::any_cast<T>(it->second);
2323
return true;
2424
}
2525
}
@@ -73,7 +73,7 @@ - (void) store:(NSString*) key
7373
auto skey = std::string(key.UTF8String);
7474
auto it = dict->find(skey);
7575
if (it != dict->end()) {
76-
otio::any a = cxx_any_to_otio_any(cxxAny);
76+
std::any a = cxx_any_to_otio_any(cxxAny);
7777
std::swap(it->second, a);
7878
}
7979
else {

Sources/objc/CxxAnyVectorMutationStamp.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static bool lookup(otio::AnyVector::MutationStamp* mutationStamp, int index, T*
1818
if (auto v = mutationStamp->any_vector) {
1919
if (index < v->size()) {
2020
if ((*v)[index].type() == typeid(T)) {
21-
*result = otio::any_cast<T>(v[index]);
21+
*result = std::any_cast<T>(v[index]);
2222
return true;
2323
}
2424
}
@@ -67,7 +67,7 @@ - (void) store:(int) index
6767
value:(CxxAny) cxxAny {
6868
if (auto v = self.mutationStamp->any_vector) {
6969
if (index >= 0 && index < v->size()) {
70-
otio::any a = cxx_any_to_otio_any(cxxAny);
70+
std::any a = cxx_any_to_otio_any(cxxAny);
7171
std::swap((*v)[index], a);
7272
}
7373
else {
@@ -94,7 +94,7 @@ - (void) shrinkOrGrow:(int) n
9494
if (auto v = self.mutationStamp->any_vector) {
9595
if (grow) {
9696
for (int i = 0; i < n; i++) {
97-
v->push_back(otio::any());
97+
v->push_back(std::any());
9898
}
9999
}
100100
else {

Sources/objc/include/CxxAny.h

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

88
#import "opentime.h"
99

10-
#if defined(__cplusplus)
11-
#import <opentimelineio/any.h>
12-
namespace otio = opentimelineio::OPENTIMELINEIO_VERSION;
13-
#endif
14-
15-
1610
typedef union CxxAnyValue {
1711
bool b;
1812
int64_t i;
@@ -45,6 +39,7 @@ typedef struct CxxAny {
4539
} CxxAny;
4640

4741
#if defined(__cplusplus)
48-
void otio_any_to_cxx_any(otio::any const&, CxxAny*);
49-
otio::any cxx_any_to_otio_any(CxxAny const&);
42+
#import <any>
43+
void otio_any_to_cxx_any(std::any const&, CxxAny*);
44+
std::any cxx_any_to_otio_any(CxxAny const&);
5045
#endif

Sources/objc/include/CxxAnyDictionaryIterator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Copyright Contributors to the OpenTimelineIO project
77

88
#import <Foundation/Foundation.h>
9+
#import "CxxAny.h"
910
#import "opentime.h"
1011
#import "CxxAnyDictionaryMutationStamp.h"
1112

Sources/objc/opentimelineio.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ void item_set_source_range(CxxRetainer* self , CxxTimeRange tr) {
357357

358358
void item_set_source_range_to_null(CxxRetainer* self) {
359359
auto item = SO_cast<otio::Item>(self);
360-
item->set_source_range(otio::optional<otio::TimeRange>());
360+
item->set_source_range(std::optional<otio::TimeRange>());
361361
}
362362

363363
CxxTimeRange item_available_range(CxxRetainer* self, CxxErrorStruct* cxxErr) {
@@ -628,7 +628,7 @@ void media_reference_set_available_range(CxxRetainer* self, CxxTimeRange tr) {
628628
}
629629

630630
void media_reference_clear_available_range(CxxRetainer* self) {
631-
SO_cast<otio::MediaReference>(self)->set_available_range(otio::nullopt);
631+
SO_cast<otio::MediaReference>(self)->set_available_range(std::nullopt);
632632
}
633633

634634
// MARK: - Timeline
@@ -655,7 +655,7 @@ void timeline_set_global_start_time(CxxRetainer* self, CxxRationalTime rt) {
655655
}
656656

657657
void timeline_clear_global_start_time(CxxRetainer* self) {
658-
SO_cast<otio::Timeline>(self)->set_global_start_time(otio::nullopt);
658+
SO_cast<otio::Timeline>(self)->set_global_start_time(std::nullopt);
659659
}
660660

661661
CxxRationalTime timeline_duration(CxxRetainer* self, CxxErrorStruct* cxxErr) {

Sources/shims/any-shim.cpp

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)