Estado atual do TinyBlocks: editor estilo Scratch + graphics como interface
Snapshot do projeto antes de implementar o diálogo "Criar um Bloco": - runtime C block-based (src/, include/) - libraries: graphics (interface), sdl2 (backend), editor (estilo Scratch), python, mcp - exemplos (hello, sdl2, editor, vector, json, customappearance, python, mcp) - Makefile com alvo help e build do editor Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
commit
4950ad6006
49 files changed
+10596
No files matched your search
@@ -0,0 +1,68 @@
|
||||
#include <stdio.h>
|
||||
#include "tinyblocks/tinyblocks.h"
|
||||
|
||||
/* ── Vtable ──────────────────────────────────────────────────────────────── */
|
||||
static void integer_eval(TinyBlocks_Block* self, TinyBlocks* rt)
|
||||
{
|
||||
(void)rt;
|
||||
TinyBlocks_IntegerBlock* ib = (TinyBlocks_IntegerBlock*)self;
|
||||
tb_block_set_output(self, 0, tb_value_integer(ib->value));
|
||||
self->dirty = false;
|
||||
}
|
||||
|
||||
static void integer_destroy(TinyBlocks_Block* self, TinyBlocks* rt)
|
||||
{
|
||||
(void)self; (void)rt; /* nada a liberar além do base */
|
||||
}
|
||||
|
||||
static size_t integer_to_string(TinyBlocks_Block* self, TinyBlocks* rt,
|
||||
char* buf, size_t sz)
|
||||
{
|
||||
(void)rt;
|
||||
TinyBlocks_IntegerBlock* ib = (TinyBlocks_IntegerBlock*)self;
|
||||
return (size_t)snprintf(buf, sz, "%lld", (long long)ib->value);
|
||||
}
|
||||
|
||||
static TinyBlocks_Block* integer_clone(const TinyBlocks_Block* self, TinyBlocks* rt)
|
||||
{
|
||||
const TinyBlocks_IntegerBlock* ib = (const TinyBlocks_IntegerBlock*)self;
|
||||
TinyBlocks_IntegerBlock* clone = tb_integer_block_create(rt, ib->value);
|
||||
if (clone && self->name) clone->base.name = tb_strdup(rt, self->name);
|
||||
return (TinyBlocks_Block*)clone;
|
||||
}
|
||||
|
||||
static const TinyBlocks_BlockVTable s_integer_vtable = {
|
||||
.eval = integer_eval,
|
||||
.destroy = integer_destroy,
|
||||
.to_string = integer_to_string,
|
||||
.clone = integer_clone,
|
||||
};
|
||||
|
||||
/* ── Ciclo de vida ───────────────────────────────────────────────────────── */
|
||||
TinyBlocks_IntegerBlock* tb_integer_block_create(TinyBlocks* rt, int64_t value)
|
||||
{
|
||||
TinyBlocks_IntegerBlock* ib = (TinyBlocks_IntegerBlock*)tb_block_alloc_base(
|
||||
rt, TB_KIND_INTEGER, sizeof(TinyBlocks_IntegerBlock),
|
||||
0, 1, &s_integer_vtable);
|
||||
if (!ib) return NULL;
|
||||
ib->value = value;
|
||||
return ib;
|
||||
}
|
||||
|
||||
void tb_integer_block_destroy(TinyBlocks_IntegerBlock* ib, TinyBlocks* rt)
|
||||
{
|
||||
tb_block_destroy(&ib->base, rt);
|
||||
}
|
||||
|
||||
/* ── Acesso ──────────────────────────────────────────────────────────────── */
|
||||
int64_t tb_integer_block_get(const TinyBlocks_IntegerBlock* ib)
|
||||
{
|
||||
return ib ? ib->value : 0;
|
||||
}
|
||||
|
||||
void tb_integer_block_set(TinyBlocks_IntegerBlock* ib, int64_t value)
|
||||
{
|
||||
if (!ib) return;
|
||||
ib->value = value;
|
||||
ib->base.dirty = true;
|
||||
}
|
||||
Reference in new issue
Block a user