Re: some unsigned/NSInteger to NSUInteger changes in -gui

2012-04-09 Thread Fred Kiefer
I just checked the code in base and Eric seems to be right here. The 
type check code in NSUnarchiver (we aren't talking about keyed coding 
here) has a lot of HACK warnings, but it seems to do what we need here, 
allow for different integer types to be used interchangeable.


Please go ahead and apply this change.

Fred

On 09.04.2012 21:14, Eric Wasylishen wrote:

Hi,
What's safe is encoding with any supported integer type and decoding with 
another integer type, so you can write a keyed archive with @encode(long) and 
decode it as @encode(int), even if long is 64-bits and int is 32-bits.

In other words it's safe to use @encode(NS[U]Integer). However, if the ivar is 
changed to NSUInteger, I think these:


-  [aCoder encodeValueOfObjCType: "i" at:&_selected_item];
+  [aCoder encodeValueOfObjCType: "I" at:&_selected_item];



-  [aDecoder decodeValueOfObjCType: "i" at:&_selected_item];
+  [aDecoder decodeValueOfObjCType: "I" at:&_selected_item];


should actually use @encode(NSUInteger), not "l". Otherwise the patch looks 
good :-).

Eric

On 2012-04-09, at 11:08 AM, Fred Kiefer wrote:


Most of the patch is ok, but we have too ake a careful look at the coding 
change. This may break backwards and forewards compatibility. Maybe Richard is 
able to explain if this change is save or not.

Fred

On the road

Am 09.04.2012 um 18:02 schrieb "Sebastian 
Reitenbach":


Hi,

while looking at compilation warnings from the latest releases, I found in -gui 
(svn) some parts in NSTableView that would need to be changed. First is easy, 
declare i as NSUInteger (was unsigned before). Further I think _selected_item 
declared in the header as NSInteger also should be a NSUInteger.

is it OK when I commit the patch?

Sebastian

Index: Source/NSTabView.m
===
--- Source/NSTabView.m(revision 35049)
+++ Source/NSTabView.m(working copy)
@@ -123,7 +123,7 @@

- (void) removeTabViewItem: (NSTabViewItem*)tabViewItem
{
-  unsigned i = [_items indexOfObject: tabViewItem];
+  NSUInteger i = [_items indexOfObject: tabViewItem];

  if (i == NSNotFound)
return;
@@ -202,7 +202,7 @@

- (void) selectNextTabViewItem: (id)sender
{
-  if ((_selected_item != NSNotFound)&&  ((unsigned)(_selected_item + 1)<  
[_items count]))
+  if ((_selected_item != NSNotFound)&&  ((_selected_item + 1)<  [_items 
count]))
{
  [self selectTabViewItemAtIndex: _selected_item + 1];
}
@@ -550,7 +550,7 @@
  [aCoder encodeValueOfObjCType: @encode(BOOL) at:&_draws_background];
  [aCoder encodeValueOfObjCType: @encode(BOOL) at:&_truncated_label];
  [aCoder encodeConditionalObject: _delegate];
-  [aCoder encodeValueOfObjCType: "i" at:&_selected_item];
+  [aCoder encodeValueOfObjCType: "I" at:&_selected_item];
}
}

@@ -631,7 +631,7 @@
  [aDecoder decodeValueOfObjCType: @encode(BOOL) at:&_draws_background];
  [aDecoder decodeValueOfObjCType: @encode(BOOL) at:&_truncated_label];
  _delegate = [aDecoder decodeObject];
-  [aDecoder decodeValueOfObjCType: "i" at:&_selected_item];
+  [aDecoder decodeValueOfObjCType: "I" at:&_selected_item];
  _selected = [_items objectAtIndex: _selected_item];
}
  return self;
Index: Headers/AppKit/NSTabView.h
===
--- Headers/AppKit/NSTabView.h(revision 35049)
+++ Headers/AppKit/NSTabView.h(working copy)
@@ -54,7 +54,7 @@
  BOOL _draws_background;
  BOOL _truncated_label;
  id _delegate;
-  NSInteger _selected_item;
+  NSUInteger _selected_item;
}
- (void)addTabViewItem:(NSTabViewItem *)tabViewItem;
- (void)insertTabViewItem:(NSTabViewItem *)tabViewItem



___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
https://lists.gnu.org/mailman/listinfo/gnustep-dev


Re: some NSInteger to NSUinterger changes in -base

2012-04-09 Thread Fred Kiefer

This change looks fine to me, please go ahead and apply it.

Fred

On 09.04.2012 17:58, Sebastian Reitenbach wrote:

Hi,

