array of const for C++Builder

Top  Previous  Next

What is translated > Array parameters > array of const > array of const for C++Builder

 

 

For C++Builder the value of an array of const is represented by two values: a pointer to a TVarRec and the index of the last element of the array, which begins at the position which the pointer points to.

 

 

procedure foo(Args : array of const);

 

->

 

void __fastcall foo (  TVarRec* Args, const int Args_Size );

 

 

When such a functions is called with a set as argument, the macro ARRAYOFCONST is used into the C++ output.

 

foo(['hello', 'world']);   ->  foo (  ARRAYOFCONST(( "hello", "world" )) );

 

This macro is defined for the C++Builder  as:

 

#define ARRAYOFCONST(values) 

OpenArray<TVarRec>values, 

OpenArrayCount<TVarRec>values.GetHigh()

 

 

The class OpenArray<TVarRec> is constructed in a manner, that it's address is equal to the pointer TVarRec* used in the signature of foo above.



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content