mirror of
https://github.com/zoriya/react-native-omni.git
synced 2026-08-05 05:36:17 +00:00
Cleanup prev/next
This commit is contained in:
-120
@@ -1,120 +0,0 @@
|
||||
///
|
||||
/// JBaseSource.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 "BaseSource.hpp"
|
||||
|
||||
#include "JMetadata.hpp"
|
||||
#include "JMixAudioMode.hpp"
|
||||
#include "JSubtitle.hpp"
|
||||
#include "JVideoSrc.hpp"
|
||||
#include "Metadata.hpp"
|
||||
#include "MixAudioMode.hpp"
|
||||
#include "Subtitle.hpp"
|
||||
#include "VideoSrc.hpp"
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace margelo::nitro::omni {
|
||||
|
||||
using namespace facebook;
|
||||
|
||||
/**
|
||||
* The C++ JNI bridge between the C++ struct "BaseSource" and the the Kotlin data class "BaseSource".
|
||||
*/
|
||||
struct JBaseSource final: public jni::JavaClass<JBaseSource> {
|
||||
public:
|
||||
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/BaseSource;";
|
||||
|
||||
public:
|
||||
/**
|
||||
* Convert this Java/Kotlin-based struct to the C++ struct BaseSource by copying all values to C++.
|
||||
*/
|
||||
[[maybe_unused]]
|
||||
[[nodiscard]]
|
||||
BaseSource toCpp() const {
|
||||
static const auto clazz = javaClassStatic();
|
||||
static const auto fieldSrc = clazz->getField<jni::JArrayClass<JVideoSrc>>("src");
|
||||
jni::local_ref<jni::JArrayClass<JVideoSrc>> src = this->getFieldValue(fieldSrc);
|
||||
static const auto fieldStartTime = clazz->getField<jni::JDouble>("startTime");
|
||||
jni::local_ref<jni::JDouble> startTime = this->getFieldValue(fieldStartTime);
|
||||
static const auto fieldSubtitles = clazz->getField<jni::JArrayClass<JSubtitle>>("subtitles");
|
||||
jni::local_ref<jni::JArrayClass<JSubtitle>> subtitles = this->getFieldValue(fieldSubtitles);
|
||||
static const auto fieldMetadata = clazz->getField<JMetadata>("metadata");
|
||||
jni::local_ref<JMetadata> metadata = this->getFieldValue(fieldMetadata);
|
||||
static const auto fieldMixAudio = clazz->getField<JMixAudioMode>("mixAudio");
|
||||
jni::local_ref<JMixAudioMode> mixAudio = this->getFieldValue(fieldMixAudio);
|
||||
return BaseSource(
|
||||
[&]() {
|
||||
size_t __size = src->size();
|
||||
std::vector<VideoSrc> __vector;
|
||||
__vector.reserve(__size);
|
||||
for (size_t __i = 0; __i < __size; __i++) {
|
||||
auto __element = src->getElement(__i);
|
||||
__vector.push_back(__element->toCpp());
|
||||
}
|
||||
return __vector;
|
||||
}(),
|
||||
startTime != nullptr ? std::make_optional(startTime->value()) : std::nullopt,
|
||||
[&]() {
|
||||
size_t __size = subtitles->size();
|
||||
std::vector<Subtitle> __vector;
|
||||
__vector.reserve(__size);
|
||||
for (size_t __i = 0; __i < __size; __i++) {
|
||||
auto __element = subtitles->getElement(__i);
|
||||
__vector.push_back(__element->toCpp());
|
||||
}
|
||||
return __vector;
|
||||
}(),
|
||||
metadata != nullptr ? std::make_optional(metadata->toCpp()) : std::nullopt,
|
||||
mixAudio != nullptr ? std::make_optional(mixAudio->toCpp()) : 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<JBaseSource::javaobject> fromCpp(const BaseSource& value) {
|
||||
using JSignature = JBaseSource(jni::alias_ref<jni::JArrayClass<JVideoSrc>>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JArrayClass<JSubtitle>>, jni::alias_ref<JMetadata>, jni::alias_ref<JMixAudioMode>);
|
||||
static const auto clazz = javaClassStatic();
|
||||
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
||||
return create(
|
||||
clazz,
|
||||
[&]() {
|
||||
size_t __size = value.src.size();
|
||||
jni::local_ref<jni::JArrayClass<JVideoSrc>> __array = jni::JArrayClass<JVideoSrc>::newArray(__size);
|
||||
for (size_t __i = 0; __i < __size; __i++) {
|
||||
const auto& __element = value.src[__i];
|
||||
auto __elementJni = JVideoSrc::fromCpp(__element);
|
||||
__array->setElement(__i, *__elementJni);
|
||||
}
|
||||
return __array;
|
||||
}(),
|
||||
value.startTime.has_value() ? jni::JDouble::valueOf(value.startTime.value()) : nullptr,
|
||||
[&]() {
|
||||
size_t __size = value.subtitles.size();
|
||||
jni::local_ref<jni::JArrayClass<JSubtitle>> __array = jni::JArrayClass<JSubtitle>::newArray(__size);
|
||||
for (size_t __i = 0; __i < __size; __i++) {
|
||||
const auto& __element = value.subtitles[__i];
|
||||
auto __elementJni = JSubtitle::fromCpp(__element);
|
||||
__array->setElement(__i, *__elementJni);
|
||||
}
|
||||
return __array;
|
||||
}(),
|
||||
value.metadata.has_value() ? JMetadata::fromCpp(value.metadata.value()) : nullptr,
|
||||
value.mixAudio.has_value() ? JMixAudioMode::fromCpp(value.mixAudio.value()) : nullptr
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace margelo::nitro::omni
|
||||
@@ -11,8 +11,6 @@
|
||||
namespace margelo::nitro::omni { class HybridOmniPlayerSpec; }
|
||||
// Forward declaration of `Source` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct Source; }
|
||||
// Forward declaration of `BaseSource` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct BaseSource; }
|
||||
// Forward declaration of `VideoSrc` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct VideoSrc; }
|
||||
// Forward declaration of `Subtitle` to properly resolve imports.
|
||||
@@ -27,13 +25,11 @@ namespace margelo::nitro::omni { enum class MixAudioMode; }
|
||||
#include "JHybridOmniPlayerSpec.hpp"
|
||||
#include "Source.hpp"
|
||||
#include "JSource.hpp"
|
||||
#include "BaseSource.hpp"
|
||||
#include <optional>
|
||||
#include "JBaseSource.hpp"
|
||||
#include "VideoSrc.hpp"
|
||||
#include <vector>
|
||||
#include "JVideoSrc.hpp"
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include "Subtitle.hpp"
|
||||
#include "JSubtitle.hpp"
|
||||
|
||||
+1
-5
@@ -11,8 +11,6 @@
|
||||
namespace margelo::nitro::omni { class HybridOmniEventMapSpec; }
|
||||
// Forward declaration of `Source` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct Source; }
|
||||
// Forward declaration of `BaseSource` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct BaseSource; }
|
||||
// Forward declaration of `VideoSrc` to properly resolve imports.
|
||||
namespace margelo::nitro::omni { struct VideoSrc; }
|
||||
// Forward declaration of `Subtitle` to properly resolve imports.
|
||||
@@ -33,13 +31,11 @@ namespace margelo::nitro::omni { enum class PlayerStatus; }
|
||||
#include "JHybridOmniEventMapSpec.hpp"
|
||||
#include "Source.hpp"
|
||||
#include "JSource.hpp"
|
||||
#include "BaseSource.hpp"
|
||||
#include <optional>
|
||||
#include "JBaseSource.hpp"
|
||||
#include "VideoSrc.hpp"
|
||||
#include <vector>
|
||||
#include "JVideoSrc.hpp"
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include "Subtitle.hpp"
|
||||
#include "JSubtitle.hpp"
|
||||
|
||||
+11
-3
@@ -40,11 +40,17 @@ namespace margelo::nitro::omni {
|
||||
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
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
@@ -54,7 +60,7 @@ namespace margelo::nitro::omni {
|
||||
*/
|
||||
[[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>);
|
||||
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(
|
||||
@@ -62,7 +68,9 @@ namespace margelo::nitro::omni {
|
||||
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.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
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
+1
-11
@@ -10,8 +10,6 @@
|
||||
#include <fbjni/fbjni.h>
|
||||
#include "Source.hpp"
|
||||
|
||||
#include "BaseSource.hpp"
|
||||
#include "JBaseSource.hpp"
|
||||
#include "JMetadata.hpp"
|
||||
#include "JMixAudioMode.hpp"
|
||||
#include "JSubtitle.hpp"
|
||||
@@ -44,10 +42,6 @@ namespace margelo::nitro::omni {
|
||||
[[nodiscard]]
|
||||
Source toCpp() const {
|
||||
static const auto clazz = javaClassStatic();
|
||||
static const auto fieldPrev = clazz->getField<JBaseSource>("prev");
|
||||
jni::local_ref<JBaseSource> prev = this->getFieldValue(fieldPrev);
|
||||
static const auto fieldNext = clazz->getField<JBaseSource>("next");
|
||||
jni::local_ref<JBaseSource> next = this->getFieldValue(fieldNext);
|
||||
static const auto fieldSrc = clazz->getField<jni::JArrayClass<JVideoSrc>>("src");
|
||||
jni::local_ref<jni::JArrayClass<JVideoSrc>> src = this->getFieldValue(fieldSrc);
|
||||
static const auto fieldStartTime = clazz->getField<jni::JDouble>("startTime");
|
||||
@@ -59,8 +53,6 @@ namespace margelo::nitro::omni {
|
||||
static const auto fieldMixAudio = clazz->getField<JMixAudioMode>("mixAudio");
|
||||
jni::local_ref<JMixAudioMode> mixAudio = this->getFieldValue(fieldMixAudio);
|
||||
return Source(
|
||||
prev != nullptr ? std::make_optional(prev->toCpp()) : std::nullopt,
|
||||
next != nullptr ? std::make_optional(next->toCpp()) : std::nullopt,
|
||||
[&]() {
|
||||
size_t __size = src->size();
|
||||
std::vector<VideoSrc> __vector;
|
||||
@@ -93,13 +85,11 @@ namespace margelo::nitro::omni {
|
||||
*/
|
||||
[[maybe_unused]]
|
||||
static jni::local_ref<JSource::javaobject> fromCpp(const Source& value) {
|
||||
using JSignature = JSource(jni::alias_ref<JBaseSource>, jni::alias_ref<JBaseSource>, jni::alias_ref<jni::JArrayClass<JVideoSrc>>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JArrayClass<JSubtitle>>, jni::alias_ref<JMetadata>, jni::alias_ref<JMixAudioMode>);
|
||||
using JSignature = JSource(jni::alias_ref<jni::JArrayClass<JVideoSrc>>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JArrayClass<JSubtitle>>, jni::alias_ref<JMetadata>, jni::alias_ref<JMixAudioMode>);
|
||||
static const auto clazz = javaClassStatic();
|
||||
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
||||
return create(
|
||||
clazz,
|
||||
value.prev.has_value() ? JBaseSource::fromCpp(value.prev.value()) : nullptr,
|
||||
value.next.has_value() ? JBaseSource::fromCpp(value.next.value()) : nullptr,
|
||||
[&]() {
|
||||
size_t __size = value.src.size();
|
||||
jni::local_ref<jni::JArrayClass<JVideoSrc>> __array = jni::JArrayClass<JVideoSrc>::newArray(__size);
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
///
|
||||
/// BaseSource.kt
|
||||
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
||||
/// https://github.com/mrousavy/nitro
|
||||
/// Copyright © Marc Rousavy @ Margelo
|
||||
///
|
||||
|
||||
package com.margelo.nitro.omni
|
||||
|
||||
import androidx.annotation.Keep
|
||||
import com.facebook.proguard.annotations.DoNotStrip
|
||||
|
||||
|
||||
/**
|
||||
* Represents the JavaScript object/struct "BaseSource".
|
||||
*/
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
data class BaseSource(
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
val src: Array<VideoSrc>,
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
val startTime: Double?,
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
val subtitles: Array<Subtitle>,
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
val metadata: Metadata?,
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
val mixAudio: MixAudioMode?
|
||||
) {
|
||||
/* primary constructor */
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Constructor called from C++
|
||||
*/
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
@Suppress("unused")
|
||||
@JvmStatic
|
||||
private fun fromCpp(src: Array<VideoSrc>, startTime: Double?, subtitles: Array<Subtitle>, metadata: Metadata?, mixAudio: MixAudioMode?): BaseSource {
|
||||
return BaseSource(src, startTime, subtitles, metadata, mixAudio)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,13 @@ data class Metadata(
|
||||
val artist: String?,
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
val imageLink: String?
|
||||
val imageLink: String?,
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
val hasPrev: Boolean?,
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
val hasNext: Boolean?
|
||||
) {
|
||||
/* primary constructor */
|
||||
|
||||
@@ -40,8 +46,8 @@ data class Metadata(
|
||||
@Keep
|
||||
@Suppress("unused")
|
||||
@JvmStatic
|
||||
private fun fromCpp(title: String, album: String?, artist: String?, imageLink: String?): Metadata {
|
||||
return Metadata(title, album, artist, imageLink)
|
||||
private fun fromCpp(title: String, album: String?, artist: String?, imageLink: String?, hasPrev: Boolean?, hasNext: Boolean?): Metadata {
|
||||
return Metadata(title, album, artist, imageLink, hasPrev, hasNext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,6 @@ import com.facebook.proguard.annotations.DoNotStrip
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
data class Source(
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
val prev: BaseSource?,
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
val next: BaseSource?,
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
val src: Array<VideoSrc>,
|
||||
@@ -49,8 +43,8 @@ data class Source(
|
||||
@Keep
|
||||
@Suppress("unused")
|
||||
@JvmStatic
|
||||
private fun fromCpp(prev: BaseSource?, next: BaseSource?, src: Array<VideoSrc>, startTime: Double?, subtitles: Array<Subtitle>, metadata: Metadata?, mixAudio: MixAudioMode?): Source {
|
||||
return Source(prev, next, src, startTime, subtitles, metadata, mixAudio)
|
||||
private fun fromCpp(src: Array<VideoSrc>, startTime: Double?, subtitles: Array<Subtitle>, metadata: Metadata?, mixAudio: MixAudioMode?): Source {
|
||||
return Source(src, startTime, subtitles, metadata, mixAudio)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user