Skip to content

Commit

Permalink
[cgo] refs skycoin#105 Rewrite functions in params.distribution
Browse files Browse the repository at this point in the history
- Added datatype `Distribution__Handle`
- Added datatype `SKY_params_Distribution_GetMaxCoinSupply`
- Added datatype `SKY_params_Distribution_SetMaxCoinSupply`
- Added datatype `SKY_params_Distribution_GetInitialUnlockedCount`
- Added datatype `SKY_params_Distribution_SetInitialUnlockedCount`
- Added datatype `SKY_params_Distribution_GetUnlockAddressRate`
- Added datatype `SKY_params_Distribution_SetUnlockAddressRate`
- Added datatype `SKY_params_Distribution_GetUnlockTimeInterval`
- Added datatype `SKY_params_Distribution_SetUnlockTimeInterval`
- Added datatype `SKY_params_Distribution_GetAddresses`
- Added datatype `SKY_params_Distribution_SetAddresses`
- Added datatype `SKY_params_Distribution_Validate`
- Added datatype `SKY_params_Distribution_AddressInitialBalance`
- Added datatype `SKY_params_Distribution_UnlockedAddresses`
- Added datatype `SKY_params_Distribution_LockedAddresses`
- Added datatype `SKY_params_Distribution_AddressesDecoded`
- Added datatype `SKY_params_Distribution_UnlockedAddressesDecoded`
- Added datatype `SKY_params_Distribution_LockedAddressesDecoded`
  • Loading branch information
Maykel Arias Torres committed Aug 11, 2019
1 parent f0d8a1e commit 661becd
Show file tree
Hide file tree
Showing 4 changed files with 243 additions and 0 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added function `SKY_wallet_MetaWallet_Version`
- Added function `SKY_wallet_MetaWallet_Type`
- Added datatype `WalletSeedResponse__Handle`
- Added datatype `Distribution__Handle`
- Added datatype `SKY_params_Distribution_GetMaxCoinSupply`
- Added datatype `SKY_params_Distribution_SetMaxCoinSupply`
- Added datatype `SKY_params_Distribution_GetInitialUnlockedCount`
- Added datatype `SKY_params_Distribution_SetInitialUnlockedCount`
- Added datatype `SKY_params_Distribution_GetUnlockAddressRate`
- Added datatype `SKY_params_Distribution_SetUnlockAddressRate`
- Added datatype `SKY_params_Distribution_GetUnlockTimeInterval`
- Added datatype `SKY_params_Distribution_SetUnlockTimeInterval`
- Added datatype `SKY_params_Distribution_GetAddresses`
- Added datatype `SKY_params_Distribution_SetAddresses`
- Added datatype `SKY_params_Distribution_Validate`
- Added datatype `SKY_params_Distribution_AddressInitialBalance`
- Added datatype `SKY_params_Distribution_UnlockedAddresses`
- Added datatype `SKY_params_Distribution_LockedAddresses`
- Added datatype `SKY_params_Distribution_AddressesDecoded`
- Added datatype `SKY_params_Distribution_UnlockedAddressesDecoded`
- Added datatype `SKY_params_Distribution_LockedAddressesDecoded`

### Removed

Expand Down
5 changes: 5 additions & 0 deletions include/skytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ typedef Handle MetaWallet__Handle;
*/
typedef Handle WalletSeedResponse__Handle;

/**
* Distribution__Handle Handle, struct param.distribution
*/
typedef Handle Distribution__Handle;

/**
* Instances of Go interface types.
*/
Expand Down
15 changes: 15 additions & 0 deletions lib/cgo/libsky_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/skycoin/skycoin/src/coin"
"github.com/skycoin/skycoin/src/readable"
"github.com/skycoin/skycoin/src/wallet"
"github.com/skycoin/skycoin/src/params"
)

type Handle uint64
Expand Down Expand Up @@ -532,3 +533,17 @@ func lookupWalletSeedResponseHandle(handle C.WalletSeedResponse__Handle) (*api.W
}
return nil, false
}