while looking at latest release compilation warnings on OpenBSD amd64, I found 
that some of the changes made after the release don't seem to be right. NSArray 
count or indexOfObject return NSUInteger and also NSRange.location is 
NSUInteger, but the variables were changed from int to NSInteger. I think they 
should be NSUInteger.

is it OK when I commit the patch below?

Sebastian


Index: Tools/make_strings/StringsFile.m
===
--- Tools/make_strings/StringsFile.m(revision 34987)
+++ Tools/make_strings/StringsFile.m(working copy)
@@ -127,7 +127,7 @@
  NSMutableArray *update_list=[[NSMutableArray alloc] init];
  NSArray *lines;
  NSString *l;
-NSInteger i,c,pos;
+NSUInteger i,c,pos;
  NSMutableDictionary *dummy_entries=[[NSMutableDictionary alloc] init];

  NSMutableString *user_comment=[[NSMutableString alloc] init];
Index: Tools/pl.m
===
--- Tools/pl.m  (revision 34987)
+++ Tools/pl.m  (working copy)
@@ -39,7 +39,7 @@
NSFileHandle *fileHandle = nil;
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
NSArray *arguments = [processInfo arguments];
-  NSInteger outputIndex = 0;
+  NSUInteger outputIndex = 0;

// insert your code here
outputIndex = [arguments indexOfObject: @"-output"];
@@ -94,7 +94,7 @@
NSFileHandle *fileHandle = nil;
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
NSArray *arguments = [processInfo arguments];
-  NSInteger inputIndex = 0;
+  NSUInteger inputIndex = 0;

// insert your code here
inputIndex = [arguments indexOfObject: @"-input"];



___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
https://lists.gnu.org/mailman/listinfo/gnustep-dev


Re: some unsigned/NSInteger to NSUInteger changes in -gui

2012-04-09 Thread Eric Wasylishen
Hi,
What's safe is encoding with any supported integer type and decoding with 
another integer type, so you can write a keyed archive with @encode(long) and 
decode it as @encode(int), even if long is 64-bits and int is 32-bits.

In other words it's safe to use @encode(NS[U]Integer). However, if the ivar is 
changed to NSUInteger, I think these:

>> -  [aCoder encodeValueOfObjCType: "i" at: &_selected_item];
>> +  [aCoder encodeValueOfObjCType: "I" at: &_selected_item];

>> -  [aDecoder decodeValueOfObjCType: "i" at: &_selected_item];
>> +  [aDecoder decodeValueOfObjCType: "I" at: &_selected_item];

should actually use @encode(NSUInteger), not "l". Otherwise the patch looks 
good :-).

Eric

On 2012-04-09, at 11:08 AM, Fred Kiefer wrote:

> Most of the patch is ok, but we have too ake a careful look at the coding 
> change. This may break backwards and forewards compatibility. Maybe Richard 
> is able to explain if this change is save or not.
> 
> Fred
> 
> On the road
> 
> Am 09.04.2012 um 18:02 schrieb "Sebastian Reitenbach" 
> :
> 
>> Hi,
>> 
>> while looking at compilation warnings from the latest releases, I found in 
>> -gui (svn) some parts in NSTableView that would need to be changed. First is 
>> easy, declare i as NSUInteger (was unsigned before). Further I think 
>> _selected_item declared in the header as NSInteger also should be a 
>> NSUInteger.
>> 
>> is it OK when I commit the patch?
>> 
>> Sebastian
>> 
>> Index: Source/NSTabView.m
>> ===
>> --- Source/NSTabView.m(revision 35049)
>> +++ Source/NSTabView.m(working copy)
>> @@ -123,7 +123,7 @@
>> 
>> - (void) removeTabViewItem: (NSTabViewItem*)tabViewItem
>> {
>> -  unsigned i = [_items indexOfObject: tabViewItem];
>> +  NSUInteger i = [_items indexOfObject: tabViewItem];
>> 
>>  if (i == NSNotFound)
>>return;
>> @@ -202,7 +202,7 @@
>> 
>> - (void) selectNextTabViewItem: (id)sender
>> {
>> -  if ((_selected_item != NSNotFound) && ((unsigned)(_selected_item + 1) < 
>> [_items count]))
>> +  if ((_selected_item != NSNotFound) && ((_selected_item + 1) < [_items 
>> count]))
>>{
>>  [self selectTabViewItemAtIndex: _selected_item + 1];
>>}
>> @@ -550,7 +550,7 @@
>>  [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_draws_background];
>>  [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_truncated_label];
>>  [aCoder encodeConditionalObject: _delegate];
>> -  [aCoder encodeValueOfObjCType: "i" at: &_selected_item];
>> +  [aCoder encodeValueOfObjCType: "I" at: &_selected_item];
>>}
>> }
>> 
>> @@ -631,7 +631,7 @@
>>  [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_draws_background];
>>  [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_truncated_label];
>>  _delegate = [aDecoder decodeObject];
>> -  [aDecoder decodeValueOfObjCType: "i" at: &_selected_item];
>> +  [aDecoder decodeValueOfObjCType: "I" at: &_selected_item];
>>  _selected = [_items objectAtIndex: _selected_item];
>>}
>>  return self;
>> Index: Headers/AppKit/NSTabView.h
>> ===
>> --- Headers/AppKit/NSTabView.h(revision 35049)
>> +++ Headers/AppKit/NSTabView.h(working copy)
>> @@ -54,7 +54,7 @@
>>  BOOL _draws_background;
>>  BOOL _truncated_label;
>>  id _delegate;
>> -  NSInteger _selected_item;
>> +  NSUInteger _selected_item;
>> }
>> - (void)addTabViewItem:(NSTabViewItem *)tabViewItem;
>> - (void)insertTabViewItem:(NSTabViewItem *)tabViewItem
>> 
>> ___
>> Gnustep-dev mailing list
>> Gnustep-dev@gnu.org
>> https://lists.gnu.org/mailman/listinfo/gnustep-dev
> 
> ___
> Gnustep-dev mailing list
> Gnustep-dev@gnu.org
> https://lists.gnu.org/mailman/listinfo/gnustep-dev


