lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [08/16] lucy git commit: Custom Go binding for `BitVec_To_Array`.
Date Fri, 11 Sep 2015 22:00:33 GMT
Custom Go binding for `BitVec_To_Array`.

Return a slice of bool.


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

Branch: refs/heads/master
Commit: 0c44c9f505cd500d3f784b28c6c346a5f9c1396e
Parents: c0bdb9c
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Wed Aug 12 14:22:08 2015 -0700
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Wed Sep 9 18:25:23 2015 -0700

----------------------------------------------------------------------
 go/build.go       |  4 ++++
 go/lucy/object.go | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/0c44c9f5/go/build.go
----------------------------------------------------------------------
diff --git a/go/build.go b/go/build.go
index 67672eb..828a79b 100644
--- a/go/build.go
+++ b/go/build.go
@@ -167,6 +167,10 @@ func specClasses(parcel *cfc.Parcel) {
 	orQueryBinding := cfc.NewGoClass(parcel, "Lucy::Search::ORQuery")
 	orQueryBinding.SetSuppressCtor(true)
 	orQueryBinding.Register()
+
+	bitVecBinding := cfc.NewGoClass(parcel, "Lucy::Object::BitVector")
+	bitVecBinding.SpecMethod("To_Array", "ToArray() []bool")
+	bitVecBinding.Register()
 }
 
 func build() {

http://git-wip-us.apache.org/repos/asf/lucy/blob/0c44c9f5/go/lucy/object.go
----------------------------------------------------------------------
diff --git a/go/lucy/object.go b/go/lucy/object.go
new file mode 100644
index 0000000..0dc669f
--- /dev/null
+++ b/go/lucy/object.go
@@ -0,0 +1,38 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package lucy
+
+/*
+#include "Lucy/Object/BitVector.h"
+*/
+import "C"
+import "fmt"
+
+import _ "git-wip-us.apache.org/repos/asf/lucy-clownfish.git/runtime/go/clownfish"
+
+func (bv *BitVectorIMP) ToArray() []bool {
+	cap := bv.GetCapacity()
+	if cap != uint32(int(cap)) {
+		panic(fmt.Sprintf("Capacity of range: %d", cap))
+	}
+	bools := make([]bool, int(cap))
+	for i := uint32(0); i < cap; i++ {
+		bools[i] = bv.Get(i)
+	}
+	return bools
+}
+


Mime
View raw message