From 3fc8e2808b73f93cbc4150be58951127fcd7d606 Mon Sep 17 00:00:00 2001 From: Zxilly Date: Wed, 3 Jun 2026 09:45:25 +0800 Subject: [PATCH 1/2] fix: emit package header before helpers --- cjbind/src/codegen/lib.cj | 5 +- .../testdata/expected/16-byte-alignment.cj | 284 ++-- .../testdata/expected/anon-fields-prefix.cj | 4 +- .../testdata/expected/anon_struct_in_union.cj | 98 +- .../expected/bitfield-32bit-overflow.cj | 1086 ++++++------- .../testdata/expected/bitfield_align.cj | 460 +++--- .../testdata/expected/bitfield_align_2.cj | 67 +- .../expected/bitfield_method_mangling.cj | 57 +- .../testdata/expected/bitfield_pack_offset.cj | 134 +- .../divide-by-zero-in-struct-layout.cj | 30 +- .../expected/incomplete-array-padding.cj | 44 +- cjbind_test/testdata/expected/layout_align.cj | 126 +- .../testdata/expected/layout_eth_conf.cj | 1382 ++++++++--------- cjbind_test/testdata/expected/layout_mbuf.cj | 4 +- .../expected/packed-struct-anon-union.cj | 4 +- .../expected/struct_with_anon_union.cj | 86 +- .../struct_with_anon_unnamed_union.cj | 82 +- .../expected/struct_with_bitfields.cj | 287 ++-- .../testdata/expected/struct_with_nesting.cj | 168 +- .../expected/typedef-pointer-overlap.cj | 121 +- cjbind_test/testdata/expected/union-align.cj | 78 +- .../expected/union_with_anon_struct.cj | 86 +- .../union_with_anon_struct_bitfield.cj | 106 +- .../expected/union_with_anon_union.cj | 106 +- .../union_with_anon_unnamed_struct.cj | 94 +- .../expected/union_with_anon_unnamed_union.cj | 106 +- .../testdata/expected/union_with_nesting.cj | 186 +-- .../expected/union_with_zero_sized_array.cj | 4 +- 28 files changed, 2640 insertions(+), 2655 deletions(-) diff --git a/cjbind/src/codegen/lib.cj b/cjbind/src/codegen/lib.cj index 58ed3d0..e83ec11 100644 --- a/cjbind/src/codegen/lib.cj +++ b/cjbind/src/codegen/lib.cj @@ -28,6 +28,7 @@ public enum CodegenError { } public class CodegenResult { + public let headers: ArrayList = ArrayList() public let items: ArrayList = ArrayList() public let helpers: ArrayList = ArrayList() @@ -72,6 +73,7 @@ public class CodegenResult { this.sawIncompleteArray ||= next.sawIncompleteArray this.sawCjbindUnion ||= next.sawCjbindUnion this.sawBitfieldUnit ||= next.sawBitfieldUnit + this.headers.add(all: next.headers) this.helpers.add(all: next.helpers) return next.items @@ -94,6 +96,7 @@ public func codegen(tctx: CjbindContext): Result { ) let allItems = ArrayList() + allItems.add(all: result.headers) allItems.add(all: result.helpers) allItems.add(all: result.items) let ret = joinStreams(allItems, "\n\n") @@ -156,7 +159,7 @@ extend Module <: CodeGenerator { package ${pkgName} ) - result.items.add(header, at: 0) + result.headers.add(header) } } } diff --git a/cjbind_test/testdata/expected/16-byte-alignment.cj b/cjbind_test/testdata/expected/16-byte-alignment.cj index 7196d5e..c3e6725 100644 --- a/cjbind_test/testdata/expected/16-byte-alignment.cj +++ b/cjbind_test/testdata/expected/16-byte-alignment.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_read_rte_ipv4_tuple__cjbind_ty_1(ptr: CPointer): rte_ipv4_tuple__cjbind_ty_1 { return unsafe { CPointer(ptr).read() } @@ -48,199 +50,197 @@ func __cjbind_write_rte_ipv6_tuple_rte_ipv6_tuple(ptr: CPointer, val: rte unsafe { CPointer(ptr).write(val) } } -package cjbind_ffi - @C public struct rte_ipv4_tuple__cjbind_ty_1 { -public let dport : UInt16 -public let sport : UInt16 -public init(dport : UInt16 , sport : UInt16) { - this.dport = dport -this.sport = sport -} + public let dport: UInt16 + public let sport: UInt16 + public init(dport: UInt16, sport: UInt16) { + this.dport = dport + this.sport = sport + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of rte_ipv4_tuple__cjbind_ty_1 is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 2) { - throw Exception("Alignment of rte_ipv4_tuple__cjbind_ty_1 is not 2 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of rte_ipv4_tuple__cjbind_ty_1 is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 2) { + throw Exception("Alignment of rte_ipv4_tuple__cjbind_ty_1 is not 2 but ${align} bytes") + } } @C public struct rte_ipv4_tuple__cjbind_ty_1 { -var _storage: UInt32 = unsafe { zeroValue() } -public init() {} -public func __cjbind_anon_1(): rte_ipv4_tuple__cjbind_ty_1 { - var s = this._storage - return unsafe { __cjbind_read_rte_ipv4_tuple__cjbind_ty_1(CPointer(inout s)) } -} -public mut func __cjbind_anon_1(val!: rte_ipv4_tuple__cjbind_ty_1): Unit { - unsafe { __cjbind_write_rte_ipv4_tuple__cjbind_ty_1(CPointer(inout this._storage), val) } -} -public func sctp_tag(): UInt32 { - var s = this._storage - return unsafe { __cjbind_read_UInt32(CPointer(inout s)) } -} -public mut func sctp_tag(val!: UInt32): Unit { - unsafe { __cjbind_write_UInt32(CPointer(inout this._storage), val) } -} + var _storage: UInt32 = unsafe { zeroValue() } + public init() {} + public func __cjbind_anon_1(): rte_ipv4_tuple__cjbind_ty_1 { + var s = this._storage + return unsafe { __cjbind_read_rte_ipv4_tuple__cjbind_ty_1(CPointer(inout s)) } + } + public mut func __cjbind_anon_1(val!: rte_ipv4_tuple__cjbind_ty_1): Unit { + unsafe { __cjbind_write_rte_ipv4_tuple__cjbind_ty_1(CPointer(inout this._storage), val) } + } + public func sctp_tag(): UInt32 { + var s = this._storage + return unsafe { __cjbind_read_UInt32(CPointer(inout s)) } + } + public mut func sctp_tag(val!: UInt32): Unit { + unsafe { __cjbind_write_UInt32(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of rte_ipv4_tuple__cjbind_ty_1 is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of rte_ipv4_tuple__cjbind_ty_1 is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of rte_ipv4_tuple__cjbind_ty_1 is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of rte_ipv4_tuple__cjbind_ty_1 is not 4 but ${align} bytes") + } } @C public struct rte_ipv4_tuple_rte_ipv4_tuple { -public let src_addr : UInt32 -public let dst_addr : UInt32 -public let __cjbind_anon_1 : rte_ipv4_tuple__cjbind_ty_1 -public init(src_addr : UInt32 , dst_addr : UInt32 , __cjbind_anon_1 : rte_ipv4_tuple__cjbind_ty_1) { - this.src_addr = src_addr -this.dst_addr = dst_addr -this.__cjbind_anon_1 = __cjbind_anon_1 -} + public let src_addr: UInt32 + public let dst_addr: UInt32 + public let __cjbind_anon_1: rte_ipv4_tuple__cjbind_ty_1 + public init(src_addr: UInt32, dst_addr: UInt32, __cjbind_anon_1: rte_ipv4_tuple__cjbind_ty_1) { + this.src_addr = src_addr + this.dst_addr = dst_addr + this.__cjbind_anon_1 = __cjbind_anon_1 + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 12) { - throw Exception("Size of rte_ipv4_tuple_rte_ipv4_tuple is not 12 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of rte_ipv4_tuple_rte_ipv4_tuple is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 12) { + throw Exception("Size of rte_ipv4_tuple_rte_ipv4_tuple is not 12 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of rte_ipv4_tuple_rte_ipv4_tuple is not 4 but ${align} bytes") + } } @C public struct rte_ipv6_tuple__cjbind_ty_1 { -public let dport : UInt16 -public let sport : UInt16 -public init(dport : UInt16 , sport : UInt16) { - this.dport = dport -this.sport = sport -} + public let dport: UInt16 + public let sport: UInt16 + public init(dport: UInt16, sport: UInt16) { + this.dport = dport + this.sport = sport + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of rte_ipv6_tuple__cjbind_ty_1 is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 2) { - throw Exception("Alignment of rte_ipv6_tuple__cjbind_ty_1 is not 2 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of rte_ipv6_tuple__cjbind_ty_1 is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 2) { + throw Exception("Alignment of rte_ipv6_tuple__cjbind_ty_1 is not 2 but ${align} bytes") + } } @C public struct rte_ipv6_tuple__cjbind_ty_1 { -var _storage: UInt32 = unsafe { zeroValue() } -public init() {} -public func __cjbind_anon_1(): rte_ipv6_tuple__cjbind_ty_1 { - var s = this._storage - return unsafe { __cjbind_read_rte_ipv6_tuple__cjbind_ty_1(CPointer(inout s)) } -} -public mut func __cjbind_anon_1(val!: rte_ipv6_tuple__cjbind_ty_1): Unit { - unsafe { __cjbind_write_rte_ipv6_tuple__cjbind_ty_1(CPointer(inout this._storage), val) } -} -public func sctp_tag(): UInt32 { - var s = this._storage - return unsafe { __cjbind_read_UInt32(CPointer(inout s)) } -} -public mut func sctp_tag(val!: UInt32): Unit { - unsafe { __cjbind_write_UInt32(CPointer(inout this._storage), val) } -} + var _storage: UInt32 = unsafe { zeroValue() } + public init() {} + public func __cjbind_anon_1(): rte_ipv6_tuple__cjbind_ty_1 { + var s = this._storage + return unsafe { __cjbind_read_rte_ipv6_tuple__cjbind_ty_1(CPointer(inout s)) } + } + public mut func __cjbind_anon_1(val!: rte_ipv6_tuple__cjbind_ty_1): Unit { + unsafe { __cjbind_write_rte_ipv6_tuple__cjbind_ty_1(CPointer(inout this._storage), val) } + } + public func sctp_tag(): UInt32 { + var s = this._storage + return unsafe { __cjbind_read_UInt32(CPointer(inout s)) } + } + public mut func sctp_tag(val!: UInt32): Unit { + unsafe { __cjbind_write_UInt32(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of rte_ipv6_tuple__cjbind_ty_1 is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of rte_ipv6_tuple__cjbind_ty_1 is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of rte_ipv6_tuple__cjbind_ty_1 is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of rte_ipv6_tuple__cjbind_ty_1 is not 4 but ${align} bytes") + } } @C public struct rte_ipv6_tuple_rte_ipv6_tuple { -public let src_addr : VArray -public let dst_addr : VArray -public let __cjbind_anon_1 : rte_ipv6_tuple__cjbind_ty_1 -public init(src_addr : VArray , dst_addr : VArray , __cjbind_anon_1 : rte_ipv6_tuple__cjbind_ty_1) { - this.src_addr = src_addr -this.dst_addr = dst_addr -this.__cjbind_anon_1 = __cjbind_anon_1 -} + public let src_addr: VArray + public let dst_addr: VArray + public let __cjbind_anon_1: rte_ipv6_tuple__cjbind_ty_1 + public init(src_addr: VArray, dst_addr: VArray, __cjbind_anon_1: rte_ipv6_tuple__cjbind_ty_1) { + this.src_addr = src_addr + this.dst_addr = dst_addr + this.__cjbind_anon_1 = __cjbind_anon_1 + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 36) { - throw Exception("Size of rte_ipv6_tuple_rte_ipv6_tuple is not 36 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of rte_ipv6_tuple_rte_ipv6_tuple is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 36) { + throw Exception("Size of rte_ipv6_tuple_rte_ipv6_tuple is not 36 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of rte_ipv6_tuple_rte_ipv6_tuple is not 4 but ${align} bytes") + } } @C public struct rte_thash_tuple_rte_thash_tuple { -var _storage: VArray = unsafe { zeroValue>() } -public init() {} -public func v4(): rte_ipv4_tuple_rte_ipv4_tuple { - var s = this._storage - return unsafe { __cjbind_read_rte_ipv4_tuple_rte_ipv4_tuple(CPointer(inout s)) } -} -public mut func v4(val!: rte_ipv4_tuple_rte_ipv4_tuple): Unit { - unsafe { __cjbind_write_rte_ipv4_tuple_rte_ipv4_tuple(CPointer(inout this._storage), val) } -} -public func v6(): rte_ipv6_tuple_rte_ipv6_tuple { - var s = this._storage - return unsafe { __cjbind_read_rte_ipv6_tuple_rte_ipv6_tuple(CPointer(inout s)) } -} -public mut func v6(val!: rte_ipv6_tuple_rte_ipv6_tuple): Unit { - unsafe { __cjbind_write_rte_ipv6_tuple_rte_ipv6_tuple(CPointer(inout this._storage), val) } -} + var _storage: VArray = unsafe { zeroValue>() } + public init() {} + public func v4(): rte_ipv4_tuple_rte_ipv4_tuple { + var s = this._storage + return unsafe { __cjbind_read_rte_ipv4_tuple_rte_ipv4_tuple(CPointer(inout s)) } + } + public mut func v4(val!: rte_ipv4_tuple_rte_ipv4_tuple): Unit { + unsafe { __cjbind_write_rte_ipv4_tuple_rte_ipv4_tuple(CPointer(inout this._storage), val) } + } + public func v6(): rte_ipv6_tuple_rte_ipv6_tuple { + var s = this._storage + return unsafe { __cjbind_read_rte_ipv6_tuple_rte_ipv6_tuple(CPointer(inout s)) } + } + public mut func v6(val!: rte_ipv6_tuple_rte_ipv6_tuple): Unit { + unsafe { __cjbind_write_rte_ipv6_tuple_rte_ipv6_tuple(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 48) { - throw Exception("Size of rte_thash_tuple_rte_thash_tuple is not 48 but ${size} bytes") - } - let align = alignOf() - if (align != 16) { - throw Exception("Alignment of rte_thash_tuple_rte_thash_tuple is not 16 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 48) { + throw Exception("Size of rte_thash_tuple_rte_thash_tuple is not 48 but ${size} bytes") + } + let align = alignOf() + if (align != 16) { + throw Exception("Alignment of rte_thash_tuple_rte_thash_tuple is not 16 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/anon-fields-prefix.cj b/cjbind_test/testdata/expected/anon-fields-prefix.cj index 3475e61..c528767 100644 --- a/cjbind_test/testdata/expected/anon-fields-prefix.cj +++ b/cjbind_test/testdata/expected/anon-fields-prefix.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_read_color__cjbind_ty_1(ptr: CPointer): color__cjbind_ty_1 { return unsafe { CPointer(ptr).read() } @@ -28,8 +30,6 @@ func __cjbind_write_VArray(ptr: CPointer, val: VArray>(ptr).write(val) } } -package cjbind_ffi - @C public struct color__cjbind_ty_1 { public let r : UInt8 diff --git a/cjbind_test/testdata/expected/anon_struct_in_union.cj b/cjbind_test/testdata/expected/anon_struct_in_union.cj index 64aaa6a..9a6ecc1 100644 --- a/cjbind_test/testdata/expected/anon_struct_in_union.cj +++ b/cjbind_test/testdata/expected/anon_struct_in_union.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_read_s_inner_inner(ptr: CPointer): s_inner_inner { return unsafe { CPointer(ptr).read() } @@ -8,74 +10,72 @@ func __cjbind_write_s_inner_inner(ptr: CPointer, val: s_inner_inner): Uni unsafe { CPointer(ptr).write(val) } } -package cjbind_ffi - @C public struct s_inner_inner { -public let b : Int32 -public init(b : Int32) { - this.b = b -} + public let b: Int32 + public init(b: Int32) { + this.b = b + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of s_inner_inner is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of s_inner_inner is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of s_inner_inner is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of s_inner_inner is not 4 but ${align} bytes") + } } @C public struct s__cjbind_ty_1 { -var _storage: UInt32 = unsafe { zeroValue() } -public init() {} -public func field(): s_inner_inner { - var s = this._storage - return unsafe { __cjbind_read_s_inner_inner(CPointer(inout s)) } -} -public mut func field(val!: s_inner_inner): Unit { - unsafe { __cjbind_write_s_inner_inner(CPointer(inout this._storage), val) } -} + var _storage: UInt32 = unsafe { zeroValue() } + public init() {} + public func field(): s_inner_inner { + var s = this._storage + return unsafe { __cjbind_read_s_inner_inner(CPointer(inout s)) } + } + public mut func field(val!: s_inner_inner): Unit { + unsafe { __cjbind_write_s_inner_inner(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of s__cjbind_ty_1 is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of s__cjbind_ty_1 is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of s__cjbind_ty_1 is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of s__cjbind_ty_1 is not 4 but ${align} bytes") + } } @C public struct s_s { -public let u : s__cjbind_ty_1 -public let __cjbind_anon_1 : s__cjbind_ty_1 -public init(u : s__cjbind_ty_1 , __cjbind_anon_1 : s__cjbind_ty_1) { - this.u = u -this.__cjbind_anon_1 = __cjbind_anon_1 -} + public let u: s__cjbind_ty_1 + public let __cjbind_anon_1: s__cjbind_ty_1 + public init(u: s__cjbind_ty_1, __cjbind_anon_1: s__cjbind_ty_1) { + this.u = u + this.__cjbind_anon_1 = __cjbind_anon_1 + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of s_s is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of s_s is not 4 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of s_s is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of s_s is not 4 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/bitfield-32bit-overflow.cj b/cjbind_test/testdata/expected/bitfield-32bit-overflow.cj index 93a432b..01e5a83 100644 --- a/cjbind_test/testdata/expected/bitfield-32bit-overflow.cj +++ b/cjbind_test/testdata/expected/bitfield-32bit-overflow.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_bitfield_read(ptr: CPointer, bitOffset: Int64, bitWidth: Int64): UInt64 { let startByte = bitOffset / 8 @@ -50,560 +52,558 @@ func __cjbind_bitfield_read_signed(ptr: CPointer, bitOffset: Int64, bitWi return Int64(raw) } -package cjbind_ffi - @C public struct MuchBitfield_MuchBitfield { -var _bitfield_1 : VArray = VArray(repeat: 0) -public func m0(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 0, 1) }) -} -public mut func m0(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 1, UInt64(val)) } -} -public func m1(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 1, 1) }) -} -public mut func m1(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 1, 1, UInt64(val)) } -} -public func m2(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 2, 1) }) -} -public mut func m2(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 2, 1, UInt64(val)) } -} -public func m3(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 3, 1) }) -} -public mut func m3(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 3, 1, UInt64(val)) } -} -public func m4(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 4, 1) }) -} -public mut func m4(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 4, 1, UInt64(val)) } -} -public func m5(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 5, 1) }) -} -public mut func m5(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 5, 1, UInt64(val)) } -} -public func m6(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 6, 1) }) -} -public mut func m6(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 6, 1, UInt64(val)) } -} -public func m7(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 7, 1) }) -} -public mut func m7(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 7, 1, UInt64(val)) } -} -public func m8(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 8, 1) }) -} -public mut func m8(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 8, 1, UInt64(val)) } -} -public func m9(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 9, 1) }) -} -public mut func m9(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 9, 1, UInt64(val)) } -} -public func m10(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 10, 1) }) -} -public mut func m10(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 10, 1, UInt64(val)) } -} -public func m11(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 11, 1) }) -} -public mut func m11(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 11, 1, UInt64(val)) } -} -public func m12(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 12, 1) }) -} -public mut func m12(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 12, 1, UInt64(val)) } -} -public func m13(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 13, 1) }) -} -public mut func m13(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 13, 1, UInt64(val)) } -} -public func m14(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 14, 1) }) -} -public mut func m14(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 14, 1, UInt64(val)) } -} -public func m15(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 15, 1) }) -} -public mut func m15(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 15, 1, UInt64(val)) } -} -public func m16(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 16, 1) }) -} -public mut func m16(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 16, 1, UInt64(val)) } -} -public func m17(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 17, 1) }) -} -public mut func m17(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 17, 1, UInt64(val)) } -} -public func m18(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 18, 1) }) -} -public mut func m18(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 18, 1, UInt64(val)) } -} -public func m19(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 19, 1) }) -} -public mut func m19(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 19, 1, UInt64(val)) } -} -public func m20(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 20, 1) }) -} -public mut func m20(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 20, 1, UInt64(val)) } -} -public func m21(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 21, 1) }) -} -public mut func m21(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 21, 1, UInt64(val)) } -} -public func m22(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 22, 1) }) -} -public mut func m22(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 22, 1, UInt64(val)) } -} -public func m23(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 23, 1) }) -} -public mut func m23(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 23, 1, UInt64(val)) } -} -public func m24(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 24, 1) }) -} -public mut func m24(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 24, 1, UInt64(val)) } -} -public func m25(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 25, 1) }) -} -public mut func m25(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 25, 1, UInt64(val)) } -} -public func m26(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 26, 1) }) -} -public mut func m26(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 26, 1, UInt64(val)) } -} -public func m27(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 27, 1) }) -} -public mut func m27(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 27, 1, UInt64(val)) } -} -public func m28(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 28, 1) }) -} -public mut func m28(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 28, 1, UInt64(val)) } -} -public func m29(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 29, 1) }) -} -public mut func m29(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 29, 1, UInt64(val)) } -} -public func m30(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 30, 1) }) -} -public mut func m30(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 30, 1, UInt64(val)) } -} -public func m31(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 31, 1) }) -} -public mut func m31(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 31, 1, UInt64(val)) } -} -public func m32(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 32, 1) }) -} -public mut func m32(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 32, 1, UInt64(val)) } -} -public init() {} + var _bitfield_1: VArray = VArray(repeat: 0) + public func m0(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 0, 1) }) + } + public mut func m0(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 1, UInt64(val)) } + } + public func m1(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 1, 1) }) + } + public mut func m1(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 1, 1, UInt64(val)) } + } + public func m2(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 2, 1) }) + } + public mut func m2(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 2, 1, UInt64(val)) } + } + public func m3(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 3, 1) }) + } + public mut func m3(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 3, 1, UInt64(val)) } + } + public func m4(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 4, 1) }) + } + public mut func m4(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 4, 1, UInt64(val)) } + } + public func m5(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 5, 1) }) + } + public mut func m5(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 5, 1, UInt64(val)) } + } + public func m6(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 6, 1) }) + } + public mut func m6(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 6, 1, UInt64(val)) } + } + public func m7(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 7, 1) }) + } + public mut func m7(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 7, 1, UInt64(val)) } + } + public func m8(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 8, 1) }) + } + public mut func m8(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 8, 1, UInt64(val)) } + } + public func m9(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 9, 1) }) + } + public mut func m9(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 9, 1, UInt64(val)) } + } + public func m10(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 10, 1) }) + } + public mut func m10(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 10, 1, UInt64(val)) } + } + public func m11(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 11, 1) }) + } + public mut func m11(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 11, 1, UInt64(val)) } + } + public func m12(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 12, 1) }) + } + public mut func m12(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 12, 1, UInt64(val)) } + } + public func m13(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 13, 1) }) + } + public mut func m13(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 13, 1, UInt64(val)) } + } + public func m14(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 14, 1) }) + } + public mut func m14(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 14, 1, UInt64(val)) } + } + public func m15(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 15, 1) }) + } + public mut func m15(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 15, 1, UInt64(val)) } + } + public func m16(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 16, 1) }) + } + public mut func m16(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 16, 1, UInt64(val)) } + } + public func m17(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 17, 1) }) + } + public mut func m17(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 17, 1, UInt64(val)) } + } + public func m18(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 18, 1) }) + } + public mut func m18(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 18, 1, UInt64(val)) } + } + public func m19(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 19, 1) }) + } + public mut func m19(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 19, 1, UInt64(val)) } + } + public func m20(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 20, 1) }) + } + public mut func m20(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 20, 1, UInt64(val)) } + } + public func m21(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 21, 1) }) + } + public mut func m21(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 21, 1, UInt64(val)) } + } + public func m22(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 22, 1) }) + } + public mut func m22(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 22, 1, UInt64(val)) } + } + public func m23(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 23, 1) }) + } + public mut func m23(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 23, 1, UInt64(val)) } + } + public func m24(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 24, 1) }) + } + public mut func m24(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 24, 1, UInt64(val)) } + } + public func m25(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 25, 1) }) + } + public mut func m25(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 25, 1, UInt64(val)) } + } + public func m26(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 26, 1) }) + } + public mut func m26(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 26, 1, UInt64(val)) } + } + public func m27(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 27, 1) }) + } + public mut func m27(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 27, 1, UInt64(val)) } + } + public func m28(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 28, 1) }) + } + public mut func m28(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 28, 1, UInt64(val)) } + } + public func m29(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 29, 1) }) + } + public mut func m29(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 29, 1, UInt64(val)) } + } + public func m30(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 30, 1) }) + } + public mut func m30(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 30, 1, UInt64(val)) } + } + public func m31(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 31, 1) }) + } + public mut func m31(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 31, 1, UInt64(val)) } + } + public func m32(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 32, 1) }) + } + public mut func m32(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 32, 1, UInt64(val)) } + } + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 5) { - throw Exception("Size of MuchBitfield_MuchBitfield is not 5 but ${size} bytes") - } - let align = alignOf() - if (align != 1) { - throw Exception("Alignment of MuchBitfield_MuchBitfield is not 1 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 5) { + throw Exception("Size of MuchBitfield_MuchBitfield is not 5 but ${size} bytes") + } + let align = alignOf() + if (align != 1) { + throw Exception("Alignment of MuchBitfield_MuchBitfield is not 1 but ${align} bytes") + } } @C public struct capabilities_capabilities { -var _bitfield_1 : VArray = VArray(repeat: 0) -public func bit_1(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 0, 1) }) -} -public mut func bit_1(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 1, UInt64(val)) } -} -public func bit_2(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 1, 1) }) -} -public mut func bit_2(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 1, 1, UInt64(val)) } -} -public func bit_3(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 2, 1) }) -} -public mut func bit_3(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 2, 1, UInt64(val)) } -} -public func bit_4(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 3, 1) }) -} -public mut func bit_4(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 3, 1, UInt64(val)) } -} -public func bit_5(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 4, 1) }) -} -public mut func bit_5(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 4, 1, UInt64(val)) } -} -public func bit_6(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 5, 1) }) -} -public mut func bit_6(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 5, 1, UInt64(val)) } -} -public func bit_7(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 6, 1) }) -} -public mut func bit_7(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 6, 1, UInt64(val)) } -} -public func bit_8(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 7, 1) }) -} -public mut func bit_8(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 7, 1, UInt64(val)) } -} -public func bit_9(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 8, 1) }) -} -public mut func bit_9(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 8, 1, UInt64(val)) } -} -public func bit_10(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 9, 1) }) -} -public mut func bit_10(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 9, 1, UInt64(val)) } -} -public func bit_11(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 10, 1) }) -} -public mut func bit_11(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 10, 1, UInt64(val)) } -} -public func bit_12(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 11, 1) }) -} -public mut func bit_12(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 11, 1, UInt64(val)) } -} -public func bit_13(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 12, 1) }) -} -public mut func bit_13(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 12, 1, UInt64(val)) } -} -public func bit_14(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 13, 1) }) -} -public mut func bit_14(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 13, 1, UInt64(val)) } -} -public func bit_15(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 14, 1) }) -} -public mut func bit_15(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 14, 1, UInt64(val)) } -} -public func bit_16(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 15, 1) }) -} -public mut func bit_16(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 15, 1, UInt64(val)) } -} -public func bit_17(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 16, 1) }) -} -public mut func bit_17(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 16, 1, UInt64(val)) } -} -public func bit_18(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 17, 1) }) -} -public mut func bit_18(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 17, 1, UInt64(val)) } -} -public func bit_19(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 18, 1) }) -} -public mut func bit_19(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 18, 1, UInt64(val)) } -} -public func bit_20(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 19, 1) }) -} -public mut func bit_20(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 19, 1, UInt64(val)) } -} -public func bit_21(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 20, 1) }) -} -public mut func bit_21(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 20, 1, UInt64(val)) } -} -public func bit_22(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 21, 1) }) -} -public mut func bit_22(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 21, 1, UInt64(val)) } -} -public func bit_23(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 22, 1) }) -} -public mut func bit_23(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 22, 1, UInt64(val)) } -} -public func bit_24(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 23, 1) }) -} -public mut func bit_24(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 23, 1, UInt64(val)) } -} -public func bit_25(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 24, 1) }) -} -public mut func bit_25(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 24, 1, UInt64(val)) } -} -public func bit_26(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 25, 1) }) -} -public mut func bit_26(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 25, 1, UInt64(val)) } -} -public func bit_27(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 26, 1) }) -} -public mut func bit_27(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 26, 1, UInt64(val)) } -} -public func bit_28(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 27, 1) }) -} -public mut func bit_28(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 27, 1, UInt64(val)) } -} -public func bit_29(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 28, 1) }) -} -public mut func bit_29(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 28, 1, UInt64(val)) } -} -public func bit_30(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 29, 1) }) -} -public mut func bit_30(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 29, 1, UInt64(val)) } -} -public func bit_31(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 30, 1) }) -} -public mut func bit_31(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 30, 1, UInt64(val)) } -} -public func bit_32(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 31, 1) }) -} -public mut func bit_32(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 31, 1, UInt64(val)) } -} -public func bit_33(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 32, 1) }) -} -public mut func bit_33(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 32, 1, UInt64(val)) } -} -public func bit_34(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 33, 1) }) -} -public mut func bit_34(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 33, 1, UInt64(val)) } -} -public func bit_35(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 34, 1) }) -} -public mut func bit_35(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 34, 1, UInt64(val)) } -} -public func bit_36(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 35, 1) }) -} -public mut func bit_36(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 35, 1, UInt64(val)) } -} -public func bit_37(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 36, 1) }) -} -public mut func bit_37(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 36, 1, UInt64(val)) } -} -public func bit_38(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 37, 1) }) -} -public mut func bit_38(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 37, 1, UInt64(val)) } -} -public func bit_39(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 38, 1) }) -} -public mut func bit_39(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 38, 1, UInt64(val)) } -} -public func bit_40(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 39, 1) }) -} -public mut func bit_40(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 39, 1, UInt64(val)) } -} -public func bit_41(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 40, 1) }) -} -public mut func bit_41(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 40, 1, UInt64(val)) } -} -public init() {} + var _bitfield_1: VArray = VArray(repeat: 0) + public func bit_1(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 0, 1) }) + } + public mut func bit_1(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 1, UInt64(val)) } + } + public func bit_2(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 1, 1) }) + } + public mut func bit_2(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 1, 1, UInt64(val)) } + } + public func bit_3(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 2, 1) }) + } + public mut func bit_3(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 2, 1, UInt64(val)) } + } + public func bit_4(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 3, 1) }) + } + public mut func bit_4(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 3, 1, UInt64(val)) } + } + public func bit_5(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 4, 1) }) + } + public mut func bit_5(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 4, 1, UInt64(val)) } + } + public func bit_6(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 5, 1) }) + } + public mut func bit_6(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 5, 1, UInt64(val)) } + } + public func bit_7(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 6, 1) }) + } + public mut func bit_7(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 6, 1, UInt64(val)) } + } + public func bit_8(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 7, 1) }) + } + public mut func bit_8(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 7, 1, UInt64(val)) } + } + public func bit_9(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 8, 1) }) + } + public mut func bit_9(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 8, 1, UInt64(val)) } + } + public func bit_10(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 9, 1) }) + } + public mut func bit_10(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 9, 1, UInt64(val)) } + } + public func bit_11(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 10, 1) }) + } + public mut func bit_11(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 10, 1, UInt64(val)) } + } + public func bit_12(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 11, 1) }) + } + public mut func bit_12(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 11, 1, UInt64(val)) } + } + public func bit_13(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 12, 1) }) + } + public mut func bit_13(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 12, 1, UInt64(val)) } + } + public func bit_14(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 13, 1) }) + } + public mut func bit_14(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 13, 1, UInt64(val)) } + } + public func bit_15(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 14, 1) }) + } + public mut func bit_15(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 14, 1, UInt64(val)) } + } + public func bit_16(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 15, 1) }) + } + public mut func bit_16(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 15, 1, UInt64(val)) } + } + public func bit_17(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 16, 1) }) + } + public mut func bit_17(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 16, 1, UInt64(val)) } + } + public func bit_18(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 17, 1) }) + } + public mut func bit_18(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 17, 1, UInt64(val)) } + } + public func bit_19(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 18, 1) }) + } + public mut func bit_19(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 18, 1, UInt64(val)) } + } + public func bit_20(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 19, 1) }) + } + public mut func bit_20(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 19, 1, UInt64(val)) } + } + public func bit_21(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 20, 1) }) + } + public mut func bit_21(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 20, 1, UInt64(val)) } + } + public func bit_22(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 21, 1) }) + } + public mut func bit_22(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 21, 1, UInt64(val)) } + } + public func bit_23(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 22, 1) }) + } + public mut func bit_23(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 22, 1, UInt64(val)) } + } + public func bit_24(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 23, 1) }) + } + public mut func bit_24(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 23, 1, UInt64(val)) } + } + public func bit_25(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 24, 1) }) + } + public mut func bit_25(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 24, 1, UInt64(val)) } + } + public func bit_26(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 25, 1) }) + } + public mut func bit_26(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 25, 1, UInt64(val)) } + } + public func bit_27(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 26, 1) }) + } + public mut func bit_27(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 26, 1, UInt64(val)) } + } + public func bit_28(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 27, 1) }) + } + public mut func bit_28(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 27, 1, UInt64(val)) } + } + public func bit_29(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 28, 1) }) + } + public mut func bit_29(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 28, 1, UInt64(val)) } + } + public func bit_30(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 29, 1) }) + } + public mut func bit_30(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 29, 1, UInt64(val)) } + } + public func bit_31(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 30, 1) }) + } + public mut func bit_31(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 30, 1, UInt64(val)) } + } + public func bit_32(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 31, 1) }) + } + public mut func bit_32(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 31, 1, UInt64(val)) } + } + public func bit_33(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 32, 1) }) + } + public mut func bit_33(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 32, 1, UInt64(val)) } + } + public func bit_34(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 33, 1) }) + } + public mut func bit_34(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 33, 1, UInt64(val)) } + } + public func bit_35(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 34, 1) }) + } + public mut func bit_35(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 34, 1, UInt64(val)) } + } + public func bit_36(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 35, 1) }) + } + public mut func bit_36(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 35, 1, UInt64(val)) } + } + public func bit_37(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 36, 1) }) + } + public mut func bit_37(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 36, 1, UInt64(val)) } + } + public func bit_38(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 37, 1) }) + } + public mut func bit_38(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 37, 1, UInt64(val)) } + } + public func bit_39(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 38, 1) }) + } + public mut func bit_39(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 38, 1, UInt64(val)) } + } + public func bit_40(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 39, 1) }) + } + public mut func bit_40(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 39, 1, UInt64(val)) } + } + public func bit_41(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 40, 1) }) + } + public mut func bit_41(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 40, 1, UInt64(val)) } + } + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 16) { - throw Exception("Size of capabilities_capabilities is not 16 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of capabilities_capabilities is not 4 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 16) { + throw Exception("Size of capabilities_capabilities is not 16 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of capabilities_capabilities is not 4 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/bitfield_align.cj b/cjbind_test/testdata/expected/bitfield_align.cj index 2ca1d5c..460f890 100644 --- a/cjbind_test/testdata/expected/bitfield_align.cj +++ b/cjbind_test/testdata/expected/bitfield_align.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_bitfield_read(ptr: CPointer, bitOffset: Int64, bitWidth: Int64): UInt64 { let startByte = bitOffset / 8 @@ -50,279 +52,277 @@ func __cjbind_bitfield_read_signed(ptr: CPointer, bitOffset: Int64, bitWi return Int64(raw) } -package cjbind_ffi - @C public struct A_A { -public var x : UInt8 = unsafe { zeroValue() } -var _bitfield_1 : VArray = VArray(repeat: 0) -public func b1(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 0, 1) }) -} -public mut func b1(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 1, UInt64(val)) } -} -public func b2(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 1, 1) }) -} -public mut func b2(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 1, 1, UInt64(val)) } -} -public func b3(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 2, 1) }) -} -public mut func b3(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 2, 1, UInt64(val)) } -} -public func b4(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 3, 1) }) -} -public mut func b4(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 3, 1, UInt64(val)) } -} -public func b5(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 4, 1) }) -} -public mut func b5(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 4, 1, UInt64(val)) } -} -public func b6(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 5, 1) }) -} -public mut func b6(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 5, 1, UInt64(val)) } -} -public func b7(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 6, 1) }) -} -public mut func b7(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 6, 1, UInt64(val)) } -} -public func b8(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 7, 1) }) -} -public mut func b8(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 7, 1, UInt64(val)) } -} -public func b9(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 8, 1) }) -} -public mut func b9(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 8, 1, UInt64(val)) } -} -public func b10(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 9, 1) }) -} -public mut func b10(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 9, 1, UInt64(val)) } -} -public var y : UInt8 = unsafe { zeroValue() } -public init() {} + public var x: UInt8 = unsafe { zeroValue() } + var _bitfield_1: VArray = VArray(repeat: 0) + public func b1(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 0, 1) }) + } + public mut func b1(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 1, UInt64(val)) } + } + public func b2(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 1, 1) }) + } + public mut func b2(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 1, 1, UInt64(val)) } + } + public func b3(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 2, 1) }) + } + public mut func b3(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 2, 1, UInt64(val)) } + } + public func b4(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 3, 1) }) + } + public mut func b4(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 3, 1, UInt64(val)) } + } + public func b5(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 4, 1) }) + } + public mut func b5(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 4, 1, UInt64(val)) } + } + public func b6(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 5, 1) }) + } + public mut func b6(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 5, 1, UInt64(val)) } + } + public func b7(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 6, 1) }) + } + public mut func b7(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 6, 1, UInt64(val)) } + } + public func b8(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 7, 1) }) + } + public mut func b8(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 7, 1, UInt64(val)) } + } + public func b9(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 8, 1) }) + } + public mut func b9(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 8, 1, UInt64(val)) } + } + public func b10(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 9, 1) }) + } + public mut func b10(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 9, 1, UInt64(val)) } + } + public var y: UInt8 = unsafe { zeroValue() } + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of A_A is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of A_A is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of A_A is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of A_A is not 4 but ${align} bytes") + } } @C public struct B_B { -var _bitfield_1 : VArray = VArray(repeat: 0) -public func foo(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 0, 31) }) -} -public mut func foo(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 31, UInt64(val)) } -} -public func bar(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read(inout s, 31, 1) }) -} -public mut func bar(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 31, 1, UInt64(val)) } -} -public init() {} + var _bitfield_1: VArray = VArray(repeat: 0) + public func foo(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 0, 31) }) + } + public mut func foo(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 31, UInt64(val)) } + } + public func bar(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read(inout s, 31, 1) }) + } + public mut func bar(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 31, 1, UInt64(val)) } + } + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of B_B is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of B_B is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of B_B is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of B_B is not 4 but ${align} bytes") + } } @C public struct C_C { -public var x : UInt8 = unsafe { zeroValue() } -var _bitfield_1 : VArray = VArray(repeat: 0) -public func b1(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 0, 1) }) -} -public mut func b1(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 1, UInt64(val)) } -} -public func b2(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 1, 1) }) -} -public mut func b2(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 1, 1, UInt64(val)) } -} -public var baz : UInt32 = unsafe { zeroValue() } -public init() {} + public var x: UInt8 = unsafe { zeroValue() } + var _bitfield_1: VArray = VArray(repeat: 0) + public func b1(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 0, 1) }) + } + public mut func b1(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 1, UInt64(val)) } + } + public func b2(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 1, 1) }) + } + public mut func b2(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 1, 1, UInt64(val)) } + } + public var baz: UInt32 = unsafe { zeroValue() } + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 8) { - throw Exception("Size of C_C is not 8 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of C_C is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 8) { + throw Exception("Size of C_C is not 8 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of C_C is not 4 but ${align} bytes") + } } @C public struct Date1_Date1 { -var _bitfield_1 : VArray = VArray(repeat: 0) -public func nWeekDay(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 0, 3) }) -} -public mut func nWeekDay(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 3, UInt64(val)) } -} -public func nMonthDay(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 3, 6) }) -} -public mut func nMonthDay(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 3, 6, UInt64(val)) } -} -public func nMonth(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 9, 5) }) -} -public mut func nMonth(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 9, 5, UInt64(val)) } -} -public func nYear(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 16, 8) }) -} -public mut func nYear(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 16, 8, UInt64(val)) } -} -public init() {} + var _bitfield_1: VArray = VArray(repeat: 0) + public func nWeekDay(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 0, 3) }) + } + public mut func nWeekDay(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 3, UInt64(val)) } + } + public func nMonthDay(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 3, 6) }) + } + public mut func nMonthDay(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 3, 6, UInt64(val)) } + } + public func nMonth(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 9, 5) }) + } + public mut func nMonth(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 9, 5, UInt64(val)) } + } + public func nYear(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 16, 8) }) + } + public mut func nYear(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 16, 8, UInt64(val)) } + } + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of Date1_Date1 is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 2) { - throw Exception("Alignment of Date1_Date1 is not 2 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of Date1_Date1 is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 2) { + throw Exception("Alignment of Date1_Date1 is not 2 but ${align} bytes") + } } @C public struct Date2_Date2 { -let _cjbind_opaque_blob: VArray -public init() { - this._cjbind_opaque_blob = unsafe { zeroValue>() } -} + let _cjbind_opaque_blob: VArray + public init() { + this._cjbind_opaque_blob = unsafe { zeroValue>() } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of Date2_Date2 is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 2) { - throw Exception("Alignment of Date2_Date2 is not 2 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of Date2_Date2 is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 2) { + throw Exception("Alignment of Date2_Date2 is not 2 but ${align} bytes") + } } @C public struct Date3_Date3 { -var _bitfield_1 : VArray = VArray(repeat: 0) -public func nWeekDay(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 0, 3) }) -} -public mut func nWeekDay(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 3, UInt64(val)) } -} -public func nMonthDay(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 3, 6) }) -} -public mut func nMonthDay(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 3, 6, UInt64(val)) } -} -public func nMonth(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 9, 5) }) -} -public mut func nMonth(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 9, 5, UInt64(val)) } -} -public func nYear(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 16, 8) }) -} -public mut func nYear(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 16, 8, UInt64(val)) } -} -public var byte : UInt8 = unsafe { zeroValue() } -public init() {} + var _bitfield_1: VArray = VArray(repeat: 0) + public func nWeekDay(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 0, 3) }) + } + public mut func nWeekDay(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 3, UInt64(val)) } + } + public func nMonthDay(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 3, 6) }) + } + public mut func nMonthDay(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 3, 6, UInt64(val)) } + } + public func nMonth(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 9, 5) }) + } + public mut func nMonth(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 9, 5, UInt64(val)) } + } + public func nYear(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 16, 8) }) + } + public mut func nYear(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 16, 8, UInt64(val)) } + } + public var byte: UInt8 = unsafe { zeroValue() } + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of Date3_Date3 is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 2) { - throw Exception("Alignment of Date3_Date3 is not 2 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of Date3_Date3 is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 2) { + throw Exception("Alignment of Date3_Date3 is not 2 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/bitfield_align_2.cj b/cjbind_test/testdata/expected/bitfield_align_2.cj index 86ece23..5d58382 100644 --- a/cjbind_test/testdata/expected/bitfield_align_2.cj +++ b/cjbind_test/testdata/expected/bitfield_align_2.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_bitfield_read(ptr: CPointer, bitOffset: Int64, bitWidth: Int64): UInt64 { let startByte = bitOffset / 8 @@ -50,47 +52,42 @@ func __cjbind_bitfield_read_signed(ptr: CPointer, bitOffset: Int64, bitWi return Int64(raw) } -package cjbind_ffi - -public const MyEnum_ONE : MyEnum_MyEnum = 0 - -public const MyEnum_TWO : MyEnum_MyEnum = 1 - -public const MyEnum_THREE : MyEnum_MyEnum = 2 - -public const MyEnum_FOUR : MyEnum_MyEnum = 3 +public const MyEnum_ONE: MyEnum_MyEnum = 0 +public const MyEnum_TWO: MyEnum_MyEnum = 1 +public const MyEnum_THREE: MyEnum_MyEnum = 2 +public const MyEnum_FOUR: MyEnum_MyEnum = 3 public type MyEnum_MyEnum = UInt32 @C public struct TaggedPtr_TaggedPtr { -var _bitfield_1 : VArray = VArray(repeat: 0) -public func tag(): MyEnum_MyEnum { - var s = this._bitfield_1 - return MyEnum_MyEnum(unsafe { __cjbind_bitfield_read(inout s, 0, 2) }) -} -public mut func tag(val!: MyEnum_MyEnum): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 2, UInt64(val)) } -} -public func ptr(): Int64 { - var s = this._bitfield_1 - return Int64(unsafe { __cjbind_bitfield_read_signed(inout s, 2, 62) }) -} -public mut func ptr(val!: Int64): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 2, 62, UInt64(val)) } -} -public init() {} + var _bitfield_1: VArray = VArray(repeat: 0) + public func tag(): MyEnum_MyEnum { + var s = this._bitfield_1 + return MyEnum_MyEnum(unsafe { __cjbind_bitfield_read(inout s, 0, 2) }) + } + public mut func tag(val!: MyEnum_MyEnum): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 2, UInt64(val)) } + } + public func ptr(): Int64 { + var s = this._bitfield_1 + return Int64(unsafe { __cjbind_bitfield_read_signed(inout s, 2, 62) }) + } + public mut func ptr(val!: Int64): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 2, 62, UInt64(val)) } + } + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 8) { - throw Exception("Size of TaggedPtr_TaggedPtr is not 8 but ${size} bytes") - } - let align = alignOf() - if (align != 8) { - throw Exception("Alignment of TaggedPtr_TaggedPtr is not 8 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 8) { + throw Exception("Size of TaggedPtr_TaggedPtr is not 8 but ${size} bytes") + } + let align = alignOf() + if (align != 8) { + throw Exception("Alignment of TaggedPtr_TaggedPtr is not 8 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/bitfield_method_mangling.cj b/cjbind_test/testdata/expected/bitfield_method_mangling.cj index 3c0e517..c904c09 100644 --- a/cjbind_test/testdata/expected/bitfield_method_mangling.cj +++ b/cjbind_test/testdata/expected/bitfield_method_mangling.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_bitfield_read(ptr: CPointer, bitOffset: Int64, bitWidth: Int64): UInt64 { let startByte = bitOffset / 8 @@ -50,37 +52,36 @@ func __cjbind_bitfield_read_signed(ptr: CPointer, bitOffset: Int64, bitWi return Int64(raw) } -package cjbind_ffi - @C public struct mach_msg_type_descriptor_t_mach_msg_type_descriptor_t { -var _bitfield_1 : VArray = VArray(repeat: 0) -public func pad3(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 0, 24) }) -} -public mut func pad3(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 24, UInt64(val)) } -} -public func type_(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 24, 8) }) -} -public mut func type_(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 24, 8, UInt64(val)) } -} -public init() {} + var _bitfield_1: VArray = VArray(repeat: 0) + public func pad3(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 0, 24) }) + } + public mut func pad3(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 24, UInt64(val)) } + } + public func type_(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 24, 8) }) + } + public mut func type_(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 24, 8, UInt64(val)) } + } + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of mach_msg_type_descriptor_t_mach_msg_type_descriptor_t is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of mach_msg_type_descriptor_t_mach_msg_type_descriptor_t is not 4 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of mach_msg_type_descriptor_t_mach_msg_type_descriptor_t is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception( + "Alignment of mach_msg_type_descriptor_t_mach_msg_type_descriptor_t is not 4 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/bitfield_pack_offset.cj b/cjbind_test/testdata/expected/bitfield_pack_offset.cj index 1a5c927..b49246c 100644 --- a/cjbind_test/testdata/expected/bitfield_pack_offset.cj +++ b/cjbind_test/testdata/expected/bitfield_pack_offset.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_bitfield_read(ptr: CPointer, bitOffset: Int64, bitWidth: Int64): UInt64 { let startByte = bitOffset / 8 @@ -50,76 +52,74 @@ func __cjbind_bitfield_read_signed(ptr: CPointer, bitOffset: Int64, bitWi return Int64(raw) } -package cjbind_ffi - @C public struct A_A { -public var name : VArray = unsafe { zeroValue>() } -var _bitfield_1 : VArray = VArray(repeat: 0) -public func firmness(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read(inout s, 0, 4) }) -} -public mut func firmness(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 4, UInt64(val)) } -} -public func color(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read(inout s, 4, 4) }) -} -public mut func color(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 4, 4, UInt64(val)) } -} -public func weedsBonus(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 8, 3) }) -} -public mut func weedsBonus(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 8, 3, UInt64(val)) } -} -public func pestsBonus(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 11, 3) }) -} -public mut func pestsBonus(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 11, 3, UInt64(val)) } -} -public func size(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 16, 10) }) -} -public mut func size(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 16, 10, UInt64(val)) } -} -public var maxYield : UInt8 = unsafe { zeroValue() } -var _bitfield_2 : VArray = VArray(repeat: 0) -public func minYield(): UInt8 { - var s = this._bitfield_2 - return UInt8(unsafe { __cjbind_bitfield_read(inout s, 0, 4) }) -} -public mut func minYield(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_2, 0, 4, UInt64(val)) } -} -public func waterBonus(): UInt8 { - var s = this._bitfield_2 - return UInt8(unsafe { __cjbind_bitfield_read(inout s, 4, 4) }) -} -public mut func waterBonus(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_2, 4, 4, UInt64(val)) } -} -public var description1 : CPointer = unsafe { zeroValue>() } -public init() {} + public var name: VArray = unsafe { zeroValue>() } + var _bitfield_1: VArray = VArray(repeat: 0) + public func firmness(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read(inout s, 0, 4) }) + } + public mut func firmness(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 4, UInt64(val)) } + } + public func color(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read(inout s, 4, 4) }) + } + public mut func color(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 4, 4, UInt64(val)) } + } + public func weedsBonus(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 8, 3) }) + } + public mut func weedsBonus(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 8, 3, UInt64(val)) } + } + public func pestsBonus(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 11, 3) }) + } + public mut func pestsBonus(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 11, 3, UInt64(val)) } + } + public func size(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 16, 10) }) + } + public mut func size(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 16, 10, UInt64(val)) } + } + public var maxYield: UInt8 = unsafe { zeroValue() } + var _bitfield_2: VArray = VArray(repeat: 0) + public func minYield(): UInt8 { + var s = this._bitfield_2 + return UInt8(unsafe { __cjbind_bitfield_read(inout s, 0, 4) }) + } + public mut func minYield(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_2, 0, 4, UInt64(val)) } + } + public func waterBonus(): UInt8 { + var s = this._bitfield_2 + return UInt8(unsafe { __cjbind_bitfield_read(inout s, 4, 4) }) + } + public mut func waterBonus(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_2, 4, 4, UInt64(val)) } + } + public var description1: CPointer = unsafe { zeroValue>() } + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 24) { - throw Exception("Size of A_A is not 24 but ${size} bytes") - } - let align = alignOf() - if (align != 8) { - throw Exception("Alignment of A_A is not 8 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 24) { + throw Exception("Size of A_A is not 24 but ${size} bytes") + } + let align = alignOf() + if (align != 8) { + throw Exception("Alignment of A_A is not 8 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/divide-by-zero-in-struct-layout.cj b/cjbind_test/testdata/expected/divide-by-zero-in-struct-layout.cj index ffbdaaa..585189d 100644 --- a/cjbind_test/testdata/expected/divide-by-zero-in-struct-layout.cj +++ b/cjbind_test/testdata/expected/divide-by-zero-in-struct-layout.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_bitfield_read(ptr: CPointer, bitOffset: Int64, bitWidth: Int64): UInt64 { let startByte = bitOffset / 8 @@ -50,24 +52,22 @@ func __cjbind_bitfield_read_signed(ptr: CPointer, bitOffset: Int64, bitWi return Int64(raw) } -package cjbind_ffi - @C public struct WithBitfield_WithBitfield { -var _bitfield_1 : VArray = VArray(repeat: 0) -public var a : UInt32 = unsafe { zeroValue() } -public init() {} + var _bitfield_1: VArray = VArray(repeat: 0) + public var a: UInt32 = unsafe { zeroValue() } + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 8) { - throw Exception("Size of WithBitfield_WithBitfield is not 8 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of WithBitfield_WithBitfield is not 4 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 8) { + throw Exception("Size of WithBitfield_WithBitfield is not 8 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of WithBitfield_WithBitfield is not 4 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/incomplete-array-padding.cj b/cjbind_test/testdata/expected/incomplete-array-padding.cj index 6ba1fca..9c6aeef 100644 --- a/cjbind_test/testdata/expected/incomplete-array-padding.cj +++ b/cjbind_test/testdata/expected/incomplete-array-padding.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_bitfield_read(ptr: CPointer, bitOffset: Int64, bitWidth: Int64): UInt64 { let startByte = bitOffset / 8 @@ -50,31 +52,29 @@ func __cjbind_bitfield_read_signed(ptr: CPointer, bitOffset: Int64, bitWi return Int64(raw) } -package cjbind_ffi - @C public struct foo_foo { -var _bitfield_1 : VArray = VArray(repeat: 0) -public func a(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 0, 1) }) -} -public mut func a(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 1, UInt64(val)) } -} -public var b : CPointer> = unsafe { zeroValue>>() } -public init() {} + var _bitfield_1: VArray = VArray(repeat: 0) + public func a(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read_signed(inout s, 0, 1) }) + } + public mut func a(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 1, UInt64(val)) } + } + public var b: CPointer> = unsafe { zeroValue>>() } + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 8) { - throw Exception("Size of foo_foo is not 8 but ${size} bytes") - } - let align = alignOf() - if (align != 8) { - throw Exception("Alignment of foo_foo is not 8 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 8) { + throw Exception("Size of foo_foo is not 8 but ${size} bytes") + } + let align = alignOf() + if (align != 8) { + throw Exception("Alignment of foo_foo is not 8 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/layout_align.cj b/cjbind_test/testdata/expected/layout_align.cj index 81b0cff..b023b59 100644 --- a/cjbind_test/testdata/expected/layout_align.cj +++ b/cjbind_test/testdata/expected/layout_align.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_bitfield_read(ptr: CPointer, bitOffset: Int64, bitWidth: Int64): UInt64 { let startByte = bitOffset / 8 @@ -50,80 +52,78 @@ func __cjbind_bitfield_read_signed(ptr: CPointer, bitOffset: Int64, bitWi return Int64(raw) } -package cjbind_ffi - @C public struct rte_kni_fifo_rte_kni_fifo { -//< Next position to be written* -public let write : UInt32 -//< Next position to be read * -public let read : UInt32 -//< Circular buffer length * -public let len : UInt32 -//< Pointer size - for 32/64 bit OS * -public let elem_size : UInt32 -//< The buffer contains mbuf pointers * -public let buffer : CPointer> -public init(write : UInt32 , read : UInt32 , len : UInt32 , elem_size : UInt32 , buffer : CPointer>) { - this.write = write -this.read = read -this.len = len -this.elem_size = elem_size -this.buffer = buffer -} + //< Next position to be written* + public let write: UInt32 + //< Next position to be read * + public let read: UInt32 + //< Circular buffer length * + public let len: UInt32 + //< Pointer size - for 32/64 bit OS * + public let elem_size: UInt32 + //< The buffer contains mbuf pointers * + public let buffer: CPointer> + public init(write: UInt32, read: UInt32, len: UInt32, elem_size: UInt32, buffer: CPointer>) { + this.write = write + this.read = read + this.len = len + this.elem_size = elem_size + this.buffer = buffer + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 16) { - throw Exception("Size of rte_kni_fifo_rte_kni_fifo is not 16 but ${size} bytes") - } - let align = alignOf() - if (align != 8) { - throw Exception("Alignment of rte_kni_fifo_rte_kni_fifo is not 8 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 16) { + throw Exception("Size of rte_kni_fifo_rte_kni_fifo is not 16 but ${size} bytes") + } + let align = alignOf() + if (align != 8) { + throw Exception("Alignment of rte_kni_fifo_rte_kni_fifo is not 8 but ${align} bytes") + } } @C public struct rte_eth_link_rte_eth_link { -//< ETH_SPEED_NUM_ * -public var link_speed : UInt32 = unsafe { zeroValue() } -var _bitfield_1 : VArray = VArray(repeat: 0) -public func link_duplex(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 0, 1) }) -} -public mut func link_duplex(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 1, UInt64(val)) } -} -public func link_autoneg(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 1, 1) }) -} -public mut func link_autoneg(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 1, 1, UInt64(val)) } -} -public func link_status(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 2, 1) }) -} -public mut func link_status(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 2, 1, UInt64(val)) } -} -public init() {} + //< ETH_SPEED_NUM_ * + public var link_speed: UInt32 = unsafe { zeroValue() } + var _bitfield_1: VArray = VArray(repeat: 0) + public func link_duplex(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 0, 1) }) + } + public mut func link_duplex(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 1, UInt64(val)) } + } + public func link_autoneg(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 1, 1) }) + } + public mut func link_autoneg(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 1, 1, UInt64(val)) } + } + public func link_status(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 2, 1) }) + } + public mut func link_status(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 2, 1, UInt64(val)) } + } + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 8) { - throw Exception("Size of rte_eth_link_rte_eth_link is not 8 but ${size} bytes") - } - let align = alignOf() - if (align != 8) { - throw Exception("Alignment of rte_eth_link_rte_eth_link is not 8 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 8) { + throw Exception("Size of rte_eth_link_rte_eth_link is not 8 but ${size} bytes") + } + let align = alignOf() + if (align != 8) { + throw Exception("Alignment of rte_eth_link_rte_eth_link is not 8 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/layout_eth_conf.cj b/cjbind_test/testdata/expected/layout_eth_conf.cj index 8f9b244..28ea2e1 100644 --- a/cjbind_test/testdata/expected/layout_eth_conf.cj +++ b/cjbind_test/testdata/expected/layout_eth_conf.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_bitfield_read(ptr: CPointer, bitOffset: Int64, bitWidth: Int64): UInt64 { let startByte = bitOffset / 8 @@ -56,7 +58,8 @@ func __cjbind_read_rte_eth_vmdq_dcb_tx_conf_rte_eth_vmdq_dcb_tx_conf(ptr: CPoint } @C -func __cjbind_write_rte_eth_vmdq_dcb_tx_conf_rte_eth_vmdq_dcb_tx_conf(ptr: CPointer, val: rte_eth_vmdq_dcb_tx_conf_rte_eth_vmdq_dcb_tx_conf): Unit { +func __cjbind_write_rte_eth_vmdq_dcb_tx_conf_rte_eth_vmdq_dcb_tx_conf(ptr: CPointer, + val: rte_eth_vmdq_dcb_tx_conf_rte_eth_vmdq_dcb_tx_conf): Unit { unsafe { CPointer(ptr).write(val) } } @@ -66,7 +69,8 @@ func __cjbind_read_rte_eth_dcb_tx_conf_rte_eth_dcb_tx_conf(ptr: CPointer) } @C -func __cjbind_write_rte_eth_dcb_tx_conf_rte_eth_dcb_tx_conf(ptr: CPointer, val: rte_eth_dcb_tx_conf_rte_eth_dcb_tx_conf): Unit { +func __cjbind_write_rte_eth_dcb_tx_conf_rte_eth_dcb_tx_conf(ptr: CPointer, + val: rte_eth_dcb_tx_conf_rte_eth_dcb_tx_conf): Unit { unsafe { CPointer(ptr).write(val) } } @@ -76,99 +80,67 @@ func __cjbind_read_rte_eth_vmdq_tx_conf_rte_eth_vmdq_tx_conf(ptr: CPointer, val: rte_eth_vmdq_tx_conf_rte_eth_vmdq_tx_conf): Unit { +func __cjbind_write_rte_eth_vmdq_tx_conf_rte_eth_vmdq_tx_conf(ptr: CPointer, + val: rte_eth_vmdq_tx_conf_rte_eth_vmdq_tx_conf): Unit { unsafe { CPointer(ptr).write(val) } } -package cjbind_ffi - -public const ETH_MQ_RX_RSS_FLAG_ETH_MQ_RX_RSS_FLAG : Int64 = 1 - -public const ETH_MQ_RX_DCB_FLAG_ETH_MQ_RX_DCB_FLAG : Int64 = 2 - -public const ETH_MQ_RX_VMDQ_FLAG_ETH_MQ_RX_VMDQ_FLAG : Int64 = 4 - -public const ETH_VMDQ_MAX_VLAN_FILTERS_ETH_VMDQ_MAX_VLAN_FILTERS : Int64 = 64 - -public const ETH_DCB_NUM_USER_PRIORITIES_ETH_DCB_NUM_USER_PRIORITIES : Int64 = 8 - -public const ETH_VMDQ_DCB_NUM_QUEUES_ETH_VMDQ_DCB_NUM_QUEUES : Int64 = 128 - -public const ETH_DCB_NUM_QUEUES_ETH_DCB_NUM_QUEUES : Int64 = 128 - -public const RTE_ETH_FDIR_MAX_FLEXLEN_RTE_ETH_FDIR_MAX_FLEXLEN : Int64 = 16 - -public const RTE_ETH_INSET_SIZE_MAX_RTE_ETH_INSET_SIZE_MAX : Int64 = 128 - -public const RTE_ETH_FLOW_UNKNOWN_RTE_ETH_FLOW_UNKNOWN : Int64 = 0 - -public const RTE_ETH_FLOW_RAW_RTE_ETH_FLOW_RAW : Int64 = 1 - -public const RTE_ETH_FLOW_IPV4_RTE_ETH_FLOW_IPV4 : Int64 = 2 - -public const RTE_ETH_FLOW_FRAG_IPV4_RTE_ETH_FLOW_FRAG_IPV4 : Int64 = 3 - -public const RTE_ETH_FLOW_NONFRAG_IPV4_TCP_RTE_ETH_FLOW_NONFRAG_IPV4_TCP : Int64 = 4 - -public const RTE_ETH_FLOW_NONFRAG_IPV4_UDP_RTE_ETH_FLOW_NONFRAG_IPV4_UDP : Int64 = 5 - -public const RTE_ETH_FLOW_NONFRAG_IPV4_SCTP_RTE_ETH_FLOW_NONFRAG_IPV4_SCTP : Int64 = 6 - -public const RTE_ETH_FLOW_NONFRAG_IPV4_OTHER_RTE_ETH_FLOW_NONFRAG_IPV4_OTHER : Int64 = 7 - -public const RTE_ETH_FLOW_IPV6_RTE_ETH_FLOW_IPV6 : Int64 = 8 - -public const RTE_ETH_FLOW_FRAG_IPV6_RTE_ETH_FLOW_FRAG_IPV6 : Int64 = 9 - -public const RTE_ETH_FLOW_NONFRAG_IPV6_TCP_RTE_ETH_FLOW_NONFRAG_IPV6_TCP : Int64 = 10 - -public const RTE_ETH_FLOW_NONFRAG_IPV6_UDP_RTE_ETH_FLOW_NONFRAG_IPV6_UDP : Int64 = 11 - -public const RTE_ETH_FLOW_NONFRAG_IPV6_SCTP_RTE_ETH_FLOW_NONFRAG_IPV6_SCTP : Int64 = 12 - -public const RTE_ETH_FLOW_NONFRAG_IPV6_OTHER_RTE_ETH_FLOW_NONFRAG_IPV6_OTHER : Int64 = 13 - -public const RTE_ETH_FLOW_L2_PAYLOAD_RTE_ETH_FLOW_L2_PAYLOAD : Int64 = 14 - -public const RTE_ETH_FLOW_IPV6_EX_RTE_ETH_FLOW_IPV6_EX : Int64 = 15 - -public const RTE_ETH_FLOW_IPV6_TCP_EX_RTE_ETH_FLOW_IPV6_TCP_EX : Int64 = 16 - -public const RTE_ETH_FLOW_IPV6_UDP_EX_RTE_ETH_FLOW_IPV6_UDP_EX : Int64 = 17 - -public const RTE_ETH_FLOW_PORT_RTE_ETH_FLOW_PORT : Int64 = 18 - -public const RTE_ETH_FLOW_VXLAN_RTE_ETH_FLOW_VXLAN : Int64 = 19 - -public const RTE_ETH_FLOW_GENEVE_RTE_ETH_FLOW_GENEVE : Int64 = 20 - -public const RTE_ETH_FLOW_NVGRE_RTE_ETH_FLOW_NVGRE : Int64 = 21 - -public const RTE_ETH_FLOW_MAX_RTE_ETH_FLOW_MAX : Int64 = 22 +public const ETH_MQ_RX_RSS_FLAG_ETH_MQ_RX_RSS_FLAG: Int64 = 1 +public const ETH_MQ_RX_DCB_FLAG_ETH_MQ_RX_DCB_FLAG: Int64 = 2 +public const ETH_MQ_RX_VMDQ_FLAG_ETH_MQ_RX_VMDQ_FLAG: Int64 = 4 +public const ETH_VMDQ_MAX_VLAN_FILTERS_ETH_VMDQ_MAX_VLAN_FILTERS: Int64 = 64 +public const ETH_DCB_NUM_USER_PRIORITIES_ETH_DCB_NUM_USER_PRIORITIES: Int64 = 8 +public const ETH_VMDQ_DCB_NUM_QUEUES_ETH_VMDQ_DCB_NUM_QUEUES: Int64 = 128 +public const ETH_DCB_NUM_QUEUES_ETH_DCB_NUM_QUEUES: Int64 = 128 +public const RTE_ETH_FDIR_MAX_FLEXLEN_RTE_ETH_FDIR_MAX_FLEXLEN: Int64 = 16 +public const RTE_ETH_INSET_SIZE_MAX_RTE_ETH_INSET_SIZE_MAX: Int64 = 128 +public const RTE_ETH_FLOW_UNKNOWN_RTE_ETH_FLOW_UNKNOWN: Int64 = 0 +public const RTE_ETH_FLOW_RAW_RTE_ETH_FLOW_RAW: Int64 = 1 +public const RTE_ETH_FLOW_IPV4_RTE_ETH_FLOW_IPV4: Int64 = 2 +public const RTE_ETH_FLOW_FRAG_IPV4_RTE_ETH_FLOW_FRAG_IPV4: Int64 = 3 +public const RTE_ETH_FLOW_NONFRAG_IPV4_TCP_RTE_ETH_FLOW_NONFRAG_IPV4_TCP: Int64 = 4 +public const RTE_ETH_FLOW_NONFRAG_IPV4_UDP_RTE_ETH_FLOW_NONFRAG_IPV4_UDP: Int64 = 5 +public const RTE_ETH_FLOW_NONFRAG_IPV4_SCTP_RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: Int64 = 6 +public const RTE_ETH_FLOW_NONFRAG_IPV4_OTHER_RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: Int64 = 7 +public const RTE_ETH_FLOW_IPV6_RTE_ETH_FLOW_IPV6: Int64 = 8 +public const RTE_ETH_FLOW_FRAG_IPV6_RTE_ETH_FLOW_FRAG_IPV6: Int64 = 9 +public const RTE_ETH_FLOW_NONFRAG_IPV6_TCP_RTE_ETH_FLOW_NONFRAG_IPV6_TCP: Int64 = 10 +public const RTE_ETH_FLOW_NONFRAG_IPV6_UDP_RTE_ETH_FLOW_NONFRAG_IPV6_UDP: Int64 = 11 +public const RTE_ETH_FLOW_NONFRAG_IPV6_SCTP_RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: Int64 = 12 +public const RTE_ETH_FLOW_NONFRAG_IPV6_OTHER_RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: Int64 = 13 +public const RTE_ETH_FLOW_L2_PAYLOAD_RTE_ETH_FLOW_L2_PAYLOAD: Int64 = 14 +public const RTE_ETH_FLOW_IPV6_EX_RTE_ETH_FLOW_IPV6_EX: Int64 = 15 +public const RTE_ETH_FLOW_IPV6_TCP_EX_RTE_ETH_FLOW_IPV6_TCP_EX: Int64 = 16 +public const RTE_ETH_FLOW_IPV6_UDP_EX_RTE_ETH_FLOW_IPV6_UDP_EX: Int64 = 17 +public const RTE_ETH_FLOW_PORT_RTE_ETH_FLOW_PORT: Int64 = 18 +public const RTE_ETH_FLOW_VXLAN_RTE_ETH_FLOW_VXLAN: Int64 = 19 +public const RTE_ETH_FLOW_GENEVE_RTE_ETH_FLOW_GENEVE: Int64 = 20 +public const RTE_ETH_FLOW_NVGRE_RTE_ETH_FLOW_NVGRE: Int64 = 21 +public const RTE_ETH_FLOW_MAX_RTE_ETH_FLOW_MAX: Int64 = 22 // None of DCB,RSS or VMDQ mode * -public const rte_eth_rx_mq_mode_ETH_MQ_RX_NONE : rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = 0 +public const rte_eth_rx_mq_mode_ETH_MQ_RX_NONE: rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = 0 // For RX side, only RSS is on * -public const rte_eth_rx_mq_mode_ETH_MQ_RX_RSS : rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = 1 +public const rte_eth_rx_mq_mode_ETH_MQ_RX_RSS: rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = 1 // For RX side,only DCB is on. * -public const rte_eth_rx_mq_mode_ETH_MQ_RX_DCB : rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = 2 +public const rte_eth_rx_mq_mode_ETH_MQ_RX_DCB: rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = 2 // Both DCB and RSS enable * -public const rte_eth_rx_mq_mode_ETH_MQ_RX_DCB_RSS : rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = 3 +public const rte_eth_rx_mq_mode_ETH_MQ_RX_DCB_RSS: rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = 3 // Only VMDQ, no RSS nor DCB * -public const rte_eth_rx_mq_mode_ETH_MQ_RX_VMDQ_ONLY : rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = 4 +public const rte_eth_rx_mq_mode_ETH_MQ_RX_VMDQ_ONLY: rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = 4 // RSS mode with VMDQ * -public const rte_eth_rx_mq_mode_ETH_MQ_RX_VMDQ_RSS : rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = 5 +public const rte_eth_rx_mq_mode_ETH_MQ_RX_VMDQ_RSS: rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = 5 // Use VMDQ+DCB to route traffic to queues * -public const rte_eth_rx_mq_mode_ETH_MQ_RX_VMDQ_DCB : rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = 6 +public const rte_eth_rx_mq_mode_ETH_MQ_RX_VMDQ_DCB: rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = 6 // Enable both VMDQ and DCB in VMDq * -public const rte_eth_rx_mq_mode_ETH_MQ_RX_VMDQ_DCB_RSS : rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = 7 +public const rte_eth_rx_mq_mode_ETH_MQ_RX_VMDQ_DCB_RSS: rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = 7 // A set of values to identify what method is to be used to route // packets to multiple queues. @@ -177,103 +149,103 @@ public type rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = UInt32 // A structure used to configure the RX features of an Ethernet port. @C public struct rte_eth_rxmode_rte_eth_rxmode { -// The multi-queue packet distribution mode to be used, e.g. RSS. * -public var mq_mode : rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = unsafe { zeroValue() } -//< Only used if jumbo_frame enabled. * -public var max_rx_pkt_len : UInt32 = unsafe { zeroValue() } -//< hdr buf size (header_split enabled).* -public var split_hdr_size : UInt16 = unsafe { zeroValue() } -var _bitfield_1 : VArray = VArray(repeat: 0) -public func header_split(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 0, 1) }) -} -public mut func header_split(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 1, UInt64(val)) } -} -public func hw_ip_checksum(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 1, 1) }) -} -public mut func hw_ip_checksum(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 1, 1, UInt64(val)) } -} -public func hw_vlan_filter(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 2, 1) }) -} -public mut func hw_vlan_filter(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 2, 1, UInt64(val)) } -} -public func hw_vlan_strip(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 3, 1) }) -} -public mut func hw_vlan_strip(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 3, 1, UInt64(val)) } -} -public func hw_vlan_extend(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 4, 1) }) -} -public mut func hw_vlan_extend(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 4, 1, UInt64(val)) } -} -public func jumbo_frame(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 5, 1) }) -} -public mut func jumbo_frame(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 5, 1, UInt64(val)) } -} -public func hw_strip_crc(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 6, 1) }) -} -public mut func hw_strip_crc(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 6, 1, UInt64(val)) } -} -public func enable_scatter(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 7, 1) }) -} -public mut func enable_scatter(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 7, 1, UInt64(val)) } -} -public func enable_lro(): UInt16 { - var s = this._bitfield_1 - return UInt16(unsafe { __cjbind_bitfield_read(inout s, 8, 1) }) -} -public mut func enable_lro(val!: UInt16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 8, 1, UInt64(val)) } -} -public init() {} + // The multi-queue packet distribution mode to be used, e.g. RSS. * + public var mq_mode: rte_eth_rx_mq_mode_rte_eth_rx_mq_mode = unsafe { zeroValue() } + //< Only used if jumbo_frame enabled. * + public var max_rx_pkt_len: UInt32 = unsafe { zeroValue() } + //< hdr buf size (header_split enabled).* + public var split_hdr_size: UInt16 = unsafe { zeroValue() } + var _bitfield_1: VArray = VArray(repeat: 0) + public func header_split(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 0, 1) }) + } + public mut func header_split(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 1, UInt64(val)) } + } + public func hw_ip_checksum(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 1, 1) }) + } + public mut func hw_ip_checksum(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 1, 1, UInt64(val)) } + } + public func hw_vlan_filter(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 2, 1) }) + } + public mut func hw_vlan_filter(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 2, 1, UInt64(val)) } + } + public func hw_vlan_strip(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 3, 1) }) + } + public mut func hw_vlan_strip(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 3, 1, UInt64(val)) } + } + public func hw_vlan_extend(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 4, 1) }) + } + public mut func hw_vlan_extend(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 4, 1, UInt64(val)) } + } + public func jumbo_frame(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 5, 1) }) + } + public mut func jumbo_frame(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 5, 1, UInt64(val)) } + } + public func hw_strip_crc(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 6, 1) }) + } + public mut func hw_strip_crc(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 6, 1, UInt64(val)) } + } + public func enable_scatter(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 7, 1) }) + } + public mut func enable_scatter(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 7, 1, UInt64(val)) } + } + public func enable_lro(): UInt16 { + var s = this._bitfield_1 + return UInt16(unsafe { __cjbind_bitfield_read(inout s, 8, 1) }) + } + public mut func enable_lro(val!: UInt16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 8, 1, UInt64(val)) } + } + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 12) { - throw Exception("Size of rte_eth_rxmode_rte_eth_rxmode is not 12 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of rte_eth_rxmode_rte_eth_rxmode is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 12) { + throw Exception("Size of rte_eth_rxmode_rte_eth_rxmode is not 12 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of rte_eth_rxmode_rte_eth_rxmode is not 4 but ${align} bytes") + } } //< It is in neither DCB nor VT mode. * -public const rte_eth_tx_mq_mode_ETH_MQ_TX_NONE : rte_eth_tx_mq_mode_rte_eth_tx_mq_mode = 0 +public const rte_eth_tx_mq_mode_ETH_MQ_TX_NONE: rte_eth_tx_mq_mode_rte_eth_tx_mq_mode = 0 //< For TX side,only DCB is on. * -public const rte_eth_tx_mq_mode_ETH_MQ_TX_DCB : rte_eth_tx_mq_mode_rte_eth_tx_mq_mode = 1 +public const rte_eth_tx_mq_mode_ETH_MQ_TX_DCB: rte_eth_tx_mq_mode_rte_eth_tx_mq_mode = 1 //< For TX side,both DCB and VT is on. * -public const rte_eth_tx_mq_mode_ETH_MQ_TX_VMDQ_DCB : rte_eth_tx_mq_mode_rte_eth_tx_mq_mode = 2 +public const rte_eth_tx_mq_mode_ETH_MQ_TX_VMDQ_DCB: rte_eth_tx_mq_mode_rte_eth_tx_mq_mode = 2 //< Only VT on, no DCB * -public const rte_eth_tx_mq_mode_ETH_MQ_TX_VMDQ_ONLY : rte_eth_tx_mq_mode_rte_eth_tx_mq_mode = 3 +public const rte_eth_tx_mq_mode_ETH_MQ_TX_VMDQ_ONLY: rte_eth_tx_mq_mode_rte_eth_tx_mq_mode = 3 // A set of values to identify what method is to be used to transmit // packets using multi-TCs. @@ -282,45 +254,45 @@ public type rte_eth_tx_mq_mode_rte_eth_tx_mq_mode = UInt32 // A structure used to configure the TX features of an Ethernet port. @C public struct rte_eth_txmode_rte_eth_txmode { -//< TX multi-queues mode. * -public var mq_mode : rte_eth_tx_mq_mode_rte_eth_tx_mq_mode = unsafe { zeroValue() } -public var pvid : UInt16 = unsafe { zeroValue() } -var _bitfield_1 : VArray = VArray(repeat: 0) -public func hw_vlan_reject_tagged(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read(inout s, 0, 1) }) -} -public mut func hw_vlan_reject_tagged(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 1, UInt64(val)) } -} -public func hw_vlan_reject_untagged(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read(inout s, 1, 1) }) -} -public mut func hw_vlan_reject_untagged(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 1, 1, UInt64(val)) } -} -public func hw_vlan_insert_pvid(): UInt8 { - var s = this._bitfield_1 - return UInt8(unsafe { __cjbind_bitfield_read(inout s, 2, 1) }) -} -public mut func hw_vlan_insert_pvid(val!: UInt8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 2, 1, UInt64(val)) } -} -public init() {} + //< TX multi-queues mode. * + public var mq_mode: rte_eth_tx_mq_mode_rte_eth_tx_mq_mode = unsafe { zeroValue() } + public var pvid: UInt16 = unsafe { zeroValue() } + var _bitfield_1: VArray = VArray(repeat: 0) + public func hw_vlan_reject_tagged(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read(inout s, 0, 1) }) + } + public mut func hw_vlan_reject_tagged(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 1, UInt64(val)) } + } + public func hw_vlan_reject_untagged(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read(inout s, 1, 1) }) + } + public mut func hw_vlan_reject_untagged(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 1, 1, UInt64(val)) } + } + public func hw_vlan_insert_pvid(): UInt8 { + var s = this._bitfield_1 + return UInt8(unsafe { __cjbind_bitfield_read(inout s, 2, 1) }) + } + public mut func hw_vlan_insert_pvid(val!: UInt8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 2, 1, UInt64(val)) } + } + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 8) { - throw Exception("Size of rte_eth_txmode_rte_eth_txmode is not 8 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of rte_eth_txmode_rte_eth_txmode is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 8) { + throw Exception("Size of rte_eth_txmode_rte_eth_txmode is not 8 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of rte_eth_txmode_rte_eth_txmode is not 4 but ${align} bytes") + } } // A structure used to configure the Receive Side Scaling (RSS) feature @@ -340,53 +312,53 @@ let _ = { // Supplying an *rss_hf* equal to zero disables the RSS feature. @C public struct rte_eth_rss_conf_rte_eth_rss_conf { -//< If not NULL, 40-byte hash key. * -public let rss_key : CPointer -//< hash key length in bytes. * -public let rss_key_len : UInt8 -//< Hash functions to apply - see below. * -public let rss_hf : UInt64 -public init(rss_key : CPointer , rss_key_len : UInt8 , rss_hf : UInt64) { - this.rss_key = rss_key -this.rss_key_len = rss_key_len -this.rss_hf = rss_hf -} + //< If not NULL, 40-byte hash key. * + public let rss_key: CPointer + //< hash key length in bytes. * + public let rss_key_len: UInt8 + //< Hash functions to apply - see below. * + public let rss_hf: UInt64 + public init(rss_key: CPointer, rss_key_len: UInt8, rss_hf: UInt64) { + this.rss_key = rss_key + this.rss_key_len = rss_key_len + this.rss_hf = rss_hf + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 24) { - throw Exception("Size of rte_eth_rss_conf_rte_eth_rss_conf is not 24 but ${size} bytes") - } - let align = alignOf() - if (align != 8) { - throw Exception("Alignment of rte_eth_rss_conf_rte_eth_rss_conf is not 8 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 24) { + throw Exception("Size of rte_eth_rss_conf_rte_eth_rss_conf is not 24 but ${size} bytes") + } + let align = alignOf() + if (align != 8) { + throw Exception("Alignment of rte_eth_rss_conf_rte_eth_rss_conf is not 8 but ${align} bytes") + } } //< 4 TCs with DCB. * -public const rte_eth_nb_tcs_ETH_4_TCS : rte_eth_nb_tcs_rte_eth_nb_tcs = 4 +public const rte_eth_nb_tcs_ETH_4_TCS: rte_eth_nb_tcs_rte_eth_nb_tcs = 4 //< 8 TCs with DCB. * -public const rte_eth_nb_tcs_ETH_8_TCS : rte_eth_nb_tcs_rte_eth_nb_tcs = 8 +public const rte_eth_nb_tcs_ETH_8_TCS: rte_eth_nb_tcs_rte_eth_nb_tcs = 8 // This enum indicates the possible number of traffic classes // in DCB configratioins public type rte_eth_nb_tcs_rte_eth_nb_tcs = UInt32 //< 8 VMDq pools. * -public const rte_eth_nb_pools_ETH_8_POOLS : rte_eth_nb_pools_rte_eth_nb_pools = 8 +public const rte_eth_nb_pools_ETH_8_POOLS: rte_eth_nb_pools_rte_eth_nb_pools = 8 //< 16 VMDq pools. * -public const rte_eth_nb_pools_ETH_16_POOLS : rte_eth_nb_pools_rte_eth_nb_pools = 16 +public const rte_eth_nb_pools_ETH_16_POOLS: rte_eth_nb_pools_rte_eth_nb_pools = 16 //< 32 VMDq pools. * -public const rte_eth_nb_pools_ETH_32_POOLS : rte_eth_nb_pools_rte_eth_nb_pools = 32 +public const rte_eth_nb_pools_ETH_32_POOLS: rte_eth_nb_pools_rte_eth_nb_pools = 32 //< 64 VMDq pools. * -public const rte_eth_nb_pools_ETH_64_POOLS : rte_eth_nb_pools_rte_eth_nb_pools = 64 +public const rte_eth_nb_pools_ETH_64_POOLS: rte_eth_nb_pools_rte_eth_nb_pools = 64 // This enum indicates the possible number of queue pools // in VMDQ configurations. @@ -394,27 +366,27 @@ public type rte_eth_nb_pools_rte_eth_nb_pools = UInt32 @C public struct rte_eth_vmdq_dcb_conf__cjbind_ty_1 { -//< The vlan ID of the received frame * -public let vlan_id : UInt16 -//< Bitmask of pools for packet rx * -public let pools : UInt64 -public init(vlan_id : UInt16 , pools : UInt64) { - this.vlan_id = vlan_id -this.pools = pools -} + //< The vlan ID of the received frame * + public let vlan_id: UInt16 + //< Bitmask of pools for packet rx * + public let pools: UInt64 + public init(vlan_id: UInt16, pools: UInt64) { + this.vlan_id = vlan_id + this.pools = pools + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 16) { - throw Exception("Size of rte_eth_vmdq_dcb_conf__cjbind_ty_1 is not 16 but ${size} bytes") - } - let align = alignOf() - if (align != 8) { - throw Exception("Alignment of rte_eth_vmdq_dcb_conf__cjbind_ty_1 is not 8 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 16) { + throw Exception("Size of rte_eth_vmdq_dcb_conf__cjbind_ty_1 is not 16 but ${size} bytes") + } + let align = alignOf() + if (align != 8) { + throw Exception("Alignment of rte_eth_vmdq_dcb_conf__cjbind_ty_1 is not 8 but ${align} bytes") + } } // A structure used to configure the VMDQ+DCB feature @@ -428,245 +400,250 @@ let _ = { // does not match the vlan filter rules. @C public struct rte_eth_vmdq_dcb_conf_rte_eth_vmdq_dcb_conf { -//< With DCB, 16 or 32 pools * -public let nb_queue_pools : rte_eth_nb_pools_rte_eth_nb_pools -//< If non-zero, use a default pool * -public let enable_default_pool : UInt8 -//< The default pool, if applicable * -public let default_pool : UInt8 -//< We can have up to 64 filters/mappings * -public let nb_pool_maps : UInt8 -//< VMDq vlan pool maps. * -public let pool_map : VArray -public let __cjbind_anon_1 : rte_eth_vmdq_dcb_conf__cjbind_ty_1 -public let dcb_tc : VArray -public init(nb_queue_pools : rte_eth_nb_pools_rte_eth_nb_pools , enable_default_pool : UInt8 , default_pool : UInt8 , nb_pool_maps : UInt8 , pool_map : VArray , __cjbind_anon_1 : rte_eth_vmdq_dcb_conf__cjbind_ty_1 , dcb_tc : VArray) { - this.nb_queue_pools = nb_queue_pools -this.enable_default_pool = enable_default_pool -this.default_pool = default_pool -this.nb_pool_maps = nb_pool_maps -this.pool_map = pool_map -this.__cjbind_anon_1 = __cjbind_anon_1 -this.dcb_tc = dcb_tc -} + //< With DCB, 16 or 32 pools * + public let nb_queue_pools: rte_eth_nb_pools_rte_eth_nb_pools + //< If non-zero, use a default pool * + public let enable_default_pool: UInt8 + //< The default pool, if applicable * + public let default_pool: UInt8 + //< We can have up to 64 filters/mappings * + public let nb_pool_maps: UInt8 + //< VMDq vlan pool maps. * + public let pool_map: VArray + public let __cjbind_anon_1: rte_eth_vmdq_dcb_conf__cjbind_ty_1 + public let dcb_tc: VArray + public init(nb_queue_pools: rte_eth_nb_pools_rte_eth_nb_pools, enable_default_pool: UInt8, default_pool: UInt8, + nb_pool_maps: UInt8, pool_map: VArray, + __cjbind_anon_1: rte_eth_vmdq_dcb_conf__cjbind_ty_1, dcb_tc: VArray) { + this.nb_queue_pools = nb_queue_pools + this.enable_default_pool = enable_default_pool + this.default_pool = default_pool + this.nb_pool_maps = nb_pool_maps + this.pool_map = pool_map + this.__cjbind_anon_1 = __cjbind_anon_1 + this.dcb_tc = dcb_tc + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 1040) { - throw Exception("Size of rte_eth_vmdq_dcb_conf_rte_eth_vmdq_dcb_conf is not 1040 but ${size} bytes") - } - let align = alignOf() - if (align != 8) { - throw Exception("Alignment of rte_eth_vmdq_dcb_conf_rte_eth_vmdq_dcb_conf is not 8 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 1040) { + throw Exception("Size of rte_eth_vmdq_dcb_conf_rte_eth_vmdq_dcb_conf is not 1040 but ${size} bytes") + } + let align = alignOf() + if (align != 8) { + throw Exception("Alignment of rte_eth_vmdq_dcb_conf_rte_eth_vmdq_dcb_conf is not 8 but ${align} bytes") + } } @C public struct rte_eth_dcb_rx_conf_rte_eth_dcb_rx_conf { -//< Possible DCB TCs, 4 or 8 TCs * -public let nb_tcs : rte_eth_nb_tcs_rte_eth_nb_tcs -// Traffic class each UP mapped to. * -public let dcb_tc : VArray -public init(nb_tcs : rte_eth_nb_tcs_rte_eth_nb_tcs , dcb_tc : VArray) { - this.nb_tcs = nb_tcs -this.dcb_tc = dcb_tc -} + //< Possible DCB TCs, 4 or 8 TCs * + public let nb_tcs: rte_eth_nb_tcs_rte_eth_nb_tcs + // Traffic class each UP mapped to. * + public let dcb_tc: VArray + public init(nb_tcs: rte_eth_nb_tcs_rte_eth_nb_tcs, dcb_tc: VArray) { + this.nb_tcs = nb_tcs + this.dcb_tc = dcb_tc + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 12) { - throw Exception("Size of rte_eth_dcb_rx_conf_rte_eth_dcb_rx_conf is not 12 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of rte_eth_dcb_rx_conf_rte_eth_dcb_rx_conf is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 12) { + throw Exception("Size of rte_eth_dcb_rx_conf_rte_eth_dcb_rx_conf is not 12 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of rte_eth_dcb_rx_conf_rte_eth_dcb_rx_conf is not 4 but ${align} bytes") + } } @C public struct rte_eth_vmdq_dcb_tx_conf_rte_eth_vmdq_dcb_tx_conf { -//< With DCB, 16 or 32 pools. * -public let nb_queue_pools : rte_eth_nb_pools_rte_eth_nb_pools -// Traffic class each UP mapped to. * -public let dcb_tc : VArray -public init(nb_queue_pools : rte_eth_nb_pools_rte_eth_nb_pools , dcb_tc : VArray) { - this.nb_queue_pools = nb_queue_pools -this.dcb_tc = dcb_tc -} + //< With DCB, 16 or 32 pools. * + public let nb_queue_pools: rte_eth_nb_pools_rte_eth_nb_pools + // Traffic class each UP mapped to. * + public let dcb_tc: VArray + public init(nb_queue_pools: rte_eth_nb_pools_rte_eth_nb_pools, dcb_tc: VArray) { + this.nb_queue_pools = nb_queue_pools + this.dcb_tc = dcb_tc + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 12) { - throw Exception("Size of rte_eth_vmdq_dcb_tx_conf_rte_eth_vmdq_dcb_tx_conf is not 12 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of rte_eth_vmdq_dcb_tx_conf_rte_eth_vmdq_dcb_tx_conf is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 12) { + throw Exception("Size of rte_eth_vmdq_dcb_tx_conf_rte_eth_vmdq_dcb_tx_conf is not 12 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception( + "Alignment of rte_eth_vmdq_dcb_tx_conf_rte_eth_vmdq_dcb_tx_conf is not 4 but ${align} bytes") + } } @C public struct rte_eth_dcb_tx_conf_rte_eth_dcb_tx_conf { -//< Possible DCB TCs, 4 or 8 TCs. * -public let nb_tcs : rte_eth_nb_tcs_rte_eth_nb_tcs -// Traffic class each UP mapped to. * -public let dcb_tc : VArray -public init(nb_tcs : rte_eth_nb_tcs_rte_eth_nb_tcs , dcb_tc : VArray) { - this.nb_tcs = nb_tcs -this.dcb_tc = dcb_tc -} + //< Possible DCB TCs, 4 or 8 TCs. * + public let nb_tcs: rte_eth_nb_tcs_rte_eth_nb_tcs + // Traffic class each UP mapped to. * + public let dcb_tc: VArray + public init(nb_tcs: rte_eth_nb_tcs_rte_eth_nb_tcs, dcb_tc: VArray) { + this.nb_tcs = nb_tcs + this.dcb_tc = dcb_tc + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 12) { - throw Exception("Size of rte_eth_dcb_tx_conf_rte_eth_dcb_tx_conf is not 12 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of rte_eth_dcb_tx_conf_rte_eth_dcb_tx_conf is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 12) { + throw Exception("Size of rte_eth_dcb_tx_conf_rte_eth_dcb_tx_conf is not 12 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of rte_eth_dcb_tx_conf_rte_eth_dcb_tx_conf is not 4 but ${align} bytes") + } } @C public struct rte_eth_vmdq_tx_conf_rte_eth_vmdq_tx_conf { -//< VMDq mode, 64 pools. * -public let nb_queue_pools : rte_eth_nb_pools_rte_eth_nb_pools -public init(nb_queue_pools : rte_eth_nb_pools_rte_eth_nb_pools) { - this.nb_queue_pools = nb_queue_pools -} + //< VMDq mode, 64 pools. * + public let nb_queue_pools: rte_eth_nb_pools_rte_eth_nb_pools + public init(nb_queue_pools: rte_eth_nb_pools_rte_eth_nb_pools) { + this.nb_queue_pools = nb_queue_pools + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of rte_eth_vmdq_tx_conf_rte_eth_vmdq_tx_conf is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of rte_eth_vmdq_tx_conf_rte_eth_vmdq_tx_conf is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of rte_eth_vmdq_tx_conf_rte_eth_vmdq_tx_conf is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of rte_eth_vmdq_tx_conf_rte_eth_vmdq_tx_conf is not 4 but ${align} bytes") + } } @C public struct rte_eth_vmdq_rx_conf__cjbind_ty_1 { -//< The vlan ID of the received frame * -public let vlan_id : UInt16 -//< Bitmask of pools for packet rx * -public let pools : UInt64 -public init(vlan_id : UInt16 , pools : UInt64) { - this.vlan_id = vlan_id -this.pools = pools -} + //< The vlan ID of the received frame * + public let vlan_id: UInt16 + //< Bitmask of pools for packet rx * + public let pools: UInt64 + public init(vlan_id: UInt16, pools: UInt64) { + this.vlan_id = vlan_id + this.pools = pools + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 16) { - throw Exception("Size of rte_eth_vmdq_rx_conf__cjbind_ty_1 is not 16 but ${size} bytes") - } - let align = alignOf() - if (align != 8) { - throw Exception("Alignment of rte_eth_vmdq_rx_conf__cjbind_ty_1 is not 8 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 16) { + throw Exception("Size of rte_eth_vmdq_rx_conf__cjbind_ty_1 is not 16 but ${size} bytes") + } + let align = alignOf() + if (align != 8) { + throw Exception("Alignment of rte_eth_vmdq_rx_conf__cjbind_ty_1 is not 8 but ${align} bytes") + } } @C public struct rte_eth_vmdq_rx_conf_rte_eth_vmdq_rx_conf { -//< VMDq only mode, 8 or 64 pools * -public let nb_queue_pools : rte_eth_nb_pools_rte_eth_nb_pools -//< If non-zero, use a default pool * -public let enable_default_pool : UInt8 -//< The default pool, if applicable * -public let default_pool : UInt8 -//< Enable VT loop back * -public let enable_loop_back : UInt8 -//< We can have up to 64 filters/mappings * -public let nb_pool_maps : UInt8 -//< Flags from ETH_VMDQ_ACCEPT_* * -public let rx_mode : UInt32 -//< VMDq vlan pool maps. * -public let pool_map : VArray -public let __cjbind_anon_1 : rte_eth_vmdq_rx_conf__cjbind_ty_1 -public init(nb_queue_pools : rte_eth_nb_pools_rte_eth_nb_pools , enable_default_pool : UInt8 , default_pool : UInt8 , enable_loop_back : UInt8 , nb_pool_maps : UInt8 , rx_mode : UInt32 , pool_map : VArray , __cjbind_anon_1 : rte_eth_vmdq_rx_conf__cjbind_ty_1) { - this.nb_queue_pools = nb_queue_pools -this.enable_default_pool = enable_default_pool -this.default_pool = default_pool -this.enable_loop_back = enable_loop_back -this.nb_pool_maps = nb_pool_maps -this.rx_mode = rx_mode -this.pool_map = pool_map -this.__cjbind_anon_1 = __cjbind_anon_1 -} + //< VMDq only mode, 8 or 64 pools * + public let nb_queue_pools: rte_eth_nb_pools_rte_eth_nb_pools + //< If non-zero, use a default pool * + public let enable_default_pool: UInt8 + //< The default pool, if applicable * + public let default_pool: UInt8 + //< Enable VT loop back * + public let enable_loop_back: UInt8 + //< We can have up to 64 filters/mappings * + public let nb_pool_maps: UInt8 + //< Flags from ETH_VMDQ_ACCEPT_* * + public let rx_mode: UInt32 + //< VMDq vlan pool maps. * + public let pool_map: VArray + public let __cjbind_anon_1: rte_eth_vmdq_rx_conf__cjbind_ty_1 + public init(nb_queue_pools: rte_eth_nb_pools_rte_eth_nb_pools, enable_default_pool: UInt8, default_pool: UInt8, + enable_loop_back: UInt8, nb_pool_maps: UInt8, rx_mode: UInt32, + pool_map: VArray, __cjbind_anon_1: rte_eth_vmdq_rx_conf__cjbind_ty_1) { + this.nb_queue_pools = nb_queue_pools + this.enable_default_pool = enable_default_pool + this.default_pool = default_pool + this.enable_loop_back = enable_loop_back + this.nb_pool_maps = nb_pool_maps + this.rx_mode = rx_mode + this.pool_map = pool_map + this.__cjbind_anon_1 = __cjbind_anon_1 + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 1040) { - throw Exception("Size of rte_eth_vmdq_rx_conf_rte_eth_vmdq_rx_conf is not 1040 but ${size} bytes") - } - let align = alignOf() - if (align != 8) { - throw Exception("Alignment of rte_eth_vmdq_rx_conf_rte_eth_vmdq_rx_conf is not 8 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 1040) { + throw Exception("Size of rte_eth_vmdq_rx_conf_rte_eth_vmdq_rx_conf is not 1040 but ${size} bytes") + } + let align = alignOf() + if (align != 8) { + throw Exception("Alignment of rte_eth_vmdq_rx_conf_rte_eth_vmdq_rx_conf is not 8 but ${align} bytes") + } } //< Disable FDIR support. * -public const rte_fdir_mode_RTE_FDIR_MODE_NONE : rte_fdir_mode_rte_fdir_mode = 0 +public const rte_fdir_mode_RTE_FDIR_MODE_NONE: rte_fdir_mode_rte_fdir_mode = 0 //< Enable FDIR signature filter mode. * -public const rte_fdir_mode_RTE_FDIR_MODE_SIGNATURE : rte_fdir_mode_rte_fdir_mode = 1 +public const rte_fdir_mode_RTE_FDIR_MODE_SIGNATURE: rte_fdir_mode_rte_fdir_mode = 1 //< Enable FDIR perfect filter mode. * -public const rte_fdir_mode_RTE_FDIR_MODE_PERFECT : rte_fdir_mode_rte_fdir_mode = 2 +public const rte_fdir_mode_RTE_FDIR_MODE_PERFECT: rte_fdir_mode_rte_fdir_mode = 2 //< Enable FDIR filter mode - MAC VLAN. * -public const rte_fdir_mode_RTE_FDIR_MODE_PERFECT_MAC_VLAN : rte_fdir_mode_rte_fdir_mode = 3 +public const rte_fdir_mode_RTE_FDIR_MODE_PERFECT_MAC_VLAN: rte_fdir_mode_rte_fdir_mode = 3 //< Enable FDIR filter mode - tunnel. * -public const rte_fdir_mode_RTE_FDIR_MODE_PERFECT_TUNNEL : rte_fdir_mode_rte_fdir_mode = 4 +public const rte_fdir_mode_RTE_FDIR_MODE_PERFECT_TUNNEL: rte_fdir_mode_rte_fdir_mode = 4 // Flow Director setting modes: none, signature or perfect. public type rte_fdir_mode_rte_fdir_mode = UInt32 //< 64k. * -public const rte_fdir_pballoc_type_RTE_FDIR_PBALLOC_64K : rte_fdir_pballoc_type_rte_fdir_pballoc_type = 0 +public const rte_fdir_pballoc_type_RTE_FDIR_PBALLOC_64K: rte_fdir_pballoc_type_rte_fdir_pballoc_type = 0 //< 128k. * -public const rte_fdir_pballoc_type_RTE_FDIR_PBALLOC_128K : rte_fdir_pballoc_type_rte_fdir_pballoc_type = 1 +public const rte_fdir_pballoc_type_RTE_FDIR_PBALLOC_128K: rte_fdir_pballoc_type_rte_fdir_pballoc_type = 1 //< 256k. * -public const rte_fdir_pballoc_type_RTE_FDIR_PBALLOC_256K : rte_fdir_pballoc_type_rte_fdir_pballoc_type = 2 +public const rte_fdir_pballoc_type_RTE_FDIR_PBALLOC_256K: rte_fdir_pballoc_type_rte_fdir_pballoc_type = 2 // Memory space that can be configured to store Flow Director filters // in the board memory. public type rte_fdir_pballoc_type_rte_fdir_pballoc_type = UInt32 //< Never report FDIR hash. * -public const rte_fdir_status_mode_RTE_FDIR_NO_REPORT_STATUS : rte_fdir_status_mode_rte_fdir_status_mode = 0 +public const rte_fdir_status_mode_RTE_FDIR_NO_REPORT_STATUS: rte_fdir_status_mode_rte_fdir_status_mode = 0 //< Only report FDIR hash for matching pkts. * -public const rte_fdir_status_mode_RTE_FDIR_REPORT_STATUS : rte_fdir_status_mode_rte_fdir_status_mode = 1 +public const rte_fdir_status_mode_RTE_FDIR_REPORT_STATUS: rte_fdir_status_mode_rte_fdir_status_mode = 1 //< Always report FDIR hash. * -public const rte_fdir_status_mode_RTE_FDIR_REPORT_STATUS_ALWAYS : rte_fdir_status_mode_rte_fdir_status_mode = 2 +public const rte_fdir_status_mode_RTE_FDIR_REPORT_STATUS_ALWAYS: rte_fdir_status_mode_rte_fdir_status_mode = 2 // Select report mode of FDIR hash information in RX descriptors. public type rte_fdir_status_mode_rte_fdir_status_mode = UInt32 @@ -674,131 +651,128 @@ public type rte_fdir_status_mode_rte_fdir_status_mode = UInt32 // A structure used to define the input for IPV4 flow @C public struct rte_eth_ipv4_flow_rte_eth_ipv4_flow { -//< IPv4 source address in big endian. * -public let src_ip : UInt32 -//< IPv4 destination address in big endian. * -public let dst_ip : UInt32 -//< Type of service to match. * -public let tos : UInt8 -//< Time to live to match. * -public let ttl : UInt8 -//< Protocol, next header in big endian. * -public let proto : UInt8 -public init(src_ip : UInt32 , dst_ip : UInt32 , tos : UInt8 , ttl : UInt8 , proto : UInt8) { - this.src_ip = src_ip -this.dst_ip = dst_ip -this.tos = tos -this.ttl = ttl -this.proto = proto -} + //< IPv4 source address in big endian. * + public let src_ip: UInt32 + //< IPv4 destination address in big endian. * + public let dst_ip: UInt32 + //< Type of service to match. * + public let tos: UInt8 + //< Time to live to match. * + public let ttl: UInt8 + //< Protocol, next header in big endian. * + public let proto: UInt8 + public init(src_ip: UInt32, dst_ip: UInt32, tos: UInt8, ttl: UInt8, proto: UInt8) { + this.src_ip = src_ip + this.dst_ip = dst_ip + this.tos = tos + this.ttl = ttl + this.proto = proto + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 12) { - throw Exception("Size of rte_eth_ipv4_flow_rte_eth_ipv4_flow is not 12 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of rte_eth_ipv4_flow_rte_eth_ipv4_flow is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 12) { + throw Exception("Size of rte_eth_ipv4_flow_rte_eth_ipv4_flow is not 12 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of rte_eth_ipv4_flow_rte_eth_ipv4_flow is not 4 but ${align} bytes") + } } // A structure used to define the input for IPV6 flow @C public struct rte_eth_ipv6_flow_rte_eth_ipv6_flow { -//< IPv6 source address in big endian. * -public let src_ip : VArray -//< IPv6 destination address in big endian. * -public let dst_ip : VArray -//< Traffic class to match. * -public let tc : UInt8 -//< Protocol, next header to match. * -public let proto : UInt8 -//< Hop limits to match. * -public let hop_limits : UInt8 -public init(src_ip : VArray , dst_ip : VArray , tc : UInt8 , proto : UInt8 , hop_limits : UInt8) { - this.src_ip = src_ip -this.dst_ip = dst_ip -this.tc = tc -this.proto = proto -this.hop_limits = hop_limits -} + //< IPv6 source address in big endian. * + public let src_ip: VArray + //< IPv6 destination address in big endian. * + public let dst_ip: VArray + //< Traffic class to match. * + public let tc: UInt8 + //< Protocol, next header to match. * + public let proto: UInt8 + //< Hop limits to match. * + public let hop_limits: UInt8 + public init(src_ip: VArray, dst_ip: VArray, tc: UInt8, proto: UInt8, hop_limits: UInt8) { + this.src_ip = src_ip + this.dst_ip = dst_ip + this.tc = tc + this.proto = proto + this.hop_limits = hop_limits + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 36) { - throw Exception("Size of rte_eth_ipv6_flow_rte_eth_ipv6_flow is not 36 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of rte_eth_ipv6_flow_rte_eth_ipv6_flow is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 36) { + throw Exception("Size of rte_eth_ipv6_flow_rte_eth_ipv6_flow is not 36 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of rte_eth_ipv6_flow_rte_eth_ipv6_flow is not 4 but ${align} bytes") + } } // A structure used to configure FDIR masks that are used by the device // to match the various fields of RX packet headers. @C public struct rte_eth_fdir_masks_rte_eth_fdir_masks { -//< Bit mask for vlan_tci in big endian * -public let vlan_tci_mask : UInt16 -// Bit mask for ipv4 flow in big endian. * -public let ipv4_mask : rte_eth_ipv4_flow_rte_eth_ipv4_flow -// Bit maks for ipv6 flow in big endian. * -public let ipv6_mask : rte_eth_ipv6_flow_rte_eth_ipv6_flow -// Bit mask for L4 source port in big endian. * -public let src_port_mask : UInt16 -// Bit mask for L4 destination port in big endian. * -public let dst_port_mask : UInt16 -// 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the -//first byte on the wire * -public let mac_addr_byte_mask : UInt8 -// Bit mask for tunnel ID in big endian. * -public let tunnel_id_mask : UInt32 -//< 1 - Match tunnel type, -//0 - Ignore tunnel type. * -public let tunnel_type_mask : UInt8 -public init(vlan_tci_mask : UInt16 , ipv4_mask : rte_eth_ipv4_flow_rte_eth_ipv4_flow , ipv6_mask : rte_eth_ipv6_flow_rte_eth_ipv6_flow , src_port_mask : UInt16 , dst_port_mask : UInt16 , mac_addr_byte_mask : UInt8 , tunnel_id_mask : UInt32 , tunnel_type_mask : UInt8) { - this.vlan_tci_mask = vlan_tci_mask -this.ipv4_mask = ipv4_mask -this.ipv6_mask = ipv6_mask -this.src_port_mask = src_port_mask -this.dst_port_mask = dst_port_mask -this.mac_addr_byte_mask = mac_addr_byte_mask -this.tunnel_id_mask = tunnel_id_mask -this.tunnel_type_mask = tunnel_type_mask -} + //< Bit mask for vlan_tci in big endian * + public let vlan_tci_mask: UInt16 + // Bit mask for ipv4 flow in big endian. * + public let ipv4_mask: rte_eth_ipv4_flow_rte_eth_ipv4_flow + // Bit maks for ipv6 flow in big endian. * + public let ipv6_mask: rte_eth_ipv6_flow_rte_eth_ipv6_flow + // Bit mask for L4 source port in big endian. * + public let src_port_mask: UInt16 + // Bit mask for L4 destination port in big endian. * + public let dst_port_mask: UInt16 + // 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the + //first byte on the wire * + public let mac_addr_byte_mask: UInt8 + // Bit mask for tunnel ID in big endian. * + public let tunnel_id_mask: UInt32 + //< 1 - Match tunnel type, + //0 - Ignore tunnel type. * + public let tunnel_type_mask: UInt8 + public init(vlan_tci_mask: UInt16, ipv4_mask: rte_eth_ipv4_flow_rte_eth_ipv4_flow, + ipv6_mask: rte_eth_ipv6_flow_rte_eth_ipv6_flow, src_port_mask: UInt16, dst_port_mask: UInt16, + mac_addr_byte_mask: UInt8, tunnel_id_mask: UInt32, tunnel_type_mask: UInt8) { + this.vlan_tci_mask = vlan_tci_mask + this.ipv4_mask = ipv4_mask + this.ipv6_mask = ipv6_mask + this.src_port_mask = src_port_mask + this.dst_port_mask = dst_port_mask + this.mac_addr_byte_mask = mac_addr_byte_mask + this.tunnel_id_mask = tunnel_id_mask + this.tunnel_type_mask = tunnel_type_mask + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 68) { - throw Exception("Size of rte_eth_fdir_masks_rte_eth_fdir_masks is not 68 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of rte_eth_fdir_masks_rte_eth_fdir_masks is not 4 but ${align} bytes") - } -} - -public const rte_eth_payload_type_RTE_ETH_PAYLOAD_UNKNOWN : rte_eth_payload_type_rte_eth_payload_type = 0 - -public const rte_eth_payload_type_RTE_ETH_RAW_PAYLOAD : rte_eth_payload_type_rte_eth_payload_type = 1 - -public const rte_eth_payload_type_RTE_ETH_L2_PAYLOAD : rte_eth_payload_type_rte_eth_payload_type = 2 - -public const rte_eth_payload_type_RTE_ETH_L3_PAYLOAD : rte_eth_payload_type_rte_eth_payload_type = 3 - -public const rte_eth_payload_type_RTE_ETH_L4_PAYLOAD : rte_eth_payload_type_rte_eth_payload_type = 4 - -public const rte_eth_payload_type_RTE_ETH_PAYLOAD_MAX : rte_eth_payload_type_rte_eth_payload_type = 8 + => + let size = sizeOf() + if (size != 68) { + throw Exception("Size of rte_eth_fdir_masks_rte_eth_fdir_masks is not 68 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of rte_eth_fdir_masks_rte_eth_fdir_masks is not 4 but ${align} bytes") + } +} + +public const rte_eth_payload_type_RTE_ETH_PAYLOAD_UNKNOWN: rte_eth_payload_type_rte_eth_payload_type = 0 +public const rte_eth_payload_type_RTE_ETH_RAW_PAYLOAD: rte_eth_payload_type_rte_eth_payload_type = 1 +public const rte_eth_payload_type_RTE_ETH_L2_PAYLOAD: rte_eth_payload_type_rte_eth_payload_type = 2 +public const rte_eth_payload_type_RTE_ETH_L3_PAYLOAD: rte_eth_payload_type_rte_eth_payload_type = 3 +public const rte_eth_payload_type_RTE_ETH_L4_PAYLOAD: rte_eth_payload_type_rte_eth_payload_type = 4 +public const rte_eth_payload_type_RTE_ETH_PAYLOAD_MAX: rte_eth_payload_type_rte_eth_payload_type = 8 // Payload type public type rte_eth_payload_type_rte_eth_payload_type = UInt32 @@ -807,82 +781,85 @@ public type rte_eth_payload_type_rte_eth_payload_type = UInt32 // flexible payload for filter @C public struct rte_eth_flex_payload_cfg_rte_eth_flex_payload_cfg { -//< Payload type * -public let type_ : rte_eth_payload_type_rte_eth_payload_type -public let src_offset : VArray -public init(type_ : rte_eth_payload_type_rte_eth_payload_type , src_offset : VArray) { - this.type_ = type_ -this.src_offset = src_offset -} + //< Payload type * + public let type_: rte_eth_payload_type_rte_eth_payload_type + public let src_offset: VArray + public init(type_: rte_eth_payload_type_rte_eth_payload_type, src_offset: VArray) { + this.type_ = type_ + this.src_offset = src_offset + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 36) { - throw Exception("Size of rte_eth_flex_payload_cfg_rte_eth_flex_payload_cfg is not 36 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of rte_eth_flex_payload_cfg_rte_eth_flex_payload_cfg is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 36) { + throw Exception("Size of rte_eth_flex_payload_cfg_rte_eth_flex_payload_cfg is not 36 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception( + "Alignment of rte_eth_flex_payload_cfg_rte_eth_flex_payload_cfg is not 4 but ${align} bytes") + } } // A structure used to define FDIR masks for flexible payload // for each flow type @C public struct rte_eth_fdir_flex_mask_rte_eth_fdir_flex_mask { -public let flow_type : UInt16 -public let mask : VArray -public init(flow_type : UInt16 , mask : VArray) { - this.flow_type = flow_type -this.mask = mask -} + public let flow_type: UInt16 + public let mask: VArray + public init(flow_type: UInt16, mask: VArray) { + this.flow_type = flow_type + this.mask = mask + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 18) { - throw Exception("Size of rte_eth_fdir_flex_mask_rte_eth_fdir_flex_mask is not 18 but ${size} bytes") - } - let align = alignOf() - if (align != 2) { - throw Exception("Alignment of rte_eth_fdir_flex_mask_rte_eth_fdir_flex_mask is not 2 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 18) { + throw Exception("Size of rte_eth_fdir_flex_mask_rte_eth_fdir_flex_mask is not 18 but ${size} bytes") + } + let align = alignOf() + if (align != 2) { + throw Exception("Alignment of rte_eth_fdir_flex_mask_rte_eth_fdir_flex_mask is not 2 but ${align} bytes") + } } // A structure used to define all flexible payload related setting // include flex payload and flex mask @C public struct rte_eth_fdir_flex_conf_rte_eth_fdir_flex_conf { -//< The number of following payload cfg * -public let nb_payloads : UInt16 -//< The number of following mask * -public let nb_flexmasks : UInt16 -public let flex_set : VArray -public let flex_mask : VArray -public init(nb_payloads : UInt16 , nb_flexmasks : UInt16 , flex_set : VArray , flex_mask : VArray) { - this.nb_payloads = nb_payloads -this.nb_flexmasks = nb_flexmasks -this.flex_set = flex_set -this.flex_mask = flex_mask -} + //< The number of following payload cfg * + public let nb_payloads: UInt16 + //< The number of following mask * + public let nb_flexmasks: UInt16 + public let flex_set: VArray + public let flex_mask: VArray + public init(nb_payloads: UInt16, nb_flexmasks: UInt16, + flex_set: VArray, + flex_mask: VArray) { + this.nb_payloads = nb_payloads + this.nb_flexmasks = nb_flexmasks + this.flex_set = flex_set + this.flex_mask = flex_mask + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 688) { - throw Exception("Size of rte_eth_fdir_flex_conf_rte_eth_fdir_flex_conf is not 688 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of rte_eth_fdir_flex_conf_rte_eth_fdir_flex_conf is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 688) { + throw Exception("Size of rte_eth_fdir_flex_conf_rte_eth_fdir_flex_conf is not 688 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of rte_eth_fdir_flex_conf_rte_eth_fdir_flex_conf is not 4 but ${align} bytes") + } } // A structure used to configure the Flow Director (FDIR) feature @@ -891,131 +868,135 @@ let _ = { // If mode is RTE_FDIR_DISABLE, the pballoc value is ignored. @C public struct rte_fdir_conf_rte_fdir_conf { -//< Flow Director mode. * -public let mode : rte_fdir_mode_rte_fdir_mode -//< Space for FDIR filters. * -public let pballoc : rte_fdir_pballoc_type_rte_fdir_pballoc_type -//< How to report FDIR hash. * -public let status : rte_fdir_status_mode_rte_fdir_status_mode -// RX queue of packets matching a "drop" filter in perfect mode. * -public let drop_queue : UInt8 -public let mask : rte_eth_fdir_masks_rte_eth_fdir_masks -public let flex_conf : rte_eth_fdir_flex_conf_rte_eth_fdir_flex_conf -public init(mode : rte_fdir_mode_rte_fdir_mode , pballoc : rte_fdir_pballoc_type_rte_fdir_pballoc_type , status : rte_fdir_status_mode_rte_fdir_status_mode , drop_queue : UInt8 , mask : rte_eth_fdir_masks_rte_eth_fdir_masks , flex_conf : rte_eth_fdir_flex_conf_rte_eth_fdir_flex_conf) { - this.mode = mode -this.pballoc = pballoc -this.status = status -this.drop_queue = drop_queue -this.mask = mask -this.flex_conf = flex_conf -} + //< Flow Director mode. * + public let mode: rte_fdir_mode_rte_fdir_mode + //< Space for FDIR filters. * + public let pballoc: rte_fdir_pballoc_type_rte_fdir_pballoc_type + //< How to report FDIR hash. * + public let status: rte_fdir_status_mode_rte_fdir_status_mode + // RX queue of packets matching a "drop" filter in perfect mode. * + public let drop_queue: UInt8 + public let mask: rte_eth_fdir_masks_rte_eth_fdir_masks + public let flex_conf: rte_eth_fdir_flex_conf_rte_eth_fdir_flex_conf + public init(mode: rte_fdir_mode_rte_fdir_mode, pballoc: rte_fdir_pballoc_type_rte_fdir_pballoc_type, + status: rte_fdir_status_mode_rte_fdir_status_mode, drop_queue: UInt8, + mask: rte_eth_fdir_masks_rte_eth_fdir_masks, flex_conf: rte_eth_fdir_flex_conf_rte_eth_fdir_flex_conf) { + this.mode = mode + this.pballoc = pballoc + this.status = status + this.drop_queue = drop_queue + this.mask = mask + this.flex_conf = flex_conf + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 772) { - throw Exception("Size of rte_fdir_conf_rte_fdir_conf is not 772 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of rte_fdir_conf_rte_fdir_conf is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 772) { + throw Exception("Size of rte_fdir_conf_rte_fdir_conf is not 772 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of rte_fdir_conf_rte_fdir_conf is not 4 but ${align} bytes") + } } // A structure used to enable/disable specific device interrupts. @C public struct rte_intr_conf_rte_intr_conf { -// enable/disable lsc interrupt. 0 (default) - disable, 1 enable * -public let lsc : UInt16 -// enable/disable rxq interrupt. 0 (default) - disable, 1 enable * -public let rxq : UInt16 -public init(lsc : UInt16 , rxq : UInt16) { - this.lsc = lsc -this.rxq = rxq -} + // enable/disable lsc interrupt. 0 (default) - disable, 1 enable * + public let lsc: UInt16 + // enable/disable rxq interrupt. 0 (default) - disable, 1 enable * + public let rxq: UInt16 + public init(lsc: UInt16, rxq: UInt16) { + this.lsc = lsc + this.rxq = rxq + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of rte_intr_conf_rte_intr_conf is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 2) { - throw Exception("Alignment of rte_intr_conf_rte_intr_conf is not 2 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of rte_intr_conf_rte_intr_conf is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 2) { + throw Exception("Alignment of rte_intr_conf_rte_intr_conf is not 2 but ${align} bytes") + } } @C public struct rte_eth_conf__cjbind_ty_1 { -//< Port RSS configuration * -public let rss_conf : rte_eth_rss_conf_rte_eth_rss_conf -public let vmdq_dcb_conf : rte_eth_vmdq_dcb_conf_rte_eth_vmdq_dcb_conf -public let dcb_rx_conf : rte_eth_dcb_rx_conf_rte_eth_dcb_rx_conf -public let vmdq_rx_conf : rte_eth_vmdq_rx_conf_rte_eth_vmdq_rx_conf -public init(rss_conf : rte_eth_rss_conf_rte_eth_rss_conf , vmdq_dcb_conf : rte_eth_vmdq_dcb_conf_rte_eth_vmdq_dcb_conf , dcb_rx_conf : rte_eth_dcb_rx_conf_rte_eth_dcb_rx_conf , vmdq_rx_conf : rte_eth_vmdq_rx_conf_rte_eth_vmdq_rx_conf) { - this.rss_conf = rss_conf -this.vmdq_dcb_conf = vmdq_dcb_conf -this.dcb_rx_conf = dcb_rx_conf -this.vmdq_rx_conf = vmdq_rx_conf -} + //< Port RSS configuration * + public let rss_conf: rte_eth_rss_conf_rte_eth_rss_conf + public let vmdq_dcb_conf: rte_eth_vmdq_dcb_conf_rte_eth_vmdq_dcb_conf + public let dcb_rx_conf: rte_eth_dcb_rx_conf_rte_eth_dcb_rx_conf + public let vmdq_rx_conf: rte_eth_vmdq_rx_conf_rte_eth_vmdq_rx_conf + public init(rss_conf: rte_eth_rss_conf_rte_eth_rss_conf, vmdq_dcb_conf: rte_eth_vmdq_dcb_conf_rte_eth_vmdq_dcb_conf, + dcb_rx_conf: rte_eth_dcb_rx_conf_rte_eth_dcb_rx_conf, vmdq_rx_conf: rte_eth_vmdq_rx_conf_rte_eth_vmdq_rx_conf) { + this.rss_conf = rss_conf + this.vmdq_dcb_conf = vmdq_dcb_conf + this.dcb_rx_conf = dcb_rx_conf + this.vmdq_rx_conf = vmdq_rx_conf + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 2120) { - throw Exception("Size of rte_eth_conf__cjbind_ty_1 is not 2120 but ${size} bytes") - } - let align = alignOf() - if (align != 8) { - throw Exception("Alignment of rte_eth_conf__cjbind_ty_1 is not 8 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 2120) { + throw Exception("Size of rte_eth_conf__cjbind_ty_1 is not 2120 but ${size} bytes") + } + let align = alignOf() + if (align != 8) { + throw Exception("Alignment of rte_eth_conf__cjbind_ty_1 is not 8 but ${align} bytes") + } } @C public struct rte_eth_conf__cjbind_ty_2 { -var _storage: VArray = unsafe { zeroValue>() } -public init() {} -public func vmdq_dcb_tx_conf(): rte_eth_vmdq_dcb_tx_conf_rte_eth_vmdq_dcb_tx_conf { - var s = this._storage - return unsafe { __cjbind_read_rte_eth_vmdq_dcb_tx_conf_rte_eth_vmdq_dcb_tx_conf(CPointer(inout s)) } -} -public mut func vmdq_dcb_tx_conf(val!: rte_eth_vmdq_dcb_tx_conf_rte_eth_vmdq_dcb_tx_conf): Unit { - unsafe { __cjbind_write_rte_eth_vmdq_dcb_tx_conf_rte_eth_vmdq_dcb_tx_conf(CPointer(inout this._storage), val) } -} -public func dcb_tx_conf(): rte_eth_dcb_tx_conf_rte_eth_dcb_tx_conf { - var s = this._storage - return unsafe { __cjbind_read_rte_eth_dcb_tx_conf_rte_eth_dcb_tx_conf(CPointer(inout s)) } -} -public mut func dcb_tx_conf(val!: rte_eth_dcb_tx_conf_rte_eth_dcb_tx_conf): Unit { - unsafe { __cjbind_write_rte_eth_dcb_tx_conf_rte_eth_dcb_tx_conf(CPointer(inout this._storage), val) } -} -public func vmdq_tx_conf(): rte_eth_vmdq_tx_conf_rte_eth_vmdq_tx_conf { - var s = this._storage - return unsafe { __cjbind_read_rte_eth_vmdq_tx_conf_rte_eth_vmdq_tx_conf(CPointer(inout s)) } -} -public mut func vmdq_tx_conf(val!: rte_eth_vmdq_tx_conf_rte_eth_vmdq_tx_conf): Unit { - unsafe { __cjbind_write_rte_eth_vmdq_tx_conf_rte_eth_vmdq_tx_conf(CPointer(inout this._storage), val) } -} + var _storage: VArray = unsafe { zeroValue>() } + public init() {} + public func vmdq_dcb_tx_conf(): rte_eth_vmdq_dcb_tx_conf_rte_eth_vmdq_dcb_tx_conf { + var s = this._storage + return unsafe { __cjbind_read_rte_eth_vmdq_dcb_tx_conf_rte_eth_vmdq_dcb_tx_conf(CPointer(inout s)) } + } + public mut func vmdq_dcb_tx_conf(val!: rte_eth_vmdq_dcb_tx_conf_rte_eth_vmdq_dcb_tx_conf): Unit { + unsafe { __cjbind_write_rte_eth_vmdq_dcb_tx_conf_rte_eth_vmdq_dcb_tx_conf(CPointer(inout this._storage), + val) } + } + public func dcb_tx_conf(): rte_eth_dcb_tx_conf_rte_eth_dcb_tx_conf { + var s = this._storage + return unsafe { __cjbind_read_rte_eth_dcb_tx_conf_rte_eth_dcb_tx_conf(CPointer(inout s)) } + } + public mut func dcb_tx_conf(val!: rte_eth_dcb_tx_conf_rte_eth_dcb_tx_conf): Unit { + unsafe { __cjbind_write_rte_eth_dcb_tx_conf_rte_eth_dcb_tx_conf(CPointer(inout this._storage), val) } + } + public func vmdq_tx_conf(): rte_eth_vmdq_tx_conf_rte_eth_vmdq_tx_conf { + var s = this._storage + return unsafe { __cjbind_read_rte_eth_vmdq_tx_conf_rte_eth_vmdq_tx_conf(CPointer(inout s)) } + } + public mut func vmdq_tx_conf(val!: rte_eth_vmdq_tx_conf_rte_eth_vmdq_tx_conf): Unit { + unsafe { __cjbind_write_rte_eth_vmdq_tx_conf_rte_eth_vmdq_tx_conf(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 12) { - throw Exception("Size of rte_eth_conf__cjbind_ty_2 is not 12 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of rte_eth_conf__cjbind_ty_2 is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 12) { + throw Exception("Size of rte_eth_conf__cjbind_ty_2 is not 12 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of rte_eth_conf__cjbind_ty_2 is not 4 but ${align} bytes") + } } // A structure used to configure an Ethernet port. @@ -1023,61 +1004,64 @@ let _ = { // configuration settings may be needed. @C public struct rte_eth_conf_rte_eth_conf { -//< bitmap of ETH_LINK_SPEED_XXX of speeds to be -//used. ETH_LINK_SPEED_FIXED disables link -//autonegotiation, and a unique speed shall be -//set. Otherwise, the bitmap defines the set of -//speeds to be advertised. If the special value -//ETH_LINK_SPEED_AUTONEG (0) is used, all speeds -//supported are advertised. * -public let link_speeds : UInt32 -//< Port RX configuration. * -public let rxmode : rte_eth_rxmode_rte_eth_rxmode -//< Port TX configuration. * -public let txmode : rte_eth_txmode_rte_eth_txmode -//< Loopback operation mode. By default the value -//is 0, meaning the loopback mode is disabled. -//Read the datasheet of given ethernet controller -//for details. The possible values of this field -//are defined in implementation of each driver. * -public let lpbk_mode : UInt32 -//< Port RX filtering configuration (union). * -public let rx_adv_conf : rte_eth_conf__cjbind_ty_1 -public let __cjbind_anon_1 : rte_eth_conf__cjbind_ty_1 -//< Port TX DCB configuration (union). * -public let tx_adv_conf : rte_eth_conf__cjbind_ty_2 -public let __cjbind_anon_2 : rte_eth_conf__cjbind_ty_2 -// Currently,Priority Flow Control(PFC) are supported,if DCB with PFC -//is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. * -public let dcb_capability_en : UInt32 -//< FDIR configuration. * -public let fdir_conf : rte_fdir_conf_rte_fdir_conf -//< Interrupt mode configuration. * -public let intr_conf : rte_intr_conf_rte_intr_conf -public init(link_speeds : UInt32 , rxmode : rte_eth_rxmode_rte_eth_rxmode , txmode : rte_eth_txmode_rte_eth_txmode , lpbk_mode : UInt32 , rx_adv_conf : rte_eth_conf__cjbind_ty_1 , __cjbind_anon_1 : rte_eth_conf__cjbind_ty_1 , tx_adv_conf : rte_eth_conf__cjbind_ty_2 , __cjbind_anon_2 : rte_eth_conf__cjbind_ty_2 , dcb_capability_en : UInt32 , fdir_conf : rte_fdir_conf_rte_fdir_conf , intr_conf : rte_intr_conf_rte_intr_conf) { - this.link_speeds = link_speeds -this.rxmode = rxmode -this.txmode = txmode -this.lpbk_mode = lpbk_mode -this.rx_adv_conf = rx_adv_conf -this.__cjbind_anon_1 = __cjbind_anon_1 -this.tx_adv_conf = tx_adv_conf -this.__cjbind_anon_2 = __cjbind_anon_2 -this.dcb_capability_en = dcb_capability_en -this.fdir_conf = fdir_conf -this.intr_conf = intr_conf -} + //< bitmap of ETH_LINK_SPEED_XXX of speeds to be + //used. ETH_LINK_SPEED_FIXED disables link + //autonegotiation, and a unique speed shall be + //set. Otherwise, the bitmap defines the set of + //speeds to be advertised. If the special value + //ETH_LINK_SPEED_AUTONEG (0) is used, all speeds + //supported are advertised. * + public let link_speeds: UInt32 + //< Port RX configuration. * + public let rxmode: rte_eth_rxmode_rte_eth_rxmode + //< Port TX configuration. * + public let txmode: rte_eth_txmode_rte_eth_txmode + //< Loopback operation mode. By default the value + //is 0, meaning the loopback mode is disabled. + //Read the datasheet of given ethernet controller + //for details. The possible values of this field + //are defined in implementation of each driver. * + public let lpbk_mode: UInt32 + //< Port RX filtering configuration (union). * + public let rx_adv_conf: rte_eth_conf__cjbind_ty_1 + public let __cjbind_anon_1: rte_eth_conf__cjbind_ty_1 + //< Port TX DCB configuration (union). * + public let tx_adv_conf: rte_eth_conf__cjbind_ty_2 + public let __cjbind_anon_2: rte_eth_conf__cjbind_ty_2 + // Currently,Priority Flow Control(PFC) are supported,if DCB with PFC + //is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. * + public let dcb_capability_en: UInt32 + //< FDIR configuration. * + public let fdir_conf: rte_fdir_conf_rte_fdir_conf + //< Interrupt mode configuration. * + public let intr_conf: rte_intr_conf_rte_intr_conf + public init(link_speeds: UInt32, rxmode: rte_eth_rxmode_rte_eth_rxmode, txmode: rte_eth_txmode_rte_eth_txmode, + lpbk_mode: UInt32, rx_adv_conf: rte_eth_conf__cjbind_ty_1, __cjbind_anon_1: rte_eth_conf__cjbind_ty_1, + tx_adv_conf: rte_eth_conf__cjbind_ty_2, __cjbind_anon_2: rte_eth_conf__cjbind_ty_2, dcb_capability_en: UInt32, + fdir_conf: rte_fdir_conf_rte_fdir_conf, intr_conf: rte_intr_conf_rte_intr_conf) { + this.link_speeds = link_speeds + this.rxmode = rxmode + this.txmode = txmode + this.lpbk_mode = lpbk_mode + this.rx_adv_conf = rx_adv_conf + this.__cjbind_anon_1 = __cjbind_anon_1 + this.tx_adv_conf = tx_adv_conf + this.__cjbind_anon_2 = __cjbind_anon_2 + this.dcb_capability_en = dcb_capability_en + this.fdir_conf = fdir_conf + this.intr_conf = intr_conf + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 2944) { - throw Exception("Size of rte_eth_conf_rte_eth_conf is not 2944 but ${size} bytes") - } - let align = alignOf() - if (align != 8) { - throw Exception("Alignment of rte_eth_conf_rte_eth_conf is not 8 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 2944) { + throw Exception("Size of rte_eth_conf_rte_eth_conf is not 2944 but ${size} bytes") + } + let align = alignOf() + if (align != 8) { + throw Exception("Alignment of rte_eth_conf_rte_eth_conf is not 8 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/layout_mbuf.cj b/cjbind_test/testdata/expected/layout_mbuf.cj index a62daa5..18e96f0 100644 --- a/cjbind_test/testdata/expected/layout_mbuf.cj +++ b/cjbind_test/testdata/expected/layout_mbuf.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_read_rte_atomic16_t_rte_atomic16_t(ptr: CPointer): rte_atomic16_t_rte_atomic16_t { return unsafe { CPointer(ptr).read() } @@ -120,8 +122,6 @@ func __cjbind_write_UInt64(ptr: CPointer, val: UInt64): Unit { unsafe { CPointer(ptr).write(val) } } -package cjbind_ffi - public const RTE_CACHE_LINE_MIN_SIZE_RTE_CACHE_LINE_MIN_SIZE : Int64 = 64 public const RTE_CACHE_LINE_SIZE_RTE_CACHE_LINE_SIZE : Int64 = 64 diff --git a/cjbind_test/testdata/expected/packed-struct-anon-union.cj b/cjbind_test/testdata/expected/packed-struct-anon-union.cj index 03d09a7..28e08fd 100644 --- a/cjbind_test/testdata/expected/packed-struct-anon-union.cj +++ b/cjbind_test/testdata/expected/packed-struct-anon-union.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_read_CPointer(ptr: CPointer): CPointer { return unsafe { CPointer>(ptr).read() } @@ -18,8 +20,6 @@ func __cjbind_write_UInt64(ptr: CPointer, val: UInt64): Unit { unsafe { CPointer(ptr).write(val) } } -package cjbind_ffi - @C public struct rte_memseg__cjbind_ty_1 { var _storage: UInt64 = unsafe { zeroValue() } diff --git a/cjbind_test/testdata/expected/struct_with_anon_union.cj b/cjbind_test/testdata/expected/struct_with_anon_union.cj index d53cf5c..4f8de4c 100644 --- a/cjbind_test/testdata/expected/struct_with_anon_union.cj +++ b/cjbind_test/testdata/expected/struct_with_anon_union.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_read_UInt32(ptr: CPointer): UInt32 { return unsafe { CPointer(ptr).read() } @@ -18,60 +20,58 @@ func __cjbind_write_UInt16(ptr: CPointer, val: UInt16): Unit { unsafe { CPointer(ptr).write(val) } } -package cjbind_ffi - @C public struct foo__cjbind_ty_1 { -var _storage: UInt32 = unsafe { zeroValue() } -public init() {} -public func a(): UInt32 { - var s = this._storage - return unsafe { __cjbind_read_UInt32(CPointer(inout s)) } -} -public mut func a(val!: UInt32): Unit { - unsafe { __cjbind_write_UInt32(CPointer(inout this._storage), val) } -} -public func b(): UInt16 { - var s = this._storage - return unsafe { __cjbind_read_UInt16(CPointer(inout s)) } -} -public mut func b(val!: UInt16): Unit { - unsafe { __cjbind_write_UInt16(CPointer(inout this._storage), val) } -} + var _storage: UInt32 = unsafe { zeroValue() } + public init() {} + public func a(): UInt32 { + var s = this._storage + return unsafe { __cjbind_read_UInt32(CPointer(inout s)) } + } + public mut func a(val!: UInt32): Unit { + unsafe { __cjbind_write_UInt32(CPointer(inout this._storage), val) } + } + public func b(): UInt16 { + var s = this._storage + return unsafe { __cjbind_read_UInt16(CPointer(inout s)) } + } + public mut func b(val!: UInt16): Unit { + unsafe { __cjbind_write_UInt16(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of foo__cjbind_ty_1 is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of foo__cjbind_ty_1 is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of foo__cjbind_ty_1 is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of foo__cjbind_ty_1 is not 4 but ${align} bytes") + } } @C public struct foo_foo { -public let bar : foo__cjbind_ty_1 -public let __cjbind_anon_1 : foo__cjbind_ty_1 -public init(bar : foo__cjbind_ty_1 , __cjbind_anon_1 : foo__cjbind_ty_1) { - this.bar = bar -this.__cjbind_anon_1 = __cjbind_anon_1 -} + public let bar: foo__cjbind_ty_1 + public let __cjbind_anon_1: foo__cjbind_ty_1 + public init(bar: foo__cjbind_ty_1, __cjbind_anon_1: foo__cjbind_ty_1) { + this.bar = bar + this.__cjbind_anon_1 = __cjbind_anon_1 + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of foo_foo is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of foo_foo is not 4 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of foo_foo is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of foo_foo is not 4 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/struct_with_anon_unnamed_union.cj b/cjbind_test/testdata/expected/struct_with_anon_unnamed_union.cj index e3af259..cb8e791 100644 --- a/cjbind_test/testdata/expected/struct_with_anon_unnamed_union.cj +++ b/cjbind_test/testdata/expected/struct_with_anon_unnamed_union.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_read_UInt32(ptr: CPointer): UInt32 { return unsafe { CPointer(ptr).read() } @@ -18,58 +20,56 @@ func __cjbind_write_UInt16(ptr: CPointer, val: UInt16): Unit { unsafe { CPointer(ptr).write(val) } } -package cjbind_ffi - @C public struct foo__cjbind_ty_1 { -var _storage: UInt32 = unsafe { zeroValue() } -public init() {} -public func a(): UInt32 { - var s = this._storage - return unsafe { __cjbind_read_UInt32(CPointer(inout s)) } -} -public mut func a(val!: UInt32): Unit { - unsafe { __cjbind_write_UInt32(CPointer(inout this._storage), val) } -} -public func b(): UInt16 { - var s = this._storage - return unsafe { __cjbind_read_UInt16(CPointer(inout s)) } -} -public mut func b(val!: UInt16): Unit { - unsafe { __cjbind_write_UInt16(CPointer(inout this._storage), val) } -} + var _storage: UInt32 = unsafe { zeroValue() } + public init() {} + public func a(): UInt32 { + var s = this._storage + return unsafe { __cjbind_read_UInt32(CPointer(inout s)) } + } + public mut func a(val!: UInt32): Unit { + unsafe { __cjbind_write_UInt32(CPointer(inout this._storage), val) } + } + public func b(): UInt16 { + var s = this._storage + return unsafe { __cjbind_read_UInt16(CPointer(inout s)) } + } + public mut func b(val!: UInt16): Unit { + unsafe { __cjbind_write_UInt16(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of foo__cjbind_ty_1 is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of foo__cjbind_ty_1 is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of foo__cjbind_ty_1 is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of foo__cjbind_ty_1 is not 4 but ${align} bytes") + } } @C public struct foo_foo { -public let __cjbind_anon_1 : foo__cjbind_ty_1 -public init(__cjbind_anon_1 : foo__cjbind_ty_1) { - this.__cjbind_anon_1 = __cjbind_anon_1 -} + public let __cjbind_anon_1: foo__cjbind_ty_1 + public init(__cjbind_anon_1: foo__cjbind_ty_1) { + this.__cjbind_anon_1 = __cjbind_anon_1 + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of foo_foo is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of foo_foo is not 4 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of foo_foo is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of foo_foo is not 4 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/struct_with_bitfields.cj b/cjbind_test/testdata/expected/struct_with_bitfields.cj index c389746..b087b3a 100644 --- a/cjbind_test/testdata/expected/struct_with_bitfields.cj +++ b/cjbind_test/testdata/expected/struct_with_bitfields.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_bitfield_read(ptr: CPointer, bitOffset: Int64, bitWidth: Int64): UInt64 { let startByte = bitOffset / 8 @@ -50,93 +52,92 @@ func __cjbind_bitfield_read_signed(ptr: CPointer, bitOffset: Int64, bitWi return Int64(raw) } -package cjbind_ffi - @C public struct bitfield_bitfield { -let _cjbind_opaque_blob: VArray -public init() { - this._cjbind_opaque_blob = unsafe { zeroValue>() } -} + let _cjbind_opaque_blob: VArray + public init() { + this._cjbind_opaque_blob = unsafe { zeroValue>() } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 16) { - throw Exception("Size of bitfield_bitfield is not 16 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of bitfield_bitfield is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 16) { + throw Exception("Size of bitfield_bitfield is not 16 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of bitfield_bitfield is not 4 but ${align} bytes") + } } @C public struct MixedPtrBoolBitfield_MixedPtrBoolBitfield { -public var p : CPointer = unsafe { zeroValue>() } -public var b : Bool = unsafe { zeroValue() } -var _bitfield_1 : VArray = VArray(repeat: 0) -public func u(): UInt32 { - var s = this._bitfield_1 - return UInt32(unsafe { __cjbind_bitfield_read(inout s, 0, 16) }) -} -public mut func u(val!: UInt32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 16, UInt64(val)) } -} -public init() {} + public var p: CPointer = unsafe { zeroValue>() } + public var b: Bool = unsafe { zeroValue() } + var _bitfield_1: VArray = VArray(repeat: 0) + public func u(): UInt32 { + var s = this._bitfield_1 + return UInt32(unsafe { __cjbind_bitfield_read(inout s, 0, 16) }) + } + public mut func u(val!: UInt32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 16, UInt64(val)) } + } + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 16) { - throw Exception("Size of MixedPtrBoolBitfield_MixedPtrBoolBitfield is not 16 but ${size} bytes") - } - let align = alignOf() - if (align != 8) { - throw Exception("Alignment of MixedPtrBoolBitfield_MixedPtrBoolBitfield is not 8 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 16) { + throw Exception("Size of MixedPtrBoolBitfield_MixedPtrBoolBitfield is not 16 but ${size} bytes") + } + let align = alignOf() + if (align != 8) { + throw Exception("Alignment of MixedPtrBoolBitfield_MixedPtrBoolBitfield is not 8 but ${align} bytes") + } } @C public struct OnlyUnnamedBitfield_OnlyUnnamedBitfield { -var _bitfield_1 : VArray = VArray(repeat: 0) -public init() {} + var _bitfield_1: VArray = VArray(repeat: 0) + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 2) { - throw Exception("Size of OnlyUnnamedBitfield_OnlyUnnamedBitfield is not 2 but ${size} bytes") - } - let align = alignOf() - if (align != 1) { - throw Exception("Alignment of OnlyUnnamedBitfield_OnlyUnnamedBitfield is not 1 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 2) { + throw Exception("Size of OnlyUnnamedBitfield_OnlyUnnamedBitfield is not 2 but ${size} bytes") + } + let align = alignOf() + if (align != 1) { + throw Exception("Alignment of OnlyUnnamedBitfield_OnlyUnnamedBitfield is not 1 but ${align} bytes") + } } @C public struct MixedSignedUnnamedBitfield_MixedSignedUnnamedBitfield { -var _bitfield_1 : VArray = VArray(repeat: 0) -public init() {} + var _bitfield_1: VArray = VArray(repeat: 0) + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 3) { - throw Exception("Size of MixedSignedUnnamedBitfield_MixedSignedUnnamedBitfield is not 3 but ${size} bytes") - } - let align = alignOf() - if (align != 1) { - throw Exception("Alignment of MixedSignedUnnamedBitfield_MixedSignedUnnamedBitfield is not 1 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 3) { + throw Exception("Size of MixedSignedUnnamedBitfield_MixedSignedUnnamedBitfield is not 3 but ${size} bytes") + } + let align = alignOf() + if (align != 1) { + throw Exception( + "Alignment of MixedSignedUnnamedBitfield_MixedSignedUnnamedBitfield is not 1 but ${align} bytes") + } } public type U8_U8 = UInt8 @@ -145,93 +146,93 @@ public type U16_U16 = UInt16 @C public struct V56AMDY_V56AMDY { -var _bitfield_1 : VArray = VArray(repeat: 0) -public func MADZ(): U16_U16 { - var s = this._bitfield_1 - return U16_U16(unsafe { __cjbind_bitfield_read(inout s, 0, 10) }) -} -public mut func MADZ(val!: U16_U16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 10, UInt64(val)) } -} -public func MAI0(): U16_U16 { - var s = this._bitfield_1 - return U16_U16(unsafe { __cjbind_bitfield_read(inout s, 10, 2) }) -} -public mut func MAI0(val!: U16_U16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 10, 2, UInt64(val)) } -} -public func MAI1(): U16_U16 { - var s = this._bitfield_1 - return U16_U16(unsafe { __cjbind_bitfield_read(inout s, 12, 2) }) -} -public mut func MAI1(val!: U16_U16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 12, 2, UInt64(val)) } -} -public func MAI2(): U16_U16 { - var s = this._bitfield_1 - return U16_U16(unsafe { __cjbind_bitfield_read(inout s, 14, 2) }) -} -public mut func MAI2(val!: U16_U16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 14, 2, UInt64(val)) } -} -public var MADK : U8_U8 = unsafe { zeroValue() } -public var MABR : U8_U8 = unsafe { zeroValue() } -var _bitfield_2 : VArray = VArray(repeat: 0) -public func MATH(): U16_U16 { - var s = this._bitfield_2 - return U16_U16(unsafe { __cjbind_bitfield_read(inout s, 0, 10) }) -} -public mut func MATH(val!: U16_U16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_2, 0, 10, UInt64(val)) } -} -public func MATE(): U16_U16 { - var s = this._bitfield_2 - return U16_U16(unsafe { __cjbind_bitfield_read(inout s, 10, 4) }) -} -public mut func MATE(val!: U16_U16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_2, 10, 4, UInt64(val)) } -} -public func MATW(): U16_U16 { - var s = this._bitfield_2 - return U16_U16(unsafe { __cjbind_bitfield_read(inout s, 14, 2) }) -} -public mut func MATW(val!: U16_U16): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_2, 14, 2, UInt64(val)) } -} -public func MASW(): U8_U8 { - var s = this._bitfield_2 - return U8_U8(unsafe { __cjbind_bitfield_read(inout s, 16, 4) }) -} -public mut func MASW(val!: U8_U8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_2, 16, 4, UInt64(val)) } -} -public func MABW(): U8_U8 { - var s = this._bitfield_2 - return U8_U8(unsafe { __cjbind_bitfield_read(inout s, 20, 3) }) -} -public mut func MABW(val!: U8_U8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_2, 20, 3, UInt64(val)) } -} -public func MAXN(): U8_U8 { - var s = this._bitfield_2 - return U8_U8(unsafe { __cjbind_bitfield_read(inout s, 23, 1) }) -} -public mut func MAXN(val!: U8_U8): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_2, 23, 1, UInt64(val)) } -} -public var _rB_ : U8_U8 = unsafe { zeroValue() } -public init() {} + var _bitfield_1: VArray = VArray(repeat: 0) + public func MADZ(): U16_U16 { + var s = this._bitfield_1 + return U16_U16(unsafe { __cjbind_bitfield_read(inout s, 0, 10) }) + } + public mut func MADZ(val!: U16_U16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 10, UInt64(val)) } + } + public func MAI0(): U16_U16 { + var s = this._bitfield_1 + return U16_U16(unsafe { __cjbind_bitfield_read(inout s, 10, 2) }) + } + public mut func MAI0(val!: U16_U16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 10, 2, UInt64(val)) } + } + public func MAI1(): U16_U16 { + var s = this._bitfield_1 + return U16_U16(unsafe { __cjbind_bitfield_read(inout s, 12, 2) }) + } + public mut func MAI1(val!: U16_U16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 12, 2, UInt64(val)) } + } + public func MAI2(): U16_U16 { + var s = this._bitfield_1 + return U16_U16(unsafe { __cjbind_bitfield_read(inout s, 14, 2) }) + } + public mut func MAI2(val!: U16_U16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 14, 2, UInt64(val)) } + } + public var MADK: U8_U8 = unsafe { zeroValue() } + public var MABR: U8_U8 = unsafe { zeroValue() } + var _bitfield_2: VArray = VArray(repeat: 0) + public func MATH(): U16_U16 { + var s = this._bitfield_2 + return U16_U16(unsafe { __cjbind_bitfield_read(inout s, 0, 10) }) + } + public mut func MATH(val!: U16_U16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_2, 0, 10, UInt64(val)) } + } + public func MATE(): U16_U16 { + var s = this._bitfield_2 + return U16_U16(unsafe { __cjbind_bitfield_read(inout s, 10, 4) }) + } + public mut func MATE(val!: U16_U16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_2, 10, 4, UInt64(val)) } + } + public func MATW(): U16_U16 { + var s = this._bitfield_2 + return U16_U16(unsafe { __cjbind_bitfield_read(inout s, 14, 2) }) + } + public mut func MATW(val!: U16_U16): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_2, 14, 2, UInt64(val)) } + } + public func MASW(): U8_U8 { + var s = this._bitfield_2 + return U8_U8(unsafe { __cjbind_bitfield_read(inout s, 16, 4) }) + } + public mut func MASW(val!: U8_U8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_2, 16, 4, UInt64(val)) } + } + public func MABW(): U8_U8 { + var s = this._bitfield_2 + return U8_U8(unsafe { __cjbind_bitfield_read(inout s, 20, 3) }) + } + public mut func MABW(val!: U8_U8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_2, 20, 3, UInt64(val)) } + } + public func MAXN(): U8_U8 { + var s = this._bitfield_2 + return U8_U8(unsafe { __cjbind_bitfield_read(inout s, 23, 1) }) + } + public mut func MAXN(val!: U8_U8): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_2, 23, 1, UInt64(val)) } + } + public var _rB_: U8_U8 = unsafe { zeroValue() } + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 8) { - throw Exception("Size of V56AMDY_V56AMDY is not 8 but ${size} bytes") - } - let align = alignOf() - if (align != 2) { - throw Exception("Alignment of V56AMDY_V56AMDY is not 2 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 8) { + throw Exception("Size of V56AMDY_V56AMDY is not 8 but ${size} bytes") + } + let align = alignOf() + if (align != 2) { + throw Exception("Alignment of V56AMDY_V56AMDY is not 2 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/struct_with_nesting.cj b/cjbind_test/testdata/expected/struct_with_nesting.cj index 0724949..a48104f 100644 --- a/cjbind_test/testdata/expected/struct_with_nesting.cj +++ b/cjbind_test/testdata/expected/struct_with_nesting.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_read_UInt32(ptr: CPointer): UInt32 { return unsafe { CPointer(ptr).read() } @@ -28,117 +30,115 @@ func __cjbind_write_foo__cjbind_ty_2(ptr: CPointer, val: foo__cjbind_ty_2 unsafe { CPointer(ptr).write(val) } } -package cjbind_ffi - @C public struct foo__cjbind_ty_1 { -public let c1 : UInt16 -public let c2 : UInt16 -public init(c1 : UInt16 , c2 : UInt16) { - this.c1 = c1 -this.c2 = c2 -} + public let c1: UInt16 + public let c2: UInt16 + public init(c1: UInt16, c2: UInt16) { + this.c1 = c1 + this.c2 = c2 + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of foo__cjbind_ty_1 is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 2) { - throw Exception("Alignment of foo__cjbind_ty_1 is not 2 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of foo__cjbind_ty_1 is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 2) { + throw Exception("Alignment of foo__cjbind_ty_1 is not 2 but ${align} bytes") + } } @C public struct foo__cjbind_ty_2 { -public let d1 : UInt8 -public let d2 : UInt8 -public let d3 : UInt8 -public let d4 : UInt8 -public init(d1 : UInt8 , d2 : UInt8 , d3 : UInt8 , d4 : UInt8) { - this.d1 = d1 -this.d2 = d2 -this.d3 = d3 -this.d4 = d4 -} + public let d1: UInt8 + public let d2: UInt8 + public let d3: UInt8 + public let d4: UInt8 + public init(d1: UInt8, d2: UInt8, d3: UInt8, d4: UInt8) { + this.d1 = d1 + this.d2 = d2 + this.d3 = d3 + this.d4 = d4 + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of foo__cjbind_ty_2 is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 1) { - throw Exception("Alignment of foo__cjbind_ty_2 is not 1 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of foo__cjbind_ty_2 is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 1) { + throw Exception("Alignment of foo__cjbind_ty_2 is not 1 but ${align} bytes") + } } @C public struct foo__cjbind_ty_1 { -var _storage: UInt32 = unsafe { zeroValue() } -public init() {} -public func b(): UInt32 { - var s = this._storage - return unsafe { __cjbind_read_UInt32(CPointer(inout s)) } -} -public mut func b(val!: UInt32): Unit { - unsafe { __cjbind_write_UInt32(CPointer(inout this._storage), val) } -} -public func __cjbind_anon_1(): foo__cjbind_ty_1 { - var s = this._storage - return unsafe { __cjbind_read_foo__cjbind_ty_1(CPointer(inout s)) } -} -public mut func __cjbind_anon_1(val!: foo__cjbind_ty_1): Unit { - unsafe { __cjbind_write_foo__cjbind_ty_1(CPointer(inout this._storage), val) } -} -public func __cjbind_anon_2(): foo__cjbind_ty_2 { - var s = this._storage - return unsafe { __cjbind_read_foo__cjbind_ty_2(CPointer(inout s)) } -} -public mut func __cjbind_anon_2(val!: foo__cjbind_ty_2): Unit { - unsafe { __cjbind_write_foo__cjbind_ty_2(CPointer(inout this._storage), val) } -} + var _storage: UInt32 = unsafe { zeroValue() } + public init() {} + public func b(): UInt32 { + var s = this._storage + return unsafe { __cjbind_read_UInt32(CPointer(inout s)) } + } + public mut func b(val!: UInt32): Unit { + unsafe { __cjbind_write_UInt32(CPointer(inout this._storage), val) } + } + public func __cjbind_anon_1(): foo__cjbind_ty_1 { + var s = this._storage + return unsafe { __cjbind_read_foo__cjbind_ty_1(CPointer(inout s)) } + } + public mut func __cjbind_anon_1(val!: foo__cjbind_ty_1): Unit { + unsafe { __cjbind_write_foo__cjbind_ty_1(CPointer(inout this._storage), val) } + } + public func __cjbind_anon_2(): foo__cjbind_ty_2 { + var s = this._storage + return unsafe { __cjbind_read_foo__cjbind_ty_2(CPointer(inout s)) } + } + public mut func __cjbind_anon_2(val!: foo__cjbind_ty_2): Unit { + unsafe { __cjbind_write_foo__cjbind_ty_2(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of foo__cjbind_ty_1 is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of foo__cjbind_ty_1 is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of foo__cjbind_ty_1 is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of foo__cjbind_ty_1 is not 4 but ${align} bytes") + } } @C public struct foo_foo { -public let a : UInt32 -public let __cjbind_anon_1 : foo__cjbind_ty_1 -public init(a : UInt32 , __cjbind_anon_1 : foo__cjbind_ty_1) { - this.a = a -this.__cjbind_anon_1 = __cjbind_anon_1 -} + public let a: UInt32 + public let __cjbind_anon_1: foo__cjbind_ty_1 + public init(a: UInt32, __cjbind_anon_1: foo__cjbind_ty_1) { + this.a = a + this.__cjbind_anon_1 = __cjbind_anon_1 + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 8) { - throw Exception("Size of foo_foo is not 8 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of foo_foo is not 4 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 8) { + throw Exception("Size of foo_foo is not 8 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of foo_foo is not 4 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/typedef-pointer-overlap.cj b/cjbind_test/testdata/expected/typedef-pointer-overlap.cj index 47f64c2..1ad139b 100644 --- a/cjbind_test/testdata/expected/typedef-pointer-overlap.cj +++ b/cjbind_test/testdata/expected/typedef-pointer-overlap.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_read_Int32(ptr: CPointer): Int32 { return unsafe { CPointer(ptr).read() } @@ -8,114 +10,111 @@ func __cjbind_write_Int32(ptr: CPointer, val: Int32): Unit { unsafe { CPointer(ptr).write(val) } } -package cjbind_ffi - @C public struct foo_foo { -public let inner : UInt8 -public init(inner : UInt8) { - this.inner = inner -} + public let inner: UInt8 + public init(inner: UInt8) { + this.inner = inner + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 1) { - throw Exception("Size of foo_foo is not 1 but ${size} bytes") - } - let align = alignOf() - if (align != 1) { - throw Exception("Alignment of foo_foo is not 1 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 1) { + throw Exception("Size of foo_foo is not 1 but ${size} bytes") + } + let align = alignOf() + if (align != 1) { + throw Exception("Alignment of foo_foo is not 1 but ${align} bytes") + } } public type foo_ptr_foo_ptr = CPointer @C public struct bar_bar { -public let inner : UInt8 -public init(inner : UInt8) { - this.inner = inner -} + public let inner: UInt8 + public init(inner: UInt8) { + this.inner = inner + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 1) { - throw Exception("Size of bar_bar is not 1 but ${size} bytes") - } - let align = alignOf() - if (align != 1) { - throw Exception("Alignment of bar_bar is not 1 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 1) { + throw Exception("Size of bar_bar is not 1 but ${size} bytes") + } + let align = alignOf() + if (align != 1) { + throw Exception("Alignment of bar_bar is not 1 but ${align} bytes") + } } public type bar_ptr_bar_ptr = CPointer @C public struct baz_baz { - -init() { - throw Exception("type should not be inited") -} + init() { + throw Exception("type should not be inited") + } } public type baz_ptr_baz_ptr = CPointer @C public struct cat_cat { -var _storage: UInt32 = unsafe { zeroValue() } -public init() {} -public func standard_issue(): Int32 { - var s = this._storage - return unsafe { __cjbind_read_Int32(CPointer(inout s)) } -} -public mut func standard_issue(val!: Int32): Unit { - unsafe { __cjbind_write_Int32(CPointer(inout this._storage), val) } -} + var _storage: UInt32 = unsafe { zeroValue() } + public init() {} + public func standard_issue(): Int32 { + var s = this._storage + return unsafe { __cjbind_read_Int32(CPointer(inout s)) } + } + public mut func standard_issue(val!: Int32): Unit { + unsafe { __cjbind_write_Int32(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of cat_cat is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of cat_cat is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of cat_cat is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of cat_cat is not 4 but ${align} bytes") + } } public type cat_ptr_cat_ptr = CPointer -public const mad_scientist : mad_mad = 0 +public const mad_scientist: mad_mad = 0 public type mad_mad = UInt32 public type mad_ptr_mad_ptr = CPointer -foreign func takes_foo_ptr ( arg1: foo_ptr_foo_ptr ) : Unit +foreign func takes_foo_ptr(arg1: foo_ptr_foo_ptr): Unit -foreign func takes_foo_struct ( arg1: foo_foo ) : Unit +foreign func takes_foo_struct(arg1: foo_foo): Unit -foreign func takes_bar_ptr ( arg1: bar_ptr_bar_ptr ) : Unit +foreign func takes_bar_ptr(arg1: bar_ptr_bar_ptr): Unit -foreign func takes_bar_struct ( arg1: bar_bar ) : Unit +foreign func takes_bar_struct(arg1: bar_bar): Unit -foreign func takes_baz_ptr ( arg1: baz_ptr_baz_ptr ) : Unit +foreign func takes_baz_ptr(arg1: baz_ptr_baz_ptr): Unit -foreign func takes_baz_struct ( arg1: baz_baz ) : Unit +foreign func takes_baz_struct(arg1: baz_baz): Unit -foreign func takes_cat_ptr ( arg1: cat_ptr_cat_ptr ) : Unit +foreign func takes_cat_ptr(arg1: cat_ptr_cat_ptr): Unit -foreign func takes_cat_union ( arg1: cat_cat ) : Unit +foreign func takes_cat_union(arg1: cat_cat): Unit -foreign func takes_mad_ptr ( arg1: mad_ptr_mad_ptr ) : Unit +foreign func takes_mad_ptr(arg1: mad_ptr_mad_ptr): Unit -foreign func takes_mad_enum ( arg1: mad_mad ) : Unit \ No newline at end of file +foreign func takes_mad_enum(arg1: mad_mad): Unit diff --git a/cjbind_test/testdata/expected/union-align.cj b/cjbind_test/testdata/expected/union-align.cj index 263272f..8e02ba8 100644 --- a/cjbind_test/testdata/expected/union-align.cj +++ b/cjbind_test/testdata/expected/union-align.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_read_UInt8(ptr: CPointer): UInt8 { return unsafe { CPointer(ptr).read() } @@ -18,56 +20,54 @@ func __cjbind_write_Bar_Bar(ptr: CPointer, val: Bar_Bar): Unit { unsafe { CPointer(ptr).write(val) } } -package cjbind_ffi - @C public struct Bar_Bar { -var _storage: VArray = unsafe { zeroValue>() } -public init() {} -public func foo(): UInt8 { - var s = this._storage - return unsafe { __cjbind_read_UInt8(CPointer(inout s)) } -} -public mut func foo(val!: UInt8): Unit { - unsafe { __cjbind_write_UInt8(CPointer(inout this._storage), val) } -} + var _storage: VArray = unsafe { zeroValue>() } + public init() {} + public func foo(): UInt8 { + var s = this._storage + return unsafe { __cjbind_read_UInt8(CPointer(inout s)) } + } + public mut func foo(val!: UInt8): Unit { + unsafe { __cjbind_write_UInt8(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 16) { - throw Exception("Size of Bar_Bar is not 16 but ${size} bytes") - } - let align = alignOf() - if (align != 16) { - throw Exception("Alignment of Bar_Bar is not 16 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 16) { + throw Exception("Size of Bar_Bar is not 16 but ${size} bytes") + } + let align = alignOf() + if (align != 16) { + throw Exception("Alignment of Bar_Bar is not 16 but ${align} bytes") + } } @C public struct Baz_Baz { -var _storage: VArray = unsafe { zeroValue>() } -public init() {} -public func bar(): Bar_Bar { - var s = this._storage - return unsafe { __cjbind_read_Bar_Bar(CPointer(inout s)) } -} -public mut func bar(val!: Bar_Bar): Unit { - unsafe { __cjbind_write_Bar_Bar(CPointer(inout this._storage), val) } -} + var _storage: VArray = unsafe { zeroValue>() } + public init() {} + public func bar(): Bar_Bar { + var s = this._storage + return unsafe { __cjbind_read_Bar_Bar(CPointer(inout s)) } + } + public mut func bar(val!: Bar_Bar): Unit { + unsafe { __cjbind_write_Bar_Bar(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 16) { - throw Exception("Size of Baz_Baz is not 16 but ${size} bytes") - } - let align = alignOf() - if (align != 16) { - throw Exception("Alignment of Baz_Baz is not 16 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 16) { + throw Exception("Size of Baz_Baz is not 16 but ${size} bytes") + } + let align = alignOf() + if (align != 16) { + throw Exception("Alignment of Baz_Baz is not 16 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/union_with_anon_struct.cj b/cjbind_test/testdata/expected/union_with_anon_struct.cj index 2e14bc4..1af616a 100644 --- a/cjbind_test/testdata/expected/union_with_anon_struct.cj +++ b/cjbind_test/testdata/expected/union_with_anon_struct.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_read_foo__cjbind_ty_1(ptr: CPointer): foo__cjbind_ty_1 { return unsafe { CPointer(ptr).read() } @@ -8,60 +10,58 @@ func __cjbind_write_foo__cjbind_ty_1(ptr: CPointer, val: foo__cjbind_ty_1 unsafe { CPointer(ptr).write(val) } } -package cjbind_ffi - @C public struct foo__cjbind_ty_1 { -public let a : UInt32 -public let b : UInt32 -public init(a : UInt32 , b : UInt32) { - this.a = a -this.b = b -} + public let a: UInt32 + public let b: UInt32 + public init(a: UInt32, b: UInt32) { + this.a = a + this.b = b + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 8) { - throw Exception("Size of foo__cjbind_ty_1 is not 8 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of foo__cjbind_ty_1 is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 8) { + throw Exception("Size of foo__cjbind_ty_1 is not 8 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of foo__cjbind_ty_1 is not 4 but ${align} bytes") + } } @C public struct foo_foo { -var _storage: VArray = unsafe { zeroValue>() } -public init() {} -public func bar(): foo__cjbind_ty_1 { - var s = this._storage - return unsafe { __cjbind_read_foo__cjbind_ty_1(CPointer(inout s)) } -} -public mut func bar(val!: foo__cjbind_ty_1): Unit { - unsafe { __cjbind_write_foo__cjbind_ty_1(CPointer(inout this._storage), val) } -} -public func __cjbind_anon_1(): foo__cjbind_ty_1 { - var s = this._storage - return unsafe { __cjbind_read_foo__cjbind_ty_1(CPointer(inout s)) } -} -public mut func __cjbind_anon_1(val!: foo__cjbind_ty_1): Unit { - unsafe { __cjbind_write_foo__cjbind_ty_1(CPointer(inout this._storage), val) } -} + var _storage: VArray = unsafe { zeroValue>() } + public init() {} + public func bar(): foo__cjbind_ty_1 { + var s = this._storage + return unsafe { __cjbind_read_foo__cjbind_ty_1(CPointer(inout s)) } + } + public mut func bar(val!: foo__cjbind_ty_1): Unit { + unsafe { __cjbind_write_foo__cjbind_ty_1(CPointer(inout this._storage), val) } + } + public func __cjbind_anon_1(): foo__cjbind_ty_1 { + var s = this._storage + return unsafe { __cjbind_read_foo__cjbind_ty_1(CPointer(inout s)) } + } + public mut func __cjbind_anon_1(val!: foo__cjbind_ty_1): Unit { + unsafe { __cjbind_write_foo__cjbind_ty_1(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 8) { - throw Exception("Size of foo_foo is not 8 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of foo_foo is not 4 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 8) { + throw Exception("Size of foo_foo is not 8 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of foo_foo is not 4 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/union_with_anon_struct_bitfield.cj b/cjbind_test/testdata/expected/union_with_anon_struct_bitfield.cj index e173caf..fb1eae1 100644 --- a/cjbind_test/testdata/expected/union_with_anon_struct_bitfield.cj +++ b/cjbind_test/testdata/expected/union_with_anon_struct_bitfield.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_bitfield_read(ptr: CPointer, bitOffset: Int64, bitWidth: Int64): UInt64 { let startByte = bitOffset / 8 @@ -70,70 +72,68 @@ func __cjbind_write_foo__cjbind_ty_1(ptr: CPointer, val: foo__cjbind_ty_1 unsafe { CPointer(ptr).write(val) } } -package cjbind_ffi - @C public struct foo__cjbind_ty_1 { -var _bitfield_1 : VArray = VArray(repeat: 0) -public func b(): Int32 { - var s = this._bitfield_1 - return Int32(unsafe { __cjbind_bitfield_read_signed(inout s, 0, 7) }) -} -public mut func b(val!: Int32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 7, UInt64(val)) } -} -public func c(): Int32 { - var s = this._bitfield_1 - return Int32(unsafe { __cjbind_bitfield_read_signed(inout s, 7, 25) }) -} -public mut func c(val!: Int32): Unit { - unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 7, 25, UInt64(val)) } -} -public init() {} + var _bitfield_1: VArray = VArray(repeat: 0) + public func b(): Int32 { + var s = this._bitfield_1 + return Int32(unsafe { __cjbind_bitfield_read_signed(inout s, 0, 7) }) + } + public mut func b(val!: Int32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 0, 7, UInt64(val)) } + } + public func c(): Int32 { + var s = this._bitfield_1 + return Int32(unsafe { __cjbind_bitfield_read_signed(inout s, 7, 25) }) + } + public mut func c(val!: Int32): Unit { + unsafe { __cjbind_bitfield_write(inout this._bitfield_1, 7, 25, UInt64(val)) } + } + public init() {} } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of foo__cjbind_ty_1 is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of foo__cjbind_ty_1 is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of foo__cjbind_ty_1 is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of foo__cjbind_ty_1 is not 4 but ${align} bytes") + } } @C public struct foo_foo { -var _storage: UInt32 = unsafe { zeroValue() } -public init() {} -public func a(): Int32 { - var s = this._storage - return unsafe { __cjbind_read_Int32(CPointer(inout s)) } -} -public mut func a(val!: Int32): Unit { - unsafe { __cjbind_write_Int32(CPointer(inout this._storage), val) } -} -public func __cjbind_anon_1(): foo__cjbind_ty_1 { - var s = this._storage - return unsafe { __cjbind_read_foo__cjbind_ty_1(CPointer(inout s)) } -} -public mut func __cjbind_anon_1(val!: foo__cjbind_ty_1): Unit { - unsafe { __cjbind_write_foo__cjbind_ty_1(CPointer(inout this._storage), val) } -} + var _storage: UInt32 = unsafe { zeroValue() } + public init() {} + public func a(): Int32 { + var s = this._storage + return unsafe { __cjbind_read_Int32(CPointer(inout s)) } + } + public mut func a(val!: Int32): Unit { + unsafe { __cjbind_write_Int32(CPointer(inout this._storage), val) } + } + public func __cjbind_anon_1(): foo__cjbind_ty_1 { + var s = this._storage + return unsafe { __cjbind_read_foo__cjbind_ty_1(CPointer(inout s)) } + } + public mut func __cjbind_anon_1(val!: foo__cjbind_ty_1): Unit { + unsafe { __cjbind_write_foo__cjbind_ty_1(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of foo_foo is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of foo_foo is not 4 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of foo_foo is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of foo_foo is not 4 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/union_with_anon_union.cj b/cjbind_test/testdata/expected/union_with_anon_union.cj index a71df06..2122d66 100644 --- a/cjbind_test/testdata/expected/union_with_anon_union.cj +++ b/cjbind_test/testdata/expected/union_with_anon_union.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_read_UInt32(ptr: CPointer): UInt32 { return unsafe { CPointer(ptr).read() } @@ -28,70 +30,68 @@ func __cjbind_write_foo__cjbind_ty_1(ptr: CPointer, val: foo__cjbind_ty_1 unsafe { CPointer(ptr).write(val) } } -package cjbind_ffi - @C public struct foo__cjbind_ty_1 { -var _storage: UInt32 = unsafe { zeroValue() } -public init() {} -public func a(): UInt32 { - var s = this._storage - return unsafe { __cjbind_read_UInt32(CPointer(inout s)) } -} -public mut func a(val!: UInt32): Unit { - unsafe { __cjbind_write_UInt32(CPointer(inout this._storage), val) } -} -public func b(): UInt16 { - var s = this._storage - return unsafe { __cjbind_read_UInt16(CPointer(inout s)) } -} -public mut func b(val!: UInt16): Unit { - unsafe { __cjbind_write_UInt16(CPointer(inout this._storage), val) } -} + var _storage: UInt32 = unsafe { zeroValue() } + public init() {} + public func a(): UInt32 { + var s = this._storage + return unsafe { __cjbind_read_UInt32(CPointer(inout s)) } + } + public mut func a(val!: UInt32): Unit { + unsafe { __cjbind_write_UInt32(CPointer(inout this._storage), val) } + } + public func b(): UInt16 { + var s = this._storage + return unsafe { __cjbind_read_UInt16(CPointer(inout s)) } + } + public mut func b(val!: UInt16): Unit { + unsafe { __cjbind_write_UInt16(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of foo__cjbind_ty_1 is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of foo__cjbind_ty_1 is not 4 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of foo__cjbind_ty_1 is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of foo__cjbind_ty_1 is not 4 but ${align} bytes") + } } @C public struct foo_foo { -var _storage: UInt32 = unsafe { zeroValue() } -public init() {} -public func bar(): foo__cjbind_ty_1 { - var s = this._storage - return unsafe { __cjbind_read_foo__cjbind_ty_1(CPointer(inout s)) } -} -public mut func bar(val!: foo__cjbind_ty_1): Unit { - unsafe { __cjbind_write_foo__cjbind_ty_1(CPointer(inout this._storage), val) } -} -public func __cjbind_anon_1(): foo__cjbind_ty_1 { - var s = this._storage - return unsafe { __cjbind_read_foo__cjbind_ty_1(CPointer(inout s)) } -} -public mut func __cjbind_anon_1(val!: foo__cjbind_ty_1): Unit { - unsafe { __cjbind_write_foo__cjbind_ty_1(CPointer(inout this._storage), val) } -} + var _storage: UInt32 = unsafe { zeroValue() } + public init() {} + public func bar(): foo__cjbind_ty_1 { + var s = this._storage + return unsafe { __cjbind_read_foo__cjbind_ty_1(CPointer(inout s)) } + } + public mut func bar(val!: foo__cjbind_ty_1): Unit { + unsafe { __cjbind_write_foo__cjbind_ty_1(CPointer(inout this._storage), val) } + } + public func __cjbind_anon_1(): foo__cjbind_ty_1 { + var s = this._storage + return unsafe { __cjbind_read_foo__cjbind_ty_1(CPointer(inout s)) } + } + public mut func __cjbind_anon_1(val!: foo__cjbind_ty_1): Unit { + unsafe { __cjbind_write_foo__cjbind_ty_1(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of foo_foo is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of foo_foo is not 4 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of foo_foo is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of foo_foo is not 4 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/union_with_anon_unnamed_struct.cj b/cjbind_test/testdata/expected/union_with_anon_unnamed_struct.cj index dcc09ea..8e508a3 100644 --- a/cjbind_test/testdata/expected/union_with_anon_unnamed_struct.cj +++ b/cjbind_test/testdata/expected/union_with_anon_unnamed_struct.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_read_UInt32(ptr: CPointer): UInt32 { return unsafe { CPointer(ptr).read() } @@ -18,64 +20,62 @@ func __cjbind_write_pixel__cjbind_ty_1(ptr: CPointer, val: pixel__cjbind_ unsafe { CPointer(ptr).write(val) } } -package cjbind_ffi - @C public struct pixel__cjbind_ty_1 { -public let r : UInt8 -public let g : UInt8 -public let b : UInt8 -public let a : UInt8 -public init(r : UInt8 , g : UInt8 , b : UInt8 , a : UInt8) { - this.r = r -this.g = g -this.b = b -this.a = a -} + public let r: UInt8 + public let g: UInt8 + public let b: UInt8 + public let a: UInt8 + public init(r: UInt8, g: UInt8, b: UInt8, a: UInt8) { + this.r = r + this.g = g + this.b = b + this.a = a + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of pixel__cjbind_ty_1 is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 1) { - throw Exception("Alignment of pixel__cjbind_ty_1 is not 1 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of pixel__cjbind_ty_1 is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 1) { + throw Exception("Alignment of pixel__cjbind_ty_1 is not 1 but ${align} bytes") + } } @C public struct pixel_pixel { -var _storage: UInt32 = unsafe { zeroValue() } -public init() {} -public func rgba(): UInt32 { - var s = this._storage - return unsafe { __cjbind_read_UInt32(CPointer(inout s)) } -} -public mut func rgba(val!: UInt32): Unit { - unsafe { __cjbind_write_UInt32(CPointer(inout this._storage), val) } -} -public func __cjbind_anon_1(): pixel__cjbind_ty_1 { - var s = this._storage - return unsafe { __cjbind_read_pixel__cjbind_ty_1(CPointer(inout s)) } -} -public mut func __cjbind_anon_1(val!: pixel__cjbind_ty_1): Unit { - unsafe { __cjbind_write_pixel__cjbind_ty_1(CPointer(inout this._storage), val) } -} + var _storage: UInt32 = unsafe { zeroValue() } + public init() {} + public func rgba(): UInt32 { + var s = this._storage + return unsafe { __cjbind_read_UInt32(CPointer(inout s)) } + } + public mut func rgba(val!: UInt32): Unit { + unsafe { __cjbind_write_UInt32(CPointer(inout this._storage), val) } + } + public func __cjbind_anon_1(): pixel__cjbind_ty_1 { + var s = this._storage + return unsafe { __cjbind_read_pixel__cjbind_ty_1(CPointer(inout s)) } + } + public mut func __cjbind_anon_1(val!: pixel__cjbind_ty_1): Unit { + unsafe { __cjbind_write_pixel__cjbind_ty_1(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of pixel_pixel is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of pixel_pixel is not 4 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of pixel_pixel is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of pixel_pixel is not 4 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/union_with_anon_unnamed_union.cj b/cjbind_test/testdata/expected/union_with_anon_unnamed_union.cj index 50fd0fd..d620055 100644 --- a/cjbind_test/testdata/expected/union_with_anon_unnamed_union.cj +++ b/cjbind_test/testdata/expected/union_with_anon_unnamed_union.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_read_UInt16(ptr: CPointer): UInt16 { return unsafe { CPointer(ptr).read() } @@ -38,70 +40,68 @@ func __cjbind_write_foo__cjbind_ty_1(ptr: CPointer, val: foo__cjbind_ty_1 unsafe { CPointer(ptr).write(val) } } -package cjbind_ffi - @C public struct foo__cjbind_ty_1 { -var _storage: UInt16 = unsafe { zeroValue() } -public init() {} -public func b(): UInt16 { - var s = this._storage - return unsafe { __cjbind_read_UInt16(CPointer(inout s)) } -} -public mut func b(val!: UInt16): Unit { - unsafe { __cjbind_write_UInt16(CPointer(inout this._storage), val) } -} -public func c(): UInt8 { - var s = this._storage - return unsafe { __cjbind_read_UInt8(CPointer(inout s)) } -} -public mut func c(val!: UInt8): Unit { - unsafe { __cjbind_write_UInt8(CPointer(inout this._storage), val) } -} + var _storage: UInt16 = unsafe { zeroValue() } + public init() {} + public func b(): UInt16 { + var s = this._storage + return unsafe { __cjbind_read_UInt16(CPointer(inout s)) } + } + public mut func b(val!: UInt16): Unit { + unsafe { __cjbind_write_UInt16(CPointer(inout this._storage), val) } + } + public func c(): UInt8 { + var s = this._storage + return unsafe { __cjbind_read_UInt8(CPointer(inout s)) } + } + public mut func c(val!: UInt8): Unit { + unsafe { __cjbind_write_UInt8(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 2) { - throw Exception("Size of foo__cjbind_ty_1 is not 2 but ${size} bytes") - } - let align = alignOf() - if (align != 2) { - throw Exception("Alignment of foo__cjbind_ty_1 is not 2 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 2) { + throw Exception("Size of foo__cjbind_ty_1 is not 2 but ${size} bytes") + } + let align = alignOf() + if (align != 2) { + throw Exception("Alignment of foo__cjbind_ty_1 is not 2 but ${align} bytes") + } } @C public struct foo_foo { -var _storage: UInt32 = unsafe { zeroValue() } -public init() {} -public func a(): UInt32 { - var s = this._storage - return unsafe { __cjbind_read_UInt32(CPointer(inout s)) } -} -public mut func a(val!: UInt32): Unit { - unsafe { __cjbind_write_UInt32(CPointer(inout this._storage), val) } -} -public func __cjbind_anon_1(): foo__cjbind_ty_1 { - var s = this._storage - return unsafe { __cjbind_read_foo__cjbind_ty_1(CPointer(inout s)) } -} -public mut func __cjbind_anon_1(val!: foo__cjbind_ty_1): Unit { - unsafe { __cjbind_write_foo__cjbind_ty_1(CPointer(inout this._storage), val) } -} + var _storage: UInt32 = unsafe { zeroValue() } + public init() {} + public func a(): UInt32 { + var s = this._storage + return unsafe { __cjbind_read_UInt32(CPointer(inout s)) } + } + public mut func a(val!: UInt32): Unit { + unsafe { __cjbind_write_UInt32(CPointer(inout this._storage), val) } + } + public func __cjbind_anon_1(): foo__cjbind_ty_1 { + var s = this._storage + return unsafe { __cjbind_read_foo__cjbind_ty_1(CPointer(inout s)) } + } + public mut func __cjbind_anon_1(val!: foo__cjbind_ty_1): Unit { + unsafe { __cjbind_write_foo__cjbind_ty_1(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of foo_foo is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of foo_foo is not 4 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of foo_foo is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of foo_foo is not 4 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/union_with_nesting.cj b/cjbind_test/testdata/expected/union_with_nesting.cj index d9c4cd5..ded6345 100644 --- a/cjbind_test/testdata/expected/union_with_nesting.cj +++ b/cjbind_test/testdata/expected/union_with_nesting.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_read_UInt16(ptr: CPointer): UInt16 { return unsafe { CPointer(ptr).read() } @@ -28,126 +30,124 @@ func __cjbind_write_foo__cjbind_ty_1(ptr: CPointer, val: foo__cjbind_ty_1 unsafe { CPointer(ptr).write(val) } } -package cjbind_ffi - @C public struct foo__cjbind_ty_1 { -var _storage: UInt16 = unsafe { zeroValue() } -public init() {} -public func b1(): UInt16 { - var s = this._storage - return unsafe { __cjbind_read_UInt16(CPointer(inout s)) } -} -public mut func b1(val!: UInt16): Unit { - unsafe { __cjbind_write_UInt16(CPointer(inout this._storage), val) } -} -public func b2(): UInt16 { - var s = this._storage - return unsafe { __cjbind_read_UInt16(CPointer(inout s)) } -} -public mut func b2(val!: UInt16): Unit { - unsafe { __cjbind_write_UInt16(CPointer(inout this._storage), val) } -} + var _storage: UInt16 = unsafe { zeroValue() } + public init() {} + public func b1(): UInt16 { + var s = this._storage + return unsafe { __cjbind_read_UInt16(CPointer(inout s)) } + } + public mut func b1(val!: UInt16): Unit { + unsafe { __cjbind_write_UInt16(CPointer(inout this._storage), val) } + } + public func b2(): UInt16 { + var s = this._storage + return unsafe { __cjbind_read_UInt16(CPointer(inout s)) } + } + public mut func b2(val!: UInt16): Unit { + unsafe { __cjbind_write_UInt16(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 2) { - throw Exception("Size of foo__cjbind_ty_1 is not 2 but ${size} bytes") - } - let align = alignOf() - if (align != 2) { - throw Exception("Alignment of foo__cjbind_ty_1 is not 2 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 2) { + throw Exception("Size of foo__cjbind_ty_1 is not 2 but ${size} bytes") + } + let align = alignOf() + if (align != 2) { + throw Exception("Alignment of foo__cjbind_ty_1 is not 2 but ${align} bytes") + } } @C public struct foo__cjbind_ty_2 { -var _storage: UInt16 = unsafe { zeroValue() } -public init() {} -public func c1(): UInt16 { - var s = this._storage - return unsafe { __cjbind_read_UInt16(CPointer(inout s)) } -} -public mut func c1(val!: UInt16): Unit { - unsafe { __cjbind_write_UInt16(CPointer(inout this._storage), val) } -} -public func c2(): UInt16 { - var s = this._storage - return unsafe { __cjbind_read_UInt16(CPointer(inout s)) } -} -public mut func c2(val!: UInt16): Unit { - unsafe { __cjbind_write_UInt16(CPointer(inout this._storage), val) } -} + var _storage: UInt16 = unsafe { zeroValue() } + public init() {} + public func c1(): UInt16 { + var s = this._storage + return unsafe { __cjbind_read_UInt16(CPointer(inout s)) } + } + public mut func c1(val!: UInt16): Unit { + unsafe { __cjbind_write_UInt16(CPointer(inout this._storage), val) } + } + public func c2(): UInt16 { + var s = this._storage + return unsafe { __cjbind_read_UInt16(CPointer(inout s)) } + } + public mut func c2(val!: UInt16): Unit { + unsafe { __cjbind_write_UInt16(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 2) { - throw Exception("Size of foo__cjbind_ty_2 is not 2 but ${size} bytes") - } - let align = alignOf() - if (align != 2) { - throw Exception("Alignment of foo__cjbind_ty_2 is not 2 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 2) { + throw Exception("Size of foo__cjbind_ty_2 is not 2 but ${size} bytes") + } + let align = alignOf() + if (align != 2) { + throw Exception("Alignment of foo__cjbind_ty_2 is not 2 but ${align} bytes") + } } @C public struct foo__cjbind_ty_1 { -public let __cjbind_anon_1 : foo__cjbind_ty_1 -public let __cjbind_anon_2 : foo__cjbind_ty_2 -public init(__cjbind_anon_1 : foo__cjbind_ty_1 , __cjbind_anon_2 : foo__cjbind_ty_2) { - this.__cjbind_anon_1 = __cjbind_anon_1 -this.__cjbind_anon_2 = __cjbind_anon_2 -} + public let __cjbind_anon_1: foo__cjbind_ty_1 + public let __cjbind_anon_2: foo__cjbind_ty_2 + public init(__cjbind_anon_1: foo__cjbind_ty_1, __cjbind_anon_2: foo__cjbind_ty_2) { + this.__cjbind_anon_1 = __cjbind_anon_1 + this.__cjbind_anon_2 = __cjbind_anon_2 + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of foo__cjbind_ty_1 is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 2) { - throw Exception("Alignment of foo__cjbind_ty_1 is not 2 but ${align} bytes") - } + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of foo__cjbind_ty_1 is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 2) { + throw Exception("Alignment of foo__cjbind_ty_1 is not 2 but ${align} bytes") + } } @C public struct foo_foo { -var _storage: UInt32 = unsafe { zeroValue() } -public init() {} -public func a(): UInt32 { - var s = this._storage - return unsafe { __cjbind_read_UInt32(CPointer(inout s)) } -} -public mut func a(val!: UInt32): Unit { - unsafe { __cjbind_write_UInt32(CPointer(inout this._storage), val) } -} -public func __cjbind_anon_1(): foo__cjbind_ty_1 { - var s = this._storage - return unsafe { __cjbind_read_foo__cjbind_ty_1(CPointer(inout s)) } -} -public mut func __cjbind_anon_1(val!: foo__cjbind_ty_1): Unit { - unsafe { __cjbind_write_foo__cjbind_ty_1(CPointer(inout this._storage), val) } -} + var _storage: UInt32 = unsafe { zeroValue() } + public init() {} + public func a(): UInt32 { + var s = this._storage + return unsafe { __cjbind_read_UInt32(CPointer(inout s)) } + } + public mut func a(val!: UInt32): Unit { + unsafe { __cjbind_write_UInt32(CPointer(inout this._storage), val) } + } + public func __cjbind_anon_1(): foo__cjbind_ty_1 { + var s = this._storage + return unsafe { __cjbind_read_foo__cjbind_ty_1(CPointer(inout s)) } + } + public mut func __cjbind_anon_1(val!: foo__cjbind_ty_1): Unit { + unsafe { __cjbind_write_foo__cjbind_ty_1(CPointer(inout this._storage), val) } + } } @When[debug] let _ = { -=> - let size = sizeOf() - if (size != 4) { - throw Exception("Size of foo_foo is not 4 but ${size} bytes") - } - let align = alignOf() - if (align != 4) { - throw Exception("Alignment of foo_foo is not 4 but ${align} bytes") - } -} \ No newline at end of file + => + let size = sizeOf() + if (size != 4) { + throw Exception("Size of foo_foo is not 4 but ${size} bytes") + } + let align = alignOf() + if (align != 4) { + throw Exception("Alignment of foo_foo is not 4 but ${align} bytes") + } +} diff --git a/cjbind_test/testdata/expected/union_with_zero_sized_array.cj b/cjbind_test/testdata/expected/union_with_zero_sized_array.cj index e301504..24fb2d3 100644 --- a/cjbind_test/testdata/expected/union_with_zero_sized_array.cj +++ b/cjbind_test/testdata/expected/union_with_zero_sized_array.cj @@ -1,3 +1,5 @@ +package cjbind_ffi + @C func __cjbind_read_CPointer(ptr: CPointer): CPointer { return unsafe { CPointer>(ptr).read() } @@ -28,8 +30,6 @@ func __cjbind_write_VArray(ptr: CPointer, val: VArray>(ptr).write(val) } } -package cjbind_ffi - @C public struct U_U { var _storage: VArray = unsafe { zeroValue>() } From 17609dcab9da4a7de12ad524e511121aee82ad5a Mon Sep 17 00:00:00 2001 From: Zxilly Date: Wed, 3 Jun 2026 09:45:32 +0800 Subject: [PATCH 2/2] ci: update Cangjie nightly setup --- .github/workflows/build.yml | 8 ++------ .github/workflows/test.yml | 14 ++++---------- DEVELOPMENT.md | 8 +++++--- cangjie-sdk.toml | 2 ++ 4 files changed, 13 insertions(+), 19 deletions(-) create mode 100644 cangjie-sdk.toml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6cd0103..23db8a5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,14 +78,10 @@ jobs: cache: true - name: Setup Cangjie - uses: Zxilly/setup-cangjie@ff94aa01f985321ddfa5cd0973bb26b4c37e6010 # v2.1.1 + uses: Zxilly/setup-cangjie@91463316b1c359f216c2ac49e35900f9341c1571 # v3.2.0 with: channel: "nightly" - version: "1.1.0-alpha.20260404010029" - - - name: Patch Cangjie - run: | - uv run scripts/patch_opt.py + version: "1.1.0-alpha.20260603010036" - name: Install system libclang (dynamic, Linux) if: matrix.linking.mode == 'dynamic' && matrix.os.sys == 'linux' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 96f297b..6803de6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -59,13 +59,10 @@ jobs: cache: true - name: Setup Cangjie - uses: Zxilly/setup-cangjie@ff94aa01f985321ddfa5cd0973bb26b4c37e6010 # v2.1.1 + uses: Zxilly/setup-cangjie@91463316b1c359f216c2ac49e35900f9341c1571 # v3.2.0 with: channel: "nightly" - version: "1.1.0-alpha.20260404010029" - - - name: Patch Cangjie - run: uv run scripts/patch_opt.py + version: "1.1.0-alpha.20260603010036" - name: Setup MSYS2 if: matrix.os.sys == 'windows' @@ -145,13 +142,10 @@ jobs: cache: true - name: Setup Cangjie - uses: Zxilly/setup-cangjie@ff94aa01f985321ddfa5cd0973bb26b4c37e6010 # v2.1.1 + uses: Zxilly/setup-cangjie@91463316b1c359f216c2ac49e35900f9341c1571 # v3.2.0 with: channel: "nightly" - version: "1.1.0-alpha.20260404010029" - - - name: Patch Cangjie - run: uv run scripts/patch_opt.py + version: "1.1.0-alpha.20260603010036" - name: Setup MSYS2 if: matrix.os.sys == 'windows' diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index e3437b3..e39f5e6 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -2,13 +2,15 @@ ## 依赖版本 -- 仓颉版本:`1.1.0`:需要为 opt 生成补丁 +- 仓颉版本:`nightly`:当前 CI 使用 `1.1.0-alpha.20260603010036` - uv: `>= 0.6.0` Python 版本:`>= 3.11`:用于运行 `scripts` 下的脚本并自动配置依赖 - Go: `>= 1.24`:用于构建 opt 的补丁 -## 修补编译器 +## 修补旧版编译器 -确保当前环境中安装了 `Go`,并且环境变量 `CANGJIE_HOME` 指向仓颉的安装目录。 +仓颉 `1.1.x` 旧版工具链可能需要为 `opt` 生成补丁。当前 nightly 不需要此步骤。 + +如需在旧版工具链上运行,确保当前环境中安装了 `Go`,并且环境变量 `CANGJIE_HOME` 指向仓颉的安装目录。 在 `cjbind` 的根目录下运行以下命令: ``` diff --git a/cangjie-sdk.toml b/cangjie-sdk.toml new file mode 100644 index 0000000..5d56faf --- /dev/null +++ b/cangjie-sdk.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "nightly"