ebitengine/purego

purego callback function unsupport string ?

Closed this issue · 3 comments

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • Android
  • iOS

What feature would you like to be added?

not supporting string will increase a lot of development costs

Why is this needed?

No response

Hey @vela-security ,
you can use a byte pointer and convert this one into a string using the windows / unix package. Here is an example:

func traceLogCallbackWrapper(fn TraceLogCallbackFun) uintptr {
	return purego.NewCallback(func(logLevel int32, text *byte) uintptr {
		fn(int(logLevel), windows.BytePtrToString(text))
		return 0
	})
}

Source: https://github.com/gen2brain/raylib-go/blob/raylib/v5.0.0/raylib/purego_windows.go#L39

good ths..

not supporting string will increase a lot of development costs

I don't fully understand. Increasing development costs is usually a bad thing.

Forcing callbacks to be platform dependent because they take a string argument isn't the greatest user experience