help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] #at:put: with uint shape does not accept all uint


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] #at:put: with uint shape does not accept all uint
Date: Mon, 10 Jan 2011 10:49:37 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101103 Fedora/1.0-0.33.b2pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.6

On 01/09/2011 11:17 PM, Mathieu Suen wrote:
> On Jan 9, 2011, at 10:50 PM, Paolo Bonzini wrote:
> 
>> On Sun, Jan 9, 2011 at 19:38, Mathieu Suen<address@hidden>  wrote:
>>> Hi,
>>>
>>> I have a class with a uint as shape:
>>>
>>> Object subclass: Foo
>>> [
>>>         <shape:#uint>
>>>         Foo class>>  new [
>>>                 ^(self new:1)
>>>                         at: 1 put: 16r80000000
>>>         ]
>>> ]
>>>
>>> Eval [
>>>
>>>     Foo new.
>>>
>>> ]
>>>
>>> This snippet above raise an error:
>>> "Object: Foo new: 1<0x101327230>  error:
>>>      Invalid argument 2147483648: argument must be between 0 and 4294967295"
>>>
>>> I don't know if that make sense but I have fixed it with the following 
>>> patch:
>>> rev:
>>> 7ccfb10 https://github.com/mathk/smalltalk/commit/7ccfb10
>>
>> Yes, that's fine.
>>
>>> I also have fixed the #at:put: for #int shape in a 32bit arch were it was 
>>> possible to do:
>>> aIntShape at: 1 put: 16r80000000 "Should raise an error"
>>
>> Your change doesn't change anything: :)
>>
>> -    return (ba->bytes[4] == 0);
>> +    return (ba->bytes[4] == 0)&&  (ba->bytes[4]&80) == 0;
>>
>> since it tests bytes[4] twice.  You probably meant ba->bytes[3]&  0x80.
> 
> Yes of course :)
> Fixed in
> 1bfa206 https://github.com/mathk/smalltalk/commit/1bfa206

The following is also enough:

diff --git a/libgst/dict.inl b/libgst/dict.inl
index 702de10..c7b6bbc 100644
--- a/libgst/dict.inl
+++ b/libgst/dict.inl
@@ -1321,20 +1321,10 @@ is_c_int_32 (OOP oop)
 #endif
 
   ba = (gst_byte_array) OOP_TO_OBJ (oop);
-  if (ba->objClass == _gst_large_negative_integer_class)
+  if (COMMON (ba->objClass == _gst_large_positive_integer_class)
+      || ba->objClass == _gst_large_negative_integer_class)
     return (NUM_INDEXABLE_FIELDS (oop) == 4);
 
-  else if COMMON (ba->objClass == _gst_large_positive_integer_class)
-    {
-      switch (NUM_INDEXABLE_FIELDS (oop))
-       {
-       case 4:
-         return (true);
-       case 5:
-         return (ba->bytes[4] == 0);
-       }
-    }
-
   return (false);
 }
 
Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]