From 73c1b54d5036cb87eaf615c78d34a733fe6b047b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 24 Dec 2025 19:40:48 -0500 Subject: [PATCH] xo-facet: facet template [WIP] --- idl/Sequence.json5 | 47 ++++++++++++++++++++++++++++++++ include/xo/object2/ASequence.hpp | 43 +++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 idl/Sequence.json5 create mode 100644 include/xo/object2/ASequence.hpp diff --git a/idl/Sequence.json5 b/idl/Sequence.json5 new file mode 100644 index 0000000..a0dc001 --- /dev/null +++ b/idl/Sequence.json5 @@ -0,0 +1,47 @@ +{ + includes: [""], + namespace1: "xo", + namespace2: "scm", + facet: "Sequence", + brief: "an ordered collection of variants", + doc: [ + "Elements appear in some determinstic order.", + "Sequence is GC-aware --> elements must be GC-aware" + ], + methods: [ + // bool is_empty() const noexcept + { + name: "is_empty", + doc: ["true iff sequence is empty"], + return_type: "bool", + args: [], + const: true, + noexcept: true, + attributes: [], + }, + + // bool is_finite() const noexcept + { + name: "is_finite", + doc: ["true iff sequence is finite"], + return_type: "bool", + args: [], + const: true, + noexcept: true, + attributes: [], + }, + + // obj at(size_type index) const; + { + name: "at", + doc: ["return element @p index of this sequence"], + return_type: "obj", + args: [ + {type: "size_type", name: "index"}, + ], + const: true, + noexcept: false, + attributes: [], + }, + ], +} diff --git a/include/xo/object2/ASequence.hpp b/include/xo/object2/ASequence.hpp new file mode 100644 index 0000000..db12e6b --- /dev/null +++ b/include/xo/object2/ASequence.hpp @@ -0,0 +1,43 @@ +/** @file ASequence.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet.py] + * arguments: + * --input [./idl/Sequence.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [abstract_facet.hpp.j2] + * 3. idl for facet methods + * [./idl/Sequence.json5] + **/ + +#pragma once + +// includes (via {facet_includes}) +#include + +namespace xo { +namespace scm { + +/** +Elements appear in some determinstic order. +Sequence is GC-aware --> elements must be GC-aware +**/ +class ASequence { +public: + + /** true iff sequence is empty **/ + virtual bool is_empty() const noexcept = 0; + + + /** true iff sequence is finite **/ + virtual bool is_finite() const noexcept = 0; + + + /** return element @p index of this sequence **/ + virtual obj at(size_type index) const = 0; + +}; /*ASequence*/ + +} /*namespace scm*/ +} /*namespace xo*/ \ No newline at end of file