parameters: (self, cpp_name, pypath, wclass, wtype, wnamespace,
                 can_copy, can_move, can_destruct, virtual, ns=None)
docstring: Register a new class.
  
      Args:
        cpp_name: C++ FQ class name (module::ns::FooCpp)
        pypath: Python qualified name (Nested.Foo)
        wclass: wrapper class (module_wrap::pyFoo::wrapper)
        wtype: wrapper type (...+_Type)
        wnamespace: wrapper ns (module_wrap::pyFoo::)
        can_copy: True if can copy the non-abstract C++ class
        can_move: True if can move the non-abstract C++ class
        can_destruct: True if C++ class has a public dtor
        virtual: True if class has @virtual method(s) and needs a redirector
        ns: namespace where class defined
docstring_summary: Register a new class.
docstring_tokens: Register a new class .
function: def __init__(self, cpp_name, pypath, wclass, wtype, wnamespace,
                 can_copy, can_move, can_destruct, virtual, ns=None):
      """Register a new class.
  
      Args:
        cpp_name: C++ FQ class name (module::ns::FooCpp)
        pypath: Python qualified name (Nested.Foo)
        wclass: wrapper class (module_wrap::pyFoo::wrapper)
        wtype: wrapper type (...+_Type)
        wnamespace: wrapper ns (module_wrap::pyFoo::)
        can_copy: True if can copy the non-abstract C++ class
        can_move: True if can move the non-abstract C++ class
        can_destruct: True if C++ class has a public dtor
        virtual: True if class has @virtual method(s) and needs a redirector
        ns: namespace where class defined
      """
      TypeDef.__init__(self, cpp_name, pypath, ns)
      self.wrapper_obj = wclass
      self.wrapper_type = wtype
      self.wrapper_ns = wnamespace
      self.can_move = can_move
      self.virtual = virtual
      # Argument list for Clif_PyObjFrom().
      # Generate the conversion function for movable but uncopyable classes
      # in the form of:
      #   a. PyObject* Clif_PyObjFrom(UncopyableButMovableClass&& c,
      #                            py::PostConv unused);
      # Keep the conversion function for copyable classes in the form of:
      #   b. PyObject* Clif_PyObjFrom(const CopyableClass& c,
      #                             py::PostConv unused);
      #
      # 1. For movable but uncopyable C++ objects, conversion
      # function (b) is marked as delete in the generated code to avoid
      # copying an uncopyable object. C++ does not need to keep a copy of the
      # returned object. We support this condition by moving the object and
      # shifting object ownership to Python.
      #
      # 2. For copyable and movable C++ objects, we would generate both conversion
      # function (a) and (b) and let the compiler choose the rigth one to invoke.
      #
      # 3. Uncopyable and unmovable C++ objects are prohibited.
      self._from = []  # [C++ Argument, Can get NULL, Init expression]
      if not virtual:
        self._from = [
            ('%s*', True, '::clif::Instance<%s>(c, ::clif::UnOwnedResource());'),
            ('std::shared_ptr<%s>', True, '::clif::Instance<%s>(c);')]
        if can_destruct:
          self._from.append((
              'std::unique_ptr<%s>', True, '::clif::Instance<%s>(std::move(c));'))
          if can_move: self._from.append(
              ('%s&&', False, '::clif::MakeShared<%s>(std::move(c));'))
        if can_copy:
          self._from.extend([
              ('const %s&', False, '::clif::MakeShared<%s>(c);'),
              ('const %s*', True, '::clif::MakeShared<%s>(*c);')])
        else:
          # Explicitly delete signatures that do pass-by-value (set ptr to None).
          self._from.extend([
              ('const %s*', None, ''),
              ('const %s&', None, '')])
      # Argument list for Clif_PyObjAs().
      self._as = [  # [C++ Argument, ptr_deref]
          ('%s*', ''),
          ('std::shared_ptr<%s>', '',)]
      if can_destruct:
        self._as.append(('std::unique_ptr<%s>', ''))
      if can_copy and not virtual:
        self._as.append(('%s', '*'))
function_tokens: def __init__ ( self , cpp_name , pypath , wclass , wtype , wnamespace , can_copy , can_move , can_destruct , virtual , ns = None ) : TypeDef . __init__ ( self , cpp_name , pypath , ns ) self . wrapper_obj = wclass self . wrapper_type = wtype self . wrapper_ns = wnamespace self . can_move = can_move self . virtual = virtual # Argument list for Clif_PyObjFrom(). # Generate the conversion function for movable but uncopyable classes # in the form of: #   a. PyObject* Clif_PyObjFrom(UncopyableButMovableClass&& c, #                            py::PostConv unused); # Keep the conversion function for copyable classes in the form of: #   b. PyObject* Clif_PyObjFrom(const CopyableClass& c, #                             py::PostConv unused); # # 1. For movable but uncopyable C++ objects, conversion # function (b) is marked as delete in the generated code to avoid # copying an uncopyable object. C++ does not need to keep a copy of the # returned object. We support this condition by moving the object and # shifting object ownership to Python. # # 2. For copyable and movable C++ objects, we would generate both conversion # function (a) and (b) and let the compiler choose the rigth one to invoke. # # 3. Uncopyable and unmovable C++ objects are prohibited. self . _from = [ ] # [C++ Argument, Can get NULL, Init expression] if not virtual : self . _from = [ ( '%s*' , True , '::clif::Instance<%s>(c, ::clif::UnOwnedResource());' ) , ( 'std::shared_ptr<%s>' , True , '::clif::Instance<%s>(c);' ) ] if can_destruct : self . _from . append ( ( 'std::unique_ptr<%s>' , True , '::clif::Instance<%s>(std::move(c));' ) ) if can_move : self . _from . append ( ( '%s&&' , False , '::clif::MakeShared<%s>(std::move(c));' ) ) if can_copy : self . _from . extend ( [ ( 'const %s&' , False , '::clif::MakeShared<%s>(c);' ) , ( 'const %s*' , True , '::clif::MakeShared<%s>(*c);' ) ] ) else : # Explicitly delete signatures that do pass-by-value (set ptr to None). self . _from . extend ( [ ( 'const %s*' , None , '' ) , ( 'const %s&' , None , '' ) ] ) # Argument list for Clif_PyObjAs(). self . _as = [ # [C++ Argument, ptr_deref] ( '%s*' , '' ) , ( 'std::shared_ptr<%s>' , '' , ) ] if can_destruct : self . _as . append ( ( 'std::unique_ptr<%s>' , '' ) ) if can_copy and not virtual : self . _as . append ( ( '%s' , '*' ) )