forked from inaneverb/ekacore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunsafe.go
More file actions
49 lines (42 loc) · 1.47 KB
/
Copy pathunsafe.go
File metadata and controls
49 lines (42 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright © 2020. All rights reserved.
// Author: Ilya Stroy.
// Contacts: qioalice@gmail.com, https://github.com/qioalice
// License: https://opensource.org/licenses/MIT
package ekaerr
import (
"unsafe"
"github.com/qioalice/ekago/v2/internal/ekaletter"
)
// -----
// Functions with names started with "bridge..." are not used in this package
// but assigns to the bridge
// ( https://github.com/qioalice/ekago/internal/letter/bridge.go )
// and used at the ekaunsafe package's ekaerr related functions
// ( https://github.com/qioalice/ekago/ekaunsafe/ekaerr.go )
// -----
// bridgeGetLetter return *ekaletter.Letter object from the *ekaerr.Error object
// assuming that 'err' is an untyped pointer to the ekaerr.Error.
// Returns nil if 'err' == nil.
func bridgeGetLetter(err unsafe.Pointer) *ekaletter.Letter {
if err := (*Error)(err); err.IsValid() {
return err.letter
} else {
return nil
}
}
// bridgeGetStackIdx returns current stackIdx of the *ekaerr.Error object
// assuming that 'err' is an untyped pointer to the ekaerr.Error.
func bridgeGetStackIdx(err unsafe.Pointer) int16 {
if err := (*Error)(err); err.IsValid() {
return err.stackIdx
} else {
return -1
}
}
// bridgeSetStackIdx sets the new value of the *ekaerr.Error object's 'stackIdx' field
// assuming that 'err' is an untyped pointer to the ekaerr.Error.
func bridgeSetStackIdx(err unsafe.Pointer, newStackIdx int16) {
if err := (*Error)(err); err.IsValid() && newStackIdx >= 0 {
err.stackIdx = newStackIdx
}
}