11.2.3.2 Predicates on instances of mbfl_default_object

Function: mbfl_default_object_is_a DEFOBJ DEFCLS

Return true if the class of DEFOBJ is DEFCLS or a subclass of DEFCLS.

Given the class diagram, in which not all the connections are depicted:

            -------------------------------------------------------------------
           |                           metaclass                               |
           |                                                                   |
 -class---------------                                                         |
| mbfl_default_object |<-----------+---------------------------                |
 ---------------------             |                           |               |
           ^                       |                           |               |
           | superclass            | superclass                | superclass    |
           |                       |                           |               |
 -class--------------------     -class--   metaclass   -metaclass----------    |
| mbfl_predefined_constant |   | colour |------------>| mbfl_default_class |   |
 --------------------------     --------               --------------------    |
                                   ^                       ^                   |
                                   | class                 | superclass        |
                                   |                       |                   |
     -instance--------             |           -metaclass-------------------   |
    | DARK_SLATE_GRAY |------------           | mbfl_default_abstract_class |<-
     -----------------                         -----------------------------

we can understand the following code:

mbfl_default_class_declare(COLOUR)
mbfl_default_object_declare(DARK_SLATE_BLUE)

mbfl_default_class_define _(COLOUR) _(mbfl_default_object) 'colour' r g b
colour_define _(DARK_SLATE_BLUE) 72 61 139

mbfl_default_object_is_a _(DARK_SLATE_BLUE) _(mbfl_default_object)              ⇒ true
mbfl_default_object_is_a _(DARK_SLATE_BLUE) _(COLOUR)                           ⇒ true
mbfl_default_object_is_a _(DARK_SLATE_BLUE) _(mbfl_predefined_constant)         ⇒ false
mbfl_default_object_is_a _(DARK_SLATE_BLUE) _(mbfl_default_class)               ⇒ false
mbfl_default_object_is_a _(DARK_SLATE_BLUE) _(mbfl_default_abstract_class)      ⇒ false

mbfl_default_object_is_a _(COLOUR) _(mbfl_default_object)                       ⇒ true
mbfl_default_object_is_a _(COLOUR) _(mbfl_default_class)                        ⇒ true
mbfl_default_object_is_a _(COLOUR) _(mbfl_default_abstract_class)               ⇒ false

There are also the following cases:

mbfl_default_object_is_a _(mbfl_default_object) _(mbfl_default_object)          ⇒ true
mbfl_default_object_is_a _(mbfl_default_object) _(mbfl_default_class)           ⇒ true
mbfl_default_object_is_a _(mbfl_default_object) _(mbfl_default_abstract_class)  ⇒ true

mbfl_default_object_is_a _(mbfl_default_class)  _(mbfl_default_object)          ⇒ true
mbfl_default_object_is_a _(mbfl_default_class)  _(mbfl_default_class)           ⇒ true
mbfl_default_object_is_a _(mbfl_default_class)  _(mbfl_default_abstract_class)  ⇒ false

mbfl_default_object_is_a _(mbfl_default_abstract_class)  _(mbfl_default_object)          ⇒ true
mbfl_default_object_is_a _(mbfl_default_abstract_class)  _(mbfl_default_class)           ⇒ true
mbfl_default_object_is_a _(mbfl_default_abstract_class)  _(mbfl_default_abstract_class)  ⇒ false

This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.