Converte símbolos Unicode decorativos dos comentários para ASCII
Substitui barras de caixa (─ ═ │ ┌ ┐ └ ┘ ├ ┤ ┬ ┴), travessões (—), setas (→ ←), reticências (…), bullets (•), multiplicação (×) e guillemets (› ‹) por equivalentes ASCII. Acentos portugueses são preservados.
This commit is contained in:
1 parent
1cc0ff9d02
commit
90d47bf8a0
36 files changed
+327
-327
No files matched your search
+18
-18
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* TinyBlocks — exemplo hello
|
||||
* TinyBlocks - exemplo hello
|
||||
*
|
||||
* Demonstra:
|
||||
* 1. Inicializar o runtime
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <stdio.h>
|
||||
#include <tinyblocks/tinyblocks.h>
|
||||
|
||||
/* ── TypeBlock: Math.Add ─────────────────────────────────────────────────── */
|
||||
/* -- TypeBlock: Math.Add --- */
|
||||
/* inputs: a(int), b(int)
|
||||
* outputs: result(int) */
|
||||
static void eval_math_add(TinyBlocks_Block* self, TinyBlocks* rt)
|
||||
@@ -23,7 +23,7 @@ static void eval_math_add(TinyBlocks_Block* self, TinyBlocks* rt)
|
||||
tb_block_set_output(self, 0, tb_value_integer(a + b));
|
||||
}
|
||||
|
||||
/* ── TypeBlock: Math.Mul ─────────────────────────────────────────────────── */
|
||||
/* -- TypeBlock: Math.Mul --- */
|
||||
static void eval_math_mul(TinyBlocks_Block* self, TinyBlocks* rt)
|
||||
{
|
||||
TinyBlocks_Value va = tb_block_get_input(self, rt, 0);
|
||||
@@ -33,7 +33,7 @@ static void eval_math_mul(TinyBlocks_Block* self, TinyBlocks* rt)
|
||||
tb_block_set_output(self, 0, tb_value_integer(a * b));
|
||||
}
|
||||
|
||||
/* ── TypeBlock: IO.Print ─────────────────────────────────────────────────── */
|
||||
/* -- TypeBlock: IO.Print --- */
|
||||
/* inputs: label(text), value(int)
|
||||
* outputs: (nenhum) */
|
||||
static void eval_io_print(TinyBlocks_Block* self, TinyBlocks* rt)
|
||||
@@ -54,7 +54,7 @@ static void eval_io_print(TinyBlocks_Block* self, TinyBlocks* rt)
|
||||
printf("[IO.Print] %s = %s\n", label, valstr);
|
||||
}
|
||||
|
||||
/* ── TypeBlock: Math.Factorial (demonstra userdata por instância) ─────────── */
|
||||
/* -- TypeBlock: Math.Factorial (demonstra userdata por instância) --- */
|
||||
/* inputs: n(int)
|
||||
* outputs: result(int) */
|
||||
typedef struct { int64_t memo; } FactorialData;
|
||||
@@ -72,12 +72,12 @@ static void eval_math_factorial(TinyBlocks_Block* self, TinyBlocks* rt)
|
||||
tb_block_set_output(self, 0, tb_value_integer(result));
|
||||
}
|
||||
|
||||
/* ═══════════════════════════════════════════════════════════════════════════
|
||||
/* ===
|
||||
* main
|
||||
* ═══════════════════════════════════════════════════════════════════════════ */
|
||||
* === */
|
||||
int main(void)
|
||||
{
|
||||
printf("=== TinyBlocks — exemplo hello ===\n\n");
|
||||
printf("=== TinyBlocks - exemplo hello ===\n\n");
|
||||
|
||||
/* 1. Inicializar runtime */
|
||||
TinyBlocks* rt = NULL;
|
||||
@@ -124,7 +124,7 @@ int main(void)
|
||||
printf("[libs] Math=%u blocos, IO=%u bloco(s)\n\n",
|
||||
lib_math->block_count, lib_io->block_count);
|
||||
|
||||
/* ── Exemplo 1: 3 + 4 ───────────────────────────────────────────────── */
|
||||
/* -- Exemplo 1: 3 + 4 --- */
|
||||
printf("--- Exemplo 1: 3 + 4 ---\n");
|
||||
{
|
||||
TinyBlocks_IntegerBlock* lit3 = tb_integer_block_create(rt, 3);
|
||||
@@ -133,13 +133,13 @@ int main(void)
|
||||
TinyBlocks_Block* add = tb_block_create(rt, t_add);
|
||||
TinyBlocks_Block* print = tb_block_create(rt, t_print);
|
||||
|
||||
/* Conecta: add.in[0] ← lit3.out[0]
|
||||
add.in[1] ← lit4.out[0] */
|
||||
/* Conecta: add.in[0] <- lit3.out[0]
|
||||
add.in[1] <- lit4.out[0] */
|
||||
tb_block_connect(add, 0, &lit3->base, 0);
|
||||
tb_block_connect(add, 1, &lit4->base, 0);
|
||||
|
||||
/* print.in[0] ← label.out[0]
|
||||
print.in[1] ← add.out[0] */
|
||||
/* print.in[0] <- label.out[0]
|
||||
print.in[1] <- add.out[0] */
|
||||
tb_block_connect(print, 0, &label->base, 0);
|
||||
tb_block_connect(print, 1, add, 0);
|
||||
|
||||
@@ -147,7 +147,7 @@ int main(void)
|
||||
tb_block_eval(print, rt);
|
||||
}
|
||||
|
||||
/* ── Exemplo 2: (2 + 3) * 5 ────────────────────────────────────────── */
|
||||
/* -- Exemplo 2: (2 + 3) * 5 --- */
|
||||
printf("\n--- Exemplo 2: (2 + 3) * 5 ---\n");
|
||||
{
|
||||
TinyBlocks_IntegerBlock* lit2 = tb_integer_block_create(rt, 2);
|
||||
@@ -168,7 +168,7 @@ int main(void)
|
||||
tb_block_eval(print, rt);
|
||||
}
|
||||
|
||||
/* ── Exemplo 3: 7! (fatorial com userdata por instância) ────────────── */
|
||||
/* -- Exemplo 3: 7! (fatorial com userdata por instância) --- */
|
||||
printf("\n--- Exemplo 3: 7! ---\n");
|
||||
{
|
||||
TinyBlocks_IntegerBlock* lit7 = tb_integer_block_create(rt, 7);
|
||||
@@ -187,7 +187,7 @@ int main(void)
|
||||
printf(" userdata.memo = %lld\n", (long long)d->memo);
|
||||
}
|
||||
|
||||
/* ── Exemplo 4: busca de tipo por nome ──────────────────────────────── */
|
||||
/* -- Exemplo 4: busca de tipo por nome --- */
|
||||
printf("\n--- Exemplo 4: busca de tipo por nome ---\n");
|
||||
{
|
||||
TinyBlocks_TypeBlock* found = tb_type_block_find(rt, "Math.Add");
|
||||
@@ -202,7 +202,7 @@ int main(void)
|
||||
? ((TinyBlocks_TypeBlock*)b)->type_name : "?");
|
||||
}
|
||||
|
||||
/* ── Exemplo 5: to_string ────────────────────────────────────────────── */
|
||||
/* -- Exemplo 5: to_string --- */
|
||||
printf("\n--- Exemplo 5: representação textual ---\n");
|
||||
{
|
||||
TinyBlocks_IntegerBlock* ib = tb_integer_block_create(rt, 42);
|
||||
@@ -222,7 +222,7 @@ int main(void)
|
||||
printf("TextBlock: %s\n", buf);
|
||||
}
|
||||
|
||||
/* ── Resumo do runtime ───────────────────────────────────────────────── */
|
||||
/* -- Resumo do runtime --- */
|
||||
printf("\n--- Estado do runtime ---\n");
|
||||
printf("blocks vivos: %u\n", rt->block_count);
|
||||
printf("types: %u\n", rt->type_count);
|
||||
|
||||
Reference in new issue
Block a user