___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
https://lists.gnu.org/mailman/listinfo/gnustep-dev


Re: some unsigned/NSInteger to NSUInteger changes in -gui

2012-04-09 Thread Fred Kiefer
Most of the patch is ok, but we have too ake a careful look at the coding 
change. This may break backwards and forewards compatibility. Maybe Richard is 
able to explain if this change is save or not.

Fred

On the road

Am 09.04.2012 um 18:02 schrieb "Sebastian Reitenbach" 
:

> Hi,
> 
> while looking at compilation warnings from the latest releases, I found in 
> -gui (svn) some parts in NSTableView that would need to be changed. First is 
> easy, declare i as NSUInteger (was unsigned before). Further I think 
> _selected_item declared in the header as NSInteger also should be a 
> NSUInteger.
> 
> is it OK when I commit the patch?
> 
> Sebastian
> 
> Index: Source/NSTabView.m
> ===
> --- Source/NSTabView.m(revision 35049)
> +++ Source/NSTabView.m(working copy)
> @@ -123,7 +123,7 @@
> 
> - (void) removeTabViewItem: (NSTabViewItem*)tabViewItem
> {
> -  unsigned i = [_items indexOfObject: tabViewItem];
> +  NSUInteger i = [_items indexOfObject: tabViewItem];
> 
>   if (i == NSNotFound)
> return;
> @@ -202,7 +202,7 @@
> 
> - (void) selectNextTabViewItem: (id)sender
> {
> -  if ((_selected_item != NSNotFound) && ((unsigned)(_selected_item + 1) < 
> [_items count]))
> +  if ((_selected_item != NSNotFound) && ((_selected_item + 1) < [_items 
> count]))
> {
>   [self selectTabViewItemAtIndex: _selected_item + 1];
> }
> @@ -550,7 +550,7 @@
>   [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_draws_background];
>   [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_truncated_label];
>   [aCoder encodeConditionalObject: _delegate];
> -  [aCoder encodeValueOfObjCType: "i" at: &_selected_item];
> +  [aCoder encodeValueOfObjCType: "I" at: &_selected_item];
> }
> }
> 
> @@ -631,7 +631,7 @@
>   [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_draws_background];
>   [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_truncated_label];
>   _delegate = [aDecoder decodeObject];
> -  [aDecoder decodeValueOfObjCType: "i" at: &_selected_item];
> +  [aDecoder decodeValueOfObjCType: "I" at: &_selected_item];
>   _selected = [_items objectAtIndex: _selected_item];
> }
>   return self;
> Index: Headers/AppKit/NSTabView.h
> ===
> --- Headers/AppKit/NSTabView.h(revision 35049)
> +++ Headers/AppKit/NSTabView.h(working copy)
> @@ -54,7 +54,7 @@
>   BOOL _draws_background;
>   BOOL _truncated_label;
>   id _delegate;
> -  NSInteger _selected_item;
> +  NSUInteger _selected_item;
> }
> - (void)addTabViewItem:(NSTabViewItem *)tabViewItem;
> - (void)insertTabViewItem:(NSTabViewItem *)tabViewItem
> 
> ___
> Gnustep-dev mailing list
> Gnustep-dev@gnu.org
> https://lists.gnu.org/mailman/listinfo/gnustep-dev

___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
https://lists.gnu.org/mailman/listinfo/gnustep-dev


