Adiciona tinyblocks-api, tinyblocks-libman e a tela "Escolha uma Extensão"
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.
This commit is contained in:
1 parent
f616503caa
commit
dcc20985c5
20 files changed
+1143
-112
No files matched your search
@@ -8,6 +8,8 @@
|
||||
|
||||
#include <tinyblocks/tinyblocks.h>
|
||||
#include "tb_toml.h"
|
||||
#include "ast.h" /* interno a tinyblocks-toml */
|
||||
#include "lexeme.h"
|
||||
|
||||
#define CAT_COLOR 0.62f, 0.44f, 0.86f, 1.f
|
||||
#define CAT_DARK 0.49f, 0.33f, 0.70f, 1.f
|
||||
@@ -76,3 +78,44 @@ const char* tb_toml_file_get(const char* path, const char* dotted, const char* d
|
||||
toml_free(doc);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* -- Documento via interface publica (opaca) --- */
|
||||
TbTomlDoc* tb_toml_open(const char* path) {
|
||||
TomlLexError err;
|
||||
return (TbTomlDoc*)toml_parse_file(path, &err);
|
||||
}
|
||||
|
||||
void tb_toml_close(TbTomlDoc* doc) {
|
||||
toml_free((TomlDoc*)doc);
|
||||
}
|
||||
|
||||
const char* tb_toml_str(const TbTomlDoc* doc, const char* dotted, const char* def) {
|
||||
static char buf[256];
|
||||
if (!doc) return def;
|
||||
const TomlValue* v = toml_path_get(((const TomlDoc*)doc)->root, dotted);
|
||||
if (!v) return def;
|
||||
value_to_text(v, buf, sizeof(buf));
|
||||
return buf;
|
||||
}
|
||||
|
||||
long long tb_toml_int(const TbTomlDoc* doc, const char* dotted, long long def) {
|
||||
if (!doc) return def;
|
||||
const TomlValue* v = toml_path_get(((const TomlDoc*)doc)->root, dotted);
|
||||
return v ? toml_as_int(v, def) : def;
|
||||
}
|
||||
|
||||
int tb_toml_int_array(const TbTomlDoc* doc, const char* dotted,
|
||||
int* out, int max, int def) {
|
||||
for (int i = 0; i < max; i++) out[i] = def;
|
||||
if (!doc) return 0;
|
||||
const TomlValue* v = toml_path_get(((const TomlDoc*)doc)->root, dotted);
|
||||
if (!v || v->kind != TOML_ARRAY) return 0;
|
||||
size_t cnt = toml_array_count(v);
|
||||
int n = 0;
|
||||
for (int i = 0; i < max && (size_t)i < cnt; i++) {
|
||||
const TomlValue* it = toml_array_get(v, (size_t)i);
|
||||
if (it) out[i] = (int)toml_as_int(it, def);
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
Reference in new issue
Block a user