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
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* TinyBlocks — tb_block.h
|
||||
* TinyBlocks - tb_block.h
|
||||
* Estrutura base de todo bloco e operações polimórficas via vtable.
|
||||
*
|
||||
* Todos os tipos concretos (TypeBlock, LibraryBlock, TextBlock…) começam com
|
||||
* um campo `TinyBlocks_Block base` — herança em C via primeiro membro.
|
||||
* Todos os tipos concretos (TypeBlock, LibraryBlock, TextBlock...) começam com
|
||||
* um campo `TinyBlocks_Block base` - herança em C via primeiro membro.
|
||||
*/
|
||||
#ifndef TINYBLOCKS_BLOCK_H
|
||||
#define TINYBLOCKS_BLOCK_H
|
||||
|
||||
#include "tb_defs.h"
|
||||
|
||||
/* ── Vtable de bloco ─────────────────────────────────────────────────────── */
|
||||
/* -- Vtable de bloco --- */
|
||||
typedef struct TinyBlocks_BlockVTable {
|
||||
/* Avalia o bloco: lê inputs, processa, escreve outputs */
|
||||
void (*eval) (TinyBlocks_Block* self, TinyBlocks* rt);
|
||||
@@ -23,7 +23,7 @@ typedef struct TinyBlocks_BlockVTable {
|
||||
TinyBlocks_Block* (*clone) (const TinyBlocks_Block* self, TinyBlocks* rt);
|
||||
} TinyBlocks_BlockVTable;
|
||||
|
||||
/* ── Estrutura base de todo bloco ────────────────────────────────────────── */
|
||||
/* -- Estrutura base de todo bloco --- */
|
||||
struct TinyBlocks_Block {
|
||||
TinyBlocks_BlockKind kind;
|
||||
const TinyBlocks_BlockVTable* vtable;
|
||||
@@ -48,7 +48,7 @@ struct TinyBlocks_Block {
|
||||
bool in_eval; /* guard anti-ciclo */
|
||||
};
|
||||
|
||||
/* ── Ciclo de vida ───────────────────────────────────────────────────────── */
|
||||
/* -- Ciclo de vida --- */
|
||||
|
||||
/* Cria um bloco a partir de um TypeBlock; registra no runtime */
|
||||
TB_API TinyBlocks_Block* tb_block_create (TinyBlocks* rt, TinyBlocks_TypeBlock* type);
|
||||
@@ -62,14 +62,14 @@ TB_API TinyBlocks_Block* tb_block_clone (const TinyBlocks_Block* block, TinyBlo
|
||||
TB_API size_t tb_block_to_string(TinyBlocks_Block* block, TinyBlocks* rt,
|
||||
char* buf, size_t buf_size);
|
||||
|
||||
/* ── Conexões ────────────────────────────────────────────────────────────── */
|
||||
/* -- Conexões --- */
|
||||
TB_API bool tb_block_connect (TinyBlocks_Block* target, uint32_t input_idx,
|
||||
TinyBlocks_Block* source, uint32_t output_idx);
|
||||
TB_API void tb_block_disconnect(TinyBlocks_Block* target, uint32_t input_idx);
|
||||
TB_API bool tb_block_set_default(TinyBlocks_Block* target, uint32_t input_idx,
|
||||
TinyBlocks_Value default_value);
|
||||
|
||||
/* ── Acesso a valores (para uso dentro de eval_fn) ───────────────────────── */
|
||||
/* -- Acesso a valores (para uso dentro de eval_fn) --- */
|
||||
/* Retorna o valor do input[idx]; resolve a conexão se necessário */
|
||||
TB_API TinyBlocks_Value tb_block_get_input (TinyBlocks_Block* self, TinyBlocks* rt,
|
||||
uint32_t input_idx);
|
||||
@@ -77,14 +77,14 @@ TB_API TinyBlocks_Value tb_block_get_input (TinyBlocks_Block* self, TinyBlocks*
|
||||
TB_API void tb_block_set_output(TinyBlocks_Block* self,
|
||||
uint32_t output_idx, TinyBlocks_Value v);
|
||||
|
||||
/* ── Downcasting seguro ──────────────────────────────────────────────────── */
|
||||
/* -- Downcasting seguro --- */
|
||||
TB_API TinyBlocks_TypeBlock* tb_block_as_type (TinyBlocks_Block* b);
|
||||
TB_API TinyBlocks_LibraryBlock* tb_block_as_library(TinyBlocks_Block* b);
|
||||
TB_API TinyBlocks_TextBlock* tb_block_as_text (TinyBlocks_Block* b);
|
||||
TB_API TinyBlocks_IntegerBlock* tb_block_as_integer(TinyBlocks_Block* b);
|
||||
TB_API TinyBlocks_RealBlock* tb_block_as_real (TinyBlocks_Block* b);
|
||||
|
||||
/* ── Helpers internos (usados por implementações de built-ins) ───────────── */
|
||||
/* -- Helpers internos (usados por implementações de built-ins) --- */
|
||||
TB_API TinyBlocks_Block* tb_block_alloc_base(TinyBlocks* rt,
|
||||
TinyBlocks_BlockKind kind,
|
||||
size_t struct_size,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* TinyBlocks — tb_defs.h
|
||||
* TinyBlocks - tb_defs.h
|
||||
* Forward declarations, enums e tipos primitivos compartilhados por todo o runtime.
|
||||
*/
|
||||
#ifndef TINYBLOCKS_DEFS_H
|
||||
@@ -9,14 +9,14 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* ── Visibilidade de API ─────────────────────────────────────────────────── */
|
||||
/* -- Visibilidade de API --- */
|
||||
#ifdef _WIN32
|
||||
# define TB_API __declspec(dllexport)
|
||||
#else
|
||||
# define TB_API __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
/* ── Forward declarations ────────────────────────────────────────────────── */
|
||||
/* -- Forward declarations --- */
|
||||
typedef struct TinyBlocks TinyBlocks;
|
||||
typedef struct TinyBlocks_Block TinyBlocks_Block;
|
||||
typedef struct TinyBlocks_TypeBlock TinyBlocks_TypeBlock;
|
||||
@@ -29,7 +29,7 @@ typedef struct TinyBlocks_VectorData TinyBlocks_VectorData;
|
||||
typedef struct TinyBlocks_RenderableBlock TinyBlocks_RenderableBlock;
|
||||
typedef struct TinyBlocks_JsonValue TinyBlocks_JsonValue;
|
||||
|
||||
/* ── Kinds de bloco ──────────────────────────────────────────────────────── */
|
||||
/* -- Kinds de bloco --- */
|
||||
typedef enum TinyBlocks_BlockKind {
|
||||
TB_KIND_BLOCK = 0, /* bloco genérico / definido pelo usuário */
|
||||
TB_KIND_TYPE = 1, /* TinyBlocks_TypeBlock */
|
||||
@@ -40,7 +40,7 @@ typedef enum TinyBlocks_BlockKind {
|
||||
TB_KIND_VECTOR = 6, /* TinyBlocks_VectorBlock */
|
||||
} TinyBlocks_BlockKind;
|
||||
|
||||
/* ── Kinds de valor (para slots) ─────────────────────────────────────────── */
|
||||
/* -- Kinds de valor (para slots) --- */
|
||||
typedef enum TinyBlocks_ValueKind {
|
||||
TB_VALUE_NONE = 0,
|
||||
TB_VALUE_INTEGER = 1,
|
||||
@@ -51,7 +51,7 @@ typedef enum TinyBlocks_ValueKind {
|
||||
TB_VALUE_JSON = 6, /* valor JSON (ref-counted) */
|
||||
} TinyBlocks_ValueKind;
|
||||
|
||||
/* ── Valor com tag (flui entre slots) ────────────────────────────────────── */
|
||||
/* -- Valor com tag (flui entre slots) --- */
|
||||
typedef struct TinyBlocks_Value {
|
||||
TinyBlocks_ValueKind kind;
|
||||
union {
|
||||
@@ -64,9 +64,9 @@ typedef struct TinyBlocks_Value {
|
||||
} as;
|
||||
} TinyBlocks_Value;
|
||||
|
||||
/* ══════════════════════════════════════════════════════════════════════════
|
||||
/* ===
|
||||
* Dados de vetor 2D (fluxo de comandos de desenho, ref-counted)
|
||||
* ══════════════════════════════════════════════════════════════════════════ */
|
||||
* === */
|
||||
typedef enum TinyBlocks_VCmdKind {
|
||||
TB_VCMD_BEGIN_PATH = 0, /* nenhum arg */
|
||||
TB_VCMD_MOVE_TO, /* args[0]=x, args[1]=y */
|
||||
@@ -87,24 +87,24 @@ struct TinyBlocks_VectorData {
|
||||
};
|
||||
|
||||
|
||||
/* ── Descritor de slot (em TypeBlock — descreve a forma dos inputs/outputs) ─ */
|
||||
/* -- Descritor de slot (em TypeBlock - descreve a forma dos inputs/outputs) - */
|
||||
typedef struct TinyBlocks_SlotDesc {
|
||||
const char* name;
|
||||
TinyBlocks_ValueKind expected_kind; /* TB_VALUE_NONE = aceita qualquer tipo */
|
||||
} TinyBlocks_SlotDesc;
|
||||
|
||||
/* ── Conexão de entrada (de qual bloco/slot este input lê) ───────────────── */
|
||||
/* -- Conexão de entrada (de qual bloco/slot este input lê) --- */
|
||||
typedef struct TinyBlocks_Connection {
|
||||
TinyBlocks_Block* source; /* bloco de origem (NULL se não conectado) */
|
||||
uint32_t output_idx; /* qual output slot da origem */
|
||||
TinyBlocks_Value default_value; /* valor quando não há conexão */
|
||||
} TinyBlocks_Connection;
|
||||
|
||||
/* ── Alocador customizável ───────────────────────────────────────────────── */
|
||||
/* -- Alocador customizável --- */
|
||||
typedef void* (*TinyBlocks_AllocFn)(size_t size, void* userdata);
|
||||
typedef void (*TinyBlocks_FreeFn) (void* ptr, void* userdata);
|
||||
|
||||
/* ── Helpers para TinyBlocks_Value ──────────────────────────────────────── */
|
||||
/* -- Helpers para TinyBlocks_Value --- */
|
||||
TB_API TinyBlocks_Value tb_value_none(void);
|
||||
TB_API TinyBlocks_Value tb_value_integer(int64_t v);
|
||||
TB_API TinyBlocks_Value tb_value_real(double v);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* TinyBlocks — tb_integer_block.h
|
||||
* TinyBlocks - tb_integer_block.h
|
||||
* TinyBlocks_IntegerBlock: bloco primitivo que contém um inteiro de 64 bits.
|
||||
*
|
||||
* IntegerBlocks são literais: têm 0 inputs e 1 output (TB_VALUE_INTEGER).
|
||||
@@ -14,12 +14,12 @@ struct TinyBlocks_IntegerBlock {
|
||||
int64_t value;
|
||||
};
|
||||
|
||||
/* ── Ciclo de vida ───────────────────────────────────────────────────────── */
|
||||
/* -- Ciclo de vida --- */
|
||||
TB_API TinyBlocks_IntegerBlock* tb_integer_block_create (TinyBlocks* rt, int64_t value);
|
||||
TB_API void tb_integer_block_destroy(TinyBlocks_IntegerBlock* ib,
|
||||
TinyBlocks* rt);
|
||||
|
||||
/* ── Acesso ao valor ─────────────────────────────────────────────────────── */
|
||||
/* -- Acesso ao valor --- */
|
||||
TB_API int64_t tb_integer_block_get(const TinyBlocks_IntegerBlock* ib);
|
||||
TB_API void tb_integer_block_set(TinyBlocks_IntegerBlock* ib, int64_t value);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* TinyBlocks — tb_json_block.h
|
||||
* TinyBlocks - tb_json_block.h
|
||||
* TinyBlocks_JsonValue: árvore JSON imutável e ref-counted que flui como valor
|
||||
* entre blocos (TB_VALUE_JSON).
|
||||
*
|
||||
@@ -28,7 +28,7 @@ typedef enum TinyBlocks_JsonKind {
|
||||
TB_JSON_OBJECT = 5,
|
||||
} TinyBlocks_JsonKind;
|
||||
|
||||
/* ── Ciclo de vida ───────────────────────────────────────────────────────── */
|
||||
/* -- Ciclo de vida --- */
|
||||
TB_API TinyBlocks_JsonValue* tb_json_null (void);
|
||||
TB_API TinyBlocks_JsonValue* tb_json_bool (bool b);
|
||||
TB_API TinyBlocks_JsonValue* tb_json_number(double d);
|
||||
@@ -40,7 +40,7 @@ TB_API void tb_json_retain (TinyBlocks_JsonValue* j);
|
||||
TB_API void tb_json_release(TinyBlocks_JsonValue* j);
|
||||
TB_API TinyBlocks_JsonValue* tb_json_clone (const TinyBlocks_JsonValue* j); /* deep copy */
|
||||
|
||||
/* ── Inspeção ────────────────────────────────────────────────────────────── */
|
||||
/* -- Inspeção --- */
|
||||
TB_API TinyBlocks_JsonKind tb_json_kind (const TinyBlocks_JsonValue* j);
|
||||
TB_API const char* tb_json_kind_name(const TinyBlocks_JsonValue* j);
|
||||
|
||||
@@ -48,24 +48,24 @@ TB_API bool tb_json_as_bool (const TinyBlocks_JsonValue* j, bool def);
|
||||
TB_API double tb_json_as_number(const TinyBlocks_JsonValue* j, double def);
|
||||
TB_API const char* tb_json_as_string(const TinyBlocks_JsonValue* j); /* NULL se não for string */
|
||||
|
||||
/* ── Arrays (mutação in-place; use em árvores não compartilhadas) ───────── */
|
||||
/* -- Arrays (mutação in-place; use em árvores não compartilhadas) --- */
|
||||
TB_API bool tb_json_array_push (TinyBlocks_JsonValue* arr, TinyBlocks_JsonValue* item);
|
||||
TB_API uint32_t tb_json_array_length(const TinyBlocks_JsonValue* arr);
|
||||
TB_API TinyBlocks_JsonValue* tb_json_array_get(const TinyBlocks_JsonValue* arr, uint32_t idx); /* ref nova, ou NULL */
|
||||
|
||||
/* ── Objetos (mutação in-place; use em árvores não compartilhadas) ──────── */
|
||||
/* -- Objetos (mutação in-place; use em árvores não compartilhadas) --- */
|
||||
TB_API bool tb_json_object_set (TinyBlocks_JsonValue* obj, const char* key, TinyBlocks_JsonValue* val);
|
||||
TB_API uint32_t tb_json_object_length (const TinyBlocks_JsonValue* obj);
|
||||
TB_API const char* tb_json_object_key_at (const TinyBlocks_JsonValue* obj, uint32_t idx);
|
||||
TB_API TinyBlocks_JsonValue* tb_json_object_get(const TinyBlocks_JsonValue* obj, const char* key); /* ref nova, ou NULL */
|
||||
|
||||
/* ── Parsing / serialização ──────────────────────────────────────────────── */
|
||||
/* -- Parsing / serialização --- */
|
||||
/* Retorna NULL em erro de sintaxe; se errbuf não for NULL, escreve a mensagem. */
|
||||
TB_API TinyBlocks_JsonValue* tb_json_parse(const char* text, char* errbuf, size_t errbuf_size);
|
||||
/* Serializa para texto; retorna buffer heap-alocado (free() do chamador). */
|
||||
TB_API char* tb_json_stringify(const TinyBlocks_JsonValue* j);
|
||||
|
||||
/* ── Helpers para TinyBlocks_Value ──────────────────────────────────────── */
|
||||
/* -- Helpers para TinyBlocks_Value --- */
|
||||
TB_API TinyBlocks_Value tb_value_json (TinyBlocks_JsonValue* j); /* retém ref */
|
||||
TB_API TinyBlocks_JsonValue* tb_value_as_json(TinyBlocks_Value v);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* TinyBlocks — tb_real_block.h
|
||||
* TinyBlocks - tb_real_block.h
|
||||
* TinyBlocks_RealBlock: bloco primitivo que contém um número real (double).
|
||||
*
|
||||
* RealBlocks são literais: têm 0 inputs e 1 output (TB_VALUE_REAL).
|
||||
@@ -14,12 +14,12 @@ struct TinyBlocks_RealBlock {
|
||||
double value;
|
||||
};
|
||||
|
||||
/* ── Ciclo de vida ───────────────────────────────────────────────────────── */
|
||||
/* -- Ciclo de vida --- */
|
||||
TB_API TinyBlocks_RealBlock* tb_real_block_create (TinyBlocks* rt, double value);
|
||||
TB_API void tb_real_block_destroy(TinyBlocks_RealBlock* rb,
|
||||
TinyBlocks* rt);
|
||||
|
||||
/* ── Acesso ao valor ─────────────────────────────────────────────────────── */
|
||||
/* -- Acesso ao valor --- */
|
||||
TB_API double tb_real_block_get(const TinyBlocks_RealBlock* rb);
|
||||
TB_API void tb_real_block_set(TinyBlocks_RealBlock* rb, double value);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* TinyBlocks — tb_renderable_block.h
|
||||
* TinyBlocks - tb_renderable_block.h
|
||||
*
|
||||
* TinyBlocks_RenderableBlock: lista de comandos de desenho produzida por on_draw.
|
||||
* O backend (ex: SDL2.App) interpreta os comandos para renderizar na tela.
|
||||
@@ -22,13 +22,13 @@
|
||||
|
||||
#include "tb_defs.h"
|
||||
|
||||
/* ── Tipos de comando ──────────────────────────────────────────────────────── */
|
||||
/* -- Tipos de comando --- */
|
||||
typedef enum {
|
||||
TB_DRAW_CLEAR, /* limpa toda a área com uma cor */
|
||||
TB_DRAW_FILL_RECT, /* retângulo preenchido */
|
||||
TB_DRAW_FILL_RRECT, /* retângulo com cantos arredondados (param=radius) */
|
||||
TB_DRAW_FILL_CIRCLE, /* círculo preenchido (x=cx, y=cy, param=radius) */
|
||||
TB_DRAW_STROKE_LINE, /* linha (x,y → w,h como x2,y2; param=espessura) */
|
||||
TB_DRAW_STROKE_LINE, /* linha (x,y -> w,h como x2,y2; param=espessura) */
|
||||
TB_DRAW_STROKE_RECT, /* contorno de retângulo (param=espessura) */
|
||||
TB_DRAW_STROKE_CIRCLE, /* contorno de círculo (x=cx,y=cy,param=r,w=espessura)*/
|
||||
TB_DRAW_SET_CLIP, /* define rect de clip (coordenadas tela) */
|
||||
@@ -45,7 +45,7 @@ typedef struct {
|
||||
char text[128]; /* conteúdo do texto (TB_DRAW_TEXT) */
|
||||
} TinyBlocks_DrawCmd;
|
||||
|
||||
/* ── RenderableBlock ───────────────────────────────────────────────────────── */
|
||||
/* -- RenderableBlock --- */
|
||||
#define TB_DRAW_CMD_CAP 8192
|
||||
|
||||
struct TinyBlocks_RenderableBlock {
|
||||
@@ -53,7 +53,7 @@ struct TinyBlocks_RenderableBlock {
|
||||
uint32_t count;
|
||||
};
|
||||
|
||||
/* ── Pool de renderables (reset por frame, sem malloc durante o loop) ──────── */
|
||||
/* -- Pool de renderables (reset por frame, sem malloc durante o loop) --- */
|
||||
|
||||
/* Adquire um renderable limpo do pool. Retorna NULL se esgotado. */
|
||||
TB_API TinyBlocks_RenderableBlock* tb_renderable_acquire(void);
|
||||
@@ -65,7 +65,7 @@ TB_API void tb_renderable_release(TinyBlocks_RenderableBlock* rb);
|
||||
depois que o backend terminar de renderizar). */
|
||||
TB_API void tb_renderable_release_all(void);
|
||||
|
||||
/* ── Helpers para acrescentar comandos ────────────────────────────────────── */
|
||||
/* -- Helpers para acrescentar comandos --- */
|
||||
|
||||
TB_API void tb_draw_clear (TinyBlocks_RenderableBlock* rb,
|
||||
float r, float g, float b, float a);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* TinyBlocks — tb_text_block.h
|
||||
* TinyBlocks - tb_text_block.h
|
||||
* TinyBlocks_TextBlock: bloco primitivo que contém um valor textual.
|
||||
*
|
||||
* TextBlocks são literais: têm 0 inputs e 1 output (TB_VALUE_TEXT).
|
||||
@@ -15,12 +15,12 @@ struct TinyBlocks_TextBlock {
|
||||
char* value; /* string heap-owned */
|
||||
};
|
||||
|
||||
/* ── Ciclo de vida ───────────────────────────────────────────────────────── */
|
||||
/* -- Ciclo de vida --- */
|
||||
TB_API TinyBlocks_TextBlock* tb_text_block_create (TinyBlocks* rt, const char* value);
|
||||
TB_API void tb_text_block_destroy(TinyBlocks_TextBlock* tb,
|
||||
TinyBlocks* rt);
|
||||
|
||||
/* ── Acesso ao valor ─────────────────────────────────────────────────────── */
|
||||
/* -- Acesso ao valor --- */
|
||||
TB_API const char* tb_text_block_get(const TinyBlocks_TextBlock* tb);
|
||||
TB_API void tb_text_block_set(TinyBlocks_TextBlock* tb, const char* value);
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
* TinyBlocks — tb_type_block.h
|
||||
* TinyBlocks - tb_type_block.h
|
||||
* TinyBlocks_TypeBlock: representa a "classe" de um bloco.
|
||||
*
|
||||
* Um TypeBlock define:
|
||||
* • O nome do tipo
|
||||
* • Os descritores de slots (inputs e outputs)
|
||||
* • A função de avaliação para instâncias
|
||||
* • Hooks de init/deinit por instância
|
||||
* • Tamanho extra de userdata para instâncias
|
||||
* * O nome do tipo
|
||||
* * Os descritores de slots (inputs e outputs)
|
||||
* * A função de avaliação para instâncias
|
||||
* * Hooks de init/deinit por instância
|
||||
* * Tamanho extra de userdata para instâncias
|
||||
*
|
||||
* TypeBlocks são eles mesmos blocos (base.kind == TB_KIND_TYPE).
|
||||
*/
|
||||
@@ -45,7 +45,7 @@ struct TinyBlocks_TypeBlock {
|
||||
TinyBlocks_RenderableBlock** dst);
|
||||
};
|
||||
|
||||
/* ── Criação de TypeBlock ────────────────────────────────────────────────── */
|
||||
/* -- Criação de TypeBlock --- */
|
||||
|
||||
/* Cria e registra um TypeBlock no runtime */
|
||||
TB_API TinyBlocks_TypeBlock* tb_type_block_create(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* TinyBlocks — tb_vector_block.h
|
||||
* TinyBlocks - tb_vector_block.h
|
||||
* TinyBlocks_VectorBlock: bloco que armazena dados de vetor 2D.
|
||||
* TinyBlocks_VectorData: comandos de desenho ref-counted que fluem como valores.
|
||||
*
|
||||
@@ -22,13 +22,13 @@
|
||||
#include "tb_block.h"
|
||||
#include "tb_renderable_block.h"
|
||||
|
||||
/* ── TinyBlocks_VectorBlock — bloco que contém VectorData ───────────────── */
|
||||
/* -- TinyBlocks_VectorBlock - bloco que contém VectorData --- */
|
||||
struct TinyBlocks_VectorBlock {
|
||||
TinyBlocks_Block base; /* DEVE ser o primeiro campo */
|
||||
TinyBlocks_VectorData* data;
|
||||
};
|
||||
|
||||
/* ── Ciclo de vida de VectorData ────────────────────────────────────────── */
|
||||
/* -- Ciclo de vida de VectorData --- */
|
||||
TB_API TinyBlocks_VectorData* tb_vector_data_create (void);
|
||||
TB_API void tb_vector_data_retain (TinyBlocks_VectorData* v);
|
||||
TB_API void tb_vector_data_release(TinyBlocks_VectorData* v);
|
||||
@@ -36,7 +36,7 @@ TB_API TinyBlocks_VectorData* tb_vector_data_clone (const TinyBlocks_VectorData
|
||||
TB_API bool tb_vector_data_push (TinyBlocks_VectorData* v,
|
||||
TinyBlocks_VCmd cmd);
|
||||
|
||||
/* ── Construtores de comandos ────────────────────────────────────────────── */
|
||||
/* -- Construtores de comandos --- */
|
||||
TB_API bool tb_vector_begin_path(TinyBlocks_VectorData* v);
|
||||
TB_API bool tb_vector_move_to (TinyBlocks_VectorData* v, float x, float y);
|
||||
TB_API bool tb_vector_line_to (TinyBlocks_VectorData* v, float x, float y);
|
||||
@@ -50,16 +50,16 @@ TB_API bool tb_vector_rect (TinyBlocks_VectorData* v,
|
||||
TB_API bool tb_vector_circle (TinyBlocks_VectorData* v,
|
||||
float cx, float cy, float radius);
|
||||
|
||||
/* ── Helpers para TinyBlocks_Value ──────────────────────────────────────── */
|
||||
/* -- Helpers para TinyBlocks_Value --- */
|
||||
TB_API TinyBlocks_Value tb_value_vector (TinyBlocks_VectorData* v);
|
||||
TB_API TinyBlocks_VectorData* tb_value_as_vector(TinyBlocks_Value v);
|
||||
|
||||
/* ── VectorBlock (bloco no grafo) ────────────────────────────────────────── */
|
||||
/* -- VectorBlock (bloco no grafo) --- */
|
||||
TB_API TinyBlocks_VectorBlock* tb_vector_block_create (TinyBlocks* rt);
|
||||
TB_API void tb_vector_block_set_data (TinyBlocks_VectorBlock* b,
|
||||
TinyBlocks_VectorData* v);
|
||||
|
||||
/* ── Reprodução de VectorData via RenderableBlock ───────────────────────── */
|
||||
/* -- Reprodução de VectorData via RenderableBlock --- */
|
||||
TB_API void tb_draw_ctx_play(TinyBlocks_RenderableBlock* rb, TinyBlocks_VectorData* v);
|
||||
|
||||
#endif /* TINYBLOCKS_VECTOR_BLOCK_H */
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* TinyBlocks — tinyblocks.h
|
||||
* TinyBlocks - tinyblocks.h
|
||||
* Cabeçalho principal do runtime. Inclua apenas este arquivo.
|
||||
*
|
||||
* O struct TinyBlocks é o runtime da linguagem. Ele é completamente separado
|
||||
* de qualquer interface gráfica — GUIs são implementadas como LibraryBlocks.
|
||||
* de qualquer interface gráfica - GUIs são implementadas como LibraryBlocks.
|
||||
*
|
||||
* Fluxo de uso mínimo:
|
||||
*
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "tb_vector_block.h"
|
||||
#include "tb_json_block.h"
|
||||
|
||||
/* ── Runtime ─────────────────────────────────────────────────────────────── */
|
||||
/* -- Runtime --- */
|
||||
struct TinyBlocks {
|
||||
/* Alocador (padrão: malloc/free) */
|
||||
TinyBlocks_AllocFn alloc;
|
||||
@@ -70,7 +70,7 @@ struct TinyBlocks {
|
||||
char error[512];
|
||||
};
|
||||
|
||||
/* ── Opções de inicialização ─────────────────────────────────────────────── */
|
||||
/* -- Opções de inicialização --- */
|
||||
typedef struct TinyBlocks_InitOptions {
|
||||
TinyBlocks_AllocFn alloc; /* NULL = malloc padrão */
|
||||
TinyBlocks_FreeFn free_fn; /* NULL = free padrão */
|
||||
@@ -80,11 +80,11 @@ typedef struct TinyBlocks_InitOptions {
|
||||
uint32_t initial_library_cap; /* 0 = 16 */
|
||||
} TinyBlocks_InitOptions;
|
||||
|
||||
/* ── Ciclo de vida do runtime ────────────────────────────────────────────── */
|
||||
/* -- Ciclo de vida do runtime --- */
|
||||
TB_API bool tinyblocks_init (TinyBlocks** out_rt, const TinyBlocks_InitOptions* opts);
|
||||
TB_API void tinyblocks_deinit(TinyBlocks** rt);
|
||||
|
||||
/* ── Registro interno (usado pelas implementações de bloco) ─────────────── */
|
||||
/* -- Registro interno (usado pelas implementações de bloco) --- */
|
||||
TB_API bool tb_rt_register_block (TinyBlocks* rt, TinyBlocks_Block* block);
|
||||
TB_API void tb_rt_unregister_block(TinyBlocks* rt, TinyBlocks_Block* block);
|
||||
TB_API bool tb_rt_register_type (TinyBlocks* rt, TinyBlocks_TypeBlock* type);
|
||||
@@ -92,22 +92,22 @@ TB_API void tb_rt_unregister_type (TinyBlocks* rt, TinyBlocks_TypeBlock* typ
|
||||
TB_API bool tb_rt_register_library(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib);
|
||||
TB_API void tb_rt_unregister_library(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib);
|
||||
|
||||
/* ── Alocação com o alocador do runtime ─────────────────────────────────── */
|
||||
/* -- Alocação com o alocador do runtime --- */
|
||||
TB_API void* tb_alloc(TinyBlocks* rt, size_t size);
|
||||
TB_API void tb_free (TinyBlocks* rt, void* ptr);
|
||||
TB_API char* tb_strdup(TinyBlocks* rt, const char* str);
|
||||
|
||||
/* ── Diagnósticos ────────────────────────────────────────────────────────── */
|
||||
/* -- Diagnósticos --- */
|
||||
TB_API const char* tinyblocks_last_error(TinyBlocks* rt);
|
||||
TB_API void tinyblocks_set_error (TinyBlocks* rt, const char* fmt, ...);
|
||||
TB_API void tinyblocks_clear_error(TinyBlocks* rt);
|
||||
|
||||
/* ── Busca no registro ───────────────────────────────────────────────────── */
|
||||
/* -- Busca no registro --- */
|
||||
TB_API TinyBlocks_Block* tb_rt_find_block (TinyBlocks* rt, uint64_t id);
|
||||
TB_API TinyBlocks_TypeBlock* tb_rt_find_type (TinyBlocks* rt, const char* name);
|
||||
TB_API TinyBlocks_LibraryBlock* tb_rt_find_library(TinyBlocks* rt, const char* name);
|
||||
|
||||
/* ── Geração de ID ───────────────────────────────────────────────────────── */
|
||||
/* -- Geração de ID --- */
|
||||
TB_API uint64_t tb_rt_next_id(TinyBlocks* rt);
|
||||
|
||||
#endif /* TINYBLOCKS_H */
|
||||
Reference in new issue
Block a user