_board_classes = {} #板子类型字典
class BoardMeta(type): #类BoardMeta,类的模板,所以必须从type
类型派生
def init(cls, name, bases, dct): #类似构造函数,self类似this指针,其他是强制传入的参数
super(BoardMeta, cls).init(name, bases, dct) #super() 函数是用于调用父类(超类)的一个方法。
if 'abstract' not in cls.__dict__:
cls.abstract = False
if cls.abstract:
return
if not hasattr(cls, 'toolchain'):
cls.toolchain = 'native'
board_name = getattr(cls, 'name', name)
if board_name in _board_classes:
raise Exception('board named %s already exists' % board_name)
_board_classes[board_name] = cls
class Board:
abstract = True #变量abstract
def __init__(self): #初始化实例,self表示创建的实例本身
self.with_uavcan = False #
......省略了其他代码
下面一句怎么理解呢?
Board = BoardMeta('Board', Board.bases, dict(Board.dict))
请问Board = BoardMeta('Board', Board.bases, dict(Board.dict))该怎么理解?