Unfortunately, it is very difficult to infer the parameters of
function-objects generically in C++03 without any additional type
information. The current implementation fails to do so, and the compiler
simply bails with "unable to deduce template parameter".
Rather than leaving the user with a small novel of error messages, this
patch removes the problematic callback overloads, leaving only callback
overloads for the original pointer types.
Added mbed-events from https://github.com/ARMMbed/mbed-events. Changes
from upstream:
- the whole code is licensed under the Apache license. Sources and
headers were updates with this information.
- removed the porting layers for Windows and FreeRTOS and the references
to these porting layers in equeue_platform.h.
- moved the TESTS directory in mbed-events to the TESTS directory of
mbed-os.
* Application has been using MBED_MESH_API_6LOWPAN_ND_SECURITY_MODE as the macro to define Secuity mode.
* The fall back mechanism, in case of absence of neo or yotta macro definition, was setting the macro to
be yotta format which was not used at all in the application.
* The bug was fixed by changing YOTTA_CFG_MBED_MESH_API_6LOWPAN_ND_SECURITY_MODE to
MBED_MESH_API_6LOWPAN_ND_SECURITY_MODE in the fall back mechanism.
This functionality was already present in the ARM toolchain script, but
this commit adds this across all toolchain scripts. Solves an issue that
cropped up where a build error wasn't being printed unless the verbose
flag was used. This should now print any existing error messages that have
been printed when the compiler output is being parsed.
Previously, when building tests with test.py, if an exception occurred, the
error message would be masked by the function 'build_tests'. This commit
handles NotSupportedExceptions and ToolExceptions, but lets all other
Exceptions propigate up to the caller function. In most cases, this is the
CLI scripts, which will print a traceback. This will allow us to better
debug the python tools if errors occur.
The callback class can now accept generalized function-objects:
class Thing {
public:
int value;
void operator()() {
printf("hi! %d\n", value);
}
};
Callback<void()> cb(Thing(2));
However, with the intention of avoiding implicit dynamic-memory
allocations, the Callback class is limited to a single word of storage.
Exceeding this size will eliminate the function-object type from the
overload set and fail to compile.
Effort was invested to make this situation very clear to the user. Here
is an example error message with noise removed:
[ERROR] ./main.cpp: In function 'int main()':
./mbed-os/hal/api/Ticker.h:101:10: note:
no known conversion for argument 1 from 'BigFunc' to 'mbed::Callback<void()>'
The real benefit of this change is the ability for users to hook into
the attributes of the Callback class. This mostly allows lifetime
management of the function-objects from third-party libraries (such as
the Event class from mbed-events).
Note: The convenient `callback` function may become ambiguous if
provided with a type that defines multiple incompatible `operator()`
member functions.
This allows additional attributes to be attached to the internally
generated type such as move and destructor operations with no increase
in RAM footprint.
The current overloads can't take advantage of this, but it does open
the possibility for more powerful overloads that can provide these
additional attributes.
Changes to mbed-os memory consumption:
.text .data .bss
before 57887 2292 7692
after 57842 2292 7691
This change is not located in the hal because SDK v10 is not available from this
place. It is safe to provide the implementation in BLE because the SDK V10 is
defined there. Default implementations of critical section enter/exit are safe
as long as the softdevice is not used.