Licence: This software is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages arising from the use of this software.
Topic | Description |
Index | Alphabetical list of all items. |
Callbacks | Allowing your functions to be called by pointer |
Calling Conventions | Information about the different calling conventions supported |
Calling functions | Calling other functions by pointer |
There are 3 different calling conventions supported by fptr.e:
func( 1, 2, 3 ) -- asm pseudocode -- push 3 -- push 2 -- push 1 -- call funcBoth stdcall and thiscall require the called function to clean up the stack (move the stack pointer above the arguments--whenever you push something onto the stack the stack pointer is decreased by 4, not increased), meaning that they should be able to know (at compile time) how many arguments are being passed. It is possible (in C/C++) to have functions that take variable arguments. Since the called function can't know how many arguments it will be passed, it cannot clean the stack, so the calling function must clean the stack.
ex:function my_function( atom a1, atom a2, atom a3, atom a4, atom a5, atom a6, atom a7, atom a8, atom ptr ) atom a9, a10 a9 = peek4u(ptr) a10 = peek4u(ptr+4) -- do stuff... return 0 end function my_callback = call_back_cdecl( routine_id("my_function"), 10 )
See Also: call_back_stdcall, call_back_thiscall
ex:function my_function( atom a1, atom a2, atom a3, atom a4, atom a5, atom a6, atom a7, atom a8, atom ptr ) atom a9, a10 a9 = peek4u(ptr) a10 = peek4u(ptr+4) -- do stuff... return 0 end function my_callback = call_back_stdcall( routine_id("my_function"), 10 )
See Also: call_back_cdecl, call_back_thiscall
Returns a callback address for the routine with id rid, and params parameters, not including the this pointer. The this pointer will be the first argument passed. Up to 8 parameters can be passed by value. If there are more than 8 parameters, the ninth parameter will be a pointer to the 8th through last parameters. Suppose you had a C++ function prototype:
int theClass::theMember( int x1, int x2, , int x3, int x4, int x5, int x6, int x7, int x8, int x9 )-- then your Euphoria function should look like: function theClass_theMember( atom this, atom x1, atom x2, atom x3, atom x4, atom x5, atom x6, atom x7, atom ptr) atom x8, x9 x8 = peek4s( ptr ) x9 = peek4s( ptr + 4 ) -- do stuff end function theClass_theMember_callback = call_back_thiscall( routine_id("theClass_theMember"), 9 )
See Also: call_back_cdecl, call_back_stdcall
Calls a function using stdcall Use this to call a function using the stdcall calling convention when you have a pointer to the function. This is the most common calling convention in Linux. You can get the pointer to a function in a .dll or .so using define_c_var() instead of define_c_func(). You should discard the return value if you call a routine that does not return a value.
See Also: call_stdcall, call_thiscall
Calls a function using stdcall Use this to call a function using the stdcall calling convention when you have a pointer to the function. This is the most common convention in Windows. You can get the pointer to a function in a .dll or .so using define_c_var() instead of define_c_func(). You should discard the return value if you call a routine that does not return a value.
See Also: call_cdecl, call_thiscall
See Also: call_cdecl, call_stdcall
func
] func
] Allowing your functions to be called by pointerfunc
] func
] Calls a function using cdeclfunc
] Calls a function using stdcallfunc
]
]