xo-printjson: bugfix: adjust for upstream changes:

xo::ref::rp -> xo::rp
xo::quoted -> xo::quot
new reflection metatype mt_function
This commit is contained in:
Roland Conybeare 2024-09-14 12:09:06 -05:00
commit cac526a517
2 changed files with 12 additions and 6 deletions

View file

@ -41,7 +41,7 @@ namespace xo {
/* convenience -- shorthand for
* .print(obj->self_tp(), p_os)
*/
void print_obj(ref::rp<SelfTagging> const & obj, std::ostream * p_os) const;
void print_obj(rp<SelfTagging> const & obj, std::ostream * p_os) const;
void provide_printer(TypeId id, std::unique_ptr<JsonPrinter> p) {
*(printer_map_.require(id)) = std::move(p);
@ -74,13 +74,13 @@ namespace xo {
*/
class PrintJsonSingleton {
public:
static ref::rp<PrintJson> instance();
static rp<PrintJson> instance();
private:
/* we don't need this to be stored as pointer.
* memory burned if unused will be one empty std::vector<>
*/
static ref::rp<PrintJson> s_instance;
static rp<PrintJson> s_instance;
}; /*PrintJsonSingleton*/
} /*namespace json*/

View file

@ -17,9 +17,8 @@ namespace xo {
using xo::reflect::TypeDescr;
using xo::reflect::TaggedPtr;
using xo::reflect::TaggedRcptr;
using xo::print::quoted;
using xo::print::quot;
using xo::time::iso8601;
using xo::ref::rp;
using xo::xtag;
namespace json {
@ -153,6 +152,13 @@ namespace xo {
case Metatype::mt_struct:
print_generic_struct(*this, tp, p_os);
return;
case Metatype::mt_function:
/** new branch (added for xo-expression / xo-jit) **/
(*p_os) << "<error-json-printer-not-implemented"
<< xtag("type", tp.td()->canonical_name())
<< xtag("metatype", tp.td()->metatype())
<< ">";
return;
case Metatype::mt_invalid:
case Metatype::mt_atomic:
break;
@ -340,7 +346,7 @@ namespace xo {
if (x) {
/* TODO: escapes special characters */
*p_os << quoted(*x);
*p_os << quot(*x);
} else {
report_internal_type_consistency_error(Reflect::require<T>(),
tp.td(),