本文整理汇总了Python中objc_generator.ObjCGenerator.objc_protocol_import_expression_for_parameter方法的典型用法代码示例。如果您正苦于以下问题:Python ObjCGenerator.objc_protocol_import_expression_for_parameter方法的具体用法?Python ObjCGenerator.objc_protocol_import_expression_for_parameter怎么用?Python ObjCGenerator.objc_protocol_import_expression_for_parameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类objc_generator.ObjCGenerator
的用法示例。
在下文中一共展示了ObjCGenerator.objc_protocol_import_expression_for_parameter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _generate_conversions_for_command
# 需要导入模块: from objc_generator import ObjCGenerator [as 别名]
# 或者: from objc_generator.ObjCGenerator import objc_protocol_import_expression_for_parameter [as 别名]
def _generate_conversions_for_command(self, domain, command):
lines = []
if command.call_parameters:
lines.append("")
def in_param_expression(param_name, parameter):
_type = parameter.type
if isinstance(_type, AliasedType):
_type = _type.aliased_type # Fall through to enum or primitive.
if isinstance(_type, EnumType):
_type = _type.primitive_type # Fall through to primitive.
if isinstance(_type, PrimitiveType):
if _type.raw_name() in ["array", "any", "object"]:
return "&%s" % param_name if not parameter.is_optional else param_name
return "*%s" % param_name if parameter.is_optional else param_name
return "&%s" % param_name if not parameter.is_optional else param_name
for parameter in command.call_parameters:
in_param_name = "in_%s" % parameter.parameter_name
objc_in_param_name = "o_%s" % in_param_name
objc_type = ObjCGenerator.objc_type_for_param(domain, command.command_name, parameter, False)
param_expression = in_param_expression(in_param_name, parameter)
import_expression = ObjCGenerator.objc_protocol_import_expression_for_parameter(
param_expression, domain, command.command_name, parameter
)
if not parameter.is_optional:
lines.append(" %s = %s;" % (join_type_and_name(objc_type, objc_in_param_name), import_expression))
else:
lines.append(" %s;" % join_type_and_name(objc_type, objc_in_param_name))
lines.append(" if (%s)" % in_param_name)
lines.append(" %s = %s;" % (objc_in_param_name, import_expression))
if lines:
lines.append("")
return "\n".join(lines)
示例2: _generate_conversions_for_command
# 需要导入模块: from objc_generator import ObjCGenerator [as 别名]
# 或者: from objc_generator.ObjCGenerator import objc_protocol_import_expression_for_parameter [as 别名]
def _generate_conversions_for_command(self, domain, command):
lines = []
if command.call_parameters:
lines.append('')
def in_param_expression(param_name, parameter):
_type = parameter.type
if isinstance(_type, AliasedType):
_type = _type.aliased_type # Fall through to enum or primitive.
if isinstance(_type, EnumType):
_type = _type.primitive_type # Fall through to primitive.
if isinstance(_type, PrimitiveType):
return '*%s' % param_name if parameter.is_optional else param_name
return '%s.copyRef()' % param_name
for parameter in command.call_parameters:
in_param_name = 'in_%s' % parameter.parameter_name
objc_in_param_name = 'o_%s' % in_param_name
objc_type = ObjCGenerator.objc_type_for_param(domain, command.command_name, parameter, False)
param_expression = in_param_expression(in_param_name, parameter)
import_expression = ObjCGenerator.objc_protocol_import_expression_for_parameter(param_expression, domain, command.command_name, parameter)
if not parameter.is_optional:
lines.append(' %s = %s;' % (join_type_and_name(objc_type, objc_in_param_name), import_expression))
else:
lines.append(' %s;' % join_type_and_name(objc_type, objc_in_param_name))
lines.append(' if (%s)' % in_param_name)
lines.append(' %s = %s;' % (objc_in_param_name, import_expression))
if lines:
lines.append('')
return '\n'.join(lines)
示例3: _generate_conversions_for_command
# 需要导入模块: from objc_generator import ObjCGenerator [as 别名]
# 或者: from objc_generator.ObjCGenerator import objc_protocol_import_expression_for_parameter [as 别名]
def _generate_conversions_for_command(self, domain, command):
lines = []
if command.call_parameters:
lines.append('')
for parameter in command.call_parameters:
in_param_name = 'in_%s' % parameter.parameter_name
objc_in_param_name = 'o_%s' % in_param_name
objc_type = ObjCGenerator.objc_type_for_param(domain, command.command_name, parameter, False)
in_param_optional_safe_name = '*%s' % in_param_name if parameter.is_optional else in_param_name
import_expression = ObjCGenerator.objc_protocol_import_expression_for_parameter(in_param_optional_safe_name, domain, command.command_name, parameter)
if not parameter.is_optional:
lines.append(' %s = %s;' % (join_type_and_name(objc_type, objc_in_param_name), import_expression))
else:
lines.append(' %s;' % join_type_and_name(objc_type, objc_in_param_name))
lines.append(' if (%s)' % in_param_name)
lines.append(' %s = %s;' % (objc_in_param_name, import_expression))
if lines:
lines.append('')
return '\n'.join(lines)