|
11 | 11 | #include <opentimelineio/stringUtils.h> |
12 | 12 | #include <opentimelineio/serializableObject.h> |
13 | 13 |
|
14 | | -otio::any cxx_any_to_otio_any(CxxAny const& cxxAny) { |
| 14 | +std::any cxx_any_to_otio_any(CxxAny const& cxxAny) { |
15 | 15 | switch(cxxAny.type_code) { |
16 | 16 | case CxxAny::NONE: |
17 | | - return otio::any(); |
| 17 | + return std::any(); |
18 | 18 | case CxxAny::BOOL_: |
19 | | - return otio::any(cxxAny.value.b); |
| 19 | + return std::any(cxxAny.value.b); |
20 | 20 | case CxxAny::INT: |
21 | 21 | 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); |
23 | 23 | } |
24 | 24 | else { |
25 | | - return otio::any(int(cxxAny.value.i)); |
| 25 | + return std::any(int(cxxAny.value.i)); |
26 | 26 | } |
27 | 27 | case CxxAny::DOUBLE: |
28 | | - return otio::any(cxxAny.value.d); |
| 28 | + return std::any(cxxAny.value.d); |
29 | 29 | case CxxAny::STRING: |
30 | | - return otio::any(std::string(cxxAny.value.s)); |
| 30 | + return std::any(std::string(cxxAny.value.s)); |
31 | 31 | case CxxAny::SERIALIZABLE_OBJECT: |
32 | 32 | { 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)); |
34 | 34 | } |
35 | 35 | case CxxAny::RATIONAL_TIME: |
36 | | - return otio::any(*((otio::RationalTime const*)(&cxxAny.value.rt))); |
| 36 | + return std::any(*((otio::RationalTime const*)(&cxxAny.value.rt))); |
37 | 37 | case CxxAny::TIME_RANGE: |
38 | | - return otio::any(*((otio::TimeRange const*)(&cxxAny.value.tr))); |
| 38 | + return std::any(*((otio::TimeRange const*)(&cxxAny.value.tr))); |
39 | 39 | case CxxAny::TIME_TRANSFORM: |
40 | | - return otio::any(*((otio::TimeTransform const*)(&cxxAny.value.tt))); |
| 40 | + return std::any(*((otio::TimeTransform const*)(&cxxAny.value.tt))); |
41 | 41 | 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)); |
43 | 43 | 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)); |
45 | 45 | default: |
46 | 46 | return otio::SerializableObject::UnknownType { opentime::string_printf("%s <Swift Type>", cxxAny.value.s) }; |
47 | 47 | } |
48 | 48 | } |
49 | 49 |
|
50 | 50 | namespace { |
51 | 51 | 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; |
53 | 53 |
|
54 | 54 | _ToCxxAny() { |
55 | 55 | 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) { |
57 | 57 | cxxAny->type_code = CxxAny::NONE; |
58 | 58 |
|
59 | 59 | }; |
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) { |
61 | 61 | cxxAny->type_code = CxxAny::BOOL_; |
62 | | - cxxAny->value.b = otio::any_cast<bool>(a); |
| 62 | + cxxAny->value.b = std::any_cast<bool>(a); |
63 | 63 | }; |
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) { |
65 | 65 | cxxAny->type_code = CxxAny::INT; |
66 | | - cxxAny->value.i = otio::any_cast<int>(a); |
| 66 | + cxxAny->value.i = std::any_cast<int>(a); |
67 | 67 | }; |
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) { |
69 | 69 | 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); |
71 | 71 | }; |
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) { |
73 | 73 | cxxAny->type_code = CxxAny::DOUBLE; |
74 | | - cxxAny->value.d = otio::any_cast<double>(a); |
| 74 | + cxxAny->value.d = std::any_cast<double>(a); |
75 | 75 | }; |
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) { |
77 | 77 | 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(); |
79 | 79 | }; |
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) { |
81 | 81 | 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)); |
83 | 83 | }; |
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) { |
85 | 85 | 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)); |
87 | 87 | }; |
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) { |
89 | 89 | 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)); |
91 | 91 | }; |
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) { |
93 | 93 | 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; |
95 | 95 | }; |
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) { |
97 | 97 | 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); |
99 | 99 | }; |
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) { |
101 | 101 | 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); |
103 | 103 | }; |
104 | 104 | } |
105 | 105 | }; |
106 | 106 | } |
107 | 107 |
|
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) { |
109 | 109 | static auto toCxxAny = _ToCxxAny(); |
110 | 110 | auto e = toCxxAny.function_map.find(std::type_index(a.type())); |
111 | 111 |
|
|
0 commit comments