From a62173ada673c178ce59924aaa2105c5fe0c2b67 Mon Sep 17 00:00:00 2001 From: Stephen Lane-Walsh Date: Thu, 2 Jul 2026 11:55:55 -0400 Subject: [PATCH] Feature: Add TDI TreeShr functions used by mdsthin When implementing the thin Tree class for mdsthin, I needed these functions from the TDI stdlib. Currently, they're implemented on the fly when called, but they should be added to the stdlib so other things can use them. TreeFindNodeWildRelative operates much like TreeFindNodeWild, but relative to a node TreeGetRecordSerialized returns the serialized data for a node TreeDecompileRecord returns the decompiled data for a node Once these are included, mdsthin can check the server version and only implement them on the fly as needed --- tdi/treeshr/TreeDecompileRecord.fun | 7 +++++++ tdi/treeshr/TreeFindNodeWildRelative.fun | 17 +++++++++++++++++ tdi/treeshr/TreeGetRecordSerialized.fun | 7 +++++++ 3 files changed, 31 insertions(+) create mode 100644 tdi/treeshr/TreeDecompileRecord.fun create mode 100644 tdi/treeshr/TreeFindNodeWildRelative.fun create mode 100644 tdi/treeshr/TreeGetRecordSerialized.fun diff --git a/tdi/treeshr/TreeDecompileRecord.fun b/tdi/treeshr/TreeDecompileRecord.fun new file mode 100644 index 0000000000..0358849676 --- /dev/null +++ b/tdi/treeshr/TreeDecompileRecord.fun @@ -0,0 +1,7 @@ +/* FOR INTERNAL USE ONLY */ +public fun TreeDecompileRecord(in _nid) +{ + _out = 1; + _status = TreeShr->TreeGetRecord(val(_nid), xd(_out)); + return(execute("decompile(`_out)")); +}; diff --git a/tdi/treeshr/TreeFindNodeWildRelative.fun b/tdi/treeshr/TreeFindNodeWildRelative.fun new file mode 100644 index 0000000000..55be624cc4 --- /dev/null +++ b/tdi/treeshr/TreeFindNodeWildRelative.fun @@ -0,0 +1,17 @@ +/* FOR INTERNAL USE ONLY */ +public fun TreeFindNodeWildRelative(in _path, in _startnid, optional _usagemask) +{ + _ctx = 0q; + _nid = 0; + _nids = []; + if (!present(_usagemask)) _usagemask = -1; + while (TreeShr->TreeFindNodeWildRelative(_path, val(_startnid), ref(_nid), ref(_ctx), val(_usagemask)) & 1) { + if (size(_nids) > 0) { + _nids = [_nids, _nid]; + } else { + _nids = [_nid]; + } + }; + TreeShr->TreeFindNodeEnd(_ctx); + return(_nids); +}; \ No newline at end of file diff --git a/tdi/treeshr/TreeGetRecordSerialized.fun b/tdi/treeshr/TreeGetRecordSerialized.fun new file mode 100644 index 0000000000..c153027fdf --- /dev/null +++ b/tdi/treeshr/TreeGetRecordSerialized.fun @@ -0,0 +1,7 @@ +/* FOR INTERNAL USE ONLY */ +public fun TreeGetRecordSerialized(in _nid) +{ + _out = 1; + _status = TreeShr->TreeGetRecord(val(_nid), xd(_out)); + return(execute("SerializeOut(`_out)")); +};