| 1 | #pragma once | ||
| 2 | #include <xs/Hash.h> | ||
| 3 | #include <xs/Stash.h> | ||
| 4 | #include <xs/Simple.h> | ||
| 5 | #include <initializer_list> | ||
| 6 | |||
| 7 | namespace xs { namespace exp { | ||
| 8 | |||
| 9 | struct Constant { | ||
| 10 | using string_view = panda::string_view; | ||
| 11 | string_view name; | ||
| 12 | Sv value; | ||
| 13 | |||
| 14 | 18 | Constant (string_view name, const Sv& val) : name(name), value(val) {} | |
| 15 | Constant (string_view name, string_view val) : name(name), value(Simple(val)) {} | ||
| 16 | Constant (string_view name, int64_t val) : name(name), value(Simple(val)) {} | ||
| 17 | }; | ||
| 18 | |||
| 19 | void create_constant (Stash stash, const Constant& c); | ||
| 20 | |||
| 21 | inline void create_constant (Stash stash, panda::string_view name, const Sv& value) { create_constant(stash, Constant(name, value)); } | ||
| 22 | inline void create_constant (Stash stash, panda::string_view name, panda::string_view value) { create_constant(stash, Constant(name, value)); } | ||
| 23 | inline void create_constant (Stash stash, panda::string_view name, int64_t value) { create_constant(stash, Constant(name, value)); } | ||
| 24 | |||
| 25 | void create_constants (Stash stash, const std::initializer_list<Constant>& l); | ||
| 26 | void create_constants (Stash stash, const Hash& h); | ||
| 27 | void create_constants (Stash stash, SV*const* list, size_t items); | ||
| 28 | |||
| 29 | void register_export (const Stash& stash, panda::string_view name); | ||
| 30 | |||
| 31 | void export_sub (const Stash& from, Stash to, panda::string_view name); | ||
| 32 | void export_constants (const Stash& from, Stash to); | ||
| 33 | |||
| 34 | Array constants_list (const Stash& stash); | ||
| 35 | |||
| 36 | void autoexport (Stash stash); | ||
| 37 | |||
| 38 | }} |