xlab / c-for-go

Automatic C-Go Bindings Generator for Go Programming Language
https://c.for-go.com
MIT License
1.5k stars 119 forks source link

runtime error: invalid memory address or nil pointer dereference #172

Closed henriquetied472 closed 3 weeks ago

henriquetied472 commented 2 months ago

Im struggling to make bindings for Ultralight

ultralight.yml:

GENERATOR: 
  PackageName: ultralight
  PackageDescription: "Ultralight bindings for golang"
  PackageLicense: "THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS."
  FlagGroups:
    - {name: CFLAGS, flags: [-I../include]}
    - {name: LDFLAGS, flags: ["-Wl,--allow-multiple-definition -L${SRCDIR}/libs/linux/x64 -Wl,-rpath,/home/co/code/Muon/ultralight/libs/linux/x64 -lUltralightCore -lAppCore -lUltralight -lWebCore"]}
  Includes: ["AppCore/CAPI.h"]
  Options:
    SafeStrings: true

PARSER: 
  Arch: x86_64
  IncludePaths:
    - include
    - /usr/include
    - /usr/lib/gcc/x86_64-linux-gnu/9/include
  SourcesPaths:
    - AppCore/CAPI.h

TRANSLATOR:
    ConstRules:
      defines: expand
      enum: eval
    Rules:
        global:
          - {action: accept, from: "^ul"}
          - {action: accept, from: "^Ul"}
          - {action: accept, from: "^UL"}
          - {action: accept, from: "^js"}
          - {action: accept, from: "^JS"}
          - {action: accept, from: "^k"}
          - {action: accept, from: "^B"}
          - {transform: export}
            # - {action: accept, from: "^ul"}
            # - {action: accept, from: "^UL"}
            # - {action: accept, from: "^Ul"}
            # - {action: accept, from: "^JS"}
            # - {action: accept, from: "^k"}
            # - {action: accept, from: "^B"}
            # # - {action: ignore, from: __size_t__}
            # # - {action: ignore, from: __SIZE_T__}
            # # - {action: ignore, from: _BSD_SIZE_T_DEFINED_}
            # # - {action: ignore, from: _SIZE_T_DECLARED}
            # # - {action: ignore, from: __wchar_t__}
            # # - {action: ignore, from: __WCHAR_T__}
            #- {transform: export}
        function:
          - {action: accept, from: "^ul"}
          - {action: accept, from: "^Ul"}
          - {action: accept, from: "^UL"}
          - {action: accept, from: "^js"}
          - {action: accept, from: "^JS"}
          - {action: ignore, from: "ulCreateStringFromCopy"} # Not actually exported the header lies!

          - {transform: export}
        private:
          - {transform: unexport}
        post-global: 
          - {action: replace, from: _$}
          - {load: snakecase}

and the error:

$ c-for-go -out ultralight -ccdefs ultralight.yml
 processing ultralight.yml ⠋panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x78 pc=0x66150d]

goroutine 1 [running]:
github.com/xlab/c-for-go/parser.ParseWith(0xc00009bbc0?)
    /home/henrique/go/pkg/mod/github.com/xlab/c-for-go@v1.2.0/parser/parser.go:89 +0x94d
main.NewProcess({0x7fff0a03aa61, 0xe}, {0x7fff0a03aa4e, 0xa})
    /home/henrique/go/pkg/mod/github.com/xlab/c-for-go@v1.2.0/process.go:81 +0x30b
main.main()
    /home/henrique/go/pkg/mod/github.com/xlab/c-for-go@v1.2.0/main.go:80 +0x225

Im using Manjaro x64 and Go 1.23.