Skip to content

Commit

Permalink
Cxx17 updates (#58)
Browse files Browse the repository at this point in the history
* switch to ASWF OTIO submodule
* update to std any and std optional
* get latest OTIO changes
* repair discrepancies between copentimelineio headers and code
* remove unused references to old OTIO any.h
* Add disclaimer for missing version map support in JSON serialization

Signed-off-by: Jon Morley <jmorley.signup@runbox.com>
  • Loading branch information
rogergodspeed authored Apr 15, 2024
1 parent dfd76a7 commit e8a695a
Show file tree
Hide file tree
Showing 26 changed files with 144 additions and 120 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.swp
*.pyc
build*
compile_commands.json
cmake-build*
dist*
*.egg-info
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "OpenTimelineIO"]
path = OpenTimelineIO
url = https://github.com/PixarAnimationStudios/OpenTimelineIO
[submodule "cmocka"]
path = cmocka
url = https://git.cryptomilk.org/projects/cmocka.git
[submodule "OpenTimelineIO"]
path = OpenTimelineIO
url = https://github.com/AcademySoftwareFoundation/OpenTimelineIO.git
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
#------------------------------------------------------------------------------
# Global language settings

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down
2 changes: 1 addition & 1 deletion OpenTimelineIO
Submodule OpenTimelineIO updated 437 files
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ some essential features and there are large changes planned. During this phase
we actively encourage you to provide feedback, requests, comments, and/or
contributions.

NOTE: One of these missing features is support for the downgrade versioning
map in the JSON serialization and deserialization. This can be addressed in
the future, but for now an empty map is passed to the underlying C++ calls.

Overview
--------

Expand Down
4 changes: 2 additions & 2 deletions include/copentimelineio/anyVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ AnyVectorIterator_not_equal(AnyVectorIterator *lhs, AnyVectorIterator *rhs);

OTIO_API void AnyVectorIterator_destroy(AnyVectorIterator *self);

OTIO_API AnyVectorMutationStamp *MutationStamp_create(AnyVector *v);
OTIO_API AnyVectorMutationStamp *AnyVectorMutationStamp_create(AnyVector *v);

OTIO_API void MutationStamp_destroy(AnyVectorMutationStamp *self);
OTIO_API void AnyVectorMutationStamp_destroy(AnyVectorMutationStamp *self);

OTIO_API AnyVectorMutationStamp *
AnyVector_get_or_create_mutation_stamp(AnyVector *self);
1 change: 0 additions & 1 deletion include/copentimelineio/timeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,5 @@ OTIO_API const char *Timeline_to_json_string(
Timeline *self, OTIOErrorStatus *error_status, int indent);
OTIO_API bool Timeline_is_equivalent_to(Timeline *self, OTIOSerializableObject *other);
OTIO_API Timeline *Timeline_clone(Timeline *self, OTIOErrorStatus *error_status);
OTIO_API bool Timeline_is_unknown_schema(Timeline *self);
OTIO_API const char *Timeline_schema_name(Timeline *self);
OTIO_API int Timeline_schema_version(Timeline *self);
4 changes: 2 additions & 2 deletions src/copentimelineio/any.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Copyright Contributors to the OpenTimelineIO project

#include "copentimelineio/any.h"
#include <opentimelineio/any.h>
#include <opentimelineio/version.h>
#include <any>

OTIO_API void Any_destroy(Any *self) {
delete reinterpret_cast<OTIO_NS::any *>(self);
delete reinterpret_cast<std::any *>(self);
}
9 changes: 5 additions & 4 deletions src/copentimelineio/anyDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
#include <opentimelineio/anyDictionary.h>
#include <opentimelineio/version.h>
#include <string.h>
#include <any>

typedef std::map<std::string, OTIO_NS::any>::iterator DictionaryIterator;
typedef std::map<std::string, std::any>::iterator DictionaryIterator;

