aboutsummaryrefslogtreecommitdiff
path: root/integration
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-04-30 05:57:25 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-04-30 05:57:25 -0700
commit7e6fe52c4687ad2417364bf603cc3d7d3bdce6fa (patch)
tree8b27716897a705808501347c9375bd1c3a90033b /integration
parent893d245dcabd540199e0b900d850677cf3896569 (diff)
downloadbun-7e6fe52c4687ad2417364bf603cc3d7d3bdce6fa.tar.gz
bun-7e6fe52c4687ad2417364bf603cc3d7d3bdce6fa.tar.zst
bun-7e6fe52c4687ad2417364bf603cc3d7d3bdce6fa.zip
Update ffi-test.c
Diffstat (limited to 'integration')
-rw-r--r--integration/bunjs-only-snippets/ffi-test.c59
1 files changed, 35 insertions, 24 deletions
diff --git a/integration/bunjs-only-snippets/ffi-test.c b/integration/bunjs-only-snippets/ffi-test.c
index 07a477cc0..850ba3ef7 100644
--- a/integration/bunjs-only-snippets/ffi-test.c
+++ b/integration/bunjs-only-snippets/ffi-test.c
@@ -58,21 +58,18 @@ uint16_t add_uint16_t(uint16_t a, uint16_t b);
uint32_t add_uint32_t(uint32_t a, uint32_t b);
uint64_t add_uint64_t(uint64_t a, uint64_t b);
-uint16_t returns_42_uint16_t() { return 42; }
-uint32_t returns_42_uint32_t() { return 42; }
-uint64_t returns_42_uint64_t() { return 42; }
-
-int8_t returns_neg_42_int8_t() { return -42; }
-int16_t returns_neg_42_int16_t() { return -42; }
-int32_t returns_neg_42_int32_t() { return -42; }
-int64_t returns_neg_42_int64_t() { return -42; }
-
-bool returns_true() { return true; }
bool returns_false() { return false; }
-
+bool returns_true() { return true; }
char returns_42_char() { return '*'; }
-float returns_42_float() { return 42.42f; }
double returns_42_double() { return (double)42.42; }
+float returns_42_float() { return 42.42f; }
+int16_t returns_neg_42_int16_t() { return -42; }
+int32_t returns_neg_42_int32_t() { return -42; }
+int64_t returns_neg_42_int64_t() { return -42; }
+int8_t returns_neg_42_int8_t() { return -42; }
+uint16_t returns_42_uint16_t() { return 42; }
+uint32_t returns_42_uint32_t() { return 42; }
+uint64_t returns_42_uint64_t() { return 42; }
uint8_t returns_42_uint8_t() { return (uint8_t)42; }
char identity_char(char a) { return a; }
@@ -87,6 +84,7 @@ uint16_t identity_uint16_t(uint16_t a) { return a; }
uint32_t identity_uint32_t(uint32_t a) { return a; }
uint64_t identity_uint64_t(uint64_t a) { return a; }
bool identity_bool(bool ident) { return ident; }
+void *identity_ptr(void *ident) { return ident; }
char add_char(char a, char b) { return a + b; }
float add_float(float a, float b) { return a + b; }
@@ -109,15 +107,28 @@ void *ptr_should_point_to_42_as_int32_t() {
bool does_pointer_equal_42_as_int32_t(int32_t *ptr);
bool does_pointer_equal_42_as_int32_t(int32_t *ptr) { return *ptr == 42; }
-bool cb_identity_false(bool (*cb)()) { return cb(); }
-char cb_identity_42_char(char (*cb)()) { return cb(); }
-float cb_identity_42_float(float (*cb)()) { return cb(); }
-double cb_identity_42_double(double (*cb)()) { return cb(); }
-uint8_t cb_identity_42_uint8_t(uint8_t (*cb)()) { return cb(); }
-int8_t cb_identity_neg_42_int8_t(int8_t (*cb)()) { return cb(); }
-uint16_t cb_identity_42_uint16_t(uint16_t (*cb)()) { return cb(); }
-uint32_t cb_identity_42_uint32_t(uint32_t (*cb)()) { return cb(); }
-uint64_t cb_identity_42_uint64_t(uint64_t (*cb)()) { return cb(); }
-int16_t cb_identity_neg_42_int16_t(int16_t (*cb)()) { return cb(); }
-int32_t cb_identity_neg_42_int32_t(int32_t (*cb)()) { return cb(); }
-int64_t cb_identity_neg_42_int64_t(int64_t (*cb)()) { return cb(); } \ No newline at end of file
+
+void *return_a_function_ptr_to_function_that_returns_true();
+void *return_a_function_ptr_to_function_that_returns_true() {
+ return (void *)&returns_true;
+}
+
+bool cb_identity_true(bool (*cb)()) {
+ printf("The memory address is: %p\n", cb);
+ printf("The memory address should be %p\n", &returns_true);
+ bool ran = cb();
+ printf("The result is : %d\n", ran);
+ return ran;
+}
+bool cb_identity_false(bool (^cb)()) { return cb(); }
+char cb_identity_42_char(char (^cb)()) { return cb(); }
+float cb_identity_42_float(float (^cb)()) { return cb(); }
+double cb_identity_42_double(double (^cb)()) { return cb(); }
+uint8_t cb_identity_42_uint8_t(uint8_t (^cb)()) { return cb(); }
+int8_t cb_identity_neg_42_int8_t(int8_t (^cb)()) { return cb(); }
+uint16_t cb_identity_42_uint16_t(uint16_t (^cb)()) { return cb(); }
+uint32_t cb_identity_42_uint32_t(uint32_t (^cb)()) { return cb(); }
+uint64_t cb_identity_42_uint64_t(uint64_t (^cb)()) { return cb(); }
+int16_t cb_identity_neg_42_int16_t(int16_t (^cb)()) { return cb(); }
+int32_t cb_identity_neg_42_int32_t(int32_t (^cb)()) { return cb(); }
+int64_t cb_identity_neg_42_int64_t(int64_t (^cb)()) { return cb(); } \ No newline at end of file
20:21:02 +0000'>2022-05-12[ci] formatGravatar matthewp 1-85/+78 2022-05-12Fixed search bar of the docs example not working (#3247)Gravatar Rafid Muhymin Wafi 1-76/+94 * fixed search bar not working * fixed search bar not working during build * fix search bar throwing error on production site 2022-05-12Add config option customPages (#3315)Gravatar Eloi-Perez 1-0/+14 * Add config option customPages Add config option customPages to be able to add custom URL pages to the sitemap.xml * add comment to document customPages option 2022-05-12fix: vite types (#3352)Gravatar Juan Martín Seery 4-5/+16 * Re-export vite types and added them to zod schema * Removed casted typed * Changeset 2022-05-12[ci] update lockfile (#3287)Gravatar Fred K. Schott 33-1038/+1096 * [ci] update lockfile * chore: fix lockfile * fix: pin turbo Co-authored-by: FredKSchott <FredKSchott@users.noreply.github.com> Co-authored-by: Nate Moore <nate@skypack.dev> 2022-05-12[ci] formatGravatar matthewp 2-2/+2 2022-05-12add error hints (#3350)Gravatar Fred K. Schott 3-0/+19 * add error hints * chore: add changeset Co-authored-by: Nate Moore <nate@skypack.dev> 2022-05-12[ci] formatGravatar matthewp 2-10/+6 2022-05-12Fix: React - Use "createRoot" instead of "hydrateRoot" for `client:only` (#3337)Gravatar Ben Holmes 4-22/+34 * feat: pass "client" directive to clientEntrypoints * refactor: remove hydration warning suppression react 17 * feat: remove hydration warning suppression react 18 * chore: changeset * fix: change metadata to options bag 2022-05-12[ci] formatGravatar matthewp 1-2/+8 2022-05-12Resolve components by module ID during compilation (#3300)Gravatar Tony Sullivan 22-41/+407 * WIP: adding test coverage * test fixes * moving the shared lib up a directory to reproduce the bug * fix: transform with the module ID instead of parsing the filepath * adding the shared lib to the workspaces list * fix: client-only assets now get the full URL from vite * why is this needed for windows? * WIP: using /@fs to handle windows filepaths * fix: remove /@fs from hoisted script imports * nit: removing unused imports * fix: strip off the path root when mapping client:only styles * had to reverse the `/@fs` handling to work on windows and unix * chore: adding comments to explain the fix * chore: adding changeset 2022-05-12[ci] collect statsGravatar FredKSchott 1-0/+1 2022-05-11Exclude `node-fetch` from vite.optimizeDeps (#3348)Gravatar Nate Moore 2-0/+6 * fix: exclude `node-fetch` from vite.optimizeDeps * chore: format 2022-05-11fix: updated blog template with existing address (#3312)Gravatar Gautier Ben Aïm 1-2/+2 2022-05-11refactor(vercel): Build Output API v3 (#3216)Gravatar Juan Martín Seery 42-231/+659 * Removed ignores * Migration to v3 * More changes * Remove legacy redirects * Fail when there is no ENABLE_VC_BUILD * Fix edge * Updated readme * Changeset * Added static mode * Updated documentation * Updated shim * Made edge work! * Updated changeset * Ensure empty dir * Fixed redirects for dynamic paths * Removed extra declaration * Splited imports * Updated readme * Fixed some urls * Deprecated shim! * [test]: Vercel NFT * Beautify * Edge bundle to node 14.19 Vercel runs 14.19.1 (I've checked it manually) * Re-added shim (#3304) * Added `node:` prefix * Use the same bundling as Deno for Edge * Remove esbuild * Fixed shim * Moved nft * Updated changeset * Added note about Edge * fix typo * Added support for Node 16 (vercel/vercel#7772) 2022-05-11Fix APIRoute type (#3344)Gravatar Matthew Phillips 3-11/+8 * Fix APIRoute type * Adds a changeset * Update usage of the two API route signatures 2022-05-11[create-astro] Finalize developer experience... with gradients 🚀 (#3313)Gravatar Ben Holmes 5-23/+123 * wip: port gradient helpers from sandbox ideas * feat: wire up rocket gradient 🚀 * feat: wire up rocket gradient on install step * refactor: update "next steps" wording * deps: add chalk (for rendering gradient) * chore: changeset * chore: clean up sstray template string