From 410644c41a1b10798a0fe442c66f9bf582ecf067 Mon Sep 17 00:00:00 2001 From: Nicola Pero Date: Fri, 24 Dec 2010 18:41:05 +0000 Subject: In libobjc/: 2010-12-24 Nicola Pero In libobjc/: 2010-12-24 Nicola Pero * objc/runtime.h (class_addIvar): Updated documentation. The alignment is actually the log_2 of the alignment in bytes. * ivars.c (class_addIvar): Corresponding change to the implementation. In gcc/testsuite/: 2010-12-24 Nicola Pero * objc.dg/gnu-api-2-class.m: Updated test to pass log_2 of the alignment to class_addIvar, instead of the alignment itself. * obj-c++.dg/gnu-api-2-class.mm: Same change. From-SVN: r168230 --- libobjc/objc/runtime.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'libobjc/objc') diff --git a/libobjc/objc/runtime.h b/libobjc/objc/runtime.h index 18fc872..9332f7b 100644 --- a/libobjc/objc/runtime.h +++ b/libobjc/objc/runtime.h @@ -352,14 +352,16 @@ objc_EXPORT Ivar * class_copyIvarList (Class class_, unsigned int *numberOfRetur using objc_allocateClassPair() and has not been registered with the runtime using objc_registerClassPair() yet. You can not add instance variables to classes already registered with the runtime. - 'size' is the size of the instance variable, 'alignment' the - alignment, and 'type' the type encoding of the variable type. You - can use sizeof(), __alignof__() and @encode() to determine the - right 'size', 'alignment' and 'type' for your instance variable. - For example, to add an instance variable name "my_variable" and of - type 'id', you can use: - - class_addIvar (class, "my_variable", sizeof (id), __alignof__ (id), + 'size' is the size of the instance variable, 'log_2_of_alignment' + the alignment as a power of 2 (so 0 means alignment to a 1 byte + boundary, 1 means alignment to a 2 byte boundary, 2 means alignment + to a 4 byte boundary, etc), and 'type' the type encoding of the + variable type. You can use sizeof(), log2(__alignof__()) and + @encode() to determine the right 'size', 'alignment' and 'type' for + your instance variable. For example, to add an instance variable + name "my_variable" and of type 'id', you can use: + + class_addIvar (class, "my_variable", sizeof (id), log2 ( __alignof__ (id)), @encode (id)); Return YES if the variable was added, and NO if not. In @@ -368,7 +370,7 @@ objc_EXPORT Ivar * class_copyIvarList (Class class_, unsigned int *numberOfRetur 'type' is NULL, or 'size' is 0. */ objc_EXPORT BOOL class_addIvar (Class class_, const char * ivar_name, size_t size, - unsigned char alignment, const char *type); + unsigned char log_2_of_alignment, const char *type); /* Return the name of the property. Return NULL if 'property' is NULL. */ -- cgit v1.1