This commit is contained in:
agra
2026-03-06 10:46:28 +02:00
parent f9dda972d2
commit 69934592d8
8 changed files with 113 additions and 14 deletions

View File

@@ -0,0 +1,10 @@
// This module imports C functions and provides wrappers
#import c {
#include "vendors/test_c/test.h";
#source "vendors/test_c/test.c";
};
// Wrapper function that calls the C function
wrapped_add :: (a: s32, b: s32) -> s32 {
add_numbers(a, b);
}

View File

@@ -0,0 +1,18 @@
// Test: other.sx calls C functions without importing the C module
// main imports both c_wrapper.sx and other.sx
// other.sx should NOT have access to C functions from c_wrapper
#import "../modules/std.sx";
#import "c_wrapper.sx";
#import "other.sx";
main :: () -> s32 {
// This works: we import c_wrapper so we have transitive access
result := wrapped_add(10, 20);
print("wrapped_add(10, 20) = {}\n", result);
// This calls other.sx's function which tries to call add_numbers
// other.sx did NOT import c_wrapper.sx, so this should fail
bad := use_c_directly();
print("use_c_directly() = {}\n", bad);
0;
}

View File

@@ -0,0 +1,10 @@
// Test: calling wrapper functions works (we import the module)
#import "../modules/std.sx";
#import "c_wrapper.sx";
main :: () -> s32 {
// This should work: calling the sx wrapper
result := wrapped_add(10, 20);
print("wrapped_add(10, 20) = {}\n", result);
0;
}

View File

@@ -0,0 +1,6 @@
// This file does NOT import c_wrapper.sx
// It should NOT be able to call add_numbers
use_c_directly :: () -> s32 {
add_numbers(5, 3);
}