Skip to content
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

Ensure header files and .cpp files use the codal namespace appropriately #437

Merged

Conversation

carlosperate
Copy link
Contributor

@carlosperate carlosperate commented Jul 23, 2024

This is part of:

The only thing that hasn't been added to the codal namespace are the Mbed header files, as those are only included by programmes explicitly doing include <mbed.h>:

#include "MbedTimer.h"
#include "Ticker.h"
#include "Timeout.h"
#include "InterruptIn.h"
#include "PwmOut.h"
#include "DigitalIn.h"
#include "DigitalOut.h"

This PR uses a new config option added to codal-core in lancaster-university/codal-nrf52@8802eb4. By default is set to 1, so that the codal namespace is still added globally in MicroBit.h, but the user can change this config option in case they need to integrate CODAL with other frameworks and avoid clashes in the namespace.

@@ -31,7 +31,6 @@ DEALINGS IN THE SOFTWARE.
#include "CodalDevice.h"
#include "ErrorNo.h"
#include "NRFLowLevelTimer.h"
#include "Matrix4.h"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed as it wasn't used.

Comment on lines -45 to -47
namespace MicroBitUtility
typedef enum replyState_t
{
typedef enum replyState_t
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This enum is declared and only used inside this cpp file, so no need to declare it inside the MicroBitUtility namespace, otherwise with these changes each usage in this file would have to be prepended by the namespace.

@carlosperate carlosperate force-pushed the namespaces branch 2 times, most recently from 977d285 to 9f3d96e Compare July 23, 2024 17:10
carlosperate added a commit to carlosperate/codal-nrf52 that referenced this pull request Jul 24, 2024
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 header file to set up this namespace 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
carlosperate added a commit to carlosperate/codal-nrf52 that referenced this pull request Jul 24, 2024
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 header file to set up this namespace 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
carlosperate added a commit to carlosperate/codal-nrf52 that referenced this pull request Jul 24, 2024
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
microbit-carlos pushed a commit to lancaster-university/codal-nrf52 that referenced this pull request Jul 24, 2024
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
…ely.

Also update the codal-core and codal-nrf52 dependencies as they
include changes on the same topic.

The classes declared in the Mbed compatibility header files have
not been wrapped in the codal namespace, as programmes including
the mbed.h header might not expect them to be inside that namespace.
This header file is not included in any of the codal-microbit-v2
or dependencies, it's mostly used by MakeCode extensions that
were accessing Mbed-specific libraries in micro:bit V1.
@microbit-carlos microbit-carlos merged commit 762629c into lancaster-university:master Jul 24, 2024
13 checks passed
@carlosperate carlosperate deleted the namespaces branch July 24, 2024 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants