Skip to content

Commit

Permalink
Merge commit '08b0d22eac529307b2368a0a7a841936705d4209' into release/…
Browse files Browse the repository at this point in the history
…v1.7
  • Loading branch information
muit committed Dec 6, 2024
2 parents 3c1632f + 08b0d22 commit c6e3794
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
9 changes: 4 additions & 5 deletions Include/PipeReflect.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,10 @@ namespace p
}


template<typename T>
template<typename Type>
TypeId RegisterTypeId()
{ // Static to only register once
using T = Mut<Type>;
static bool bRegistered = false;
const TypeId typeId = GetTypeId<T>();
if (!bRegistered && BeginTypeId(typeId))
Expand Down Expand Up @@ -676,11 +677,9 @@ private: \
\
static void __BuildProperty(p::MetaCounter<id_name>) \
{ \
p::AddTypeProperty<decltype(name)>( \
[](void* instance) { \
p::AddTypeProperty<decltype(name)>([](void* instance) { \
return (void*)&static_cast<Self*>(instance)->name; \
}, \
#name, p::InitPropertyFlags(flags)); \
}, #name, p::InitPropertyFlags(flags)); \
/* Registry next property if any */ \
__BuildProperty(p::MetaCounter<id_name + 1>{}); \
} \
Expand Down
5 changes: 4 additions & 1 deletion Src/PipeReflect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,10 @@ namespace p

TPtr<BaseObject> ObjectOwnership::nextOwner{};

ObjectOwnership::ObjectOwnership() : self{}, owner{Move(nextOwner)} {}
ObjectOwnership::ObjectOwnership() : self{}, owner{Move(nextOwner)}
{
;
}
const TPtr<BaseObject>& ObjectOwnership::AsPtr() const
{
return self;
Expand Down
13 changes: 6 additions & 7 deletions Tests/Reflection/Object.spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@

using namespace snowhouse;
using namespace bandit;
using namespace p;


class TestObject : public Object
class TestObject : public p::Object
{
using Super = Object;
public:
using Super = p::Object;
P_CLASS(TestObject);

public:
bool bConstructed = false;

TestObject()
Expand All @@ -28,15 +27,15 @@ go_bandit([]() {
describe("Reflection.Object", []() {
describe("Pointers", []() {
it("Can create object", [&]() {
auto owner = MakeOwned<TestObject>();
auto owner = p::MakeOwned<TestObject>();

AssertThat(owner.Get(), Is().Not().EqualTo(nullptr));
AssertThat(owner->bConstructed, Equals(true));
});

it("Can create object with owner", [&]() {
auto owner = MakeOwned<TestObject>();
auto owner2 = MakeOwned<TestObject>(owner);
auto owner = p::MakeOwned<TestObject>();
auto owner2 = p::MakeOwned<TestObject>(owner);

AssertThat(owner2->bConstructed, Equals(true));
AssertThat(owner2->GetOwner().IsValid(), Equals(true));
Expand Down

0 comments on commit c6e3794

Please sign in to comment.