Skip to content

Commit

Permalink
Merge pull request #394 from gucio321/logger
Browse files Browse the repository at this point in the history
Logger updates
  • Loading branch information
gucio321 authored Nov 16, 2024
2 parents 36852d6 + d7773e3 commit af475a3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/codegen/gengo_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func GenerateGoFuncs(
// stop, when the function should not be generated
if !generator.shouldGenerate {
if context.flags.showNotGenerated {
glg.Failf("not generated: %s%s", f.FuncName, f.Args)
glg.Errorf("not generated: %s%s", f.FuncName, f.Args)
}
continue
} else {
Expand Down
2 changes: 1 addition & 1 deletion cmd/codegen/gengo_typedefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func GenerateTypedefs(
validTypeNames = append(validTypeNames, k)
default:
if ctx.flags.showNotGenerated {
glg.Failf("unknown situation happened for type %s; not implemented. Probably unknown Arg (err: %v), Ret (err; %v) PtrArg (err: %v) or PtrRet (err: %v) type wrappers for isPointer: %v for %s. Check out source code for more details",
glg.Errorf("unknown situation happened for type %s; not implemented. Probably unknown Arg (err: %v), Ret (err; %v) PtrArg (err: %v) or PtrRet (err: %v) type wrappers for isPointer: %v for %s. Check out source code for more details",
k, known.argTypeErr, known.returnTypeErr, known.ptrArgTypeErr, known.ptrReturnTypeErr, isPtr, typedefs.data[k])
}
}
Expand Down
15 changes: 7 additions & 8 deletions cmd/codegen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"encoding/json"
"fmt"
"log"
"os"

"github.com/kpango/glg"
Expand Down Expand Up @@ -87,7 +86,7 @@ func loadData(f *flags) (*jsonData, error) {

result.structAndEnums, err = os.ReadFile(f.enumsJsonpath)
if err != nil {
log.Panic(err)
glg.Fatalf("cannot read struct and enums json file: %v", err)
}

if len(f.refEnumsJsonPath) > 0 {
Expand All @@ -107,7 +106,7 @@ func loadData(f *flags) (*jsonData, error) {
if len(f.presetJsonPath) > 0 {
result.preset, err = os.ReadFile(f.presetJsonPath)
if err != nil {
log.Panic(err)
glg.Fatalf("cannot read preset json file: %v", err)
}
}

Expand Down Expand Up @@ -241,35 +240,35 @@ func main() {
// 1.2. Generate Go typedefs
typedefsNames, callbacksToGenerate, err := GenerateTypedefs(context.typedefs, context.structs, context)
if err != nil {
log.Panic(err)
glg.Fatalf("Cannot generate typedefs: %v", err)
}

context.typedefsNames = SliceToMap(typedefsNames)

validCallbacks, err := GenerateCallbacks(callbacksToGenerate, context)
if err != nil {
log.Panic(err)
glg.Fatalf("Cannot generate callbacks: %v", err)
}

context.typedefsNames = MergeMaps(context.typedefsNames, SliceToMap(validCallbacks))

// 1.3. Generate C wrapper
validFuncs, err := generateCppWrapper(flags.prefix, flags.include, context.funcs, context)
if err != nil {
log.Panic(err)
glg.Fatalf("Cannot generate CPP Wrapper: %v", err)
}

// 1.3.1. Generate Struct accessors in C
structAccessorFuncs, err := generateCppStructsAccessor(flags.prefix, validFuncs, context.structs, context)
if err != nil {
log.Panic(err)
glg.Fatalf("Cannot generate CPP Struct Accessors: %v", err)
}

// This variable stores funcs that needs to be written to GO now.
validFuncs = append(validFuncs, structAccessorFuncs...)

if err := GenerateGoFuncs(validFuncs, context); err != nil {
log.Panic(err)
glg.Fatalf("Cannot generate Go functions: %v", err)
}
}

Expand Down

0 comments on commit af475a3

Please sign in to comment.