Match and link CObjectReference

This commit is contained in:
Phillip Stephens 2023-01-13 22:27:43 -08:00
parent 267f40bff8
commit 5b126665df
22 changed files with 145 additions and 51 deletions

View File

@ -1025,7 +1025,7 @@ lbl_802C1EA0:
/* 802C1EB4 002BEE14 48 00 0B C9 */ bl __dt__9CGuiFrameFv
lbl_802C1EB8:
/* 802C1EB8 002BEE18 38 61 00 08 */ addi r3, r1, 8
/* 802C1EBC 002BEE1C 4B D7 24 49 */ bl sub_80034304
/* 802C1EBC 002BEE1C 4B D7 24 49 */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
/* 802C1EC0 002BEE20 80 01 00 34 */ lwz r0, 0x34(r1)
/* 802C1EC4 002BEE24 83 E1 00 2C */ lwz r31, 0x2c(r1)
/* 802C1EC8 002BEE28 7C 08 03 A6 */ mtlr r0

View File

@ -257,7 +257,7 @@ lbl_802FE280:
/* 802FE294 002FB1F4 4B FF FC 89 */ bl __dt__21CAllFormatsAnimSourceFv
lbl_802FE298:
/* 802FE298 002FB1F8 38 61 00 08 */ addi r3, r1, 8
/* 802FE29C 002FB1FC 4B D3 60 69 */ bl sub_80034304
/* 802FE29C 002FB1FC 4B D3 60 69 */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
/* 802FE2A0 002FB200 80 01 00 34 */ lwz r0, 0x34(r1)
/* 802FE2A4 002FB204 83 E1 00 2C */ lwz r31, 0x2c(r1)
/* 802FE2A8 002FB208 83 C1 00 28 */ lwz r30, 0x28(r1)
@ -514,4 +514,3 @@ lbl_803D6E58:
# ROM: 0x3D3E58
.asciz "??(??)"
.balign 4

View File

@ -296,7 +296,7 @@ lbl_8033FEAC:
/* 8033FEB4 0033CE14 34 1E 00 14 */ addic. r0, r30, 0x14
/* 8033FEB8 0033CE18 41 82 00 0C */ beq lbl_8033FEC4
/* 8033FEBC 0033CE1C 38 7E 00 14 */ addi r3, r30, 0x14
/* 8033FEC0 0033CE20 4B CF 44 45 */ bl sub_80034304
/* 8033FEC0 0033CE20 4B CF 44 45 */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
lbl_8033FEC4:
/* 8033FEC4 0033CE24 7F E0 07 35 */ extsh. r0, r31
/* 8033FEC8 0033CE28 40 81 00 0C */ ble lbl_8033FED4
@ -341,7 +341,7 @@ lbl_8033FED4:
/* 8033FF54 0033CEB4 80 85 00 04 */ lwz r4, 4(r5)
/* 8033FF58 0033CEB8 38 04 00 01 */ addi r0, r4, 1
/* 8033FF5C 0033CEBC 90 05 00 04 */ stw r0, 4(r5)
/* 8033FF60 0033CEC0 4B CF 43 A5 */ bl sub_80034304
/* 8033FF60 0033CEC0 4B CF 43 A5 */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
/* 8033FF64 0033CEC4 80 01 00 24 */ lwz r0, 0x24(r1)
/* 8033FF68 0033CEC8 7F E3 FB 78 */ mr r3, r31
/* 8033FF6C 0033CECC 83 E1 00 1C */ lwz r31, 0x1c(r1)

View File

@ -310,7 +310,7 @@ lbl_803398B4:
/* 803398BC 0033681C 34 1E 00 34 */ addic. r0, r30, 0x34
/* 803398C0 00336820 41 82 00 0C */ beq lbl_803398CC
/* 803398C4 00336824 38 7E 00 34 */ addi r3, r30, 0x34
/* 803398C8 00336828 4B CF AA 3D */ bl sub_80034304
/* 803398C8 00336828 4B CF AA 3D */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
lbl_803398CC:
/* 803398CC 0033682C 34 1E 00 24 */ addic. r0, r30, 0x24
/* 803398D0 00336830 41 82 00 18 */ beq lbl_803398E8