some unsigned/NSInteger to NSUInteger changes in -gui

2012-04-09 Thread Sebastian Reitenbach
Hi,

while looking at compilation warnings from the latest releases, I found in -gui 
(svn) some parts in NSTableView that would need to be changed. First is easy, 
declare i as NSUInteger (was unsigned before). Further I think _selected_item 
declared in the header as NSInteger also should be a NSUInteger.

is it OK when I commit the patch?

Sebastian

Index: Source/NSTabView.m
===
--- Source/NSTabView.m  (revision 35049)
+++ Source/NSTabView.m  (working copy)
@@ -123,7 +123,7 @@
 
 - (void) removeTabViewItem: (NSTabViewItem*)tabViewItem
 {
-  unsigned i = [_items indexOfObject: tabViewItem];
+  NSUInteger i = [_items indexOfObject: tabViewItem];
   
   if (i == NSNotFound)
 return;
@@ -202,7 +202,7 @@
 
 - (void) selectNextTabViewItem: (id)sender
 {
-  if ((_selected_item != NSNotFound) && ((unsigned)(_selected_item + 1) < 
[_items count]))
+  if ((_selected_item != NSNotFound) && ((_selected_item + 1) < [_items 
count]))
 {
   [self selectTabViewItemAtIndex: _selected_item + 1];
 }
@@ -550,7 +550,7 @@
   [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_draws_background];
   [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_truncated_label];
   [aCoder encodeConditionalObject: _delegate];
-  [aCoder encodeValueOfObjCType: "i" at: &_selected_item];
+  [aCoder encodeValueOfObjCType: "I" at: &_selected_item];
 }
 }
 
@@ -631,7 +631,7 @@
   [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_draws_background];
   [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_truncated_label];
   _delegate = [aDecoder decodeObject];
-  [aDecoder decodeValueOfObjCType: "i" at: &_selected_item];
+  [aDecoder decodeValueOfObjCType: "I" at: &_selected_item];
   _selected = [_items objectAtIndex: _selected_item];
 }
   return self;
Index: Headers/AppKit/NSTabView.h
===
--- Headers/AppKit/NSTabView.h  (revision 35049)
+++ Headers/AppKit/NSTabView.h  (working copy)
@@ -54,7 +54,7 @@
   BOOL _draws_background;
   BOOL _truncated_label;
   id _delegate;
-  NSInteger _selected_item;
+  NSUInteger _selected_item;
 }
 - (void)addTabViewItem:(NSTabViewItem *)tabViewItem;
 - (void)insertTabViewItem:(NSTabViewItem *)tabViewItem

___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
https://lists.gnu.org/mailman/listinfo/gnustep-dev


some NSInteger to NSUinterger changes in -base

2012-04-09 Thread Sebastian Reitenbach
Hi,

while looking at latest release compilation warnings on OpenBSD amd64, I found 
that some of the changes made after the release don't seem to be right. NSArray 
count or indexOfObject return NSUInteger and also NSRange.location is 
NSUInteger, but the variables were changed from int to NSInteger. I think they 
should be NSUInteger.

is it OK when I commit the patch below?

Sebastian


Index: Tools/make_strings/StringsFile.m
===
--- Tools/make_strings/StringsFile.m(revision 34987)
+++ Tools/make_strings/StringsFile.m(working copy)
@@ -127,7 +127,7 @@
 NSMutableArray *update_list=[[NSMutableArray alloc] init];
 NSArray *lines;
 NSString *l;
-NSInteger i,c,pos;
+NSUInteger i,c,pos;
 NSMutableDictionary *dummy_entries=[[NSMutableDictionary alloc] init];
 
 NSMutableString *user_comment=[[NSMutableString alloc] init];
Index: Tools/pl.m
===
--- Tools/pl.m  (revision 34987)
+++ Tools/pl.m  (working copy)
@@ -39,7 +39,7 @@
   NSFileHandle *fileHandle = nil;
   NSProcessInfo *processInfo = [NSProcessInfo processInfo];
   NSArray *arguments = [processInfo arguments];
-  NSInteger outputIndex = 0;
+  NSUInteger outputIndex = 0;
 
   // insert your code here
   outputIndex = [arguments indexOfObject: @"-output"];
@@ -94,7 +94,7 @@
   NSFileHandle *fileHandle = nil;
   NSProcessInfo *processInfo = [NSProcessInfo processInfo];
   NSArray *arguments = [processInfo arguments];
-  NSInteger inputIndex = 0;
+  NSUInteger inputIndex = 0;
 
   // insert your code here
   inputIndex = [arguments indexOfObject: @"-input"];

___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
https://lists.gnu.org/mailman/listinfo/gnustep-dev