Skip to content

Commit

Permalink
[cgo] refs fibercrypto#5 Added coin.mocks.TransactionIterator
Browse files Browse the repository at this point in the history
  • Loading branch information
Maykel Arias Torres committed Mar 24, 2020
1 parent 675efc8 commit 152ba34
Show file tree
Hide file tree
Showing 4 changed files with 68 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 @@ -477,10 +477,16 @@ typedef Handle TransactionInputMocks__Handle;
typedef Handle TransactionInputIteratorMocks__Handle;

/**
* TransactionInput__Handle Handle, struct core.TransactionInput
* TransactionInput__Handle Handle, interface core.TransactionInput
*/
typedef Handle TransactionInput__Handle;

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

// Callbacks

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

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

//export FC_mocks_TransactionIterator_HasNext
func FC_mocks_TransactionIterator_HasNext(__m *C.TransactionIteratorMocks__Handle, _arg0 *bool) (____error_code uint32) {
_m, ok_m := lookupTransactionIteratorMocksHandle(*__m)
if !ok_m {
____error_code = FC_BAD_HANDLE
return
}
__arg0 := _m.HasNext()
*_arg0 = __arg0
return
}

//export FC_mocks_TransactionIterator_Next
func FC_mocks_TransactionIterator_Next(__m *C.TransactionIteratorMocks__Handle, _arg0 *bool) (____error_code uint32) {
_m, ok_m := lookupTransactionIteratorMocksHandle(*__m)
if !ok_m {
____error_code = FC_BAD_HANDLE
return
}
__arg0 := _m.Next()
*_arg0 = __arg0
return
}

//export FC_mocks_TransactionIterator_Value
func FC_mocks_TransactionIterator_Value(__m *C.TransactionIteratorMocks__Handle, _arg0 *C.Transaction__Handle) (____error_code uint32) {
_m, ok_m := lookupTransactionIteratorMocksHandle(*__m)
if !ok_m {
____error_code = FC_BAD_HANDLE
return
}
__arg0 := _m.Value()
*_arg0 = registerTransactionHandle(&__arg0)
return
}
3 changes: 2 additions & 1 deletion lib/cgo/handles
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ CGOGEN HANDLES mocks__StringAddress|StringAddressMocks
CGOGEN HANDLES mocks__Transaction|TransactionMocks
CGOGEN HANDLES mocks__TransactionInput|TransactionInputMocks
CGOGEN HANDLES mocks__TransactionInputIterator|TransactionInputIteratorMocks
CGOGEN HANDLES core__TransactionInput|TransactionInput
CGOGEN HANDLES core__TransactionInput|TransactionInput
CGOGEN HANDLES mocks__TransactionIterator|TransactionIteratorMocks
13 changes: 13 additions & 0 deletions lib/cgo/libfc_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -901,3 +901,16 @@ func lookupTransactionInputHandle(handle C.TransactionInput__Handle) (*core.Tran
func registerTransactionInputHandle(obj *core.TransactionInput) C.TransactionInput__Handle {
return (C.TransactionInput__Handle)(registerHandle(obj))
}
func lookupTransactionIteratorMocksHandle(handle C.TransactionIteratorMocks__Handle) (*mocks.TransactionIterator, bool) {
obj, ok := lookupHandle(C.Handle(handle))
if ok {
if obj, isOK := (obj).(*mocks.TransactionIterator); isOK {
return obj, true
}
}
return nil, false
}

func registerTransactionIteratorMocksHandle(obj *mocks.TransactionIterator) C.TransactionIteratorMocks__Handle {
return (C.TransactionIteratorMocks__Handle)(registerHandle(obj))
}

0 comments on commit 152ba34

Please sign in to comment.