parameters: (self, p)
docstring: MegDNN param structures are not packed and we need to initialize the structure
          paddings to zero or it would break MegBrain hash system. We do memset(0) in default
          ctor and use a trick, wrapping non-static members in a anonymous union which would
          copy the object representation in its default copy/move ctor, for copy/move ctor.
          > The implicitly-defined copy/move constructor for a non-union class X performs
          > a memberwise copy/move of its bases and members. [class.copy.ctor 14]
          > The implicitly-defined copy/move constructor for a union X copies the object
          > representation (6.9) of X. [class.copy.ctor 15]
docstring_summary: MegDNN param structures are not packed and we need to initialize the structure
          paddings to zero or it would break MegBrain hash system. We do memset(0) in default
          ctor and use a trick, wrapping non-static members in a anonymous union which would
          copy the object representation in its default copy/move ctor, for copy/move ctor.
          > The implicitly-defined copy/move constructor for a non-union class X performs
          > a memberwise copy/move of its bases and members. [class.copy.ctor 14]
          > The implicitly-defined copy/move constructor for a union X copies the object
          > representation (6.9) of X. [class.copy.ctor 15]
docstring_tokens: MegDNN param structures are not packed and we need to initialize the structure paddings to zero or it would break MegBrain hash system . We do memset ( 0 ) in default ctor and use a trick wrapping non - static members in a anonymous union which would copy the object representation in its default copy / move ctor for copy / move ctor . > The implicitly - defined copy / move constructor for a non - union class X performs > a memberwise copy / move of its bases and members . [ class . copy . ctor 14 ] > The implicitly - defined copy / move constructor for a union X copies the object > representation ( 6 . 9 ) of X . [ class . copy . ctor 15 ]
function: def _on_param_end(self, p):
          '''
          MegDNN param structures are not packed and we need to initialize the structure
          paddings to zero or it would break MegBrain hash system. We do memset(0) in default
          ctor and use a trick, wrapping non-static members in a anonymous union which would
          copy the object representation in its default copy/move ctor, for copy/move ctor.
          > The implicitly-defined copy/move constructor for a non-union class X performs
          > a memberwise copy/move of its bases and members. [class.copy.ctor 14]
          > The implicitly-defined copy/move constructor for a union X copies the object
          > representation (6.9) of X. [class.copy.ctor 15]
          '''
          if self._non_static_members:
              self._write('union { struct {')
              for i in self._non_static_members:
                  if isinstance(i, member_defs.Field):
                      self._write_doc(i.name)
                      self._write('%s%s %s;', i.dtype.cname_attr, i.dtype.cname, i.name)
                  else:
                      assert isinstance(i, (member_defs.Enum, member_defs.EnumAlias))
                      self._write('%s %s;', i.name, i.name_field)
              self._write('}; };')
          if self._ctor_args:
              pdefs, varnames = zip(*self._ctor_args)
              self._write('%s(%s) {', p.name, ', '.join(pdefs), indent=1)
              self._write('memset(this, 0, sizeof(*this));')
              for var in varnames:
                  self._write('this->%s = %s_;', var, var)
              self._write('}', indent=-1)
          self._write('};\n', indent=-1)
function_tokens: def _on_param_end ( self , p ) : if self . _non_static_members : self . _write ( 'union { struct {' ) for i in self . _non_static_members : if isinstance ( i , member_defs . Field ) : self . _write_doc ( i . name ) self . _write ( '%s%s %s;' , i . dtype . cname_attr , i . dtype . cname , i . name ) else : assert isinstance ( i , ( member_defs . Enum , member_defs . EnumAlias ) ) self . _write ( '%s %s;' , i . name , i . name_field ) self . _write ( '}; };' ) if self . _ctor_args : pdefs , varnames = zip ( * self . _ctor_args ) self . _write ( '%s(%s) {' , p . name , ', ' . join ( pdefs ) , indent = 1 ) self . _write ( 'memset(this, 0, sizeof(*this));' ) for var in varnames : self . _write ( 'this->%s = %s_;' , var , var ) self . _write ( '}' , indent = - 1 ) self . _write ( '};\n' , indent = - 1 )