coan 4.2.4
Macros for the component
Collaboration diagram for Macros for the component:

Defines

#define IMPLEMENT_STATIC(component, init_type)
#define IMPLEMENT_DYNAMIC(component, init_type)
#define IMPLEMENT(component, init_type)   IMPLEMENT_STATIC(component,init_type)
#define USE_STATIC_INITIALISER(component)
#define DEFINE_USER_INIT(component)
#define DEFINE_USER_FINIS(component)
#define INCLUDE_PUBLIC(component)   PUBLIC_STATE_T(component) PUBLIC_STATE(component)
#define STATE_DEF(component)   typedef struct component##_state_s
#define STATE_T(component)   component##_state_t
#define NO_PRIVATE_STATE(component)   typedef PUBLIC_STATE_T(component) STATE_T(component)
#define GET_STATE(component, field)   GET_STATIC_STATE(component,field)
#define SET_STATE(component, field)   SET_STATIC_STATE(component,field)

Enumerations

enum  component_storage_type { STATE_STATIC, STATE_DYNAMIC }
enum  component_initialisation_type { ZERO_INITABLE, STATIC_INITABLE, USER_INITABLE }

Detailed Description

implementation file.


Define Documentation

#define DEFINE_USER_FINIS (   component)
Value:
DECL_USER_FINIS(component);\
        DECL_USER_FINIS_HANDLE(component) = &USER_FINIS(component);\
        void USER_FINIS(component)

Define a user finalisation function for component.

Parameters:
componentName of the component. The function body should be written immediately after the macro invocation:

The macro generates the function signature:

A user finalisation function must be defined if the component is implemented with initialisation type USER_INITABLE. The user finalisation function USER_FINIS(component) should not be confused with the generated component finalisation function FINITOR(component). USER_FINIS(component) does not need to destroy storage for the component's state, even if the component is implemented dynamically. That dynamic storage will be disposed of by FINITOR(component). USER_FINIS(component) need only finalise the elements of the state structure.

Definition at line 732 of file state_utils.h.

#define DEFINE_USER_INIT (   component)
Value:
DECL_USER_INIT(component);\
        DECL_USER_INIT_HANDLE(component) = &USER_INIT(component);\
        void USER_INIT(component)

Define a user initialisation function for component.

Parameters:
componentName of the component. The function body should be written immediately after the macro invocation:

The macro generates the function signature:

A user initialisation function must be defined if the component is implemented with initialisation type USER_INITABLE. The user initialisation function USER_INIT(component) should not be confused with the generated component initialisation function INITOR(component). USER_INIT(component) does not need to provide storage for the component's state. It can assume that storage is addressed by the STATE_T(component) * argument and need only initialise the the elements of the state structure.

Definition at line 708 of file state_utils.h.

#define GET_STATE (   component,
  field 
)    GET_STATIC_STATE(component,field)
#define IMPLEMENT (   component,
  init_type 
)    IMPLEMENT_STATIC(component,init_type)

Abbreviate IMPLEMENT_STATIC as IMPLEMENT when DEFAULT_STATIC_STATE is defined.

Definition at line 666 of file state_utils.h.

#define IMPLEMENT_DYNAMIC (   component,
  init_type 
)
Value:
DECL_DYNAMIC_STATE(component);\
        SELECT_DYNAMIC(component);\
        SELECT_INITIALISATION_TYPE(component,init_type);\
        DECL_STATIC_INITIALISER_HANDLE(component);\
        DECL_USER_INIT_HANDLE(component);\
        DECL_USER_FINIS_HANDLE(component);\
        DEFINE_INITOR(component)\
        DEFINE_FINITOR(component)

Implement the component's state in dynamic storage

Parameters:
componentName of the component
init_typeType of component initialisation. One of:
  • ZERO_INITABLE
  • STATIC_INITABLE
  • USER_INITABLE

Definition at line 651 of file state_utils.h.

#define IMPLEMENT_STATIC (   component,
  init_type 
)
Value:
DECL_STATIC_STATE(component);\
        SELECT_STATIC(component);\
        SELECT_INITIALISATION_TYPE(component,init_type);\
        DECL_STATIC_INITIALISER_HANDLE(component);\
        DECL_USER_INIT_HANDLE(component);\
        DECL_USER_FINIS_HANDLE(component);\
        DEFINE_INITOR(component)\
        DEFINE_FINITOR(component)

Implement the component's state in static storage

Parameters:
componentName of the component
init_typeType of component initialisation. One of:
  • ZERO_INITABLE
  • STATIC_INITABLE
  • USER_INITABLE

Definition at line 634 of file state_utils.h.

#define INCLUDE_PUBLIC (   component)    PUBLIC_STATE_T(component) PUBLIC_STATE(component)

Invoke this macro immediately after opening STATE_DEF(component) to place the public state instance at the start of the state instance. It must be invoked at that position if the component has public as well as private state.

Parameters:
componentName of the component

Definition at line 743 of file state_utils.h.

#define NO_PRIVATE_STATE (   component)    typedef PUBLIC_STATE_T(component) STATE_T(component)

Invoke this macro in a component's implementation file in place of STATE_DEF(component) to say that the component's global state is simply its public state (if any ).

Parameters:
componentName of the component

Definition at line 768 of file state_utils.h.

#define SET_STATE (   component,
  field 
)    SET_STATIC_STATE(component,field)

Abbreviate SET_STATIC_STATE as SET_STATE when DEFAULT_STATE_STATIC is defined.

Invoke this macro in the component's implementation file to code an assignable reference to a field in the component's global state.

Parameters:
componentName of the component
fieldName of the field to be evaluated in the component's state.

If the field also belongs to the component's public state, then prefer SET_PUBLIC.

Definition at line 795 of file state_utils.h.

Referenced by args_finis(), chew_on(), chew_toplevel(), close_io(), contradiction_policy(), dataset_filter_filetypes(), debugging(), Dendif(), drop(), ensure_buf(), eval_definition_text(), eval_line(), exitcode(), if_control_toplevel(), line_despatch_no_op(), make_backup_name(), make_tempfile(), nest(), open_io(), parse_args_file(), parse_command_args(), Pendif(), print(), read_filename(), readon(), save_contradiction(), save_read_pos(), set_exit_flags(), vbail(), and vreport().

#define STATE_DEF (   component)    typedef struct component##_state_s

Invoke this macro in a component's implementation file to open the definition of the component's global state structure:

Parameters:
componentName of the component

Definition at line 752 of file state_utils.h.

#define STATE_T (   component)    component##_state_t

Invoke this macro in a component's implementation file to close the definition of the component's global state:

Parameters:
componentName of the component

Definition at line 761 of file state_utils.h.

#define USE_STATIC_INITIALISER (   component)
Value:

Declare a static initialiser for the component.

Parameters:
componentThe name of the component. The macro invocation should be immediately followed by the specification of the static initialiser:

The static initialiser will be copied into the component's global state instance whenever INITIALISE(component) is invoked.

Definition at line 684 of file state_utils.h.


Enumeration Type Documentation

The initialisation type of the component's state

Enumerator:
ZERO_INITABLE 

Module is zero-initialisable

STATIC_INITABLE 

Module has a constant static initialiser

USER_INITABLE 

Module has user-defined initialisation and finalisation functions

Definition at line 616 of file state_utils.h.

The storage type of the component's state

Enumerator:
STATE_STATIC 

Module's state is in static storage

STATE_DYNAMIC 

Module's state is in dynamic storage

Definition at line 608 of file state_utils.h.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines