github.com/qioalice/ekago/v3@v3.3.2-0.20221202205325-5c262d586ee4/internal/ekaletter/bridge.go (about) 1 // Copyright © 2020-2021. All rights reserved. 2 // Author: Ilya Stroy. 3 // Contacts: iyuryevich@pm.me, https://github.com/qioalice 4 // License: https://opensource.org/licenses/MIT 5 6 package ekaletter 7 8 import ( 9 "unsafe" 10 ) 11 12 // It's a special file that contains gate functions. 13 // 14 // So, we need to import 'ekalog' -> 'ekaerr' and vice-versa, but cross imports 15 // are prohibited by Go rules. So, it's a simple hack. We initializing these 16 // functions at the packages' init() calls and then use them and use unsafe.Pointer 17 // as arguments to describe arguments but do not specify types. 18 19 var ( 20 // BridgeErrorGetLetter is a function that is initialized 21 // in the ekaerr package and used in the ekaunsafe package. 22 // 23 // This function must return an underlying *Letter object 24 // from the 'err' - *ekaerr.Error object. 25 BridgeErrorGetLetter func(err unsafe.Pointer) *Letter 26 27 // BridgeErrorGetStackIdx, BridgeErrorSetStackIdx are a functions that are initialized 28 // in the ekaerr package and used in the ekaunsafe package. 29 // 30 // These functions are *ekaerr.Error object's 'stackIdx' field getter/setter. 31 32 BridgeErrorGetStackIdx func(err unsafe.Pointer) int16 33 BridgeErrorSetStackIdx func(err unsafe.Pointer, newStackIdx int16) 34 )