Skip to content

Commit

Permalink
[lib] refs #992 - Load cli config handle.
Browse files Browse the repository at this point in the history
[====] Synthesis: Tested: 49 | Passing: 49 | Failing: 0 | Crashing: 0
  • Loading branch information
olemis committed May 6, 2018
1 parent 92ed314 commit 34c8e1d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
7 changes: 6 additions & 1 deletion include/skytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,16 @@ typedef GoInt64_ Handle;
typedef Handle PasswordReader__Handle;

/**
* Memory handle granting clients with access to perform Skycoin RPC API calls
* Memory handle to perform Skycoin RPC API calls
* encrypted wallets.
*/
typedef Handle WebRpcClient__Handle;

/**
* Memory handle to access to Skycoin CLI configuration
*/
typedef Handle Config__Handle;

#include "cipher.hash.go.h"
#include "cipher.crypto.go.h"
#include "cipher.address.go.h"
Expand Down
26 changes: 18 additions & 8 deletions lib/cgo/api.cli.cli.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package main

import (
cli "github.com/skycoin/skycoin/src/api/cli"
)

/*
#include <string.h>
Expand All @@ -9,12 +13,18 @@ package main
*/
import "C"

import (
cli "github.com/skycoin/skycoin/src/api/cli"
)

//export SKY_cli_NewPasswordReader
func SKY_cli_NewPasswordReader(_p []byte) C.PasswordReader__Handle {
pr := cli.NewPasswordReader(_p)
return registerPasswordReaderHandle(pr)
//export SKY_cli_LoadConfig
func SKY_cli_LoadConfig(_arg0 *C.Config__Handle) (____error_code uint32) {
____error_code = 0
defer func() {
____error_code = catchApiPanic(____error_code, recover())
}()
__arg0, ____return_err := cli.LoadConfig()
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
*_arg0 = registerConfigHandle(&__arg0)
}
return
}

// TODO: RpcClientFromConfig
14 changes: 14 additions & 0 deletions lib/cgo/libsky_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ func lookupWebRpcClientHandle(handle C.WebRpcClient__Handle) (*webrpc.Client, bo
return nil, false
}

func registerConfigHandle(obj *cli.Config) C.Config__Handle {
return (C.Config__Handle)(registerHandle(obj))
}

func lookupConfigHandle(handle C.Config__Handle) (*cli.Config, bool) {
obj, ok := lookupHandleObj(Handle(handle))
if ok {
if obj, isOK := (obj).(*cli.Config); isOK {
return obj, true
}
}
return nil, false
}

func registerPasswordReaderHandle(obj cli.PasswordReader) C.PasswordReader__Handle {
return (C.PasswordReader__Handle)(registerHandle(obj))
}
Expand Down

0 comments on commit 34c8e1d

Please sign in to comment.