From: Arno P. <ar...@pu...> - 2010-03-27 09:17:31
|
that sounds like a fascinating solution to an old problem! (although I have to admit I had to read your post twice to understand it :) ) Gergely: would you mind for the benefit of the people on the mailing list to post some code sniplet that shows the general approach? Kind of a distilled template to show how you do it? Probably easier than to go into your patch. But I like your proposal and I would like to make that change. I think NSProxy might even help us with some other problems in XMLVM (@Wolfgang, Panayotis: overloading of UIView.drawRect). Nice idea! Arno On 3/26/10 10:58 AM, Gergely Kis wrote: > Hi, > > There are already multiple patches in the review queue for the > Collections Framework. Following my previous suggestion, I am now trying > to open a discussion regarding the design of the collections framework. > In our patch (http://xmlvm-reviews.appspot.com/18002) you can already > see a partial implementation of this suggestion. > > Requirements: > 1. Need to support seamless integration between regular ObjC types > (NSArray ... etc.) and Java classes -> use categories > 2. Need to support subclassing for non-final classes. This is a problem > with using class clusters as the basis. > > The proposal: > 1. Create the interfaces as protocols (java_util_List, java_util_Map ... > etc.) > 2. Implement the interfaces as categories of the non-mutable ObjC > collection classes. (NSArray, NSSet, NSDictionary) > - The mutator methods are implemented to throw > UnsupportedOperationException. In essence you receive the same behavior > as if you used Collections.unmodifiable*() methods > 3. Only implement the mutator methods in the NSMutable* collection classes. > > At this point any ObjC collection can be used as a regular Java collection. > Now we need to implement the actual concrete classes. > > However class clusters cannot be subclassed easily. > The solution is to implement the concrete classes using NSProxy. (See > how java_util_Vector is implemented in our patch). > However, this implementation adds an unnecessary indirection and > performance overhead. So the idea is to detect in the proxy class init > function whether a subclass is instantiated. > If it is not a subclass, then simply return the appropriate NSMutable* > instance. Otherwise return the proxy. > > What do you think? If you agree with this approach we can clean up our > implementation, and submit it separately. > > Best Regards, > Gergely > > -- > Kis Gergely > MattaKis Consulting > Email: ger...@ma... <mailto:ger...@ma...> > Web: http://www.mattakis.com > Phone: +36 70 408 1723 > Fax: +36 27 998 622 > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > > > > _______________________________________________ > xmlvm-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlvm-users |