def type_node_to_type(node): children = node.GetChildren() if len(children) < 1 or len(children) > 2: raise ValueError( 'Type node expects 1 or 2 children (type + optional array []), got %s (multi-dimensional arrays are not supported).' % len(children)) base_type = type_node_inner_to_type(children[0]) if node.GetProperty('NULLABLE'): base_type = IdlNullableType(base_type) if len(children) == 2: array_node = children[1] array_node_class = array_node.GetClass() if array_node_class != 'Array': raise ValueError( 'Expected Array node as TypeSuffix, got %s node.' % array_node_class) array_type = IdlArrayType(base_type) if array_node.GetProperty('NULLABLE'): return IdlNullableType(array_type) return array_type return base_type
def type_node_to_type(node): children = node.GetChildren() if len(children) < 1 or len(children) > 2: raise ValueError('Type node expects 1 or 2 children (type + optional array []), got %s (multi-dimensional arrays are not supported).' % len(children)) is_nullable = node.GetProperty('NULLABLE') or False # syntax: T? type_node_child = children[0] base_type = type_node_inner_to_type(type_node_child, is_nullable=is_nullable) if len(children) == 2: array_node = children[1] array_node_class = array_node.GetClass() if array_node_class != 'Array': raise ValueError('Expected Array node as TypeSuffix, got %s node.' % array_node_class) array_is_nullable = array_node.GetProperty('NULLABLE') or False return IdlArrayType(base_type, is_nullable=array_is_nullable) return base_type