Calling inline functions

Ty Young youngty1997 at gmail.com
Mon Apr 20 14:44:04 UTC 2020


That's disappointing. Instead of jextract, could it be added into the 
core API somehow?


On 4/20/20 8:25 AM, Maurizio Cimadamore wrote:
> Inline functions do not exist in the .so/.dll/.dynlib file. They are 
> essentially function-like macros, expanded by the compiler whenever 
> they are used.
>
> If you want to call them using the current support you need to create 
> your own C library wrapper which exposes the additional symbol (as a 
> regular function) and then calls the corresponding inline function. 
> Then you extract your header (which will also include the original 
> header you wanted to work on) with jextract.
>
> In the future we might automate support for function-like macro a 
> little, by providing jextract API plugins which generate the correct 
> plumbings.
>
> Maurizio
>
> On 20/04/2020 13:34, Ty Young wrote:
>> Is calling inline functions supported right now? I'm trying to call 
>> this function:
>>
>>
>> __attribute__((always_inline)) static inline int 
>> internal_load_libgamemode(void)
>>
>>
>> with:
>>
>>
>> this.address = 
>> gamemode_client_h.LIBRARY_LOOKUP.lookup("internal_load_libgamemode");
>>
>> this.descriptor = FunctionDescriptor.of(MemoryLayouts.C_INT);
>>
>> this.type = MethodType.methodType(int.class);
>>
>> this.handle = 
>> Foreign.getInstance().getSystemABI().downcallHandle(this.address, 
>> this.type, this.descriptor);
>>
>>
>> ...but it fails saying the symbol doesn't exist. Is there a way to 
>> call it?
>>
>>
>> Full header: 
>> https://github.com/FeralInteractive/gamemode/blob/master/lib/gamemode_client.h
>>
>>


More information about the panama-dev mailing list