Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-bridge/blob/main/examples/deepinfer/callers/caller.cpp # omega-bridge Omega-first language interoperability: checked conversion backends and native language bindings Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-bridge / examples / deepinfer / callers / caller.cpp` 61 lines ยท 2374 bytes Raw Blame History 1 // C++ caller for examples/deepinfer/flops_pairs.om. Every Omega declaration comes from the generated 2 // omega_native.h; nothing is typed by hand here. Expected values: evidence/deepinfer-flops-pairs/wolfram.md. 3 #include 4 #include 5 #include 6 #include 7 #include 8 9 #include "omega_native.h" 10 11 namespace { 12 int fails = 0; 13 void check(const std::string &name, bool ok) { 14 std::printf("%s %s\n", ok ? "PASS" : "FAIL", name.c_str()); 15 if (!ok) fails++; 16 } 17 struct V { 18 const char *fn; 19 std::vector a; 20 uint32_t status; 21 int64_t want; 22 }; 23 uint32_t call(const V &x, uint64_t *r) { 24 std::vector u; 25 for (int64_t v : x.a) u.push_back(static_cast(v)); 26 if (!std::strcmp(x.fn, "floor_prefix")) return omega2_floor_prefix(r, u[0], u[1]); 27 if (!std::strcmp(x.fn, "capped_prefix")) return omega2_capped_prefix(r, u[0], u[1], u[2]); 28 return omega2_pairs(r, u[0], u[1], u[2], u[3]); 29 } 30 } // namespace 31 32 int main() { 33 const std::vector vs = { 34 {"floor_prefix", {9, 2}, 0, 20}, 35 {"capped_prefix", {9, 2, 3}, 0, 18}, 36 {"pairs", {3, 9, 2, 3}, 0, 16}, 37 {"pairs", {3, 9, 2, 0}, 0, 18}, 38 {"pairs", {0, 4096, 1, 512}, 0, `1966336`}, 39 {"floor_prefix", {`3037000499`, 1}, 0, `4611686016981624750`}, 40 {"capped_prefix", {`4611686018427387904`, 1, 2}, 0, `9223372036854775807`}, 41 {"floor_prefix", {`3037000500`, 1}, 1, 0}, 42 {"capped_prefix", {`4611686018427387905`, 1, 2}, 1, 0}, 43 {"capped_prefix", {0, `4294967296`, `2147483648`}, 1, 0}, 44 {"floor_prefix", {-1, 1}, 9, 0}, 45 {"floor_prefix", {5, 0}, 9, 0}, 46 {"pairs", {5, 3, 1, 0}, 9, 0}, 47 {"pairs", {0, 3, 1, -1}, 9, 0}, 48 }; 49 const uint64_t sentinel = 0x5a5a5a5a5a5a5a5aull; 50 check("ident: library == header", std::strcmp(omega2_ident_flops_pairs(), OMEGA2_IDENT_flops_pairs) == 0); 51 for (const V &x : vs) { 52 uint64_t r = sentinel; 53 const uint32_t st = call(x, &r); 54 std::string name = x.fn; 55 for (int64_t v : x.a) name += " " + std::to_string(v); 56 name += " -> status " + std::to_string(st); 57 check(name, st == x.status && (st == OMEGA_OK ? static_cast(r) == x.want : r == sentinel)); 58 } 59 check("null result refused 32", omega2_pairs(nullptr, 0, 3, 1, 0) == OMEGA_BAD_ARG); 60 return fails ? 1 : 0; 61 }