xo-reader2 xo-expression2: define example working and printing
def foo : f64 = 3.141593;
This commit is contained in:
parent
c3907f45df
commit
855cdb08b7
9 changed files with 172 additions and 6 deletions
|
|
@ -11,7 +11,9 @@ set(SELF_SRCS
|
|||
TypeRef.cpp
|
||||
|
||||
IExpression_Any.cpp
|
||||
|
||||
IExpression_DConstant.cpp
|
||||
IPrintable_DConstant.cpp
|
||||
|
||||
IExpression_DVariable.cpp
|
||||
IPrintable_DVariable.cpp
|
||||
|
|
|
|||
|
|
@ -7,12 +7,16 @@
|
|||
#include "TypeDescr.hpp"
|
||||
#include <xo/object2/DFloat.hpp>
|
||||
#include <xo/object2/DInteger.hpp>
|
||||
#include <xo/facet/FacetRegistry.hpp>
|
||||
#include <xo/reflect/Reflect.hpp>
|
||||
#include <xo/printable2/Printable.hpp>
|
||||
#include <xo/reflectutil/typeseq.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::scm::DFloat;
|
||||
using xo::scm::DInteger;
|
||||
using xo::print::APrintable;
|
||||
using xo::facet::FacetRegistry;
|
||||
using xo::reflect::Reflect;
|
||||
using xo::reflect::TypeDescr;
|
||||
using xo::reflect::typeseq;
|
||||
|
|
@ -57,6 +61,20 @@ namespace xo {
|
|||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
DConstant::pretty(const ppindentinfo & ppii) const
|
||||
{
|
||||
obj<APrintable> value
|
||||
= FacetRegistry::instance().variant<APrintable,AGCObject>(value_);
|
||||
|
||||
return ppii.pps()->pretty_struct
|
||||
(ppii,
|
||||
"DConstant",
|
||||
refrtag("value_.tseq", value_._typeseq()),
|
||||
refrtag("value.tseq", value._typeseq()),
|
||||
refrtag("value", value));
|
||||
}
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
|
|
@ -79,11 +79,21 @@ namespace xo {
|
|||
auto rhs = FacetRegistry::instance().try_variant<APrintable,
|
||||
AExpression>(rhs_);
|
||||
|
||||
return ppii.pps()->pretty_struct
|
||||
(ppii,
|
||||
"DDefineExpr",
|
||||
refrtag("lhs", lhs),
|
||||
refrtag("rhs", cond(rhs_, rhs, "nullptr")));
|
||||
// note: xo::print::cond() doesn't resolve the way we want here
|
||||
|
||||
if (rhs) {
|
||||
return ppii.pps()->pretty_struct
|
||||
(ppii,
|
||||
"DDefineExpr",
|
||||
refrtag("lhs", lhs),
|
||||
refrtag("rhs", rhs));
|
||||
} else {
|
||||
return ppii.pps()->pretty_struct
|
||||
(ppii,
|
||||
"DDefineExpr",
|
||||
refrtag("lhs", lhs));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
28
src/expression2/IPrintable_DConstant.cpp
Normal file
28
src/expression2/IPrintable_DConstant.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/** @file IPrintable_DConstant.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DConstant.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IPrintable_DConstant.json5]
|
||||
**/
|
||||
|
||||
#include "detail/IPrintable_DConstant.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IPrintable_DConstant::pretty(const DConstant & self, const ppindentinfo & ppii) -> bool
|
||||
{
|
||||
return self.pretty(ppii);
|
||||
}
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IPrintable_DConstant.cpp */
|
||||
|
|
@ -8,10 +8,15 @@
|
|||
#include <xo/expression2/detail/IGCObject_DUniqueString.hpp>
|
||||
#include <xo/expression2/detail/IPrintable_DUniqueString.hpp>
|
||||
|
||||
#include <xo/expression2/detail/IExpression_DDefineExpr.hpp>
|
||||
#include <xo/expression2/detail/IPrintable_DDefineExpr.hpp>
|
||||
|
||||
#include <xo/expression2/detail/IExpression_DVariable.hpp>
|
||||
#include <xo/expression2/detail/IPrintable_DVariable.hpp>
|
||||
|
||||
#include <xo/expression2/detail/IExpression_DConstant.hpp>
|
||||
#include <xo/expression2/detail/IPrintable_DConstant.hpp>
|
||||
|
||||
#include <xo/gc/detail/AGCObject.hpp>
|
||||
#include <xo/printable2/detail/APrintable.hpp>
|
||||
#include <xo/facet/FacetRegistry.hpp>
|
||||
|
|
@ -32,13 +37,24 @@ namespace xo {
|
|||
FacetRegistry::register_impl<AGCObject, DUniqueString>();
|
||||
FacetRegistry::register_impl<APrintable, DUniqueString>();
|
||||
|
||||
FacetRegistry::register_impl<APrintable, DDefineExpr>();
|
||||
// Expression
|
||||
// +- Constant
|
||||
// +- Variable
|
||||
// \- DefineExpr
|
||||
|
||||
FacetRegistry::register_impl<AExpression, DConstant>();
|
||||
FacetRegistry::register_impl<APrintable, DConstant>();
|
||||
|
||||
FacetRegistry::register_impl<AExpression, DVariable>();
|
||||
FacetRegistry::register_impl<APrintable, DVariable>();
|
||||
|
||||
FacetRegistry::register_impl<AExpression, DDefineExpr>();
|
||||
FacetRegistry::register_impl<APrintable, DDefineExpr>();
|
||||
|
||||
log && log(xtag("DUniqueString.tseq", typeseq::id<DUniqueString>()));
|
||||
log && log(xtag("DDefineExpr.tseq", typeseq::id<DDefineExpr>()));
|
||||
log && log(xtag("DVariable.tseq", typeseq::id<DVariable>()));
|
||||
log && log(xtag("DConstant.tseq", typeseq::id<DConstant>()));
|
||||
|
||||
log && log(xtag("AExpression.tqseq", typeseq::id<AExpression>()));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue