-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcci2ccx.py
executable file
·80 lines (63 loc) · 2.25 KB
/
cci2ccx.py
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python
#
# Copyright (C) 2012 LVK labs
#
# This file is part of LVK cci2ccx tool.
#
# LVK cci2ccx is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# LVK cci2ccx is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LVK cci2ccx. If not, see <http://www.gnu.org/licenses/>.
import argparse
from os.path import basename
from parseObjc import ParseObjc
from translator import CppTranslate
def write_file(filename, content):
f = open(filename, 'w')
f.write(content)
f.close()
def read_file(filepath):
f = open(filepath, 'r')
content = f.read()
f.close()
return content
if __name__ == '__main__':
#opt_parser = optparse.OptionParser()
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument("-hh", "--header", dest="header",
help="header file")
arg_parser.add_argument("-src", "--source", dest="source",
help="source file, must provide one")
arg_parser.add_argument("-o", "--path", dest="opath",
help="TODO: Path to output files")
args = arg_parser.parse_args()
if not args.source:
exit("not source indicated, \n please use -h to more help")
#source_file = args.source
source = read_file(args.source)
header_file_name = basename(args.header)
#header_file = args.header
header = read_file(args.header)
parserObjc = ParseObjc()
parserObjc.parse_source(source)
parserObjc.parse_header(header)
ptc = CppTranslate(parserObjc)
ptc.set_header_name(header_file_name)
header = ptc.construct_header()
source = ptc.construct_source()
#Just for testing right now
write_file(args.source + '.translated.cpp', source)
write_file(args.header + '.translated.h', header)
'''
To test try to run this code :
python cci2ccx.py --source examples/EndLevelScene.m \
--header examples/EndLevelScene.h
'''