Skip to content

Commit 5bc8761

Browse files
committed
mbed - Moved to explicit using statements per class
This avoids revealing the entire mbed namespace, allowing less-unique names to be used behind the mbed namespace. Additionally this adds an extra step to introducing new names into the global namespace.
1 parent b2ce50a commit 5bc8761

File tree

8 files changed

+105
-38
lines changed

8 files changed

+105
-38
lines changed

features/net/network-socket/Socket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class Socket {
177177
template <typename T, typename M>
178178
MBED_DEPRECATED_SINCE("mbed-os-5.1",
179179
"The attach function does not support cv-qualifiers. Replaced by "
180-
"attach(callback(obj, method)).")
180+
"attach(mbed::callback(obj, method)).")
181181
void attach(T *obj, M method) {
182182
attach(mbed::callback(obj, method));
183183
}

hal/api/CallChain.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ class CallChain {
9191
*
9292
* @deprecated
9393
* The add function does not support cv-qualifiers. Replaced by
94-
* add(callback(obj, method)).
94+
* add(mbed::callback(obj, method)).
9595
*/
9696
template<typename T, typename M>
9797
MBED_DEPRECATED_SINCE("mbed-os-5.1",
9898
"The add function does not support cv-qualifiers. Replaced by "
99-
"add(callback(obj, method)).")
99+
"add(mbed::callback(obj, method)).")
100100
pFunctionPointer_t add(T *obj, M method) {
101-
return add(callback(obj, method));
101+
return add(mbed::callback(obj, method));
102102
}
103103

104104
/** Add a function at the beginning of the chain
@@ -120,14 +120,14 @@ class CallChain {
120120
*
121121
* @deprecated
122122
* The add_front function does not support cv-qualifiers. Replaced by
123-
* add_front(callback(obj, method)).
123+
* add_front(mbed::callback(obj, method)).
124124
*/
125125
template<typename T, typename M>
126126
MBED_DEPRECATED_SINCE("mbed-os-5.1",
127127
"The add_front function does not support cv-qualifiers. Replaced by "
128-
"add_front(callback(obj, method)).")
128+
"add_front(mbed::callback(obj, method)).")
129129
pFunctionPointer_t add_front(T *obj, M method) {
130-
return add_front(callback(obj, method));
130+
return add_front(mbed::callback(obj, method));
131131
}
132132

133133
/** Get the number of functions in the chain

hal/api/InterruptIn.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ class InterruptIn {
9191
* @param method pointer to the member function to be called
9292
* @deprecated
9393
* The rise function does not support cv-qualifiers. Replaced by
94-
* rise(callback(obj, method)).
94+
* rise(mbed::callback(obj, method)).
9595
*/
9696
template<typename T, typename M>
9797
MBED_DEPRECATED_SINCE("mbed-os-5.1",
9898
"The rise function does not support cv-qualifiers. Replaced by "
99-
"rise(callback(obj, method)).")
99+
"rise(mbed::callback(obj, method)).")
100100
void rise(T *obj, M method) {
101101
core_util_critical_section_enter();
102-
rise(callback(obj, method));
102+
rise(mbed::callback(obj, method));
103103
core_util_critical_section_exit();
104104
}
105105

@@ -115,15 +115,15 @@ class InterruptIn {
115115
* @param method pointer to the member function to be called
116116
* @deprecated
117117
* The rise function does not support cv-qualifiers. Replaced by
118-
* rise(callback(obj, method)).
118+
* rise(mbed::callback(obj, method)).
119119
*/
120120
template<typename T, typename M>
121121
MBED_DEPRECATED_SINCE("mbed-os-5.1",
122122
"The fall function does not support cv-qualifiers. Replaced by "
123-
"fall(callback(obj, method)).")
123+
"fall(mbed::callback(obj, method)).")
124124
void fall(T *obj, M method) {
125125
core_util_critical_section_enter();
126-
fall(callback(obj, method));
126+
fall(mbed::callback(obj, method));
127127
core_util_critical_section_exit();
128128
}
129129

hal/api/SerialBase.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ class SerialBase {
106106
* @param type Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
107107
* @deprecated
108108
* The attach function does not support cv-qualifiers. Replaced by
109-
* attach(callback(obj, method), type).
109+
* attach(mbed::callback(obj, method), type).
110110
*/
111111
template<typename T>
112112
MBED_DEPRECATED_SINCE("mbed-os-5.1",
113113
"The attach function does not support cv-qualifiers. Replaced by "
114-
"attach(callback(obj, method), type).")
114+
"attach(mbed::callback(obj, method), type).")
115115
void attach(T *obj, void (T::*method)(), IrqType type=RxIrq) {
116-
attach(callback(obj, method), type);
116+
attach(mbed::callback(obj, method), type);
117117
}
118118

