10000 Encapsulate everything in namespace arduino · smohekey/ArduinoCore-API@fc0c12d · GitHub
[go: up one dir, main page]

Skip to content

Commit fc0c12d

Browse files
committed
Encapsulate everything in namespace arduino
This will help integrating with other C++ frameworks declaring the same classes (String/Serial/...)
1 parent 398e70f commit fc0c12d

20 files changed

+83
-25
lines changed

api/Client.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "Stream.h"
2323
#include "IPAddress.h"
2424

25+
namespace arduino {
26+
2527
class Client : public Stream {
2628

2729
public:
@@ -41,3 +43,4 @@ class Client : public Stream {
4143
uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
4244
};
4345

46+
}

api/HardwareI2C.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <inttypes.h>
2222
#include "Stream.h"
2323

24+
namespace arduino {
25+
2426
class HardwareI2C : public Stream
2527
{
2628
public:
@@ -41,3 +43,5 @@ class HardwareI2C : public Stream
4143
virtual void onRequest(void(*)(void)) = 0;
4244
};
4345

46+
}
47+

api/HardwareSerial.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <inttypes.h>
2222
#include "Stream.h"
2323

24+
namespace arduino {
25+
2426
// XXX: Those constants should be defined as const int / enums?
2527
// XXX: shall we use namespaces too?
2628
#define SERIAL_PARITY_EVEN (0x1ul)
@@ -100,3 +102,4 @@ class HardwareSerial : public Stream
100102
// XXX: Are we keeping the serialEvent API?
101103
extern void serialEventRun(void) __attribute__((weak));
102104

105+
}

api/IPAddress.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "IPAddress.h"
2121
#include "Print.h"
2222

23+
using namespace arduino;
24+
2325
IPAddress::IPAddress()
2426
{
2527
_address.dword = 0;

api/IPAddress.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include "Printable.h"
2424
#include "String.h"
2525

26+
namespace arduino {
27+
2628
// A class to make it easier to handle and pass around IP addresses
2729

2830
class IPAddress : public Printable {
@@ -74,4 +76,4 @@ class IPAddress : public Printable {
7476
};
7577

7678
extern const IPAddress INADDR_NONE;
77-
79+
}

api/Interrupts.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <stdint.h>
88
#include "Common.h"
99

10+
namespace arduino {
11+
1012
template <typename T>
1113
using voidTemplateFuncPtrParam = void (*)(T param);
1214

@@ -37,5 +39,6 @@ template<typename T> void attachInterrupt(pin_size_t interruptNum, voidTemplateF
3739
attachInterruptParam(interruptNum, (voidFuncPtrParam)userFunc, mode, (void*)param);
3840
}
3941

42+
}
4043
#endif
4144
#endif

api/PluggableUSB.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "USBAPI.h"
2121
#include "PluggableUSB.h"
2222

23+
using namespace arduino;
24+
2325
int PluggableUSB_::getInterface(uint8_t* interfaceCount)
2426
{
2527
int sent = 0;

api/PluggableUSB.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <stdint.h>
2525
#include <stddef.h>
2626

27+
namespace arduino {
28+
2729
// core need to define
28< 10000 /code>30
void* epBuffer(unsigned int n); // -> returns a poointer to the Nth element of the EP buffer structure
2931

@@ -72,4 +74,6 @@ class PluggableUSB_ {
7274
// https://isocpp.org/wiki/faq/ctors#static-init-order-on-first-use
7375
PluggableUSB_& PluggableUSB();
7476

77+
}
78+
7579
#endif

api/Print.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#include "Print.h"
2525

26+
using namespace arduino;
27+
2628
// Public Methods //////////////////////////////////////////////////////////////
2729

2830
/* default implementation: may be overridden */

api/Print.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#define OCT 8
3030
#define BIN 2
3131

32+
namespace arduino {
33+
3234
class Print
3335
{
3436
private:
@@ -90,3 +92,4 @@ class Print
9092
virtual void flush() { /* Empty implementation for backward compatibility */ }
9193
};
9294

95+
}

0 commit comments

Comments
 (0)
0