Skip to content

Commit

Permalink
typedefs: small cleanup:
Browse files Browse the repository at this point in the history
- remove commented-out debug stmt
- reorder case conditions so that the most important check were on top (readability, performance)
  • Loading branch information
gucio321 committed Nov 5, 2024
1 parent b36b761 commit 178f49f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cmd/codegen/gengo_typedefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ typedefsGeneration:

generatedTypedefs++
validTypeNames = append(validTypeNames, k)
case known.ptrReturnTypeErr == nil && known.argTypeErr == nil && known.ptrArgTypeErr == nil && !isPtr:
case !isPtr &&
known.ptrReturnTypeErr == nil &&
known.argTypeErr == nil &&
known.ptrArgTypeErr == nil:
if ctx.flags.showGenerated {
glg.Successf("typedef %s is an alias typedef.", k)
}
Expand Down Expand Up @@ -156,7 +159,9 @@ func New%[1]sFromC[SRC any](cvalue SRC) *%[1]s {

generatedTypedefs++
validTypeNames = append(validTypeNames, k)
case known.returnTypeErr == nil && known.argTypeErr == nil && isPtr:
case isPtr &&
known.returnTypeErr == nil &&
known.argTypeErr == nil:
// if it's a pointer type, I think we can proceed as above, but without Handle() method...
// (handle proceeds pointer values and we don't want double pointers, really)
fmt.Fprintf(generator.GoSb, `
Expand Down Expand Up @@ -200,11 +205,6 @@ func New%[1]sFromC[SRC any](cvalue SRC) *%[1]s {
generatedTypedefs++
validTypeNames = append(validTypeNames, k)
case IsCallbackTypedef(typedefs.data[k]):
/*
if ctx.flags.showNotGenerated {
glg.Failf("typedef %s is a callback. Not implemented yet", k)
}
*/
// see https://github.com/AllenDang/cimgui-go/issues/224#issuecomment-2452156237
// 1: preprocessing - parse typedefs.data[k] to get return type and arguments
typedefName := CIdentifier(k)
Expand Down

0 comments on commit 178f49f

Please sign in to comment.