Skip to content

Conversation

@silverweed
Copy link
Contributor

This Pull request:

  • introduces RFile::GetKeyInfo (necessary for the non-templated Get pythonization)
  • pythonizes the factory methods, Get, Put, GetKeyInfo and ListKeys.

Get/Put: allow them to be called without template arguments, check the type at runtime
GetKeyInfo: return None instead of std::nullopt
ListKeys: use keyword arguments instead of bitmask for flags

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

Copy link
Member

@vepadulano vepadulano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this already looks quite good! I just left a couple of comments for clarifications and minor improvements to consider.

Comment on lines +99 to +104
def rfile_open_wrapper(klass, *args):
rfile = original(*args)
rfile._OriginalGet = rfile.Get
rfile.Get = _RFile_Get(rfile)
rfile._OriginalPut = rfile.Put
rfile.Put = _RFile_Put(rfile)
return rfile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's slightly weird to see these lines here as they do not relate to the Open method per se. Usually these are placed in the function that is wrapped by the @pythonization decorator

"""
Prevent the creation of RFile through constructor (must use a factory method)
"""
raise NotImplementedError("RFile can only be created via Recreate, Open or Update")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@github-actions
Copy link

github-actions bot commented Oct 22, 2025

Test Results

    20 files      20 suites   3d 13h 13m 37s ⏱️
 3 695 tests  3 694 ✅ 0 💤 1 ❌
72 097 runs  72 096 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit 013c747.

♻️ This comment has been updated with latest results.

Comment on lines +242 to +244
[[nodiscard]] void *GetUntyped(std::string_view path,
std::variant<const char *, std::reference_wrapper<const std::type_info>> type) const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is private and only use in the source file, would this be an option:

Suggested change
[[nodiscard]] void *GetUntyped(std::string_view path,
std::variant<const char *, std::reference_wrapper<const std::type_info>> type) const;
template <typename T>
[[nodiscard]] void *GetUntyped(std::string_view path,
T type) const;

(TClass::GetClass itself has the 2 overloads).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can't work because it's also called from the header (in Get,which cannot be moved to the cxx)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. This is then down to a stylistic choice. You could still use the template but with one level of indirection (2 non templated one line overloads implemented in the source file and 1 templated Impl function)

Copy link
Contributor

@jblomer jblomer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I'll leave approval up to the other reviewers


/// Returns an **owning** pointer to the object referenced by `key`. The caller must delete this pointer.
/// This method is meant to only be used by the pythonization.
[[nodiscard]] void *GetRFileObjectFromKey(RFile &file, const RKeyInfo &key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would prefer a special handling of Get<void>(...) that doesn't check types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if you mean:

  1. in this function (but since it's not templated I'm not sure what you mean)
  2. instead of this function
  3. in RFile::Get in general, unrelated to this function

@silverweed silverweed added the clean build Ask CI to do non-incremental build on PR label Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clean build Ask CI to do non-incremental build on PR in:I/O in:Python Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants