ffi: move test-companion .c/.h next to their .sx (drop vendors/ namespace)
vendors/ is a third-party namespace (stb_image, kb_text_shape, etc.);
test fixtures don't belong there. The .c/.h companion files for the
Phase-0 FFI baselines now sit alongside the .sx that drives them in
examples/, with matching basenames:
examples/ffi-01-primitives.{sx,c,h} <- was vendors/ffi_primitives/
examples/ffi-02-small-struct.{sx,c,h} <- was vendors/ffi_structs/
examples/ffi-03-large-struct.{sx,c,h} <- was vendors/ffi_large_struct/
examples/ffi-04-fp-struct.{sx,c,h} <- was vendors/ffi_fp_struct/
examples/ffi-05-string-args.{sx,c,h} <- was vendors/ffi_strings/
examples/ffi-06-callback.{sx,c,h} <- was vendors/ffi_callback/
examples/101-ffi-medium-struct.{sx,c} <- was vendors/ffi_medium_struct/
`#source` / `#include` paths in the .sx files become bare filenames
(no prefix) since imports.zig's base_dir resolution finds them
relative to the importing .sx file's directory.
`library/vendors/sx_ffi_resolve_test/` stays put — that one's the
whole point: regression coverage for the stdlib-search branch of
the resolution chain, so it must live where ONLY that branch can
find it.
94/94 regression tests pass.
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
#import "modules/std.sx";
|
||||
|
||||
#import c {
|
||||
#source "vendors/ffi_medium_struct/ffi_medium_struct.c";
|
||||
#source "101-ffi-medium-struct.c";
|
||||
};
|
||||
|
||||
Pair64 :: struct { a: s64; b: s64; }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "ffi_primitives.h"
|
||||
#include "ffi-01-primitives.h"
|
||||
|
||||
int ffi_id_int (int v) { return v; }
|
||||
unsigned int ffi_id_uint (unsigned int v) { return v; }
|
||||
@@ -10,8 +10,8 @@
|
||||
#import "modules/std.sx";
|
||||
|
||||
#import c {
|
||||
#include "vendors/ffi_primitives/ffi_primitives.h";
|
||||
#source "vendors/ffi_primitives/ffi_primitives.c";
|
||||
#include "ffi-01-primitives.h";
|
||||
#source "ffi-01-primitives.c";
|
||||
};
|
||||
|
||||
main :: () -> s32 {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "ffi_structs.h"
|
||||
#include "ffi-02-small-struct.h"
|
||||
|
||||
Vec2 ffi_vec2_make(float x, float y) {
|
||||
Vec2 r = { x, y };
|
||||
@@ -18,7 +18,7 @@
|
||||
// by-value ABI. The hand-written #foreign decls below keep sx's
|
||||
// struct types end-to-end.
|
||||
#import c {
|
||||
#source "vendors/ffi_structs/ffi_structs.c";
|
||||
#source "ffi-02-small-struct.c";
|
||||
};
|
||||
|
||||
Vec2 :: struct { x: f32; y: f32; }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "ffi_large_struct.h"
|
||||
#include "ffi-03-large-struct.h"
|
||||
|
||||
Big24 ffi_big24_make(long long a, long long b, long long c) {
|
||||
Big24 r = { a, b, c };
|
||||
@@ -16,7 +16,7 @@
|
||||
#import "modules/std.sx";
|
||||
|
||||
#import c {
|
||||
#source "vendors/ffi_large_struct/ffi_large_struct.c";
|
||||
#source "ffi-03-large-struct.c";
|
||||
};
|
||||
|
||||
Big24 :: struct { a: s64; b: s64; c: s64; }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "ffi_fp_struct.h"
|
||||
#include "ffi-04-fp-struct.h"
|
||||
|
||||
FQuad ffi_fquad_make(float a, float b, float c, float d) {
|
||||
FQuad r = { a, b, c, d };
|
||||
@@ -16,7 +16,7 @@
|
||||
#import "modules/std.sx";
|
||||
|
||||
#import c {
|
||||
#source "vendors/ffi_fp_struct/ffi_fp_struct.c";
|
||||
#source "ffi-04-fp-struct.c";
|
||||
};
|
||||
|
||||
FQuad :: struct { a: f32; b: f32; c: f32; d: f32; }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "ffi_strings.h"
|
||||
#include "ffi-05-string-args.h"
|
||||
|
||||
int ffi_strlen(const char *s) {
|
||||
int n = 0;
|
||||
@@ -11,7 +11,7 @@
|
||||
#import "modules/std.sx";
|
||||
|
||||
#import c {
|
||||
#source "vendors/ffi_strings/ffi_strings.c";
|
||||
#source "ffi-05-string-args.c";
|
||||
};
|
||||
|
||||
ffi_strlen :: (s: [:0]u8) -> s32 #foreign;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "ffi_callback.h"
|
||||
#include "ffi-06-callback.h"
|
||||
|
||||
int ffi_apply_callback(int (*cb)(int), int value) {
|
||||
return cb(value);
|
||||
@@ -13,7 +13,7 @@
|
||||
#import "modules/std.sx";
|
||||
|
||||
#import c {
|
||||
#source "vendors/ffi_callback/ffi_callback.c";
|
||||
#source "ffi-06-callback.c";
|
||||
};
|
||||
|
||||
ffi_apply_callback :: (cb: (s32) -> s32, value: s32) -> s32 #foreign;
|
||||
|
||||
Reference in New Issue
Block a user