mirror of
https://github.com/zoriya/nitro.git
synced 2026-10-13 00:05:23 +00:00
* feat: Add explicit `null` type
* Handle the cases
* Use NullType instead of `std::monostate`
* null is now variant! nice
* fix: Add missing imports
* fix: Fix podspec
* whoops now its fixed
* we're getting there...
* it builds on Android!
* fix: Add monostate back
* fix: Fix JNull lookup
* fix: Fix Swift build
* feat: Add tests for `null` type
* remove `UndefinedType`
* Now iOS builds???
* Nulls docs
* fix: Build with Xcode 26.1
* Revert "fix: Build with Xcode 26.1"
This reverts commit 41d1efea7a.
43 lines
829 B
C++
43 lines
829 B
C++
//
|
|
// Created by Marc Rousavy on 30.07.24.
|
|
//
|
|
|
|
#pragma once
|
|
|
|
#include "NitroDefines.hpp"
|
|
#include <functional>
|
|
#include <type_traits>
|
|
|
|
namespace margelo::nitro {
|
|
|
|
/**
|
|
* Represents the type of `null` - which should always be a singleton.
|
|
*/
|
|
enum class NullType { null };
|
|
|
|
/**
|
|
* Represents an explicit `null` from JS.
|
|
* This is a singleton.
|
|
*/
|
|
inline constexpr NullType null = NullType::null;
|
|
|
|
// Equality and ordering: all instances are equal
|
|
constexpr bool operator==(NullType, NullType) noexcept {
|
|
return true;
|
|
}
|
|
constexpr bool operator!=(NullType, NullType) noexcept {
|
|
return false;
|
|
}
|
|
|
|
} // namespace margelo::nitro
|
|
|
|
// Makes nitro::Null hashable
|
|
namespace std {
|
|
template <>
|
|
struct hash<margelo::nitro::NullType> {
|
|
size_t operator()(margelo::nitro::NullType) const noexcept {
|
|
return 0;
|
|
}
|
|
};
|
|
} // namespace std
|