View File

@ -531,7 +531,7 @@ lbl_803405DC:
/* 803405DC 0033D53C 7F 40 07 75 */ extsb. r0, r26
/* 803405E0 0033D540 41 82 00 0C */ beq lbl_803405EC
/* 803405E4 0033D544 38 61 00 08 */ addi r3, r1, 8
/* 803405E8 0033D548 4B CF 3D 1D */ bl sub_80034304
/* 803405E8 0033D548 4B CF 3D 1D */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
lbl_803405EC:
/* 803405EC 0033D54C 80 BE 00 00 */ lwz r5, 0(r30)
/* 803405F0 0033D550 38 61 00 1C */ addi r3, r1, 0x1c
@ -644,7 +644,7 @@ lbl_80340758:
/* 80340760 0033D6C0 34 1E 00 1C */ addic. r0, r30, 0x1c
/* 80340764 0033D6C4 41 82 00 0C */ beq lbl_80340770
/* 80340768 0033D6C8 38 7E 00 1C */ addi r3, r30, 0x1c
/* 8034076C 0033D6CC 4B CF 3B 99 */ bl sub_80034304
/* 8034076C 0033D6CC 4B CF 3B 99 */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
lbl_80340770:
/* 80340770 0033D6D0 34 1E 00 04 */ addic. r0, r30, 4
/* 80340774 0033D6D4 41 82 00 34 */ beq lbl_803407A8
@ -709,7 +709,7 @@ __ct__11CSimplePoolFR8IFactory:
/* 80340848 0033D7A8 80 85 00 04 */ lwz r4, 4(r5)
/* 8034084C 0033D7AC 38 04 00 01 */ addi r0, r4, 1
/* 80340850 0033D7B0 90 05 00 04 */ stw r0, 4(r5)
/* 80340854 0033D7B4 4B CF 3A B1 */ bl sub_80034304
/* 80340854 0033D7B4 4B CF 3A B1 */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
/* 80340858 0033D7B8 3C 80 80 3D */ lis r4, lbl_803D7A98@ha
/* 8034085C 0033D7BC 38 60 00 08 */ li r3, 8
/* 80340860 0033D7C0 38 84 7A 98 */ addi r4, r4, lbl_803D7A98@l
@ -745,7 +745,7 @@ lbl_803408C4:
/* 803408D0 0033D830 7C 00 18 40 */ cmplw r0, r3
/* 803408D4 0033D834 41 82 00 24 */ beq lbl_803408F8
/* 803408D8 0033D838 7C 83 23 78 */ mr r3, r4
/* 803408DC 0033D83C 4B CF 3A 29 */ bl sub_80034304
/* 803408DC 0033D83C 4B CF 3A 29 */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
/* 803408E0 0033D840 80 01 00 10 */ lwz r0, 0x10(r1)
/* 803408E4 0033D844 90 1F 00 1C */ stw r0, 0x1c(r31)
/* 803408E8 0033D848 80 9F 00 1C */ lwz r4, 0x1c(r31)
@ -754,7 +754,7 @@ lbl_803408C4:
/* 803408F4 0033D854 90 04 00 04 */ stw r0, 4(r4)
lbl_803408F8:
/* 803408F8 0033D858 38 61 00 10 */ addi r3, r1, 0x10
/* 803408FC 0033D85C 4B CF 3A 09 */ bl sub_80034304
/* 803408FC 0033D85C 4B CF 3A 09 */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
/* 80340900 0033D860 80 01 00 24 */ lwz r0, 0x24(r1)
/* 80340904 0033D864 7F E3 FB 78 */ mr r3, r31
/* 80340908 0033D868 83 E1 00 1C */ lwz r31, 0x1c(r1)

