ObjFW  Check-in [5a127a0804]

Overview
Comment:Add -[removeLastItem] and -[removeLastObject].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5a127a08044e06e92a007567dfb6aff9936c708596d1eddaccf8aaa8fa73d243
User & Date: js on 2011-06-17 00:35:44
Other Links: manifest | tags
Context
2011-06-20
19:26
Let -[writeNBytes:fromBuffer:] return void. check-in: 2a2d5c4c47 user: js tags: trunk
2011-06-17
00:35
Add -[removeLastItem] and -[removeLastObject]. check-in: 5a127a0804 user: js tags: trunk
00:29
Check for M_PI and define it if it's missing. check-in: b1fa976eaa user: js tags: trunk
Changes

Modified src/OFDataArray.h from [8f65cb712a] to [bb04b4c706].

223
224
225
226
227
228
229





230
231
232
233
234
235
236
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241







+
+
+
+
+







 *
 * \param nItems The number of items to remove
 * \param index The index at which the items are removed
 */
- (void)removeNItems: (size_t)nItems
	     atIndex: (size_t)index;

/**
 * \brief Removes the last item.
 */
- (void)removeLastItem;

/**
 * \brief Returns a string containing the data in Base64 encoding.
 *
 * \return A string containing the data in Base64 encoding
 */
- (OFString*)stringByBase64Encoding;

Modified src/OFDataArray.m from [1dbaab5743] to [14e7076f02].

308
309
310
311
312
313
314













315
316
317
318
319
320
321
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334







+
+
+
+
+
+
+
+
+
+
+
+
+







				 toNItems: count
				 withSize: itemSize];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
		[e release];
	}
}

- (void)removeLastItem
{
	count--;
	@try {
		data = [self resizeMemory: data
				 toNItems: count
				 withSize: itemSize];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't care, as we only made it smaller */
		[e release];
	}
}

- copy
{
	OFDataArray *copy = [[OFDataArray alloc] initWithItemSize: itemSize];

	[copy addNItems: count
	     fromCArray: data];

Modified src/OFMutableArray.h from [17e878ade7] to [246ee00df8].

107
108
109
110
111
112
113





114
115
116
117
118
119
120
121
122
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127







+
+
+
+
+









 *
 * \param nobjects The number of objects to remove
 * \param index The index at which the objects are removed
 */
- (void)removeNObjects: (size_t)nObjects
	       atIndex: (size_t)index;

/**
 * \brief Removes the last object.
 */
- (void)removeLastObject;

#ifdef OF_HAVE_BLOCKS
/**
 * \brief Replaces each object with the object returned by the block.
 *
 * \param block The block which returns a new object for each object
 */
- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block;
#endif
@end

Modified src/OFMutableArray.m from [cc5ed55b35] to [9e095a5f89].

186
187
188
189
190
191
192









193
194
195
196
197
198
199
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208







+
+
+
+
+
+
+
+
+








		for (i = 0; i < nObjects; i++)
			[copy[i] release];
	} @finally {
		[self freeMemory: copy];
	}
}

- (void)removeLastObject
{
	id object = [self objectAtIndex: [array count] - 1];
	[array removeLastItem];
	[object release];

	mutations++;
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count_
{
	size_t count = [array count];

Modified src/OFXMLElementBuilder.m from [38288e0329] to [04c630ff09].

117
118
119
120
121
122
123
124

125
126
127
128
129
130
131
117
118
119
120
121
122
123

124
125
126
127
128
129
130
131







-
+







		return;
	}

	if ([stack count] == 1)
		[delegate elementBuilder: self
			 didBuildElement: [stack firstObject]];

	[stack removeNObjects: 1];
	[stack removeLastObject];
}

-    (void)parser: (OFXMLParser*)parser
  foundCharacters: (OFString*)characters
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFXMLElement *element =

Modified src/OFXMLParser.m from [2ab7767e17] to [c97fda3f99].

632
633
634
635
636
637
638
639

640
641
642
643
644
645
646
632
633
634
635
636
637
638

639
640
641
642
643
644
645
646







-
+







		prefix = nil;
	}

	if (![[previous lastObject] isEqual: cache])
		@throw [OFMalformedXMLException newWithClass: isa
						      parser: self];

	[previous removeNObjects: 1];
	[previous removeLastObject];

	[cache setToCString: ""];

	ns = namespace_for_prefix(prefix, namespaces);
	if (prefix != nil && ns == nil)
		@throw [OFUnboundNamespaceException newWithClass: isa
							  prefix: prefix];
655
656
657
658
659
660
661
662

663
664
665
666
667
668
669
655
656
657
658
659
660
661

662
663
664
665
666
667
668
669







-
+







		[delegate parser: self
		   didEndElement: name
		      withPrefix: prefix
		       namespace: ns];

	[pool release];

	[namespaces removeNObjects: 1];
	[namespaces removeLastObject];
	[name release];
	[prefix release];
	name = prefix = nil;

	*last = *i + 1;
	state = (buffer[*i] == '>'
	    ? OF_XMLPARSER_OUTSIDE_TAG
730
731
732
733
734
735
736
737

738
739
740
741
742
743
744
730
731
732
733
734
735
736

737
738
739
740
741
742
743
744







-
+







			   didEndElement: name
			      withPrefix: prefix
			       namespace: ns];

		if ([previous count] == 0)
			finishedParsing = YES;

		[namespaces removeNObjects: 1];
		[namespaces removeLastObject];
	} else if (prefix != nil) {
		OFString *str = [OFString stringWithFormat: @"%@:%@",
							    prefix, name];
		[previous addObject: str];
	} else
		[previous addObject: name];