clang

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NodeKinds = map[string]func(rt *refTracker, val *fastjson.Value) (Node, error){}

Functions

func All

func All[T Node](n Node) (res []T)

func CreateAST

func CreateAST(opt *Options) ([]byte, error)

func CreateLayoutMap

func CreateLayoutMap(opt *Options) ([]byte, error)

func First

func First[T Node](n Node) (res T)

func Fprint

func Fprint(w io.Writer, n Node) error

Printers

func Parse

func Parse(opt *Options) (ast Node, layout *LayoutMap, err error)

func Print

func Print(n Node) error

func RegisterNode

func RegisterNode[T Node]()

func Visit

func Visit[T Node](n Node, f func(T) bool)

Types

type BinaryOperator

type BinaryOperator struct {
	Opcode string `json:"opcode"`
	// contains filtered or unexported fields
}

func (*BinaryOperator) Category

func (n *BinaryOperator) Category() string

func (*BinaryOperator) Type

func (n *BinaryOperator) Type() Type

type BlockCommandComment

type BlockCommandComment struct {
	Name string `json:"name"`
	// contains filtered or unexported fields
}

func (*BlockCommandComment) AppendTo

func (n *BlockCommandComment) AppendTo(wr *strings.Builder)

type BuiltinType

type BuiltinType struct {
	// contains filtered or unexported fields
}

func (*BuiltinType) DesugaredQualifiedType

func (n *BuiltinType) DesugaredQualifiedType() string

func (*BuiltinType) QualifiedType

func (n *BuiltinType) QualifiedType() string

func (*BuiltinType) TypeAliasDeclID

func (n *BuiltinType) TypeAliasDeclID() string

type CStyleCastExpr

type CStyleCastExpr struct {
	CastKind string `json:"castKind"`
	// contains filtered or unexported fields
}

func (*CStyleCastExpr) Category

func (n *CStyleCastExpr) Category() string

func (*CStyleCastExpr) Type

func (n *CStyleCastExpr) Type() Type

type CommentNode

type CommentNode interface {
	Node
	AppendTo(wr *strings.Builder)
}

type CompoundStmt

type CompoundStmt struct {
	// contains filtered or unexported fields
}

func (*CompoundStmt) At

func (n *CompoundStmt) At(i int) Node

func (*CompoundStmt) Base

func (n *CompoundStmt) Base() *baseNode

func (*CompoundStmt) Children

func (n *CompoundStmt) Children() []Node

func (*CompoundStmt) Comment

func (n *CompoundStmt) Comment() string

func (*CompoundStmt) ID

func (n *CompoundStmt) ID() string

func (*CompoundStmt) Kind

func (n *CompoundStmt) Kind() string

func (*CompoundStmt) Location

func (n *CompoundStmt) Location() *Location

func (*CompoundStmt) SrcRange

func (n *CompoundStmt) SrcRange() *SourceRange

type ConditionalOperator

type ConditionalOperator struct {
	// contains filtered or unexported fields
}

func (*ConditionalOperator) Category

func (n *ConditionalOperator) Category() string

func (*ConditionalOperator) Type

func (n *ConditionalOperator) Type() Type

type ConstValueNode

type ConstValueNode interface {
	ValueNode
	Value() string
}

type ConstantExpr

type ConstantExpr struct {
	ExpressionValue string `json:"value"`
	// contains filtered or unexported fields
}

func (*ConstantExpr) Category

func (n *ConstantExpr) Category() string

func (*ConstantExpr) Type

func (n *ConstantExpr) Type() Type

func (*ConstantExpr) Value

func (l *ConstantExpr) Value() string

type DeclNode

type DeclNode interface {
	Node
	DeclName() string
}

type DeclRefExpr

type DeclRefExpr struct {
	ReferencedDecl NodeDecl `json:"referencedDecl"`
	// contains filtered or unexported fields
}

func (*DeclRefExpr) Category

func (n *DeclRefExpr) Category() string

func (*DeclRefExpr) Type

func (n *DeclRefExpr) Type() Type

type ElaboratedType

type ElaboratedType struct {
	OwnedTagDecl NodeDecl `json:"ownedTagDecl"`
	// contains filtered or unexported fields
}

func (*ElaboratedType) DesugaredQualifiedType

func (n *ElaboratedType) DesugaredQualifiedType() string

func (*ElaboratedType) QualifiedType

func (n *ElaboratedType) QualifiedType() string

func (*ElaboratedType) TypeAliasDeclID

