~ubuntu-branches/ubuntu/edgy/gnustep-base/edgy

« back to all changes in this revision

Viewing changes to Source/NSPortCoder.m

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Berg, Hubert Chan, Christoph Berg
  • Date: 2005-12-29 18:14:22 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051229181422-abmd8d53tpyxrum2
Tags: 1.11.2-1
[ Hubert Chan ]
* New upstream release.

[ Christoph Berg ]
* Point gdomap symlink to /usr/sbin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
   You should have received a copy of the GNU Library General Public
28
28
   License along with this library; if not, write to the Free
29
 
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
 
29
   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
30
30
 
31
31
   <title>NSPortCoder class reference</title>
32
 
   $Date: 2005/02/22 11:22:44 $ $Revision: 1.45 $
 
32
   $Date: 2005/11/28 15:41:33 $ $Revision: 1.52 $
33
33
   */
34
34
 
35
35
#include "config.h"
46
46
#include "Foundation/NSPort.h"
47
47
#include "Foundation/NSString.h"
48
48
 
 
49
@class  NSMutableDataMalloc;
 
50
@interface NSMutableDataMalloc : NSObject       // Help the compiler
 
51
@end
 
52
 
49
53
/*
50
54
 *      Setup for inline operation of pointer map tables.
51
55
 */
230
234
{
231
235
  if (type_map[(t2 & _GSC_MASK)] != t1)
232
236
    {
 
237
/*
 
238
 * HACK ... allow int/long/longlong types to be used interchangably
 
239
 * as the ObjC compiler currently uses quadword (q/Q) encoding for
 
240
 * integer types on some 64bit systems, so the i/l/q/I/L/Q encodings
 
241
 * can vary.
 
242
 */
 
243
      char      c = type_map[(t2 & _GSC_MASK)];
 
244
      if ((c == _C_INT || c == _C_LNG
 
245
#ifdef  _C_LNG_LNG
 
246
        || c == _C_LNG_LNG
 
247
#endif
 
248
        ) && (t1 == _C_INT || t1 == _C_LNG
 
249
#ifdef  _C_LNG_LNG
 
250
        || t1 == _C_LNG_LNG
 
251
#endif
 
252
        )) return;
 
253
      if ((c == _C_UINT || c == _C_ULNG
 
254
#ifdef  _C_LNG_LNG
 
255
        || c == _C_ULNG_LNG
 
256
#endif
 
257
        ) && (t1 == _C_UINT || t1 == _C_ULNG
 
258
#ifdef  _C_LNG_LNG
 
259
        || t1 == _C_ULNG_LNG
 
260
#endif
 
261
        )) return;
 
262
 
233
263
      [NSException raise: NSInternalInconsistencyException
234
264
                  format: @"expected %s and got %s",
235
265
                    typeToName1(t1), typeToName2(t2)];
295
325
 
296
326
@implementation NSPortCoder
297
327
 
298
 
@class  NSMutableDataMalloc;
299
 
 
300
328
static Class    connectionClass;
301
329
static Class    mutableArrayClass;
302
330
static Class    mutableDataClass;
667
695
                    GSNameFromClass([self class]), GSNameFromSelector(_cmd));
668
696
                }
669
697
              classInfo = [GSClassInfo newWithClass: c andVersion: cver];
670
 
              GSIArrayAddItem(_clsAry, (GSIArrayItem)classInfo);
 
698
              GSIArrayAddItem(_clsAry, (GSIArrayItem)((id)classInfo));
671
699
              *(Class*)address = classInfo->class;
672
700
              /*
673
701
               *        Point the address to a dummy location and read the
742
770
          objc_layout_structure (type, &layout);
743
771
          while (objc_layout_structure_next_member (&layout))
744
772
            {
745
 
              int               offset;
746
 
              int               align;
 
773
              unsigned          offset;
 
774
              unsigned          align;
747
775
              const char        *ftype;
748
776
 
749
777
              objc_layout_structure_get_info (&layout, &offset, &align, &ftype);
1347
1375
          objc_layout_structure (type, &layout);
1348
1376
          while (objc_layout_structure_next_member (&layout))
1349
1377
            {
1350
 
              int               offset;
1351
 
              int               align;
 
1378
              unsigned          offset;
 
1379
              unsigned          align;
1352
1380
              const char        *ftype;
1353
1381
 
1354
1382
              objc_layout_structure_get_info (&layout, &offset, &align, &ftype);
1932
1960
 
1933
1961
@end
1934
1962
 
 
1963
@implementation NSObject (NSPortCoder)
 
1964
/**
 
1965
 * Override to substitute class when an instance is being serialized by an
 
1966
 * [NSPortCoder].  Default implementation returns -classForCoder .
 
1967
 */
 
1968
- (Class) classForPortCoder
 
1969
{
 
1970
  return [self classForCoder];
 
1971
}
 
1972
 
 
1973
/**
 
1974
 * Returns the actual object to be encoded for sending over the
 
1975
 * network on a Distributed Objects connection.<br />
 
1976
 * The default implementation returns self if the receiver is being
 
1977
 * sent <em>bycopy</em> and returns a proxy otherwise.<br />
 
1978
 * Subclasses may override this method to change this behavior,
 
1979
 * eg. to ensure that they are always copied.
 
1980
 */
 
1981
- (id) replacementObjectForPortCoder: (NSPortCoder*)aCoder
 
1982
{
 
1983
  static Class  proxyClass = 0;
 
1984
  static IMP    proxyImp = 0;
 
1985
 
 
1986
  if (proxyImp == 0)
 
1987
    {
 
1988
      proxyClass = [NSDistantObject class];
 
1989
      /*
 
1990
       * use get_imp() because NSDistantObject doesn't implement
 
1991
       * methodForSelector:
 
1992
       */
 
1993
      proxyImp = get_imp(GSObjCClass((id)proxyClass),
 
1994
        @selector(proxyWithLocal:connection:));
 
1995
    }
 
1996
 
 
1997
  if ([aCoder isBycopy])
 
1998
    {
 
1999
      return self;
 
2000
    }
 
2001
  else
 
2002
    {
 
2003
      return (*proxyImp)(proxyClass, @selector(proxyWithLocal:connection:),
 
2004
        self, [aCoder connection]);
 
2005
    }
 
2006
}
 
2007
 
 
2008
@end
 
2009