119119
/** Attach a member function to call whenever a serial interrupt is generated
@@ -123,14 +123,14 @@ class SerialBase {
123123
* @param type Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
124124
* @deprecated
125125
* The attach function does not support cv-qualifiers. Replaced by
126-
* attach(callback(obj, method), type).
126+
* attach(mbed::callback(obj, method), type).
127127
*/
128128
template<typename T>
129129
MBED_DEPRECATED_SINCE("mbed-os-5.1",
130130
"The attach function does not support cv-qualifiers. Replaced by "
131-
"attach(callback(obj, method), type).")
131+
"attach(mbed::callback(obj, method), type).")
132132
void attach(T *obj, void (*method)(T*), IrqType type=RxIrq) {
133-
attach(callback(obj, method), type);
133+
attach(mbed::callback(obj, method), type);
134134
}
135135

136136
/** Generate a break condition on the serial line

hal/api/Ticker.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ class Ticker : public TimerEvent {
8383
* @param t the time between calls in seconds
8484
* @deprecated
8585
* The attach function does not support cv-qualifiers. Replaced by
86-
* attach(callback(obj, method), t).
86+
* attach(mbed::callback(obj, method), t).
8787
*/
8888
template<typename T, typename M>
8989
MBED_DEPRECATED_SINCE("mbed-os-5.1",
9090
"The attach function does not support cv-qualifiers. Replaced by "
91-
"attach(callback(obj, method), t).")
91+
"attach(mbed::callback(obj, method), t).")
9292
void attach(T *obj, M method, float t) {
93-
attach(callback(obj, method), t);
93+
attach(mbed::callback(obj, method), t);
9494
}
9595

9696
/** Attach a function to be called by the Ticker, specifiying the interval in micro-seconds
@@ -110,12 +110,12 @@ class Ticker : public TimerEvent {
110110
* @param t the time between calls in micro-seconds
111111
* @deprecated
112112
* The attach_us function does not support cv-qualifiers. Replaced by
113-
* attach_us(callback(obj, method), t).
113+
* attach_us(mbed::callback(obj, method), t).
114114
*/
115115
template<typename T, typename M>
116116
MBED_DEPRECATED_SINCE("mbed-os-5.1",
117117
"The attach_us function does not support cv-qualifiers. Replaced by "
118-
"attach_us(callback(obj, method), t).")
118+
"attach_us(mbed::callback(obj, method), t).")
119119
void attach_us(T *obj, M method, timestamp_t t) {
120120
attach_us(Callback<void()>(obj, method), t);
121121
}

hal/api/mbed.h

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,74 @@
7777
#include "Callback.h"
7878
#include "FunctionPointer.h"
7979

80-
using namespace mbed;
80+
// expansion of the std namespace
8181
using namespace std;
8282

83+
// explicit expansion of mbed classes
84+
using mbed::DigitalIn;
85+
using mbed::DigitalOut;
86+
using mbed::DigitalInOut;
87+
using mbed::BusIn;
88+
using mbed::BusOut;
89+
using mbed::BusInOut;
90+
#if DEVICE_PORTIN
91+
using mbed::PortIn;
92+
#endif
93+
#if DEVICE_PORTINOUT
94+
using mbed::PortInOut;
95+
#endif
96+
#if DEVICE_PORTOUT
97+
using mbed::PortOut;
98+
#endif
99+
#if DEVICE_ANALOGIN
100+
using mbed::AnalogIn;
101+
#endif
102+
#if DEVICE_ANALOGOUT
103+
using mbed::AnalogOut;
104+
#endif
105+
#if DEVICE_PWMOUT
106+
using mbed::PwmOut;
107+
#endif
108+
#if DEVICE_SERIAL
109+
using mbed::SerialBase;
110+
using mbed::Serial;
111+
using mbed::RawSerial;
112+
#endif
113+
#if DEVICE_SPI
114+
using mbed::SPI;
115+
#endif
116+
#if DEVICE_SPISLAVE
117+
using mbed::SPISlave;
118+
#endif
119+
#if DEVICE_I2C
120+
using mbed::I2C;
121+
#endif
122+
#if DEVICE_I2CSLAVE
123+
using mbed::I2CSlave;
124+
#endif
125+
#if DEVICE_ETHERNET
126+
using mbed::Ethernet;
127+
#endif
128+
#if DEVICE_CAN
129+
using mbed::CAN;
130+
#endif
131+
using mbed::Timer;
132+
using mbed::Ticker;
133+
using mbed::Timeout;
134+
#if DEVICE_LOWPOWERTIMER
135+
using mbed::LowPowerTimeout;
136+
using mbed::LowPowerTicker;
137+
using mbed::LowPowerTimer;
138+
#endif
139+
#if DEVICE_LOCALFILESYSTEM
140+
using mbed::LocalFileSystem;
141+
#endif
142+
#if DEVICE_INTERRUPTIN
143+
using mbed::InterruptIn;
144+
#endif
145+
using mbed::Stream;
146+
using mbed::Callback;
147+
using mbed::FunctionPointer;
148+
149+
83150
#endif

