Skip to content

Commit

Permalink
Merge pull request #172 from Snapchat/lf/optional-future
Browse files Browse the repository at this point in the history
Support optional<future>
  • Loading branch information
li-feng-sc authored Jun 18, 2024
2 parents e65df3d + 88bab44 commit 7eadef8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions support-lib/composer/djinni_composer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ struct Optional {
static ComposerType fromCpp(const OptionalType<typename T::CppType>& c) {
return c ? T::Boxed::fromCpp(*c) : Composer::Value::undefined();
}
static ComposerType fromCpp(OptionalType<typename T::CppType>&& c) {
return c ? T::Boxed::fromCpp(std::move(*c)) : Composer::Value::undefined();
}
template<typename C = T>
static ComposerType fromCpp(const typename C::CppOptType& cppOpt) {
return T::Boxed::fromCppOpt(cppOpt);
Expand Down
4 changes: 4 additions & 0 deletions support-lib/jni/Marshal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ namespace djinni
{
return c ? T::Boxed::fromCpp(jniEnv, *c) : LocalRef<JniType>{};
}
static LocalRef<JniType> fromCpp(JNIEnv* jniEnv, OptionalType<typename T::CppType> &&c)
{
return c ? T::Boxed::fromCpp(jniEnv, std::move(*c)) : LocalRef<JniType>{};
}

// fromCpp used for nullable shared_ptr
template <typename C = T>
Expand Down
3 changes: 3 additions & 0 deletions support-lib/objc/DJIMarshal+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ class Optional {
static ObjcType fromCpp(const OptionalType<typename T::CppType>& opt) {
return opt ? T::Boxed::fromCpp(*opt) : nil;
}
static ObjcType fromCpp(OptionalType<typename T::CppType>&& opt) {
return opt ? T::Boxed::fromCpp(std::move(*opt)) : nil;
}

// fromCpp used for nullable shared_ptr
template <typename C = T>
Expand Down
3 changes: 3 additions & 0 deletions support-lib/wasm/djinni_wasm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ struct Optional
static JsType fromCpp(const OptionalType<typename T::CppType>& c) {
return c ? T::Boxed::fromCpp(*c) : em::val::undefined();
}
static JsType fromCpp(OptionalType<typename T::CppType>&& c) {
return c ? T::Boxed::fromCpp(std::move(*c)) : em::val::undefined();
}
template <typename C = T>
static JsType fromCpp(const typename C::CppOptType& cppOpt) {
return T::Boxed::fromCppOpt(cppOpt);
Expand Down

0 comments on commit 7eadef8

Please sign in to comment.