Delphi call JNI methods with variable argument list

后端 未结 1 864
我在风中等你
我在风中等你 2021-01-21 23:19

Using Embarcadero\'s Jni api unit, how does one supply variable argument lists to the JNI methods that require it? For example, the CallStaticObjectMethodV() method of the JNINa

相关标签:
1条回答
  • 2021-01-22 00:00

    The va_list needs to point to a block of memory that matches what would be pushed onto the stack if you had instead called a variadic function.

    The usual implementation of va_start simply yields the address of the location on the stack where the variadic arguments were pushed.

    #define va_start(ap, parmN) ((void)((ap) = (va_list)((char _FAR *)(&parmN)+__size(parmN)))) 
    

    So your attempt to make an array containing the arguments, and use that as your va_list ought to work. Perhaps you've given up on it too hastily? Perhaps instead of:

    Move( Str1, Data[0], Sz);
    Move( Str1, Data[Sz], Sz);
    

    you meant

    Move( Str1, Data[0], Sz);
    Move( Str2, Data[Sz], Sz);
    

    Although personally I'd opt for a array of JNIString rather than a byte array.

    So perhaps your approach to create the va_list is fine, but the failure is caused by an error elsewhere.

    0 讨论(0)
提交回复
热议问题