Skip to content

Commit

Permalink
support newer versions of ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfitz committed Jan 7, 2018
1 parent 0e20d2c commit 9723ac8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions genrb.ml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ let s_path ctx stat path p =
match path with
| ([],name) ->
(match name with
| "Int" -> "Fixnum"
| "Int" -> "Integer"
| "Float" -> "Float"
| "Dynamic" -> "Object"
| "Bool" -> "TrueClass"
Expand Down Expand Up @@ -1622,14 +1622,14 @@ let generate_main ctx inits reqs com =
spr ctx " end\n";
spr ctx " old_get = instance_method(:[]) rescue nil\n";
spr ctx " define_method(:[]) do |x|\n";
spr ctx " return old_get.bind(self).(x) if x.is_a?(Fixnum)\n";
spr ctx " return old_get.bind(self).(x) if x.is_a?(0.class)\n";
spr ctx " tag = _haxe_vars_[x]\n";
spr ctx " return instance_variable_get(tag) if tag\n";
spr ctx " method x\n";
spr ctx " end\n";
spr ctx " old_set = instance_method(:[]=) rescue nil\n";
spr ctx " define_method(:[]=) do |x,y|\n";
spr ctx " return old_set.bind(self).(x,y) if x.is_a?(Fixnum)\n";
spr ctx " return old_set.bind(self).(x,y) if x.is_a?(0.class)\n";
spr ctx " instance_variable_set(_haxe_vars_[x],y)\n";
spr ctx " end\n";
spr ctx " define_method(:haxe_name) do\n";
Expand Down
4 changes: 2 additions & 2 deletions std/rb/Boot.hx
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ end
// avoid switch statement for now, translation is
// wrong when comparing types at the moment
if (cl == Int) {
return (untyped __rb__("o.is_a? Fixnum"));
return (untyped __rb__("o.is_a? 0.class"));
} else if (cl == Float) {
return (untyped __dotcall__(o,"is_a?(Float)")||
untyped __dotcall__(o,"is_a?(Fixnum)"));
untyped __dotcall__(o,"is_a?(0.class)"));
} else if (cl == Bool) {
return (untyped __rb__("((o.is_a? TrueClass)||(o.is_a? FalseClass))"));
} else if (cl == String) {
Expand Down
3 changes: 2 additions & 1 deletion std/rb/_std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ enum ValueType {
} else {
name = untyped __dotcall__(c,"name");
}
if (name=="Fixnum") name = "Int";
if (name=="Integer" || name=="Fixnum") name = "Int";
if (name=="Haxe::Ds::StringMap") name = "haxe.ds.StringMap";
return name;
}
Expand Down Expand Up @@ -167,6 +167,7 @@ enum ValueType {
case "TrueClass": return TBool;
case "FalseClass": return TBool;
case "String": return TClass(String);
case "Integer": return TInt;
case "Fixnum": return TInt;
case "Float": return TFloat;
case "Proc": return TFunction;
Expand Down

0 comments on commit 9723ac8

Please sign in to comment.