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:
1 parent
a5e36b3eed
commit
5ffc1741c2
27 files changed
+217
-416
No files matched your search
@@ -179,13 +179,7 @@ static Shape shape_of(const TinyBlocks_TypeBlock* t) {
|
||||
case TB_SHAPE_BOOLEAN: return SH_BOOL;
|
||||
default: break;
|
||||
}
|
||||
if (t->output_desc_count == 1) {
|
||||
if (tb_type_block_output_flags(t, 0) & TB_SLOT_BOOLEAN) return SH_BOOL;
|
||||
/* convencao antiga das libraries: saida cujo nome termina em '?' */
|
||||
const char* on = t->output_descs && t->output_descs[0].name ? t->output_descs[0].name : "";
|
||||
size_t ol = strlen(on);
|
||||
if (ol > 0 && on[ol - 1] == '?') return SH_BOOL;
|
||||
}
|
||||
if (t->output_desc_count == 1 && (tb_type_block_output_flags(t, 0) & TB_SLOT_BOOLEAN)) return SH_BOOL;
|
||||
return t->output_desc_count > 0 ? SH_REPORTER : SH_STACK;
|
||||
}
|
||||
|
||||
@@ -1405,11 +1399,6 @@ static unsigned now_ms(void) {
|
||||
/* ===
|
||||
* Portas de blocos compostos ("Meus Blocos")
|
||||
* === */
|
||||
static void input_name(TinyBlocks_Block* self, TinyBlocks* rt, uint32_t i, char* out, size_t cap) {
|
||||
TinyBlocks_Value v = tb_block_get_input(self, rt, i);
|
||||
tb_value_to_text(v, out, cap);
|
||||
}
|
||||
|
||||
/* == Blocos compostos ("Meus Blocos") ===
|
||||
* A definição é uma aba com scripts; "parâmetro [x]" lê os inputs da chamada
|
||||
* e "devolva [y] - (v)" escreve os outputs. */
|
||||
@@ -1428,7 +1417,7 @@ static void eval_port_in(TinyBlocks_Block* self, TinyBlocks* rt) {
|
||||
CallFrame* f = cur_frame();
|
||||
TinyBlocks_Value out = tb_value_none();
|
||||
if (f) {
|
||||
char label[64]; input_name(self, rt, 0, label, sizeof(label));
|
||||
const char* label = tb_block_input_text(self, rt, 0);
|
||||
for (int i = 0; i < f->def->input_count; i++)
|
||||
if (strcmp(f->def->input_names[i], label) == 0) { out = tb_value_clone(f->in[i]); break; }
|
||||
}
|
||||
@@ -1439,7 +1428,7 @@ static void eval_port_in(TinyBlocks_Block* self, TinyBlocks* rt) {
|
||||
static void eval_port_out(TinyBlocks_Block* self, TinyBlocks* rt) {
|
||||
CallFrame* f = cur_frame();
|
||||
if (f) {
|
||||
char label[64]; input_name(self, rt, 0, label, sizeof(label));
|
||||
const char* label = tb_block_input_text(self, rt, 0);
|
||||
for (int i = 0; i < f->def->output_count; i++) {
|
||||
if (strcmp(f->def->output_names[i], label) != 0) continue;
|
||||
tb_value_free(&f->out[i]);
|
||||
|
||||
Reference in new issue
Block a user