ObjFW  Diff

Differences From Artifact [fbc06e6c49]:

To Artifact [d77796d59f]:


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
- (size_t)_readNBytes: (size_t)length
	   intoBuffer: (void*)buffer
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- (size_t)_writeNBytes: (size_t)length
	    fromBuffer: (const void*)buffer
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- (BOOL)isAtEndOfStream
{







|
|







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
- (size_t)_readNBytes: (size_t)length
	   intoBuffer: (void*)buffer
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- (void)_writeNBytes: (size_t)length
	  fromBuffer: (const void*)buffer
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- (BOOL)isAtEndOfStream
{
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
		fromBuffer: writeBuffer];

	[self freeMemory: writeBuffer];
	writeBuffer = NULL;
	writeBufferLength = 0;
}

- (size_t)writeNBytes: (size_t)length
	   fromBuffer: (const void*)buffer
{
	if (!buffersWrites)
		return [self _writeNBytes: length
			       fromBuffer: buffer];
	else {
		writeBuffer = [self resizeMemory: writeBuffer
					  toSize: writeBufferLength + length];
		memcpy(writeBuffer + writeBufferLength, buffer, length);
		writeBufferLength += length;

		return length;
	}
}

- (void)writeInt8: (uint8_t)int8
{
	[self writeNBytes: 1
	       fromBuffer: (char*)&int8];







|
|


|
|





<
<







621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638


639
640
641
642
643
644
645
		fromBuffer: writeBuffer];

	[self freeMemory: writeBuffer];
	writeBuffer = NULL;
	writeBufferLength = 0;
}

- (void)writeNBytes: (size_t)length
	 fromBuffer: (const void*)buffer
{
	if (!buffersWrites)
		[self _writeNBytes: length
			fromBuffer: buffer];
	else {
		writeBuffer = [self resizeMemory: writeBuffer
					  toSize: writeBufferLength + length];
		memcpy(writeBuffer + writeBufferLength, buffer, length);
		writeBufferLength += length;


	}
}

- (void)writeInt8: (uint8_t)int8
{
	[self writeNBytes: 1
	       fromBuffer: (char*)&int8];
725
726
727
728
729
730
731
732


733


734
735
736
737


738
739


740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766

	[self writeNBytes: 8
	       fromBuffer: (char*)&double_];
}

- (size_t)writeDataArray: (OFDataArray*)dataArray
{
	return [self writeNBytes: [dataArray count] * [dataArray itemSize]


		      fromBuffer: [dataArray cArray]];


}

- (size_t)writeString: (OFString*)string
{


	return [self writeNBytes: [string cStringLength]
		      fromBuffer: [string cString]];


}

- (size_t)writeLine: (OFString*)string
{
	size_t retLength, stringLength = [string cStringLength];
	char *buffer;

	buffer = [self allocMemoryWithSize: stringLength + 1];

	@try {
		memcpy(buffer, [string cString], stringLength);
		buffer[stringLength] = '\n';

		retLength = [self writeNBytes: stringLength + 1
				   fromBuffer: buffer];
	} @finally {
		[self freeMemory: buffer];
	}

	return retLength;
}

- (size_t)writeFormat: (OFString*)format, ...
{
	va_list arguments;
	size_t ret;








|
>
>
|
>
>




>
>
|
|
>
>




|








|
|




|







723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772

	[self writeNBytes: 8
	       fromBuffer: (char*)&double_];
}

- (size_t)writeDataArray: (OFDataArray*)dataArray
{
	size_t length = [dataArray count] * [dataArray itemSize];

	[self writeNBytes: length
	       fromBuffer: [dataArray cArray]];

	return [dataArray count] * [dataArray itemSize];
}

- (size_t)writeString: (OFString*)string
{
	size_t length = [string cStringLength];

	[self writeNBytes: length
	       fromBuffer: [string cString]];

	return length;
}

- (size_t)writeLine: (OFString*)string
{
	size_t stringLength = [string cStringLength];
	char *buffer;

	buffer = [self allocMemoryWithSize: stringLength + 1];

	@try {
		memcpy(buffer, [string cString], stringLength);
		buffer[stringLength] = '\n';

		[self writeNBytes: stringLength + 1
		       fromBuffer: buffer];
	} @finally {
		[self freeMemory: buffer];
	}

	return stringLength + 1;
}

- (size_t)writeFormat: (OFString*)format, ...
{
	va_list arguments;
	size_t ret;

783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
						       selector: _cmd];

	if ((length = of_vasprintf(&cString, [format cString],
	    arguments)) == -1)
		@throw [OFInvalidFormatException newWithClass: isa];

	@try {
		return [self writeNBytes: length
			      fromBuffer: cString];
	} @finally {
		free(cString);
	}

	/* Get rid of a warning, never reached anyway */
	assert(0);
}

- (size_t)pendingBytes
{
	return cacheLength;
}








|
|




|
<







789
790
791
792
793
794
795
796
797
798
799
800
801
802

803
804
805
806
807
808
809
						       selector: _cmd];

	if ((length = of_vasprintf(&cString, [format cString],
	    arguments)) == -1)
		@throw [OFInvalidFormatException newWithClass: isa];

	@try {
		[self writeNBytes: length
		       fromBuffer: cString];
	} @finally {
		free(cString);
	}

	return length;

}

- (size_t)pendingBytes
{
	return cacheLength;
}