Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › zig › llvm › Builder › opaqueTypeAssumeCapacity Private Function opaqueTypeAssumeCapacity Doc Source Private Function std.zig.llvm.Builder.opaqueTypeAssumeCapacity
fn opaqueTypeAssumeCapacity (self : *Builder , name : String ) Type Params File zig/llvm/Builder.zig: 12119
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164 fn opaqueTypeAssumeCapacity (self : *Builder , name : String ) Type {
const Adapter = struct {
builder : *const Builder ,
pub fn hash (_ : @This (), key : String ) u32 {
return @truncate (std .hash .Wyhash .hash (
comptime std .hash .int (@backingInt (Type .Tag .named_structure )),
std .mem .asBytes (&key ),
));
}
pub fn eql (ctx : @This (), lhs_key : String , _ : void , rhs_index : usize ) bool {
const rhs_data = ctx .builder .type_items .items [rhs_index ];
return rhs_data .tag == .named_structure and
lhs_key == ctx .builder .typeExtraData (Type .NamedStructure , rhs_data .data ).id ;
}
};
var id = name ;
if (name == .empty ) {
id = self .next_unnamed_type ;
assert (id != .none );
self .next_unnamed_type = @fromBackingInt (@backingInt (id ) + 1 );
} else assert (!name .isAnon ());
while (true ) {
const type_gop = self .types .getOrPutAssumeCapacity (id );
if (!type_gop .found_existing ) {
const gop = self .type_map .getOrPutAssumeCapacityAdapted (id , Adapter { .builder = self });
assert (!gop .found_existing );
gop .key_ptr .* = {};
gop .value_ptr .* = {};
self .type_items .appendAssumeCapacity (.{
.tag = .named_structure ,
.data = self .addTypeExtraAssumeCapacity (Type .NamedStructure {
.id = id ,
.body = .none ,
}),
});
const result : Type = @fromBackingInt (@intCast (gop .index ));
type_gop .value_ptr .* = result ;
return result ;
}
const unique_gop = self .next_unique_type_id .getOrPutAssumeCapacity (name );
if (!unique_gop .found_existing ) unique_gop .value_ptr .* = 2 ;
id = self .fmtAssumeCapacity ("{s}.{d}" , .{ name .slice (self ).?, unique_gop .value_ptr .* });
unique_gop .value_ptr .* += 1 ;
}
}