Generate individual common-case type converter functions
diamondburned opened this issue · 0 comments
diamondburned commented
Right now, the typeconv
package is used by the code generators to inline the conversion directly into the functions. This means the code size (and probably binary size) is really big.
A possible fix for this is to define a set of rules for generating typeconv
code into specific functions, like (in pseudo-code)
// convertTGo converts the C type T to its Go equivalent.
func convertTGo(v T, ...) GoT
// convertGoT converts the Go type T to its C equivalent.
func convertGoT(v GoT, ...) T
This should deduplicate a lot of C-to-Go class/interface conversions and maybe bidirectional record conversions as well.
These functions will look fairly similar to the marshalT
functions, except now that we're autogenerating signal callbacks, we don't need marshalT
functions anymore. These functions will also be invoked directly instead of being registered globally for runtime invocation.