2022-02-21 03:53:13 +00:00
|
|
|
package main // import "git.tuxpa.in/a/gosora/hook_stub_gen"
|
2020-05-23 22:24:23 +00:00
|
|
|
|
|
|
|
import (
|
2022-02-21 03:53:13 +00:00
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"runtime/debug"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
h "git.tuxpa.in/a/gosora/cmd/common_hook_gen"
|
2020-05-23 22:24:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// TODO: Make sure all the errors in this file propagate upwards properly
|
|
|
|
func main() {
|
2022-02-21 03:16:15 +00:00
|
|
|
// Capture panics instead of closing the window at a superhuman speed before the user can read the message on Windows
|
|
|
|
defer func() {
|
|
|
|
if r := recover(); r != nil {
|
|
|
|
fmt.Println(r)
|
|
|
|
debug.PrintStack()
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
imports := []string{"net/http"}
|
|
|
|
hookVars := h.HookVars{imports,nil}
|
|
|
|
add := func(name, params, ret, htype string, multiHook, skip bool, defaultRet, pure string) {
|
|
|
|
var params2 string
|
|
|
|
first := true
|
|
|
|
for _, param := range strings.Split(params,",") {
|
|
|
|
if !first {
|
|
|
|
params2 += ","
|
|
|
|
}
|
|
|
|
pspl := strings.Split(strings.ReplaceAll(strings.TrimSpace(param)," "," ")," ")
|
|
|
|
params2 += pspl[0]
|
|
|
|
first = false
|
|
|
|
}
|
|
|
|
hookVars.Hooks = append(hookVars.Hooks, h.Hook{name, params, params2, ret, htype, true, multiHook, skip, defaultRet,pure})
|
|
|
|
}
|
2020-05-23 22:24:23 +00:00
|
|
|
|
2022-02-21 03:16:15 +00:00
|
|
|
h.AddHooks(add)
|
|
|
|
h.Write(hookVars)
|
|
|
|
log.Println("Successfully generated the hooks")
|
2020-05-23 22:24:23 +00:00
|
|
|
}
|