diff --git a/gengo/bind/ARImpRec/ARImpRec.go b/gengo/bind/ARImpRec/ARImpRec.go index 3f92329ea..8ee92a921 100644 --- a/gengo/bind/ARImpRec/ARImpRec.go +++ b/gengo/bind/ARImpRec/ARImpRec.go @@ -9,49 +9,54 @@ const GengoLibraryName = "ARImpRec" var GengoLibrary = gengort.NewLibrary(GengoLibraryName) -type _Int128T = any -type _Uint128T = any -type __NSConstantString = any -type SizeT = uint64 -type _BuiltinMsVaList = *byte -type _BuiltinVaList = *byte -type UintptrT = uint64 -type VaList = *byte -//type SizeT = uint64 -type PtrdiffT = int64 -type IntptrT = int64 -type _VcrtBool = bool -type WcharT = uint16 -type Int8T = int8 -type Int16T = int16 -type Int32T = int32 -type Int64T = int64 -type Uint8T = uint8 -type Uint16T = uint16 -type Uint32T = uint32 -type Uint64T = uint64 -type IntLeast8T = int8 -type IntLeast16T = int16 -type IntLeast32T = int32 -type IntLeast64T = int64 -type UintLeast8T = uint8 -type UintLeast16T = uint16 -type UintLeast32T = uint32 -type UintLeast64T = uint64 -type IntFast8T = int8 -type IntFast16T = int32 -type IntFast32T = int32 -type IntFast64T = int64 -type UintFast8T = uint8 -type UintFast16T = uint32 -type UintFast32T = uint32 -type UintFast64T = uint64 -type IntmaxT = int64 -type UintmaxT = uint64 - -//var __imp___va_start gengort.PreloadProc - -// Gengo init function. +type ( + _Int128T = any + _Uint128T = any + __NSConstantString = any + SizeT = uint64 + _BuiltinMsVaList = *byte + _BuiltinVaList = *byte + UintptrT = uint64 + VaList = *byte +) + +// type SizeT = uint64 +type ( + PtrdiffT = int64 + IntptrT = int64 + _VcrtBool = bool + WcharT = uint16 + Int8T = int8 + Int16T = int16 + Int32T = int32 + Int64T = int64 + Uint8T = uint8 + Uint16T = uint16 + Uint32T = uint32 + Uint64T = uint64 + IntLeast8T = int8 + IntLeast16T = int16 + IntLeast32T = int32 + IntLeast64T = int64 + UintLeast8T = uint8 + UintLeast16T = uint16 + UintLeast32T = uint32 + UintLeast64T = uint64 + IntFast8T = int8 + IntFast16T = int32 + IntFast32T = int32 + IntFast64T = int64 + UintFast8T = uint8 + UintFast16T = uint32 + UintFast32T = uint32 + UintFast64T = uint64 + IntmaxT = int64 + UintmaxT = uint64 +) + +// var __imp___va_start gengort.PreloadProc + +// Gengo init function. func init() { __imp___va_start = GengoLibrary.ImportNow("__va_start") __imp___va_start = GengoLibrary.ImportNow("__va_start") @@ -70,12 +75,11 @@ func init() { __imp_GetProcName = GengoLibrary.ImportNow("GetProcName") __imp_GetAllVAddressesOfImports = GengoLibrary.ImportNow("GetAllVAddressesOfImports") } -func _VaStart( **byte) { gengort.CCall1(__imp___va_start.Addr(), gengort.MarshallSyscall("")) } +func _VaStart(**byte) { gengort.CCall1(__imp___va_start.Addr(), gengort.MarshallSyscall("")) } var __imp___va_start gengort.PreloadProc -//func _VaStart( *VaList) { gengort.CCall1(__imp___va_start.Addr(), gengort.MarshallSyscall()) } - +// func _VaStart( *VaList) { gengort.CCall1(__imp___va_start.Addr(), gengort.MarshallSyscall()) } var __imp___security_init_cookie gengort.PreloadProc func _SecurityInitCookie() { gengort.CCall0(__imp___security_init_cookie.Addr()) } diff --git a/gengo/bind/ARImpRec/ARImpRec_test.go b/gengo/bind/ARImpRec/ARImpRec_test.go index 181154997..58a77da57 100644 --- a/gengo/bind/ARImpRec/ARImpRec_test.go +++ b/gengo/bind/ARImpRec/ARImpRec_test.go @@ -9,7 +9,7 @@ import ( ) func TestGetProcName(t *testing.T) { - //GetProcName() + // GetProcName() } func TestARImpRec(t *testing.T) { diff --git a/gengo/bind/demo/libdemo.go b/gengo/bind/demo/libdemo.go index a35d3920c..f342f8847 100644 --- a/gengo/bind/demo/libdemo.go +++ b/gengo/bind/demo/libdemo.go @@ -3,6 +3,7 @@ package libdemo import ( "unsafe" + "github.com/can1357/gengo/gengort" ) @@ -10,15 +11,17 @@ const GengoLibraryName = "libdemo" var GengoLibrary = gengort.NewLibrary(GengoLibraryName) -type _Int128T = any -type _Uint128T = any -type __NSConstantString = any -type SizeT = uint64 -type _BuiltinMsVaList = *byte -type _BuiltinVaList = *byte +type ( + _Int128T = any + _Uint128T = any + __NSConstantString = any + SizeT = uint64 + _BuiltinMsVaList = *byte + _BuiltinVaList = *byte +) var __imp_hello gengort.PreloadProc -// Gengo init function. +// Gengo init function. func init() { __imp_hello = GengoLibrary.ImportNow("hello") } func Hello() { gengort.CCall0(__imp_hello.Addr()) } diff --git a/gengo/clang/invoke.go b/gengo/clang/invoke.go index 269296fdd..65894fa3a 100644 --- a/gengo/clang/invoke.go +++ b/gengo/clang/invoke.go @@ -37,7 +37,7 @@ func (o *Options) ClangCommand(opt ...string) ([]byte, error) { return stream.RunCommandArgs(cmd.Args...).Output.Bytes(), nil - //cmd.Args = append(cmd.Args, "2>&1") + // cmd.Args = append(cmd.Args, "2>&1") mylog.Trace("commands", strings.Join(cmd.Args, " ")) Stdout := &bytes.Buffer{} Stderr := &bytes.Buffer{} @@ -84,6 +84,6 @@ func Parse(opt *Options) (ast Node, layout *LayoutMap, err error) { return nil }) mylog.Check(errg.Wait()) - stream.RunCommand("clang -E -dM " + opt.Sources[0] + " > macros.log") //2>&1 + stream.RunCommand("clang -E -dM " + opt.Sources[0] + " > macros.log") // 2>&1 return ast, layout, nil } diff --git a/gengo/clang/layout_parse.go b/gengo/clang/layout_parse.go index 56e3bf72c..eb26dfd26 100644 --- a/gengo/clang/layout_parse.go +++ b/gengo/clang/layout_parse.go @@ -67,8 +67,8 @@ func (r *RecordLayout) UnmarshalString(data string) error { switch { case strings.Contains(data, "__NSConstantString_tag"): - //mylog.Warning("skip unmarshal RecordLayout", data) - //return nil + // mylog.Warning("skip unmarshal RecordLayout", data) + // return nil } first := true @@ -87,7 +87,7 @@ func (r *RecordLayout) UnmarshalString(data string) error { before = strings.TrimSpace(before) if before == "" { after = strings.TrimSpace(after) - //mylog.Check2(fmt.Sscanf(after, "[sizeof=%d, align=%d]", &r.Size, &r.Align)) + // mylog.Check2(fmt.Sscanf(after, "[sizeof=%d, align=%d]", &r.Size, &r.Align)) mylog.Check2(fmt.Sscanf(after, "[sizeof=%d, align=%d", &r.Size, &r.Align)) break } @@ -109,12 +109,12 @@ func (r *RecordLayout) UnmarshalString(data string) error { after = strings.TrimSpace(after) // Parse name and type - name := "" //todo test + name := "" // todo test typen := after - //save strut type todo test + // save strut type todo test if strings.HasPrefix(typen, "struct ") { - //typen = "struct " + // typen = "struct " } if lastSpace := strings.LastIndex(after, " "); lastSpace != -1 { // If the last space is followed by a closing parenthesis, then it is part of the type. @@ -128,7 +128,7 @@ func (r *RecordLayout) UnmarshalString(data string) error { } if name == "" { - //continue + // continue } // Create node @@ -147,7 +147,7 @@ func (r *RecordLayout) UnmarshalString(data string) error { }) } } - //mylog.Json("layout", r.layout.Fields) + // mylog.Json("layout", r.layout.Fields) // Group fields r.regroup() return nil diff --git a/gengo/gengo/generate.go b/gengo/gengo/generate.go index f09654ec5..33bd246e7 100644 --- a/gengo/gengo/generate.go +++ b/gengo/gengo/generate.go @@ -2,11 +2,12 @@ package gengo import ( "fmt" - "github.com/ddkwork/golibrary/mylog" "go/token" "strconv" "strings" + "github.com/ddkwork/golibrary/mylog" + "github.com/can1357/gengo/clang" "github.com/dave/dst" ) @@ -641,7 +642,7 @@ func (mod Module) EmitFrom(ast clang.Node, layouts *clang.LayoutMap) { // Define typedefs. clang.Visit(ast, func(td *clang.TypedefDecl) bool { - //mylog.Warning(td.Name, td.Type.QualType) + // mylog.Warning(td.Name, td.Type.QualType) mod.EmitTypedef(td) return true }) diff --git a/gengo/go.mod b/gengo/go.mod index 704d5b9fa..372013bf4 100644 --- a/gengo/go.mod +++ b/gengo/go.mod @@ -25,7 +25,7 @@ require ( require ( github.com/dave/dst v0.27.3 - github.com/ddkwork/golibrary v0.0.65 + github.com/ddkwork/golibrary v0.0.66 github.com/valyala/fastjson v1.6.4 golang.org/x/sync v0.7.0 ) diff --git a/gengo/go.sum b/gengo/go.sum index ec5751edb..039750d93 100644 --- a/gengo/go.sum +++ b/gengo/go.sum @@ -14,6 +14,8 @@ github.com/ddkwork/golibrary v0.0.62 h1:1FykFpwByIEtR6l7tm7sa2MmZDjuoMEcZwY3tB1J github.com/ddkwork/golibrary v0.0.62/go.mod h1:aLG0o5decT3ocB5SWY94n55ynRpVcL8OInSo2p0o5UA= github.com/ddkwork/golibrary v0.0.65 h1:/WyTQzoVywAlCbNQgVhnoPXQ91NS6KclXvUBLc1ZDlQ= github.com/ddkwork/golibrary v0.0.65/go.mod h1:/55gYXaVeq2QkSTCaBk3sL0yzbg+DDPr9u3AvyFJblU= +github.com/ddkwork/golibrary v0.0.66 h1:8tsV0lUHZ0sfoqFTl6fF43GL4Kt+ttB0vyLc7LVbrEg= +github.com/ddkwork/golibrary v0.0.66/go.mod h1:/55gYXaVeq2QkSTCaBk3sL0yzbg+DDPr9u3AvyFJblU= github.com/ebitengine/purego v0.7.1 h1:6/55d26lG3o9VCZX8lping+bZcmShseiqlh2bnUDiPA= github.com/ebitengine/purego v0.7.1/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ= github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= diff --git a/go.mod b/go.mod index 22554d4db..918acb472 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22.4 require ( github.com/ddkwork/app v0.0.0-20240618181015-bd28c7f7b739 - github.com/ddkwork/golibrary v0.0.65 + github.com/ddkwork/golibrary v0.0.66 github.com/richardwilkes/unison v0.71.0 ) diff --git a/go.sum b/go.sum index c0e8dee67..5c9a87c6c 100644 --- a/go.sum +++ b/go.sum @@ -19,6 +19,8 @@ github.com/ddkwork/app v0.0.0-20240618181015-bd28c7f7b739 h1:XyAjgR84qIQeLh7BHYN github.com/ddkwork/app v0.0.0-20240618181015-bd28c7f7b739/go.mod h1:1WX5EAXe8SfAOk6vdmxEKXv7xeIWlMMJB0/rydlFJWE= github.com/ddkwork/golibrary v0.0.65 h1:/WyTQzoVywAlCbNQgVhnoPXQ91NS6KclXvUBLc1ZDlQ= github.com/ddkwork/golibrary v0.0.65/go.mod h1:/55gYXaVeq2QkSTCaBk3sL0yzbg+DDPr9u3AvyFJblU= +github.com/ddkwork/golibrary v0.0.66 h1:8tsV0lUHZ0sfoqFTl6fF43GL4Kt+ttB0vyLc7LVbrEg= +github.com/ddkwork/golibrary v0.0.66/go.mod h1:/55gYXaVeq2QkSTCaBk3sL0yzbg+DDPr9u3AvyFJblU= github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/edsrzf/mmap-go v1.1.0 h1:6EUwBLQ/Mcr1EYLE4Tn1VdW1A4ckqCQWZBw8Hr0kjpQ=