c variadic calls
This commit is contained in:
@@ -10,4 +10,11 @@ main :: func() void {
|
||||
_ = native.child_value(7)
|
||||
_ = native.imported_read(native.imported_handle()?)
|
||||
_ = native.configured_value(9)
|
||||
signed i8 :: -2
|
||||
unsigned u16 :: 3
|
||||
float_value f32 :: 4.0
|
||||
c_float_value c_float :: 5.0
|
||||
pointer *u8 :: "ok".ptr
|
||||
nullable ?*u8 :: pointer
|
||||
_ = native.imported_variadic(7, signed, unsigned, float_value, c_float_value, pointer, nullable)
|
||||
}
|
||||
|
||||
@@ -35,6 +35,6 @@ int configured_value(int value);
|
||||
#endif
|
||||
|
||||
#define IMPORTED_MACRO 42
|
||||
int imported_variadic(const char *format, ...);
|
||||
int imported_variadic(int marker, ...);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "include/native.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct Imported_Handle {
|
||||
int value;
|
||||
@@ -26,6 +28,28 @@ int imported_read(const Imported_Handle *value) {
|
||||
return value->value;
|
||||
}
|
||||
|
||||
int imported_variadic(int marker, ...) {
|
||||
va_list args;
|
||||
va_start(args, marker);
|
||||
int narrow_signed = va_arg(args, int);
|
||||
int narrow_unsigned = va_arg(args, int);
|
||||
double float_value = va_arg(args, double);
|
||||
double c_float_value = va_arg(args, double);
|
||||
const unsigned char *pointer = va_arg(args, const unsigned char *);
|
||||
const unsigned char *nullable = va_arg(args, const unsigned char *);
|
||||
va_end(args);
|
||||
if (!(marker == 7 &&
|
||||
narrow_signed == -2 &&
|
||||
narrow_unsigned == 3 &&
|
||||
float_value == 4.0 &&
|
||||
c_float_value == 5.0 &&
|
||||
pointer[0] == 'o' &&
|
||||
nullable == pointer)) {
|
||||
abort();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef BROLANG_FEATURE
|
||||
int configured_value(int value) {
|
||||
return value;
|
||||
|
||||
@@ -5,7 +5,6 @@ use_union :: c_func(value native.Imported_Union) void
|
||||
use_enum :: c_func(value native.Imported_Enum) void
|
||||
|
||||
main :: func() void {
|
||||
_ = native.imported_variadic("value")
|
||||
_ = native.IMPORTED_MACRO
|
||||
_ = native.imported_by_value()
|
||||
_ = native.imported_volatile()
|
||||
|
||||
Reference in New Issue
Block a user