Merge branch 'pu-fix-blocking-sm-calls' into next
operations: force user to set the caller when collecting is done.

In order to save users from debugging deadlocks, force them to declare the
caller when using collect(), directly or indirectly. Does not influence send()

Signed-off-by: Peter Soetens <peter@thesourceworks.com>
corba: update to new SendStatus enum which contains CollectFailure

Signed-off-by: Peter Soetens <peter@thesourceworks.com>
corba: explicitly provide GlobalEngine::Instance when calling operations

This fixes calling operations after dc81be1

Operations now must have an explicit engine assigned, but the CORBA
layer was still passing the NULL engine (which was defaulting to
GlobalEngine()).
operations: add const qualifier in collect family of functions

There was no need to have this non-const. non-const prevented us
to use it on a const& to a SendHandle, which we do need if the
SendHandle is presented by a DataSource.

Signed-off-by: Peter Soetens <peter@thesourceworks.com>
scripting: add support for .cmd() semantics in scripting

This script introduces two changes to scripting:

1. It rearranges the ActionInterface::readArguments/execute/reset semantics
when mapped to DataSource::evaluate/rvalue/reset functions. This had some
influence on the flow of executing (remote) operations, but all cases have been
rectified.

2. It adds to the parser a look for '.cmd' suffix on operation calls,
 which is similar to '.send', but yields the script execution until
the send returns something else than SendNotReady. The result of a .cmd
call is a SendStatus which can be read/used by the script itself.

This has been tested on C++ operations and exported script functions.
'cmd' called operations will not update their arguments when SendSuccess is
returned and the return value of the operation is ignored.

Signed-off-by: Peter Soetens <peter@thesourceworks.com>
Fixed the .cmd() syntax to also work in state machine scripts.

Since a condition edge now waits on the result of a collect
datasource, that datasource needs to implement copy/clone
semantics properly, such that when copying the state machine,
we keep referencing the correct datasource.

This patch also adds support for var SendStatus ss = foo.cmd()
in which case, the initialisation of the var is delayed until
the cmd result is known (identical behavior to:
var SendStatus ss;
ss = foo.cmd();
)

Signed-off-by: Peter Soetens <peter@thesourceworks.com>
Introduce .cmd() and .send() syntax for exported script functions

This patch adds .cmd() and .send()+collectIfDone() syntax for an exported script function
just like for a C++ operation. The patch consists of 3 parts:

1. Cleanup in CmdFunction and CallFunction : removed unused variables
2. Adding logic into the ExpressionParser to detect the case of script functions.
   Since they don't have true SendHandle objects and use SendStatus datasources,
   the parser needs to re-arrange some data sources when handling a 'SendHandleAlias'.
   The SendHandle of a script function is effectively the alias to the .send() function,
   + that a .reset() is not forwarded. Evaluating a SendHandle of a script function is
   the same as writing sh.collectIfDone().
3. Added unit tests in state_test to test all these cases.

I also removed a deprecated warning in the ScriptngService

Signed-off-by: Peter Soetens <peter@thesourceworks.com>
scripting: fixed segfault in CmdFunction::reset() if the engine is already gone

This is related to 00b26794c31051b6710ccf7bad1ea393a9ebb6ca in CallFunction.hpp.

Signed-off-by: Johannes Meyer <johannes@intermodalics.eu>
scripting: fix .send() bug when using a SendHandle for exported script functions

We noticed that a send() on a script function did not work when
the return value was stored in a SendHandle. The reason was that the
SendHandleAlias was stored as an Attribute, but can't be instantiated
(since its an alias to a FusedFunctorDataSource), hence, it copied
all arguments, prior to giving the arguments a chance to instantiate.
so this send() then used copies that weren't used later on...
We now remove the SendHandleAlias from the StateMachineService such
that they are removed before instantiation happens. We only need them
during parsing as attributes, not during execution.

Signed-off-by: Ruben Smits <ruben.smits@intermodalics.eu>
scripting: fixed the operation.call() syntax

Without this patch calling operation task.foo with .call() ended up with a
```
Service or Task "task" has no Peer or Service foo (or task was not found at all).
```
error message.

I also eliminated some compiler warnings due to signed/unsigned comparisons.

Signed-off-by: Johannes Meyer <johannes@intermodalics.eu>
extras: fixed blocking trigger() calls on FileDescriptorActivities if the step() function takes too long

A pipe in Linux seems to have a limited buffer size of 65536 bytes. Every trigger() has written a command byte to
the pipe to wakeup the thread and the loop() function empties the command before each step() invocation. For the
case the step takes too long, commands could queue up and after the pipe is full the write() system call has
blocked the thread that triggered the FileDescriptorActivity.

This patches makes the command pipe non-blocking and adds additional flags to the FileDescriptorActivity to make
sure that we never miss a command event even if the queue was full.

Signed-off-by: Johannes Meyer <johannes@intermodalics.eu>
scripting: disable events in StateMachine::deactivate() and add mutex protection to StateMachine::activate()

Signed-off-by: Johannes Meyer <johannes@intermodalics.eu>