Meta type ‣ isArgumentString(T, arg_index) ᴾᴴᴾ - chung-leong/zigar GitHub Wiki
JavaScript | PHP
Determine whether an argument to a callback function should be a text string.
Usage:
const std = @import("std");
const Callback = fn ([]const u8) void;
pub fn call(cb: *const Callback) void {
cb("hello");
}
pub const @"meta(zigar)" = struct {
pub fn isArgumentString(comptime T: type, comptime arg_index: usize) bool {
return T == Callback and arg_index == 0;
}
};
<?php
$m = zigar_use(__DIR__ . '/meta-type-string-example-3.zig');
$m->call(function ($arg) {
echo "$arg\n";
});
hello
Arguments:
T- Callback function typearg_index- Index of argument in question