github.com/primecitizens/pcz/std@v0.2.1/ffi/callback.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  
     4  package ffi
     5  
     6  // CallbackDispatcher defines the generic interface to dispatch ffi callbacks.
     7  //
     8  // The CallbackContext is specific to each foreign language.
     9  type CallbackDispatcher[CallbackContext any] interface {
    10  	// DispatchCallback dispatches a call from foreign function.
    11  	//
    12  	// targetPC is the pc provided when registering the target function.
    13  	// ctx is the foreign function specific callback context.
    14  	DispatchCallback(targetPC uintptr, ctx *CallbackContext)
    15  }
    16  
    17  // DispatchFunc is the function signature of
    18  // CallbackDispatcher.DispatchCallback
    19  type DispatchFunc[T any, CallbackContext any] func(
    20  	recv T, targetPC uintptr, ctx *CallbackContext,
    21  )