From 8a62c140c643cbb661a90eb27149dd9ff7f54c05 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Mon, 23 Mar 2020 21:55:31 -0400 Subject: [PATCH] [cgo] refs #5 Added `coin.mocks.Transaction` --- include/core.coin.go.h | 3 +- include/fctypes.h | 5 + lib/cgo/coin.mocks.Transaction.go | 146 ++++++++++++++++++++++++++++++ lib/cgo/handles | 3 +- lib/cgo/libfc_handle.go | 13 +++ 5 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 lib/cgo/coin.mocks.Transaction.go diff --git a/include/core.coin.go.h b/include/core.coin.go.h index 83cfb81..83f82f0 100644 --- a/include/core.coin.go.h +++ b/include/core.coin.go.h @@ -1 +1,2 @@ -typedef GoUint64_ core__Timestamp; \ No newline at end of file +typedef GoUint64_ core__Timestamp; +typedef GoUint32_ core__TransactionStatus; \ No newline at end of file diff --git a/include/fctypes.h b/include/fctypes.h index e545f1d..892dcc5 100644 --- a/include/fctypes.h +++ b/include/fctypes.h @@ -460,6 +460,11 @@ typedef Handle SeedGeneratorMocks__Handle; */ typedef Handle StringAddressMocks__Handle; +/** + * TransactionMocks__Handle Handle, struct mocks.Transaction + */ +typedef Handle TransactionMocks__Handle; + // Callbacks /** diff --git a/lib/cgo/coin.mocks.Transaction.go b/lib/cgo/coin.mocks.Transaction.go new file mode 100644 index 0000000..3a4c2f1 --- /dev/null +++ b/lib/cgo/coin.mocks.Transaction.go @@ -0,0 +1,146 @@ +package main + +import ( + "reflect" + "unsafe" +) + +/* + + #include + #include + + #include "fctypes.h" +*/ +import "C" + +//export FC_mocks_Transaction_ComputeFee +func FC_mocks_Transaction_ComputeFee(__m *C.TransactionMocks__Handle, _ticker string, _arg1 *uint64) (____error_code uint32) { + _m, ok_m := lookupTransactionMocksHandle(*__m) + if !ok_m { + ____error_code = FC_BAD_HANDLE + return + } + ticker := _ticker + __arg1, ____return_err := _m.ComputeFee(ticker) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = __arg1 + } + return +} + +//export FC_mocks_Transaction_GetId +func FC_mocks_Transaction_GetId(__m *C.TransactionMocks__Handle, _arg0 *C.GoString_) (____error_code uint32) { + _m, ok_m := lookupTransactionMocksHandle(*__m) + if !ok_m { + ____error_code = FC_BAD_HANDLE + return + } + __arg0 := _m.GetId() + copyString(__arg0, _arg0) + return +} + +//export FC_mocks_Transaction_GetInputs +func FC_mocks_Transaction_GetInputs(__m *C.TransactionMocks__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { + _m, ok_m := lookupTransactionMocksHandle(*__m) + if !ok_m { + ____error_code = FC_BAD_HANDLE + return + } + __arg0 := _m.GetInputs() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} + +//export FC_mocks_Transaction_GetOutputs +func FC_mocks_Transaction_GetOutputs(__m *C.TransactionMocks__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { + _m, ok_m := lookupTransactionMocksHandle(*__m) + if !ok_m { + ____error_code = FC_BAD_HANDLE + return + } + __arg0 := _m.GetOutputs() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} + +//export FC_mocks_Transaction_GetStatus +func FC_mocks_Transaction_GetStatus(__m *C.TransactionMocks__Handle, _arg0 *C.core__TransactionStatus) (____error_code uint32) { + _m, ok_m := lookupTransactionMocksHandle(*__m) + if !ok_m { + ____error_code = FC_BAD_HANDLE + return + } + __arg0 := _m.GetStatus() + *_arg0 = *(*C.core__TransactionStatus)(unsafe.Pointer(&__arg0)) + return +} + +//export FC_mocks_Transaction_GetTimestamp +func FC_mocks_Transaction_GetTimestamp(__m *C.TransactionMocks__Handle, _arg0 *C.core__Timestamp) (____error_code uint32) { + _m, ok_m := lookupTransactionMocksHandle(*__m) + if !ok_m { + ____error_code = FC_BAD_HANDLE + return + } + __arg0 := _m.GetTimestamp() + *_arg0 = *(*C.core__Timestamp)(unsafe.Pointer(&__arg0)) + return +} + +//export FC_mocks_Transaction_IsFullySigned +func FC_mocks_Transaction_IsFullySigned(__m *C.TransactionMocks__Handle, _arg0 *bool) (____error_code uint32) { + _m, ok_m := lookupTransactionMocksHandle(*__m) + if !ok_m { + ____error_code = FC_BAD_HANDLE + return + } + __arg0, ____return_err := _m.IsFullySigned() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = __arg0 + } + return +} + +//export FC_mocks_Transaction_SupportedAssets +func FC_mocks_Transaction_SupportedAssets(__m *C.TransactionMocks__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { + _m, ok_m := lookupTransactionMocksHandle(*__m) + if !ok_m { + ____error_code = FC_BAD_HANDLE + return + } + __arg0 := _m.SupportedAssets() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} + +//export FC_mocks_Transaction_VerifySigned +func FC_mocks_Transaction_VerifySigned(__m *C.TransactionMocks__Handle) (____error_code uint32) { + _m, ok_m := lookupTransactionMocksHandle(*__m) + if !ok_m { + ____error_code = FC_BAD_HANDLE + return + } + ____return_err := _m.VerifySigned() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export FC_mocks_Transaction_VerifyUnsigned +func FC_mocks_Transaction_VerifyUnsigned(__m *C.TransactionMocks__Handle) (____error_code uint32) { + _m, ok_m := lookupTransactionMocksHandle(*__m) + if !ok_m { + ____error_code = FC_BAD_HANDLE + return + } + ____return_err := _m.VerifyUnsigned() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} diff --git a/lib/cgo/handles b/lib/cgo/handles index 72c5695..300bb18 100644 --- a/lib/cgo/handles +++ b/lib/cgo/handles @@ -64,4 +64,5 @@ CGOGEN HANDLES mocks__PexNodeSet|PexNodeSetMocks CGOGEN HANDLES mocks__PubKey|PubKeyMocks CGOGEN HANDLES mocks__SecKey|SecKeyMocks CGOGEN HANDLES mocks__SeedGenerator|SeedGeneratorMocks -CGOGEN HANDLES mocks__StringAddress|StringAddressMocks \ No newline at end of file +CGOGEN HANDLES mocks__StringAddress|StringAddressMocks +CGOGEN HANDLES mocks__Transaction|TransactionMocks \ No newline at end of file diff --git a/lib/cgo/libfc_handle.go b/lib/cgo/libfc_handle.go index 03ef705..1b5720a 100644 --- a/lib/cgo/libfc_handle.go +++ b/lib/cgo/libfc_handle.go @@ -848,3 +848,16 @@ func lookupStringAddressMocksHandle(handle C.StringAddressMocks__Handle) (*mocks func registerStringAddressMocksHandle(obj *mocks.StringAddress) C.StringAddressMocks__Handle { return (C.StringAddressMocks__Handle)(registerHandle(obj)) } +func lookupTransactionMocksHandle(handle C.TransactionMocks__Handle) (*mocks.Transaction, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*mocks.Transaction); isOK { + return obj, true + } + } + return nil, false +} + +func registerTransactionMocksHandle(obj *mocks.Transaction) C.TransactionMocks__Handle { + return (C.TransactionMocks__Handle)(registerHandle(obj)) +}