Skip to content

Commit

Permalink
[cgo] refs fibercrypto#5 Added coin.mocks.WalletEnv
Browse files Browse the repository at this point in the history
  • Loading branch information
Maykel Arias Torres committed Mar 24, 2020
1 parent 3e60cb6 commit dbef753
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
6 changes: 6 additions & 0 deletions include/fctypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,12 @@ typedef Handle AddressIterator__Handle;
*/
typedef Handle WalletAddressMocks__Handle;

/**
* WalletEnvMocks__Handle Handle, struct
* mocks.WalletEnv
*/
typedef Handle WalletEnvMocks__Handle;

// Callbacks

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

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

//export FC_mocks_WalletEnv_GetStorage
func FC_mocks_WalletEnv_GetStorage(__m *C.WalletEnvMocks__Handle, _arg0 *C.WalletStorage__Handle) (____error_code uint32) {
_m, ok_m := lookupWalletEnvMocksHandle(*__m)
if !ok_m {
____error_code = FC_BAD_HANDLE
return
}
__arg0 := _m.GetStorage()
*_arg0 = registerWalletStorageHandle(&__arg0)
return
}

//export FC_mocks_WalletEnv_GetWalletSet
func FC_mocks_WalletEnv_GetWalletSet(__m *C.WalletEnvMocks__Handle, _arg0 *C.WalletSet__Handle) (____error_code uint32) {
_m, ok_m := lookupWalletEnvMocksHandle(*__m)
if !ok_m {
____error_code = FC_BAD_HANDLE
return
}
__arg0 := _m.GetWalletSet()
*_arg0 = registerWalletSetHandle(&__arg0)
return
}

//export FC_mocks_WalletEnv_LookupWallet
func FC_mocks_WalletEnv_LookupWallet(__m *C.WalletEnvMocks__Handle, _firstAddr string, _arg1 *C.Wallet__Handle) (____error_code uint32) {
_m, ok_m := lookupWalletEnvMocksHandle(*__m)
if !ok_m {
____error_code = FC_BAD_HANDLE
return
}
firstAddr := _firstAddr
__arg1, ____return_err := _m.LookupWallet(firstAddr)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
*_arg1 = registerWalletHandle(&__arg1)
}
return
}
3 changes: 2 additions & 1 deletion lib/cgo/handles
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ CGOGEN HANDLES mocks__TransactionOutputIterator|TransactionOutputIteratorMocks
CGOGEN HANDLES mocks__TxnSigner|TxnSignerMocks
CGOGEN HANDLES mocks__TxnSignerIterator|TxnSignerIteratorMocks
CGOGEN HANDLES mocks__Wallet|WalletMocks
CGOGEN HANDLES mocks__WalletAddress|WalletAddressMocks
CGOGEN HANDLES mocks__WalletAddress|WalletAddressMocks
CGOGEN HANDLES mocks__WalletEnv|WalletEnvMocks
14 changes: 14 additions & 0 deletions lib/cgo/libfc_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -1012,3 +1012,17 @@ func lookupWalletAddressMocksHandle(handle C.WalletAddressMocks__Handle) (*mocks
func registerWalletAddressMocksHandle(obj *mocks.WalletAddress) C.WalletAddressMocks__Handle {
return (C.WalletAddressMocks__Handle)(registerHandle(obj))
}

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

func registerWalletEnvMocksHandle(obj *mocks.WalletEnv) C.WalletEnvMocks__Handle {
return (C.WalletEnvMocks__Handle)(registerHandle(obj))
}

0 comments on commit dbef753

Please sign in to comment.