This repository was archived by the owner on Aug 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.m
More file actions
64 lines (55 loc) · 1.48 KB
/
Copy pathmain.m
File metadata and controls
64 lines (55 loc) · 1.48 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// main.m
// python
//
// Created by YANG HONGBO on 2013-7-18.
// Copyright (c) 2013年 YANG HONGBO. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#import <Python.h>
#import "pythonmodules.h"
#import "twisted.h"
#import "zope_interface.h"
void init_python();
void unittest_python();
void init_python()
{
NSString * name = [[NSBundle mainBundle] bundleIdentifier];
Py_SetProgramName((char *)[name cStringUsingEncoding:NSUTF8StringEncoding]);
NSString * rootPath = [[NSBundle mainBundle] resourcePath];
Py_SetPythonHome((char *)[rootPath cStringUsingEncoding:NSUTF8StringEncoding]);
Py_OptimizeFlag = 1;
Py_Initialize();
// PyRun_SimpleString("import sys\n"
// "del sys.path[0]\n"
// "sys.path.append('')\n");
// initselect(); //unsupported on iOS ?
init_collections();
inititertools();
initoperator();
initarray();
init_struct();
init_io();
init_functools();
init_locale();
inittime();
init_socket();
initsendmsg();
initraiser();
init_zope_interface_coptimizations();
}
void unittest_python()
{
init_testcapi();//for unit_test
PyRun_SimpleString("from test.test___all__ import test_main as t\n"
"t()");
}
int main(int argc, char *argv[])
{
@autoreleasepool {
init_python();
unittest_python();
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}