From f21bb98fc5ec4e288662b44cc35143a14942f33e Mon Sep 17 00:00:00 2001 From: urso Date: Mon, 18 Mar 2024 17:32:16 +0100 Subject: [PATCH] export meta --- src/pgzx.zig | 4 ++++ src/pgzx/meta.zig | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/pgzx.zig b/src/pgzx.zig index f594fb1..a9843b8 100644 --- a/src/pgzx.zig +++ b/src/pgzx.zig @@ -41,4 +41,8 @@ pub const utils = @import("pgzx/utils.zig"); pub const intr = @import("pgzx/interrupts.zig"); pub const testing = @import("pgzx/testing.zig"); +// reexport the meta module. Although quite generic, it is useful to have these +// helpers around at times. +pub const meta = @import("pgzx/meta.zig"); + pub const guc = utils.guc; diff --git a/src/pgzx/meta.zig b/src/pgzx/meta.zig index 7f1eaa3..c607b20 100644 --- a/src/pgzx/meta.zig +++ b/src/pgzx/meta.zig @@ -32,3 +32,10 @@ pub inline fn isPrimitive(comptime T: type) bool { else => false, }; } + +pub inline fn fnReturnType(comptime T: type, comptime fnName: []const u8) type { + return switch (@typeInfo(@field(T, fnName))) { + .Fn => |f| f.return_type.?, + else => @compileError("Expected a function type"), + }; +}