Skip to content

Commit

Permalink
fwd: Add ASTERIA_TYPES_AIXE9XIG_() and explicit instantions
Browse files Browse the repository at this point in the history
  • Loading branch information
lhmouse committed Feb 25, 2024
1 parent 68e6376 commit 45831ef
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
26 changes: 14 additions & 12 deletions asteria/fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,18 +621,20 @@ using optV_function = V_function;
using optV_array = opt<V_array>;
using optV_object = opt<V_object>;

enum Type : uint8_t
{
type_null = 0,
type_boolean = 1,
type_integer = 2,
type_real = 3,
type_string = 4,
type_opaque = 5,
type_function = 6,
type_array = 7,
type_object = 8,
};
// Expand a sequence of types without a trailing comma. This macro is part
// of the ABI.
#define ASTERIA_TYPES_AIXE9XIG_(U) \
/* 0 */ U##_null, \
/* 1 */ U##_boolean, \
/* 2 */ U##_integer, \
/* 3 */ U##_real, \
/* 4 */ U##_string, \
/* 5 */ U##_opaque, \
/* 6 */ U##_function, \
/* 7 */ U##_array, \
/* 8 */ U##_object

enum Type : uint8_t { ASTERIA_TYPES_AIXE9XIG_(type) };

ROCKET_CONST
const char*
Expand Down
5 changes: 5 additions & 0 deletions asteria/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
#include "llds/variable_hashmap.hpp"
#include "../rocket/linear_buffer.hpp"
#include "../rocket/tinyfmt_file.hpp"
template class ::rocket::variant<ASTERIA_TYPES_AIXE9XIG_(::asteria::V)>;
template class ::rocket::optional<::asteria::Value>;
template class ::rocket::cow_vector<::asteria::Value>;
template class ::rocket::cow_hashmap<::asteria::phsh_string,
::asteria::Value, ::asteria::phsh_string::hash>;
namespace asteria {
namespace {

Expand Down
8 changes: 6 additions & 2 deletions asteria/value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class Value
typename ::rocket::remove_cvref<xValue>::type>;

using variant_type = ::rocket::variant<
V_null, V_boolean, V_integer, V_real, V_string,
V_opaque, V_function, V_array, V_object>;
ASTERIA_TYPES_AIXE9XIG_(V)>;

using bytes_type = ::std::aligned_storage<
sizeof(variant_type), 16>::type;
Expand Down Expand Up @@ -394,4 +393,9 @@ operator<<(tinyfmt& fmt, const Value& value)
{ return value.print_to(fmt); }

} // namespace asteria
extern template class ::rocket::variant<ASTERIA_TYPES_AIXE9XIG_(::asteria::V)>;
extern template class ::rocket::optional<::asteria::Value>;
extern template class ::rocket::cow_vector<::asteria::Value>;
extern template class ::rocket::cow_hashmap<::asteria::phsh_string,
::asteria::Value, ::asteria::phsh_string::hash>;
#endif

0 comments on commit 45831ef

Please sign in to comment.