Author: logie
Date: Thu Jan  5 07:32:52 2012
New Revision: 1227510

URL: http://svn.apache.org/viewvc?rev=1227510&view=rev
Log:
First iteration of building binding CFC::Hierarchy to ruby.
This work is associated with JIRA: 202.

Added:
    incubator/lucy/trunk/clownfish/ruby/ext/Clownfish/CFC/
    incubator/lucy/trunk/clownfish/ruby/ext/Clownfish/CFC/Hierarchy.c
    incubator/lucy/trunk/clownfish/ruby/ext/Clownfish/CFC/extconf.rb
Removed:
    incubator/lucy/trunk/clownfish/ruby/ext/Clownfish/extconf.rb
Modified:
    incubator/lucy/trunk/clownfish/ruby/Rakefile
    incubator/lucy/trunk/clownfish/ruby/ext/Clownfish/CFC.c

Modified: incubator/lucy/trunk/clownfish/ruby/Rakefile
URL: 
http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/ruby/Rakefile?rev=1227510&r1=1227509&r2=1227510&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/ruby/Rakefile (original)
+++ incubator/lucy/trunk/clownfish/ruby/Rakefile Thu Jan  5 07:32:52 2012
@@ -43,7 +43,7 @@ end
 
 desc "Build CFC Ext"
 task :cfc_ext => [:clownfish] do
-    Dir.chdir(RUBY_EXT_CFC) do
+    Dir.chdir(RUBY_EXT_CFC + "/CFC") do
         ruby 'extconf.rb'
         if system('make').nil?
             abort "Failed to make cfc ruby extension"
@@ -145,4 +145,6 @@ CLEAN.include(CLOWNFISH_SRC_DIR + '/CFCP
 CLEAN.include(CLOWNFISH_SRC_DIR + '/CFCParseHeader.h')
 CLEAN.include(RUBY_EXT_CFC + '/CFC.o')
 CLEAN.include(RUBY_EXT_CFC + '/CFC.bundle')
+CLEAN.include(RUBY_EXT_CFC + '/CFC/Hierarchy/Hierarchy.bundle')
+CLEAN.include(RUBY_EXT_CFC + '/CFC/Hierarchy/Hierarchy.o')
 

Modified: incubator/lucy/trunk/clownfish/ruby/ext/Clownfish/CFC.c
URL: 
http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/ruby/ext/Clownfish/CFC.c?rev=1227510&r1=1227509&r2=1227510&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/ruby/ext/Clownfish/CFC.c (original)
+++ incubator/lucy/trunk/clownfish/ruby/ext/Clownfish/CFC.c Thu Jan  5 07:32:52 
2012
@@ -1,15 +1,19 @@
+/* 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.
+ */
+
 #include "ruby.h"
 #include "CFC.h"
 
-VALUE cCFC;
-
-static VALUE t_init(VALUE self)
-{
-    
-}
-
-void Init_CFC() { 
-    cCFC = rb_define_class("CFC", rb_cObject);
-    rb_define_method(cCFC, "initialize", t_init, 0);
-}
-

Added: incubator/lucy/trunk/clownfish/ruby/ext/Clownfish/CFC/Hierarchy.c
URL: 
http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/ruby/ext/Clownfish/CFC/Hierarchy.c?rev=1227510&view=auto
==============================================================================
--- incubator/lucy/trunk/clownfish/ruby/ext/Clownfish/CFC/Hierarchy.c (added)
+++ incubator/lucy/trunk/clownfish/ruby/ext/Clownfish/CFC/Hierarchy.c Thu Jan  
5 07:32:52 2012
@@ -0,0 +1,58 @@
+/* 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.
+ */
+
+#include "ruby.h"
+#include "CFC.h"
+
+VALUE rb_cCFC_H;
+VALUE rb_mCFC;
+
+static VALUE ch_alloc(VALUE klass) {
+    CFCHierarchy *rb_oCFC_H = CFCHierarchy_allocate();
+    VALUE obj = Data_Wrap_Struct(klass, 0, CFCHierarchy_destroy, rb_oCFC_H);
+
+    return obj;
+}
+
+static VALUE t_init(VALUE self, VALUE source, VALUE dest) {
+    char *s = StringValuePtr(source);
+    char *d = StringValuePtr(dest);
+    CFCHierarchy *rb_oCFC_H; 
+
+    Data_Get_Struct(self, CFCHierarchy, rb_oCFC_H);
+    CFCHierarchy_init(rb_oCFC_H, s, d);
+
+    return self;
+}
+
+static VALUE build(VALUE self) {
+    CFCHierarchy *rb_oCFC_H; 
+
+    Data_Get_Struct(self, CFCHierarchy, rb_oCFC_H);
+    CFCHierarchy_build(rb_oCFC_H);
+
+    return self;
+}
+
+void Init_Hierarchy() { 
+    rb_mCFC     = rb_define_module("CFC");
+    rb_cCFC_H   = rb_define_class_under(rb_mCFC, "Hierarchy", rb_cObject);
+
+    rb_define_alloc_func(rb_cCFC_H, ch_alloc);
+    rb_define_method(rb_cCFC_H, "initialize", t_init, 2);
+    rb_define_method(rb_cCFC_H, "build", build, 0);
+}
+

Added: incubator/lucy/trunk/clownfish/ruby/ext/Clownfish/CFC/extconf.rb
URL: 
http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/ruby/ext/Clownfish/CFC/extconf.rb?rev=1227510&view=auto
==============================================================================
--- incubator/lucy/trunk/clownfish/ruby/ext/Clownfish/CFC/extconf.rb (added)
+++ incubator/lucy/trunk/clownfish/ruby/ext/Clownfish/CFC/extconf.rb Thu Jan  5 
07:32:52 2012
@@ -0,0 +1,9 @@
+require 'mkmf'
+CLOWNFISH_INCLUDE_DIR   = File.join('..','..','..','..','include')
+CLOWNFISH_SRC_DIR       = File.join('..','..','..','..','src')
+$CFLAGS = "-I#{CLOWNFISH_INCLUDE_DIR} -I#{CLOWNFISH_SRC_DIR}"
+$objs = ['Hierarchy.o']
+Dir.glob("#{CLOWNFISH_SRC_DIR}/*.o").each do|o|
+    $objs.push o
+end
+create_makefile 'Hierarchy'


Reply via email to