xo-object2: APrintable+DFloat
This commit is contained in:
parent
a5916b1f48
commit
8ff8436e9b
3 changed files with 25 additions and 11 deletions
|
|
@ -236,12 +236,15 @@ def gen_facet_impl(env,
|
|||
|
||||
# facet_includes: include section for AFoo.hpp:
|
||||
# <xo/gc/GCObject.hpp>
|
||||
facet_includes = facet_idl['includes']
|
||||
#facet_includes = facet_idl['includes']
|
||||
facet_includes = idl['includes']
|
||||
|
||||
# <xo/printable2/Printable.hpp>
|
||||
# sequence
|
||||
facet_detail_subdir = facet_idl['detail_subdir']
|
||||
# xo - facet_ns1: outer namespace for facet [e.g. xo]
|
||||
facet_ns1 = facet_idl['namespace1']
|
||||
# scm - facet_ns2: nested namespace for facet [e.g. scm]
|
||||
# facet_ns2: nested namespace for facet [print]
|
||||
facet_ns2 = facet_idl['namespace2']
|
||||
|
||||
# Sequence - facet_name: facet name
|
||||
|
|
@ -431,6 +434,8 @@ def gen_facet_impl(env,
|
|||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--input', required=True, help='input IDL JSON5 file')
|
||||
# --facet-dir: only with mode=implementation
|
||||
parser.add_argument('--facet-dir', required=False, help='base dir for facet json')
|
||||
# --output-impl-hpp: putting this in .json5, will be able to drop this.
|
||||
parser.add_argument('--output-impl-hpp', required=True, help='.hpp detail subdir')
|
||||
parser.add_argument('--output-hpp', required=True, help='.hpp output directory')
|
||||
|
|
@ -485,7 +490,10 @@ def main():
|
|||
#output_impl_hpp_dir=output_impl_hpp_dir,
|
||||
output_cpp_dir=output_cpp_dir)
|
||||
elif idl['mode'] == 'implementation':
|
||||
facet_idl_fname = idl['facet_idl']
|
||||
# idl: json5 for (iface, data) combination
|
||||
# facet: json5 for abstract iface
|
||||
|
||||
facet_idl_fname = args.facet_dir + '/' + idl['facet_idl']
|
||||
facet_idl = load_idl(facet_idl_fname)
|
||||
|
||||
gen_facet_impl(env=env,
|
||||
|
|
@ -493,7 +501,7 @@ def main():
|
|||
idl=idl,
|
||||
facet_idl=facet_idl,
|
||||
output_hpp_dir=output_hpp_dir,
|
||||
output_impl_hpp_dir=output_impl_hpp_dir,
|
||||
output_impl_hpp_subdir=output_impl_hpp_subdir,
|
||||
output_cpp_dir=output_cpp_dir)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -13,8 +13,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "{{facet_hpp_fname}}"
|
||||
#include "{{facet_detail_subdir}}/{{iface_facet_xfer_hpp_fname}}"
|
||||
{% for include_fname in facet_includes %}
|
||||
#include {{include_fname}}
|
||||
{% endfor %}
|
||||
#include "{{data_repr_hpp_fname}}"
|
||||
|
||||
namespace {{repr_ns1}} { namespace {{repr_ns2}} { class {{iface_facet_repr}}; } }
|
||||
|
|
@ -43,7 +44,7 @@ namespace {{repr_ns1}} {
|
|||
///@{
|
||||
{% endif %}
|
||||
{% for ty in types %}
|
||||
using {{ty.name}} = {{abstract_facet}}::{{ty.name}};
|
||||
using {{ty.name}} = {{facet_ns1}}::{{facet_ns2}}::{{abstract_facet}}::{{ty.name}};
|
||||
{% endfor %}
|
||||
{% if using_dox %}
|
||||
///@}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "{{abstract_facet_fname}}"
|
||||
{% for include_fname in facet_includes %}
|
||||
#include {{include_fname}}
|
||||
{% endfor %}
|
||||
|
||||
namespace {{facet_ns1}} {
|
||||
namespace {{facet_ns2}} {
|
||||
|
|
@ -26,7 +28,10 @@ namespace {{facet_ns2}} {
|
|||
/** @defgroup {{facet_ns2}}-{{facet_name_lc}}-xfer-type-traits **/
|
||||
///@{
|
||||
{% endif %}
|
||||
/** actual implementation (not generated; often delegates to DRepr) **/
|
||||
using Impl = {{iface_facet}}_DRepr;
|
||||
/** integer identifying a type **/
|
||||
using typeseq = {{abstract_facet}}::typeseq;
|
||||
{% for ty in types %}
|
||||
using {{ty.name}} = {{abstract_facet}}::{{ty.name}};
|
||||
{% endfor %}
|
||||
|
|
@ -45,7 +50,7 @@ namespace {{facet_ns2}} {
|
|||
// from {{abstract_facet}}
|
||||
|
||||
// const methods
|
||||
int32_t _typeseq() const noexcept override { return s_typeseq; }
|
||||
typeseq _typeseq() const noexcept override { return s_typeseq; }
|
||||
{% for md in const_methods %}
|
||||
{{md.return_type}} {{md.name}}({{md.args | args}}) {{md | qualifiers}} override {
|
||||
return I::{{md.name}}({{md.args | argnames}});
|
||||
|
|
@ -73,7 +78,7 @@ namespace {{facet_ns2}} {
|
|||
{% endif %}
|
||||
|
||||
/** typeseq for template parameter DRepr **/
|
||||
static int32_t s_typeseq;
|
||||
static typeseq s_typeseq;
|
||||
/** true iff satisfies facet implementation **/
|
||||
static bool _valid;
|
||||
|
||||
|
|
@ -83,7 +88,7 @@ namespace {{facet_ns2}} {
|
|||
};
|
||||
|
||||
template <typename DRepr, typename {{iface_facet}}_DRepr>
|
||||
int32_t
|
||||
xo::facet::typeseq
|
||||
{{iface_facet_xfer}}<DRepr, {{iface_facet}}_DRepr>::s_typeseq
|
||||
= xo::facet::typeseq::id<DRepr>();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue