Forum: IronRuby Code Review: ClrPrimitives2

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cb51033949ffccd982ae32c9f890f25a?d=identicon&s=25 Tomas Matousek (Guest)
on 2009-03-24 19:58
(Received via mailing list)
Attachment: ClrPrimitives2.diff (500 KB)
tfpt review "/shelveset:ClrPrimitives2;REDMOND\tomat"



Python, DLR outer ring changes:

Hoists FloorDivision implementation to MathUtils - Ruby uses the very
same operation.

Ruby changes:

A couple of breaking changes:

-          Removes ClrString constant. CLR string should be referred to
as System::String.

-          Removes IronRuby library. "require 'IronRuby'" is no longer
needed, IronRuby module is now a built-in module.

Implements integer/float operations for all CLR primitive numeric types
(byte, sbyte, short, ushort, uint, long, ulong, float).
Those integer types that fit in 32-bit signed integer (Fixnum) are
widened to Fixnum for all operations. The other integer types are
widened to BigInteger. Float is converted to double.
The operations on these types don't narrow their results even if the
values fit. For example, (System::Byte.new(1) + 1).class == Fixnum, not
System::Byte. This might not be optimal for some scenarios. If we find
it important we'll fix this in future.

The implementation takes the operations from FixnumOps, BignumOps and
FloatOps and moves them to new modules IronRuby::Clr::Integer,
IronRuby::Clr::BigInteger and IronRuby::Clr::Float respectively. These
are mixed back into the numeric types. Some methods need to be
specialized for each types, so we generated C# code for them. Ruby 1.9
script ClrInteger.Generator.rb produces ClrInteger.Generated.cs.

Implements System::Char and System::String methods so that they behave
like an immutable UTF-8 encoded string (of size 1 character in the case
of System::Char). Many methods in MutableStringOps can share
implementation with CLR string. There is still a lot of work to be done
here, especially to support encodings. So for now, to make CLR strings
work like Ruby frozen strings to a large extent, I've implemented
method-missing dispatch that forwards to a MutableString.

Adds IronRuby::Clr::MultiDimensionalArray that is mixed into all
multi-dimensional arrays. This mixin needs to implement those IList
methods that only work with vectors.

Enables checked arithmetic operations in debug builds. Fixes
underflow/overflow bugs in integer operations and adds tests for them.

Adds C# code generator script - used for generating ClrInteger classes.
Groups all StringFormatter sites into a single site local storage class.
Fixes [#20265] library classes nested in an extension class have wrong
name




Tomas
F983f0c990cba2fe743ef62a975ec99c?d=identicon&s=25 Curt Hagenlocher (Guest)
on 2009-03-24 20:58
(Received via mailing list)
Looks good.  The changes for the StringFormatter sites are much needed!

The test PythonInterop5 doesn't look complete -- there's no assertion.
It seems odd that CharOps would include Enumerable.  Is that because a
char looks like a string that can never have a length != 1?
You don't want to use Int32ToObject on ClrInteger.Narrow?
There's a minor typo in the comment for MultiDimensionalClrArrayOps.
In RubyClass.GetDeclaredClrMethods, what if the member you're looking
for actually has a name that ends in "*" ? :)

From: Tomas Matousek
Sent: Tuesday, March 24, 2009 11:33 AM
To: IronRuby External Code Reviewers
Cc: ironruby-core@rubyforge.org
Subject: Code Review: ClrPrimitives2


  tfpt review "/shelveset:ClrPrimitives2;REDMOND\tomat"



Python, DLR outer ring changes:

Hoists FloorDivision implementation to MathUtils - Ruby uses the very
same operation.

Ruby changes:

A couple of breaking changes:

-          Removes ClrString constant. CLR string should be referred to
as System::String.

-          Removes IronRuby library. "require 'IronRuby'" is no longer
needed, IronRuby module is now a built-in module.

Implements integer/float operations for all CLR primitive numeric types
(byte, sbyte, short, ushort, uint, long, ulong, float).
Those integer types that fit in 32-bit signed integer (Fixnum) are
widened to Fixnum for all operations. The other integer types are
widened to BigInteger. Float is converted to double.
The operations on these types don't narrow their results even if the
values fit. For example, (System::Byte.new(1) + 1).class == Fixnum, not
System::Byte. This might not be optimal for some scenarios. If we find
it important we'll fix this in future.

The implementation takes the operations from FixnumOps, BignumOps and
FloatOps and moves them to new modules IronRuby::Clr::Integer,
IronRuby::Clr::BigInteger and IronRuby::Clr::Float respectively. These
are mixed back into the numeric types. Some methods need to be
specialized for each types, so we generated C# code for them. Ruby 1.9
script ClrInteger.Generator.rb produces ClrInteger.Generated.cs.

