take-cheeze / mruby-marshal

mruby implementation of cruby marshaling.
12 stars 9 forks source link

A break is missing! #2

Closed asfluido closed 9 years ago

asfluido commented 9 years ago

Dear reader:

I found a showstopper in the library. A break is missing around line 242 of marshal.cpp. I had needed to change another couple of things to get the gem to compile. Here below you find the patch. If a so-called pull-request is needed you need to tell me exactly how to proceed...

diff --git a/mrbgem.rake b/mrbgem.rake
index 473bb49..acac331 100644
--- a/mrbgem.rake
+++ b/mrbgem.rake
@@ -3,6 +3,8 @@ MRuby::Gem::Specification.new('mruby-marshal') do |spec|
   spec.author = 'take-cheeze'
   spec.summary = 'Marhshal module for mruby'

+  spec.cxx.flags.push('-fpermissive')
+  
   add_dependency 'mruby-onig-regexp', :github => 'mattn/mruby-onig-regexp'
   add_dependency 'mruby-string-ext', :core => 'mruby-string-ext'
 end
diff --git a/src/marshal.cpp b/src/marshal.cpp
index 3fc47ab..168968e 100644
--- a/src/marshal.cpp
+++ b/src/marshal.cpp
@@ -6,6 +6,7 @@
 #include 
 #include 

+#include 
 #include 
 #include 
 #include 
@@ -137,7 +138,7 @@ struct write_context : public utility {

   bool is_struct(mrb_value const& v) const {
     return mrb_array_p(v) and
-        mrb_const_defined_at(M, mrb_class(M, v), mrb_intern_lit(M, "__members__"));
+      mrb_const_defined_at(M, mrb_obj_value(mrb_class(M, v)), mrb_intern_lit(M, "__members__"));
   }

   write_context& link(int const l) {
@@ -242,7 +243,7 @@ write_context& write_context::marshal(mrb_value const& v) {
         char buf[256];
         sprintf(buf, "%.16g", mrb_float(v));
         tag<'f'>().string(buf);
-      }
+      } break; 

       case MRB_TT_ARRAY: {
         uclass(v, M->array_class).tag<'['>().fixnum(RARRAY_LEN(v));

pbosetti commented 9 years ago

Hi @asfluido, you shall fork the repo on your account, then commit your changes, then click on the green button on the GitHub page, just left to the branch selector pull-down. Cheers, -P.

asfluido commented 9 years ago

Many thanks/mille grazie. I did what you suggested.