本文整理汇总了Python中objc_generator.ObjCGenerator.objc_protocol_export_expression_for_variable方法的典型用法代码示例。如果您正苦于以下问题:Python ObjCGenerator.objc_protocol_export_expression_for_variable方法的具体用法?Python ObjCGenerator.objc_protocol_export_expression_for_variable怎么用?Python ObjCGenerator.objc_protocol_export_expression_for_variable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类objc_generator.ObjCGenerator
的用法示例。
在下文中一共展示了ObjCGenerator.objc_protocol_export_expression_for_variable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _generate_event_out_parameters
# 需要导入模块: from objc_generator import ObjCGenerator [as 别名]
# 或者: from objc_generator.ObjCGenerator import objc_protocol_export_expression_for_variable [as 别名]
def _generate_event_out_parameters(self, domain, event):
lines = []
lines.append(' RefPtr<InspectorObject> paramsObject = InspectorObject::create();')
for parameter in event.event_parameters:
keyed_set_method = CppGenerator.cpp_setter_method_for_type(parameter.type)
var_name = parameter.parameter_name
safe_var_name = '(*%s)' % var_name if parameter.is_optional else var_name
export_expression = ObjCGenerator.objc_protocol_export_expression_for_variable(parameter.type, safe_var_name)
if not parameter.is_optional:
lines.append(' paramsObject->%s(ASCIILiteral("%s"), %s);' % (keyed_set_method, parameter.parameter_name, export_expression))
else:
lines.append(' if (%s)' % (parameter.parameter_name))
lines.append(' paramsObject->%s(ASCIILiteral("%s"), %s);' % (keyed_set_method, parameter.parameter_name, export_expression))
lines.append(' jsonMessage->setObject(ASCIILiteral("params"), paramsObject);')
return lines
示例2: _generate_success_block_for_command
# 需要导入模块: from objc_generator import ObjCGenerator [as 别名]
# 或者: from objc_generator.ObjCGenerator import objc_protocol_export_expression_for_variable [as 别名]
def _generate_success_block_for_command(self, domain, command):
lines = []
if command.return_parameters:
success_block_parameters = []
for parameter in command.return_parameters:
objc_type = ObjCGenerator.objc_type_for_param(domain, command.command_name, parameter)
var_name = ObjCGenerator.identifier_to_objc_identifier(parameter.parameter_name)
success_block_parameters.append(join_type_and_name(objc_type, var_name))
lines.append(' id successCallback = ^(%s) {' % ', '.join(success_block_parameters))
else:
lines.append(' id successCallback = ^{')
if command.return_parameters:
lines.append(' Ref<InspectorObject> resultObject = InspectorObject::create();')
required_pointer_parameters = filter(lambda parameter: not parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type), command.return_parameters)
for parameter in required_pointer_parameters:
var_name = ObjCGenerator.identifier_to_objc_identifier(parameter.parameter_name)
lines.append(' THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(%s, @"%s");' % (var_name, var_name))
objc_array_class = ObjCGenerator.objc_class_for_array_type(parameter.type)
if objc_array_class and objc_array_class.startswith(ObjCGenerator.OBJC_PREFIX):
lines.append(' THROW_EXCEPTION_FOR_BAD_TYPE_IN_ARRAY(%s, [%s class]);' % (var_name, objc_array_class))
optional_pointer_parameters = filter(lambda parameter: parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type), command.return_parameters)
for parameter in optional_pointer_parameters:
var_name = ObjCGenerator.identifier_to_objc_identifier(parameter.parameter_name)
lines.append(' THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(%s, @"%s");' % (var_name, var_name))
objc_array_class = ObjCGenerator.objc_class_for_array_type(parameter.type)
if objc_array_class and objc_array_class.startswith(ObjCGenerator.OBJC_PREFIX):
lines.append(' THROW_EXCEPTION_FOR_BAD_TYPE_IN_OPTIONAL_ARRAY(%s, [%s class]);' % (var_name, objc_array_class))
for parameter in command.return_parameters:
keyed_set_method = CppGenerator.cpp_setter_method_for_type(parameter.type)
var_name = ObjCGenerator.identifier_to_objc_identifier(parameter.parameter_name)
var_expression = '*%s' % var_name if parameter.is_optional else var_name
export_expression = ObjCGenerator.objc_protocol_export_expression_for_variable(parameter.type, var_expression)
if not parameter.is_optional:
lines.append(' resultObject->%s(ASCIILiteral("%s"), %s);' % (keyed_set_method, parameter.parameter_name, export_expression))
else:
lines.append(' if (%s)' % var_name)
lines.append(' resultObject->%s(ASCIILiteral("%s"), %s);' % (keyed_set_method, parameter.parameter_name, export_expression))
lines.append(' backendDispatcher()->sendResponse(requestId, WTF::move(resultObject));')
else:
lines.append(' backendDispatcher()->sendResponse(requestId, InspectorObject::create());')
lines.append(' };')
return '\n'.join(lines)