google / filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
https://google.github.io/filament/
Apache License 2.0
17.35k stars 1.84k forks source link

A new stream-based Panic API #7869

Closed pixelflinger closed 1 month ago

pixelflinger commented 1 month ago

going forward, instead of using the printf style syntax for panics we use the c++ stream syntax

The new macros that replace ASSERT_*CONDITON are

FILAMENT_CHECK_PRECONDITON FILAMENT_CHECK_POSTCONDITION FILAMENT_CHECK_ARITIHMETIC

Example usage:

FILAMENT_CHECK_PRECONDITON(condition) << "Message";

The effect is exactly the same as before, but it'll let clients use Abseil's logging facilities.

pixelflinger commented 1 month ago

LGTM. Just an observation: if a user does this:

FILAMENT_CHECK_POSTCONDITION(false);

Then we get an empty "reason" string. I wonder if there's a way we can require users to provide a message (if we even want to require it) at compile time. Or, maybe we could provide a default message.

interesting idea. I think we probably can provide the stringified condition. I will give it a shot.