func (n *ElaboratedType) TypeAliasDeclID() string

type EnumConstantDecl

type EnumConstantDecl struct {
	Type         Type `json:"type"`
	IsReferenced bool `json:"isReferenced"`
	// contains filtered or unexported fields
}

func (*EnumConstantDecl) DeclName

func (n *EnumConstantDecl) DeclName() string

type EnumDecl

type EnumDecl struct {
	// contains filtered or unexported fields
}

func (*EnumDecl) DeclName

func (n *EnumDecl) DeclName() string

type EnumType

type EnumType struct {
	Decl NodeDecl `json:"decl"`
	// contains filtered or unexported fields
}

func (*EnumType) DesugaredQualifiedType

func (n *EnumType) DesugaredQualifiedType() string

func (*EnumType) QualifiedType

func (n *EnumType) QualifiedType() string

func (*EnumType) TypeAliasDeclID

func (n *EnumType) TypeAliasDeclID() string

type FieldDecl

type FieldDecl struct {
	Type       Type `json:"type"`
	IsImplicit bool `json:"isImplicit"`
	// contains filtered or unexported fields
}

func (*FieldDecl) DeclName

func (n *FieldDecl) DeclName() string

type FullComment

type FullComment struct {
	// contains filtered or unexported fields
}

func (*FullComment) AppendTo

func (n *FullComment) AppendTo(wr *strings.Builder)

type FunctionDecl

type FunctionDecl struct {
	MangledName  string `json:"mangledName"`
	Type         Type   `json:"type"`
	StorageClass string `json:"storageClass"`
	Inline       bool   `json:"inline"`
	// contains filtered or unexported fields
}

func (*FunctionDecl) DeclName

func (n *FunctionDecl) DeclName() string

type FunctionProtoType

type FunctionProtoType struct {
	Cc string `json:"cc"`
	// contains filtered or unexported fields
}

func (*FunctionProtoType) DesugaredQualifiedType

func (n *FunctionProtoType) DesugaredQualifiedType() string

func (*FunctionProtoType) QualifiedType

func (n *FunctionProtoType) QualifiedType() string

func (*FunctionProtoType) TypeAliasDeclID

func (n *FunctionProtoType) TypeAliasDeclID() string

type IfStmt

type IfStmt struct {
	// contains filtered or unexported fields
}

func (*IfStmt) At

func (n *IfStmt) At(i int) Node

func (*IfStmt) Base

func (n *IfStmt) Base() *baseNode

func (*IfStmt) Children

func (n *IfStmt) Children() []Node

func (*IfStmt) Comment

func (n *IfStmt) Comment() string

func (*IfStmt) ID

func (n *IfStmt) ID() string

func (*IfStmt) Kind

func (n *IfStmt) Kind() string

func (*IfStmt) Location

func (n *IfStmt) Location() *Location

func (*IfStmt) SrcRange

func (n *IfStmt) SrcRange() *SourceRange

type ImplicitCastExpr

type ImplicitCastExpr struct {
	CastKind             string `json:"castKind"`
	IsPartOfExplicitCast bool   `json:"isPartOfExplicitCast"`
	// contains filtered or unexported fields
}

func (*ImplicitCastExpr) Category

func (n *ImplicitCastExpr) Category() string

func (*ImplicitCastExpr) Type

func (n *ImplicitCastExpr) Type() Type

type IndirectFieldDecl

type IndirectFieldDecl struct {
	IsImplicit bool `json:"isImplicit"`
	// contains filtered or unexported fields
}

func (*IndirectFieldDecl) DeclName

func (n *IndirectFieldDecl) DeclName() string

type InlineCommandComment

type InlineCommandComment struct {
	Name       string   `json:"name"`
	RenderKind string   `json:"renderKind"`
	Args       []string `json:"args"`
	// contains filtered or unexported fields
}

func (*InlineCommandComment) AppendTo

func (n *InlineCommandComment) AppendTo(wr *strings.Builder)

type IntegerLiteral

type IntegerLiteral struct {
	ConstantExpr
}

func (*IntegerLiteral) Category

func (n *IntegerLiteral) Category() string

func (*IntegerLiteral) Type

func (n *IntegerLiteral) Type() Type

type LayoutMap

type LayoutMap struct {
	Records []*RecordLayout
	Map     map[string]*RecordLayout
}

func ParseLayoutMap

func ParseLayoutMap(data []byte) (*LayoutMap, error)