View File

@ -556,7 +556,7 @@ lbl_803557C4:
/* 803557D8 00352738 48 00 04 79 */ bl __dt__6CModelFv
lbl_803557DC:
/* 803557DC 0035273C 38 61 00 08 */ addi r3, r1, 8
/* 803557E0 00352740 4B CD EB 25 */ bl sub_80034304
/* 803557E0 00352740 4B CD EB 25 */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
/* 803557E4 00352744 80 01 00 34 */ lwz r0, 0x34(r1)
/* 803557E8 00352748 83 E1 00 2C */ lwz r31, 0x2c(r1)
/* 803557EC 0035274C 83 C1 00 28 */ lwz r30, 0x28(r1)

View File

@ -6266,7 +6266,7 @@ lbl_8032A0B8:
/* 8032A0CC 0032702C 48 03 CD 6D */ bl __dt__15CGenDescriptionFv
lbl_8032A0D0:
/* 8032A0D0 00327030 38 61 00 08 */ addi r3, r1, 8
/* 8032A0D4 00327034 4B D0 A2 31 */ bl sub_80034304
/* 8032A0D4 00327034 4B D0 A2 31 */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
/* 8032A0D8 00327038 80 01 00 34 */ lwz r0, 0x34(r1)
/* 8032A0DC 0032703C 83 E1 00 2C */ lwz r31, 0x2c(r1)
/* 8032A0E0 00327040 7C 08 03 A6 */ mtlr r0

View File

@ -660,7 +660,7 @@ lbl_8035E7DC:
/* 8035E7F0 0035B750 48 00 7F C9 */ bl __dt__20CElectricDescriptionFv
lbl_8035E7F4:
/* 8035E7F4 0035B754 38 61 00 08 */ addi r3, r1, 8
/* 8035E7F8 0035B758 4B CD 5B 0D */ bl sub_80034304
/* 8035E7F8 0035B758 4B CD 5B 0D */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
/* 8035E7FC 0035B75C 80 01 00 34 */ lwz r0, 0x34(r1)
/* 8035E800 0035B760 83 E1 00 2C */ lwz r31, 0x2c(r1)
/* 8035E804 0035B764 7C 08 03 A6 */ mtlr r0
@ -731,4 +731,3 @@ lbl_803D83E0:
# ROM: 0x3D53E0
.asciz "??(??)"
.balign 4

View File

@ -549,7 +549,7 @@ lbl_80330088:
/* 8033009C 0032CFFC 48 03 6A 5D */ bl __dt__18CSwooshDescriptionFv
lbl_803300A0:
/* 803300A0 0032D000 38 61 00 08 */ addi r3, r1, 8
/* 803300A4 0032D004 4B D0 42 61 */ bl sub_80034304
/* 803300A4 0032D004 4B D0 42 61 */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
/* 803300A8 0032D008 80 01 00 34 */ lwz r0, 0x34(r1)
/* 803300AC 0032D00C 83 E1 00 2C */ lwz r31, 0x2c(r1)
/* 803300B0 0032D010 7C 08 03 A6 */ mtlr r0
@ -620,4 +620,3 @@ lbl_803D7970:
# ROM: 0x3D4970
.asciz "??(??)"
.balign 4

View File

@ -161,7 +161,7 @@ lbl_803000EC:
/* 803000EC 002FD04C 7F A3 EB 78 */ mr r3, r29
/* 803000F0 002FD050 48 00 00 29 */ bl sub_80300118
/* 803000F4 002FD054 38 61 00 08 */ addi r3, r1, 8
/* 803000F8 002FD058 4B D3 42 0D */ bl sub_80034304
/* 803000F8 002FD058 4B D3 42 0D */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
/* 803000FC 002FD05C 80 01 00 24 */ lwz r0, 0x24(r1)
/* 80300100 002FD060 83 E1 00 1C */ lwz r31, 0x1c(r1)
/* 80300104 002FD064 83 C1 00 18 */ lwz r30, 0x18(r1)

