Documentation ¶
Overview ¶
Package custom is similar to the WebAssembly Custom Sections. These are needed because `GOOS=js GOARCH=wasm` functions aren't defined naturally in WebAssembly. For example, every function has a single parameter "sp", which implicitly maps to stack parameters in this package.
Index ¶
Constants ¶
const ( NameCrypto = "crypto" NameCryptoGetRandomValues = "getRandomValues" )
const ( NameDate = "Date" NameDateGetTimezoneOffset = "getTimezoneOffset" )
const ( NameFs = "fs" NameFsOpen = "open" NameFsStat = "stat" NameFsFstat = "fstat" NameFsLstat = "lstat" NameFsClose = "close" NameFsWrite = "write" NameFsRead = "read" NameFsReaddir = "readdir" NameFsMkdir = "mkdir" NameFsRmdir = "rmdir" NameFsRename = "rename" NameFsUnlink = "unlink" NameFsUtimes = "utimes" NameFsChmod = "chmod" NameFsFchmod = "fchmod" NameFsChown = "chown" NameFsFchown = "fchown" NameFsLchown = "lchown" NameFsTruncate = "truncate" NameFsFtruncate = "ftruncate" NameFsReadlink = "readlink" NameFsLink = "link" NameFsSymlink = "symlink" NameFsFsync = "fsync" )
const ( S_IFSOCK = uint32(0o000140000) S_IFLNK = uint32(0o000120000) S_IFREG = uint32(0o000100000) S_IFBLK = uint32(0o000060000) S_IFDIR = uint32(0o000040000) S_IFCHR = uint32(0o000020000) S_IFIFO = uint32(0o000010000) S_ISUID = uint32(0o004000) S_ISGID = uint32(0o002000) S_ISVTX = uint32(0o001000) )
mode constants from syscall_js.go
const ( NameCallback = "callback" NameDebug = "debug" )
const ( NameRuntimeWasmExit = "runtime.wasmExit" NameRuntimeWasmWrite = "runtime.wasmWrite" NameRuntimeResetMemoryDataView = "runtime.resetMemoryDataView" NameRuntimeNanotime1 = "runtime.nanotime1" NameRuntimeWalltime = "runtime.walltime" NameRuntimeScheduleTimeoutEvent = "runtime.scheduleTimeoutEvent" NameRuntimeClearTimeoutEvent = "runtime.clearTimeoutEvent" NameRuntimeGetRandomData = "runtime.getRandomData" )
const ( NameSyscallFinalizeRef = "syscall/js.finalizeRef" NameSyscallStringVal = "syscall/js.stringVal" NameSyscallValueGet = "syscall/js.valueGet" NameSyscallValueSet = "syscall/js.valueSet" NameSyscallValueDelete = "syscall/js.valueDelete" // stubbed NameSyscallValueIndex = "syscall/js.valueIndex" NameSyscallValueSetIndex = "syscall/js.valueSetIndex" // stubbed NameSyscallValueCall = "syscall/js.valueCall" NameSyscallValueInvoke = "syscall/js.valueInvoke" // stubbed NameSyscallValueNew = "syscall/js.valueNew" NameSyscallValueLength = "syscall/js.valueLength" NameSyscallValuePrepareString = "syscall/js.valuePrepareString" NameSyscallValueLoadString = "syscall/js.valueLoadString" NameSyscallValueInstanceOf = "syscall/js.valueInstanceOf" // stubbed NameSyscallCopyBytesToGo = "syscall/js.copyBytesToGo" NameSyscallCopyBytesToJS = "syscall/js.copyBytesToJS" )
const ( NameProcess = "process" NameProcessArgv0 = "argv0" NameProcessCwd = "cwd" NameProcessChdir = "chdir" NameProcessGetuid = "getuid" NameProcessGetgid = "getgid" NameProcessGeteuid = "geteuid" NameProcessGetgroups = "getgroups" NameProcessUmask = "umask" )
const ( // NamePadding is a marker for a parameter which has no purpose, except // padding. It should not be logged. NamePadding = "padding" )
Variables ¶
var CryptoNameSection = map[string]*Names{ NameCryptoGetRandomValues: { Name: NameCryptoGetRandomValues, ParamNames: []string{"r"}, ResultNames: []string{"n"}, }, }
CryptoNameSection are the functions defined in the object named NameCrypto. Results here are those set to the current event object, but effectively are results of the host function.
var DateNameSection = map[string]*Names{ NameDateGetTimezoneOffset: { Name: NameDateGetTimezoneOffset, ParamNames: []string{}, ResultNames: []string{"tz"}, }, }
DateNameSection are the functions defined in the object named NameDate. Results here are those set to the current event object, but effectively are results of the host function.
var FsNameSection = map[string]*Names{ NameFsOpen: { Name: NameFsOpen, ParamNames: []string{"path", "flags", "perm", NameCallback}, ResultNames: []string{"err", "fd"}, }, NameFsStat: { Name: NameFsStat, ParamNames: []string{"path", NameCallback}, ResultNames: []string{"err", "stat"}, }, NameFsFstat: { Name: NameFsFstat, ParamNames: []string{"fd", NameCallback}, ResultNames: []string{"err", "stat"}, }, NameFsLstat: { Name: NameFsLstat, ParamNames: []string{"path", NameCallback}, ResultNames: []string{"err", "stat"}, }, NameFsClose: { Name: NameFsClose, ParamNames: []string{"fd", NameCallback}, ResultNames: []string{"err", "ok"}, }, NameFsRead: { Name: NameFsRead, ParamNames: []string{"fd", "buf", "offset", "byteCount", "fOffset", NameCallback}, ResultNames: []string{"err", "n"}, }, NameFsWrite: { Name: NameFsWrite, ParamNames: []string{"fd", "buf", "offset", "byteCount", "fOffset", NameCallback}, ResultNames: []string{"err", "n"}, }, NameFsReaddir: { Name: NameFsReaddir, ParamNames: []string{"path", NameCallback}, ResultNames: []string{"err", "dirents"}, }, NameFsMkdir: { Name: NameFsMkdir, ParamNames: []string{"path", "perm", NameCallback}, ResultNames: []string{"err", "fd"}, }, NameFsRmdir: { Name: NameFsRmdir, ParamNames: []string{"path", NameCallback}, ResultNames: []string{"err", "ok"}, }, NameFsRename: { Name: NameFsRename, ParamNames: []string{"from", "to", NameCallback}, ResultNames: []string{"err", "ok"}, }, NameFsUnlink: { Name: NameFsUnlink, ParamNames: []string{"path", NameCallback}, ResultNames: []string{"err", "ok"}, }, NameFsUtimes: { Name: NameFsUtimes, ParamNames: []string{"path", "atime", "mtime", NameCallback}, ResultNames: []string{"err", "ok"}, }, NameFsChmod: { Name: NameFsChmod, ParamNames: []string{"path", "mode", NameCallback}, ResultNames: []string{"err", "ok"}, }, NameFsFchmod: { Name: NameFsFchmod, ParamNames: []string{"fd", "mode", NameCallback}, ResultNames: []string{"err", "ok"}, }, NameFsChown: { Name: NameFsChown, ParamNames: []string{"path", "uid", "gid", NameCallback}, ResultNames: []string{"err", "ok"}, }, NameFsFchown: { Name: NameFsFchown, ParamNames: []string{"fd", "uid", "gid", NameCallback}, ResultNames: []string{"err", "ok"}, }, NameFsLchown: { Name: NameFsLchown, ParamNames: []string{"path", "uid", "gid", NameCallback}, ResultNames: []string{"err", "ok"}, }, NameFsTruncate: { Name: NameFsTruncate, ParamNames: []string{"path", "length", NameCallback}, ResultNames: []string{"err", "ok"}, }, NameFsFtruncate: { Name: NameFsFtruncate, ParamNames: []string{"fd", "length", NameCallback}, ResultNames: []string{"err", "ok"}, }, NameFsReadlink: { Name: NameFsReadlink, ParamNames: []string{"path", NameCallback}, ResultNames: []string{"err", "dst"}, }, NameFsLink: { Name: NameFsLink, ParamNames: []string{"path", "link", NameCallback}, ResultNames: []string{"err", "ok"}, }, NameFsSymlink: { Name: NameFsSymlink, ParamNames: []string{"path", "link", NameCallback}, ResultNames: []string{"err", "ok"}, }, NameFsFsync: { Name: NameFsFsync, ParamNames: []string{"fd", NameCallback}, ResultNames: []string{"err", "ok"}, }, }
FsNameSection are the functions defined in the object named NameFs. Results here are those set to the current event object, but effectively are results of the host function.
var NameSection = map[string]*Names{ NameDebug: { Name: NameDebug, ParamNames: []string{}, ResultNames: []string{}, }, NameRuntimeWasmExit: { Name: NameRuntimeWasmExit, ParamNames: []string{"code"}, ResultNames: []string{}, }, NameRuntimeWasmWrite: { Name: NameRuntimeWasmWrite, ParamNames: []string{"fd", "p", "p_len"}, ResultNames: []string{}, }, NameRuntimeResetMemoryDataView: { Name: NameRuntimeResetMemoryDataView, ParamNames: []string{}, ResultNames: []string{}, }, NameRuntimeNanotime1: { Name: NameRuntimeNanotime1, ParamNames: []string{}, ResultNames: []string{"nsec"}, }, NameRuntimeWalltime: { Name: NameRuntimeWalltime, ParamNames: []string{}, ResultNames: []string{"sec", "nsec"}, }, NameRuntimeScheduleTimeoutEvent: { Name: NameRuntimeScheduleTimeoutEvent, ParamNames: []string{"ms"}, ResultNames: []string{"id"}, }, NameRuntimeClearTimeoutEvent: { Name: NameRuntimeClearTimeoutEvent, ParamNames: []string{"id"}, ResultNames: []string{}, }, NameRuntimeGetRandomData: { Name: NameRuntimeGetRandomData, ParamNames: []string{"r", "r_len"}, ResultNames: []string{}, }, NameSyscallFinalizeRef: { Name: NameSyscallFinalizeRef, ParamNames: []string{"r"}, ResultNames: []string{}, }, NameSyscallStringVal: { Name: NameSyscallStringVal, ParamNames: []string{"x", "x_len"}, ResultNames: []string{"r"}, }, NameSyscallValueGet: { Name: NameSyscallValueGet, ParamNames: []string{"v", "p", "p_len"}, ResultNames: []string{"r"}, }, NameSyscallValueSet: { Name: NameSyscallValueSet, ParamNames: []string{"v", "p", "p_len", "x"}, ResultNames: []string{}, }, NameSyscallValueDelete: { Name: NameSyscallValueDelete, ParamNames: []string{"v", "p", "p_len"}, ResultNames: []string{}, }, NameSyscallValueIndex: { Name: NameSyscallValueIndex, ParamNames: []string{"v", "i"}, ResultNames: []string{"r"}, }, NameSyscallValueSetIndex: { Name: NameSyscallValueSetIndex, ParamNames: []string{"v", "i", "x"}, ResultNames: []string{}, }, NameSyscallValueCall: { Name: NameSyscallValueCall, ParamNames: []string{"v", "m", "m_len", "args", "args_len", NamePadding}, ResultNames: []string{"res", "ok"}, }, NameSyscallValueInvoke: { Name: NameSyscallValueInvoke, ParamNames: []string{"v", "args", "args_len", NamePadding}, ResultNames: []string{"res", "ok"}, }, NameSyscallValueNew: { Name: NameSyscallValueNew, ParamNames: []string{"v", "args", "args_len", NamePadding}, ResultNames: []string{"res", "ok"}, }, NameSyscallValueLength: { Name: NameSyscallValueLength, ParamNames: []string{"v"}, ResultNames: []string{"len"}, }, NameSyscallValuePrepareString: { Name: NameSyscallValuePrepareString, ParamNames: []string{"v"}, ResultNames: []string{"str", "length"}, }, NameSyscallValueLoadString: { Name: NameSyscallValueLoadString, ParamNames: []string{"v", "b", "b_len"}, ResultNames: []string{}, }, NameSyscallValueInstanceOf: { Name: NameSyscallValueInstanceOf, ParamNames: []string{"v", "t"}, ResultNames: []string{"ok"}, }, NameSyscallCopyBytesToGo: { Name: NameSyscallCopyBytesToGo, ParamNames: []string{"dst", "dst_len", NamePadding, "src"}, ResultNames: []string{"n", "ok"}, }, NameSyscallCopyBytesToJS: { Name: NameSyscallCopyBytesToJS, ParamNames: []string{"dst", "src", "src_len", NamePadding}, ResultNames: []string{"n", "ok"}, }, }
var NameSectionSyscallValueCall = map[string]map[string]*Names{ NameCrypto: CryptoNameSection, NameDate: DateNameSection, NameFs: FsNameSection, NameProcess: ProcessNameSection, }
var ProcessNameSection = map[string]*Names{ NameProcessArgv0: { Name: NameProcessArgv0, ParamNames: []string{}, ResultNames: []string{"argv0"}, }, NameProcessCwd: { Name: NameProcessCwd, ParamNames: []string{}, ResultNames: []string{"cwd"}, }, NameProcessChdir: { Name: NameProcessChdir, ParamNames: []string{"path"}, ResultNames: []string{"err"}, }, NameProcessGetuid: { Name: NameProcessGetuid, ParamNames: []string{}, ResultNames: []string{"uid"}, }, NameProcessGetgid: { Name: NameProcessGetgid, ParamNames: []string{}, ResultNames: []string{"gid"}, }, NameProcessGeteuid: { Name: NameProcessGeteuid, ParamNames: []string{}, ResultNames: []string{"euid"}, }, NameProcessGetgroups: { Name: NameProcessGetgroups, ParamNames: []string{}, ResultNames: []string{"groups"}, }, NameProcessUmask: { Name: NameProcessUmask, ParamNames: []string{"mask"}, ResultNames: []string{"oldmask"}, }, }
ProcessNameSection are the functions defined in the object named NameProcess. Results here are those set to the current event object, but effectively are results of the host function.
Functions ¶
func FromJsMode ¶
FromJsMode is required because the mode property read in `GOOS=js` is incompatible with normal go. Particularly the directory flag isn't the same.
Types ¶
type Names ¶
type Names struct { // Name is the WebAssembly function name. Name string // ParamNames are the parameters read in 8-byte strides from the stack // pointer (SP). This may be nil or include NamePadding. ParamNames []string // ResultNames are the results written in 8-byte strides from the stack // pointer (SP), after ParamNames. ResultNames []string }