Files
brolang/examples/interop/header/app/main.bro
T

66 lines
2.2 KiB
Plaintext

native :: import "../include/native.h"
pass_alias :: func(value native.imported_int_alias) native.imported_int {
return value
}
double_value :: c_func(value c_int) c_int {
return value + value
}
call_mapper :: func(mapper native.Imported_Mapper) c_int {
return mapper?(21)
}
main :: func() void {
_ = native.imported_add(pass_alias(20), 22)
_ = native.imported_scalar(3, 4)
_ = native.child_value(7)
_ = native.imported_read(native.imported_handle()?)
_ = native.imported_string("hello")
_ = native.imported_apply(double_value, 21)
_ = call_mapper(double_value)
_ = native.configured_value(9)
_ = native.IMPORTED_SHADOW_OBJECT
_ = native.IMPORTED_SHADOW_FUNCTION
native.imported_global = native.IMPORTED_MAGIC
native.imported_record_global.value = native.IMPORTED_MAGIC
color native.Imported_Color :: native.IMPORTED_COLOR
_ = native.imported_check_state(
color,
native.IMPORTED_MAGIC,
native.imported_const_global,
native.imported_global,
native.imported_record_global.value,
native.IMPORTED_OCTAL,
native.IMPORTED_UINT,
native.IMPORTED_REDEFINED,
native.IMPORTED_ACTIVE_AFTER_INACTIVE_UNDEF,
native.IMPORTED_REPEAT,
native.IMPORTED_HEX_E,
native.IMPORTED_NEG_DECIMAL,
native.IMPORTED_NEG_HEX,
native.IMPORTED_NEG_UINT,
native.IMPORTED_FLOAT,
native.IMPORTED_DOUBLE,
)
partial native.Imported_Color :: native.IMPORTED_PARTIAL_COLOR
nested native.Imported_Zero_Outer :: native.IMPORTED_ZERO_NESTED
first_union native.Imported_Zero_Union :: native.IMPORTED_FIRST_UNION
_ = native.imported_check_zero_state(partial, nested, first_union)
native.imported_mutable_array_record.values[0] = 42
_ = native.imported_check_array_record()
conversions native.Imported_Conversions :: native.IMPORTED_CONVERSIONS
_ = native.imported_check_conversions(conversions)
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)
inline_scalar c_int :: native.imported_inline(5)
inline_record native.Imported_Value :: native.imported_inline_record(native.Imported_Value { value = 7 })
_ = native.imported_check_inline(inline_scalar, inline_record.value)
}