cgo_fix.go 522 B

123456789101112131415161718
  1. package fix
  2. import "unsafe"
  3. import "C"
  4. import "log"
  5. //export message_callback_go
  6. func message_callback_go(pfunc unsafe.Pointer, trade unsafe.Pointer, msg unsafe.Pointer, sid unsafe.Pointer) {
  7. if msg == nil {
  8. f := *(*func (unsafe.Pointer, unsafe.Pointer))(pfunc)
  9. log.Println(trade, sid, msg, f)
  10. f(trade, sid)
  11. } else {
  12. f := *(*func (unsafe.Pointer, unsafe.Pointer, unsafe.Pointer))(pfunc)
  13. log.Println(trade, sid, msg, f)
  14. f(trade, msg, sid)
  15. }
  16. }