Implements System::Char and System::String methods so that they behave
like an immutable UTF-8 encoded string (of size 1 character in the case
of System::Char). Many methods in MutableStringOps can share
implementation with CLR string. There is still a lot of work to be done
here, especially to support encodings. So for now, to make CLR strings
work like Ruby frozen strings to a large extent, I've implemented
method-missing dispatch that forwards to a MutableString.

Adds IronRuby::Clr::MultiDimensionalArray that is mixed into all
multi-dimensional arrays. This mixin needs to implement those IList
methods that only work with vectors.

Enables checked arithmetic operations in debug builds. Fixes
underflow/overflow bugs in integer operations and adds tests for them.

Adds C# code generator script - used for generating ClrInteger classes.
Groups all StringFormatter sites into a single site local storage class.
Fixes [#20265] library classes nested in an extension class have wrong
name




Tomas
Cb51033949ffccd982ae32c9f890f25a?d=identicon&s=25 Tomas Matousek (Guest)
on 2009-03-24 22:02
(Received via mailing list)
Inline.

From: Curt Hagenlocher
Sent: Tuesday, March 24, 2009 12:49 PM
To: Tomas Matousek; IronRuby External Code Reviewers
Cc: ironruby-core@rubyforge.org
Subject: RE: Code Review: ClrPrimitives2

Looks good.  The changes for the StringFormatter sites are much needed!

The test PythonInterop5 doesn't look complete -- there's no assertion.

Will add assertion.

It seems odd that CharOps would include Enumerable.  Is that because a
char looks like a string that can never have a length != 1?

You can enumerate a single element :). Yes, it's for consistency.

You don't want to use Int32ToObject on ClrInteger.Narrow?

I'm not sure if it is needed. How often will the result be in the small
range of numbers for which we cache objects?

There's a minor typo in the comment for MultiDimensionalClrArrayOps.

Fixed.

In RubyClass.GetDeclaredClrMethods, what if the member you're looking
for actually has a name that ends in "*" ? :)

Then you should file a bug on Reflection ;-)

Tomas

From: Tomas Matousek
Sent: Tuesday, March 24, 2009 11:33 AM
To: IronRuby External Code Reviewers
Cc: ironruby-core@rubyforge.org
Subject: Code Review: ClrPrimitives2


  tfpt review "/shelveset:ClrPrimitives2;REDMOND\tomat"



Python, DLR outer ring changes:

Hoists FloorDivision implementation to MathUtils - Ruby uses the very
same operation.

Ruby changes:

A couple of breaking changes:

-          Removes ClrString constant. CLR string should be referred to
as System::String.

-          Removes IronRuby library. "require 'IronRuby'" is no longer
needed, IronRuby module is now a built-in module.

Implements integer/float operations for all CLR primitive numeric types
(byte, sbyte, short, ushort, uint, long, ulong, float).
Those integer types that fit in 32-bit signed integer (Fixnum) are
widened to Fixnum for all operations. The other integer types are
widened to BigInteger. Float is converted to double.
The operations on these types don't narrow their results even if the
values fit. For example, (System::Byte.new(1) + 1).class == Fixnum, not
System::Byte. This might not be optimal for some scenarios. If we find
it important we'll fix this in future.

The implementation takes the operations from FixnumOps, BignumOps and
FloatOps and moves them to new modules IronRuby::Clr::Integer,
IronRuby::Clr::BigInteger and IronRuby::Clr::Float respectively. These
are mixed back into the numeric types. Some methods need to be
specialized for each types, so we generated C# code for them. Ruby 1.9
script ClrInteger.Generator.rb produces ClrInteger.Generated.cs.

Implements System::Char and System::String methods so that they behave
like an immutable UTF-8 encoded string (of size 1 character in the case
of System::Char). Many methods in MutableStringOps can share
implementation with CLR string. There is still a lot of work to be done
here, especially to support encodings. So for now, to make CLR strings
work like Ruby frozen strings to a large extent, I've implemented
method-missing dispatch that forwards to a MutableString.

Adds IronRuby::Clr::MultiDimensionalArray that is mixed into all
multi-dimensional arrays. This mixin needs to implement those IList
methods that only work with vectors.

Enables checked arithmetic operations in debug builds. Fixes
underflow/overflow bugs in integer operations and adds tests for them.

Adds C# code generator script - used for generating ClrInteger classes.
Groups all StringFormatter sites into a single site local storage class.
Fixes [#20265] library classes nested in an extension class have wrong
name




Tomas
This topic is locked and can not be replied to.