ObjFW  Diff

Differences From Artifact [8447dff468]:

To Artifact [7d49a47280]:

  • File src/OFConstantString.m — part of check-in [3d16a30f41] at 2013-06-22 12:12:36 on branch trunk — Rework exceptions.

    This mostly removes the argument for the class in which the exception
    occurred. As backtraces were recently added for all platforms, the
    passed class does not give any extra information on where the exception
    occurred anymore.

    This also removes a few other arguments which were not too helpful. In
    the past, the idea was to pass as many arguments as possible so that it
    is easier to find the origin of the exception. However, as backtraces
    are a much better way to find the origin, those are not useful anymore
    and just make the exception more cumbersome to use. The rule is now to
    only pass arguments that might help in recovering from the exception or
    provide information that is otherwise not easily accessible. (user: js, size: 11937) [annotate] [blame] [check-ins using]


150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
		struct of_string_utf8_ivars *ivars;

		if (object_getClass(self) == [OFString_const class])
			return;

		if ((ivars = calloc(1, sizeof(*ivars))) == NULL)
			@throw [OFOutOfMemoryException
			    exceptionWithClass: [self class]
				 requestedSize: sizeof(*ivars)];

		ivars->cString = _cString;
		ivars->cStringLength = _cStringLength;

		switch (of_string_utf8_check(ivars->cString,
		    ivars->cStringLength,
			&ivars->length)) {
			case 1:
				ivars->isUTF8 = true;
				break;
			case -1:
				free(ivars);
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];
		}

		_cString = (char*)ivars;
		object_setClass(self, [OFString_const class]);
	}
}








<
|












|
<







150
151
152
153
154
155
156

157
158
159
160
161
162
163
164
165
166
167
168
169
170

171
172
173
174
175
176
177
		struct of_string_utf8_ivars *ivars;

		if (object_getClass(self) == [OFString_const class])
			return;

		if ((ivars = calloc(1, sizeof(*ivars))) == NULL)
			@throw [OFOutOfMemoryException

			    exceptionWithRequestedSize: sizeof(*ivars)];

		ivars->cString = _cString;
		ivars->cStringLength = _cStringLength;

		switch (of_string_utf8_check(ivars->cString,
		    ivars->cStringLength,
			&ivars->length)) {
			case 1:
				ivars->isUTF8 = true;
				break;
			case -1:
				free(ivars);
				@throw [OFInvalidEncodingException exception];

		}

		_cString = (char*)ivars;
		object_setClass(self, [OFString_const class]);
	}
}