Module autocxx::subclass

source ·
Expand description

Module to make Rust subclasses of C++ classes. See CppSubclass for details.

Modules

  • A prelude containing all the traits and macros required to create Rust subclasses of C++ classes. It’s recommended that you:

Traits

  • A trait to be implemented by a subclass which knows how to construct its C++ peer object. Specifically, the implementation here will arrange to call one or other of the make_unique methods to be found on the superclass of the C++ object. If the superclass has a single trivial constructor, then this is implemented automatically for you. If there are multiple constructors, or a single constructor which takes parameters, you’ll need to implement this trait for your subclass in order to call the correct constructor.
  • A subclass of a C++ type.
  • Provides default constructors for subclasses which implement Default.
  • Trait to be implemented by subclasses which are self-owned, i.e. not owned externally by either Rust or C++ code, and thus need the ability to delete themselves when some virtual function is called.
  • Provides default constructors for subclasses which implement Default and are self-owning.

Attribute Macros

  • Deprecated - use subclass instead. Attribute to state that a Rust struct is a C++ subclass. This adds an additional field to the struct which autocxx uses to track a C++ instantiation of this Rust subclass.
  • Declare a Rust subclass of a C++ class. You can use this in two ways: