ObjFW  Check-in [dcea3bad47]

Overview
Comment:Make OF_APPLICATION_DELEGATE() work with -mwindows
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: dcea3bad47af67baf7850d5ed385d3aa9437cad145e4fe2b4d9e171c4cdbd98e
User & Date: js on 2024-05-05 12:33:16
Other Links: manifest | tags
References
2024-05-06
21:14 Fixed ticket [bdfd9cfc9d]: Support `-mwindows` / `WinMain` on Windows plus 4 other changes artifact: 8c6da43dfc user: js
Context
2024-05-05
19:04
OFStdIOStream: Add special case for column 0 check-in: 1c2fe75e6e user: js tags: trunk
18:59
Add OFGameController check-in: a0f4283e81 user: js tags: gamecontroller
12:33
Make OF_APPLICATION_DELEGATE() work with -mwindows check-in: dcea3bad47 user: js tags: trunk
12:15
Increase ObjFW library minor version check-in: ab1d9b0ecb user: js tags: trunk
Changes

Modified src/OFApplication.h from [757b90a7e1] to [f42b12f4e5].

17
18
19
20
21
22
23




24
25
26
27
28
29
30
 * <https://www.gnu.org/licenses/>.
 */

#include <signal.h>

#import "OFObject.h"
#import "OFNotification.h"





OF_ASSUME_NONNULL_BEGIN

/** @file */

@class OFArray OF_GENERIC(ObjectType);
@class OFDictionary OF_GENERIC(KeyType, ObjectType);







>
>
>
>







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 * <https://www.gnu.org/licenses/>.
 */

#include <signal.h>

#import "OFObject.h"
#import "OFNotification.h"

#ifdef OF_WINDOWS
# include <windows.h>
#endif

OF_ASSUME_NONNULL_BEGIN

/** @file */

@class OFArray OF_GENERIC(ObjectType);
@class OFDictionary OF_GENERIC(KeyType, ObjectType);
64
65
66
67
68
69
70

71
72
73
74
75
76
77

























78
79
80
81
82
83
84
 * - (void)applicationDidFinishLaunching: (OFNotification *)notification
 * {
 *         [OFApplication terminate];
 * }
 * @end
 * @endcode
 */

#define OF_APPLICATION_DELEGATE(class_)			\
	int						\
	main(int argc, char *argv[])			\
	{						\
		return OFApplicationMain(&argc, &argv,	\
		    (class_ *)[[class_ alloc] init]);	\
	}


























#ifdef OF_HAVE_PLEDGE
# define OF_HAVE_SANDBOX
#endif

/**
 * @protocol OFApplicationDelegate OFApplication.h ObjFW/OFApplication.h







>
|






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
106
107
108
109
110
111
112
113
114
 * - (void)applicationDidFinishLaunching: (OFNotification *)notification
 * {
 *         [OFApplication terminate];
 * }
 * @end
 * @endcode
 */
#ifndef OF_WINDOWS
# define OF_APPLICATION_DELEGATE(class_)		\
	int						\
	main(int argc, char *argv[])			\
	{						\
		return OFApplicationMain(&argc, &argv,	\
		    (class_ *)[[class_ alloc] init]);	\
	}
#else
# define OF_APPLICATION_DELEGATE(class_)				\
	int								\
	main(int argc, char *argv[])					\
	{								\
		return OFApplicationMain(&argc, &argv,			\
		    (class_ *)[[class_ alloc] init]);			\
	}								\
									\
	WINAPI int							\
	WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,		\
	    LPSTR lpCmdLine, int nShowCmd)				\
	{								\
		extern void __getmainargs(int *, char ***, char ***,	\
		    int, int *);					\
		extern int _CRT_glob;					\
		int argc = 0, si = 0;					\
		char **argv = NULL, **envp = NULL;			\
									\
		__getmainargs(&argc, &argv, &envp, _CRT_glob, &si);	\
									\
		return OFApplicationMain(&argc, &argv,			\
		    (class_ *)[[class_ alloc] init]);			\
	}
#endif

#ifdef OF_HAVE_PLEDGE
# define OF_HAVE_SANDBOX
#endif

/**
 * @protocol OFApplicationDelegate OFApplication.h ObjFW/OFApplication.h

Modified src/OFApplication.m from [a1d7561a5b] to [87fd78d98e].

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"

#if defined(OF_MACOS)
# include <crt_externs.h>
#elif defined(OF_WINDOWS)
# include <windows.h>
extern int _CRT_glob;
extern void __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *);
#elif defined(OF_AMIGAOS)
# define Class IntuitionClass
# include <proto/exec.h>
# include <proto/dos.h>
# undef Class
#elif !defined(OF_IOS)
extern char **environ;







<
<







52
53
54
55
56
57
58


59
60
61
62
63
64
65
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"

#if defined(OF_MACOS)
# include <crt_externs.h>
#elif defined(OF_WINDOWS)
# include <windows.h>


#elif defined(OF_AMIGAOS)
# define Class IntuitionClass
# include <proto/exec.h>
# include <proto/dos.h>
# undef Class
#elif !defined(OF_IOS)
extern char **environ;
123
124
125
126
127
128
129



130
131
132
133
134
135
136
{
	[OFLocale currentLocale];

	app = [[OFApplication alloc] of_init];

#ifdef OF_WINDOWS
	if ([OFSystemInfo isWindowsNT]) {



		wchar_t **wargv, **wenvp;
		int wargc, si = 0;

		__wgetmainargs(&wargc, &wargv, &wenvp, _CRT_glob, &si);

		[app of_setArgumentCount: argc
		       andArgumentValues: argv







>
>
>







121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
{
	[OFLocale currentLocale];

	app = [[OFApplication alloc] of_init];

#ifdef OF_WINDOWS
	if ([OFSystemInfo isWindowsNT]) {
		extern void __wgetmainargs(int *, wchar_t ***, wchar_t ***, int,
		    int *);
		extern int _CRT_glob;
		wchar_t **wargv, **wenvp;
		int wargc, si = 0;

		__wgetmainargs(&wargc, &wargv, &wenvp, _CRT_glob, &si);

		[app of_setArgumentCount: argc
		       andArgumentValues: argv