238 views
in GUI Development by
I want to get multiple return values from an intrinsic module function. How can i pass them back to the EW?

Kind regards Jonas

1 Answer

0 votes
by
 
Best answer

Hello Jonas,

no, it is not possible. Due to its platform independence, Chora does not support pointers and it does not permit returning multiple values from a method except when the values are stored in an object and the object is returned. Intrinsics, on the other side, can't access objects nor create them. The approach with objects is thus not applicable in case of Intrinsics.

The unique possibility is to use dedicated functions in the Intrinsic module to peek the values individually, e.g. GetValue1(), GetValue2(), etc. In such case the Intrinsic functions cover the data members you originally wanted to access directly via pointer. This approach can be combined with the data type handle. In this case, the Intrinsic module can allocate some data structure. The pointer to the structure can be returned from the Intrinsic module as handle value. In order to access the data members within the corresponding structure you pass the handle value to the Intrinsic functions.

For example, you could implement an Intrinsic module containing following functions:

// The Intrinsic module allocates some data structure, fills it with data,
// etc. and returns the pointer to the structure as 'handle' value.
handle GetSomeData( void )

// The memory used for the data structure represented by 'handle' value
// is freed.
void FreeSomeData( handle aSomeData )

// Obtain some 'int32' value 1 from the data structure represented by the
// 'handle' value.
int32 GetSomeDataValue1( handle aSomeData )

// Obtain some 'string' value 2 from the data structure represented by the
// 'handle' value.
string GetSomeDataValue2( handle aSomeData )

...

// Obtain some 'rect' value N from the data structure represented by the
// 'handle' value.
rect GetSomeDataValueN( handle aSomeData )


I hope it helps you further.

Best regards

Paul Banach

by
Thank you for the detailed explanation. This helps me further.

Embedded Wizard Website | Privacy Policy | Imprint

...