Skip to content

Commit

Permalink
[cgo] refs fibercrypto#5 Added coin.mocks.TransactionOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
Maykel Arias Torres committed Mar 24, 2020
1 parent 152ba34 commit 78ccfa0
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 2 deletions.
8 changes: 7 additions & 1 deletion include/fctypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,16 @@ typedef Handle TransactionInput__Handle;

/**
* TransactionIteratorMocks__Handle Handle, struct
* mocks.TransactionIteratorMocks
* mocks.TransactionIterator
*/
typedef Handle TransactionIteratorMocks__Handle;

/**
* TransactionOutputMocks__Handle Handle, struct
* mocks.TransactionOutput
*/
typedef Handle TransactionOutputMocks__Handle;

// Callbacks

/**
Expand Down
79 changes: 79 additions & 0 deletions lib/cgo/coin.mocks.TransactionOutput.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package main

import "reflect"

/*
#include <string.h>
#include <stdlib.h>
#include "fctypes.h"
*/
import "C"

//export FC_mocks_TransactionOutput_GetAddress
func FC_mocks_TransactionOutput_GetAddress(__m *C.TransactionOutputMocks__Handle, _arg0 *C.Address__Handle) (____error_code uint32) {
_m, ok_m := lookupTransactionOutputMocksHandle(*__m)
if !ok_m {
____error_code = FC_BAD_HANDLE
return
}
__arg0, ____return_err := _m.GetAddress()
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
*_arg0 = registerAddressHandle(&__arg0)
}
return
}

//export FC_mocks_TransactionOutput_GetCoins
func FC_mocks_TransactionOutput_GetCoins(__m *C.TransactionOutputMocks__Handle, _ticker string, _arg1 *uint64) (____error_code uint32) {
_m, ok_m := lookupTransactionOutputMocksHandle(*__m)
if !ok_m {
____error_code = FC_BAD_HANDLE
return
}
ticker := _ticker
__arg1, ____return_err := _m.GetCoins(ticker)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
*_arg1 = __arg1
}
return
}

//export FC_mocks_TransactionOutput_GetId
func FC_mocks_TransactionOutput_GetId(__m *C.TransactionOutputMocks__Handle, _arg0 *C.GoString_) (____error_code uint32) {
_m, ok_m := lookupTransactionOutputMocksHandle(*__m)
if !ok_m {
____error_code = FC_BAD_HANDLE
return
}
__arg0 := _m.GetId()
copyString(__arg0, _arg0)
return
}

//export FC_mocks_TransactionOutput_IsSpent
func FC_mocks_TransactionOutput_IsSpent(__m *C.TransactionOutputMocks__Handle, _arg0 *bool) (____error_code uint32) {
_m, ok_m := lookupTransactionOutputMocksHandle(*__m)
if !ok_m {
____error_code = FC_BAD_HANDLE
return
}
__arg0 := _m.IsSpent()
*_arg0 = __arg0
return
}

//export FC_mocks_TransactionOutput_SupportedAssets
func FC_mocks_TransactionOutput_SupportedAssets(__m *C.TransactionOutputMocks__Handle, _arg0 *C.GoSlice_) (____error_code uint32) {
_m, ok_m := lookupTransactionOutputMocksHandle(*__m)
if !ok_m {
____error_code = FC_BAD_HANDLE
return
}
__arg0 := _m.SupportedAssets()
copyToGoSlice(reflect.ValueOf(__arg0), _arg0)
return
}
3 changes: 2 additions & 1 deletion lib/cgo/handles
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,5 @@ CGOGEN HANDLES mocks__Transaction|TransactionMocks
CGOGEN HANDLES mocks__TransactionInput|TransactionInputMocks
CGOGEN HANDLES mocks__TransactionInputIterator|TransactionInputIteratorMocks
CGOGEN HANDLES core__TransactionInput|TransactionInput
CGOGEN HANDLES mocks__TransactionIterator|TransactionIteratorMocks
CGOGEN HANDLES mocks__TransactionIterator|TransactionIteratorMocks
CGOGEN HANDLES mocks__TransactionOutput|TransactionOutputMocks
14 changes: 14 additions & 0 deletions lib/cgo/libfc_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -914,3 +914,17 @@ func lookupTransactionIteratorMocksHandle(handle C.TransactionIteratorMocks__Han
func registerTransactionIteratorMocksHandle(obj *mocks.TransactionIterator) C.TransactionIteratorMocks__Handle {
return (C.TransactionIteratorMocks__Handle)(registerHandle(obj))
}

func lookupTransactionOutputMocksHandle(handle C.TransactionOutputMocks__Handle) (*mocks.TransactionOutput, bool) {
obj, ok := lookupHandle(C.Handle(handle))
if ok {
if obj, isOK := (obj).(*mocks.TransactionOutput); isOK {
return obj, true
}
}
return nil, false
}

func registerTransactionOutputMocksHandle(obj *mocks.TransactionOutput) C.TransactionOutputMocks__Handle {
return (C.TransactionOutputMocks__Handle)(registerHandle(obj))
}

0 comments on commit 78ccfa0

Please sign in to comment.