OTIO_API AnyDictionary* AnyDictionary_create()
{
Expand Down Expand Up @@ -85,7 +86,7 @@ AnyDictionary_insert(AnyDictionary* self, const char* key, Any* anyObj)
{
DictionaryIterator it =
reinterpret_cast<OTIO_NS::AnyDictionary*>(self)
->insert({ key, *reinterpret_cast<OTIO_NS::any*>(anyObj) })
->insert({ key, *reinterpret_cast<std::any*>(anyObj) })
.first;
return reinterpret_cast<AnyDictionaryIterator*>(
new DictionaryIterator(it));
Expand Down Expand Up @@ -118,9 +119,9 @@ OTIO_API const char* AnyDictionaryIterator_key(AnyDictionaryIterator* iter)
}
OTIO_API Any* AnyDictionaryIterator_value(AnyDictionaryIterator* iter)
{
OTIO_NS::any value =
std::any value =
(*reinterpret_cast<DictionaryIterator*>(iter))->second;
return reinterpret_cast<Any*>(new OTIO_NS::any(value));
return reinterpret_cast<Any*>(new std::any(value));
}
OTIO_API bool AnyDictionaryIterator_equal(
AnyDictionaryIterator* lhs, AnyDictionaryIterator* rhs)
Expand Down
15 changes: 8 additions & 7 deletions src/copentimelineio/anyVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#include "copentimelineio/anyVector.h"
#include <opentimelineio/anyVector.h>
#include <opentimelineio/version.h>
#include <any>

typedef std::vector<OTIO_NS::any>::iterator VectorIterator;
typedef std::vector<std::any>::iterator VectorIterator;

OTIO_API AnyVector *AnyVector_create() {
return reinterpret_cast<AnyVector *>(new OTIO_NS::AnyVector());
Expand Down Expand Up @@ -59,14 +60,14 @@ OTIO_API void AnyVector_swap(AnyVector *self, AnyVector *other) {
}

OTIO_API Any *AnyVector_at(AnyVector *self, int pos) {
OTIO_NS::any value =
std::any value =
reinterpret_cast<OTIO_NS::AnyVector *>(self)->at(pos);
return reinterpret_cast<Any *>(new OTIO_NS::any(value));
return reinterpret_cast<Any *>(new std::any(value));
}

OTIO_API void AnyVector_push_back(AnyVector *self, Any *value) {
reinterpret_cast<OTIO_NS::AnyVector *>(self)->push_back(
*reinterpret_cast<OTIO_NS::any *>(value));
*reinterpret_cast<std::any *>(value));
}

OTIO_API void AnyVector_pop_back(AnyVector *self) {
Expand All @@ -77,7 +78,7 @@ OTIO_API AnyVectorIterator *
AnyVector_insert(AnyVector *self, AnyVectorIterator *pos, Any *val) {
VectorIterator it = reinterpret_cast<OTIO_NS::AnyVector *>(self)->insert(
*reinterpret_cast<VectorIterator *>(pos),
*reinterpret_cast<OTIO_NS::any *>(val));
*reinterpret_cast<std::any *>(val));
return reinterpret_cast<AnyVectorIterator *>(new VectorIterator(it));
}

Expand Down Expand Up @@ -116,8 +117,8 @@ OTIO_API AnyVectorIterator *AnyVectorIterator_prev(AnyVectorIterator *iter, int
}

OTIO_API Any *AnyVectorIterator_value(AnyVectorIterator *iter) {
OTIO_NS::any value = *reinterpret_cast<VectorIterator *>(iter);
return reinterpret_cast<Any *>(new OTIO_NS::any(value));
std::any value = *reinterpret_cast<VectorIterator *>(iter);
return reinterpret_cast<Any *>(new std::any(value));
}

OTIO_API bool
Expand Down
5 changes: 3 additions & 2 deletions src/copentimelineio/clip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@
#include <opentimelineio/clip.h>
#include <opentimelineio/errorStatus.h>
#include <opentimelineio/mediaReference.h>
#include <optional>

OTIO_API Clip *
Clip_create(
const char *name,
MediaReference *media_reference,
OptionalTimeRange source_range,
AnyDictionary *metadata) {
nonstd::optional<opentime::TimeRange> timeRangeOptional = nonstd::nullopt;
std::optional<opentime::TimeRange> timeRangeOptional = std::nullopt;
if (source_range.valid)
timeRangeOptional = nonstd::optional<opentime::TimeRange>(
timeRangeOptional = std::optional<opentime::TimeRange>(
CTimeRange_to_CppTimeRange(source_range.value));

std::string name_str = std::string();
Expand Down
17 changes: 9 additions & 8 deletions src/copentimelineio/composition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <string.h>
#include <utility>
#include <vector>
#include <optional>

typedef std::vector<OTIO_NS::Marker *> MarkerVectorDef;
typedef std::vector<OTIO_NS::Marker *>::iterator MarkerVectorIteratorDef;
Expand All @@ -33,8 +34,8 @@ typedef OTIO_NS::SerializableObject::Retainer<OTIO_NS::Composable>
typedef std::vector<OTIO_NS::Composable *> ComposableVectorDef;
typedef std::vector<OTIO_NS::Composable *>::iterator ComposableVectorIteratorDef;
typedef std::pair<
nonstd::optional<opentime::RationalTime>,
nonstd::optional<opentime::RationalTime>>
std::optional<opentime::RationalTime>,
std::optional<opentime::RationalTime>>
PairDef;

OTIO_API Composition *Composition_create(
Expand All @@ -43,9 +44,9 @@ OTIO_API Composition *Composition_create(
AnyDictionary *metadata,
EffectVector *effects,
MarkerVector *markers) {
nonstd::optional<opentime::TimeRange> timeRangeOptional = nonstd::nullopt;
std::optional<opentime::TimeRange> timeRangeOptional = std::nullopt;
if (source_range.valid)
timeRangeOptional = nonstd::optional<opentime::TimeRange>(
timeRangeOptional = std::optional<opentime::TimeRange>(
CTimeRange_to_CppTimeRange(source_range.value));

std::string name_str = std::string();
Expand Down Expand Up @@ -166,20 +167,20 @@ OTIO_API OptionalTimeRange Composition_trimmed_range_of_child(
Composition *self,
Composable *child,
OTIOErrorStatus *error_status) {
nonstd::optional<opentime::TimeRange> timeRangeOptional =
std::optional<opentime::TimeRange> timeRangeOptional =
reinterpret_cast<OTIO_NS::Composition *>(self)
->trimmed_range_of_child(
reinterpret_cast<OTIO_NS::Composable *>(child),
reinterpret_cast<OTIO_NS::ErrorStatus *>(error_status));
if (timeRangeOptional == nonstd::nullopt) return OptionalTimeRange_create_null();
if (timeRangeOptional == std::nullopt) return OptionalTimeRange_create_null();
return OptionalTimeRange_create(CppTimeRange_to_CTimeRange(timeRangeOptional.value()));
}
OTIO_API OptionalTimeRange
Composition_trim_child_range(Composition *self, TimeRange child_range) {
nonstd::optional<opentime::TimeRange> timeRangeOptional =
std::optional<opentime::TimeRange> timeRangeOptional =
reinterpret_cast<OTIO_NS::Composition *>(self)->trim_child_range(
CTimeRange_to_CppTimeRange(child_range));
if (timeRangeOptional == nonstd::nullopt) return OptionalTimeRange_create_null();
if (timeRangeOptional == std::nullopt) return OptionalTimeRange_create_null();
return OptionalTimeRange_create(CppTimeRange_to_CTimeRange(timeRangeOptional.value()));
}
OTIO_API bool Composition_has_child(Composition *self, Composable *child) {
Expand Down
5 changes: 3 additions & 2 deletions src/copentimelineio/deserialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@

#include "copentimelineio/deserialization.h"
#include <opentimelineio/deserialization.h>
#include <any>

OTIO_API bool deserialize_json_from_string(
const char *input, Any *destination, OTIOErrorStatus *error_status) {
std::string str = input;
return OTIO_NS::deserialize_json_from_string(
str,
reinterpret_cast<OTIO_NS::any *>(destination),
reinterpret_cast<std::any *>(destination),
reinterpret_cast<OTIO_NS::ErrorStatus *>(error_status));
}

OTIO_API bool deserialize_json_from_file(
const char *file_name, Any *destination, OTIOErrorStatus *error_status) {
return OTIO_NS::deserialize_json_from_file(
file_name,
reinterpret_cast<OTIO_NS::any *>(destination),
reinterpret_cast<std::any *>(destination),
reinterpret_cast<OTIO_NS::ErrorStatus *>(error_status));
}
5 changes: 3 additions & 2 deletions src/copentimelineio/externalReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
#include <opentimelineio/anyDictionary.h>
#include <opentimelineio/externalReference.h>
#include <string.h>
#include <optional>

OTIO_API ExternalReference *ExternalReference_create(
const char *target_url,
OptionalTimeRange available_range,
AnyDictionary *metadata) {
nonstd::optional<opentime::TimeRange> timeRangeOptional = nonstd::nullopt;
std::optional<opentime::TimeRange> timeRangeOptional = std::nullopt;
if (available_range.valid)
timeRangeOptional = nonstd::optional<opentime::TimeRange>(
timeRangeOptional = std::optional<opentime::TimeRange>(
CTimeRange_to_CppTimeRange(available_range.value));

OTIO_NS::AnyDictionary metadataDictionary = OTIO_NS::AnyDictionary();
Expand Down
5 changes: 3 additions & 2 deletions src/copentimelineio/generatorReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <opentimelineio/anyDictionary.h>
#include <opentimelineio/generatorReference.h>
#include <string.h>
#include <optional>

OTIO_API GeneratorReference *GeneratorReference_create(
const char *name,
Expand All @@ -32,9 +33,9 @@ OTIO_API GeneratorReference *GeneratorReference_create(
metadataDictionary =
*reinterpret_cast<OTIO_NS::AnyDictionary *>(metadata);

nonstd::optional<opentime::TimeRange> timeRangeOptional = nonstd::nullopt;
std::optional<opentime::TimeRange> timeRangeOptional = std::nullopt;
if (available_range.valid)
timeRangeOptional = nonstd::optional<opentime::TimeRange>(
timeRangeOptional = std::optional<opentime::TimeRange>(
CTimeRange_to_CppTimeRange(available_range.value));
return reinterpret_cast<GeneratorReference *>(
new OTIO_NS::GeneratorReference(
Expand Down
17 changes: 9 additions & 8 deletions src/copentimelineio/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <opentimelineio/item.h>
#include <opentimelineio/marker.h>
#include <opentimelineio/serializableObject.h>
#include <optional>

typedef std::vector<OTIO_NS::Effect *> EffectVectorDef;
typedef std::vector<OTIO_NS::Effect *>::iterator EffectVectorIteratorDef;
Expand All @@ -28,9 +29,9 @@ OTIO_API Item *Item_create(
AnyDictionary *metadata,
EffectVector *effects,
MarkerVector *markers) {
nonstd::optional<OTIO_NS::TimeRange> source_range_optional = nonstd::nullopt;
std::optional<OTIO_NS::TimeRange> source_range_optional = std::nullopt;
if (source_range.valid)
source_range_optional = nonstd::optional<OTIO_NS::TimeRange>(
source_range_optional = std::optional<OTIO_NS::TimeRange>(
CTimeRange_to_CppTimeRange(source_range.value));

std::string name_str = std::string();
Expand Down Expand Up @@ -62,16 +63,16 @@ OTIO_API bool Item_overlapping(Item *self) {
return reinterpret_cast<OTIO_NS::Item *>(self)->overlapping();
}
OTIO_API OptionalTimeRange Item_source_range(Item *self) {
nonstd::optional<OTIO_NS::TimeRange> timeRangeOptional =
std::optional<OTIO_NS::TimeRange> timeRangeOptional =
reinterpret_cast<OTIO_NS::Item *>(self)->source_range();
if (timeRangeOptional == nonstd::nullopt)
if (timeRangeOptional == std::nullopt)
return OptionalTimeRange_create_null();
return OptionalTimeRange_create(CppTimeRange_to_CTimeRange(timeRangeOptional.value()));
}
OTIO_API void Item_set_source_range(Item *self, OptionalTimeRange source_range) {
nonstd::optional<OTIO_NS::TimeRange> timeRangeOptional = nonstd::nullopt;
std::optional<OTIO_NS::TimeRange> timeRangeOptional = std::nullopt;
if (source_range.valid)
timeRangeOptional = nonstd::optional<OTIO_NS::TimeRange>(
timeRangeOptional = std::optional<OTIO_NS::TimeRange>(
CTimeRange_to_CppTimeRange(source_range.value));
reinterpret_cast<OTIO_NS::Item *>(self)->set_source_range(
timeRangeOptional);
Expand Down Expand Up @@ -114,10 +115,10 @@ OTIO_API TimeRange Item_visible_range(Item *self, OTIOErrorStatus *error_status)
}
OTIO_API OptionalTimeRange
Item_trimmed_range_in_parent(Item *self, OTIOErrorStatus *error_status) {
nonstd::optional<OTIO_NS::TimeRange> timeRangeOptional =
std::optional<OTIO_NS::TimeRange> timeRangeOptional =
reinterpret_cast<OTIO_NS::Item *>(self)->trimmed_range_in_parent(
reinterpret_cast<OTIO_NS::ErrorStatus *>(error_status));
if (timeRangeOptional == nonstd::nullopt) return OptionalTimeRange_create_null();
if (timeRangeOptional == std::nullopt) return OptionalTimeRange_create_null();
return OptionalTimeRange_create(CppTimeRange_to_CTimeRange(timeRangeOptional.value()));
}
OTIO_API TimeRange Item_range_in_parent(Item *self, OTIOErrorStatus *error_status) {
Expand Down
13 changes: 7 additions & 6 deletions src/copentimelineio/mediaReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
#include <opentime/timeRange.h>
#include <opentimelineio/anyDictionary.h>
#include <opentimelineio/mediaReference.h>
#include <optional>

OTIO_API MediaReference *MediaReference_create(
const char *name, OptionalTimeRange available_range, AnyDictionary *metadata) {
nonstd::optional<opentime::TimeRange> timeRangeOptional = nonstd::nullopt;
std::optional<opentime::TimeRange> timeRangeOptional = std::nullopt;
if (available_range.valid)
timeRangeOptional = nonstd::optional<opentime::TimeRange>(
timeRangeOptional = std::optional<opentime::TimeRange>(
CTimeRange_to_CppTimeRange(available_range.value));

std::string name_str = std::string();
Expand All @@ -28,16 +29,16 @@ OTIO_API MediaReference *MediaReference_create(
name_str, timeRangeOptional, metadataDictionary));
}
OTIO_API OptionalTimeRange MediaReference_available_range(MediaReference *self) {
nonstd::optional<opentime::TimeRange> timeRangeOptional =
std::optional<opentime::TimeRange> timeRangeOptional =
reinterpret_cast<OTIO_NS::MediaReference *>(self)->available_range();
if (timeRangeOptional == nonstd::nullopt) return OptionalTimeRange_create_null();
if (timeRangeOptional == std::nullopt) return OptionalTimeRange_create_null();
return OptionalTimeRange_create(CppTimeRange_to_CTimeRange(timeRangeOptional.value()));
}
OTIO_API void MediaReference_set_available_range(
MediaReference *self, OptionalTimeRange available_range) {
nonstd::optional<opentime::TimeRange> timeRangeOptional = nonstd::nullopt;
std::optional<opentime::TimeRange> timeRangeOptional = std::nullopt;
if (available_range.valid)
timeRangeOptional = nonstd::optional<opentime::TimeRange>(
timeRangeOptional = std::optional<opentime::TimeRange>(
CTimeRange_to_CppTimeRange(available_range.value));
reinterpret_cast<OTIO_NS::MediaReference *>(self)->set_available_range(
timeRangeOptional);
Expand Down
5 changes: 3 additions & 2 deletions src/copentimelineio/missingReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
#include <opentime/timeRange.h>
#include <opentimelineio/anyDictionary.h>
#include <opentimelineio/missingReference.h>
#include <optional>

OTIO_API MissingReference *MissingReference_create(
const char *name, OptionalTimeRange available_range, AnyDictionary *metadata) {
nonstd::optional<opentime::TimeRange> timeRangeOptional = nonstd::nullopt;
std::optional<opentime::TimeRange> timeRangeOptional = std::nullopt;
if (available_range.valid)
timeRangeOptional = nonstd::optional<opentime::TimeRange>(
timeRangeOptional = std::optional<opentime::TimeRange>(
CTimeRange_to_CppTimeRange(available_range.value));
OTIO_NS::AnyDictionary metadataDictionary = OTIO_NS::AnyDictionary();
if (metadata != NULL)
Expand Down
Loading

0 comments on commit e8a695a

Please sign in to comment.