specgen

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package specgen extracts structured API specs from Go source files produced by c-for-go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractIncludeDirsFromGoFiles

func ExtractIncludeDirsFromGoFiles(
	goFiles []string,
	sysrootInclude string,
) ([]string, error)

ExtractIncludeDirsFromGoFiles scans Go source files for CGo preamble #include <path> directives and returns the unique set of parent directories resolved under the given sysroot include path.

func MergeFunctions

func MergeFunctions(
	spec *specmodel.Spec,
	funcs map[string]specmodel.FuncDef,
)

MergeFunctions adds function definitions from parsed C headers into the spec. Only adds functions that are not already present (Go AST extraction takes priority).

func MergeStructs

func MergeStructs(
	spec *specmodel.Spec,
	structs map[string]specmodel.StructDef,
)

MergeStructs adds struct definitions from parsed C headers into the spec. Only includes structs whose type name exists in spec.Types.

func ParseFunctionsFromDir

func ParseFunctionsFromDir(dir string) (map[string]specmodel.FuncDef, error)

ParseFunctionsFromDir reads all .h files in dir and extracts function declarations.

func ParseSources

func ParseSources(module, sourcePkg string, filePaths []string) (specmodel.Spec, error)

ParseSources parses Go source files and extracts types, enums, functions, and callbacks into a Spec. The files are expected to be c-for-go output (pure Go with C.* selector expressions for opaque handle types).

func ParseStructsFromDir

func ParseStructsFromDir(dir string) (map[string]specmodel.StructDef, error)

ParseStructsFromDir reads all .h files in dir and extracts struct definitions.

func WriteSpec

func WriteSpec(spec specmodel.Spec, path string) error

WriteSpec marshals spec to YAML and writes it to path, creating parent directories as needed. The file is prefixed with a generated-code header.

Types

This section is empty.

Jump to

Keyboard shortcuts

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