资源简介
libX11的一个支持包,具体用法见《交叉编译libX11》http://write.blog.csdn.net/postedit/42028985
代码片段和文件信息
#!/usr/bin/env python
from xml.etree.cElementTree import *
from os.path import basename
from functools import reduce
import getopt
import sys
import re
# Jump to the bottom of this file for the main routine
# Some hacks to make the API more readable and to keep backwards compability
_cname_re = re.compile(‘([A-Z0-9][a-z]+|[A-Z0-9]+(?![a-z])|[a-z]+)‘)
_cname_special_cases = {‘DECnet‘:‘decnet‘}
_extension_special_cases = [‘XPrint‘ ‘XCMisc‘ ‘BigRequests‘]
_cplusplus_annoyances = {‘class‘ : ‘_class‘
‘new‘ : ‘_new‘
‘delete‘: ‘_delete‘}
_c_keywords = {‘default‘ : ‘_default‘}
_hlines = []
_hlevel = 0
_clines = []
_clevel = 0
_ns = None
# global variable to keep track of serializers and
# switch data types due to weird dependencies
finished_serializers = []
finished_sizeof = []
finished_switch = []
def _h(fmt *args):
‘‘‘
Writes the given line to the header file.
‘‘‘
_hlines[_hlevel].append(fmt % args)
def _c(fmt *args):
‘‘‘
Writes the given line to the source file.
‘‘‘
_clines[_clevel].append(fmt % args)
def _hc(fmt *args):
‘‘‘
Writes the given line to both the header and source files.
‘‘‘
_h(fmt *args)
_c(fmt *args)
# XXX See if this level thing is really necessary.
def _h_setlevel(idx):
‘‘‘
Changes the array that header lines are written to.
Supports writing different sections of the header file.
‘‘‘
global _hlevel
while len(_hlines) <= idx:
_hlines.append([])
_hlevel = idx
def _c_setlevel(idx):
‘‘‘
Changes the array that source lines are written to.
Supports writing to different sections of the source file.
‘‘‘
global _clevel
while len(_clines) <= idx:
_clines.append([])
_clevel = idx
def _n_item(str):
‘‘‘
Does C-name conversion on a single string fragment.
Uses a regexp with some hard-coded special cases.
‘‘‘
if str in _cname_special_cases:
return _cname_special_cases[str]
else:
split = _cname_re.finditer(str)
name_parts = [match.group(0) for match in split]
return ‘_‘.join(name_parts)
def _cpp(str):
‘‘‘
Checks for certain C++ reserved words and fixes them.
‘‘‘
if str in _cplusplus_annoyances:
return _cplusplus_annoyances[str]
elif str in _c_keywords:
return _c_keywords[str]
else:
return str
def _ext(str):
‘‘‘
Does C-name conversion on an extension name.
Has some additional special cases on top of _n_item.
‘‘‘
if str in _extension_special_cases:
return _n_item(str).lower()
else:
return str.lower()
def _n(list):
‘‘‘
Does C-name conversion on a tuple of strings.
Different behavior depending on length of tuple extension/not extension etc.
Basically C-name converts the individual pieces then joins with underscores.
‘‘‘
if len(list) == 1:
parts = list
e
评论
共有 条评论