Entradas convertidas no core: fim dos helpers de conversão repetidos

- tb_block_input_text / _number / _integer / _truthy: a entrada do bloco
  já convertida, despachando pela classe do valor. O texto de um valor
  que não é texto fica em cache na conexão (sem buffers nos blocos).
- Saída com nome terminado em '?' vira o traço TB_SLOT_BOOLEAN na criação
  do tipo (a convenção mora num lugar só; o editor só lê traços).
- Removidas ~35 funções locais (in_text, in_real, in_int, num, as_num,
  input_name, value_num, value_truthy, value_to_str, item_text) em 22
  libraries e no editor. Inteiros que truncavam (coordenadas de pixel)
  continuam truncando; um número ligado a um campo de texto agora vira
  texto ("42") em vez de "".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mguinhosandClaude Opus 5.5 committed 2026-10-22 18:59:14 -03:00
1 parent a5e36b3eed
commit 5ffc1741c2
27 files changed
+217 -416

No files matched your search

+10 -20
View File
@@ -295,39 +295,29 @@ const char* tb_opentype_default_font(void) {
}
/* ---------------------------------------------------------------- Blocos */
static const char* in_text(TinyBlocks_Block* self, TinyBlocks* rt, uint32_t i) {
TinyBlocks_Value v = tb_block_get_input(self, rt, i);
return (v.kind == TB_VALUE_TEXT && v.as.text) ? v.as.text : "";
}
static double in_real(TinyBlocks_Block* self, TinyBlocks* rt, uint32_t i) {
TinyBlocks_Value v = tb_block_get_input(self, rt, i);
if (v.kind == TB_VALUE_REAL) return v.as.real;
if (v.kind == TB_VALUE_INTEGER) return (double)v.as.integer;
return 0;
}
static void eval_load(TinyBlocks_Block* self, TinyBlocks* rt) {
int h = tb_opentype_load(in_text(self, rt, 0));
int h = tb_opentype_load(tb_block_input_text(self, rt, 0));
if (!h) tinyblocks_set_error(rt, "%s", tb_opentype_last_error());
tb_block_set_output(self, 0, tb_value_integer(h));
self->dirty = false;
}
static void eval_upem(TinyBlocks_Block* self, TinyBlocks* rt) {
tb_block_set_output(self, 0, tb_value_integer(tb_opentype_units_per_em((int)in_real(self, rt, 0))));
tb_block_set_output(self, 0, tb_value_integer(tb_opentype_units_per_em((int)tb_block_input_number(self, rt, 0, 0))));
self->dirty = false;
}
static void eval_glyphs(TinyBlocks_Block* self, TinyBlocks* rt) {
tb_block_set_output(self, 0, tb_value_integer(tb_opentype_glyph_count((int)in_real(self, rt, 0))));
tb_block_set_output(self, 0, tb_value_integer(tb_opentype_glyph_count((int)tb_block_input_number(self, rt, 0, 0))));
self->dirty = false;
}
static void eval_advance(TinyBlocks_Block* self, TinyBlocks* rt) {
tb_block_set_output(self, 0, tb_value_real(
tb_opentype_advance((int)in_real(self, rt, 0), in_text(self, rt, 1), (int)in_real(self, rt, 2))));
tb_opentype_advance((int)tb_block_input_number(self, rt, 0, 0), tb_block_input_text(self, rt, 1), (int)tb_block_input_number(self, rt, 2, 0))));
self->dirty = false;
}
static void eval_outline(TinyBlocks_Block* self, TinyBlocks* rt) {
TinyBlocks_JsonValue* j = tb_opentype_outline((int)in_real(self, rt, 0), in_text(self, rt, 1),
(int)in_real(self, rt, 2));
TinyBlocks_JsonValue* j = tb_opentype_outline((int)tb_block_input_number(self, rt, 0, 0), tb_block_input_text(self, rt, 1),
(int)tb_block_input_number(self, rt, 2, 0));
if (j) {
tb_block_set_output(self, 0, tb_value_json(j));
tb_json_release(j);
@@ -337,10 +327,10 @@ static void eval_outline(TinyBlocks_Block* self, TinyBlocks* rt) {
self->dirty = false;
}
static void eval_render(TinyBlocks_Block* self, TinyBlocks* rt) {
TinyBlocks_Image* img = tb_opentype_render((int)in_real(self, rt, 0), in_text(self, rt, 1),
(int)in_real(self, rt, 2),
(int)in_real(self, rt, 3), (int)in_real(self, rt, 4),
(int)in_real(self, rt, 5));
TinyBlocks_Image* img = tb_opentype_render((int)tb_block_input_number(self, rt, 0, 0), tb_block_input_text(self, rt, 1),
(int)tb_block_input_number(self, rt, 2, 0),
(int)tb_block_input_number(self, rt, 3, 0), (int)tb_block_input_number(self, rt, 4, 0),
(int)tb_block_input_number(self, rt, 5, 0));
if (!img) { tinyblocks_set_error(rt, "%s", tb_opentype_last_error()); self->dirty = false; return; }
tb_block_set_output(self, 0, tb_value_image(img));
tb_image_release(img);