init commit

This commit is contained in:
divorce committed 2026-09-30 19:27:45 -04:00
commit 6300e42bb2
28 files changed
+104005

No files matched your search

+59
View File
@@ -0,0 +1,59 @@
#ifndef ENFILADE_H
#define ENFILADE_H
#define ENSIFER_VERSION "0.1.20"
#include <stddef.h>
#include <stdint.h>
typedef struct enfilade enfilade_t;
typedef enum {
ENF_OK = 0,
ENF_ERR_NULL,
ENF_ERR_ADDR,
ENF_ERR_NOT_FOUND,
ENF_ERR_NOMEM
} enf_error_t;
typedef struct {
enf_error_t code;
const char *msg;
} enf_result_t;
enfilade_t *create_enfilade(void);
void destroy_enfilade(enfilade_t *enf);
/* Store datum at a dotted tumbler address. Missing intermediate children are
* created automatically. Replacing the final datum is allowed. */
enf_result_t put_enfilade(enfilade_t *enf, const char *tumbler, void *datum);
/* Remove only the datum stored at the exact final key. A child subtree at the
* same key is retained. Empty intermediate child nodes are pruned. */
enf_result_t remove_enfilade(enfilade_t *enf, const char *tumbler);
/* Exact terminal value, without descendant traversal. */
void *getXtumbler_enfilade(enfilade_t *enf, const char *tumbler);
/* Resolve a tumbler using the Enfilade.py getByTumbler/get semantics.
* Returns a newly allocated array of datum pointers. Caller frees the array;
* the datum pointers remain owned by the application/S7. */
enf_result_t getXtumbler_values_enfilade(enfilade_t *enf,
const char *tumbler,
void ***items,
size_t *count);
/* Flatten all values in numeric key order for the inclusive range. A negative
* end means "everything", matching the Python default end=-1. */
enf_result_t getXrange_values_enfilade(enfilade_t *enf,
int64_t start,
int64_t end,
void ***items,
size_t *count);
typedef void (*enfilade_datum_visitor)(void *datum, void *context);
void enfilade_visit_data(enfilade_t *enf,
enfilade_datum_visitor visitor,
void *context);
#endif /* ENFILADE_H */
+8
View File
@@ -0,0 +1,8 @@
#ifndef ENSIFER_ENFILADE_S7_H
#define ENSIFER_ENFILADE_S7_H
#include "s7.h"
void init_enfilade_s7(s7_scheme *sc);
#endif /* ENSIFER_ENFILADE_S7_H */
+1240
View File
File diff suppressed because it is too large. Load diff
+60
View File
@@ -0,0 +1,60 @@
#ifndef TUMBLER_H
#define TUMBLER_H
#include <stddef.h>
#include <stdint.h>
typedef struct {
uint64_t *digits;
size_t count;
} tumbler_t;
typedef enum {
TUMBLER_OK = 0,
TUMBLER_ERR_NULL,
TUMBLER_ERR_INVALID,
TUMBLER_ERR_NOMEM,
TUMBLER_ERR_OVERFLOW,
TUMBLER_ERR_UNDERFLOW
} tumbler_error_t;
typedef struct {
tumbler_error_t code;
const char *msg;
} tumbler_result_t;
/* Parse the dotted decimal representation into a heap-owned tumbler.
* On success, caller owns out->digits and must call tumbler_free(). */
tumbler_result_t tumbler_parse(const char *text, tumbler_t *out);
void tumbler_free(tumbler_t *t);
/* Format a tumbler as a newly allocated dotted decimal string.
* Caller frees the returned string. */
tumbler_result_t tumbler_to_string(const tumbler_t *t, char **out);
/* Whole-tumbler numeric ordering. Missing fields compare as zero, so
* 1 < 1.1 < 1.1.1 and trailing zero fields do not affect ordering. */
int tumbler_compare(const tumbler_t *a, const tumbler_t *b);
/* Xanadu tumbler addition: position + offset. */
tumbler_result_t tumbler_add(const tumbler_t *position,
const tumbler_t *offset,
tumbler_t *out);
/* Strong and weak tumbler subtraction, as described in the historical
* Xanadu material. Both require non-negative results at their first
* differing field. */
tumbler_result_t tumbler_subtract_strong(const tumbler_t *position,
const tumbler_t *offset,
tumbler_t *out);
tumbler_result_t tumbler_subtract_weak(const tumbler_t *position,
const tumbler_t *offset,
tumbler_t *out);
/* Generalized tumbler difference used by the Xanadu system:
* if a > b, strong-subtract b from a; otherwise weak-subtract a from b. */
tumbler_result_t tumbler_subtract(const tumbler_t *a,
const tumbler_t *b,
tumbler_t *out);
#endif /* TUMBLER_H */