small rename

This commit is contained in:
Torsten Ruger 2016-12-19 14:16:10 +02:00
parent 107e3e6d58
commit af9fed863f
5 changed files with 8 additions and 8 deletions

View File

@ -111,7 +111,7 @@ module Typed
raise "create_method #{type.inspect} is not a Type" unless type.is_a? Parfait::Type raise "create_method #{type.inspect} is not a Type" unless type.is_a? Parfait::Type
raise "Args must be Hash #{args}" unless args.is_a?(Hash) raise "Args must be Hash #{args}" unless args.is_a?(Hash)
raise "create_method #{method_name}.#{method_name.class}" unless method_name.is_a? Symbol raise "create_method #{method_name}.#{method_name.class}" unless method_name.is_a? Symbol
arguments = Parfait::Type.new_for_hash( type.object_class , args ) arguments = Parfait::Type.for_hash( type.object_class , args )
@method = type.create_instance_method( method_name , arguments) @method = type.create_instance_method( method_name , arguments)
self self
end end

View File

@ -38,7 +38,7 @@ module Parfait
include Indexed include Indexed
self.offset(3) self.offset(3)
def self.new_for_hash( object_class , hash) def self.for_hash( object_class , hash)
new_type = Type.new( object_class , hash) new_type = Type.new( object_class , hash)
code = new_type.hash code = new_type.hash
Space.object_space.types[code] = new_type Space.object_space.types[code] = new_type
@ -83,7 +83,7 @@ module Parfait
def create_instance_method( method_name , arguments ) def create_instance_method( method_name , arguments )
raise "create_instance_method #{method_name}.#{method_name.class}" unless method_name.is_a?(Symbol) raise "create_instance_method #{method_name}.#{method_name.class}" unless method_name.is_a?(Symbol)
#puts "Self: #{self.class} clazz: #{clazz.name}" #puts "Self: #{self.class} clazz: #{clazz.name}"
arguments = Parfait::Type.new_for_hash( self.object_class , arguments) if arguments.is_a?(Hash) arguments = Parfait::Type.for_hash( self.object_class , arguments) if arguments.is_a?(Hash)
add_instance_method TypedMethod.new( self , method_name , arguments ) add_instance_method TypedMethod.new( self , method_name , arguments )
end end
@ -138,7 +138,7 @@ module Parfait
if existing if existing
return existing return existing
else else
return Type.new_for_hash( object_class , hash) return Type.for_hash( object_class , hash)
end end
end end

View File

@ -8,7 +8,7 @@ class TestMeta < MiniTest::Test
end end
def foo_method for_class = :Try def foo_method for_class = :Try
args = Parfait::Type.new_for_hash( @try , { bar: :Integer}) args = Parfait::Type.for_hash( @try , { bar: :Integer})
::Parfait::TypedMethod.new @space.get_class_by_name(for_class).instance_type , :foo , args ::Parfait::TypedMethod.new @space.get_class_by_name(for_class).instance_type , :foo , args
end end

View File

@ -4,7 +4,7 @@ class TestMethod < MiniTest::Test
def setup def setup
obj = Register.machine.space.get_class_by_name(:Object).instance_type obj = Register.machine.space.get_class_by_name(:Object).instance_type
args = Parfait::Type.new_for_hash( obj , { bar: :Integer , foo: :Type}) args = Parfait::Type.for_hash( obj , { bar: :Integer , foo: :Type})
@method = ::Parfait::TypedMethod.new obj , :meth , args @method = ::Parfait::TypedMethod.new obj , :meth , args
@method.add_local :local_bar , :Integer @method.add_local :local_bar , :Integer
@method.add_local :local_foo , :Type @method.add_local :local_foo , :Type

View File

@ -8,7 +8,7 @@ class TestMethodApi < MiniTest::Test
end end
def foo_method for_class = :Try def foo_method for_class = :Try
args = Parfait::Type.new_for_hash( @try , { bar: :Integer}) args = Parfait::Type.for_hash( @try , { bar: :Integer})
::Parfait::TypedMethod.new @space.get_class_by_name(for_class).instance_type , :foo , args ::Parfait::TypedMethod.new @space.get_class_by_name(for_class).instance_type , :foo , args
end end
@ -33,7 +33,7 @@ class TestMethodApi < MiniTest::Test
end end
end end
def test_create_method def test_create_method
args = Parfait::Type.new_for_hash( @try , { bar: :Integer}) args = Parfait::Type.for_hash( @try , { bar: :Integer})
@try.create_instance_method :bar, args @try.create_instance_method :bar, args
assert_equal ":bar" , @try.method_names.inspect assert_equal ":bar" , @try.method_names.inspect
end end