Change ToPtr() to return `uintptr`.

Avoid returning `unsafe.Pointer`, so that Go modules which use
Clownfish-powered Go modules must import `unsafe` if they are to perform
any unsafe operations.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/128a2eaf
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/128a2eaf
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/128a2eaf

Branch: refs/heads/master
Commit: 128a2eaf75b94374656bab93c139f3ca83981721
Parents: ac2de38
Author: Marvin Humphrey <[email protected]>
Authored: Sat Mar 28 16:22:31 2015 -0700
Committer: Marvin Humphrey <[email protected]>
Committed: Mon Apr 6 09:08:19 2015 -0700

----------------------------------------------------------------------
 runtime/go/clownfish/clownfish.go      | 6 +++---
 runtime/go/clownfish/clownfish_test.go | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/128a2eaf/runtime/go/clownfish/clownfish.go
----------------------------------------------------------------------
diff --git a/runtime/go/clownfish/clownfish.go 
b/runtime/go/clownfish/clownfish.go
index fe68e49..bb3173e 100644
--- a/runtime/go/clownfish/clownfish.go
+++ b/runtime/go/clownfish/clownfish.go
@@ -69,7 +69,7 @@ func init() {
 }
 
 type Obj interface {
-       ToPtr() unsafe.Pointer
+       ToPtr() uintptr
 }
 
 type Err struct {
@@ -119,8 +119,8 @@ func (obj *String) finalize() {
        obj.ref = nil
 }
 
-func (obj *String) ToPtr() unsafe.Pointer {
-       return unsafe.Pointer(obj.ref)
+func (obj *String) ToPtr() uintptr {
+       return uintptr(unsafe.Pointer(obj.ref))
 }
 
 func CFStringToGo(ptr unsafe.Pointer) string {

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/128a2eaf/runtime/go/clownfish/clownfish_test.go
----------------------------------------------------------------------
diff --git a/runtime/go/clownfish/clownfish_test.go 
b/runtime/go/clownfish/clownfish_test.go
index 1709dfc..a89870b 100644
--- a/runtime/go/clownfish/clownfish_test.go
+++ b/runtime/go/clownfish/clownfish_test.go
@@ -18,10 +18,11 @@ package clownfish_test
 
 import 
"git-wip-us.apache.org/repos/asf/lucy-clownfish.git/runtime/go/clownfish"
 import "testing"
+import "unsafe"
 
 func TestStuff(t *testing.T) {
        cfString := clownfish.NewString("foo")
-       goString := clownfish.CFStringToGo(cfString.ToPtr())
+       goString := clownfish.CFStringToGo(unsafe.Pointer(cfString.ToPtr()))
        if goString != "foo" {
                t.Error("Round-tripping strings failed")
        }

Reply via email to