Add simple Go unwrapping function.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/8172d407 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/8172d407 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/8172d407 Branch: refs/heads/master Commit: 8172d40724759806bba44af34e1fd2883d89e8f8 Parents: 81ce545 Author: Marvin Humphrey <[email protected]> Authored: Wed Aug 12 19:59:47 2015 -0700 Committer: Marvin Humphrey <[email protected]> Committed: Fri Aug 14 15:36:17 2015 -0700 ---------------------------------------------------------------------- runtime/go/clownfish/clownfish.go | 11 +++++++++++ 1 file changed, 11 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/8172d407/runtime/go/clownfish/clownfish.go ---------------------------------------------------------------------- diff --git a/runtime/go/clownfish/clownfish.go b/runtime/go/clownfish/clownfish.go index 14f07ed..bae8b3d 100644 --- a/runtime/go/clownfish/clownfish.go +++ b/runtime/go/clownfish/clownfish.go @@ -354,6 +354,17 @@ func GoToClownfish(value interface{}, class unsafe.Pointer, nullable bool) unsaf panic(NewErr(fmt.Sprintf("Can't convert a %T to %s", value, className))) } +func UnwrapClownfish(value Obj, name string, nullable bool) unsafe.Pointer { + if value == nil { + if nullable { + return nil + } else { + panic(NewErr(fmt.Sprintf("%s cannot be nil", name))) + } + } + return unsafe.Pointer(value.TOPTR()) +} + func GoToString(value interface{}) unsafe.Pointer { switch v := value.(type) { case string:
