You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2015/08/17 22:26:00 UTC
[2/6] lucy-clownfish git commit: Add simple Go unwrapping function.
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 <ma...@rectangular.com>
Authored: Wed Aug 12 19:59:47 2015 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
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: