In C, you can have multiple record types with the same name differentiated by their tag:

  • union RecordName { ... }
  • struct RecordName { ... }
  • enum RecordName { ... }

To access these without the tag prefix, C uses typedef:

  • typedef struct RecordName RecordName; -> allows RecordName instead of struct RecordName
  • typedef union RecordName RecordName; -> allows RecordName instead of union RecordName
  • typedef enum RecordName RecordName; -> allows RecordName instead of enum RecordName

In Mojo, this concept doesn’t exist. struct MojoType is immediately accessible as MojoType. Therefore, typedef declarations serve to create aliases that remove the C tag prefixing, making C types accessible in a Mojo-idiomatic way.

The typedef also handles function pointer typedefs and other complex type aliases.

Structs

struct TypedefDeclNode

Aliases

alias name

alias MaybeRefersAnonymous

alias __del__is_trivial

alias __moveinit__is_trivial

alias __copyinit__is_trivial

alias MaybeAnonymous

alias MaybeHasAnonymous

Fields

var level: Int

var children_: List[AstNode]

var name: String

var dtype: String

var is_function_type_def: Bool

var is_disabled: Bool

Functions

fn __init__(out self, json_object: Object, level: Int)

fn signature(self) -> String

fn get_symbol_name(self) -> String

fn set_disabled(mut self, disabled: Bool = True)

fn get_disabled(ref self) -> Bool

fn to_string(self, just_code: Bool) -> String

fn children(ref self) -> ref [self] List[AstNode]