tinyblocks-api (gestor publico de modulos/libraries): - registry de modulos (embutidos + .so), load/unload/reload via dlopen, hot reload por mtime e introspeccao de tipos de bloco. - substitui a logica de hotlib duplicada no editor. tinyblocks-libman (gestor/buscador de libraries): - varre library.toml (libraries/ e ~/.tinyblocks/libraries), le metadados de forma RECURSIVA e resolve o caminho do .so/.a. - busca por texto e filtro por categoria; consulta o estado de carga na api. Editor: tela cheia "Escolha uma Extensão" (UI desenhada pelo editor, como no Scratch): botao Bibliotecas / Ctrl+L, busca, chips de categoria que quebram linha, grade de cartoes com faixa colorida e selo "carregada"; clicar carrega o .so via api. Respeito a interfaces publicas entre libraries: - libman deixa de incluir o ast.h (interno) do tinyblocks-toml e passa a usar uma API publica e opaca: tb_toml_open/close/str/int/int_array. - core ganha accessors publicos: tb_rt_type_count/at, tb_rt_library_count/at, tb_library_name/category/block_count; api e editor usam-nos em vez de ler campos de struct do core diretamente. Testes: make test-libman (novo) + step no harness que abre o libman, busca, carrega um .so e confirma a categoria na paleta. test-editor/toml/blueprint/ plugin seguem OK.
79 lines
2.0 KiB
C
79 lines
2.0 KiB
C
/*
|
|
* TinyBlocks - tinyblocks-toml
|
|
* ast.h: arvore sintatica e leitura de documentos TOML.
|
|
*/
|
|
#ifndef TB_TOML_AST_H
|
|
#define TB_TOML_AST_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdbool.h>
|
|
#include "lexeme.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef enum {
|
|
TOML_STRING,
|
|
TOML_INTEGER,
|
|
TOML_FLOAT,
|
|
TOML_BOOL,
|
|
TOML_DATETIME,
|
|
TOML_ARRAY,
|
|
TOML_TABLE
|
|
} TomlValueKind;
|
|
|
|
typedef struct TomlValue TomlValue;
|
|
typedef struct TomlKeyVal TomlKeyVal;
|
|
|
|
struct TomlKeyVal {
|
|
char* key;
|
|
TomlValue* value;
|
|
TomlKeyVal* next;
|
|
};
|
|
|
|
struct TomlValue {
|
|
TomlValueKind kind;
|
|
int line, col;
|
|
union {
|
|
char* string;
|
|
long long integer;
|
|
double real;
|
|
bool boolean;
|
|
struct { TomlValue** items; size_t count, cap; } array;
|
|
struct { TomlKeyVal* head, *tail; size_t count; } table;
|
|
} as;
|
|
};
|
|
|
|
typedef struct TomlDoc {
|
|
TomlValue* root; /* tabela raiz */
|
|
} TomlDoc;
|
|
|
|
/* Parser (texto em memoria / arquivo). Em erro preenche err. */
|
|
TomlDoc* toml_parse(const char* src, TomlLexError* err);
|
|
TomlDoc* toml_parse_file(const char* path, TomlLexError* err);
|
|
void toml_free(TomlDoc* doc);
|
|
|
|
/* Navegacao */
|
|
const TomlValue* toml_table_get(const TomlValue* table, const char* key);
|
|
const TomlValue* toml_path_get(const TomlValue* root, const char* dotted);
|
|
const TomlValue* toml_array_get(const TomlValue* arr, size_t i);
|
|
size_t toml_array_count(const TomlValue* arr);
|
|
size_t toml_table_count(const TomlValue* table);
|
|
const TomlKeyVal* toml_table_head(const TomlValue* table);
|
|
|
|
/* Conversoes com valor padrao */
|
|
const char* toml_as_string(const TomlValue* v, const char* def);
|
|
long long toml_as_int(const TomlValue* v, long long def);
|
|
double toml_as_float(const TomlValue* v, double def);
|
|
bool toml_as_bool(const TomlValue* v, bool def);
|
|
|
|
/* Escreve a arvore em stdout (debug) */
|
|
void toml_dump(const TomlValue* v, int indent);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* TB_TOML_AST_H */
|