• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ucode/tests/custom/17_lib_ffi/14_wrap

  1 The `ffi.C.wrap()` function creates callable wrappers around C function pointers.
  2 
  3 Wrap a C function and call it.
  4 
  5 -- Testcase --
  6 {%
  7 import * as ffi from 'ffi';
  8 
  9 let strcmp = ffi.C.wrap('int strcmp(const char *, const char *)');
 10 let result = strcmp("hello", "hello");
 11 
 12 print("strcmp result: ", result, "\n");
 13 -- End --
 14 
 15 -- Expect stdout --
 16 strcmp result: 0
 17 -- End --
 18 
 19 
 20 Wrap getpid function.
 21 
 22 -- Testcase --
 23 {%
 24 import * as ffi from 'ffi';
 25 
 26 let getpid = ffi.C.wrap('int getpid(void)');
 27 let pid = getpid();
 28 
 29 print("pid type: ", type(pid), "\n");
 30 -- End --
 31 
 32 -- Expect stdout --
 33 pid type: int
 34 -- End --
 35 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt