mirror of
https://github.com/fumiama/gozel.git
synced 2026-06-23 12:00:31 +08:00
feat(gen&zecall): add function support
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package zecall
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"syscall"
|
||||
|
||||
"github.com/ebitengine/purego"
|
||||
@@ -11,13 +10,6 @@ const (
|
||||
zeLibraryName = "libze_loader.so"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrZeCallNotInit please call Init() first.
|
||||
ErrZeCallNotInit = errors.New("zecall not init")
|
||||
// ErrNoSuchProcess please register the process first.
|
||||
ErrNoSuchProcess = errors.New("no such process")
|
||||
)
|
||||
|
||||
var (
|
||||
libZeLoader uintptr
|
||||
procMap = map[string]uintptr{}
|
||||
@@ -47,12 +39,12 @@ func Register(name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Call invokes a registered proc by name. For generated call only.
|
||||
// Syscall invokes a registered proc by name. For generated call only.
|
||||
// The go:uintptrescapes directive tells the compiler that args may contain
|
||||
// pointers converted to uintptr, so the GC will keep them alive during the call.
|
||||
//
|
||||
//go:uintptrescapes
|
||||
func Call(name string, args ...uintptr) (r1, r2 uintptr, err error) {
|
||||
func Syscall(name string, args ...uintptr) (r1, r2 uintptr, err error) {
|
||||
fn, ok := procMap[name]
|
||||
if !ok {
|
||||
return 0, 0, ErrNoSuchProcess
|
||||
|
||||
Reference in New Issue
Block a user