func (*LayoutMap) UnmarshalString

func (l *LayoutMap) UnmarshalString(data string) error

type Location

type Location struct {
	Offset   int    `json:"offset,omitempty"`
	Line     int    `json:"line,omitempty"`
	Col      int    `json:"col,omitempty"`
	TokenLen int    `json:"tokLen,omitempty"`
	File     string `json:"file,omitempty"`
}

type MaxFieldAlignmentAttr

type MaxFieldAlignmentAttr struct {
	Implicit bool `json:"implicit"`
	// contains filtered or unexported fields
}

func (*MaxFieldAlignmentAttr) At

func (n *MaxFieldAlignmentAttr) At(i int) Node

func (*MaxFieldAlignmentAttr) Base

func (n *MaxFieldAlignmentAttr) Base() *baseNode

func (*MaxFieldAlignmentAttr) Children

func (n *MaxFieldAlignmentAttr) Children() []Node

func (*MaxFieldAlignmentAttr) Comment

func (n *MaxFieldAlignmentAttr) Comment() string

func (*MaxFieldAlignmentAttr) ID

func (n *MaxFieldAlignmentAttr) ID() string

func (*MaxFieldAlignmentAttr) Kind

func (n *MaxFieldAlignmentAttr) Kind() string

func (*MaxFieldAlignmentAttr) Location

func (n *MaxFieldAlignmentAttr) Location() *Location

func (*MaxFieldAlignmentAttr) SrcRange

func (n *MaxFieldAlignmentAttr) SrcRange() *SourceRange

type Node

type Node interface {
	Base() *baseNode
	ID() string
	Kind() string
	Location() *Location
	SrcRange() *SourceRange
	Children() []Node
	At(i int) Node
	Comment() string
}

func ParseAST

func ParseAST(data []byte) (node Node, err error)

type NodeDecl

type NodeDecl struct {
	ID   string `json:"id,omitempty"`
	Kind string `json:"kind,omitempty"`
	Name string `json:"name,omitempty"`
	Type *Type  `json:"type,omitempty"`
	Ref  Node   `json:"-"`
}

func (*NodeDecl) UnmarshalValue

func (n *NodeDecl) UnmarshalValue(rt *refTracker, data *fastjson.Value) (err error)

type Options

type Options struct {
	ToolkitPath      string
	AdditionalParams []string
	Sources          []string
}

func (*Options) ClangCommand

func (o *Options) ClangCommand(opt ...string) ([]byte, error)

func (*Options) ClangPath

func (o *Options) ClangPath() string

type ParagraphComment

type ParagraphComment struct {
	// contains filtered or unexported fields
}

func (*ParagraphComment) AppendTo

func (n *ParagraphComment) AppendTo(wr *strings.Builder)

type ParamCommandComment

type ParamCommandComment struct {
	Direction string `json:"direction"`
	Param     string `json:"param"`
	ParamIdx  int    `json:"paramIdx"`
	// contains filtered or unexported fields
}

func (*ParamCommandComment) AppendTo

func (n *ParamCommandComment) AppendTo(wr *strings.Builder)

type ParenExpr

type ParenExpr struct {
	// contains filtered or unexported fields
}

func (*ParenExpr) Category

func (n *ParenExpr) Category() string

func (*ParenExpr) Type

func (n *ParenExpr) Type() Type

type ParenType

type ParenType struct {
	// contains filtered or unexported fields
}

func (*ParenType) DesugaredQualifiedType

func (n *ParenType) DesugaredQualifiedType() string

func (*ParenType) QualifiedType

func (n *ParenType) QualifiedType() string

func (*ParenType) TypeAliasDeclID

func (n *ParenType) TypeAliasDeclID() string

type ParmVarDecl

type ParmVarDecl struct {
	Type   Type `json:"type"`
	IsUsed bool `json:"isUsed"`
	// contains filtered or unexported fields
}

func (*ParmVarDecl) DeclName

func (n *ParmVarDecl) DeclName() string

type PointerType

type PointerType struct {
	// contains filtered or unexported fields
}

func (*PointerType) DesugaredQualifiedType

func (n *PointerType) DesugaredQualifiedType() string

func (*PointerType) QualifiedType

func (n *PointerType) QualifiedType() string

func (*PointerType) TypeAliasDeclID

func (n *PointerType) TypeAliasDeclID() string

type QualType

type QualType struct {
	Qualifiers string `json:"qualifiers"`
	// contains filtered or unexported fields
}

