From 6648fcea0e6afcb5d8686b1357d8638c17e0d102 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Tue, 24 Mar 2020 15:18:19 -0400 Subject: [PATCH] [cgo] refs #5 Added `coin.mocks.TxnSigner` --- include/fctypes.h | 6 ++ lib/cgo/coin.mocks.TxnSigner.go | 110 ++++++++++++++++++++++++++++++++ lib/cgo/handles | 3 +- lib/cgo/libfc_handle.go | 14 ++++ 4 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 lib/cgo/coin.mocks.TxnSigner.go diff --git a/include/fctypes.h b/include/fctypes.h index 5b1fe29..6932f6b 100644 --- a/include/fctypes.h +++ b/include/fctypes.h @@ -499,6 +499,12 @@ typedef Handle TransactionOutputMocks__Handle; */ typedef Handle TransactionOutputIteratorMocks__Handle; +/** + * TxnSignerMocks__Handle Handle, struct + * mocks.TxnSignerIterator + */ +typedef Handle TxnSignerMocks__Handle; + // Callbacks /** diff --git a/lib/cgo/coin.mocks.TxnSigner.go b/lib/cgo/coin.mocks.TxnSigner.go new file mode 100644 index 0000000..76cf4dc --- /dev/null +++ b/lib/cgo/coin.mocks.TxnSigner.go @@ -0,0 +1,110 @@ +package main + +import ( + "errors" + "unsafe" + + core "github.com/fibercrypto/fibercryptowallet/src/core" +) + +/* + + #include + #include + + #include "fctypes.h" + #include "fccallback.h" +*/ +import "C" + +//export FC_mocks_TxnSigner_GetSignerDescription +func FC_mocks_TxnSigner_GetSignerDescription(__m *C.TxnSignerMocks__Handle, _arg0 *C.GoString_) (____error_code uint32) { + _m, ok_m := lookupTxnSignerMocksHandle(*__m) + if !ok_m { + ____error_code = FC_BAD_HANDLE + return + } + __arg0, ____return_err := _m.GetSignerDescription() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg0, _arg0) + } + return +} + +//export FC_mocks_TxnSigner_GetSignerUID +func FC_mocks_TxnSigner_GetSignerUID(__m *C.TxnSignerMocks__Handle, _arg0 *C.core__UID) (____error_code uint32) { + _m, ok_m := lookupTxnSignerMocksHandle(*__m) + if !ok_m { + ____error_code = FC_BAD_HANDLE + return + } + __arg0, ____return_err := _m.GetSignerUID() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = *(*C.core__UID)(unsafe.Pointer(&__arg0)) + } + return +} + +//export FC_mocks_TxnSigner_ReadyForTxn +func FC_mocks_TxnSigner_ReadyForTxn(__m *C.TxnSignerMocks__Handle, __a0 *C.Wallet__Handle, __a1 *C.Transaction__Handle, _arg2 *bool) (____error_code uint32) { + _m, ok_m := lookupTxnSignerMocksHandle(*__m) + if !ok_m { + ____error_code = FC_BAD_HANDLE + return + } + ___a0, ok_a0 := lookupWalletHandle(*__a0) + if !ok_a0 { + ____error_code = FC_BAD_HANDLE + return + } + _a0 := *___a0 + ___a1, ok_a1 := lookupTransactionHandle(*__a1) + if !ok_a1 { + ____error_code = FC_BAD_HANDLE + return + } + _a1 := *___a1 + __arg2, ____return_err := _m.ReadyForTxn(_a0, _a1) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = __arg2 + } + return +} + +//export FC_mocks_TxnSigner_SignTransaction +func FC_mocks_TxnSigner_SignTransaction(__m *C.TxnSignerMocks__Handle, __a0 *C.Transaction__Handle, __a1 *C.PasswordReader, __a2 []string, _arg3 *C.Transaction__Handle) (____error_code uint32) { + _m, ok_m := lookupTxnSignerMocksHandle(*__m) + if !ok_m { + ____error_code = FC_BAD_HANDLE + return + } + ___a0, ok_a0 := lookupTransactionHandle(*__a0) + if !ok_a0 { + ____error_code = FC_BAD_HANDLE + return + } + _a0 := *___a0 + _a1 := func(pString string, pKVS core.KeyValueStore) (string, error) { + var pStringOut C.GoString_ + var pStringIn C.GoString_ + copyString(pString, &pStringIn) + pKVSHandle := registerKeyValueStoreHandle(&pKVS) + result := C.callPasswordReader(__a1, pStringIn, pKVSHandle, &pStringOut) + closeHandle(Handle(pKVSHandle)) + if result == FC_OK { + pStringOut_ := *(*string)(unsafe.Pointer(&pStringOut)) + return pStringOut_, nil + } + return "", errors.New("Error in PasswdReader") + } + _a2 := *(*[]string)(unsafe.Pointer(&__a2)) + __arg3, ____return_err := _m.SignTransaction(_a0, _a1, _a2) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg3 = registerTransactionHandle(&__arg3) + } + return +} diff --git a/lib/cgo/handles b/lib/cgo/handles index a56c687..283ff9e 100644 --- a/lib/cgo/handles +++ b/lib/cgo/handles @@ -71,4 +71,5 @@ CGOGEN HANDLES mocks__TransactionInputIterator|TransactionInputIteratorMocks CGOGEN HANDLES core__TransactionInput|TransactionInput CGOGEN HANDLES mocks__TransactionIterator|TransactionIteratorMocks CGOGEN HANDLES mocks__TransactionOutput|TransactionOutputMocks -CGOGEN HANDLES mocks__TransactionOutputIterator|TransactionOutputIteratorMocks \ No newline at end of file +CGOGEN HANDLES mocks__TransactionOutputIterator|TransactionOutputIteratorMocks +CGOGEN HANDLES mocks__TxnSigner|TxnSignerMocks \ No newline at end of file diff --git a/lib/cgo/libfc_handle.go b/lib/cgo/libfc_handle.go index 00ad4de..856e123 100644 --- a/lib/cgo/libfc_handle.go +++ b/lib/cgo/libfc_handle.go @@ -942,3 +942,17 @@ func lookupTransactionOutputIteratorMocksHandle(handle C.TransactionOutputIterat func registerTransactionOutputIteratorMocksHandle(obj *mocks.TransactionOutputIterator) C.TransactionOutputIteratorMocks__Handle { return (C.TransactionOutputIteratorMocks__Handle)(registerHandle(obj)) } + +func lookupTxnSignerMocksHandle(handle C.TxnSignerMocks__Handle) (*mocks.TxnSigner, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*mocks.TxnSigner); isOK { + return obj, true + } + } + return nil, false +} + +func registerTxnSignerMocksHandle(obj *mocks.TxnSigner) C.TxnSignerMocks__Handle { + return (C.TxnSignerMocks__Handle)(registerHandle(obj)) +}