11.2.4.1 Declarations and definitions for instances of mbfl_default_class

Preprocessor Macro: mbfl_default_class_declare (DEFCLS_PROXY_VARNAME)
Preprocessor Macro: mbfl_default_class_declare_global (DEFCLS_PROXY_VARNAME)

Define the variables needed to handle a new class, subclass of mbfl_default_object. The data variable is declared using, respectively: declare or declare -g.

We can think of these macros as working like mbfl_declare_varref(): they declare variables, one of which is a data variable whose name we can pass around as parameter to functions.

Function: mbfl_default_class_define DEFCLS DEFSUPERCLS CLASS_NAME FIELD_NAME

Define a new default class DEFCLS whose superclass is DEFSUPERCLS. By using this function we decide that the metaclass of the new class is mbfl_default_class.

If we want to subclass mbfl_default_object, then the parameter DEFSUPERCLS must be the datavar of mbfl_default_object; otherwise it must be the datavar of a subclass of mbfl_default_object.

The name of the new class is the identifier CLASS_NAME, which must be a string satisfying mbfl_string_is_identifier().

The following functions are defined:

CLASS_NAME_define DEFOBJ FIELD_VALUE

Initialise DEFOBJ as instance of DEFCLS filling its fields with the given FIELD_VALUE parameters.

CLASS_NAME_p DEFOBJ

Return true if DEFOBJ is an instance of DEFCLS; otherwise return false.

CLASS_NAME_FIELD_NAME_var RV DEFOBJ

Field accessor: store in the result variable RV the value of the field FIELD_NAME.

CLASS_NAME_FIELD_NAME_set DEFOBJ NEW_FIELD_VALUE

Field mutator: store in the field the new value NEW_FIELD_VALUE.


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