Skip to content

Commit

Permalink
Wrap using namespace in headers with codal config flag. (#43)
Browse files Browse the repository at this point in the history
Flag introduced in codal-core in:
lancaster-university/codal-core@509086c

By default the `using namespace` line would still be present, as
removing it can cause some codal targets to break if they depend
on the namespace to be set up globally.

For example, the codal-microbit-v2 target had this update to
fix the namespacing:
lancaster-university/codal-microbit-v2#437

This patch is part of:
lancaster-university/codal-microbit-v2#240
  • Loading branch information
carlosperate authored Jul 24, 2024
1 parent 660ee5a commit 8802eb4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
9 changes: 8 additions & 1 deletion inc/NRF52ADC.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,21 @@ DEALINGS IN THE SOFTWARE.
//
#define NRF52_ADC_DATA_READY 1


// This "using namespace codal" cannot be removed from this header file without
// breaking targets where some .cpp files depend on it. So this config flag is
// enabled by default and keeps the namespace for compatibility.
#if CONFIG_ENABLED(CODAL_USE_GLOBAL_NAMESPACE)
using namespace codal;
#endif

//
// NRF52ADCChannel status codes
//
#define NRF52_ADC_CHANNEL_STATUS_ENABLED 0x10
#define NRF52_ADC_CHANNEL_STATUS_CONNECTED 0x20

namespace codal
{
class NRF52ADC;

class NRF52ADCChannel : public DataSource
Expand Down Expand Up @@ -350,5 +356,6 @@ class NRF52ADC : public CodalComponent, public PinPeripheral
*/
void configureSampling();
};
} // namespace codal

#endif
9 changes: 9 additions & 0 deletions inc/NRF52PDM.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ DEALINGS IN THE SOFTWARE.
//
#define NRF52_PDM_BUFFER_SIZE 512

// This "using namespace codal" cannot be removed from this header file without
// breaking targets where some .cpp files depend on it. So this config flag is
// enabled by default and keeps the namespace for compatibility.
#if CONFIG_ENABLED(CODAL_USE_GLOBAL_NAMESPACE)
using namespace codal;
#endif

namespace codal
{

class NRF52PDM : public CodalComponent, public DataSource
{
Expand Down Expand Up @@ -103,5 +111,6 @@ class NRF52PDM : public CodalComponent, public DataSource

void startDMA();
};
} // namespace codal

#endif
9 changes: 8 additions & 1 deletion inc/NRF52PWM.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@
#define NRF52PWM_PWM_PERIPHERALS 3
#define NRF52PWM_PWM_CHANNELS 4


// This "using namespace codal" cannot be removed from this header file without
// breaking targets where some .cpp files depend on it. So this config flag is
// enabled by default and keeps the namespace for compatibility.
#if CONFIG_ENABLED(CODAL_USE_GLOBAL_NAMESPACE)
using namespace codal;
#endif

namespace codal
{
class NRF52PWM : public CodalComponent, public DataSink, public PinPeripheral
{

Expand Down Expand Up @@ -153,5 +159,6 @@ class NRF52PWM : public CodalComponent, public DataSink, public PinPeripheral
int tryPull(uint8_t b);

};
} // namespace codal

#endif

0 comments on commit 8802eb4

Please sign in to comment.