Add birb_assert_type

Review Request #3735 — Created Jan. 3, 2025 and submitted

Information

birb/birb
default

Reviewers

This asserts that the object is of an exact type and outputs a helpful message
if it is not.

Here's some example output:

ERROR:../birb/tests/test_string_object.c:38:test_birb_string_object_property_counter: foo is NULL and not an instance of BirbStringObject

ERROR:../birb/tests/test_string_object.c:38:test_birb_string_object_property_counter: obj is of type BirbStringObject not GObject

Ran the string object test under valgrind and called in the turtles.

Summary ID
Add birb_assert_type
This asserts that the object is of an exact type and outputs a helpful message if it is not.
a99a04474b867d631298e55a95ff4411ec9cacc4
Description From Last Updated

Technically, you should assign instance and type to new private variables in here to prevent multiple evaluation (see GLib's implementation). …

QuLogicQuLogic
QuLogic
  1. 
      
  2. birb/birbassert.h (Diff revision 1)
     
     
    Show all issues

    Technically, you should assign instance and type to new private variables in here to prevent multiple evaluation (see GLib's implementation). (though the private variable can't apply to #instance.)

    1. I thought the extra ()'s worked around that but whatever, using a variable will make it easier to understand.

    2. The parentheses are for operator precendence if the input is not just a simple identifier.

      You also missed the same for type.

  3. 
      
grim
grim
QuLogic
  1. Ship It!
  2. 
      
grim
Review request changed
Status:
Completed