func (*QualType) DesugaredQualifiedType

func (n *QualType) DesugaredQualifiedType() string

func (*QualType) QualifiedType

func (n *QualType) QualifiedType() string

func (*QualType) TypeAliasDeclID

func (n *QualType) TypeAliasDeclID() string

type RecordDecl

type RecordDecl struct {
	IsImplicit         bool   `json:"isImplicit"`
	TagUsed            string `json:"tagUsed"`
	CompleteDefinition bool   `json:"completeDefinition"`
	ParentDeclContext  string `json:"parentDeclContext"`
	PreviousDecl       string `json:"previousDecl"`
	// contains filtered or unexported fields
}

func (*RecordDecl) DeclName

func (n *RecordDecl) DeclName() string

type RecordLayout

type RecordLayout struct {
	Size, Align int
	// contains filtered or unexported fields
}

func (*RecordLayout) String

func (n *RecordLayout) String() string

func (*RecordLayout) UnmarshalString

func (r *RecordLayout) UnmarshalString(data string) error

type RecordType

type RecordType struct {
	Decl NodeDecl `json:"decl"`
	// contains filtered or unexported fields
}

func (*RecordType) DesugaredQualifiedType

func (n *RecordType) DesugaredQualifiedType() string

func (*RecordType) QualifiedType

func (n *RecordType) QualifiedType() string

func (*RecordType) TypeAliasDeclID

func (n *RecordType) TypeAliasDeclID() string

type ReturnStmt

type ReturnStmt struct {
	// contains filtered or unexported fields
}

func (*ReturnStmt) At

func (n *ReturnStmt) At(i int) Node

func (*ReturnStmt) Base

func (n *ReturnStmt) Base() *baseNode

func (*ReturnStmt) Children

func (n *ReturnStmt) Children() []Node

func (*ReturnStmt) Comment

func (n *ReturnStmt) Comment() string

func (*ReturnStmt) ID

func (n *ReturnStmt) ID() string

func (*ReturnStmt) Kind

func (n *ReturnStmt) Kind() string

func (*ReturnStmt) Location

func (n *ReturnStmt) Location() *Location

func (*ReturnStmt) SrcRange

func (n *ReturnStmt) SrcRange() *SourceRange

type SourceRange

type SourceRange struct {
	Begin        *Location `json:"begin,omitempty"`
	End          *Location `json:"end,omitempty"`
	SpellingLoc  *Location `json:"spellingLoc,omitempty"`
	ExpansionLoc *Location `json:"expansionLoc,omitempty"`
}

type StaticAssertDecl

type StaticAssertDecl struct {
	// contains filtered or unexported fields
}

func (*StaticAssertDecl) At

func (n *StaticAssertDecl) At(i int) Node

func (*StaticAssertDecl) Base

func (n *StaticAssertDecl) Base() *baseNode

func (*StaticAssertDecl) Children

func (n *StaticAssertDecl) Children() []Node

func (*StaticAssertDecl) Comment

func (n *StaticAssertDecl) Comment() string

func (*StaticAssertDecl) ID

func (n *StaticAssertDecl) ID() string

func (*StaticAssertDecl) Kind

func (n *StaticAssertDecl) Kind() string

func (*StaticAssertDecl) Location

func (n *StaticAssertDecl) Location() *Location

func (*StaticAssertDecl) SrcRange

func (n *StaticAssertDecl) SrcRange() *SourceRange

type StringLiteral

type StringLiteral struct {
	ConstantExpr
}

func (*StringLiteral) Category

func (n *StringLiteral) Category() string

func (*StringLiteral) Type

func (n *StringLiteral) Type() Type

type TextComment

type TextComment struct {
	Text string `json:"text"`
	// contains filtered or unexported fields
}

func (*TextComment) AppendTo

func (n *TextComment) AppendTo(wr *strings.Builder)

type TranslationUnitDecl

type TranslationUnitDecl struct {
	// contains filtered or unexported fields
}

func (*TranslationUnitDecl) At

func (n *TranslationUnitDecl) At(i int) Node

func (*TranslationUnitDecl) Base

func (n *TranslationUnitDecl) Base() *baseNode

func (*TranslationUnitDecl) Children

func (n *TranslationUnitDecl) Children() []Node

func (*TranslationUnitDecl) Comment

func (n *TranslationUnitDecl) Comment() string

func (*TranslationUnitDecl) ID

func (n *TranslationUnitDecl) ID() string

func (*TranslationUnitDecl) Kind

