From feadc4000f700219620fb079c5085d8d2e3170a5 Mon Sep 17 00:00:00 2001 From: IMXEren <96839938+IMXEren@users.noreply.github.com> Date: Thu, 4 Jul 2024 21:01:52 +0530 Subject: [PATCH] interface99: add package (#4546) * interface99: add package * interface99: test against older version * interface99: improve test * interface99: use c11 flag * interface99: test latest version --- packages/i/interface99/xmake.lua | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 packages/i/interface99/xmake.lua diff --git a/packages/i/interface99/xmake.lua b/packages/i/interface99/xmake.lua new file mode 100644 index 000000000..e8f943f71 --- /dev/null +++ b/packages/i/interface99/xmake.lua @@ -0,0 +1,46 @@ +package("interface99") + set_kind("library", { headeronly = true }) + set_homepage("https://github.com/Hirrolot/interface99") + set_description("Full-featured interfaces for C99") + set_license("MIT") + + add_urls("https://github.com/Hirrolot/interface99/archive/refs/tags/v$(version).tar.gz", + "https://github.com/Hirrolot/interface99.git") + + add_versions("1.0.0", "578c7e60fde4ea1c7fd3515e444c6a2e62a9095dac979516c0046a8ed008e3b2") + add_versions("1.0.1", "ddc7cd979cf9c964a4313a5e6bdc87bd8df669142f29c8edb71d2f2f7822d9aa") + + add_deps("metalang99") + + on_install(function(package) + os.cp("*.h", package:installdir("include")) + end) + + on_test(function(package) + assert(package:check_csnippets({test = [[ + #include + #define Shape_IFACE \ + vfunc( int, perim, const VSelf) \ + vfunc(void, scale, VSelf, int factor) + interface(Shape); + typedef struct { + int a, b; + } Rectangle; + int Rectangle_perim(const VSelf) { + VSELF(const Rectangle); + return (self->a + self->b) * 2; + } + void Rectangle_scale(VSelf, int factor) { + VSELF(Rectangle); + self->a *= factor; + self->b *= factor; + } + impl(Shape, Rectangle); + void test() { + Shape shape = DYN_LIT(Rectangle, Shape, {5, 7}); + assert(VCALL(shape, perim) == 24); + VCALL(shape, scale, 5); + assert(VCALL(shape, perim) == 120); + } + ]]}, { configs = { languages = "c11" }, includes = "interface99.h" })) + end)