Hello Jonas,
assuming, the slots are stored in the Init() method and you don't forget to release any of the stored slots in the Done() method, the approach can work. However please note the limitation of this approach for the target system only. If you plan to use this functionality also in the Prototyper using own implemented Prototyper extensions (so-called Intrinsic Modules), this will not work. Intrinsic Modules can't use the Runtime Environment functionality of the Prototyper.
For the case you want to use this functionality in the target system only, then following would help you:
1. To store a slot in C code, declare the corresponding variables with the type XSlot. Its default value should be {0,0}. For example:
XSlot someSlot = { 0, 0 };
2. In the Init() method you can initialize the variable with a slot. For example:
$if !$prototyper
// Get a reference to a slot method
var slot theSlot = SlotMethod;
// In native code store the slot reference in a C variable
native ( theSlot )
{
extern XSlot someSlot;
someSlot = theSlot;
}
$endif
3. In the Done() method reset the C variable to be NULL again. In this case you can use the global EwNullSlot constant and assign it to the variable:
$if !$prototyper
// In native code reset the slot reference.
native
{
extern XSlot someSlot;
someSlot = EwNullSlot;
}
$endif
4. In your middleware (or whenever it is appropriate) you send a signal to the slot by using the function EwSignal(), EwPostSignal() or EwIdleSignal() (similar to the Chora statements signal, postsignal and idelsignal). For example:
// 'postsignal' to the slot stored in the variable 'someSlot'.
// Sender object is NULL.
EwPostSignal( someSlot, 0 );
Since this approach is beyond what we recommend, there is no official documentation for the above data types and functions. For more details you have to search in ewrte.h file from the build environment for those declarations.
I hope it helps you further. Don't forget to always correctly disconnect the slots or very difficult to find runtime errors will occur.
Best regards
Paul Banach