# ligverd/sqbinding architecture

> Architecture diagram of the GitHub repository ligverd/sqbinding, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ligverd/sqbinding
- Repository: https://github.com/ligverd/sqbinding

## Overview

SQBinding is a C++11 adapter between C++ applications and the Squirrel scripting VM. The principal workflow is to create or wrap a VM, register C++ functions/classes and values, execute a script, and optionally retrieve and call script functions from C++. Tables and arrays provide script-container access; shared object handling and type conversion support these bindings. The graph covers the core runtime modules and documented capabilities. Some headers are only partially excerpted, so edges are limited to visible calls, indexed references, or README statements.

Main entry points: [`src/sqbinding.cpp`](https://github.com/ligverd/sqbinding/blob/master/src/sqbinding.cpp) (Binding API), [`src/sqbtable.h`](https://github.com/ligverd/sqbinding/blob/master/src/sqbtable.h) (Table binding), [`src/sqbobject.cpp`](https://github.com/ligverd/sqbinding/blob/master/src/sqbobject.cpp) (VM object handles), [`src/sqbfunction.h`](https://github.com/ligverd/sqbinding/blob/master/src/sqbfunction.h) (Function binding)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vm["VM lifecycle"]
  node_binding_api["Binding API<br/>[sqbinding.cpp]"]
  node_binding_declaration["Binding interface<br/>[sqbinding.h]"]
end

subgraph group_binding["C++ bindings"]
  node_table_binding["Table binding<br/>[sqbtable.h]"]
  node_function_binding["Function binding<br/>[sqbfunction.h]"]
  node_class_binding["Class binding<br/>[sqbclass.h]"]
  node_dispatch_conversion["Call dispatch<br/>[sqbdetail.h]"]
end

subgraph group_values["Objects and values"]
  node_type_conversion["Type conversion<br/>[sqbtypes.h]"]
  node_sq_object["VM object handles<br/>[sqbobject.cpp]"]
  node_array_binding["Array binding<br/>[sqbarray.h]"]
  node_table_storage["Table access<br/>[sqbtable.h]"]
  node_object_interface["Object interface<br/>[sqbobject.h]"]
end

node_cpp_app(("C++ application"))
node_squirrel_vm["Squirrel VM"]

node_cpp_app -->|"configures and executes"| node_binding_api
node_binding_api -->|"creates or wraps"| node_squirrel_vm
node_binding_api -->|"executes scripts"| node_squirrel_vm
node_binding_api -->|"inherits"| node_table_binding
node_table_binding -->|"binds classes"| node_class_binding
node_table_binding -->|"retrieves functions"| node_function_binding
node_table_binding -->|"creates arrays"| node_array_binding
node_class_binding -->|"registers methods"| node_dispatch_conversion
node_function_binding -->|"dispatches calls"| node_dispatch_conversion
node_dispatch_conversion -->|"converts arguments"| node_type_conversion
node_array_binding -->|"converts elements"| node_type_conversion
node_table_storage -->|"converts values"| node_type_conversion
node_array_binding -->|"uses handles"| node_sq_object
node_class_binding -->|"uses handles"| node_sq_object
node_function_binding -->|"uses handles"| node_sq_object
node_table_storage -->|"uses handles"| node_sq_object
node_sq_object -->|"implements"| node_object_interface
node_table_binding -->|"provides access"| node_table_storage
node_function_binding -->|"calls script function"| node_squirrel_vm
node_binding_api -->|"registers standard libraries"| node_squirrel_vm

click node_binding_api "https://github.com/ligverd/sqbinding/blob/master/src/sqbinding.cpp"
click node_table_binding "https://github.com/ligverd/sqbinding/blob/master/src/sqbtable.h"
click node_function_binding "https://github.com/ligverd/sqbinding/blob/master/src/sqbfunction.h"
click node_class_binding "https://github.com/ligverd/sqbinding/blob/master/src/sqbclass.h"
click node_dispatch_conversion "https://github.com/ligverd/sqbinding/blob/master/src/sqbdetail.h"
click node_type_conversion "https://github.com/ligverd/sqbinding/blob/master/src/sqbtypes.h"
click node_sq_object "https://github.com/ligverd/sqbinding/blob/master/src/sqbobject.cpp"
click node_array_binding "https://github.com/ligverd/sqbinding/blob/master/src/sqbarray.h"
click node_table_storage "https://github.com/ligverd/sqbinding/blob/master/src/sqbtable.h"
click node_binding_declaration "https://github.com/ligverd/sqbinding/blob/master/src/sqbinding.h"
click node_object_interface "https://github.com/ligverd/sqbinding/blob/master/src/sqbobject.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_binding_api,node_binding_declaration toneBlue
class node_table_binding,node_function_binding,node_class_binding,node_dispatch_conversion toneAmber
class node_type_conversion,node_sq_object,node_array_binding,node_table_storage,node_object_interface toneMint
class node_cpp_app,node_squirrel_vm toneIndigo
```

## Components

### VM lifecycle

- [Binding API](https://github.com/ligverd/sqbinding/blob/master/src/sqbinding.cpp): `src/sqbinding.cpp`
- [Binding interface](https://github.com/ligverd/sqbinding/blob/master/src/sqbinding.h): `src/sqbinding.h`

### C++ bindings

- [Table binding](https://github.com/ligverd/sqbinding/blob/master/src/sqbtable.h): `src/sqbtable.h`
- [Function binding](https://github.com/ligverd/sqbinding/blob/master/src/sqbfunction.h): `src/sqbfunction.h`
- [Class binding](https://github.com/ligverd/sqbinding/blob/master/src/sqbclass.h): `src/sqbclass.h`
- [Call dispatch](https://github.com/ligverd/sqbinding/blob/master/src/sqbdetail.h): `src/sqbdetail.h`

### Objects and values

- [Type conversion](https://github.com/ligverd/sqbinding/blob/master/src/sqbtypes.h): `src/sqbtypes.h`
- [VM object handles](https://github.com/ligverd/sqbinding/blob/master/src/sqbobject.cpp): `src/sqbobject.cpp`
- [Array binding](https://github.com/ligverd/sqbinding/blob/master/src/sqbarray.h): `src/sqbarray.h`
- [Table access](https://github.com/ligverd/sqbinding/blob/master/src/sqbtable.h): `src/sqbtable.h`
- [Object interface](https://github.com/ligverd/sqbinding/blob/master/src/sqbobject.h): `src/sqbobject.h`

### Other components

- **C++ application**
- **Squirrel VM**

## Connections

- C++ application → Binding API: configures and executes (evidence: `README.md`)
- Binding API → Squirrel VM: creates or wraps (evidence: `src/sqbinding.cpp`)
- Binding API → Squirrel VM: executes scripts (evidence: `src/sqbinding.cpp`)
- Binding API → Table binding: inherits
- Table binding → Class binding: binds classes (evidence: `src/sqbtable.h`)
- Table binding → Function binding: retrieves functions (evidence: `src/sqbtable.h`)
- Table binding → Array binding: creates arrays (evidence: `src/sqbtable.h`)
- Class binding → Call dispatch: registers methods (evidence: `src/sqbclass.h`)
- Function binding → Call dispatch: dispatches calls (evidence: `src/sqbfunction.h`)
- Call dispatch → Type conversion: converts arguments (evidence: `src/sqbdetail.h`)
- Array binding → Type conversion: converts elements (evidence: `src/sqbarray.h`)
- Table access → Type conversion: converts values (evidence: `src/sqbtable.h`)
- Array binding → VM object handles: uses handles (evidence: `src/sqbarray.h`)
- Class binding → VM object handles: uses handles (evidence: `src/sqbclass.h`)
- Function binding → VM object handles: uses handles (evidence: `src/sqbfunction.h`)
- Table access → VM object handles: uses handles (evidence: `src/sqbtable.h`)
- VM object handles → Object interface: implements (evidence: `src/sqbobject.cpp`)
- Table binding → Table access: provides access (evidence: `src/sqbtable.h`)
- Function binding → Squirrel VM: calls script function (evidence: `src/sqbfunction.h`)
- Binding API → Squirrel VM: registers standard libraries (evidence: `src/sqbinding.cpp`)
