Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ca-c-api.h
Go to the documentation of this file.
1/*
2 Aleph_w
3
4 Data structures & Algorithms
5 https://github.com/lrleon/Aleph-w
6
7 This file is part of Aleph-w library
8
9 Copyright (c) 2002-2026 Leandro Rabindranath Leon
10
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is
16 furnished to do so, subject to the following conditions:
17
18 The above copyright notice and this permission notice shall be included in all
19 copies or substantial portions of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 SOFTWARE.
28*/
29
30/*
31 * ca-c-api.h — Phase 25: flat C ABI for the cellular-automata module.
32 *
33 * A pure C (C99) header exposing a minimal, stable surface so that any
34 * language with a C FFI (Rust, Julia, Go, .NET, Python/ctypes, ...) can drive
35 * an Aleph-w cellular automaton without touching C++.
36 *
37 * STABILITY: experimental until v2.1 of the module. Every function carries a
38 * `_v1` suffix so a future incompatible revision can coexist (`_v2`).
39 *
40 * THREADING: error state is thread-local. Distinct engine handles may be used
41 * from distinct threads concurrently; a single handle is not thread-safe.
42 *
43 * OWNERSHIP: the caller owns every handle returned by a `create_*` function
44 * and must release it with the matching `destroy` function.
45 */
46
47#ifndef ALEPH_CA_C_API_H
48#define ALEPH_CA_C_API_H
49
50#include <stddef.h>
51#include <stdint.h>
52
53#ifdef __cplusplus
54extern "C" {
55#endif
56
57#if defined(_WIN32) || defined(__CYGWIN__)
58# if defined(ALEPH_CA_C_API_BUILD)
59# define ALEPH_CA_API __declspec(dllexport)
60# else
61# define ALEPH_CA_API __declspec(dllimport)
62# endif
63#else
64# define ALEPH_CA_API __attribute__((visibility("default")))
65#endif
66
67/* ABI version. Bump MINOR for additive changes, MAJOR for breaking ones. */
68#define ALEPH_CA_API_VERSION_MAJOR 1
69#define ALEPH_CA_API_VERSION_MINOR 0
70
71/* Error codes returned by the integer-returning functions. */
72typedef enum aleph_ca_status
73{
74 ALEPH_CA_OK = 0, /* success */
75 ALEPH_CA_ERR_NULL = 1, /* a required pointer argument was NULL */
76 ALEPH_CA_ERR_RANGE = 2, /* coordinate or size out of range */
77 ALEPH_CA_ERR_ALLOC = 3, /* allocation / construction failed */
78 ALEPH_CA_ERR_INTERNAL = 4 /* a C++ exception crossed the boundary */
80
81/* Opaque handles. */
83
84/* ------------------------------------------------------------------ */
85/* Version & error reporting */
86/* ------------------------------------------------------------------ */
87
90
93
97
98/* ------------------------------------------------------------------ */
99/* Game of Life engine */
100/* ------------------------------------------------------------------ */
101
105 size_t cols);
106
109
112 size_t *rows, size_t *cols);
113
116 size_t col, int32_t value);
117
120 size_t row, size_t col, int32_t *out);
121
124
127
131 int32_t *out, size_t out_len);
132
135
136#ifdef __cplusplus
137} /* extern "C" */
138#endif
139
140#endif /* ALEPH_CA_C_API_H */
aleph_ca_engine_t * aleph_ca_create_gol_engine_v1(size_t rows, size_t cols)
Definition ca-c-api.cc:108
int aleph_ca_copy_frame_v1(const aleph_ca_engine_t *engine, int32_t *out, size_t out_len)
Definition ca-c-api.cc:247
void aleph_ca_destroy_engine_v1(aleph_ca_engine_t *engine)
Definition ca-c-api.cc:138
int aleph_ca_extents_v1(const aleph_ca_engine_t *engine, size_t *rows, size_t *cols)
Definition ca-c-api.cc:143
int aleph_ca_step_v1(aleph_ca_engine_t *engine)
Definition ca-c-api.cc:199
int aleph_ca_set_cell_v1(aleph_ca_engine_t *engine, size_t row, size_t col, int32_t value)
Definition ca-c-api.cc:157
int aleph_ca_run_v1(aleph_ca_engine_t *engine, size_t steps)
Definition ca-c-api.cc:223
int aleph_ca_last_error_v1(void)
Definition ca-c-api.cc:98
const char * aleph_ca_error_message_v1(void)
Definition ca-c-api.cc:103
int aleph_ca_get_cell_v1(const aleph_ca_engine_t *engine, size_t row, size_t col, int32_t *out)
Definition ca-c-api.cc:178
size_t aleph_ca_steps_run_v1(const aleph_ca_engine_t *engine)
Definition ca-c-api.cc:272
uint32_t aleph_ca_api_version_v1(void)
Definition ca-c-api.cc:92
int32_t size_t out_len
Definition ca-c-api.h:131
size_t steps
Definition ca-c-api.h:126
size_t size_t int32_t value
Definition ca-c-api.h:116
size_t size_t int32_t * out
Definition ca-c-api.h:120
#define ALEPH_CA_API
Definition ca-c-api.h:64
size_t row
Definition ca-c-api.h:115
size_t * rows
Definition ca-c-api.h:112
size_t size_t col
Definition ca-c-api.h:116
aleph_ca_status
Definition ca-c-api.h:73
@ ALEPH_CA_ERR_ALLOC
Definition ca-c-api.h:77
@ ALEPH_CA_ERR_NULL
Definition ca-c-api.h:75
@ ALEPH_CA_OK
Definition ca-c-api.h:74
@ ALEPH_CA_ERR_INTERNAL
Definition ca-c-api.h:78
@ ALEPH_CA_ERR_RANGE
Definition ca-c-api.h:76
size_t cols
Definition ca-c-api.h:105
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Definition Blossom.H:466
static mt19937 engine