mirror of
https://github.com/zoriya/react-native-omni.git
synced 2026-08-16 02:44:51 +00:00
Create types for player & view
This commit is contained in:
+78
@@ -0,0 +1,78 @@
|
||||
///
|
||||
/// JMetadata.hpp
|
||||
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
||||
/// https://github.com/mrousavy/nitro
|
||||
/// Copyright © Marc Rousavy @ Margelo
|
||||
///
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fbjni/fbjni.h>
|
||||
#include "Metadata.hpp"
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace margelo::nitro::omni {
|
||||
|
||||
using namespace facebook;
|
||||
|
||||
/**
|
||||
* The C++ JNI bridge between the C++ struct "Metadata" and the the Kotlin data class "Metadata".
|
||||
*/
|
||||
struct JMetadata final: public jni::JavaClass<JMetadata> {
|
||||
public:
|
||||
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/Metadata;";
|
||||
|
||||
public:
|
||||
/**
|
||||
* Convert this Java/Kotlin-based struct to the C++ struct Metadata by copying all values to C++.
|
||||
*/
|
||||
[[maybe_unused]]
|
||||
[[nodiscard]]
|
||||
Metadata toCpp() const {
|
||||
static const auto clazz = javaClassStatic();
|
||||
static const auto fieldTitle = clazz->getField<jni::JString>("title");
|
||||
jni::local_ref<jni::JString> title = this->getFieldValue(fieldTitle);
|
||||
static const auto fieldAlbum = clazz->getField<jni::JString>("album");
|
||||
jni::local_ref<jni::JString> album = this->getFieldValue(fieldAlbum);
|
||||
static const auto fieldArtist = clazz->getField<jni::JString>("artist");
|
||||
jni::local_ref<jni::JString> artist = this->getFieldValue(fieldArtist);
|
||||
static const auto fieldImageLink = clazz->getField<jni::JString>("imageLink");
|
||||
jni::local_ref<jni::JString> imageLink = this->getFieldValue(fieldImageLink);
|
||||
static const auto fieldHasPrev = clazz->getField<jni::JBoolean>("hasPrev");
|
||||
jni::local_ref<jni::JBoolean> hasPrev = this->getFieldValue(fieldHasPrev);
|
||||
static const auto fieldHasNext = clazz->getField<jni::JBoolean>("hasNext");
|
||||
jni::local_ref<jni::JBoolean> hasNext = this->getFieldValue(fieldHasNext);
|
||||
return Metadata(
|
||||
title->toStdString(),
|
||||
album != nullptr ? std::make_optional(album->toStdString()) : std::nullopt,
|
||||
artist != nullptr ? std::make_optional(artist->toStdString()) : std::nullopt,
|
||||
imageLink != nullptr ? std::make_optional(imageLink->toStdString()) : std::nullopt,
|
||||
hasPrev != nullptr ? std::make_optional(static_cast<bool>(hasPrev->value())) : std::nullopt,
|
||||
hasNext != nullptr ? std::make_optional(static_cast<bool>(hasNext->value())) : std::nullopt
|
||||
);
|
||||
}
|
||||
|
||||
public:
|
||||
/**
|
||||
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
||||
*/
|
||||
[[maybe_unused]]
|
||||
static jni::local_ref<JMetadata::javaobject> fromCpp(const Metadata& value) {
|
||||
using JSignature = JMetadata(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>);
|
||||
static const auto clazz = javaClassStatic();
|
||||
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
||||
return create(
|
||||
clazz,
|
||||
jni::make_jstring(value.title),
|
||||
value.album.has_value() ? jni::make_jstring(value.album.value()) : nullptr,
|
||||
value.artist.has_value() ? jni::make_jstring(value.artist.value()) : nullptr,
|
||||
value.imageLink.has_value() ? jni::make_jstring(value.imageLink.value()) : nullptr,
|
||||
value.hasPrev.has_value() ? jni::JBoolean::valueOf(value.hasPrev.value()) : nullptr,
|
||||
value.hasNext.has_value() ? jni::JBoolean::valueOf(value.hasNext.value()) : nullptr
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace margelo::nitro::omni
|
||||
Reference in New Issue
Block a user