Skip to content

c: ClosureData, GoClosure #29

Description

@xushiwei

spec:

package c

func ClosureData[ClosureT any](closure ClosureT) Pointer
func GoClosure[ClosureT any](data Pointer) (closure ClosureT)

example:

// VisitChildren visits the children of a particular cursor, invoking the given
// visitor function for each child cursor. The traversal may be recursive,
// depending on the return value of the visitor function.
func VisitChildren(root Cursor, fn func(cur, parent Cursor) ChildVisitResult) uint {
	return uint(clang.VisitChildren(
		root, func(cur, parent Cursor, param clang.ClientData) ChildVisitResult {
			return c.GoClosure[func(cur, parent Cursor) ChildVisitResult](param)(cur, parent)
		}, c.ClosureData(fn)))
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions