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:
+73
@@ -0,0 +1,73 @@
|
||||
///
|
||||
/// JRendition.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 "Rendition.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace margelo::nitro::omni {
|
||||
|
||||
using namespace facebook;
|
||||
|
||||
/**
|
||||
* The C++ JNI bridge between the C++ struct "Rendition" and the the Kotlin data class "Rendition".
|
||||
*/
|
||||
struct JRendition final: public jni::JavaClass<JRendition> {
|
||||
public:
|
||||
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/Rendition;";
|
||||
|
||||
public:
|
||||
/**
|
||||
* Convert this Java/Kotlin-based struct to the C++ struct Rendition by copying all values to C++.
|
||||
*/
|
||||
[[maybe_unused]]
|
||||
[[nodiscard]]
|
||||
Rendition toCpp() const {
|
||||
static const auto clazz = javaClassStatic();
|
||||
static const auto fieldId = clazz->getField<jni::JString>("id");
|
||||
jni::local_ref<jni::JString> id = this->getFieldValue(fieldId);
|
||||
static const auto fieldWidth = clazz->getField<double>("width");
|
||||
double width = this->getFieldValue(fieldWidth);
|
||||
static const auto fieldHeight = clazz->getField<double>("height");
|
||||
double height = this->getFieldValue(fieldHeight);
|
||||
static const auto fieldBitrate = clazz->getField<double>("bitrate");
|
||||
double bitrate = this->getFieldValue(fieldBitrate);
|
||||
static const auto fieldSelected = clazz->getField<jboolean>("selected");
|
||||
jboolean selected = this->getFieldValue(fieldSelected);
|
||||
return Rendition(
|
||||
id->toStdString(),
|
||||
width,
|
||||
height,
|
||||
bitrate,
|
||||
static_cast<bool>(selected)
|
||||
);
|
||||
}
|
||||
|
||||
public:
|
||||
/**
|
||||
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
||||
*/
|
||||
[[maybe_unused]]
|
||||
static jni::local_ref<JRendition::javaobject> fromCpp(const Rendition& value) {
|
||||
using JSignature = JRendition(jni::alias_ref<jni::JString>, double, double, double, jboolean);
|
||||
static const auto clazz = javaClassStatic();
|
||||
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
||||
return create(
|
||||
clazz,
|
||||
jni::make_jstring(value.id),
|
||||
value.width,
|
||||
value.height,
|
||||
value.bitrate,
|
||||
value.selected
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace margelo::nitro::omni
|
||||
Reference in New Issue
Block a user