将 EnumName/value/IsSigned 加入 FIELD_ROUTES,消除所有冗余 hasattr/getattr
This commit is contained in:
@@ -74,14 +74,14 @@ class ImportHandle(BaseHandle):
|
||||
if not asname or asname == name:
|
||||
# Check if this name is a CDefine constant in SymbolTable
|
||||
sym_info = self.Trans.SymbolTable.get(name)
|
||||
if sym_info and getattr(sym_info, 'IsDefine', None) and getattr(sym_info, 'DefineValue', None) is not None:
|
||||
if sym_info and sym_info.IsDefine and sym_info.DefineValue is not None:
|
||||
define_constants = vars(Gen).setdefault('_define_constants', {})
|
||||
if name not in define_constants:
|
||||
define_constants[name] = sym_info.DefineValue
|
||||
# Also check with module prefix
|
||||
for prefix_key in [f"{module}.{name}", name]:
|
||||
sym_info2 = self.Trans.SymbolTable.get(prefix_key)
|
||||
if sym_info2 and getattr(sym_info2, 'IsDefine', None) and getattr(sym_info2, 'DefineValue', None) is not None:
|
||||
if sym_info2 and sym_info2.IsDefine and sym_info2.DefineValue is not None:
|
||||
define_constants = vars(Gen).setdefault('_define_constants', {})
|
||||
if name not in define_constants:
|
||||
define_constants[name] = sym_info2.DefineValue
|
||||
@@ -893,7 +893,7 @@ class ImportHandle(BaseHandle):
|
||||
elif isinstance(value_node, ast.Name):
|
||||
if value_node.id in getattr(self.Trans, 'SymbolTable', {}):
|
||||
info = self.Trans.SymbolTable[value_node.id]
|
||||
if getattr(info, 'IsDefine', None) and getattr(info, 'DefineValue', None) is not None:
|
||||
if info.IsDefine and info.DefineValue is not None:
|
||||
return info.DefineValue
|
||||
elif isinstance(value_node, ast.Call):
|
||||
if isinstance(value_node.func, ast.Attribute):
|
||||
@@ -1020,7 +1020,7 @@ class ImportHandle(BaseHandle):
|
||||
ParamTypes = []
|
||||
is_method = is_class_method or '.__' in FuncName
|
||||
class_name_for_method = FuncName.split('.')[0] if '.' in FuncName else None
|
||||
class_is_cpython = class_name_for_method and class_name_for_method in self.Trans.SymbolTable and getattr(self.Trans.SymbolTable[class_name_for_method], 'IsCpythonObject', False)
|
||||
class_is_cpython = class_name_for_method and class_name_for_method in self.Trans.SymbolTable and self.Trans.SymbolTable[class_name_for_method].IsCpythonObject
|
||||
for i, Arg in enumerate(Node.args.args):
|
||||
if i == 0 and is_method:
|
||||
# self parameter of a method should always be a pointer to the struct
|
||||
|
||||
Reference in New Issue
Block a user