1
0
mirror of https://github.com/fumiama/gozel.git synced 2026-06-12 12:30:33 +08:00

optimize(zecall): better calling experience

This commit is contained in:
源文雨
2026-03-20 23:03:40 +08:00
parent e5e76ea149
commit 949b644bc7

View File

@@ -21,18 +21,18 @@ var (
procMap = map[string]*syscall.Proc{} procMap = map[string]*syscall.Proc{}
) )
// Init load lib using syscall. func init() {
func Init() error { if libZeLoader != nil {
return
}
h, err := syscall.LoadLibrary(zeLibraryName) h, err := syscall.LoadLibrary(zeLibraryName)
if err != nil { if err != nil {
return err panic(err)
} }
libZeLoader = &syscall.DLL{Handle: h, Name: zeLibraryName} libZeLoader = &syscall.DLL{Handle: h, Name: zeLibraryName}
return nil
} }
// Register a process for calling. // Register a process for calling. For generated init only. Not thread-safe.
func Register(name string) error { func Register(name string) error {
if libZeLoader == nil { if libZeLoader == nil {
return ErrZeCallNotInit return ErrZeCallNotInit
@@ -45,7 +45,7 @@ func Register(name string) error {
return nil return nil
} }
// Call invokes a registered proc by name. // Call invokes a registered proc by name. For generated call only.
// The go:uintptrescapes directive tells the compiler that args may contain // 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. // pointers converted to uintptr, so the GC will keep them alive during the call.
// //