Skip to content

Conversation

@heinezen
Copy link
Member

This allows fetching a nyan::Object from a nyan::View as std::shared_ptr.

Even though

nyan/nyan/object.h

Lines 63 to 67 in 19e742a

// This constructor is public, but can't be invoked since the Restricted
// class is not available. We use this to be able to invoke make_shared
// within this class, but not outside of it.
Object(Object::Restricted, const fqon_t &name, const std::shared_ptr<View> &origin) :
Object(name, origin) {};
is in the code, I'm not sure why nyan::Object handles shouldn't be shared. I might be missing something there, but I don't see the disadvantage of enabling the shared pointers.

The main motivation for this change is a change to the activity system in openage PR SFTtech/openage#1688 to include nyan::Objects. Using raw objects/references makes testing the activity system more complicated as it requires us to initialize a whole nyan database for the tests. If we use shared pointers, we can get away with nullptr wrapped in shared_ptr as a workaround.

@heinezen heinezen added improvement improves existing functionality c++ involves C++ code labels May 10, 2025
@TheJJ TheJJ merged commit 12f2735 into SFTtech:master May 10, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ involves C++ code improvement improves existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants