/// /// NativeCaretDirection.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() #include #else #error NitroModules cannot be found! Are you sure you installed NitroModules properly? #endif #if __has_include() #include #else #error NitroModules cannot be found! Are you sure you installed NitroModules properly? #endif #if __has_include() #include #else #error NitroModules cannot be found! Are you sure you installed NitroModules properly? #endif namespace margelo::nitro::codepad { /** * An enum which can be represented as a JavaScript union (NativeCaretDirection). */ enum class NativeCaretDirection { LEFT SWIFT_NAME(left) = 0, RIGHT SWIFT_NAME(right) = 1, WORDLEFT SWIFT_NAME(wordleft) = 2, WORDRIGHT SWIFT_NAME(wordright) = 3, LINESTART SWIFT_NAME(linestart) = 4, LINEEND SWIFT_NAME(lineend) = 5, DOCUMENTSTART SWIFT_NAME(documentstart) = 6, DOCUMENTEND SWIFT_NAME(documentend) = 7, UP SWIFT_NAME(up) = 8, DOWN SWIFT_NAME(down) = 9, PAGEUP SWIFT_NAME(pageup) = 10, PAGEDOWN SWIFT_NAME(pagedown) = 11, } CLOSED_ENUM; } // namespace margelo::nitro::codepad namespace margelo::nitro { // C++ NativeCaretDirection <> JS NativeCaretDirection (union) template <> struct JSIConverter final { static inline margelo::nitro::codepad::NativeCaretDirection fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { std::string unionValue = JSIConverter::fromJSI(runtime, arg); switch (hashString(unionValue.c_str(), unionValue.size())) { case hashString("left"): return margelo::nitro::codepad::NativeCaretDirection::LEFT; case hashString("right"): return margelo::nitro::codepad::NativeCaretDirection::RIGHT; case hashString("wordLeft"): return margelo::nitro::codepad::NativeCaretDirection::WORDLEFT; case hashString("wordRight"): return margelo::nitro::codepad::NativeCaretDirection::WORDRIGHT; case hashString("lineStart"): return margelo::nitro::codepad::NativeCaretDirection::LINESTART; case hashString("lineEnd"): return margelo::nitro::codepad::NativeCaretDirection::LINEEND; case hashString("documentStart"): return margelo::nitro::codepad::NativeCaretDirection::DOCUMENTSTART; case hashString("documentEnd"): return margelo::nitro::codepad::NativeCaretDirection::DOCUMENTEND; case hashString("up"): return margelo::nitro::codepad::NativeCaretDirection::UP; case hashString("down"): return margelo::nitro::codepad::NativeCaretDirection::DOWN; case hashString("pageUp"): return margelo::nitro::codepad::NativeCaretDirection::PAGEUP; case hashString("pageDown"): return margelo::nitro::codepad::NativeCaretDirection::PAGEDOWN; default: [[unlikely]] throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum NativeCaretDirection - invalid value!"); } } static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::codepad::NativeCaretDirection arg) { switch (arg) { case margelo::nitro::codepad::NativeCaretDirection::LEFT: return JSIConverter::toJSI(runtime, "left"); case margelo::nitro::codepad::NativeCaretDirection::RIGHT: return JSIConverter::toJSI(runtime, "right"); case margelo::nitro::codepad::NativeCaretDirection::WORDLEFT: return JSIConverter::toJSI(runtime, "wordLeft"); case margelo::nitro::codepad::NativeCaretDirection::WORDRIGHT: return JSIConverter::toJSI(runtime, "wordRight"); case margelo::nitro::codepad::NativeCaretDirection::LINESTART: return JSIConverter::toJSI(runtime, "lineStart"); case margelo::nitro::codepad::NativeCaretDirection::LINEEND: return JSIConverter::toJSI(runtime, "lineEnd"); case margelo::nitro::codepad::NativeCaretDirection::DOCUMENTSTART: return JSIConverter::toJSI(runtime, "documentStart"); case margelo::nitro::codepad::NativeCaretDirection::DOCUMENTEND: return JSIConverter::toJSI(runtime, "documentEnd"); case margelo::nitro::codepad::NativeCaretDirection::UP: return JSIConverter::toJSI(runtime, "up"); case margelo::nitro::codepad::NativeCaretDirection::DOWN: return JSIConverter::toJSI(runtime, "down"); case margelo::nitro::codepad::NativeCaretDirection::PAGEUP: return JSIConverter::toJSI(runtime, "pageUp"); case margelo::nitro::codepad::NativeCaretDirection::PAGEDOWN: return JSIConverter::toJSI(runtime, "pageDown"); default: [[unlikely]] throw std::invalid_argument("Cannot convert NativeCaretDirection to JS - invalid value: " + std::to_string(static_cast(arg)) + "!"); } } static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { if (!value.isString()) { return false; } std::string unionValue = JSIConverter::fromJSI(runtime, value); switch (hashString(unionValue.c_str(), unionValue.size())) { case hashString("left"): case hashString("right"): case hashString("wordLeft"): case hashString("wordRight"): case hashString("lineStart"): case hashString("lineEnd"): case hashString("documentStart"): case hashString("documentEnd"): case hashString("up"): case hashString("down"): case hashString("pageUp"): case hashString("pageDown"): return true; default: return false; } } }; } // namespace margelo::nitro