c-for-go
c-for-go copied to clipboard
Write rules against the location of the type/define rather than the name
I'm trying to generate some Go code from C enums, and the generated output has the enums and their values 🎉 but it also includes a bunch of stdlib types/defines as well, my const.go has:
...
// INT64_MAX as defined in include/stdint.h:499
INT64_MAX = 0x10041bb70
// INT64_MIN as defined in include/stdint.h:500
INT64_MIN = 0x10041bb70
// UINT64_MAX as defined in include/stdint.h:501
UINT64_MAX = 0x10041bb70
...
I assume this is because my config is:
TRANSLATOR:
ConstRules:
defines: expand
enum: expand
Rules:
type:
- {action: accept, from: "^thing.*$"}
const:
- {action: accept, from: "^[A-Z].*$"}
and i'm accepting any upper case const, but i only want to accept my const/types not the stdlib ones that are also included by my header file, this seems like something everyone would encounter so I must be missing something? Can i write a rule that drops anything from include/stdint.h ?