func registerDistributionHandle(obj *params.Distribution) C.Distribution__Handle {
return (C.WalletResponse__Handle)(registerHandle(obj))
}

func lookupDistributionHandle(handle C.Distribution__Handle) (*params.Distribution, bool) {
obj, ok := lookupHandle(C.Handle(handle))
if ok {
if obj, isOK := (obj).(*params.Distribution); isOK {
return obj, true
}
}
return nil, false
}
205 changes: 205 additions & 0 deletions lib/cgo/params.distribution.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package main

import (
"reflect"
"unsafe"
)

/*
#include <string.h>
Expand All @@ -8,3 +13,203 @@ package main
#include "skytypes.h"
*/
import "C"

//export SKY_params_Distribution_GetMaxCoinSupply
func SKY_params_Distribution_GetMaxCoinSupply(_d C.Distribution__Handle, _arg0 *uint64) (____error_code uint32) {
d, ok := lookupDistributionHandle(_d)
if !ok {
____error_code = SKY_BAD_HANDLE
return
}
*_arg0 = d.MaxCoinSupply
return
}

//export SKY_params_Distribution_SetMaxCoinSupply
func SKY_params_Distribution_SetMaxCoinSupply(_d C.Distribution__Handle, _arg0 uint64) (____error_code uint32) {
d, ok := lookupDistributionHandle(_d)
if !ok {
____error_code = SKY_BAD_HANDLE
return
}
d.MaxCoinSupply = _arg0
_d = registerDistributionHandle(d)
return
}

//export SKY_params_Distribution_GetInitialUnlockedCount
func SKY_params_Distribution_GetInitialUnlockedCount(_d C.Distribution__Handle, _arg0 *uint64) (____error_code uint32) {
d, ok := lookupDistributionHandle(_d)
if !ok {
____error_code = SKY_BAD_HANDLE
return
}
*_arg0 = d.InitialUnlockedCount
return
}

//export SKY_params_Distribution_SetInitialUnlockedCount
func SKY_params_Distribution_SetInitialUnlockedCount(_d C.Distribution__Handle, _arg0 uint64) (____error_code uint32) {
d, ok := lookupDistributionHandle(_d)
if !ok {
____error_code = SKY_BAD_HANDLE
return
}
d.InitialUnlockedCount = _arg0
_d = registerDistributionHandle(d)
return
}

//export SKY_params_Distribution_GetUnlockAddressRate
func SKY_params_Distribution_GetUnlockAddressRate(_d C.Distribution__Handle, _arg0 *uint64) (____error_code uint32) {
d, ok := lookupDistributionHandle(_d)
if !ok {
____error_code = SKY_BAD_HANDLE
return
}
*_arg0 = d.UnlockAddressRate
return
}

//export SKY_params_Distribution_SetUnlockAddressRate
func SKY_params_Distribution_SetUnlockAddressRate(_d C.Distribution__Handle, _arg0 uint64) (____error_code uint32) {
d, ok := lookupDistributionHandle(_d)
if !ok {
____error_code = SKY_BAD_HANDLE
return
}
d.UnlockAddressRate = _arg0
_d = registerDistributionHandle(d)
return
}

//export SKY_params_Distribution_GetUnlockTimeInterval
func SKY_params_Distribution_GetUnlockTimeInterval(_d C.Distribution__Handle, _arg0 *uint64) (____error_code uint32) {
d, ok := lookupDistributionHandle(_d)
if !ok {
____error_code = SKY_BAD_HANDLE
return
}
*_arg0 = d.UnlockTimeInterval
return
}

//export SKY_params_Distribution_SetUnlockTimeInterval
func SKY_params_Distribution_SetUnlockTimeInterval(_d C.Distribution__Handle, _arg0 uint64) (____error_code uint32) {
d, ok := lookupDistributionHandle(_d)
if !ok {
____error_code = SKY_BAD_HANDLE
return
}
d.UnlockTimeInterval = _arg0
_d = registerDistributionHandle(d)
return
}

