Refine Schema Go binding.

Use autogen binding for `Spec_Field`.  Use custom binding for
`All_Fields` to return Go type `[]string`.


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

Branch: refs/heads/master
Commit: 43addb08773da31bce0871473990e51e46630ad4
Parents: a347c81
Author: Marvin Humphrey <[email protected]>
Authored: Thu Aug 13 10:31:39 2015 -0700
Committer: Marvin Humphrey <[email protected]>
Committed: Mon Oct 5 19:06:48 2015 -0700

----------------------------------------------------------------------
 go/build.go     |  3 +--
 go/lucy/plan.go | 18 ++++++++++++------
 2 files changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/43addb08/go/build.go
----------------------------------------------------------------------
diff --git a/go/build.go b/go/build.go
index e250aeb..395e96d 100644
--- a/go/build.go
+++ b/go/build.go
@@ -144,8 +144,7 @@ func specClasses(parcel *cfc.Parcel) {
        indexerBinding.Register()
 
        schemaBinding := cfc.NewGoClass(parcel, "Lucy::Plan::Schema")
-       schemaBinding.SpecMethod("Spec_Field",
-               "SpecField(field string, fieldType FieldType)")
+       schemaBinding.SpecMethod("All_Fields", "AllFields() []string")
        schemaBinding.Register()
 
        searcherBinding := cfc.NewGoClass(parcel, "Lucy::Search::Searcher")

http://git-wip-us.apache.org/repos/asf/lucy/blob/43addb08/go/lucy/plan.go
----------------------------------------------------------------------
diff --git a/go/lucy/plan.go b/go/lucy/plan.go
index 1ebd0bf..1f030db 100644
--- a/go/lucy/plan.go
+++ b/go/lucy/plan.go
@@ -19,17 +19,23 @@ package lucy
 /*
 #include "Lucy/Plan/Schema.h"
 #include "Lucy/Plan/FullTextType.h"
+#include "Clownfish/Vector.h"
 */
 import "C"
 import "unsafe"
 
 import 
"git-wip-us.apache.org/repos/asf/lucy-clownfish.git/runtime/go/clownfish"
 
-func (obj *SchemaIMP) SpecField(field string, fieldType FieldType) {
-       self := ((*C.lucy_Schema)(unsafe.Pointer(obj.TOPTR())))
-       fieldCF := clownfish.NewString(field)
-       C.LUCY_Schema_Spec_Field(self,
-               (*C.cfish_String)(unsafe.Pointer(fieldCF.TOPTR())),
-               (*C.lucy_FieldType)(unsafe.Pointer(fieldType.TOPTR())))
+func (s *SchemaIMP) AllFields() []string {
+       self := (*C.lucy_Schema)(unsafe.Pointer(s.TOPTR()))
+       fieldsCF := C.LUCY_Schema_All_Fields(self)
+       defer C.cfish_decref(unsafe.Pointer(fieldsCF))
+       numFields := C.CFISH_Vec_Get_Size(fieldsCF)
+       fields := make([]string, int(numFields))
+       for i := C.size_t(0); i < numFields; i++ {
+               fields[i] =
+               
clownfish.CFStringToGo(unsafe.Pointer(C.CFISH_Vec_Fetch(fieldsCF, i)))
+       }
+       return fields
 }
 

Reply via email to