def _create_type(self, env, item):
if item.name in env:<EOL><INDENT>existing_dt = env[item.name]<EOL>raise InvalidSpec(<EOL>'<STR_LIT>' %<EOL>(quote(item.name), existing_dt._ast_node.path,<EOL>existing_dt._ast_node.lineno), item.lineno, item.path)<EOL><DEDENT>namespace = self.api.ensure_namespace(env.namespace_name)<EOL>if isinstance(item, AstStructDef):<EOL><INDENT>try:<EOL><INDENT>api_type = Struct(name=item.name, namespace=namespace,<EOL>ast_node=item)<EOL><DEDENT>except ParameterError as e:<EOL><INDENT>raise InvalidSpec(<EOL>'<STR_LIT>' % (quote(item.name), e.args[<NUM_LIT:0>]),<EOL>item.lineno, item.path)<EOL><DEDENT><DEDENT>elif isinstance(item, AstUnionDef):<EOL><INDENT>api_type = Union(<EOL>name=item.name, namespace=namespace, ast_node=item,<EOL>closed=item.closed)<EOL><DEDENT>else:<EOL><INDENT>raise AssertionError('<STR_LIT>' % type(item))<EOL><DEDENT>env[item.name] = api_type<EOL>return api_type<EOL>
Create a forward reference for a union or struct.