19POLAR_FUNCTION_INTERNAL
struct objc_list_method_descriptions *
20objc_list_method_descriptions_new(
int count_methods )
22 struct objc_list_method_descriptions *result;
27 if( count_methods > 0 )
29 size_result =
sizeof(*result);
31 if( count_methods > 1 )
32 size_result += ( (count_methods - 1) *
sizeof(
struct objc_method_description) );
34 result = (
struct objc_list_method_descriptions *)polar_memory_allocate(size_result);
35 result->count_methods = count_methods;
41POLAR_FUNCTION_INTERNAL
void
42objc_list_method_descriptions_add_method(
struct objc_list_method_descriptions **p_list_target,
43 const char *name_method,
const char *type_encoding_method )
45 struct objc_list_method_descriptions *list_old, *list_new;
46 int count_descriptions;
47 size_t size_list_old, size_list_new;
49 assert( p_list_target != NULL );
50 assert( name_method != NULL );
51 assert( *name_method != 0 );
52 assert( type_encoding_method != NULL );
53 assert( *type_encoding_method != 0 );
55 list_old = *p_list_target;
56 if( list_old != NULL )
58 count_descriptions = list_old->count_methods;
60 size_list_old = objc_list_method_descriptions_get_size(list_old);
61 size_list_new = ( size_list_old +
sizeof(
struct objc_method_description) );
63 list_new = (
struct objc_list_method_descriptions *)
64 polar_memory_reallocate(list_old, size_list_new, size_list_old);
66 list_new->count_methods++;
71 list_new = objc_list_method_descriptions_new(1);
72 count_descriptions = 0;
75 list_new->array_methods[count_descriptions].name_method = name_method;
76 list_new->array_methods[count_descriptions].type_encoding_method = type_encoding_method;
78 if( list_new != list_old )
79 *p_list_target = list_new;
82POLAR_FUNCTION_INTERNAL
int
83objc_list_method_descriptions_add_methods(
struct objc_list_method_descriptions **p_list_target,
84 int count_methods,
struct objc_method_description *array_descriptions )
87 struct objc_list_method_descriptions *list_old, *list_new;
88 int count_descriptions;
89 size_t size_list_old, size_list_new;
90 struct objc_method_description *description_dest, *description_source;
92 assert( p_list_target != NULL );
94 if( (count_methods > 0) && (array_descriptions != NULL) )
100 list_old = *p_list_target;
101 if( list_old != NULL )
103 count_descriptions = list_old->count_methods;
105 size_list_old = objc_list_method_descriptions_get_size(list_old);
106 size_list_new = ( size_list_old + (
sizeof(
struct objc_method_description) * count_methods) );
108 list_new = (
struct objc_list_method_descriptions *)
109 polar_memory_reallocate(list_old, size_list_new, size_list_old);
111 list_new->count_methods++;
116 list_new = objc_list_method_descriptions_new(count_methods);
117 count_descriptions = 0;
121 description_dest = &list_new->array_methods[count_descriptions];
122 description_source = array_descriptions;
124 for( ; count_descriptions < list_new->count_methods; count_descriptions++ )
126 if( (description_source->name_method != NULL) && (*(description_source->name_method) != 0) )
132 if( (description_source->type_encoding_method != NULL) && (*(description_source->type_encoding_method) != 0) )
138 description_dest->name_method = description_source->name_method;
139 description_dest->type_encoding_method = description_source->type_encoding_method;
142 description_source++;
146 if( list_new != list_old )
147 *p_list_target = list_new;
152POLAR_FUNCTION_INTERNAL OBJC_FUNCTION_PURE
size_t
153objc_list_method_descriptions_get_size(
struct objc_list_method_descriptions *list_target )
157 if( list_target != NULL )
163 result =
sizeof(*list_target);
165 if( list_target->count_methods > 1 )
166 result += ( (list_target->count_methods - 1) *
sizeof(list_target->array_methods[0]) );