View File

@ -97,7 +97,7 @@ GetFactory__24CCharacterFactoryBuilderFRC8CAnimRes:
/* 80034928 00031888 38 80 FF FF */ li r4, -1
/* 8003492C 0003188C 48 30 C5 15 */ bl __dt__6CTokenFv
/* 80034930 00031890 38 61 00 08 */ addi r3, r1, 8
/* 80034934 00031894 4B FF F9 D1 */ bl sub_80034304
/* 80034934 00031894 4B FF F9 D1 */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
/* 80034938 00031898 80 01 00 34 */ lwz r0, 0x34(r1)
/* 8003493C 0003189C 83 E1 00 2C */ lwz r31, 0x2c(r1)
/* 80034940 000318A0 83 C1 00 28 */ lwz r30, 0x28(r1)

View File

@ -866,7 +866,7 @@ lbl_80032404:
/* 80032438 0002F398 38 80 FF FF */ li r4, -1
/* 8003243C 0002F39C 48 30 EA 05 */ bl __dt__6CTokenFv
/* 80032440 0002F3A0 38 61 00 24 */ addi r3, r1, 0x24
/* 80032444 0002F3A4 48 00 1E C1 */ bl sub_80034304
/* 80032444 0002F3A4 48 00 1E C1 */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
/* 80032448 0002F3A8 80 9E 00 A8 */ lwz r4, 0xa8(r30)
/* 8003244C 0002F3AC 38 60 00 01 */ li r3, 1
/* 80032450 0002F3B0 80 BE 00 AC */ lwz r5, 0xac(r30)
@ -954,7 +954,7 @@ lbl_80032574:
/* 80032584 0002F4E4 38 80 FF FF */ li r4, -1
/* 80032588 0002F4E8 48 30 E8 B9 */ bl __dt__6CTokenFv
/* 8003258C 0002F4EC 38 61 00 20 */ addi r3, r1, 0x20
/* 80032590 0002F4F0 48 00 1D 75 */ bl sub_80034304
/* 80032590 0002F4F0 48 00 1D 75 */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
lbl_80032594:
/* 80032594 0002F4F4 3C 60 80 3D */ lis r3, lbl_803CCD78@ha
/* 80032598 0002F4F8 3A E0 00 00 */ li r23, 0
@ -2410,7 +2410,7 @@ lbl_800339DC:
/* 800339EC 0003094C 48 30 D4 55 */ bl __dt__6CTokenFv
lbl_800339F0:
/* 800339F0 00030950 38 61 00 08 */ addi r3, r1, 8
/* 800339F4 00030954 48 00 09 11 */ bl sub_80034304
/* 800339F4 00030954 48 00 09 11 */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
/* 800339F8 00030958 48 00 02 5C */ b lbl_80033C54
lbl_800339FC:
/* 800339FC 0003095C 3C 60 80 3D */ lis r3, lbl_803CCD78@ha
@ -2565,14 +2565,14 @@ lbl_80033C20:
/* 80033C30 00030B90 48 30 D2 11 */ bl __dt__6CTokenFv
lbl_80033C34:
/* 80033C34 00030B94 38 61 00 08 */ addi r3, r1, 8
/* 80033C38 00030B98 48 00 06 CD */ bl sub_80034304
/* 80033C38 00030B98 48 00 06 CD */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
/* 80033C3C 00030B9C 48 00 00 18 */ b lbl_80033C54
lbl_80033C40:
/* 80033C40 00030BA0 38 00 00 00 */ li r0, 0
/* 80033C44 00030BA4 38 61 00 08 */ addi r3, r1, 8
/* 80033C48 00030BA8 98 1D 00 00 */ stb r0, 0(r29)
/* 80033C4C 00030BAC 90 1D 00 04 */ stw r0, 4(r29)
/* 80033C50 00030BB0 48 00 06 B5 */ bl sub_80034304
/* 80033C50 00030BB0 48 00 06 B5 */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
lbl_80033C54:
/* 80033C54 00030BB4 BA C1 01 18 */ lmw r22, 0x118(r1)
/* 80033C58 00030BB8 80 01 01 44 */ lwz r0, 0x144(r1)
@ -3064,8 +3064,8 @@ lbl_800342F0:
/* 800342FC 0003125C 38 21 00 10 */ addi r1, r1, 0x10
/* 80034300 00031260 4E 80 00 20 */ blr
.global sub_80034304
sub_80034304:
.global "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
"ReleaseData__Q24rstl10rc_ptr<Pv>Fv":
/* 80034304 00031264 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 80034308 00031268 7C 08 02 A6 */ mflr r0
/* 8003430C 0003126C 90 01 00 14 */ stw r0, 0x14(r1)

