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:
+84
@@ -0,0 +1,84 @@
|
||||
///
|
||||
/// MixAudioMode.hpp
|
||||
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
||||
/// https://github.com/mrousavy/nitro
|
||||
/// Copyright © Marc Rousavy @ Margelo
|
||||
///
|
||||
|
||||
#pragma once
|
||||
|
||||
#if __has_include(<NitroModules/NitroHash.hpp>)
|
||||
#include <NitroModules/NitroHash.hpp>
|
||||
#else
|
||||
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
||||
#endif
|
||||
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
||||
#include <NitroModules/JSIConverter.hpp>
|
||||
#else
|
||||
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
||||
#endif
|
||||
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
||||
#include <NitroModules/NitroDefines.hpp>
|
||||
#else
|
||||
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
||||
#endif
|
||||
|
||||
namespace margelo::nitro::omni {
|
||||
|
||||
/**
|
||||
* An enum which can be represented as a JavaScript union (MixAudioMode).
|
||||
*/
|
||||
enum class MixAudioMode {
|
||||
MIXWITHOTHERS SWIFT_NAME(mixwithothers) = 0,
|
||||
DONOTMIX SWIFT_NAME(donotmix) = 1,
|
||||
DUCKOTHERS SWIFT_NAME(duckothers) = 2,
|
||||
AUTO SWIFT_NAME(auto) = 3,
|
||||
} CLOSED_ENUM;
|
||||
|
||||
} // namespace margelo::nitro::omni
|
||||
|
||||
namespace margelo::nitro {
|
||||
|
||||
// C++ MixAudioMode <> JS MixAudioMode (union)
|
||||
template <>
|
||||
struct JSIConverter<margelo::nitro::omni::MixAudioMode> final {
|
||||
static inline margelo::nitro::omni::MixAudioMode fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
||||
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
||||
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
||||
case hashString("mixWithOthers"): return margelo::nitro::omni::MixAudioMode::MIXWITHOTHERS;
|
||||
case hashString("doNotMix"): return margelo::nitro::omni::MixAudioMode::DONOTMIX;
|
||||
case hashString("duckOthers"): return margelo::nitro::omni::MixAudioMode::DUCKOTHERS;
|
||||
case hashString("auto"): return margelo::nitro::omni::MixAudioMode::AUTO;
|
||||
default: [[unlikely]]
|
||||
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum MixAudioMode - invalid value!");
|
||||
}
|
||||
}
|
||||
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::omni::MixAudioMode arg) {
|
||||
switch (arg) {
|
||||
case margelo::nitro::omni::MixAudioMode::MIXWITHOTHERS: return JSIConverter<std::string>::toJSI(runtime, "mixWithOthers");
|
||||
case margelo::nitro::omni::MixAudioMode::DONOTMIX: return JSIConverter<std::string>::toJSI(runtime, "doNotMix");
|
||||
case margelo::nitro::omni::MixAudioMode::DUCKOTHERS: return JSIConverter<std::string>::toJSI(runtime, "duckOthers");
|
||||
case margelo::nitro::omni::MixAudioMode::AUTO: return JSIConverter<std::string>::toJSI(runtime, "auto");
|
||||
default: [[unlikely]]
|
||||
throw std::invalid_argument("Cannot convert MixAudioMode to JS - invalid value: "
|
||||
+ std::to_string(static_cast<int>(arg)) + "!");
|
||||
}
|
||||
}
|
||||
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
||||
if (!value.isString()) {
|
||||
return false;
|
||||
}
|
||||
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
||||
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
||||
case hashString("mixWithOthers"):
|
||||
case hashString("doNotMix"):
|
||||
case hashString("duckOthers"):
|
||||
case hashString("auto"):
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace margelo::nitro
|
||||
Reference in New Issue
Block a user