Page MenuHome

BLI: Improve CPPType system.
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on Nov 12 2022, 2:06 PM.

Details

Summary

Goals:

  • Support bidirectional type lookups. E.g. finding the base type of a field was supported, but not the other way around. This also removes the todo in get_vector_type. To achieve this, types have to be registered up-front.
  • Separate CPPType from other "type traits". For example, previously ValueOrFieldCPPType adds additional behavior on top of CPPType. Previously, it was a subclass, now it just contains a reference to the CPPType it corresponds to. This follows the composition-over-inheritance idea. This makes it easier to have self-contained "type traits" without having to put everything into CPPType.

Diff Detail

Repository
rB Blender
Branch
cpp-type-cleanup (branched from master)
Build Status
Buildable 24621
Build 24621: arc lint + arc unit

Event Timeline

Jacques Lucke (JacquesLucke) requested review of this revision.Nov 12 2022, 2:06 PM
Jacques Lucke (JacquesLucke) created this revision.
Jacques Lucke (JacquesLucke) edited the summary of this revision. (Show Details)
  • Merge branch 'master' into cpp-type-cleanup
  • cleanup

The change makes sense, it seems a bit more flexible/generic now. My main question is why registering CPP types is an explicit step now (BKE_cpp_types_init etc.). Wasn't it done at compile time before?

To continue the inspiration from the "CPP" part of the name, what do you think about "value type" rather than "base type"? Just curious.

Previously, there was no registration. The CPPType of a specific type was generated on first use (CPPType::get<T>). However, to get e.g. the vector type based on the value type, the vector type has to be registered before the lookup.

Using "value" instead of "base" sounds reasonable.

Ah, okay, that makes sense.

This revision is now accepted and ready to land.Nov 12 2022, 6:15 PM
This revision was automatically updated to reflect the committed changes.