Skip to content

Commit 67e2167

Browse files
committed
Change up to prim
1 parent 113160d commit 67e2167

24 files changed

+166
-157
lines changed

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ EXTRACT_PRIVATE = YES
113113
# methods of a class will be included in the documentation.
114114
# The default value is: NO.
115115

116-
# KOKESHI: Many interfaces like StreamBase have private virtual functions that are
116+
# KOKESHI: Many interfaces like IStream have private virtual functions that are
117117
# intended to be overriden by the user, so their documentation should be visible.
118118
EXTRACT_PRIV_VIRTUAL = YES
119119

docs/CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,12 @@ The brief description for constructors should be "Constructor", and the brief de
470470
/**
471471
* @brief Constructor
472472
*/
473-
StreamBase();
473+
IStream();
474474
475475
/**
476476
* @brief Destructor
477477
*/
478-
virtual ~StreamBase();
478+
virtual ~IStream();
479479
```
480480

481481
If there are many constructor overloads for purposes such as moving/copying, feel free to specify the constructor "type" in the Doxygen detailed description:

lib/libkiwi/core/kiwiFileStream.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef LIBKIWI_CORE_FILE_STREAM_H
22
#define LIBKIWI_CORE_FILE_STREAM_H
3-
#include <libkiwi/core/kiwiStreamBase.h>
3+
#include <libkiwi/core/kiwiIStream.h>
44
#include <libkiwi/k_types.h>
55

66
namespace kiwi {
@@ -19,7 +19,7 @@ enum EOpenMode {
1919
/**
2020
* @brief Stream to a physical file
2121
*/
22-
class FileStream : public StreamBase {
22+
class FileStream : public IStream {
2323
public:
2424
/**
2525
* @brief Constructor
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace kiwi {
88
* @param dir Seek direction
99
* @param offset Seek offset
1010
*/
11-
void StreamBase::Seek(ESeekDir dir, s32 offset) {
11+
void IStream::Seek(ESeekDir dir, s32 offset) {
1212
K_ASSERT_EX(IsOpen(), "Stream is not available");
1313
K_ASSERT_EX(CanSeek(), "Stream does not support seeking");
1414

@@ -25,7 +25,7 @@ void StreamBase::Seek(ESeekDir dir, s32 offset) {
2525
* @param size Number of bytes to read
2626
* @return Number of bytes read, or DVD error code
2727
*/
28-
s32 StreamBase::Read(void* pDst, u32 size) {
28+
s32 IStream::Read(void* pDst, u32 size) {
2929
K_ASSERT_PTR(pDst);
3030

3131
K_ASSERT_EX(IsOpen(), "Stream is not available");
@@ -52,7 +52,7 @@ s32 StreamBase::Read(void* pDst, u32 size) {
5252
* @param size Number of bytes to write
5353
* @return Number of bytes written, or DVD error code
5454
*/
55-
s32 StreamBase::Write(const void* pSrc, u32 size) {
55+
s32 IStream::Write(const void* pSrc, u32 size) {
5656
K_ASSERT_PTR(pSrc);
5757

5858
K_ASSERT_EX(IsOpen(), "Stream is not available");
@@ -80,7 +80,7 @@ s32 StreamBase::Write(const void* pSrc, u32 size) {
8080
* @param size Number of bytes to read
8181
* @return Number of bytes read, or DVD error code
8282
*/
83-
s32 StreamBase::Peek(void* pDst, u32 size) {
83+
s32 IStream::Peek(void* pDst, u32 size) {
8484
K_ASSERT_PTR(pDst);
8585

8686
K_ASSERT_EX(IsOpen(), "Stream is not available");
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef LIBKIWI_CORE_STREAM_BASE_H
2-
#define LIBKIWI_CORE_STREAM_BASE_H
1+
#ifndef LIBKIWI_CORE_I_STREAM_H
2+
#define LIBKIWI_CORE_I_STREAM_H
33
#include <libkiwi/k_types.h>
44
#include <libkiwi/prim/kiwiString.h>
55
#include <libkiwi/util/kiwiPtrUtil.h>
@@ -18,19 +18,19 @@ enum ESeekDir {
1818
};
1919

2020
/**
21-
* @brief Base class for stream types
21+
* @brief Stream type interface
2222
*/
23-
class StreamBase {
23+
class IStream {
2424
public:
2525
/**
2626
* @brief Constructor
2727
*/
28-
StreamBase() : mIsOpen(false), mPosition(0) {}
28+
IStream() : mIsOpen(false), mPosition(0) {}
2929

3030
/**
3131
* @brief Destructor
3232
*/
33-
virtual ~StreamBase() {
33+
virtual ~IStream() {
3434
K_ASSERT_EX(!IsOpen(), "Your class forgot to close the stream!");
3535
}
3636

lib/libkiwi/core/kiwiSceneHookMgr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ bool IsCurrentPackScene() {
3636
/**
3737
* @brief Gets the list of active hooks for the current scene
3838
*/
39-
TList<SceneHookBase>& SceneHookMgr::GetSceneHooks() {
39+
TList<ISceneHook>& SceneHookMgr::GetSceneHooks() {
4040
K_ASSERT_EX(IsCurrentPackScene(), "Only game scenes have hooks");
4141
s32 id = RP_GET_INSTANCE(RPSysSceneMgr)->getCurrentSceneID();
4242
return mSceneHookLists[id];
@@ -47,7 +47,7 @@ TList<SceneHookBase>& SceneHookMgr::GetSceneHooks() {
4747
*
4848
* @param rHook Scene hook
4949
*/
50-
void SceneHookMgr::AddHook(SceneHookBase& rHook) {
50+
void SceneHookMgr::AddHook(ISceneHook& rHook) {
5151
if (rHook.mSceneID == -1) {
5252
mGlobalHooks.PushBack(&rHook);
5353
} else {
@@ -60,7 +60,7 @@ void SceneHookMgr::AddHook(SceneHookBase& rHook) {
6060
*
6161
* @param rHook Scene hook
6262
*/
63-
void SceneHookMgr::RemoveHook(const SceneHookBase& rHook) {
63+
void SceneHookMgr::RemoveHook(const ISceneHook& rHook) {
6464
if (rHook.mSceneID == -1) {
6565
mGlobalHooks.Remove(&rHook);
6666
} else {

lib/libkiwi/core/kiwiSceneHookMgr.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace kiwi {
1212
//! @{
1313

1414
// Forward declarations
15-
class SceneHookBase;
15+
class ISceneHook;
1616

1717
/**
1818
* @brief Scene hook manager
@@ -26,13 +26,13 @@ class SceneHookMgr : public StaticSingleton<SceneHookMgr> {
2626
*
2727
* @param rHook Scene hook
2828
*/
29-
void AddHook(SceneHookBase& rHook);
29+
void AddHook(ISceneHook& rHook);
3030
/**
3131
* @brief Unregisters an existing hook
3232
*
3333
* @param rHook Scene hook
3434
*/
35-
void RemoveHook(const SceneHookBase& rHook);
35+
void RemoveHook(const ISceneHook& rHook);
3636

3737
private:
3838
LIBKIWI_KAMEK_PUBLIC
@@ -71,19 +71,19 @@ class SceneHookMgr : public StaticSingleton<SceneHookMgr> {
7171
/**
7272
* @brief Gets the list of active hooks for the current scene
7373
*/
74-
TList<SceneHookBase>& GetSceneHooks();
74+
TList<ISceneHook>& GetSceneHooks();
7575

7676
private:
7777
//! Lists of scene hooks
78-
TArray<TList<SceneHookBase>, ESceneID_Max> mSceneHookLists;
78+
TArray<TList<ISceneHook>, ESceneID_Max> mSceneHookLists;
7979
//! Global hooks (always active)
80-
TList<SceneHookBase> mGlobalHooks;
80+
TList<ISceneHook> mGlobalHooks;
8181
};
8282

8383
/**
84-
* @brief Base class for scene hooks
84+
* @brief Scene hook interface
8585
*/
86-
class SceneHookBase {
86+
class ISceneHook {
8787
friend class SceneHookMgr;
8888

8989
public:
@@ -93,7 +93,7 @@ class SceneHookBase {
9393
*
9494
* @param id Scene ID (-1 for all scenes)
9595
*/
96-
explicit SceneHookBase(s32 id = -1) : mSceneID(id) {
96+
explicit ISceneHook(s32 id = -1) : mSceneID(id) {
9797
K_ASSERT_EX(id == -1 || id < ESceneID_Max,
9898
"Only RP scene IDs and -1 (all scenes) are supported");
9999

@@ -102,7 +102,7 @@ class SceneHookBase {
102102
/**
103103
* @brief Destructor
104104
*/
105-
virtual ~SceneHookBase() {
105+
virtual ~ISceneHook() {
106106
SceneHookMgr::GetInstance().RemoveHook(*this);
107107
}
108108

lib/libkiwi/fun/kiwiGameCorruptor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ enum ECorruptDomain {
1919
ECorruptDomain_DolCode = (1 << 0), //!< Corrupt DOL code sections
2020
ECorruptDomain_DolData = (1 << 1), //!< Corrupt DOL data sections
2121

22-
ECorruptDomain_Mem1 = (1 << 2), // Corrupt MEM1 region of RAM
23-
ECorruptDomain_Mem2 = (1 << 3), // Corrupt MEM2 region of RAM
22+
ECorruptDomain_Mem1 = (1 << 2), //!< Corrupt MEM1 region of RAM
23+
ECorruptDomain_Mem2 = (1 << 3), //!< Corrupt MEM2 region of RAM
2424

25-
ECorruptDomain_Scene = (1 << 4), // Corrupt the current scene's memory
25+
ECorruptDomain_Scene = (1 << 4), //!< Corrupt the current scene's memory
2626
};
2727

2828
/**

lib/libkiwi/libkiwi.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef LIBKIWI_H
2-
#define LIBKIWI_H
1+
#ifndef LIBKIWI_LIBRARY_H
2+
#define LIBKIWI_LIBRARY_H
33

44
#include <libkiwi/core/kiwiColor.h>
55
#include <libkiwi/core/kiwiConsoleOut.h>
@@ -8,6 +8,7 @@
88
#include <libkiwi/core/kiwiFileRipper.h>
99
#include <libkiwi/core/kiwiIBinary.h>
1010
#include <libkiwi/core/kiwiIScene.h>
11+
#include <libkiwi/core/kiwiIStream.h>
1112
#include <libkiwi/core/kiwiJSON.h>
1213
#include <libkiwi/core/kiwiMemStream.h>
1314
#include <libkiwi/core/kiwiMemoryMgr.h>
@@ -16,7 +17,6 @@
1617
#include <libkiwi/core/kiwiSPR.h>
1718
#include <libkiwi/core/kiwiSceneCreator.h>
1819
#include <libkiwi/core/kiwiSceneHookMgr.h>
19-
#include <libkiwi/core/kiwiStreamBase.h>
2020
#include <libkiwi/core/kiwiThread.h>
2121
#include <libkiwi/crypt/kiwiBase64.h>
2222
#include <libkiwi/crypt/kiwiChecksum.h>

lib/libkiwi/net/kiwiAsyncSocket.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ class AsyncSocket::RecvJob {
4343
mpPeer(pPeer),
4444
mpCallback(pCallback),
4545
mpArg(pArg) {
46-
K_ASSERT(mpPacket != nullptr);
47-
K_ASSERT(mpDst != nullptr);
46+
47+
K_ASSERT_PTR(mpPacket);
48+
K_ASSERT_PTR(mpDst);
4849
K_ASSERT(OSIsMEM2Region(mpDst));
4950
}
5051

@@ -59,7 +60,7 @@ class AsyncSocket::RecvJob {
5960
* @brief Tests whether the receive operation is complete
6061
*/
6162
bool IsComplete() const {
62-
K_ASSERT(mpPacket != nullptr);
63+
K_ASSERT_PTR(mpPacket);
6364
return mpPacket->IsWriteComplete();
6465
}
6566

@@ -70,7 +71,7 @@ class AsyncSocket::RecvJob {
7071
* @return Whether the job is complete
7172
*/
7273
bool Calc(SOSocket socket) {
73-
K_ASSERT(mpPacket != nullptr);
74+
K_ASSERT_PTR(mpPacket);
7475
K_ASSERT(socket >= 0);
7576

7677
// Nothing left to do
@@ -84,7 +85,7 @@ class AsyncSocket::RecvJob {
8485

8586
// Write out data
8687
if (done) {
87-
K_ASSERT(mpDst != nullptr);
88+
K_ASSERT_PTR(mpDst);
8889
K_ASSERT(OSIsMEM2Region(mpDst));
8990

9091
std::memcpy(mpDst, mpPacket->GetContent(),
@@ -127,7 +128,8 @@ class AsyncSocket::SendJob {
127128
*/
128129
SendJob(Packet* pPacket, Callback pCallback = nullptr, void* pArg = nullptr)
129130
: mpPacket(pPacket), mpCallback(pCallback), mpArg(pArg) {
130-
K_ASSERT(mpPacket != nullptr);
131+
132+
K_ASSERT_PTR(mpPacket);
131133
}
132134

133135
/**
@@ -141,7 +143,7 @@ class AsyncSocket::SendJob {
141143
* @brief Tests whether the send operation is complete
142144
*/
143145
bool IsComplete() const {
144-
K_ASSERT(mpPacket != nullptr);
146+
K_ASSERT_PTR(mpPacket);
145147
return mpPacket->IsReadComplete();
146148
}
147149

@@ -152,7 +154,7 @@ class AsyncSocket::SendJob {
152154
* @return Whether the job is complete
153155
*/
154156
bool Calc(SOSocket socket) {
155-
K_ASSERT(mpPacket != nullptr);
157+
K_ASSERT_PTR(mpPacket);
156158
K_ASSERT(socket >= 0);
157159

158160
// Nothing left to do
@@ -336,7 +338,7 @@ void AsyncSocket::Calc() {
336338
// Result code is the peer descriptor
337339
if (result >= 0) {
338340
pSocket = new AsyncSocket(result, mFamily, mType);
339-
K_ASSERT(pSocket != nullptr);
341+
K_ASSERT_PTR(pSocket);
340342
}
341343

342344
mState = EState_Thinking;
@@ -408,16 +410,16 @@ SOResult AsyncSocket::RecvImpl(void* pDst, u32 len, u32& rRecv,
408410
SockAddrAny* pAddr, Callback pCallback,
409411
void* pArg) {
410412
K_ASSERT(IsOpen());
411-
K_ASSERT(pDst != nullptr);
413+
K_ASSERT_PTR(pDst);
412414
K_ASSERT(OSIsMEM2Region(pDst));
413415

414416
// Packet to hold incoming data
415417
Packet* pPacket = new Packet(len);
416-
K_ASSERT(pPacket != nullptr);
418+
K_ASSERT_PTR(pPacket);
417419

418420
// Asynchronous job
419421
RecvJob* pJob = new RecvJob(pPacket, pDst, pAddr, pCallback, pArg);
420-
K_ASSERT(pJob != nullptr);
422+
K_ASSERT_PTR(pJob);
421423
mRecvJobs.PushBack(pJob);
422424

423425
// Receive doesn't actually happen on this thread
@@ -440,19 +442,19 @@ SOResult AsyncSocket::SendImpl(const void* pSrc, u32 len, u32& rSend,
440442
const SockAddrAny* pAddr, Callback pCallback,
441443
void* pArg) {
442444
K_ASSERT(IsOpen());
443-
K_ASSERT(pSrc != nullptr);
445+
K_ASSERT_PTR(pSrc);
444446
K_ASSERT(OSIsMEM2Region(pSrc));
445447

446448
// Packet to hold incoming data
447449
Packet* pPacket = new Packet(len, pAddr);
448-
K_ASSERT(pPacket != nullptr);
450+
K_ASSERT_PTR(pPacket);
449451

450452
// Store data inside packet
451453
pPacket->Write(pSrc, len);
452454

453455
// Asynchronous job
454456
SendJob* pJob = new SendJob(pPacket, pCallback, pArg);
455-
K_ASSERT(pJob != nullptr);
457+
K_ASSERT_PTR(pJob);
456458
mSendJobs.PushBack(pJob);
457459

458460
// Send doesn't actually happen on this thread

0 commit comments

Comments
 (0)