mirror of
https://github.com/ziglang/zig.git
synced 2024-11-15 16:45:27 +00:00
Update zig files for opaque type syntax
This commit is contained in:
parent
069fbb3c01
commit
2b4b03d301
@ -329,8 +329,8 @@ pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) c_int;
|
||||
pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) c_int;
|
||||
pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) c_int;
|
||||
|
||||
pub const pthread_t = *@Type(.Opaque);
|
||||
pub const FILE = @Type(.Opaque);
|
||||
pub const pthread_t = *opaque {};
|
||||
pub const FILE = opaque {};
|
||||
|
||||
pub extern "c" fn dlopen(path: [*:0]const u8, mode: c_int) ?*c_void;
|
||||
pub extern "c" fn dlclose(handle: *c_void) c_int;
|
||||
|
@ -12,28 +12,28 @@ const in_bpf_program = switch (std.builtin.arch) {
|
||||
|
||||
pub const helpers = if (in_bpf_program) @import("helpers.zig") else struct {};
|
||||
|
||||
pub const BpfSock = @Type(.Opaque);
|
||||
pub const BpfSockAddr = @Type(.Opaque);
|
||||
pub const FibLookup = @Type(.Opaque);
|
||||
pub const MapDef = @Type(.Opaque);
|
||||
pub const PerfEventData = @Type(.Opaque);
|
||||
pub const PerfEventValue = @Type(.Opaque);
|
||||
pub const PidNsInfo = @Type(.Opaque);
|
||||
pub const SeqFile = @Type(.Opaque);
|
||||
pub const SkBuff = @Type(.Opaque);
|
||||
pub const SkMsgMd = @Type(.Opaque);
|
||||
pub const SkReusePortMd = @Type(.Opaque);
|
||||
pub const Sock = @Type(.Opaque);
|
||||
pub const SockAddr = @Type(.Opaque);
|
||||
pub const SockOps = @Type(.Opaque);
|
||||
pub const SockTuple = @Type(.Opaque);
|
||||
pub const SpinLock = @Type(.Opaque);
|
||||
pub const SysCtl = @Type(.Opaque);
|
||||
pub const Tcp6Sock = @Type(.Opaque);
|
||||
pub const TcpRequestSock = @Type(.Opaque);
|
||||
pub const TcpSock = @Type(.Opaque);
|
||||
pub const TcpTimewaitSock = @Type(.Opaque);
|
||||
pub const TunnelKey = @Type(.Opaque);
|
||||
pub const Udp6Sock = @Type(.Opaque);
|
||||
pub const XdpMd = @Type(.Opaque);
|
||||
pub const XfrmState = @Type(.Opaque);
|
||||
pub const BpfSock = opaque {};
|
||||
pub const BpfSockAddr = opaque {};
|
||||
pub const FibLookup = opaque {};
|
||||
pub const MapDef = opaque {};
|
||||
pub const PerfEventData = opaque {};
|
||||
pub const PerfEventValue = opaque {};
|
||||
pub const PidNsInfo = opaque {};
|
||||
pub const SeqFile = opaque {};
|
||||
pub const SkBuff = opaque {};
|
||||
pub const SkMsgMd = opaque {};
|
||||
pub const SkReusePortMd = opaque {};
|
||||
pub const Sock = opaque {};
|
||||
pub const SockAddr = opaque {};
|
||||
pub const SockOps = opaque {};
|
||||
pub const SockTuple = opaque {};
|
||||
pub const SpinLock = opaque {};
|
||||
pub const SysCtl = opaque {};
|
||||
pub const Tcp6Sock = opaque {};
|
||||
pub const TcpRequestSock = opaque {};
|
||||
pub const TcpSock = opaque {};
|
||||
pub const TcpTimewaitSock = opaque {};
|
||||
pub const TunnelKey = opaque {};
|
||||
pub const Udp6Sock = opaque {};
|
||||
pub const XdpMd = opaque {};
|
||||
pub const XfrmState = opaque {};
|
||||
|
@ -17,7 +17,7 @@ pub var handle: Handle = undefined;
|
||||
pub var system_table: *tables.SystemTable = undefined;
|
||||
|
||||
/// A handle to an event structure.
|
||||
pub const Event = *@Type(.Opaque);
|
||||
pub const Event = *opaque {};
|
||||
|
||||
/// GUIDs must be align(8)
|
||||
pub const Guid = extern struct {
|
||||
@ -51,7 +51,7 @@ pub const Guid = extern struct {
|
||||
};
|
||||
|
||||
/// An EFI Handle represents a collection of related interfaces.
|
||||
pub const Handle = *@Type(.Opaque);
|
||||
pub const Handle = *opaque {};
|
||||
|
||||
/// This structure represents time information.
|
||||
pub const Time = extern struct {
|
||||
@ -108,4 +108,4 @@ pub const TimeCapabilities = extern struct {
|
||||
};
|
||||
|
||||
/// File Handle as specified in the EFI Shell Spec
|
||||
pub const FileHandle = *@Type(.Opaque);
|
||||
pub const FileHandle = *opaque {};
|
||||
|
@ -6,7 +6,7 @@
|
||||
const uefi = @import("std").os.uefi;
|
||||
const Guid = uefi.Guid;
|
||||
|
||||
pub const HIIHandle = *@Type(.Opaque);
|
||||
pub const HIIHandle = *opaque {};
|
||||
|
||||
/// The header found at the start of each package.
|
||||
pub const HIIPackageHeader = packed struct {
|
||||
|
@ -32,16 +32,16 @@ pub const UCHAR = u8;
|
||||
pub const FLOAT = f32;
|
||||
pub const HANDLE = *c_void;
|
||||
pub const HCRYPTPROV = ULONG_PTR;
|
||||
pub const HBRUSH = *@Type(.Opaque);
|
||||
pub const HCURSOR = *@Type(.Opaque);
|
||||
pub const HICON = *@Type(.Opaque);
|
||||
pub const HINSTANCE = *@Type(.Opaque);
|
||||
pub const HMENU = *@Type(.Opaque);
|
||||
pub const HMODULE = *@Type(.Opaque);
|
||||
pub const HWND = *@Type(.Opaque);
|
||||
pub const HDC = *@Type(.Opaque);
|
||||
pub const HGLRC = *@Type(.Opaque);
|
||||
pub const FARPROC = *@Type(.Opaque);
|
||||
pub const HBRUSH = *opaque {};
|
||||
pub const HCURSOR = *opaque {};
|
||||
pub const HICON = *opaque {};
|
||||
pub const HINSTANCE = *opaque {};
|
||||
pub const HMENU = *opaque {};
|
||||
pub const HMODULE = *opaque {};
|
||||
pub const HWND = *opaque {};
|
||||
pub const HDC = *opaque {};
|
||||
pub const HGLRC = *opaque {};
|
||||
pub const FARPROC = *opaque {};
|
||||
pub const INT = c_int;
|
||||
pub const LPBYTE = *BYTE;
|
||||
pub const LPCH = *CHAR;
|
||||
@ -81,7 +81,7 @@ pub const WPARAM = usize;
|
||||
pub const LPARAM = ?*c_void;
|
||||
pub const LRESULT = ?*c_void;
|
||||
|
||||
pub const va_list = *@Type(.Opaque);
|
||||
pub const va_list = *opaque {};
|
||||
|
||||
pub const TRUE = 1;
|
||||
pub const FALSE = 0;
|
||||
@ -1175,10 +1175,10 @@ pub const UNICODE_STRING = extern struct {
|
||||
Buffer: [*]WCHAR,
|
||||
};
|
||||
|
||||
const ACTIVATION_CONTEXT_DATA = @Type(.Opaque);
|
||||
const ASSEMBLY_STORAGE_MAP = @Type(.Opaque);
|
||||
const FLS_CALLBACK_INFO = @Type(.Opaque);
|
||||
const RTL_BITMAP = @Type(.Opaque);
|
||||
const ACTIVATION_CONTEXT_DATA = opaque {};
|
||||
const ASSEMBLY_STORAGE_MAP = opaque {};
|
||||
const FLS_CALLBACK_INFO = opaque {};
|
||||
const RTL_BITMAP = opaque {};
|
||||
pub const PRTL_BITMAP = *RTL_BITMAP;
|
||||
const KAFFINITY = usize;
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
// and substantial portions of the software.
|
||||
usingnamespace @import("bits.zig");
|
||||
|
||||
pub const SOCKET = *@Type(.Opaque);
|
||||
pub const SOCKET = *opaque {};
|
||||
pub const INVALID_SOCKET = @intToPtr(SOCKET, ~@as(usize, 0));
|
||||
pub const SOCKET_ERROR = -1;
|
||||
|
||||
|
172
src/clang.zig
172
src/clang.zig
@ -1,89 +1,89 @@
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub const struct_ZigClangConditionalOperator = @Type(.Opaque);
|
||||
pub const struct_ZigClangBinaryConditionalOperator = @Type(.Opaque);
|
||||
pub const struct_ZigClangAbstractConditionalOperator = @Type(.Opaque);
|
||||
pub const struct_ZigClangAPInt = @Type(.Opaque);
|
||||
pub const struct_ZigClangAPSInt = @Type(.Opaque);
|
||||
pub const struct_ZigClangAPFloat = @Type(.Opaque);
|
||||
pub const struct_ZigClangASTContext = @Type(.Opaque);
|
||||
pub const struct_ZigClangASTUnit = @Type(.Opaque);
|
||||
pub const struct_ZigClangArraySubscriptExpr = @Type(.Opaque);
|
||||
pub const struct_ZigClangArrayType = @Type(.Opaque);
|
||||
pub const struct_ZigClangAttributedType = @Type(.Opaque);
|
||||
pub const struct_ZigClangBinaryOperator = @Type(.Opaque);
|
||||
pub const struct_ZigClangBreakStmt = @Type(.Opaque);
|
||||
pub const struct_ZigClangBuiltinType = @Type(.Opaque);
|
||||
pub const struct_ZigClangCStyleCastExpr = @Type(.Opaque);
|
||||
pub const struct_ZigClangCallExpr = @Type(.Opaque);
|
||||
pub const struct_ZigClangCaseStmt = @Type(.Opaque);
|
||||
pub const struct_ZigClangCompoundAssignOperator = @Type(.Opaque);
|
||||
pub const struct_ZigClangCompoundStmt = @Type(.Opaque);
|
||||
pub const struct_ZigClangConstantArrayType = @Type(.Opaque);
|
||||
pub const struct_ZigClangContinueStmt = @Type(.Opaque);
|
||||
pub const struct_ZigClangDecayedType = @Type(.Opaque);
|
||||
pub const ZigClangDecl = @Type(.Opaque);
|
||||
pub const struct_ZigClangDeclRefExpr = @Type(.Opaque);
|
||||
pub const struct_ZigClangDeclStmt = @Type(.Opaque);
|
||||
pub const struct_ZigClangDefaultStmt = @Type(.Opaque);
|
||||
pub const struct_ZigClangDiagnosticOptions = @Type(.Opaque);
|
||||
pub const struct_ZigClangDiagnosticsEngine = @Type(.Opaque);
|
||||
pub const struct_ZigClangDoStmt = @Type(.Opaque);
|
||||
pub const struct_ZigClangElaboratedType = @Type(.Opaque);
|
||||
pub const struct_ZigClangEnumConstantDecl = @Type(.Opaque);
|
||||
pub const struct_ZigClangEnumDecl = @Type(.Opaque);
|
||||
pub const struct_ZigClangEnumType = @Type(.Opaque);
|
||||
pub const struct_ZigClangExpr = @Type(.Opaque);
|
||||
pub const struct_ZigClangFieldDecl = @Type(.Opaque);
|
||||
pub const struct_ZigClangFileID = @Type(.Opaque);
|
||||
pub const struct_ZigClangForStmt = @Type(.Opaque);
|
||||
pub const struct_ZigClangFullSourceLoc = @Type(.Opaque);
|
||||
pub const struct_ZigClangFunctionDecl = @Type(.Opaque);
|
||||
pub const struct_ZigClangFunctionProtoType = @Type(.Opaque);
|
||||
pub const struct_ZigClangIfStmt = @Type(.Opaque);
|
||||
pub const struct_ZigClangImplicitCastExpr = @Type(.Opaque);
|
||||
pub const struct_ZigClangIncompleteArrayType = @Type(.Opaque);
|
||||
pub const struct_ZigClangIntegerLiteral = @Type(.Opaque);
|
||||
pub const struct_ZigClangMacroDefinitionRecord = @Type(.Opaque);
|
||||
pub const struct_ZigClangMacroExpansion = @Type(.Opaque);
|
||||
pub const struct_ZigClangMacroQualifiedType = @Type(.Opaque);
|
||||
pub const struct_ZigClangMemberExpr = @Type(.Opaque);
|
||||
pub const struct_ZigClangNamedDecl = @Type(.Opaque);
|
||||
pub const struct_ZigClangNone = @Type(.Opaque);
|
||||
pub const struct_ZigClangOpaqueValueExpr = @Type(.Opaque);
|
||||
pub const struct_ZigClangPCHContainerOperations = @Type(.Opaque);
|
||||
pub const struct_ZigClangParenExpr = @Type(.Opaque);
|
||||
pub const struct_ZigClangParenType = @Type(.Opaque);
|
||||
pub const struct_ZigClangParmVarDecl = @Type(.Opaque);
|
||||
pub const struct_ZigClangPointerType = @Type(.Opaque);
|
||||
pub const struct_ZigClangPreprocessedEntity = @Type(.Opaque);
|
||||
pub const struct_ZigClangRecordDecl = @Type(.Opaque);
|
||||
pub const struct_ZigClangRecordType = @Type(.Opaque);
|
||||
pub const struct_ZigClangReturnStmt = @Type(.Opaque);
|
||||
pub const struct_ZigClangSkipFunctionBodiesScope = @Type(.Opaque);
|
||||
pub const struct_ZigClangSourceManager = @Type(.Opaque);
|
||||
pub const struct_ZigClangSourceRange = @Type(.Opaque);
|
||||
pub const ZigClangStmt = @Type(.Opaque);
|
||||
pub const struct_ZigClangStringLiteral = @Type(.Opaque);
|
||||
pub const struct_ZigClangStringRef = @Type(.Opaque);
|
||||
pub const struct_ZigClangSwitchStmt = @Type(.Opaque);
|
||||
pub const struct_ZigClangTagDecl = @Type(.Opaque);
|
||||
pub const struct_ZigClangType = @Type(.Opaque);
|
||||
pub const struct_ZigClangTypedefNameDecl = @Type(.Opaque);
|
||||
pub const struct_ZigClangTypedefType = @Type(.Opaque);
|
||||
pub const struct_ZigClangUnaryExprOrTypeTraitExpr = @Type(.Opaque);
|
||||
pub const struct_ZigClangUnaryOperator = @Type(.Opaque);
|
||||
pub const struct_ZigClangValueDecl = @Type(.Opaque);
|
||||
pub const struct_ZigClangVarDecl = @Type(.Opaque);
|
||||
pub const struct_ZigClangWhileStmt = @Type(.Opaque);
|
||||
pub const struct_ZigClangFunctionType = @Type(.Opaque);
|
||||
pub const struct_ZigClangPredefinedExpr = @Type(.Opaque);
|
||||
pub const struct_ZigClangInitListExpr = @Type(.Opaque);
|
||||
pub const ZigClangPreprocessingRecord = @Type(.Opaque);
|
||||
pub const ZigClangFloatingLiteral = @Type(.Opaque);
|
||||
pub const ZigClangConstantExpr = @Type(.Opaque);
|
||||
pub const ZigClangCharacterLiteral = @Type(.Opaque);
|
||||
pub const ZigClangStmtExpr = @Type(.Opaque);
|
||||
pub const struct_ZigClangConditionalOperator = opaque {};
|
||||
pub const struct_ZigClangBinaryConditionalOperator = opaque {};
|
||||
pub const struct_ZigClangAbstractConditionalOperator = opaque {};
|
||||
pub const struct_ZigClangAPInt = opaque {};
|
||||
pub const struct_ZigClangAPSInt = opaque {};
|
||||
pub const struct_ZigClangAPFloat = opaque {};
|
||||
pub const struct_ZigClangASTContext = opaque {};
|
||||
pub const struct_ZigClangASTUnit = opaque {};
|
||||
pub const struct_ZigClangArraySubscriptExpr = opaque {};
|
||||
pub const struct_ZigClangArrayType = opaque {};
|
||||
pub const struct_ZigClangAttributedType = opaque {};
|
||||
pub const struct_ZigClangBinaryOperator = opaque {};
|
||||
pub const struct_ZigClangBreakStmt = opaque {};
|
||||
pub const struct_ZigClangBuiltinType = opaque {};
|
||||
pub const struct_ZigClangCStyleCastExpr = opaque {};
|
||||
pub const struct_ZigClangCallExpr = opaque {};
|
||||
pub const struct_ZigClangCaseStmt = opaque {};
|
||||
pub const struct_ZigClangCompoundAssignOperator = opaque {};
|
||||
pub const struct_ZigClangCompoundStmt = opaque {};
|
||||
pub const struct_ZigClangConstantArrayType = opaque {};
|
||||
pub const struct_ZigClangContinueStmt = opaque {};
|
||||
pub const struct_ZigClangDecayedType = opaque {};
|
||||
pub const ZigClangDecl = opaque {};
|
||||
pub const struct_ZigClangDeclRefExpr = opaque {};
|
||||
pub const struct_ZigClangDeclStmt = opaque {};
|
||||
pub const struct_ZigClangDefaultStmt = opaque {};
|
||||
pub const struct_ZigClangDiagnosticOptions = opaque {};
|
||||
pub const struct_ZigClangDiagnosticsEngine = opaque {};
|
||||
pub const struct_ZigClangDoStmt = opaque {};
|
||||
pub const struct_ZigClangElaboratedType = opaque {};
|
||||
pub const struct_ZigClangEnumConstantDecl = opaque {};
|
||||
pub const struct_ZigClangEnumDecl = opaque {};
|
||||
pub const struct_ZigClangEnumType = opaque {};
|
||||
pub const struct_ZigClangExpr = opaque {};
|
||||
pub const struct_ZigClangFieldDecl = opaque {};
|
||||
pub const struct_ZigClangFileID = opaque {};
|
||||
pub const struct_ZigClangForStmt = opaque {};
|
||||
pub const struct_ZigClangFullSourceLoc = opaque {};
|
||||
pub const struct_ZigClangFunctionDecl = opaque {};
|
||||
pub const struct_ZigClangFunctionProtoType = opaque {};
|
||||
pub const struct_ZigClangIfStmt = opaque {};
|
||||
pub const struct_ZigClangImplicitCastExpr = opaque {};
|
||||
pub const struct_ZigClangIncompleteArrayType = opaque {};
|
||||
pub const struct_ZigClangIntegerLiteral = opaque {};
|
||||
pub const struct_ZigClangMacroDefinitionRecord = opaque {};
|
||||
pub const struct_ZigClangMacroExpansion = opaque {};
|
||||
pub const struct_ZigClangMacroQualifiedType = opaque {};
|
||||
pub const struct_ZigClangMemberExpr = opaque {};
|
||||
pub const struct_ZigClangNamedDecl = opaque {};
|
||||
pub const struct_ZigClangNone = opaque {};
|
||||
pub const struct_ZigClangOpaqueValueExpr = opaque {};
|
||||
pub const struct_ZigClangPCHContainerOperations = opaque {};
|
||||
pub const struct_ZigClangParenExpr = opaque {};
|
||||
pub const struct_ZigClangParenType = opaque {};
|
||||
pub const struct_ZigClangParmVarDecl = opaque {};
|
||||
pub const struct_ZigClangPointerType = opaque {};
|
||||
pub const struct_ZigClangPreprocessedEntity = opaque {};
|
||||
pub const struct_ZigClangRecordDecl = opaque {};
|
||||
pub const struct_ZigClangRecordType = opaque {};
|
||||
pub const struct_ZigClangReturnStmt = opaque {};
|
||||
pub const struct_ZigClangSkipFunctionBodiesScope = opaque {};
|
||||
pub const struct_ZigClangSourceManager = opaque {};
|
||||
pub const struct_ZigClangSourceRange = opaque {};
|
||||
pub const ZigClangStmt = opaque {};
|
||||
pub const struct_ZigClangStringLiteral = opaque {};
|
||||
pub const struct_ZigClangStringRef = opaque {};
|
||||
pub const struct_ZigClangSwitchStmt = opaque {};
|
||||
pub const struct_ZigClangTagDecl = opaque {};
|
||||
pub const struct_ZigClangType = opaque {};
|
||||
pub const struct_ZigClangTypedefNameDecl = opaque {};
|
||||
pub const struct_ZigClangTypedefType = opaque {};
|
||||
pub const struct_ZigClangUnaryExprOrTypeTraitExpr = opaque {};
|
||||
pub const struct_ZigClangUnaryOperator = opaque {};
|
||||
pub const struct_ZigClangValueDecl = opaque {};
|
||||
pub const struct_ZigClangVarDecl = opaque {};
|
||||
pub const struct_ZigClangWhileStmt = opaque {};
|
||||
pub const struct_ZigClangFunctionType = opaque {};
|
||||
pub const struct_ZigClangPredefinedExpr = opaque {};
|
||||
pub const struct_ZigClangInitListExpr = opaque {};
|
||||
pub const ZigClangPreprocessingRecord = opaque {};
|
||||
pub const ZigClangFloatingLiteral = opaque {};
|
||||
pub const ZigClangConstantExpr = opaque {};
|
||||
pub const ZigClangCharacterLiteral = opaque {};
|
||||
pub const ZigClangStmtExpr = opaque {};
|
||||
|
||||
pub const ZigClangBO = extern enum {
|
||||
PtrMemD,
|
||||
@ -749,11 +749,11 @@ pub const ZigClangCharacterLiteral_CharacterKind = extern enum {
|
||||
};
|
||||
|
||||
pub const ZigClangRecordDecl_field_iterator = extern struct {
|
||||
opaque: *c_void,
|
||||
ptr: *c_void,
|
||||
};
|
||||
|
||||
pub const ZigClangEnumDecl_enumerator_iterator = extern struct {
|
||||
opaque: *c_void,
|
||||
ptr: *c_void,
|
||||
};
|
||||
|
||||
pub const ZigClangPreprocessingRecord_iterator = extern struct {
|
||||
|
@ -180,7 +180,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ .layout = .Auto,
|
||||
\\ .tag_type = null,
|
||||
\\ .fields = &[_]TypeInfo.UnionField{
|
||||
\\ .{ .name = "foo", .field_type = @Type(.Opaque), .alignment = 1 },
|
||||
\\ .{ .name = "foo", .field_type = opaque {}, .alignment = 1 },
|
||||
\\ },
|
||||
\\ .decls = &[_]TypeInfo.Declaration{},
|
||||
\\ },
|
||||
@ -2613,7 +2613,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
});
|
||||
|
||||
cases.add("directly embedding opaque type in struct and union",
|
||||
\\const O = @Type(.Opaque);
|
||||
\\const O = opaque {};
|
||||
\\const Foo = struct {
|
||||
\\ o: O,
|
||||
\\};
|
||||
@ -2628,7 +2628,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ var bar: Bar = undefined;
|
||||
\\}
|
||||
\\export fn c() void {
|
||||
\\ var baz: *@Type(.Opaque) = undefined;
|
||||
\\ var baz: *opaque {} = undefined;
|
||||
\\ const qux = .{baz.*};
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
@ -3592,7 +3592,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
});
|
||||
|
||||
cases.add("unknown length pointer to opaque",
|
||||
\\export const T = [*]@Type(.Opaque);
|
||||
\\export const T = [*]opaque {};
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:1:21: error: unknown-length pointer to opaque",
|
||||
});
|
||||
@ -6827,8 +6827,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
"tmp.zig:2:31: error: index 2 outside array of size 2",
|
||||
});
|
||||
|
||||
cases.add("wrong pointer coerced to pointer to @Type(.Opaque)",
|
||||
\\const Derp = @Type(.Opaque);
|
||||
cases.add("wrong pointer coerced to pointer to opaque {}",
|
||||
\\const Derp = opaque {};
|
||||
\\extern fn bar(d: *Derp) void;
|
||||
\\export fn foo() void {
|
||||
\\ var x = @as(u8, 1);
|
||||
@ -6854,8 +6854,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\export fn entry5() void {
|
||||
\\ var d = null;
|
||||
\\}
|
||||
\\export fn entry6(opaque: *Opaque) void {
|
||||
\\ var e = opaque.*;
|
||||
\\export fn entry6(opaque_: *Opaque) void {
|
||||
\\ var e = opaque_.*;
|
||||
\\}
|
||||
\\export fn entry7() void {
|
||||
\\ var f = i32;
|
||||
@ -6866,7 +6866,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\export fn entry9() void {
|
||||
\\ var z: noreturn = return;
|
||||
\\}
|
||||
\\const Opaque = @Type(.Opaque);
|
||||
\\const Opaque = opaque {};
|
||||
\\const Foo = struct {
|
||||
\\ fn bar(self: *const Foo) void {}
|
||||
\\};
|
||||
@ -7020,7 +7020,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
});
|
||||
|
||||
cases.add("field access of opaque type",
|
||||
\\const MyType = @Type(.Opaque);
|
||||
\\const MyType = opaque {};
|
||||
\\
|
||||
\\export fn entry() bool {
|
||||
\\ var x: i32 = 1;
|
||||
@ -7623,7 +7623,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
});
|
||||
|
||||
cases.add("function returning opaque type",
|
||||
\\const FooType = @Type(.Opaque);
|
||||
\\const FooType = opaque {};
|
||||
\\export fn bar() !FooType {
|
||||
\\ return error.InvalidValue;
|
||||
\\}
|
||||
@ -7641,7 +7641,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
});
|
||||
|
||||
cases.add("generic function returning opaque type",
|
||||
\\const FooType = @Type(.Opaque);
|
||||
\\const FooType = opaque {};
|
||||
\\fn generic(comptime T: type) !T {
|
||||
\\ return undefined;
|
||||
\\}
|
||||
@ -7665,7 +7665,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
});
|
||||
|
||||
cases.add("function parameter is opaque",
|
||||
\\const FooType = @Type(.Opaque);
|
||||
\\const FooType = opaque {};
|
||||
\\export fn entry1() void {
|
||||
\\ const someFuncPtr: fn (FooType) void = undefined;
|
||||
\\}
|
||||
|
@ -74,7 +74,7 @@ pub fn addCases(cases: *tests.GenHContext) void {
|
||||
});
|
||||
|
||||
cases.add("declare opaque type",
|
||||
\\const Foo = @Type(.Opaque);
|
||||
\\const Foo = opaque {};
|
||||
\\
|
||||
\\export fn entry(foo: ?*Foo) void { }
|
||||
, &[_][]const u8{
|
||||
|
@ -438,8 +438,8 @@ export fn writeToVRam() void {
|
||||
vram[0] = 'X';
|
||||
}
|
||||
|
||||
const OpaqueA = @Type(.Opaque);
|
||||
const OpaqueB = @Type(.Opaque);
|
||||
const OpaqueA = opaque {};
|
||||
const OpaqueB = opaque {};
|
||||
test "opaque types" {
|
||||
expect(*OpaqueA != *OpaqueB);
|
||||
expect(mem.eql(u8, @typeName(OpaqueA), "OpaqueA"));
|
||||
@ -704,7 +704,7 @@ test "auto created variables have correct alignment" {
|
||||
comptime expect(S.foo("\x7a\x7a\x7a\x7a") == 0x7a7a7a7a);
|
||||
}
|
||||
|
||||
extern var opaque_extern_var: @Type(.Opaque);
|
||||
extern var opaque_extern_var: opaque {};
|
||||
var var_to_export: u32 = 42;
|
||||
test "extern variable with non-pointer opaque type" {
|
||||
@export(var_to_export, .{ .name = "opaque_extern_var" });
|
||||
|
@ -121,9 +121,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
\\struct foo { int x; int y[]; };
|
||||
\\struct bar { int x; int y[0]; };
|
||||
, &[_][]const u8{
|
||||
\\pub const struct_foo = @Type(.Opaque);
|
||||
\\pub const struct_foo = opaque {};
|
||||
,
|
||||
\\pub const struct_bar = @Type(.Opaque);
|
||||
\\pub const struct_bar = opaque {};
|
||||
});
|
||||
|
||||
cases.add("nested loops without blocks",
|
||||
@ -191,7 +191,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
\\pub const struct_arcan_shmif_page = //
|
||||
,
|
||||
\\warning: unsupported type: 'Atomic'
|
||||
\\ @Type(.Opaque); //
|
||||
\\ opaque {}; //
|
||||
,
|
||||
\\ warning: struct demoted to opaque type - unable to translate type of field abufused
|
||||
, // TODO should be `addr: *struct_arcan_shmif_page`
|
||||
@ -370,8 +370,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
\\ struct opaque_2 *cast = (struct opaque_2 *)opaque;
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
\\pub const struct_opaque = @Type(.Opaque);
|
||||
\\pub const struct_opaque_2 = @Type(.Opaque);
|
||||
\\pub const struct_opaque = opaque {};
|
||||
\\pub const struct_opaque_2 = opaque {};
|
||||
\\pub export fn function(arg_opaque_1: ?*struct_opaque) void {
|
||||
\\ var opaque_1 = arg_opaque_1;
|
||||
\\ var cast: ?*struct_opaque_2 = @ptrCast(?*struct_opaque_2, opaque_1);
|
||||
@ -612,7 +612,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
\\ struct Foo *foo;
|
||||
\\};
|
||||
, &[_][]const u8{
|
||||
\\pub const struct_Foo = @Type(.Opaque);
|
||||
\\pub const struct_Foo = opaque {};
|
||||
,
|
||||
\\pub const struct_Bar = extern struct {
|
||||
\\ foo: ?*struct_Foo,
|
||||
@ -689,7 +689,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
\\struct Foo;
|
||||
\\struct Foo *some_func(struct Foo *foo, int x);
|
||||
, &[_][]const u8{
|
||||
\\pub const struct_Foo = @Type(.Opaque);
|
||||
\\pub const struct_Foo = opaque {};
|
||||
,
|
||||
\\pub extern fn some_func(foo: ?*struct_Foo, x: c_int) ?*struct_Foo;
|
||||
,
|
||||
|
Loading…
Reference in New Issue
Block a user