Questions tagged [ffi]

A foreign function interface (FFI) is a mechanism for one language to interact with software written in another language.

1778 questions
0
votes
1 answer

FFI Metatype : "cannot change a protected metatable"

If a script uses ffi.metatype and crashes unexpectedly,the next script startup produces this error : “cannot change a protected metatable”,this makes debugging real hard as I have to restart my game each time,any way to circumvent this? Here’s a…
0
votes
0 answers

How can rust safely drop a cpp array through FFI?

I have a array T* which is created like the following T* array = new T[len]; // Some initialization codes We know we can delete the array like delete [] array; However, I am writing a Rust FFI program with C++. I have sent this array pointer to…
calvin
  • 2,125
  • 2
  • 21
  • 38
0
votes
0 answers

How can I include C with dependencies in Rust?

I want to use C code which depends on babeltrace2 in Rust. For now I have in my main.rs, where prepare_graph is a custom C function: #[link(name = "bt_util", kind = "static")] extern "C" { fn prepare_graph( ctf_directory: *const…
0
votes
0 answers

Callback function's byte parameter has value out of bounds in project Panama function interface

I'm using the new Foreign function & memory API which is part of project Panama and available in preview in JAVA 19. This is the complete callback function public static byte addFive(byte t) { Byte test = (Byte) t; return (byte)…
Tristan
  • 2,000
  • 17
  • 32
0
votes
1 answer

Rust FFI OpenSSL Vec UTF Encoding

Searched all over on this. When using Rust openssl crate is it possible to return the encrypted Vec as a UTF-8 string or does the PKCS1 padding prevent this indefinitely? I would be sending the encrypted data back to the user from a .NET/C# Web in a…
0
votes
1 answer

Cannot install FFI library for Lua/LuaJIT

I have already correctly installed Lua, LuaJIT and Luarocks (I can run each of them in the terminal without any errors too). I'm trying to run the command luarocks install luaffi but it is returning an error Error: No results matching query were…
refrain
  • 51
  • 7
0
votes
1 answer

How to drop an array of T by its length and *mut T?

Please do not mark the question as duplicate of casting *mut u8 to &[u8] without std. I need a review of my idea. Let me introduce the context of this question. Consider the following C++ code, in order to drop the array of pointers, we need to void…
calvin
  • 2,125
  • 2
  • 21
  • 38
0
votes
0 answers

the cdef() gets definition of struct but the wrapper still throws ffi.error of undefined struct/union name

I have a problem in a bigger project but I managed to isolate it into a smallest possible example. Please take a look. The def.c file that contains a definition of a struct typedef struct { unsigned char data[64]; } somestruct; a build.py file…
Marek
  • 1,413
  • 2
  • 20
  • 36
0
votes
1 answer

Dart plugin dynamic linking

I am having trouble utilising the libserialport.dart package. I have put a libserialport.so in the root of the project. When trying to run an application I get the following error: Unhandled exception: Invalid argument(s): Failed to load dynamic…
0
votes
1 answer

Apple Event object property hasAlarms returning incorrect boolean value

I am attempting to wrap a number of EkEventkit objective-c commands using Livecode Builder using its Foreign Function Interface (FFI). I have created a library for use by Livecode Script but when run the Event property "hasAlarms" returns true on…
0
votes
1 answer

Most appropriate type for opaque extern static in Rust?

I want to obtain a raw pointer to an FFI-defined static, whose concrete type is opaque to Rust. This is what I currently have: use std::{ffi::c_void, ptr::addr_of}; fn ptr_to_foo() -> *const c_void { extern "C" { static FOO: /* what…
eggyal
  • 122,705
  • 18
  • 212
  • 237
0
votes
0 answers

Rust to Python FFI erroring with "invalid pointer"

I'm building a Rust to python FFI using libc and I am encountering a "invalid pointer" error. On the python side of things, I'm doing: print(CDLL("./libshared.so").print_stuff(c_char_p("test".encode("utf-8")), 4)) ...which does print the intended…
DevComp
  • 11
  • 7
0
votes
0 answers

How to use SetProgressValue in Flutter

I'm trying to us ITaskbarList3::SetProgressValue() in my Flutter App like this: Get the hWnd (thanks to Kirill): final user32 = DynamicLibrary.open('user32.dll'); final findWindowA = user32.lookupFunction< Int32 Function(Pointer
rekire
  • 47,260
  • 30
  • 167
  • 264
0
votes
0 answers

Ability to access Dart class from native code

I am in the process of migrating from Android/JNI to Flutter/Dart/FFI to build native apps. Currently in Android I have a Java class (ScanningHelper.java) which is modified during the program lifecycle. During native initialization, I send a jobject…
banerjk
  • 335
  • 2
  • 15
0
votes
2 answers

Open file in haskell, passing filepath in C FFI call (CString)

I want to open a file in Haskell, but I want the top level function to be called from C (I want to pass the filepath from C). I'm having trouble getting the filepath CString into a type that I can use readFile on. Here's my first attempt, adapting…
Aidenhjj
  • 1,249
  • 1
  • 14
  • 27