From 9ad6077e89b755b717dc4d83206559e551a6bf75 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Thu, 14 Aug 2025 16:13:15 +0800 Subject: [PATCH 1/3] Fix punctuation spacing in Go comments --- cl/internal/convert/package.go | 18 +++++++++--------- cl/nc/ncimpl/ncimpl.go | 2 +- internal/name/name.go | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cl/internal/convert/package.go b/cl/internal/convert/package.go index 71a04612..cb5234f0 100644 --- a/cl/internal/convert/package.go +++ b/cl/internal/convert/package.go @@ -51,7 +51,7 @@ type PackageConfig struct { GenConf *gogen.Config // use to gen link command like $(pkg-config --libs xxx) - // if have this field,will generate a const named LLGoPackage,and it's not necessary + // if have this field, will generate a const named LLGoPackage, and it's not necessary LibCommand string } @@ -160,8 +160,8 @@ func (p *Package) bodyStart(decl *gogen.Func, ret ast.Expr) error { } if asStruct(retType) { - // use empty named struct type to return,without this solution,we will get a anonymous struct type - // and it will cause a compile error,like following: + // use empty named struct type to return, without this solution, we will get a anonymous struct type + // and it will cause a compile error, like following: // func (recv *Vector3) Vector3Barycenter(p Vector3, a Vector3, b Vector3, c Vector3) Vector3 { // return struct { // x c.Int @@ -169,7 +169,7 @@ func (p *Package) bodyStart(decl *gogen.Func, ret ast.Expr) error { // z c.Int // }{} // } - // this result will cause the `c` in the return type is use the `c` in the parameter,which is not have the `Int` + // this result will cause the `c` in the return type is use the `c` in the parameter, which is not have the `Int` decl.BodyStart(p.p).StructLit(retType, 0, true).Return(1).End() return nil } @@ -286,7 +286,7 @@ func (p *Package) funcIsDefined(fnSpec *GoFuncSpec, funcDecl *ast.FuncDecl) (rec name: funcDecl.Name.Name, kind: FuncDecl, } - // if already processed,return + // if already processed, return _, exist = p.symbols.Lookup(node) if exist { return nil, true, nil @@ -299,7 +299,7 @@ func (p *Package) funcIsDefined(fnSpec *GoFuncSpec, funcDecl *ast.FuncDecl) (rec var namedType = getNamedType(recv.Type()) methodName := fnSpec.FnName for i := 0; i < namedType.NumMethods(); i++ { - if namedType.Method(i).Name() == methodName { // unreachable,because if have the same method name,will return in p.symbols.Lookup(node) + if namedType.Method(i).Name() == methodName { // unreachable, because if have the same method name, will return in p.symbols.Lookup(node) return nil, true, fmt.Errorf("NewFuncDecl: %s already defined", fnSpec.GoSymbName) } } @@ -364,8 +364,8 @@ func (p *Package) NewTypeDecl(goName string, typeDecl *ast.TypeDecl, pnc nc.Node return fmt.Errorf("NewTypeDecl: %s fail: %w", typeDecl.Name.Name, err) } - // if the type is already defined,we don't need to process again - // but if the previous processed node is a forward declaration,we need to complete the type + // if the type is already defined, we don't need to process again + // but if the previous processed node is a forward declaration, we need to complete the type _, isIncom := p.incompleteTypes.Lookup(typeDecl.Name.Name) if exist && (isForward || !isIncom) { if debugLog { @@ -837,7 +837,7 @@ type Node struct { } type ProcessSymbol struct { - // not same node can have same name,so use the Node as key + // not same node can have same name, so use the Node as key info map[Node]string count map[string]int } diff --git a/cl/nc/ncimpl/ncimpl.go b/cl/nc/ncimpl/ncimpl.go index 83a2512c..16ced370 100644 --- a/cl/nc/ncimpl/ncimpl.go +++ b/cl/nc/ncimpl/ncimpl.go @@ -71,7 +71,7 @@ func (p *Converter) ConvDecl(file string, decl ast.Decl) (goName, goFile string, switch decl := decl.(type) { case *ast.FuncDecl: goName, err = p.ConvSym(obj, decl.MangledName) - // only have error when symbol not found,current keep only log this error + // only have error when symbol not found, current keep only log this error if err != nil { log.Printf("ConvDecl: %s not found in symbolmap: %s", decl.MangledName, err.Error()) err = nc.ErrSkip diff --git a/internal/name/name.go b/internal/name/name.go index 9b6a6764..15e5e27b 100644 --- a/internal/name/name.go +++ b/internal/name/name.go @@ -63,7 +63,7 @@ func ToCamelCase(s string, firstPartUpper bool) string { return strings.Join(result, "") } -// Only Make it Public,no turn to other camel method +// Only Make it Public, no turn to other camel method func ExportName(name string) string { fChar := name[0] if fChar == '_' || unicode.IsDigit(rune(fChar)) { From ce6d5e7fb6d48a165a48b278c7daea17d610844d Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Thu, 14 Aug 2025 16:16:24 +0800 Subject: [PATCH 2/3] Fix punctuation spacing in type.go and parser.go comments --- _xtool/internal/parser/parser.go | 8 ++++---- cl/internal/convert/type.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/_xtool/internal/parser/parser.go b/_xtool/internal/parser/parser.go index 9fec5be5..f7331da1 100644 --- a/_xtool/internal/parser/parser.go +++ b/_xtool/internal/parser/parser.go @@ -201,7 +201,7 @@ func (ct *Converter) ParseComment(rawComment string) *ast.CommentGroup { return commentGroup } -// visit top decls (struct,class,function,enum & macro,include) +// visit top decls (struct, class, function, enum & macro, include) func (ct *Converter) visitTop(cursor, parent clang.Cursor) clang.ChildVisitResult { ct.incIndent() defer ct.decIndent() @@ -273,7 +273,7 @@ func (ct *Converter) visitTop(cursor, parent clang.Cursor) clang.ChildVisitResul return clang.ChildVisit_Continue } -// for flatten ast,keep type order +// for flatten ast, keep type order // input is clang -E 's result func (ct *Converter) Convert() (*ast.File, error) { cursor := ct.unit.Cursor() @@ -508,7 +508,7 @@ func (ct *Converter) ProcessFuncDecl(cursor clang.Cursor) *ast.FuncDecl { ct.logln("ProcessFuncDecl: CursorName:", name, "CursorKind:", kind, "mangledName:", mangledName) // function type will only collect return type - // ProcessType can't get the field names,will collect in follows + // ProcessType can't get the field names, will collect in follows fnType := cursor.Type() typName, typKind := getTypeDesc(fnType) ct.logln("ProcessFuncDecl: TypeName:", typName, "TypeKind:", typKind) @@ -703,7 +703,7 @@ func (ct *Converter) createBaseField(cursor clang.Cursor) *ast.Field { return field } -// For Record Type(struct,union ...)'s FieldList +// For Record Type(struct, union ...)'s FieldList func (ct *Converter) ProcessFieldList(cursor clang.Cursor) *ast.FieldList { ct.incIndent() defer ct.decIndent() diff --git a/cl/internal/convert/type.go b/cl/internal/convert/type.go index b1530ff2..08e1bb2e 100644 --- a/cl/internal/convert/type.go +++ b/cl/internal/convert/type.go @@ -93,7 +93,7 @@ func (p *TypeConv) handleArrayType(t *ast.ArrayType) (types.Type, error) { return nil, fmt.Errorf("error convert elem type: %w", err) } if p.ctx == Param { - // array in the parameter,ignore the len,convert as pointer + // array in the parameter, ignore the len, convert as pointer return types.NewPointer(elemType), nil } From fc02346fb60ed634e0191621da8b5a97d7c4dc27 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Thu, 14 Aug 2025 16:18:08 +0800 Subject: [PATCH 3/3] Fix punctuation spacing in symg and header comments --- _xtool/internal/header/header.go | 2 +- _xtool/llcppsymg/internal/symg/parse.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/_xtool/internal/header/header.go b/_xtool/internal/header/header.go index fd8fcc54..a70707af 100644 --- a/_xtool/internal/header/header.go +++ b/_xtool/internal/header/header.go @@ -25,7 +25,7 @@ type Config struct { // - "zlib.h" // - "openssl/ssl.h" Includes []string - // PlatDiff specifies header file include paths that differ between platforms,these are include paths in Includes. + // PlatDiff specifies header file include paths that differ between platforms, these are include paths in Includes. PlatDiff []string Args []string Mix bool diff --git a/_xtool/llcppsymg/internal/symg/parse.go b/_xtool/llcppsymg/internal/symg/parse.go index d7866e35..78f2c883 100644 --- a/_xtool/llcppsymg/internal/symg/parse.go +++ b/_xtool/llcppsymg/internal/symg/parse.go @@ -158,7 +158,7 @@ func (p *SymbolProcessor) genGoName(cursor clang.Cursor, symbolName string) stri return customGoName } - // 1. for class method,gen method name + // 1. for class method, gen method name if parent := cursor.SemanticParent(); parent.Kind == clang.CursorClassDecl { class := name.GoName(clang.GoString(parent.String()), p.prefixes, p.inCurPkg(cursor)) // concat method name @@ -172,9 +172,9 @@ func (p *SymbolProcessor) genGoName(cursor clang.Cursor, symbolName string) stri numArgs := cursor.NumArguments() // 3. Don't attempt to convert a variadic function to a method isValist := cursor.Type().IsFunctionTypeVariadic() > 0 - // also config to gen method name,if can't gen method,use the origin function type + // also config to gen method name, if can't gen method, use the origin function type if numArgs > 0 && !isValist { - // also can gen method name,but not want to be method,output func not method + // also can gen method name, but not want to be method, output func not method if isCustom && !toMethod { return p.AddSuffix(customGoName) } @@ -281,7 +281,7 @@ func (p *SymbolProcessor) processCollect() { } // Get the underlying cursor of the cursor -// if cur is a pointer,return the underlying cursor +// if cur is a pointer, return the underlying cursor func underCursor(arg clang.Cursor) clang.Cursor { typ := arg.Type() if typ.Kind == clang.TypePointer { @@ -291,7 +291,7 @@ func underCursor(arg clang.Cursor) clang.Cursor { } // https://releases.llvm.org/19.1.0/tools/clang/docs/ReleaseNotes.html#libclang -// cursor.Location() in llvm@19 cannot get the fileinfo for a macro expansion,so we dirrect use PresumedLocation +// cursor.Location() in llvm@19 cannot get the fileinfo for a macro expansion, so we dirrect use PresumedLocation func cursorFileName(cursor clang.Cursor) string { loc := cursor.Location() filePath, _, _ := clangutils.GetPresumedLocation(loc)