-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathconvert.go
More file actions
80 lines (64 loc) · 1.83 KB
/
convert.go
File metadata and controls
80 lines (64 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package cl
import (
"github.com/goplus/llcppg/ast"
"github.com/goplus/llcppg/cl/internal/convert"
llconfig "github.com/goplus/llcppg/config"
)
var ErrSkip = convert.ErrSkip
const DbgFlagAll = convert.DbgFlagAll
func SetDebug(flag int) {
convert.SetDebug(flag)
}
func ModInit(deps []string, outputDir string, modulePath string) error {
return convert.ModInit(deps, outputDir, modulePath)
}
type NodeConverter = convert.NodeConverter
type ProcessSymbol = convert.ProcessSymbol
func NewProcessSymbol() *ProcessSymbol {
return convert.NewProcessSymbol()
}
type NameMethod = convert.NameMethod
type Node = convert.Node
func NewNode(name string, kind NodeKind) Node {
return convert.NewNode(name, kind)
}
type NodeKind = convert.NodeKind
type ConvConfig struct {
OutputDir string
PkgPath string
PkgName string
Pkg *ast.File
FileMap map[string]*llconfig.FileInfo
ConvSym func(name *ast.Object, mangleName string) (goName string, err error)
NodeConv NodeConverter
Symbols *convert.ProcessSymbol
// CfgFile string // llcppg.cfg
TypeMap map[string]string // llcppg.pub
Deps []string // dependent packages
TrimPrefixes []string
Libs string
KeepUnderScore bool
}
func Convert(config *ConvConfig) (pkg Package, err error) {
cvt, err := convert.NewConverter(&convert.Config{
OutputDir: config.OutputDir,
PkgPath: config.PkgPath,
PkgName: config.PkgName,
Pkg: config.Pkg,
FileMap: config.FileMap,
ConvSym: config.ConvSym,
NodeConv: config.NodeConv,
Symbols: config.Symbols,
TypeMap: config.TypeMap,
Deps: config.Deps,
TrimPrefixes: config.TrimPrefixes,
Libs: config.Libs,
KeepUnderScore: config.KeepUnderScore,
})
if err != nil {
return
}
cvt.Convert()
gp := cvt.GenPkg
return Package{gp.Pkg(), gp.PkgInfo}, nil
}