Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mcy
Copy link
Owner

@mcy mcy commented Feb 21, 2025

This is an attempt to redo the vtable work in #26 that I wound up rolling back. In the new approach, we have:

  • best::dyn<Interface> is a special type for putting in a best::ptr and friends, which emulates Rust's dyn Trait.
  • best::interface defines what can go in a best::dyn, which is essentially a type that provides a best::vtable plus an untyped pointer. It is expected, but not required, that this type provide helper functions that emulate calling virtual functions. The BEST_INTERFACE macro makes it "easy" to define these.
    • I tried very hard to avoid the macro, but I gave up.
  • To support BEST_INTERFACE, I've added macro.h which contains all of the usual very evil macro-writing-macros.
  • To support generating vtable entries, best::fnref now exposes best::fnref::fnptr, which makes it easy to convert between the member function signature (which lacks a this pointer) and the equivalent with a void* this argument.
  • best::dynptr and best::dynbox are convenience aliases for working with dyns.
    • best::box now supports best::try_copy, which is needed because best::interfaces cannot guarantee copying at the moment.

@mcy mcy merged commit 74465e0 into main Feb 21, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants