docs: def sizefromlen(limit, *properties):
      '''
      Factory to generate a function which get size from specified field with limits.
      Often used in nstruct "size" parameter.
      
      To retrieve size without limit, simply use lambda expression: lambda x: x.header.length
      
      :param limit: the maximum size limit, if the acquired value if larger then the limit, BadLenError is raised
              to protect against serious result like memory overflow or dead loop.
              
      :param properties: the name of the specified fields. Specify more than one string to form a property path,
              like: sizefromlen(256, 'header', 'length') -> s.header.length
              
      :returns: a function which takes a NamedStruct as parameter, and returns the length value from specified
              property path.
      '''
      def func(namedstruct):
          v = namedstruct._target
          for p in properties:
              v = getattr(v, p)
          if v > limit:
              raise BadLenError('Struct length exceeds limit ' + str(limit))
          return v
      return func