Author: logie
Date: Fri Oct 12 04:30:43 2012
New Revision: 1397431

URL: http://svn.apache.org/viewvc?rev=1397431&view=rev
Log:
Updated Hierachy/Core classes to accept named paramaters instead of listed 
parameters

Modified:
    lucy/trunk/clownfish/compiler/ruby/Rakefile
    lucy/trunk/clownfish/compiler/ruby/ext/Clownfish/CFC.c
    lucy/trunk/clownfish/compiler/ruby/ext/example.rb

Modified: lucy/trunk/clownfish/compiler/ruby/Rakefile
URL: 
http://svn.apache.org/viewvc/lucy/trunk/clownfish/compiler/ruby/Rakefile?rev=1397431&r1=1397430&r2=1397431&view=diff
==============================================================================
--- lucy/trunk/clownfish/compiler/ruby/Rakefile (original)
+++ lucy/trunk/clownfish/compiler/ruby/Rakefile Fri Oct 12 04:30:43 2012
@@ -46,10 +46,10 @@ task :clownfish => [:parse_y_files] do
   Rake::Task['cfc_ext'].invoke
 
   require_relative 'ext/Clownfish/CFC'
-  hierarchy = Clownfish::CFC::Model::Hierarchy.new("autogen")
+  hierarchy = Clownfish::CFC::Model::Hierarchy.new(:dest => "autogen")
   hierarchy.build
   
-  core_binding = Clownfish::CFC::Binding::Core.new(hierarchy, autogen_header, 
'')
+  core_binding = Clownfish::CFC::Binding::Core.new(:hierarchy => hierarchy, 
:header => autogen_header, :footer => '')
   core_binding.write_all_modified
 end
 

Modified: lucy/trunk/clownfish/compiler/ruby/ext/Clownfish/CFC.c
URL: 
http://svn.apache.org/viewvc/lucy/trunk/clownfish/compiler/ruby/ext/Clownfish/CFC.c?rev=1397431&r1=1397430&r2=1397431&view=diff
==============================================================================
--- lucy/trunk/clownfish/compiler/ruby/ext/Clownfish/CFC.c (original)
+++ lucy/trunk/clownfish/compiler/ruby/ext/Clownfish/CFC.c Fri Oct 12 04:30:43 
2012
@@ -31,10 +31,15 @@ S_CFC_Binding_Core_Alloc(VALUE klass) {
 }
 
 static VALUE
-S_CFC_Binding_Core_Init(VALUE self_rb, VALUE hierarchy, VALUE header, VALUE 
footer) {
+S_CFC_Binding_Core_Init(VALUE self_rb, VALUE params) {
+
     CFCHierarchy* hierarchy_obj;
     CFCBindCore* self;
 
+    VALUE hierarchy = rb_hash_aref(params, ID2SYM(rb_intern("hierarchy"))); 
+    VALUE header    = rb_hash_aref(params, ID2SYM(rb_intern("header"))); 
+    VALUE footer    = rb_hash_aref(params, ID2SYM(rb_intern("footer"))); 
+
     Data_Get_Struct(hierarchy,CFCHierarchy,hierarchy_obj);
     Data_Get_Struct(self_rb, CFCBindCore, self);
 
@@ -60,7 +65,7 @@ static void
 S_init_Binding_Core(void) {
     cBindCore = rb_define_class_under(mBinding, "Core", rb_cObject);
     rb_define_alloc_func(cBindCore, S_CFC_Binding_Core_Alloc);
-    rb_define_method(cBindCore, "initialize", S_CFC_Binding_Core_Init, 3);
+    rb_define_method(cBindCore, "initialize", S_CFC_Binding_Core_Init, 1);
     rb_define_method(cBindCore, "write_all_modified",
                      S_CFC_Binding_Core_Write_All_Modified, -1);
 }
@@ -72,8 +77,10 @@ S_CFC_Hierarchy_Alloc(VALUE klass) {
 }
 
 static VALUE
-S_CFC_Hierarchy_Init(VALUE self_rb, VALUE dest) {
+S_CFC_Hierarchy_Init(VALUE self_rb, VALUE params) {
     CFCHierarchy* self;
+  
+    VALUE dest = rb_hash_aref(params, ID2SYM(rb_intern("dest"))); 
 
     Data_Get_Struct(self_rb,CFCHierarchy, self);
 

Modified: lucy/trunk/clownfish/compiler/ruby/ext/example.rb
URL: 
http://svn.apache.org/viewvc/lucy/trunk/clownfish/compiler/ruby/ext/example.rb?rev=1397431&r1=1397430&r2=1397431&view=diff
==============================================================================
--- lucy/trunk/clownfish/compiler/ruby/ext/example.rb (original)
+++ lucy/trunk/clownfish/compiler/ruby/ext/example.rb Fri Oct 12 04:30:43 2012
@@ -3,5 +3,8 @@
 # Simple example on how to call CFC in ruby
 require_relative 'Clownfish/CFC'
 
-hierarchy = Clownfish::CFC::Model::Hierarchy.new("autogen")
+hierarchy = Clownfish::CFC::Model::Hierarchy.new(:dest => "autogen")
 hierarchy.build
+
+core_binding = Clownfish::CFC::Binding::Core.new(:hierarchy => hierarchy, 
:header => 'foobar', :footer => '')
+core_binding.write_all_modified


Reply via email to