ObjFW  Diff

Differences From Artifact [f0a708441f]:

To Artifact [f695ac4fbd]:

  • File src/OFObject.m — part of check-in [06bcb21fc7] at 2017-01-09 06:26:04 on branch trunk — Add OFLocalization

    This singleton gives access to all things locale, including the ability
    to get localized strings.

    This also adds the OF_LOCALIZED() macro. Its first argument is an ID for
    the string to be localized and its second argument is the fallback
    string to be used if it cannot retrieve the localized string. Following
    that are variable name / value pairs to be replaced in the localized
    string.

    Getting translated strings is not implemented yet: Instead, it always
    uses the fallback string.

    This also switches ofhttp to localized strings. (user: js, size: 25077) [annotate] [blame] [check-ins using]


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

#include <assert.h>

#include <sys/time.h>

#import "OFObject.h"
#import "OFArray.h"
#import "OFSystemInfo.h"
#import "OFTimer.h"
#import "OFRunLoop.h"
#import "OFThread.h"

#import "OFAllocFailedException.h"
#import "OFEnumerationMutationException.h"
#import "OFInitializationFailedException.h"







|







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

#include <assert.h>

#include <sys/time.h>

#import "OFObject.h"
#import "OFArray.h"
#import "OFLocalization.h"
#import "OFTimer.h"
#import "OFRunLoop.h"
#import "OFThread.h"

#import "OFAllocFailedException.h"
#import "OFEnumerationMutationException.h"
#import "OFInitializationFailedException.h"
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114

#if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__)
static void
uncaughtExceptionHandler(id exception)
{
	OFString *description = [exception description];
	OFArray *backtrace = nil;
	of_string_encoding_t encoding = [OFSystemInfo native8BitEncoding];

	fprintf(stderr, "\nRuntime error: Unhandled exception:\n%s\n",
	    [description cStringWithEncoding: encoding]);

	if ([exception respondsToSelector: @selector(backtrace)])
		backtrace = [exception backtrace];








|







100
101
102
103
104
105
106
107
108
109
110
111
112
113
114

#if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__)
static void
uncaughtExceptionHandler(id exception)
{
	OFString *description = [exception description];
	OFArray *backtrace = nil;
	of_string_encoding_t encoding = [OFLocalization encoding];

	fprintf(stderr, "\nRuntime error: Unhandled exception:\n%s\n",
	    [description cStringWithEncoding: encoding]);

	if ([exception respondsToSelector: @selector(backtrace)])
		backtrace = [exception backtrace];

196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
	return instance;
}

const char*
_NSPrintForDebugger(id object)
{
	return [[object description]
	    cStringWithEncoding: [OFSystemInfo native8BitEncoding]];
}

/* References for static linking */
void
_references_to_categories_of_OFObject(void)
{
	_OFObject_KeyValueCoding_reference = 1;







|







196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
	return instance;
}

const char*
_NSPrintForDebugger(id object)
{
	return [[object description]
	    cStringWithEncoding: [OFLocalization encoding]];
}

/* References for static linking */
void
_references_to_categories_of_OFObject(void)
{
	_OFObject_KeyValueCoding_reference = 1;