updated README and a bunch of other stuff

This commit is contained in:
Sebastian Moser
2026-11-04 20:24:14 +01:00
parent 6eedb1826a
commit 9707286375
46 changed files with 3725 additions and 172 deletions

61
core/src/include/mize.h Normal file
View File

@@ -0,0 +1,61 @@
#pragma once
/**
* Mize C API — thin header over libmize.so exports (core/src/c_api.rs).
*
* Names for opt / method / thread / get_config / set_config are absolute
* dotted paths for now (e.g. "vicinae.open", "vicinae.nav").
*
* Errors: thread-local, like errno. Call set_err("...") from C; Rust
* (load_part / method wrappers) turns that into Err. Part entry is
* `void part_<name>(void)` — no sret / Result return.
*
* ItemData (`DATA`) is opaque. Ownership:
* - Callbacks receive a borrowed `args` (do not free).
* - Callbacks must return an owned DATA* (e.g. data_new()); may return NULL for empty.
* - get_config returns owned DATA*; free with data_free.
* - set_config takes ownership of the value pointer.
*/
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ItemData DATA;
/** C method / thread / effect callback. args is borrowed; return owned DATA* or NULL. */
typedef DATA *(*CFun)(DATA *args);
void opt(const char *name);
void method(const char *name, const char *signature, CFun c_fun);
void effect(const char *name, CFun c_fun);
void thread(const char *name, CFun c_fun);
void set_config(const char *name, DATA *value);
DATA *get_config(const char *name);
DATA *data_new(void);
/** Store an opaque pointer in the native-value registry. */
DATA *data_from_native(void *ptr);
/** Read back a pointer previously stored with data_from_native. Returns NULL on error. */
void *data_as_native(DATA *data);
void data_free(DATA *data);
void mize_write_stdout(const char *str);
/** Set the thread-local error message (consumed by Rust after the call). */
void set_err(const char *msg);
#ifdef __cplusplus
}
#endif