Adiciona tinyblocks-blueprint e libraries json/xml/csv; abrir/salvar/exportar projeto
- tinyblocks-blueprint: dona do estado de edicao (abas, pool de blocos, vinculos parent/prel/next/sub/args, blocos compostos e variaveis) e da serializacao. JSON nativo (to/from) usando a AST JSON do core e export JSON/XML/CSV. Testado com round-trip (test-blueprint). - tinyblocks-json: lexer + parser + emissor JSON independentes. - tinyblocks-xml: lexer + parser de XML -> AST JSON do core + emissor. - tinyblocks-csv: divisor de linhas/campos + parser/emissor sobre a AST JSON. - Editor: botoes Abrir / Salvar / Exportar JSON XML CSV no menu; converte Ed <-> TbBlueprint; barra de caminho com modo; .json pode ser arrastado. - Variaveis: tb_variables_clear e tb_variables_set_text. - Harness: teste de salvar/abrir projeto; tests/blueprint_test.c.
This commit is contained in:
1 parent
dc23b92d15
commit
1199d2d7c7
39 files changed
+3462
-24
No files matched your search
@@ -18,4 +18,10 @@ TB_API const TinyBlocks_Value* tb_variables_value(int i); /* emprestado */
|
||||
/* Zera variáveis que guardam blocos (chamado antes de uma nova execução) */
|
||||
TB_API void tb_variables_reset_blocks(void);
|
||||
|
||||
/* Remove todas as variáveis. */
|
||||
TB_API void tb_variables_clear(void);
|
||||
|
||||
/* Define uma variável a partir de texto (interpreta inteiro/real; senão texto). */
|
||||
TB_API void tb_variables_set_text(const char* name, const char* value);
|
||||
|
||||
#endif /* TINYBLOCKS_VARIABLES_H */
|
||||
@@ -99,6 +99,25 @@ void tb_variables_reset_blocks(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void tb_variables_clear(void) {
|
||||
for (int i = 0; i < s_n; i++) tb_value_free(&s_vars[i].val);
|
||||
s_n = 0;
|
||||
}
|
||||
|
||||
void tb_variables_set_text(const char* name, const char* value) {
|
||||
if (!name || !name[0]) return;
|
||||
int i = var_find(name, true);
|
||||
if (i < 0) return;
|
||||
tb_value_free(&s_vars[i].val);
|
||||
const char* s = value ? value : "";
|
||||
char* end = NULL;
|
||||
long long iv = strtoll(s, &end, 10);
|
||||
if (end && *end == 0 && end != s) { s_vars[i].val = tb_value_integer(iv); return; }
|
||||
double dv = strtod(s, &end);
|
||||
if (end && *end == 0 && end != s) { s_vars[i].val = tb_value_real(dv); return; }
|
||||
s_vars[i].val = tb_value_text(s);
|
||||
}
|
||||
|
||||
/* == Registro === */
|
||||
static bool variables_init(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib) {
|
||||
static const TinyBlocks_Category cat = {
|
||||
|
||||
Reference in new issue
Block a user