//export SKY_params_Distribution_GetAddresses
func SKY_params_Distribution_GetAddresses(_d C.Distribution__Handle, _arg0 *C.GoSlice_) (____error_code uint32) {
d, ok := lookupDistributionHandle(_d)
if !ok {
____error_code = SKY_BAD_HANDLE
return
}
copyToGoSlice(reflect.ValueOf(d.Addresses), _arg0)
return
}

//export SKY_params_Distribution_SetAddresses
func SKY_params_Distribution_SetAddresses(_d C.Distribution__Handle, _arg0 *C.GoSlice_) (____error_code uint32) {
d, ok := lookupDistributionHandle(_d)
if !ok {
____error_code = SKY_BAD_HANDLE
return
}
d.Addresses = *(*[]string)(unsafe.Pointer(_arg0))
_d = registerDistributionHandle(d)
return
}

//export SKY_params_Distribution_Validate
func SKY_params_Distribution_Validate(_d C.Distribution__Handle) (____error_code uint32) {

d, ok := lookupDistributionHandle(_d)
if !ok {
____error_code = SKY_BAD_HANDLE
return
}
__return_err := d.Validate()
____error_code = libErrorCode(__return_err)
return

}

//export SKY_params_Distribution_AddressInitialBalance
func SKY_params_Distribution_AddressInitialBalance(_d C.Distribution__Handle, _arg0 *uint64) (____error_code uint32) {
d, ok := lookupDistributionHandle(_d)
if !ok {
____error_code = SKY_BAD_HANDLE
return
}
*_arg0 = d.AddressInitialBalance()
return
}

//export SKY_params_Distribution_UnlockedAddresses
func SKY_params_Distribution_UnlockedAddresses(_d C.Distribution__Handle, _arg0 *C.GoSlice_) (____error_code uint32) {
d, ok := lookupDistributionHandle(_d)
if !ok {
____error_code = SKY_BAD_HANDLE
return
}
arg0 := d.UnlockedAddresses()
copyToGoSlice(reflect.ValueOf(arg0), _arg0)
return
}

//export SKY_params_Distribution_LockedAddresses
func SKY_params_Distribution_LockedAddresses(_d C.Distribution__Handle, _arg0 *C.GoSlice_) (____error_code uint32) {
d, ok := lookupDistributionHandle(_d)
if !ok {
____error_code = SKY_BAD_HANDLE
return
}
arg0 := d.LockedAddresses()
copyToGoSlice(reflect.ValueOf(arg0), _arg0)
return
}

//export SKY_params_Distribution_AddressesDecoded
func SKY_params_Distribution_AddressesDecoded(_d C.Distribution__Handle, _arg0 *C.GoSlice_) (____error_code uint32) {
d, ok := lookupDistributionHandle(_d)
if !ok {
____error_code = SKY_BAD_HANDLE
return
}
arg0 := d.AddressesDecoded()
copyToGoSlice(reflect.ValueOf(arg0), _arg0)
return
}

//export SKY_params_Distribution_UnlockedAddressesDecoded
func SKY_params_Distribution_UnlockedAddressesDecoded(_d C.Distribution__Handle, _arg0 *C.GoSlice_) (____error_code uint32) {
d, ok := lookupDistributionHandle(_d)
if !ok {
____error_code = SKY_BAD_HANDLE
return
}
arg0 := d.UnlockedAddressesDecoded()
copyToGoSlice(reflect.ValueOf(arg0), _arg0)
return
}

//export SKY_params_Distribution_LockedAddressesDecoded
func SKY_params_Distribution_LockedAddressesDecoded(_d C.Distribution__Handle, _arg0 *C.GoSlice_) (____error_code uint32) {
d, ok := lookupDistributionHandle(_d)
if !ok {
____error_code = SKY_BAD_HANDLE
return
}
arg0 := d.LockedAddressesDecoded()
copyToGoSlice(reflect.ValueOf(arg0), _arg0)
return
}

0 comments on commit 661becd

Please sign in to comment.