bugGNUstep - Bugs: bug #22277, KVC should handle common structs...

Group
 
 

bug #22277: KVC should handle common structs like NSSize, NSRect etc.

Submitter:  Quentin Mathé <qmathe>
Submitted:  Sun 10 Feb 2008 03:16:03 PM UTC
   
 
Category:  Base/Foundation Severity:  3 - Normal
Item Group:  Bug Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 22 Feb 2008 02:27:52 PM UTC, comment #4: 

Works well now. Thanks Richard.

Quentin Mathé <qmathe>
Group Member
Fri 22 Feb 2008 01:03:16 PM UTC, comment #3: 


> Why the return type includes human readable stuff like
> '{_NSRect={_NSPoint=ff}{_NSSize=ff}}' in addition to '12@4:8' for NSRect?


Good question ... the type information really should not include the size info at the end ... that's because it's using a pointer into the original cstring rather than creating a nul terminated string containing just the type info.

I've changed the code to produce proper nul terminated type strings.  Hopefully nothing depends on the old behavior.

Richard Frith-Macdonald <CaS>
Group Member
Fri 22 Feb 2008 12:25:50 AM UTC, comment #2: 

Thanks for implementing this feature.
I just tested it, but it doesn't work as expected.

If I add the following log statement  at line 1764 of GSObjCRuntime.m: NSLog(@"encode rect %s point %s type %s", @encode(NSRect), @encode(NSPoint), type));

I observe that -[NSMethodSignature methodReturnType] doesn't exactly match @encode values for NSRect, NSPoint etc.

Here is the output I get:
2008-02-22 01:08:21.110 ObjectManagerExample[16975] encode rect {_NSRect={_NSPoint=ff}{_NSSize=ff}} point {_NSPoint=ff} type {_NSRect={_NSPoint=ff}{_NSSize=ff}}12@4:8
ObjectManagerExample.app/ObjectManagerExample: Uncaught exception NSInvalidArgumentException, reason: key-value get method unsupported struct

Why the return type includes human readable stuff like '{_NSRect={_NSPoint=ff}{_NSSize=ff}}' in addition to '12@4:8' for NSRect?



Quentin Mathé <qmathe>
Group Member
Wed 20 Feb 2008 03:15:24 PM UTC, comment #1: 

I added code which should implement these structures ... perhaps you can test it?

Richard Frith-Macdonald <CaS>
Group Member
Sun 10 Feb 2008 03:16:03 PM UTC, original submission:  

With gnustep-base trunk r26014

KVC on Mac OS X (Cocoa) takes care of handling common structs like NSPoint, NSRange, NSSize and NSRect in -setValue:forKey: when you pass them boxed in an NSValue. In the reverse way,  it takes care of returning common structs boxed in an NSValue when you call -valueForKey:.

On GNUstep, such handling is missing, so for example an exception is raised by GSObjcSetVal() if you do:
[myObject setValue: [NSValue valueWithSize: NSMakeSize(32, 32)] forKey: @"size"];

Quentin.

Quentin Mathé <qmathe>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by CaS (Posted a comment)
  • -email is unavailable- added by qmathe (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2008-02-22 CaS Open/ClosedIn Test Closed
    2008-02-20 CaS StatusNone Fixed
        Open/ClosedOpen In Test

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code