discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Determining the length of an objCType


From: Richard Frith-Macdonald
Subject: Re: Determining the length of an objCType
Date: Tue, 10 Dec 2002 05:48:16 +0000


On Monday, December 9, 2002, at 07:00  pm, Andreas Hoeschler wrote:

Hi all,

I need to encode NSValue on my own (in a category of NSValue). The primitives of NSValue are:

- (const char *)objCType
- (void)getValue:(void *)buffer

I would like to do something like

   const char *objCType = [self objCType];
   int length = sizeof(objCType); // <-----------
   void *buffer = malloc(length);
   [self getValue:buffer];
[archiver encodeString:[NSString stringWithCString:objCType] withName:@"type"]; [archiver encodeData:[NSData dataWithBytes:buffer length:length] withName:@"value"];
   free(buffer);

The marked line of course is incorrect. But how can I get the necessary buffer size from an objC type?


The gnu runtime uses objc_sizeof_type()

eg.

unsigned int size = objc_sizeof_type(@encode(myStructType));




reply via email to

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