-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWinRT_main.h
51 lines (46 loc) · 1.15 KB
/
WinRT_main.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
/// @file
/// @author Boris Mikic
/// @version 3.3
///
/// @section LICENSE
///
/// This program is free software; you can redistribute it and/or modify it under
/// the terms of the BSD license: http://www.opensource.org/licenses/bsd-license.php
///
/// @section DESCRIPTION
///
/// Defines main for WinRT.
#if defined(_WIN32) && defined(_WINRT) && !defined(_OPENKODE)
#ifndef APRIL_WINRT_MAIN_H
#define APRIL_WINRT_MAIN_H
#include "aprilExport.h"
#include <hltypes/harray.h>
#include <hltypes/hltypesUtil.h>
#include <hltypes/hstring.h>
#include "main_base.h"
#include "aprilExport.h"
[Platform::MTAThread]
int main(Platform::Array<Platform::String^>^ args)
{
// extract arguments
int argc = 0;
char** argv = new char*[argc];
hstr arg;
for_iter (i, 0, argc)
{
arg = hstr::from_unicode(args[i]->Data());
argv[i] = new char[arg.size() + 1];
memcpy(argv[i], arg.c_str(), sizeof(char) * (arg.size() + 1));
}
// call the user specified main function
int result = april_main(april_init, april_destroy, argc, argv);
// free allocated memory for arguments
for_iter (i, 0, argc)
{
delete [] argv[i];
}
delete [] argv;
return result;
}
#endif
#endif