interface99: add package (#4546)
* interface99: add package * interface99: test against older version * interface99: improve test * interface99: use c11 flag * interface99: test latest versionautoupdate-tesseract-5.4.1
parent
1e956bf4f5
commit
feadc4000f
1 changed files with 46 additions and 0 deletions
@ -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 <assert.h> |
||||
#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) |
Loading…
Reference in new issue