|
2 | 2 | // Copyright Contributors to the OpenTimelineIO project
|
3 | 3 |
|
4 | 4 | #include <pybind11/pybind11.h>
|
| 5 | +#include <pybind11/functional.h> |
5 | 6 | #include "otio_anyDictionary.h"
|
6 | 7 | #include "otio_anyVector.h"
|
7 | 8 | #include "otio_bindings.h"
|
@@ -71,13 +72,12 @@ static void register_python_type(py::object class_object,
|
71 | 72 |
|
72 | 73 | static bool register_upgrade_function(std::string const& schema_name,
|
73 | 74 | int version_to_upgrade_to,
|
74 |
| - py::object const& upgrade_function_obj) { |
| 75 | + std::function<void(AnyDictionaryProxy*)> const& upgrade_function_obj) { |
75 | 76 | std::function<void (AnyDictionary* d)> upgrade_function = [upgrade_function_obj](AnyDictionary* d) {
|
76 | 77 | py::gil_scoped_acquire acquire;
|
77 | 78 |
|
78 | 79 | auto ptr = d->get_or_create_mutation_stamp();
|
79 |
| - py::object dobj = py::cast((AnyDictionaryProxy*)ptr); |
80 |
| - upgrade_function_obj(dobj); |
| 80 | + upgrade_function_obj((AnyDictionaryProxy*)ptr); |
81 | 81 | };
|
82 | 82 |
|
83 | 83 | // further discussion required about preventing double registering
|
@@ -112,16 +112,15 @@ static bool
|
112 | 112 | register_downgrade_function(
|
113 | 113 | std::string const& schema_name,
|
114 | 114 | int version_to_downgrade_from,
|
115 |
| - py::object const& downgrade_function_obj) |
| 115 | + std::function<void(AnyDictionaryProxy*)> const& downgrade_function_obj) |
116 | 116 | {
|
117 | 117 | std::function<void (AnyDictionary* d)> downgrade_function = (
|
118 | 118 | [downgrade_function_obj](AnyDictionary* d)
|
119 | 119 | {
|
120 | 120 | py::gil_scoped_acquire acquire;
|
121 | 121 |
|
122 | 122 | auto ptr = d->get_or_create_mutation_stamp();
|
123 |
| - py::object dobj = py::cast((AnyDictionaryProxy*)ptr); |
124 |
| - downgrade_function_obj(dobj); |
| 123 | + downgrade_function_obj((AnyDictionaryProxy*)ptr); |
125 | 124 | }
|
126 | 125 | );
|
127 | 126 |
|
|
0 commit comments