ObjFW  Diff

Differences From Artifact [a61bf65bf6]:

To Artifact [b6816d93b0]:


18
19
20
21
22
23
24









25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41























































#include "config.h"

#include <stdio.h>
#include <stdlib.h>

#include "ObjFWRT.h"
#include "private.h"










static objc_enumeration_mutation_handler_t enumerationMutationHandler = NULL;

void
objc_enumerationMutation(id object)
{
	if (enumerationMutationHandler != NULL)
		enumerationMutationHandler(object);
	else
		OBJC_ERROR("Object was mutated during enumeration!");
}

void
objc_setEnumerationMutationHandler(objc_enumeration_mutation_handler_t handler)
{
	enumerationMutationHandler = handler;
}






























































>
>
>
>
>
>
>
>
>

















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "config.h"

#include <stdio.h>
#include <stdlib.h>

#include "ObjFWRT.h"
#include "private.h"

#ifdef OF_AMIGAOS
# define USE_INLINE_STDARG
# include <proto/exec.h>
# include <clib/debug_protos.h>
# define __NOLIBBASE__
# include <proto/intuition.h>
# undef __NOLIBBASE__
#endif

static objc_enumeration_mutation_handler_t enumerationMutationHandler = NULL;

void
objc_enumerationMutation(id object)
{
	if (enumerationMutationHandler != NULL)
		enumerationMutationHandler(object);
	else
		OBJC_ERROR("Object was mutated during enumeration!");
}

void
objc_setEnumerationMutationHandler(objc_enumeration_mutation_handler_t handler)
{
	enumerationMutationHandler = handler;
}

void
objc_error(const char *file, unsigned int line, const char *format, ...)
{
#ifdef OF_AMIGAOS
# define BUF_LEN 256
	char title[BUF_LEN];
	char message[BUF_LEN];
	int status;
	va_list args;
	struct Library *IntuitionBase;

	status = snprintf(title, BUF_LEN, "ObjFWRT @ %s:%u", file, line);
	if (status <= 0 || status >= BUF_LEN)
		title[0] = '\0';

	va_start(args, format);
	status = vsnprintf(message, BUF_LEN, format, args);
	if (status <= 0 || status >= BUF_LEN)
		message[0] = '\0';
	va_end(args);

	kprintf("[%s] %s\n", title, message);

	IntuitionBase = OpenLibrary("intuition.library", 0);
	if (IntuitionBase != NULL) {
		struct EasyStruct easy = {
			.es_StructSize = sizeof(easy),
			.es_Flags = 0,
			.es_Title = (UBYTE *)title,
			.es_TextFormat = (UBYTE *)"%s",
			(UBYTE *)"OK"
		};

		EasyRequest(NULL, &easy, NULL, (ULONG)message);

		CloseLibrary(IntuitionBase);
	}
# undef BUF_LEN
#else
	va_list args;

	va_start(args, format);

	vfprintf(stderr, "[ObjFWRT @ %s:%u] ", file, line);
	vfprintf(stderr, format, args);
	vfprintf(stderr, "\n");
	fflush(stderr);

	va_end(args);
#endif
	abort();

	OF_UNREACHABLE
}