View File

@ -79,7 +79,7 @@ lbl_802B2230:
/* 802B2244 002AF1A4 48 00 04 BD */ bl sub_802b2700
lbl_802B2248:
/* 802B2248 002AF1A8 38 61 00 08 */ addi r3, r1, 8
/* 802B224C 002AF1AC 4B D8 20 B9 */ bl sub_80034304
/* 802B224C 002AF1AC 4B D8 20 B9 */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
/* 802B2250 002AF1B0 80 01 00 34 */ lwz r0, 0x34(r1)
/* 802B2254 002AF1B4 83 E1 00 2C */ lwz r31, 0x2c(r1)
/* 802B2258 002AF1B8 83 C1 00 28 */ lwz r30, 0x28(r1)
@ -1869,4 +1869,3 @@ lbl_803D6540:
# ROM: 0x3D3540
.asciz "??(??)"
.balign 4

View File

@ -1140,7 +1140,7 @@ FDecalDataFactory__FRC10SObjectTagR12CInputStreamRC15CVParamTransfer:
/* 802B4624 002B1584 7C 04 03 78 */ mr r4, r0
/* 802B4628 002B1588 48 00 00 21 */ bl "__ct__Q24rstl29auto_ptr<17CDecalDescription>FP17CDecalDescription"
/* 802B462C 002B158C 38 61 00 08 */ addi r3, r1, 8
/* 802B4630 002B1590 4B D7 FC D5 */ bl sub_80034304
/* 802B4630 002B1590 4B D7 FC D5 */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
/* 802B4634 002B1594 80 01 00 24 */ lwz r0, 0x24(r1)
/* 802B4638 002B1598 83 E1 00 1C */ lwz r31, 0x1c(r1)
/* 802B463C 002B159C 7C 08 03 A6 */ mtlr r0

View File

@ -1109,7 +1109,7 @@ lbl_802B205C:
/* 802B2070 002AEFD0 48 00 38 31 */ bl __dt__18CWeaponDescriptionFv
lbl_802B2074:
/* 802B2074 002AEFD4 38 61 00 08 */ addi r3, r1, 8
/* 802B2078 002AEFD8 4B D8 22 8D */ bl sub_80034304
/* 802B2078 002AEFD8 4B D8 22 8D */ bl "ReleaseData__Q24rstl10rc_ptr<Pv>Fv"
/* 802B207C 002AEFDC 80 01 00 34 */ lwz r0, 0x34(r1)
/* 802B2080 002AEFE0 83 E1 00 2C */ lwz r31, 0x2c(r1)
/* 802B2084 002AEFE4 7C 08 03 A6 */ mtlr r0
@ -1180,4 +1180,3 @@ lbl_803D6190:
# ROM: 0x3D3190
.asciz "??(??)"
.balign 4

View File

