Skip to content

Commit 66e1cd1

Browse files
committed
chore: M5 CI/Workflow Sweep - final synchronisation
1 parent 1933a06 commit 66e1cd1

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

ffi/zig/src/main.zig

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// {{PROJECT}} FFI Implementation
1+
// DOCMATRIX FFI Implementation
22
//
33
// This module implements the C-compatible FFI declared in src/abi/Foreign.idr
44
// All types and layouts must match the Idris2 ABI definitions.
@@ -9,7 +9,7 @@ const std = @import("std");
99

1010
// Version information (keep in sync with project)
1111
const VERSION = "0.1.0";
12-
const BUILD_INFO = "{{PROJECT}} built with Zig " ++ @import("builtin").zig_version_string;
12+
const BUILD_INFO = "DOCMATRIX built with Zig " ++ @import("builtin").zig_version_string;
1313

1414
/// Thread-local error storage
1515
threadlocal var last_error: ?[]const u8 = null;
@@ -51,7 +51,7 @@ pub const Handle = opaque {
5151

5252
/// Initialize the library
5353
/// Returns a handle, or null on failure
54-
export fn {{project}}_init() ?*Handle {
54+
export fn docmatrix_init() ?*Handle {
5555
const allocator = std.heap.c_allocator;
5656

5757
const handle = allocator.create(Handle) catch {
@@ -70,7 +70,7 @@ export fn {{project}}_init() ?*Handle {
7070
}
7171

7272
/// Free the library handle
73-
export fn {{project}}_free(handle: ?*Handle) void {
73+
export fn docmatrix_free(handle: ?*Handle) void {
7474
const h = handle orelse return;
7575
const allocator = h.allocator;
7676

@@ -86,7 +86,7 @@ export fn {{project}}_free(handle: ?*Handle) void {
8686
//==============================================================================
8787

8888
/// Process data (example operation)
89-
export fn {{project}}_process(handle: ?*Handle, input: u32) Result {
89+
export fn docmatrix_process(handle: ?*Handle, input: u32) Result {
9090
const h = handle orelse {
9191
setError("Null handle");
9292
return .null_pointer;
@@ -110,7 +110,7 @@ export fn {{project}}_process(handle: ?*Handle, input: u32) Result {
110110

111111
/// Get a string result (example)
112112
/// Caller must free the returned string
113-
export fn {{project}}_get_string(handle: ?*Handle) ?[*:0]const u8 {
113+
export fn docmatrix_get_string(handle: ?*Handle) ?[*:0]const u8 {
114114
const h = handle orelse {
115115
setError("Null handle");
116116
return null;
@@ -132,7 +132,7 @@ export fn {{project}}_get_string(handle: ?*Handle) ?[*:0]const u8 {
132132
}
133133

134134
/// Free a string allocated by the library
135-
export fn {{project}}_free_string(str: ?[*:0]const u8) void {
135+
export fn docmatrix_free_string(str: ?[*:0]const u8) void {
136136
const s = str orelse return;
137137
const allocator = std.heap.c_allocator;
138138

@@ -145,7 +145,7 @@ export fn {{project}}_free_string(str: ?[*:0]const u8) void {
145145
//==============================================================================
146146

147147
/// Process an array of data
148-
export fn {{project}}_process_array(
148+
export fn docmatrix_process_array(
149149
handle: ?*Handle,
150150
buffer: ?[*]const u8,
151151
len: u32,
@@ -181,7 +181,7 @@ export fn {{project}}_process_array(
181181

182182
/// Get the last error message
183183
/// Returns null if no error
184-
export fn {{project}}_last_error() ?[*:0]const u8 {
184+
export fn docmatrix_last_error() ?[*:0]const u8 {
185185
const err = last_error orelse return null;
186186

187187
// Return C string (static storage, no need to free)
@@ -195,12 +195,12 @@ export fn {{project}}_last_error() ?[*:0]const u8 {
195195
//==============================================================================
196196

197197
/// Get the library version
198-
export fn {{project}}_version() [*:0]const u8 {
198+
export fn docmatrix_version() [*:0]const u8 {
199199
return VERSION.ptr;
200200
}
201201

202202
/// Get build information
203-
export fn {{project}}_build_info() [*:0]const u8 {
203+
export fn docmatrix_build_info() [*:0]const u8 {
204204
return BUILD_INFO.ptr;
205205
}
206206

@@ -212,7 +212,7 @@ export fn {{project}}_build_info() [*:0]const u8 {
212212
pub const Callback = *const fn (u64, u32) callconv(.C) u32;
213213

214214
/// Register a callback
215-
export fn {{project}}_register_callback(
215+
export fn docmatrix_register_callback(
216216
handle: ?*Handle,
217217
callback: ?Callback,
218218
) Result {
@@ -243,7 +243,7 @@ export fn {{project}}_register_callback(
243243
//==============================================================================
244244

245245
/// Check if handle is initialized
246-
export fn {{project}}_is_initialized(handle: ?*Handle) u32 {
246+
export fn docmatrix_is_initialized(handle: ?*Handle) u32 {
247247
const h = handle orelse return 0;
248248
return if (h.initialized) 1 else 0;
249249
}
@@ -253,22 +253,22 @@ export fn {{project}}_is_initialized(handle: ?*Handle) u32 {
253253
//==============================================================================
254254

255255
test "lifecycle" {
256-
const handle = {{project}}_init() orelse return error.InitFailed;
257-
defer {{project}}_free(handle);
256+
const handle = docmatrix_init() orelse return error.InitFailed;
257+
defer docmatrix_free(handle);
258258

259-
try std.testing.expect({{project}}_is_initialized(handle) == 1);
259+
try std.testing.expect(docmatrix_is_initialized(handle) == 1);
260260
}
261261

262262
test "error handling" {
263-
const result = {{project}}_process(null, 0);
263+
const result = docmatrix_process(null, 0);
264264
try std.testing.expectEqual(Result.null_pointer, result);
265265

266-
const err = {{project}}_last_error();
266+
const err = docmatrix_last_error();
267267
try std.testing.expect(err != null);
268268
}
269269

270270
test "version" {
271-
const ver = {{project}}_version();
271+
const ver = docmatrix_version();
272272
const ver_str = std.mem.span(ver);
273273
try std.testing.expectEqualStrings(VERSION, ver_str);
274274
}

0 commit comments

Comments
 (0)