rtos/rtos/RtosTimer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ class RtosTimer {
6464
@param type osTimerOnce for one-shot or osTimerPeriodic for periodic behaviour. (default: osTimerPeriodic)
6565
@deprecated
6666
The RtosTimer constructor does not support cv-qualifiers. Replaced by
67-
RtosTimer(callback(obj, method), os_timer_type).
67+
RtosTimer(mbed::callback(obj, method), os_timer_type).
6868
*/
6969
template <typename T, typename M>
7070
MBED_DEPRECATED_SINCE("mbed-os-5.1",
7171
"The RtosTimer constructor does not support cv-qualifiers. Replaced by "
72-
"RtosTimer(callback(obj, method), os_timer_type).")
72+
"RtosTimer(mbed::callback(obj, method), os_timer_type).")
7373
RtosTimer(T *obj, M method, os_timer_type type=osTimerPeriodic) {
7474
constructor(mbed::callback(obj, method), type);
7575
}

rtos/rtos/Thread.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ class Thread {
108108
@param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
109109
@param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
110110
@deprecated
111-
Thread-spawning constructors hide errors. Replaced by thread.start(callback(argument, task)).
111+
Thread-spawning constructors hide errors. Replaced by thread.start(mbed::callback(argument, task)).
112112
113113
@code
114114
Thread thread(priority, stack_size, stack_pointer);
115115
116-
osStatus status = thread.start(callback(argument, task));
116+
osStatus status = thread.start(mbed::callback(argument, task));
117117
if (status != osOK) {
118118
error("oh no!");
119119
}
@@ -122,7 +122,7 @@ class Thread {
122122
template <typename T>
123123
MBED_DEPRECATED_SINCE("mbed-os-5.1",
124124
"Thread-spawning constructors hide errors. "
125-
"Replaced by thread.start(callback(argument, task)).")
125+
"Replaced by thread.start(mbed::callback(argument, task)).")
126126
Thread(T *argument, void (T::*task)(),
127127
osPriority priority=osPriorityNormal,
128128
uint32_t stack_size=DEFAULT_STACK_SIZE,
@@ -139,12 +139,12 @@ class Thread {
139139
@param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
140140
@param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
141141
@deprecated
142-
Thread-spawning constructors hide errors. Replaced by thread.start(callback(argument, task)).
142+
Thread-spawning constructors hide errors. Replaced by thread.start(mbed::callback(argument, task)).
143143
144144
@code
145145
Thread thread(priority, stack_size, stack_pointer);
146146
147-
osStatus status = thread.start(callback(argument, task));
147+
osStatus status = thread.start(mbed::callback(argument, task));
148148
if (status != osOK) {
149149
error("oh no!");
150150
}
@@ -153,7 +153,7 @@ class Thread {
153153
template <typename T>
154154
MBED_DEPRECATED_SINCE("mbed-os-5.1",
155155
"Thread-spawning constructors hide errors. "
156-
"Replaced by thread.start(callback(argument, task)).")
156+
"Replaced by thread.start(mbed::callback(argument, task)).")
157157
Thread(T *argument, void (*task)(T *),
158158
osPriority priority=osPriorityNormal,
159159
uint32_t stack_size=DEFAULT_STACK_SIZE,
@@ -170,20 +170,20 @@ class Thread {
170170
@param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
171171
@param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
172172
@deprecated
173-
Thread-spawning constructors hide errors. Replaced by thread.start(callback(argument, task)).
173+
Thread-spawning constructors hide errors. Replaced by thread.start(mbed::callback(argument, task)).
174174
175175
@code
176176
Thread thread(priority, stack_size, stack_pointer);
177177
178-
osStatus status = thread.start(callback(argument, task));
178+
osStatus status = thread.start(mbed::callback(argument, task));
179179
if (status != osOK) {
180180
error("oh no!");
181181
}
182182
@endcode
183183
*/
184184
MBED_DEPRECATED_SINCE("mbed-os-5.1",
185185
"Thread-spawning constructors hide errors. "
186-
"Replaced by thread.start(callback(argument, task)).")
186+
"Replaced by thread.start(mbed::callback(argument, task)).")
187187
Thread(void (*task)(void const *argument), void *argument=NULL,
188188
osPriority priority=osPriorityNormal,
189189
uint32_t stack_size=DEFAULT_STACK_SIZE,
@@ -203,12 +203,12 @@ class Thread {
203203
@param method function to be executed by this thread.
204204
@return status code that indicates the execution status of the function.
205205
@deprecated
206-
The start function does not support cv-qualifiers. Replaced by start(callback(obj, method)).
206+
The start function does not support cv-qualifiers. Replaced by start(mbed::callback(obj, method)).
207207
*/
208208
template <typename T, typename M>
209209
MBED_DEPRECATED_SINCE("mbed-os-5.1",
210210
"The start function does not support cv-qualifiers. "
211-
"Replaced by thread.start(callback(obj, method)).")
211+
"Replaced by thread.start(mbed::callback(obj, method)).")
212212
osStatus start(T *obj, M method) {
213213
return start(mbed::callback(obj, method));
214214
}

0 commit comments

Comments
 (0)