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