Calling a function by hand

From: William Egge (remove_pro_remove_at_eggcentric.com)
Date: 12/08/04

  • Next message: Avatar Zondertau: "Re: Calling a function by hand"
    Date: Wed, 8 Dec 2004 11:39:13 -0500
    
    

    Hello,

    I wanted to get some advice before starting a little project.

    I need to call a function at runtime but the number of arguments and their
    types, and the pointer to the function are not known until runtime.

    So, I need to call a function and pass the parameters "by hand" rather than the
    compiler doing it at compile time.

    I was going to create a procedure that accepts the function pointer and a
    variant open array, like the function Format('', []) does. Then I was going to
    call the function and pass the parameters.

    I know there are different calling conventions, stdcall, cdecl, etc... I assume
    that I will be able to call the function correctly if I know its calling
    convention and its parameters. The variant array will tell me what the parameter
    types are.

    The end resulting procedure I imagine is
    procedure CallFunction(AFunction: Pointer; Args: array of const);

    I want this to be able to call functions in C, C++, and Delphi. I may also want
    to call an object method in Delphi or C++.

    The possibility of getting return results, and var params might be necessary.

    What advice can you give me?

    William Egge
    http://www.eggcentric.com


  • Next message: Avatar Zondertau: "Re: Calling a function by hand"

    Relevant Pages

    • Re: pointer( array ) <- invalid typecast BLEH
      ... > (except when the array is empty, in which case the latter is an error). ... I wrote a little program that demonstrates the "problems" with delphi arrays ... StaticBuffer in C means the address of the first character of the buffer. ... (there is no pointer! ...
      (alt.comp.lang.borland-delphi)
    • Re: How many string types?
      ... dynamic array of both. ... pointer to array of both, ... open array shortstring. ... And then people say Delphi is a clean language because it is Pascal :-) ...
      (comp.lang.pascal.delphi.misc)
    • Re: Faster way?
      ... Function rc is pixel function in delphi to get colors. ... I am using g32 library and rc function is just pointer to array of 32 bit ... rounds and move i have pretty fast interpolation, ...
      (borland.public.delphi.language.basm)
    • Re: Changing elements in dynamic array
      ... As someone pointed out this is an open array not a dynamic array. ... TBytes = array of bytes; ... What does Delphi do: ... It pushes two things a pointer and a length. ...
      (alt.comp.lang.borland-delphi)
    • Re: char **argv & char *argv[]
      ... "pointer to pointer to char". ... >> pointer)) pointing to the first element of an array. ... so we have to start adding more context. ... type "pointer to char", rather than "array MISSING_SIZE of char". ...
      (comp.lang.c)