@ -611,7 +611,7 @@ LIBS = [
["Kyoto/Streams/CZipOutputStream", True],
["Kyoto/Streams/CZipSupport", True],
"Kyoto/CFactoryStore",
"Kyoto/CObjectReference",
["Kyoto/CObjectReference", True],
"Kyoto/CSimplePool",
["Kyoto/CToken", True],
["Kyoto/IObj", True],

View File

@ -18,6 +18,7 @@ public:
template < typename T >
CFactoryFnReturn(T* ptr) : obj(TToken< T >::GetIObjObjectFor(ptr).release()) {}
IObj* GetObjForTransfer() const { return obj.release(); }
private:
rstl::auto_ptr< CObjOwnerDerivedFromIObjUntyped > obj;
};

View File

@ -17,7 +17,7 @@ public:
// , x10_object(obj.release())
// , x14_params(CVParamTransfer::Null()) {}
~CObjectReference();
CObjectReference(IObjectStore* store, const rstl::auto_ptr< IObj >& obj, SObjectTag tag,
CObjectReference(IObjectStore& store, const rstl::auto_ptr< IObj >& obj, const SObjectTag& tag,
CVParamTransfer xfer);
bool IsLoaded() const { return x10_object != nullptr; }
@ -27,12 +27,15 @@ public:
void Lock();
void Unlock();
IObj* GetObject();
void Unload();
void CancelLoad();
bool IsLoading() const;
const SObjectTag& GetTag() const { return x4_objTag; }
private:
short x0_refCount;
bool x2_locked : 1;
ushort x2_lockCount : 15;
short x0_refCount : 16;
short x2_lockCount : 15;
short x3_loading : 1;
SObjectTag x4_objTag;
IObjectStore* xc_objectStore;
IObj* x10_object;

View File

@ -11,9 +11,8 @@
class IFactory {
public:
virtual ~IFactory() {}
virtual CFactoryFnReturn Build(const SObjectTag&, const CVParamTransfer&, CObjectReference*) = 0;
virtual void BuildAsync(const SObjectTag&, const CVParamTransfer&, rstl::auto_ptr< IObj >*,
CObjectReference*) = 0;
virtual CFactoryFnReturn Build(const SObjectTag&, const CVParamTransfer&) = 0;
virtual void BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**) = 0;
virtual void CancelBuild(const SObjectTag&) = 0;
virtual bool CanBuild(const SObjectTag&) = 0;
virtual const SObjectTag* GetResourceIdByName(const char* name) const = 0;
@ -24,13 +23,12 @@ class CResFactory : public IFactory {
public:
CResFactory();
~CResFactory() override {}
CFactoryFnReturn Build(const SObjectTag&, const CVParamTransfer&, CObjectReference*) override;
void BuildAsync(const SObjectTag&, const CVParamTransfer&, rstl::auto_ptr< IObj >*,
CObjectReference*) override;
void CancelBuild(const SObjectTag&) override;
bool CanBuild(const SObjectTag&) override;
const SObjectTag* GetResourceIdByName(const char* name) const override;
~CResFactory() {}
CFactoryFnReturn Build(const SObjectTag&, const CVParamTransfer&);
void BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**);
void CancelBuild(const SObjectTag&);
bool CanBuild(const SObjectTag&);
const SObjectTag* GetResourceIdByName(const char* name) const;
uint ResourceSize(const SObjectTag& tag) const { return x4_resLoader.ResourceSize(tag); }

View File

@ -10,7 +10,6 @@
#include "Kyoto/IObjectStore.hpp"
class IFactory;
class CSimplePool : public IObjectStore {
public:
CSimplePool(IFactory& factory);
@ -22,7 +21,7 @@ public:
virtual CToken GetObj(const char* name, CVParamTransfer xfer);
virtual bool HasObject(const SObjectTag& tag);
virtual bool ObjectIsLive(const SObjectTag& tag);
virtual unkptr GetFactory();
virtual IFactory& GetFactory() { return x18_factory; }
virtual void Flush();
virtual void ObjectUnreferenced(const SObjectTag& tag);
@ -30,7 +29,7 @@ private:
uchar x4_;
uchar x5_;
rstl::hash_map< unkptr, unkptr, void, void > x8_resources;
unkptr x18_factory;
IFactory& x18_factory;
rstl::rc_ptr< CVParamTransfer > x1c_paramXfr;
};
CHECK_SIZEOF(CSimplePool, 0x20)

View File

@ -8,6 +8,7 @@
#include "rstl/auto_ptr.hpp"
#include "rstl/rc_ptr.hpp"
class IFactory;
class IObjectStore {
public:
virtual CToken GetObj(const SObjectTag& tag, CVParamTransfer xfer) = 0;
@ -16,7 +17,7 @@ public:
virtual CToken GetObj(const char* name, CVParamTransfer xfer) = 0;
virtual bool HasObject(const SObjectTag& tag) = 0;
virtual bool ObjectIsLive(const SObjectTag& tag) = 0;
virtual unkptr GetFactory() = 0;
virtual IFactory& GetFactory() = 0;
virtual void Flush() = 0;
virtual void ObjectUnreferenced(const SObjectTag& tag) = 0;
};

View File

@ -0,0 +1,97 @@
#include "Kyoto/CObjectReference.hpp"
#include "Kyoto/Alloc/CMemory.hpp"
#include "Kyoto/CResFactory.hpp"
#include "Kyoto/CSimplePool.hpp"
CObjectReference::CObjectReference(IObjectStore& store, const rstl::auto_ptr< IObj >& obj,
const SObjectTag& tag, CVParamTransfer xfer)
: x0_refCount(0)
, x2_lockCount(0)
, x3_loading(false)
, x4_objTag(tag)
, xc_objectStore(&store)
, x10_object(obj.release())
, x14_params(xfer) {}
CObjectReference::CObjectReference(const rstl::auto_ptr< IObj >& obj)
: x0_refCount(0)
, x2_lockCount(0)
, x3_loading(false)
, xc_objectStore(nullptr)
, x10_object(obj.release())
, x14_params(CVParamTransfer::Null()) {}
CObjectReference::~CObjectReference() {
if (x10_object) {
delete x10_object;
} else if (x3_loading) {
xc_objectStore->GetFactory().CancelBuild(x4_objTag);
}
}
void CObjectReference::Lock() {
++x2_lockCount;
if (x10_object == nullptr && !x3_loading) {
xc_objectStore->GetFactory().BuildAsync(x4_objTag, x14_params, &x10_object);
x3_loading = true;
}
}
IObj* CObjectReference::GetObject() {
if (x10_object == nullptr) {
x10_object = xc_objectStore->GetFactory().Build(x4_objTag, x14_params).GetObjForTransfer();
}
x3_loading = false;
return x10_object;
}
void CObjectReference::Unload() {
delete x10_object;
x10_object = nullptr;
x3_loading = false;
}
void CObjectReference::CancelLoad() {
if (xc_objectStore == nullptr) {
return;
}
if (!IsLoading()) {
return;
}
xc_objectStore->GetFactory().CancelBuild(x4_objTag);
x3_loading = false;
}
int CObjectReference::RemoveReference() {
--x0_refCount;
if (x0_refCount == 0) {
if (x10_object != nullptr) {
Unload();
} else if (IsLoading()) {
CancelLoad();
}
if (xc_objectStore != nullptr) {
xc_objectStore->ObjectUnreferenced(x4_objTag);
}
}
return x0_refCount;
}
void CObjectReference::Unlock() {
--x2_lockCount;
if (x2_lockCount != 0) {
return;
}
if (x10_object != nullptr && xc_objectStore != nullptr) {
Unload();
} else if (IsLoading()) {
CancelLoad();
}
}
bool CObjectReference::IsLoading() const { return x3_loading && x10_object == nullptr; }