-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wip] gogensig #790
[wip] gogensig #790
Conversation
21667b5
to
f76bd8c
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #790 +/- ##
==========================================
+ Coverage 97.57% 97.70% +0.12%
==========================================
Files 20 31 +11
Lines 5165 6025 +860
==========================================
+ Hits 5040 5887 +847
- Misses 106 114 +8
- Partials 19 24 +5 ☔ View full report in Codecov by Sentry. |
d981005
to
6a49f48
Compare
func NewFuncDocComments(funcName string, goFuncName string) *goast.CommentGroup { | ||
txt := "\n//go:linkname " + goFuncName + " " + "C." + funcName | ||
comment := goast.Comment{Text: txt} | ||
commentGroup := goast.CommentGroup{List: []*goast.Comment{&comment}} | ||
return &commentGroup | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里直接使用llgo:link是更推荐的
func TestFunc1(t *testing.T) { | ||
bytes, err := readJSONFile("./jsons/func1.json") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
docVisitors := []visitor.DocVisitor{visitor.NewAstConvert("func1")} | ||
p := unmarshal.NewDocFileSetUnmarshaller(docVisitors) | ||
err = p.Unmarshal(bytes) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark: 将对这里处理为直接从源代码通过llcppsigfetch的 命令行进行转换,而非读取硬编码的json
goFuncName := toGoFuncName(funcDecl.Name.Name) | ||
p.p.NewFuncDecl(token.NoPos, goFuncName, sig).SetComments(p.p, NewFuncDocComments(funcDecl.Name.Name, goFuncName)) | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里Go函数的名字其实应该是接收llcppg.symb.json中的Go Name
{
"mangle": "sqlite3_backup_finish",
"c++": "sqlite3_backup_finish(sqlite3_backup *)",
"go": "backup_finish"
}
chore/llcppg/llcppg.cfg
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个测试文件需要明确标识,并且这个llcppg.cfg
和llcppg.symb.json
只应该是gogensig测试的一部分,这个文件在llcppg下并不妥
@@ -20,6 +22,15 @@ func NewAstConvert(name string) *AstConvert { | |||
return p | |||
} | |||
|
|||
func (p *AstConvert) SetupSymbleTableFile(fileName string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func (p *AstConvert) SetupSymbleTableFile(fileName string) error { | |
func (p *AstConvert) SetupSymbolTableFile(fileName string) error { |
chore/llcppg/llcppg.go
Outdated
|
||
func llcppsymg(conf []byte) error { | ||
func llcppsymg(conf []byte, out io.Writer) error { | ||
cmd := exec.Command("llcppsymg", "-") | ||
cmd.Stdin = bytes.NewReader(conf) | ||
cmd.Stdout = os.Stdout | ||
cmd.Stdout = out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对llcppg的一些修改还是另外起个Pr来做修改
3c0b88b
to
c15f178
Compare
docPath := "./_enumtest/spectrum.json" | ||
astConvert := visitor.NewAstConvert("spectrum", docPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gogensig 对于llcppsigfetch 的输出是直接通过标准输出输入流来做的,也就是说永远不存在一个llcppsigfetch 的输出的文件路径,对于这个converter来说,即使现在需要临时读取一个文件作为输入,也不应该直接将这个NewAstConvert的签名修改为接受docPath
chore/llcppg/ast/ast.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conversion 中 指明一下还依赖了这个Pr #757 中的mangledname修改吧,commit中就不用存在这个修改
chore/llcppg/llcppg.cfg
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个就不用上传了,如果是gogensig的一部分,应该在测试用例中
func TestSpectrum(t *testing.T) { | ||
docPath := "./_testinput/_enumtest/spectrum.h" | ||
astConvert := visitor.NewAstConvert("spectrum", docPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
就目前的设计来说,这里应该接受的是一个llcppg.symb.json的路径,不应该会有头文件了
"github.com/goplus/llgo/chore/gogensig/visitor/symb" | ||
) | ||
|
||
func TestLookupSymble(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func TestLookupSymble(t *testing.T) { | |
func TestLookupSymbol(t *testing.T) { |
d7cd226
to
f3a8c01
Compare
e68c6d0
to
622b4c5
Compare
} | ||
|
||
/* | ||
//TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的todo最好的姿势是类似如下 TODO(xxxx): .......
Lines 296 to 300 in 32f41a0
// TODO(xsw): support generic type | |
func trecvTypeName(t ast.Expr, indices ...ast.Expr) string { | |
_ = indices | |
return t.(*ast.Ident).Name | |
} |
func mangle name: #757