from chc.app.CGEnumTag import CGEnumTag from chc.app.CGFunction import CGFunction from chc.app.CGType import CGType from chc.app.CGVarDecl import CGVarDecl from chc.app.CGVarDef import CGVarDef from chc.app.CLocation import CLocation from chc.app.CCompInfo import CCompInfo from chc.app.CEnumInfo import CEnumInfo from chc.app.CEnumItem import CEnumItem from chc.app.CFieldInfo import CFieldInfo from chc.app.CVarInfo import CVarInfo from chc.app.CTypeInfo import CTypeInfo initinfo_constructors = { 'single':lambda x:CI.CSingleInitInfo(*x), 'compound':lambda x:CI.CCompoundInitInfo(*x) } def table_to_string(title,d,headerlen=10): lines = [] lines.append('\n' + title) for k in sorted(d): lines.append (str(k).rjust(headerlen) + ' ' + str(d[k])) return '\n'.join(lines) class CFilename(CD.CDeclarationsRecord): def __init__(self,decls,index,tags,args): CD.CDeclarationsRecord.__init__(self,decls,index,tags,args)
def get_value(node): rep = IT.get_rep(node) args = (self,) + rep return CI.COffsetInitInfo(*args)
def f(index, key): return CI.COffsetInitInfo(self, index, [], args)
def f(index, key): return CI.CCompoundInitInfo(self, index, tags, args)
def f(index, key): return CI.CSingleInitInfo(self, index, tags, args)
def get_value(node: ET.Element) -> CI.COffsetInitInfo: rep = IT.get_rep(node) args = (self, ) + rep return CI.COffsetInitInfo(*args)
from chc.app.CGVarDef import CGVarDef from chc.app.CLocation import CLocation from chc.app.CCompInfo import CCompInfo from chc.app.CEnumInfo import CEnumInfo from chc.app.CEnumItem import CEnumItem from chc.app.CFieldInfo import CFieldInfo from chc.app.CVarInfo import CVarInfo from chc.app.CTypeInfo import CTypeInfo if TYPE_CHECKING: from chc.app.CFile import CFile initinfo_constructors: Dict[str, Callable[ [Tuple["CDeclarations", int, List[str], List[int]]], CI.CInitInfoBase]] = { "single": lambda x: CI.CSingleInitInfo(*x), "compound": lambda x: CI.CCompoundInitInfo(*x), } def table_to_string(title: str, d: Dict[Any, Any], headerlen: int = 10) -> str: lines = [] lines.append("\n" + title) for k in sorted(d): lines.append(str(k).rjust(headerlen) + " " + str(d[k])) return "\n".join(lines) class CFilename(CD.CDeclarationsRecord): def __init__(self, decls: CDeclarations, index: int, tags: List[str], args: List[int]):