get sod to output lists and dicts

This commit is contained in:
Torsten Ruger 2015-05-20 10:57:20 +03:00
parent 6f46f54714
commit 06cfba7c58
3 changed files with 31 additions and 7 deletions

View File

@ -60,6 +60,17 @@ module Parfait
set(key,val)
end
def each
index = 1
while index <= @keys.get_length
key = @keys.get(index)
value = @values.get(index)
yield key , value
index = index + 1
end
self
end
# :rehash, :to_hash, :to_h, :to_a, :[], :fetch, :[]=, :store, :default, :default=, :default_proc, :default_proc=,
# :key, :index, :size, :length, :empty?, :each_value, :each_key, :each_pair, :each, :keys, :values,
# :values_at, :shift, :delete, :delete_if, :keep_if, :select, :select!, :reject, :reject!, :clear, :invert,

View File

@ -19,6 +19,7 @@ module Parfait
def self.new_object *args
object = self.new(*args)
puts "NEW #{object.class}"
object
end
@ -53,17 +54,17 @@ module Parfait
@@EMPTY
end
def instance_variables
get_layout().instance_variables
def get_instance_variables
get_layout().get_instance_variables
end
def instance_variable_get name
def get_instance_variable name
index = instance_variable_defined(name)
return nil if index == nil
return internal_get(index)
end
def instance_variable_set name , value
def set_instance_variable name , value
index = instance_variable_defined(name)
return nil if index == nil
return internal_set(index , value)
@ -76,7 +77,7 @@ module Parfait
# Object
# :nil?, :===, :=~, :!~, :eql?, :hash, :<=>, :class, :singleton_class, :clone, :dup, :taint, :tainted?, :untaint,
# :untrust, :untrusted?, :trust, :freeze, :frozen?, :to_s, :inspect, :methods, :singleton_methods, :protected_methods,
# :private_methods, :public_methods, :instance_variables, :instance_variable_get, :instance_variable_set, :instance_variable_defined?,
# :private_methods, :public_methods, :get_instance_variables, :get_instance_variable, :set_instance_variable, :instance_variable_defined?,
# :remove_instance_variable, :instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send, :respond_to?,
# :extend, :display, :method, :public_method, :singleton_method, :define_singleton_method,
# :object_id, :to_enum, :enum_for

View File

@ -43,11 +43,23 @@ module Parfait
old_length = old_length + 1
end
end
end
class Parfait::Class
def to_s
Sof::Writer.write(self)
end
end
class Parfait::List
def to_sof_node(writer , level , ref )
Sof.array_to_sof_node(self , writer , level , ref )
end
end
class Dictionary
def to_sof_node(writer , level , ref)
Sof.hash_to_sof_node( self , writer , level , ref)
end
end
Word.class_eval do
def to_s