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/03/19 01:22:35 UTC

[8/9] lucy git commit: Go stubs for Schema, FieldType, FullTextType.

Go stubs for Schema, FieldType, FullTextType.


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

Branch: refs/heads/master
Commit: 6e108814ac9f5c26a8cb9c103cb2cfe9dcc8a9c6
Parents: 1981c82
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Sun Nov 16 21:40:34 2014 -0800
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Sun Mar 15 18:48:11 2015 -0700

----------------------------------------------------------------------
 go/lucy/plan.go | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/6e108814/go/lucy/plan.go
----------------------------------------------------------------------
diff --git a/go/lucy/plan.go b/go/lucy/plan.go
new file mode 100644
index 0000000..673f861
--- /dev/null
+++ b/go/lucy/plan.go
@@ -0,0 +1,80 @@
+/* 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/Plan/Schema.h"
+#include "Lucy/Plan/FullTextType.h"
+*/
+import "C"
+import "runtime"
+import "unsafe"
+
+import "git-wip-us.apache.org/repos/asf/lucy-clownfish.git/runtime/go/clownfish"
+
+type Schema struct {
+	ref *C.lucy_Schema
+}
+
+type FieldType interface {
+	clownfish.Obj
+	ToFieldTypePtr() unsafe.Pointer
+}
+
+type FullTextType struct {
+	ref *C.lucy_FullTextType
+}
+
+func NewSchema() *Schema {
+	obj := &Schema{
+		C.lucy_Schema_new(),
+	}
+	runtime.SetFinalizer(obj, (*Schema).finalize)
+	return obj
+}
+
+func (obj *Schema) finalize() {
+	C.cfish_dec_refcount(unsafe.Pointer(obj.ref))
+	obj.ref = nil
+}
+
+func (obj *Schema) SpecField(field string, fieldType FieldType) {
+	fieldCF := clownfish.NewString(field)
+	C.LUCY_Schema_Spec_Field(obj.ref, (*C.cfish_String)(fieldCF.ToPtr()),
+		(*C.lucy_FieldType)(fieldType.ToFieldTypePtr()))
+}
+
+func NewFullTextType(analyzer Analyzer) *FullTextType {
+	obj := &FullTextType{
+		C.lucy_FullTextType_new((*C.lucy_Analyzer)(analyzer.ToAnalyzerPtr())),
+	}
+	runtime.SetFinalizer(obj, (*FullTextType).finalize)
+	return obj
+}
+
+func (obj *FullTextType) finalize() {
+	C.cfish_dec_refcount(unsafe.Pointer(obj.ref))
+	obj.ref = nil
+}
+
+func (obj *FullTextType) ToPtr() unsafe.Pointer {
+	return unsafe.Pointer(obj.ref)
+}
+
+func (obj *FullTextType) ToFieldTypePtr() unsafe.Pointer {
+	return obj.ToPtr()
+}