github.com/gotranspile/cxgo@v0.3.8-0.20240118201721-29871598a6a2/libs/glob.go (about)

     1  package libs
     2  
     3  import (
     4  	"github.com/gotranspile/cxgo/runtime/stdio"
     5  	"github.com/gotranspile/cxgo/types"
     6  )
     7  
     8  const (
     9  	globH = "glob.h"
    10  )
    11  
    12  func init() {
    13  	RegisterLibrary(globH, func(c *Env) *Library {
    14  		gint := c.Go().Int()
    15  		intT := types.IntT(4)
    16  		sizeT := intT
    17  		strT := c.C().String()
    18  		globT := types.NamedT("stdio.Glob", types.StructT([]*types.Field{
    19  			{Name: types.NewIdentGo("gl_pathc", "Num", sizeT)},
    20  			{Name: types.NewIdentGo("gl_pathv", "Paths", c.PtrT(strT))},
    21  			{Name: types.NewIdentGo("gl_offs", "Reserve", sizeT)},
    22  			{Name: types.NewIdentGo("Glob", "Glob", c.FuncTT(intT, strT, intT, c.FuncTT(intT, strT, intT)))},
    23  			{Name: types.NewIdentGo("Free", "Free", c.FuncTT(nil))},
    24  		}))
    25  		return &Library{
    26  			Imports: map[string]string{
    27  				"libc":  RuntimeLibc,
    28  				"stdio": RuntimePrefix + "stdio",
    29  			},
    30  			Types: map[string]types.Type{
    31  				"glob_t": globT,
    32  			},
    33  			Idents: map[string]*types.Ident{
    34  				"GLOB_NOESCAPE": c.NewIdent("GLOB_NOESCAPE", "stdio.GlobNoEscape", stdio.GlobNoEscape, gint),
    35  			},
    36  		}
    37  	})
    38  }