资源简介
c++代码生成器,用python写得
代码片段和文件信息
#!/usr/bin/env python
#=======================================================================
# Copyright (C) 2013 William Hallahan
#
# Permission is hereby granted free of charge to any person
# obtaining a copy of this software and associated documentation
# files (the “Software“) to deal in the Software without restriction
# including without limitation the rights to use copy modify merge
# publish distribute sublicense and/or sell copies of the Software
# and to permit persons to whom the Software is furnished to do so
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED “AS IS“ WITHOUT WARRANTY OF ANY KIND
# EXPRESS OR IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER LIABILITY
# WHETHER IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING
# FROM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#=======================================================================
import time
from type_info import TypeInfo
from type_and_name_info import TypeAndNameInfo
from function_info import FunctionInfo
from bparse import Bparse
def get_date_and_year():
now = time.ctime()
now_list = now.split()
time_list = now_list[3].split(‘:‘)
day_of_week = now_list[0]
month = now_list[1]
day_number = now_list[2]
year = now_list[4]
date = ‘{0} {1} {2}‘.format(month day_number year)
return date year
def create_cpp_class_files(input_file_name
class_name
base_class
author
full_header
abstract_class):
“““ Create class files. “““
# Generate all of the class name strings.
if not author:
author = ‘William Hallahan‘
class_definition_file_name = ‘{0}.h‘.format(class_name)
class_implementation_file_name = ‘{0}.cpp‘.format(class_name)
conditional_include_name_text = ‘{0}_H‘.format(class_name)
conditional_include_name_text = conditional_include_name_text.upper()
# Open the input file.
with open(input_file_name ‘r‘) as input_file:
# Create a parser.
parser = Bparse(input_file)
# Parse the input file.
data_member_type_and_name_info_list = []
definition_class_name_set = set()
implementation_class_name_set = set()
function_info_list = []
parse_success_status = True
exception_line_number = 0
try:
parser.parse(data_member_type_and_name_info_list
definition_class_name_set
impl
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-04-21 23:09 make_cpp_class\
文件 20388 2013-10-16 23:23 make_cpp_class\bclass.py
目录 0 2015-04-21 23:11 __MACOSX\
目录 0 2015-04-21 23:11 __MACOSX\make_cpp_class\
文件 212 2013-10-16 23:23 __MACOSX\make_cpp_class\._bclass.py
文件 53486 2013-10-19 21:36 make_cpp_class\bparse.py
文件 212 2013-10-19 21:36 __MACOSX\make_cpp_class\._bparse.py
文件 1877 2013-10-12 23:20 make_cpp_class\file_buffer.py
文件 212 2013-10-12 23:20 __MACOSX\make_cpp_class\._file_buffer.py
文件 19486 2013-10-16 01:06 make_cpp_class\function_info.py
文件 212 2013-10-16 01:06 __MACOSX\make_cpp_class\._function_info.py
文件 5422 2013-10-12 23:20 make_cpp_class\include_file_manager.py
文件 212 2013-10-12 23:20 __MACOSX\make_cpp_class\._include_file_manager.py
文件 12419 2013-10-20 18:47 make_cpp_class\make_cpp_class.py
文件 212 2013-10-20 18:47 __MACOSX\make_cpp_class\._make_cpp_class.py
文件 1277 2013-09-20 21:49 make_cpp_class\test_input.txt
文件 212 2013-09-20 21:49 __MACOSX\make_cpp_class\._test_input.txt
文件 2904 2013-10-16 01:06 make_cpp_class\type_and_name_info.py
文件 212 2013-10-16 01:06 __MACOSX\make_cpp_class\._type_and_name_info.py
文件 5065 2013-10-16 01:10 make_cpp_class\type_info.py
文件 212 2013-10-16 01:10 __MACOSX\make_cpp_class\._type_info.py
文件 212 2015-04-21 23:09 __MACOSX\._make_cpp_class
评论
共有 条评论