Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const TypeId = @import("builtin").TypeId;
- fn init_zeroes(comptime T: type) T {
- var t: T = undefined;
- inline for (@typeInfo(T).Struct.fields) |field, i| {
- const field_type = @typeInfo(field.field_type);
- if (TypeId(field_type) == TypeId.Pointer) {
- @field(t, field.name) = null;
- }
- if (TypeId(field_type) == TypeId.Int) {
- @field(t, field.name) = 0;
- }
- if (TypeId(field_type) == TypeId.Float) {
- @field(t, field.name) = 0;
- }
- }
- return t;
- }
- fn protocol(name: [*c]const u8) lws_protocols {
- var p: lws_protocols = init_zeroes(lws_protocols);
- p.name = name;
- return p;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement