sentinel pointers and c strings

This commit is contained in:
2026-06-14 19:21:49 +02:00
parent 2d3d0bd266
commit 3b7c3fcbd0
16 changed files with 512 additions and 55 deletions
+1
View File
@@ -9,6 +9,7 @@ main :: func() void {
_ = native.imported_scalar(3, 4)
_ = native.child_value(7)
_ = native.imported_read(native.imported_handle()?)
_ = native.imported_string("hello")
_ = native.configured_value(9)
signed i8 :: -2
unsigned u16 :: 3
+1
View File
@@ -21,6 +21,7 @@ int imported_add(imported_int_alias left, int right);
unsigned long imported_scalar(unsigned char value, unsigned long extra);
Imported_Handle *imported_handle(void);
int imported_read(const Imported_Handle *handle);
int imported_string(const char *value);
Imported_Value imported_by_value(Imported_Value value);
int imported_volatile(volatile int *value);
_Bool imported_bool(_Bool value);
+8
View File
@@ -1,6 +1,7 @@
#include "include/native.h"
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
struct Imported_Handle {
int value;
@@ -28,6 +29,13 @@ int imported_read(const Imported_Handle *value) {
return value->value;
}
int imported_string(const char *value) {
if (strcmp(value, "hello") != 0) {
abort();
}
return 0;
}
int imported_variadic(int marker, ...) {
va_list args;
va_start(args, marker);
+5
View File
@@ -0,0 +1,5 @@
printf :: c_func(format *c_char, ...) c_int
main :: func() void {
_ = printf("answer: %d\n", 42)
}