xo-facet: facet template [WIP]

This commit is contained in:
Roland Conybeare 2025-12-24 19:40:48 -05:00
commit 73c1b54d50
2 changed files with 90 additions and 0 deletions

47
idl/Sequence.json5 Normal file
View file

@ -0,0 +1,47 @@
{
includes: ["<xo/gc/GCObject.hpp>"],
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<AGCObject> at(size_type index) const;
{
name: "at",
doc: ["return element @p index of this sequence"],
return_type: "obj<AGCObject>",
args: [
{type: "size_type", name: "index"},
],
const: true,
noexcept: false,
attributes: [],
},
],
}

View file

@ -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 <xo/gc/GCObject.hpp>
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<AGCObject> at(size_type index) const = 0;
}; /*ASequence*/
} /*namespace scm*/
} /*namespace xo*/