Meta type ‣ isFieldPlain(T, name) ᴾᴴᴾ - chung-leong/zigar GitHub Wiki
JavaScript | PHP
Determine whether a struct/union field should be a plain JavaScript object.
Usage:
const std = @import("std");
const Struct = struct {
field: []const u8 = "hello",
};
pub const structure: Struct = .{};
pub const @"meta(zigar)" = struct {
pub fn isFieldPlain(comptime T: type, comptime name: std.meta.FieldEnum(T)) bool {
return T == Struct and name == .field;
}
};
<?php
$m = zigar_use(__DIR__ . '/meta-type-plain-example-2.zig');
print_r($m->structure->field);
Array
(
[0] => 104
[1] => 101
[2] => 108
[3] => 108
[4] => 111
)
Arguments:
T- Struct/union type in questionname- Name of the field represented by an enum