Skip to content

Commit

Permalink
[cgo] refs fibercrypto#105 Restore to *string => *C.GoString_
Browse files Browse the repository at this point in the history
  • Loading branch information
Maykel Arias Torres committed Sep 21, 2019
1 parent 636d24c commit 8b24ee0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
11 changes: 7 additions & 4 deletions lib/cgo/cipher.address.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"reflect"
"unsafe"

cipher "github.com/skycoin/skycoin/src/cipher"
Expand Down Expand Up @@ -64,9 +65,10 @@ func SKY_cipher_Address_Null(_addr *C.cipher__Address, _arg0 *bool) (____error_c
}

//export SKY_cipher_Address_Bytes
func SKY_cipher_Address_Bytes(_addr *C.cipher__Address, _arg0 *[]byte) (____error_code uint32) {
func SKY_cipher_Address_Bytes(_addr *C.cipher__Address, _arg0 *C.GoSlice_) (____error_code uint32) {
addr := (*cipher.Address)(unsafe.Pointer(_addr))
*_arg0 = addr.Bytes()
bytes := addr.Bytes()
copyToGoSlice(reflect.ValueOf(bytes), _arg0)
return
}

Expand All @@ -80,9 +82,10 @@ func SKY_cipher_Address_Verify(_addr *C.cipher__Address, _key *C.cipher__PubKey)
}

//export SKY_cipher_Address_String
func SKY_cipher_Address_String(_addr *C.cipher__Address, _arg1 *string) (____error_code uint32) {
func SKY_cipher_Address_String(_addr *C.cipher__Address, _arg1 *C.GoString_) (____error_code uint32) {
addr := (*cipher.Address)(unsafe.Pointer(_addr))
*_arg1 = addr.String()
__arg1 := addr.String()
copyString(__arg1, _arg1)
return
}

Expand Down
28 changes: 16 additions & 12 deletions lib/cgo/cipher.base58.base58.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"encoding/hex"
"reflect"
"unsafe"

"github.com/skycoin/skycoin/src/cipher/base58"
Expand All @@ -17,46 +18,49 @@ import (
import "C"

//export SKY_base58_Hex2Base58
func SKY_base58_Hex2Base58(_val []byte, _arg1 *string) (____error_code uint32) {
func SKY_base58_Hex2Base58(_val []byte, _arg1 *C.GoString_) (____error_code uint32) {
val := *(*[]byte)(unsafe.Pointer(&_val))
*_arg1 = string(base58.Encode(val))
__arg1 := string(base58.Encode(val))
copyString(__arg1, _arg1)
return
}

//export SKY_base58_Encode
func SKY_base58_Encode(_bin []byte, _arg1 *string) (____error_code uint32) {
func SKY_base58_Encode(_bin []byte, _arg1 *C.GoString_) (____error_code uint32) {
bin := *(*[]byte)(unsafe.Pointer(&_bin))
*_arg1 = base58.Encode(bin)

__arg1 := base58.Encode(bin)
copyString(__arg1, _arg1)
return
}

//export SKY_base58_Decode
func SKY_base58_Decode(_s string, _arg1 *[]byte) (____error_code uint32) {
func SKY_base58_Decode(_s string, _arg1 *C.GoSlice_) (____error_code uint32) {
s := _s
__arg1, ____return_err := base58.Decode(s)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
*_arg1 = __arg1
copyToGoSlice(reflect.ValueOf(__arg1), _arg1)
}

return
}

//export SKY_base58_String2Hex
func SKY_base58_String2Hex(_s string, _arg1 *[]byte) (____error_code uint32) {
__arg1, ____return_err := hex.DecodeString(_s)
func SKY_base58_String2Hex(_s string, _arg1 *C.GoSlice_) (____error_code uint32) {
s := _s
__arg1, ____return_err := hex.DecodeString(s)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
*_arg1 = __arg1
copyToGoSlice(reflect.ValueOf(__arg1), _arg1)
}

return
}

//export SKY_base58_Hex2String
func SKY_base58_Hex2String(_b []byte, _arg1 *string) (____error_code uint32) {
func SKY_base58_Hex2String(_b []byte, _arg1 *C.GoString_) (____error_code uint32) {
bin := *(*[]byte)(unsafe.Pointer(&_b))
*_arg1 = hex.EncodeToString(bin)
__arg1 := hex.EncodeToString(bin)
copyString(__arg1, _arg1)
return
}

0 comments on commit 8b24ee0

Please sign in to comment.