Skip to content

Update template argument names to not collide with Arduino names #11504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions drivers/internal/Task.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace events {
*/


template<typename F, typename A1 = void, typename A2 = void, typename A3 = void, typename A4 = void, typename A5 = void>
template<typename F, typename ARG1 = void, typename ARG2 = void, typename ARG3 = void, typename ARG4 = void, typename ARG5 = void>
struct AllArgs;

template<typename B0>
Expand Down Expand Up @@ -543,22 +543,22 @@ class Task<R()>: public TaskBase {
All _args;
};

template <typename R, typename A0>
class Task<R(A0)>: public TaskBase {
template <typename R, typename ARG0>
class Task<R(ARG0)>: public TaskBase {
public:

Task(TaskQueue *q = NULL, mbed::Callback<R(A0)> cb = mbed::Callback<R(A0)>())
Task(TaskQueue *q = NULL, mbed::Callback<R(ARG0)> cb = mbed::Callback<R(ARG0)>())
: TaskBase(q), _args(cb)
{
}

Task &operator=(mbed::Callback<R(A0)> cb)
Task &operator=(mbed::Callback<R(ARG0)> cb)
{
_args.b0 = cb;
return *this;
}

void call(A0 a0)
void call(ARG0 a0)
{
_args.b1 = a0;
post();
Expand All @@ -578,16 +578,16 @@ class Task<R(A0)>: public TaskBase {
}

private:
typedef AllArgs<mbed::Callback<R(A0)>, A0> All;
typedef AllArgs<mbed::Callback<R(ARG0)>, ARG0> All;
All _args;
};

/** Task
*
* Representation of a postable task
*/
template <typename R, typename A0, typename A1>
class Task<R(A0, A1)>: public TaskBase {
template <typename R, typename ARG0, typename ARG1>
class Task<R(ARG0, ARG1)>: public TaskBase {
public:

/**
Expand All @@ -596,7 +596,7 @@ class Task<R(A0, A1)>: public TaskBase {
* @param q TaskQueue to post to
* @param cb Callback to run
*/
Task(TaskQueue *q = NULL, mbed::Callback<R(A0, A1)> cb = mbed::Callback<R(A0, A1)>())
Task(TaskQueue *q = NULL, mbed::Callback<R(ARG0, ARG1)> cb = mbed::Callback<R(ARG0, ARG1)>())
: TaskBase(q), _args(cb)
{
}
Expand All @@ -606,7 +606,7 @@ class Task<R(A0, A1)>: public TaskBase {
*
* @param cb Callback to run
*/
Task &operator=(mbed::Callback<R(A0, A1)> cb)
Task &operator=(mbed::Callback<R(ARG0, ARG1)> cb)
{
_args.b0 = cb;
return *this;
Expand All @@ -623,7 +623,7 @@ class Task<R(A0, A1)>: public TaskBase {
* @param a0 First callback parameter
* @param a1 Second callback parameter
*/
void call(A0 a0, A1 a1)
void call(ARG0 a0, ARG1 a1)
{
_args.b1 = a0;
_args.b2 = a1;
Expand All @@ -644,7 +644,7 @@ class Task<R(A0, A1)>: public TaskBase {
}

private:
typedef AllArgs<mbed::Callback<R(A0, A1)>, A0, A1> All;
typedef AllArgs<mbed::Callback<R(ARG0, ARG1)>, ARG0, ARG1> All;
All _args;
};

Expand Down
26 changes: 13 additions & 13 deletions platform/FunctionPointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,37 @@ namespace mbed {

// Declarations for backwards compatibility
// To be foward compatible, code should adopt the Callback class
template <typename R, typename A1>
class FunctionPointerArg1 : public Callback<R(A1)> {
template <typename R, typename ARG1>
class FunctionPointerArg1 : public Callback<R(ARG1)> {
public:
MBED_DEPRECATED_SINCE("mbed-os-5.1",
"FunctionPointerArg1<R, A> has been replaced by Callback<R(A)>")
FunctionPointerArg1(R(*function)(A1) = 0)
: Callback<R(A1)>(function) {}
FunctionPointerArg1(R(*function)(ARG1) = 0)
: Callback<R(ARG1)>(function) {}

template<typename T>
MBED_DEPRECATED_SINCE("mbed-os-5.1",
"FunctionPointerArg1<R, A> has been replaced by Callback<R(A)>")
FunctionPointerArg1(T *object, R(T::*member)(A1))
: Callback<R(A1)>(object, member) {}
FunctionPointerArg1(T *object, R(T::*member)(ARG1))
: Callback<R(ARG1)>(object, member) {}

R(*get_function())(A1)
R(*get_function())(ARG1)
{
return *reinterpret_cast<R(* *)(A1)>(this);
return *reinterpret_cast<R(* *)(ARG1)>(this);
}

R call(A1 a1) const
R call(ARG1 a1) const
{
if (!Callback<R(A1)>::operator bool()) {
if (!Callback<R(ARG1)>::operator bool()) {
return (R)0;
}

return Callback<R(A1)>::call(a1);
return Callback<R(ARG1)>::call(a1);
}

R operator()(A1 a1) const
R operator()(ARG1 a1) const
{
return Callback<R(A1)>::call(a1);
return Callback<R(ARG1)>::call(a1);
}
};

Expand Down