View Single Post
Old 30 December 2013, 13:27   #26
FS-UAE Developer

FrodeSolheim's Avatar
Join Date: Dec 2011
Location: Førde, Norway
Age: 37
Posts: 3,427
While at I can just as well present a third options for argument passing. If the UAE interface layers knows the function signature, it could automatically byte-swap integer arguments if needed, and also resolve Amiga pointers to native pointers. It can also then dynamically build function parameters.

This can be done with a macro which exports a signature string for each function. Something like this:

UNIAPI("csll") void UNICALL add_numbers(struct uni *uni, uni_char *c,
uni_short *s, uni_long *l, uni_long *result) {
    *result = *c + *s + *l;
Pointers are used for all args here, could pass some parameters by value instead if the signature string indicates for each parameter pass by value or reference. After the function call, UAE would then reverse transformations on the parameters before returning to the Amiga caller.

A bit more work to implement (and the library writer must be careful when writing the function signature) but otherwise doable. This approach would work well in tandem with a param struct from the Amiga side - with struct members in the same order as the arguments to the native function.
FrodeSolheim is offline  
Page generated in 0.04110 seconds with 10 queries