parameters: (typeclass, struct_attr, python_attr)
docstring: Make an automatic attribute wrapper exposing member named *struct_attr*
      as a read-only attribute named *python_attr*.
      The given *typeclass*'s model must be a StructModel subclass.
docstring_summary: Make an automatic attribute wrapper exposing member named *struct_attr*
      as a read-only attribute named *python_attr*.
      The given *typeclass*'s model must be a StructModel subclass.
docstring_tokens: Make an automatic attribute wrapper exposing member named * struct_attr * as a read - only attribute named * python_attr * . The given * typeclass * s model must be a StructModel subclass .
function: def make_attribute_wrapper(typeclass, struct_attr, python_attr):
      """
      Make an automatic attribute wrapper exposing member named *struct_attr*
      as a read-only attribute named *python_attr*.
      The given *typeclass*'s model must be a StructModel subclass.
      """
      from .typing.templates import AttributeTemplate
      from .datamodel import default_manager
      from .datamodel.models import StructModel
      from .targets.imputils import impl_ret_borrowed
      from . import cgutils
  
      if not isinstance(typeclass, type) or not issubclass(typeclass, types.Type):
          raise TypeError("typeclass should be a Type subclass, got %s"
                          % (typeclass,))
  
      def get_attr_fe_type(typ):
          """
          Get the Numba type of member *struct_attr* in *typ*.
          """
          model = default_manager.lookup(typ)
          if not isinstance(model, StructModel):
              raise TypeError("make_struct_attribute_wrapper() needs a type "
                              "with a StructModel, but got %s" % (model,))
          return model.get_member_fe_type(struct_attr)
  
      @infer_getattr
      class StructAttribute(AttributeTemplate):
          key = typeclass
  
          def generic_resolve(self, typ, attr):
              if attr == python_attr:
                  return get_attr_fe_type(typ)
  
      @lower_getattr(typeclass, python_attr)
      def struct_getattr_impl(context, builder, typ, val):
          val = cgutils.create_struct_proxy(typ)(context, builder, value=val)
          attrty = get_attr_fe_type(typ)
          attrval = getattr(val, struct_attr)
          return impl_ret_borrowed(context, builder, attrty, attrval)
function_tokens: def make_attribute_wrapper ( typeclass , struct_attr , python_attr ) : from . typing . templates import AttributeTemplate from . datamodel import default_manager from . datamodel . models import StructModel from . targets . imputils import impl_ret_borrowed from . import cgutils if not isinstance ( typeclass , type ) or not issubclass ( typeclass , types . Type ) : raise TypeError ( "typeclass should be a Type subclass, got %s" % ( typeclass , ) ) def get_attr_fe_type ( typ ) : """
          Get the Numba type of member *struct_attr* in *typ*.
          """ model = default_manager . lookup ( typ ) if not isinstance ( model , StructModel ) : raise TypeError ( "make_struct_attribute_wrapper() needs a type " "with a StructModel, but got %s" % ( model , ) ) return model . get_member_fe_type ( struct_attr ) @ infer_getattr class StructAttribute ( AttributeTemplate ) : key = typeclass def generic_resolve ( self , typ , attr ) : if attr == python_attr : return get_attr_fe_type ( typ ) @ lower_getattr ( typeclass , python_attr ) def struct_getattr_impl ( context , builder , typ , val ) : val = cgutils . create_struct_proxy ( typ ) ( context , builder , value = val ) attrty = get_attr_fe_type ( typ ) attrval = getattr ( val , struct_attr ) return impl_ret_borrowed ( context , builder , attrty , attrval )