Skip to content

Commit

Permalink
Remove include_cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
SeekyCt committed Jan 4, 2025
1 parent 1e8e2c8 commit 6ff5db2
Show file tree
Hide file tree
Showing 18 changed files with 36 additions and 27 deletions.
13 changes: 12 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## C++ notes
- Most headers are designed to be compileable in C and C++
- The CPP_WRAPPER macro allows for the file's namespace to be dropped when compiling in C and for `extern "C"` to
be inserted when compiling in C++
- The headers in the spm folder where the game used C++ features should still have C support
- These are rare, so it's less effort than supporting C++ in nw4r would be, and more useful
- Use `#ifdef __cplusplus` and padding where neccessary to achieve this
- The headers in the nw4r folder don't have C support since they were written in C++ originally
- They therefore don't use the CPP_WRAPPER macro
- They're named .hpp instead of .h to indicate this

## Naming

- Use official names when possible (from TTYD symbol map, asserts, etc.), and try to follow the style otherwise
Expand Down Expand Up @@ -30,7 +41,7 @@
- Wrap files in CPP_WRAPPER from where includes finish to the end of the file
- The name passed in should be `folder::filename` (for example, `spm::evtmgr`)
- `common.h` and the variants of `evt_cmd.h` are exceptions to this
- This won't apply to nw4r headers' code they're done properly
- This doesn't apply to nw4r headers' as they're done with real C++
- Wrap file-local and function-local symbols in DECOMP_STATIC in headers (for example, `DECOMP_STATIC(evtmgr_work)`)
- Add offset comments on the left of every struct member
- Add value comments on the left of every enum member
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ For use in decomp, the `include`, `include_cpp` and `decomp` folders should be a

## Mods

For use in mods, the `include`, `include_cpp` and `mod` folder should be added to the include path and an lst from `linker` should be used. Mods should include their compiler's standard library headers (do not use `-nostdinc`), though linking it is not required (so `-nostdlib` is fine).
For use in mods, the `include` and `mod` folders should be added to the include path and an lst from `linker` should be used. Mods should include their compiler's standard library headers (do not use `-nostdinc`), though linking it is not required (so `-nostdlib` is fine).

## C

For the cases where C is required (such as m2c or maybe some niche modding cases), omitting the `include_cpp` folder should be all that's neccessary.
**Warning**: NW4R headers are probably unsafe to use with GCC currently

# Licensing

All code originally written for this project (everything under the `include`, `include_cpp`, `decomp` and `linker` directories) is available under the MIT license.
All code originally written for this project (everything under the `include`, `decomp` and `linker` directories) is available under the MIT license.

Everything under the `mod` folder is available under the GPLv3 license as it's derived from other GPL code.

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion include_cpp/msl/new.h → include/msl/new
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// TODO: does this actually need to be hidden for modding?
#ifdef DECOMP

#include <msl/exception.h>
#include <msl/exception>

namespace std {

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include <common.h>
#include <nw4r/lyt/resourceAccessor.h>
#include <nw4r/ut/linkList.h>
#include <nw4r/lyt/resourceAccessor.hpp>
#include <nw4r/ut/linkList.hpp>

namespace nw4r {
namespace lyt {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include <common.h>
#include <nw4r/math/types.h>
#include <nw4r/ut/rect.h>
#include <nw4r/math/types.hpp>
#include <nw4r/ut/rect.hpp>

namespace nw4r {
namespace lyt {
Expand Down
12 changes: 6 additions & 6 deletions include_cpp/nw4r/lyt/layout.h → include/nw4r/lyt/layout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

#include <common.h>
#include <wii/mem.h>
#include <msl/new.h>
#include <nw4r/lyt/animation.h>
#include <nw4r/lyt/drawInfo.h>
#include <nw4r/lyt/pane.h>
#include <nw4r/lyt/resourceAccessor.h>
#include <nw4r/ut/rect.h>
#include <msl/new>
#include <nw4r/lyt/animation.hpp>
#include <nw4r/lyt/drawInfo.hpp>
#include <nw4r/lyt/pane.hpp>
#include <nw4r/lyt/resourceAccessor.hpp>
#include <nw4r/ut/rect.hpp>

namespace nw4r {
namespace lyt {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <common.h>
#include <wii/gx.h>
#include <nw4r/ut/linkList.h>
#include <nw4r/ut/linkList.hpp>

namespace nw4r {
namespace lyt {
Expand Down
8 changes: 4 additions & 4 deletions include_cpp/nw4r/lyt/pane.h → include/nw4r/lyt/pane.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once

#include <common.h>
#include <msl/new.h>
#include <nw4r/lyt/animation.h>
#include <nw4r/lyt/material.h>
#include <nw4r/lyt/resourceAccessor.h>
#include <msl/new>
#include <nw4r/lyt/animation.hpp>
#include <nw4r/lyt/material.hpp>
#include <nw4r/lyt/resourceAccessor.hpp>

namespace nw4r {
namespace lyt {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#include <common.h>
#include <nw4r/ut/nonCopyable.h>
#include <nw4r/ut/nonCopyable.hpp>

namespace nw4r {
namespace ut {
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions include_cpp/spm/seq_title.h → include/spm/seq_title.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include <wii/mem.h>

#ifdef __cplusplus
#include <nw4r/lyt/arcResourceAccessor.h>
#include <nw4r/lyt/animation.h>
#include <nw4r/lyt/drawInfo.h>
#include <nw4r/lyt/layout.h>
#include <nw4r/lyt/arcResourceAccessor.hpp>
#include <nw4r/lyt/animation.hpp>
#include <nw4r/lyt/drawInfo.hpp>
#include <nw4r/lyt/layout.hpp>
#endif

CPP_WRAPPER(spm::seq_title)
Expand Down

0 comments on commit 6ff5db2

Please sign in to comment.