File tree Expand file tree Collapse file tree 6 files changed +48
-8
lines changed
Expand file tree Collapse file tree 6 files changed +48
-8
lines changed Original file line number Diff line number Diff line change 1+ extern crate cbindgen;
2+
3+ use std:: path:: Path ;
4+
5+ fn main ( ) {
6+ let header_file = Path :: new ( "include" ) . join ( "kcl_ffi.h" ) ;
7+
8+ cbindgen:: generate ( "." )
9+ . expect ( "Unable to generate bindings" )
10+ . write_to_file ( header_file) ;
11+ }
Original file line number Diff line number Diff line change 1+ cpp_compat = true
2+ include_guard = " _KCL_FFI_H"
3+ language = " C"
4+ no_includes = true
5+ sys_includes = [" stdint.h" , " stddef.h" , " stdbool.h" ]
6+
7+ [parse ]
8+ include = [" kcl_ffi" ]
9+ parse_deps = true
Original file line number Diff line number Diff line change 11#include <kcl_lib.h>
22
3- int exec_file (const char * file_str ) {
3+ int exec_file (const char * file_str )
4+ {
45 uint8_t buffer [BUFFER_SIZE ];
56 uint8_t result_buffer [BUFFER_SIZE ];
67 size_t message_length ;
Original file line number Diff line number Diff line change 11#include <kcl_lib.h>
22
3- int ping (const char * msg ) {
3+ int ping (const char * msg )
4+ {
45 uint8_t buffer [BUFFER_SIZE ];
56 uint8_t result_buffer [BUFFER_SIZE ];
67 size_t message_length ;
Original file line number Diff line number Diff line change 1+ #ifndef _KCL_FFI_H
2+ #define _KCL_FFI_H
3+
4+ #include <stdint.h>
5+ #include <stddef.h>
6+ #include <stdbool.h>
7+
8+ #ifdef __cplusplus
9+ extern "C" {
10+ #endif // __cplusplus
11+
12+ uintptr_t call_native (const uint8_t * name_ptr ,
13+ uintptr_t name_len ,
14+ const uint8_t * args_ptr ,
15+ uintptr_t args_len ,
16+ uint8_t * result_ptr );
17+
18+ #ifdef __cplusplus
19+ } // extern "C"
20+ #endif // __cplusplus
21+
22+ #endif /* _KCL_FFI_H */
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ extern "C" {
1414#include <stddef.h>
1515#include <stdbool.h>
1616
17+ #include "kcl_ffi.h"
18+
1719#define BUFFER_SIZE 1024
1820
1921struct Buffer {
@@ -77,12 +79,6 @@ bool check_error_prefix(uint8_t result_buffer[])
7779 return false;
7880}
7981
80- uintptr_t call_native (const uint8_t * name_ptr ,
81- uintptr_t name_len ,
82- const uint8_t * args_ptr ,
83- uintptr_t args_len ,
84- uint8_t * result_ptr );
85-
8682#ifdef __cplusplus
8783} /* extern "C" */
8884#endif
You can’t perform that action at this time.
0 commit comments