Skip to content

Allow retrieving nyan::Object handle as shared_ptr #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2025

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