Skip to content

Commit

Permalink
[cgo] refs #105 Corrections all declare to *C.GoString => *string …
Browse files Browse the repository at this point in the history
…and `*C.GoSlice_` => `*[]byte` (While the return value is one `[]byte`)
  • Loading branch information
Maykel Arias Torres committed Sep 5, 2019
1 parent f73ebef commit a7e8466
Show file tree
Hide file tree
Showing 23 changed files with 145 additions and 164 deletions.
24 changes: 12 additions & 12 deletions lib/cgo/api.client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func SKY_api_NewClient(_addr string, _arg1 *C.Client__Handle) (____error_code ui
}

//export SKY_api_Client_CSRF
func SKY_api_Client_CSRF(_c C.Client__Handle, _arg0 *C.GoString_) (____error_code uint32) {
func SKY_api_Client_CSRF(_c C.Client__Handle, _arg0 *string) (____error_code uint32) {
c, okc := lookupClientHandle(_c)
if !okc {
____error_code = SKY_BAD_HANDLE
Expand All @@ -36,7 +36,7 @@ func SKY_api_Client_CSRF(_c C.Client__Handle, _arg0 *C.GoString_) (____error_cod
__arg0, ____return_err := c.CSRF()
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
copyString(__arg0, _arg0)
*_arg0 = __arg0
}
return
}
Expand Down Expand Up @@ -376,7 +376,7 @@ func SKY_api_Client_WalletFolderName(_c C.Client__Handle, _arg0 *C.Handle) (____
}

//export SKY_api_Client_NewSeed
func SKY_api_Client_NewSeed(_c C.Client__Handle, _entropy int, _arg1 *C.GoString_) (____error_code uint32) {
func SKY_api_Client_NewSeed(_c C.Client__Handle, _entropy int, _arg1 *string) (____error_code uint32) {
c, okc := lookupClientHandle(_c)
if !okc {
____error_code = SKY_BAD_HANDLE
Expand All @@ -386,7 +386,7 @@ func SKY_api_Client_NewSeed(_c C.Client__Handle, _entropy int, _arg1 *C.GoString
__arg1, ____return_err := c.NewSeed(entropy)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
copyString(__arg1, _arg1)
*_arg1 = __arg1
}
return
}
Expand Down Expand Up @@ -581,7 +581,7 @@ func SKY_api_Client_UnconfirmedTransactions(_c C.Client__Handle, _addrs []string
}

//export SKY_api_Client_InjectTransaction
func SKY_api_Client_InjectTransaction(_c C.Client__Handle, _rawTx C.Transaction__Handle, _arg1 *C.GoString_) (____error_code uint32) {
func SKY_api_Client_InjectTransaction(_c C.Client__Handle, _rawTx C.Transaction__Handle, _arg1 *string) (____error_code uint32) {
c, okc := lookupClientHandle(_c)
if !okc {
____error_code = SKY_BAD_HANDLE
Expand All @@ -596,7 +596,7 @@ func SKY_api_Client_InjectTransaction(_c C.Client__Handle, _rawTx C.Transaction_
__arg1, ____return_err := c.InjectTransaction(rawTx)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
copyString(__arg1, _arg1)
*_arg1 = __arg1
}
return
}
Expand All @@ -617,7 +617,7 @@ func SKY_api_Client_ResendUnconfirmedTransactions(_c C.Client__Handle, _arg0 *C.
}

//export SKY_api_Client_RawTransaction
func SKY_api_Client_RawTransaction(_c C.Client__Handle, _txid string, _arg1 *C.GoString_) (____error_code uint32) {
func SKY_api_Client_RawTransaction(_c C.Client__Handle, _txid string, _arg1 *string) (____error_code uint32) {
c, okc := lookupClientHandle(_c)
if !okc {
____error_code = SKY_BAD_HANDLE
Expand All @@ -627,7 +627,7 @@ func SKY_api_Client_RawTransaction(_c C.Client__Handle, _txid string, _arg1 *C.G
__arg1, ____return_err := c.RawTransaction(txid)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
copyString(__arg1, _arg1)
*_arg1 = __arg1
}
return
}
Expand Down Expand Up @@ -748,7 +748,7 @@ func SKY_api_Client_CreateWallet(_c C.Client__Handle, _cwo C.CreateWalletOptions
}

//export SKY_api_Client_InjectTransactionNoBroadcast
func SKY_api_Client_InjectTransactionNoBroadcast(_c C.Client__Handle, _txn C.Transaction__Handle, _arg0 *C.GoString_) (____error_code uint32) {
func SKY_api_Client_InjectTransactionNoBroadcast(_c C.Client__Handle, _txn C.Transaction__Handle, _arg0 *string) (____error_code uint32) {
c, okc := lookupClientHandle(_c)
if !okc {
____error_code = SKY_BAD_HANDLE
Expand All @@ -763,13 +763,13 @@ func SKY_api_Client_InjectTransactionNoBroadcast(_c C.Client__Handle, _txn C.Tra
____error_code = libErrorCode(____return_err)
if ____return_err == nil {

copyString(arg0, _arg0)
*_arg0 = arg0
}
return
}

//export SKY_api_Client_InjectEncodedTransactionNoBroadcast
func SKY_api_Client_InjectEncodedTransactionNoBroadcast(_c C.Client__Handle, rawtx string, _arg0 *C.GoString_) (____error_code uint32) {
func SKY_api_Client_InjectEncodedTransactionNoBroadcast(_c C.Client__Handle, rawtx string, _arg0 *string) (____error_code uint32) {
c, okc := lookupClientHandle(_c)
if !okc {
____error_code = SKY_BAD_HANDLE
Expand All @@ -780,7 +780,7 @@ func SKY_api_Client_InjectEncodedTransactionNoBroadcast(_c C.Client__Handle, raw
____error_code = libErrorCode(____return_err)
if ____return_err == nil {

copyString(arg0, _arg0)
*_arg0 = arg0
}
return
}
Expand Down
11 changes: 4 additions & 7 deletions lib/cgo/cipher.address.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"reflect"
"unsafe"

cipher "github.com/skycoin/skycoin/src/cipher"
Expand Down Expand Up @@ -65,10 +64,9 @@ 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 *C.GoSlice_) (____error_code uint32) {
func SKY_cipher_Address_Bytes(_addr *C.cipher__Address, _arg0 *[]byte) (____error_code uint32) {
addr := (*cipher.Address)(unsafe.Pointer(_addr))
bytes := addr.Bytes()
copyToGoSlice(reflect.ValueOf(bytes), _arg0)
*_arg0 = addr.Bytes()
return
}

Expand All @@ -82,10 +80,9 @@ 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 *C.GoString_) (____error_code uint32) {
func SKY_cipher_Address_String(_addr *C.cipher__Address, _arg1 *string) (____error_code uint32) {
addr := (*cipher.Address)(unsafe.Pointer(_addr))
s := addr.String()
copyString(s, _arg1)
*_arg1 = addr.String()
return
}

Expand Down
6 changes: 2 additions & 4 deletions lib/cgo/cipher.bip32.bip32.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"reflect"
"unsafe"

"github.com/skycoin/skycoin/src/cipher/bip32"
Expand Down Expand Up @@ -171,15 +170,14 @@ func SKY_bip32_PrivateKey_Serialize(_pk C.PrivateKey__Handle, _arg0 *[]byte) (__
}

//export SKY_bip32_PublicKey_Serialize
func SKY_bip32_PublicKey_Serialize(_pk C.PublicKey__Handle, _arg0 *C.GoSlice_) (___error_code uint32) {
func SKY_bip32_PublicKey_Serialize(_pk C.PublicKey__Handle, _arg0 *[]byte) (___error_code uint32) {
pk, okpk := lookupPublicKeyHandle(_pk)

if !okpk {
___error_code = SKY_BAD_HANDLE
return
}
arg0 := pk.Serialize()
copyToGoSlice(reflect.ValueOf(arg0), _arg0)
*_arg0 = pk.Serialize()
return
}

Expand Down
17 changes: 8 additions & 9 deletions lib/cgo/cipher.bip39.bip39.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"reflect"
"unsafe"

"github.com/skycoin/skycoin/src/cipher/bip39"
Expand All @@ -17,33 +16,33 @@ import (
import "C"

//export SKY_bip39_NewDefaultMnemomic
func SKY_bip39_NewDefaultMnemomic(_arg0 *C.GoString_) (____error_code uint32) {
func SKY_bip39_NewDefaultMnemomic(_arg0 *string) (____error_code uint32) {
__arg0, ____return_err := bip39.NewDefaultMnemonic()
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
copyString(__arg0, _arg0)
*_arg0 = __arg0
}
return
}

//export SKY_bip39_NewEntropy
func SKY_bip39_NewEntropy(_bitSize int, _arg1 *C.GoSlice_) (____error_code uint32) {
func SKY_bip39_NewEntropy(_bitSize int, _arg1 *[]byte) (____error_code uint32) {
bitSize := _bitSize
__arg1, ____return_err := bip39.NewEntropy(bitSize)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
copyToGoSlice(reflect.ValueOf(__arg1), _arg1)
*_arg1 = __arg1
}
return
}

//export SKY_bip39_NewMnemonic
func SKY_bip39_NewMnemonic(_entropy []byte, _arg1 *C.GoString_) (____error_code uint32) {
func SKY_bip39_NewMnemonic(_entropy []byte, _arg1 *string) (____error_code uint32) {
entropy := *(*[]byte)(unsafe.Pointer(&_entropy))
__arg1, ____return_err := bip39.NewMnemonic(entropy)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
copyString(__arg1, _arg1)
*_arg1 = __arg1
}
return
}
Expand All @@ -57,13 +56,13 @@ func SKY_bip39_ValidateMnemonic(_mnemonic string) (____error_code uint32) {
}

//export SKY_bip39_NewSeed
func SKY_bip39_NewSeed(_mnemonic string, _password string, _arg1 *C.GoSlice_) (____error_code uint32) {
func SKY_bip39_NewSeed(_mnemonic string, _password string, _arg1 *[]byte) (____error_code uint32) {
mnemonic := _mnemonic
password := _password
__arg1, ____return_err := bip39.NewSeed(mnemonic, password)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
copyToGoSlice(reflect.ValueOf(__arg1), _arg1)
*_arg1 = __arg1
}
return
}
11 changes: 4 additions & 7 deletions lib/cgo/cipher.bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ package main
import "C"

import (
"reflect"
"unsafe"

cipher "github.com/skycoin/skycoin/src/cipher"
Expand Down Expand Up @@ -83,10 +82,9 @@ func SKY_cipher_BitcoinAddress_Null(_addr *C.cipher__BitcoinAddress) bool {
}

//export SKY_cipher_BitcoinAddress_Bytes
func SKY_cipher_BitcoinAddress_Bytes(_addr *C.cipher__BitcoinAddress, _arg0 *C.GoSlice_) {
func SKY_cipher_BitcoinAddress_Bytes(_addr *C.cipher__BitcoinAddress, _arg0 *[]byte) {
addr := (*cipher.BitcoinAddress)(unsafe.Pointer(_addr))
bytes := addr.Bytes()
copyToGoSlice(reflect.ValueOf(bytes), _arg0)
*_arg0 = addr.Bytes()
}

//export SKY_cipher_BitcoinAddress_Verify
Expand All @@ -98,10 +96,9 @@ func SKY_cipher_BitcoinAddress_Verify(_addr *C.cipher__BitcoinAddress, _key *C.c
}

//export SKY_cipher_BitcoinAddress_String
func SKY_cipher_BitcoinAddress_String(_addr *C.cipher__BitcoinAddress, _arg1 *C.GoString_) {
func SKY_cipher_BitcoinAddress_String(_addr *C.cipher__BitcoinAddress, _arg1 *string) {
addr := (*cipher.BitcoinAddress)(unsafe.Pointer(_addr))
s := addr.String()
copyString(s, _arg1)
*_arg1 = addr.String()
}

//export SKY_cipher_BitcoinAddress_Checksum
Expand Down
31 changes: 14 additions & 17 deletions lib/cgo/cipher.crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ import (
import "C"

//export SKY_cipher_RandByte
func SKY_cipher_RandByte(_n int, _arg1 *C.GoSlice_) (____error_code uint32) {
b := cipher.RandByte(_n)
copyToGoSlice(reflect.ValueOf(b), _arg1)
func SKY_cipher_RandByte(_n int, _arg1 *[]byte) (____error_code uint32) {
*_arg1 = cipher.RandByte(_n)
return
}

Expand Down Expand Up @@ -84,10 +83,9 @@ func SKY_cipher_PubKey_Verify(_pk *C.cipher__PubKey) (____error_code uint32) {
}

//export SKY_cipher_PubKey_Hex
func SKY_cipher_PubKey_Hex(_pk *C.cipher__PubKey, _arg1 *C.GoString_) (____error_code uint32) {
func SKY_cipher_PubKey_Hex(_pk *C.cipher__PubKey, _arg1 *string) (____error_code uint32) {
pk := (*cipher.PubKey)(unsafe.Pointer(_pk))
s := pk.Hex()
copyString(s, _arg1)
*_arg1 = pk.Hex()
return SKY_OK
}

Expand Down Expand Up @@ -130,21 +128,20 @@ func SKY_cipher_SecKey_Verify(_sk *C.cipher__SecKey) (____error_code uint32) {
}

//export SKY_cipher_SecKey_Hex
func SKY_cipher_SecKey_Hex(_sk *C.cipher__SecKey, _arg1 *C.GoString_) (____error_code uint32) {
func SKY_cipher_SecKey_Hex(_sk *C.cipher__SecKey, _arg1 *string) (____error_code uint32) {
sk := (*cipher.SecKey)(unsafe.Pointer(_sk))
s := sk.Hex()
copyString(s, _arg1)
*_arg1 = sk.Hex()
return
}

//export SKY_cipher_ECDH
func SKY_cipher_ECDH(_pub *C.cipher__PubKey, _sec *C.cipher__SecKey, _arg2 *C.GoSlice_) (____error_code uint32) {
func SKY_cipher_ECDH(_pub *C.cipher__PubKey, _sec *C.cipher__SecKey, _arg2 *[]byte) (____error_code uint32) {
pub := (*cipher.PubKey)(unsafe.Pointer(_pub))
sec := (*cipher.SecKey)(unsafe.Pointer(_sec))
b, err := cipher.ECDH(*pub, *sec)
____error_code = libErrorCode(err)
if err == nil {
copyToGoSlice(reflect.ValueOf(b), _arg2)
*_arg2 = b
}
return
}
Expand All @@ -171,9 +168,9 @@ func SKY_cipher_SigFromHex(_s string, _arg1 *C.cipher__Sig) (____error_code uint
}

//export SKY_cipher_Sig_Hex
func SKY_cipher_Sig_Hex(_s *C.cipher__Sig, _arg1 *C.GoString_) (____error_code uint32) {
func SKY_cipher_Sig_Hex(_s *C.cipher__Sig, _arg1 *string) (____error_code uint32) {
s := (*cipher.Sig)(unsafe.Pointer(_s))
copyString(s.Hex(), _arg1)
*_arg1 = s.Hex()
return
}

Expand Down Expand Up @@ -257,10 +254,10 @@ func SKY_cipher_GenerateDeterministicKeyPairs(_seed []byte, _n int, _arg2 *C.GoS
}

//export SKY_cipher_GenerateDeterministicKeyPairsSeed
func SKY_cipher_GenerateDeterministicKeyPairsSeed(_seed []byte, _n int, _arg2 *C.GoSlice_, _arg3 *C.GoSlice_) (____error_code uint32) {
func SKY_cipher_GenerateDeterministicKeyPairsSeed(_seed []byte, _n int, _arg2 *[]byte, _arg3 *C.GoSlice_) (____error_code uint32) {
h, sks, err := cipher.GenerateDeterministicKeyPairsSeed(_seed, _n)
if err == nil {
copyToGoSlice(reflect.ValueOf(h), _arg2)
*_arg2 = h
copyToGoSlice(reflect.ValueOf(sks), _arg3)
}

Expand All @@ -287,9 +284,9 @@ func SKY_cipher_CheckSecKeyHash(_seckey *C.cipher__SecKey, _hash *C.cipher__SHA2
}

//export SKY_cipher_Sig_String
func SKY_cipher_Sig_String(_s *C.cipher__Sig, _arg1 *C.GoString_) (____error_code uint32) {
func SKY_cipher_Sig_String(_s *C.cipher__Sig, _arg1 *string) (____error_code uint32) {
s := (*cipher.Sig)(unsafe.Pointer(_s))
copyString(s.String(), _arg1)
*_arg1 = s.String()
return
}

Expand Down
9 changes: 4 additions & 5 deletions lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"reflect"
"unsafe"

encrypt "github.com/skycoin/skycoin/src/cipher/encrypt"
Expand All @@ -17,28 +16,28 @@ import (
import "C"

//export SKY_encrypt_ScryptChacha20poly1305_Encrypt
func SKY_encrypt_ScryptChacha20poly1305_Encrypt(_s *C.encrypt__ScryptChacha20poly1305, _data []byte, _password []byte, _arg1 *C.GoSlice_) (____error_code uint32) {
func SKY_encrypt_ScryptChacha20poly1305_Encrypt(_s *C.encrypt__ScryptChacha20poly1305, _data []byte, _password []byte, _arg1 *[]byte) (____error_code uint32) {

s := *(*encrypt.ScryptChacha20poly1305)(unsafe.Pointer(_s))
data := *(*[]byte)(unsafe.Pointer(&_data))
password := *(*[]byte)(unsafe.Pointer(&_password))
__arg1, ____return_err := s.Encrypt(data, password)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
copyToGoSlice(reflect.ValueOf(__arg1), _arg1)
*_arg1 = __arg1
}
return
}

//export SKY_encrypt_ScryptChacha20poly1305_Decrypt
func SKY_encrypt_ScryptChacha20poly1305_Decrypt(_s *C.encrypt__ScryptChacha20poly1305, _data []byte, _password []byte, _arg1 *C.GoSlice_) (____error_code uint32) {
func SKY_encrypt_ScryptChacha20poly1305_Decrypt(_s *C.encrypt__ScryptChacha20poly1305, _data []byte, _password []byte, _arg1 *[]byte) (____error_code uint32) {
s := *(*encrypt.ScryptChacha20poly1305)(unsafe.Pointer(_s))
data := *(*[]byte)(unsafe.Pointer(&_data))
password := *(*[]byte)(unsafe.Pointer(&_password))
__arg1, ____return_err := s.Decrypt(data, password)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
copyToGoSlice(reflect.ValueOf(__arg1), _arg1)
*_arg1 = __arg1
}
return
}
Loading

0 comments on commit a7e8466

Please sign in to comment.