func (n *TranslationUnitDecl) Kind() string

func (*TranslationUnitDecl) Location

func (n *TranslationUnitDecl) Location() *Location

func (*TranslationUnitDecl) SrcRange

func (n *TranslationUnitDecl) SrcRange() *SourceRange

type Type

type Type struct {
	QualType          string  `json:"qualType"`
	TypeAliasDeclId   string  `json:"typeAliasDeclId,omitempty"`
	DesugaredQualType *string `json:"desugaredQualType,omitempty"`
}

func (*Type) UnmarshalValue

func (n *Type) UnmarshalValue(data *fastjson.Value) (err error)

type TypeNode

type TypeNode interface {
	Node
	QualifiedType() string
	TypeAliasDeclID() string
	DesugaredQualifiedType() string
}

type TypeVisibilityAttr

type TypeVisibilityAttr struct {
	Implicit bool `json:"implicit"`
	// contains filtered or unexported fields
}

func (*TypeVisibilityAttr) At

func (n *TypeVisibilityAttr) At(i int) Node

func (*TypeVisibilityAttr) Base

func (n *TypeVisibilityAttr) Base() *baseNode

func (*TypeVisibilityAttr) Children

func (n *TypeVisibilityAttr) Children() []Node

func (*TypeVisibilityAttr) Comment

func (n *TypeVisibilityAttr) Comment() string

func (*TypeVisibilityAttr) ID

func (n *TypeVisibilityAttr) ID() string

func (*TypeVisibilityAttr) Kind

func (n *TypeVisibilityAttr) Kind() string

func (*TypeVisibilityAttr) Location

func (n *TypeVisibilityAttr) Location() *Location

func (*TypeVisibilityAttr) SrcRange

func (n *TypeVisibilityAttr) SrcRange() *SourceRange

type TypedefDecl

type TypedefDecl struct {
	IsImplicit   bool `json:"isImplicit"`
	Type         Type `json:"type"`
	IsReferenced bool `json:"isReferenced"`
	// contains filtered or unexported fields
}

func (*TypedefDecl) DeclName

func (n *TypedefDecl) DeclName() string

type TypedefType

type TypedefType struct {
	Decl NodeDecl `json:"decl"`
	// contains filtered or unexported fields
}

func (*TypedefType) DesugaredQualifiedType

func (n *TypedefType) DesugaredQualifiedType() string

func (*TypedefType) QualifiedType

func (n *TypedefType) QualifiedType() string

func (*TypedefType) TypeAliasDeclID

func (n *TypedefType) TypeAliasDeclID() string

type UnaryExprOrTypeTraitExpr

type UnaryExprOrTypeTraitExpr struct {
	Name    string `json:"name"`
	ArgType Type   `json:"argType"`
	// contains filtered or unexported fields
}

func (*UnaryExprOrTypeTraitExpr) Category

func (n *UnaryExprOrTypeTraitExpr) Category() string

func (*UnaryExprOrTypeTraitExpr) Type

func (n *UnaryExprOrTypeTraitExpr) Type() Type

type UnaryOperator

type UnaryOperator struct {
	CanOverflow bool   `json:"canOverflow"`
	IsPostfix   bool   `json:"isPostfix"`
	Opcode      string `json:"opcode"`
	// contains filtered or unexported fields
}

func (*UnaryOperator) Category

func (n *UnaryOperator) Category() string

func (*UnaryOperator) Type

func (n *UnaryOperator) Type() Type

type UnknownNode

type UnknownNode struct {
	Raw json.RawMessage
	// contains filtered or unexported fields
}

func (*UnknownNode) At

func (n *UnknownNode) At(i int) Node

func (*UnknownNode) Base

func (n *UnknownNode) Base() *baseNode

func (*UnknownNode) Children

func (n *UnknownNode) Children() []Node

func (*UnknownNode) Comment

func (n *UnknownNode) Comment() string

func (*UnknownNode) ID

func (n *UnknownNode) ID() string

func (*UnknownNode) Kind

func (n *UnknownNode) Kind() string

func (*UnknownNode) Location

func (n *UnknownNode) Location() *Location

func (*UnknownNode) SrcRange

func (n *UnknownNode) SrcRange() *SourceRange

func (*UnknownNode) UnmarshalValue

func (n *UnknownNode) UnmarshalValue(rt *refTracker, data *fastjson.Value) error

type ValueNode

type ValueNode interface {
	Node
	Category() string
	Type() Type
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL