2.7.6 Scope of behaviors

Component behaviors and port behaviors are both in the scope of the component and can directly access the resources of the component.

Behaviors that want to return pointers or instances of types that are defined in the resources section of the same component must use the COMPONENT_CLASS_NAME() construct to access the type in the resource section. COMPONENT_CLASS_NAME(x) represents the scope of component x, and when returning a pointer or an instance of a type that is declared in the resources section of component x, you must explicitly specify this scope when specifying the return type of the behavior.

Component scope with COMPONENT_CLASS_NAME(x)
component MyComponent
{
    resources
    {
        struct status_t
        {
            int i;
        };
        status_t status;
    }

    behavior getStatus():status_t  // Incorrect: status_t is unknown outside the behavior.
    {
        return status;
    }

    behavior getStatus(): COMPONENT_CLASS_NAME(MyComponent)::status_t  // Correct: prefix the return type with the scope.
    {
        return status;
    }
}
Non-ConfidentialPDF file icon PDF version101092_0100_03_en
Copyright © 2014–2018 Arm Limited or its affiliates. All rights reserved.