GreyCat SDK - C API & Standard Library
Comprehensive reference for GreyCat native development (C API) and the GCL Standard Library.
Contents
- C API - Native function implementation, tensor operations, object manipulation
- Standard Library (std) - GCL runtime features, I/O, collections, and utilities
GreyCat C API
Core Concepts
gc_machine_t - Execution context passed to all native functions. Use to get parameters, set results, report errors, and create objects.
gc_slot_t - Universal value container (union type) holding any GreyCat value: integers, floats, bools, objects, etc.
gc_type_t - Type system enum defining all GreyCat types (null, bool, int, float, str, object, static_field, etc.).
Common Operations
Parameter handling:
gc_slot_t param = gc_machine__get_param(ctx, offset);
gc_type_t type = gc_machine__get_param_type(ctx, offset);
Object field access:
gc_slot_t value = gc_object__get_at(obj, field_offset, &type, ctx);
Tensor operations:
gc_core_tensor_t *tensor = gc_core_tensor__create(ctx);
gc_core_tensor__init_2d(tensor, rows, cols, gc_core_TensorType_f32, ctx);
f32_t val = gc_core_tensor__get_2d_f32(tensor, row, col, ctx);
Memory management:
char *temp = (char *)gc_gnu_malloc(size); // Per-worker allocator
double *shared = (double *)gc_global_gnu_malloc(size); // Global allocator
Detailed Reference
File: references/api_reference.md (1,461 lines)
Load when implementing:
- Native C functions with gc_machine_t
- Tensor operations (multi-dimensional arrays)
- Object/field manipulation, type introspection
- Buffer building, string operations
- HTTP client, cryptography, I/O operations
Contains: Complete function signatures, real production examples, and documentation for Machine API, Object API, Tensor API, Array/Table APIs, Buffer/String APIs, Memory Allocation, Program/Type System, HTTP Client, Cryptography, and I/O.
GreyCat Standard Library (std)
Module Organization
- std::core - Fundamental types (Date, Time, Duration, Tuple, Error, geospatial types, enumerations)
- std::runtime - Scheduler, Task, Job, Logger, User/Security, System, ChildProcess, License, OpenAPI, MCP
- std::io - Text/Binary I/O, CSV, JSON, XML, HTTP client, Email/SMTP, FileWalker
- std::util - Collections (Queue, Stack, SlidingWindow, TimeWindow), Statistics (Gaussian, Histogram), Quantizers, Assert, ProgressTracker, Crypto, Random, Plot
Detailed Reference
File: references/standard_library.md (957 lines)
Load when working with:
- Task scheduling and automation (Scheduler with periodicities)
- File I/O operations (CSV, JSON, XML, binary files)
- HTTP integration and REST APIs
- Statistical analysis and data processing
- Security, authentication, and user management
- System operations and logging
Contains: Complete documentation for all four standard library modules with code examples, usage patterns, and best practices.
1---
2name: greycat-c
3description: "GreyCat C API and GCL Standard Library reference. Use for: (1) Native C development with gc_machine_t context, tensors, objects, memory management, HTTP, crypto, I/O; (2) GCL Standard Library modules - std::core (Date/Time/Tuple/geospatial types), std::runtime (Scheduler/Task/Logger/User/Security/System/OpenAPI/MCP), std::io (CSV/JSON/XML/HTTP/Email/FileWalker), std::util (Queue/Stack/SlidingWindow/Gaussian/Histogram/Quantizers/Random/Plot). Keywords: GreyCat, GCL, native functions, tensors, task automation, scheduler."
4metadata:
5 source: https://skillmd.com/skills/aibot88/greycat-c
6---
7
8# GreyCat SDK - C API & Standard Library
9
10Comprehensive reference for GreyCat native development (C API) and the GCL Standard Library.
11
12## Contents
13
141. **C API** - Native function implementation, tensor operations, object manipulation
152. **Standard Library (std)** - GCL runtime features, I/O, collections, and utilities
16
17---
18
19# GreyCat C API
20
21## Core Concepts
22
23**gc_machine_t** - Execution context passed to all native functions. Use to get parameters, set results, report errors, and create objects.
24
25**gc_slot_t** - Universal value container (union type) holding any GreyCat value: integers, floats, bools, objects, etc.
26
27**gc_type_t** - Type system enum defining all GreyCat types (null, bool, int, float, str, object, static_field, etc.).
28
29## Common Operations
30
31**Parameter handling:**
32```c
33gc_slot_t param = gc_machine__get_param(ctx, offset);
34gc_type_t type = gc_machine__get_param_type(ctx, offset);
35```
36
37**Object field access:**
38```c
39gc_slot_t value = gc_object__get_at(obj, field_offset, &type, ctx);
40```
41
42**Tensor operations:**
43```c
44gc_core_tensor_t *tensor = gc_core_tensor__create(ctx);
45gc_core_tensor__init_2d(tensor, rows, cols, gc_core_TensorType_f32, ctx);
46f32_t val = gc_core_tensor__get_2d_f32(tensor, row, col, ctx);
47```
48
49**Memory management:**
50```c
51char *temp = (char *)gc_gnu_malloc(size); // Per-worker allocator
52double *shared = (double *)gc_global_gnu_malloc(size); // Global allocator
53```
54
55## Detailed Reference
56
57**File:** [references/api_reference.md](references/api_reference.md) (1,461 lines)
58
59**Load when implementing:**
60- Native C functions with gc_machine_t
61- Tensor operations (multi-dimensional arrays)
62- Object/field manipulation, type introspection
63- Buffer building, string operations
64- HTTP client, cryptography, I/O operations
65
66**Contains:** Complete function signatures, real production examples, and documentation for Machine API, Object API, Tensor API, Array/Table APIs, Buffer/String APIs, Memory Allocation, Program/Type System, HTTP Client, Cryptography, and I/O.
67
68---
69
70# GreyCat Standard Library (std)
71
72## Module Organization
73
74- **std::core** - Fundamental types (Date, Time, Duration, Tuple, Error, geospatial types, enumerations)
75- **std::runtime** - Scheduler, Task, Job, Logger, User/Security, System, ChildProcess, License, OpenAPI, MCP
76- **std::io** - Text/Binary I/O, CSV, JSON, XML, HTTP client, Email/SMTP, FileWalker
77- **std::util** - Collections (Queue, Stack, SlidingWindow, TimeWindow), Statistics (Gaussian, Histogram), Quantizers, Assert, ProgressTracker, Crypto, Random, Plot
78
79## Detailed Reference
80
81**File:** [references/standard_library.md](references/standard_library.md) (957 lines)
82
83**Load when working with:**
84- Task scheduling and automation (Scheduler with periodicities)
85- File I/O operations (CSV, JSON, XML, binary files)
86- HTTP integration and REST APIs
87- Statistical analysis and data processing
88- Security, authentication, and user management
89- System operations and logging
90
91**Contains:** Complete documentation for all four standard library modules with code examples, usage patterns, and best practices.