Skip to content

Commit

Permalink
another bunch of various fixes found during testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed May 7, 2013
1 parent b2cca52 commit cfc6eea
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
2 changes: 0 additions & 2 deletions src/binary/YCP.cc
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,6 @@ ycp_module_call_ycp_function(int argc, VALUE *argv, VALUE self)
{
//set back reference
rb_funcall(argv[i->first], rb_intern("value="), 1, ycpvalue_2_rbvalue(i->second->value()));
//clean up created symbol entry
delete (SymbolEntry*)&(*(i->second));
}
return ycpvalue_2_rbvalue(res);
}
Expand Down
2 changes: 1 addition & 1 deletion src/binary/YRuby.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void YRuby::gc_free(void *object)
YRuby::~YRuby()
{
y2milestone( "Shutting down ruby interpreter." );
ruby_finalize();
//ruby_finalize(); Do not finalize to allow clear work inside ruby
_y_ruby_finalized = true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ruby/ycp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def copy_arg object
case object
when Numeric,TrueClass,FalseClass,NilClass,Symbol #immutable
object
when YCP::Reference, YCP::External, YCP::YReference #contains only reference somewhere
when YCP::FunRef, YCP::ArgRef, YCP::External, YCP::YReference #contains only reference somewhere
object
else
object.dup
Expand Down
19 changes: 13 additions & 6 deletions src/ruby/ycp/builtins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def self.add object, *params
return res
when ::NilClass then return nil
else
raise "Invalid object for add builtin"
raise "Invalid object '#{object.inspect}' for add builtin"
end
end

Expand Down Expand Up @@ -322,11 +322,12 @@ module List
# Reduces a list to a single value.
def self.reduce *params, &block
return nil if params.first.nil?
list = params.first
if params.size == 2
return nil if params[1].nil?
list = [list] + params[1]
end
list = if params.size == 2 #so first is default and second is list
return nil if params[1].nil?
[params.first] + params[1]
else
params.first
end
return list.reduce &block
end

Expand Down Expand Up @@ -896,6 +897,7 @@ def self.symbolof term
return term.value
end


# Converts a value to a term.
def self.toterm symbol, list=DEF_LENGHT
return nil if symbol.nil? || list.nil?
Expand All @@ -914,5 +916,10 @@ def self.toterm symbol, list=DEF_LENGHT
end
end

def self.tosymbol value
return nil if value.nil?

return value.to_sym
end
end
end
4 changes: 2 additions & 2 deletions src/ruby/ycp/ops.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#predefine term to avoid circular dependency
class YCP::Term;end
class YCP::Reference;end
class YCP::FunRef;end
class YCP::YReference;end

module YCP
Expand All @@ -22,7 +22,7 @@ module Ops
'term' => YCP::Term,
'path' => YCP::Path,
'locale' => ::String,
'function' => [YCP::Reference, YCP::YReference]
'function' => [YCP::FunRef, YCP::YReference]
}

def self.index (object, indexes, default)
Expand Down

0 comments on commit cfc6eea

Please sign in to comment.