当前位置: 首页>>代码示例>>Python>>正文


Python ObjCGenerator.identifier_to_objc_identifier方法代码示例

本文整理汇总了Python中objc_generator.ObjCGenerator.identifier_to_objc_identifier方法的典型用法代码示例。如果您正苦于以下问题:Python ObjCGenerator.identifier_to_objc_identifier方法的具体用法?Python ObjCGenerator.identifier_to_objc_identifier怎么用?Python ObjCGenerator.identifier_to_objc_identifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在objc_generator.ObjCGenerator的用法示例。


在下文中一共展示了ObjCGenerator.identifier_to_objc_identifier方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _generate_init_method_for_required_members

# 需要导入模块: from objc_generator import ObjCGenerator [as 别名]
# 或者: from objc_generator.ObjCGenerator import identifier_to_objc_identifier [as 别名]
    def _generate_init_method_for_required_members(self, domain, declaration, required_members):
        pairs = []
        for member in required_members:
            objc_type = self.objc_type_for_member(declaration, member)
            var_name = ObjCGenerator.identifier_to_objc_identifier(member.member_name)
            pairs.append('%s:(%s)%s' % (var_name, objc_type, var_name))
        pairs[0] = ucfirst(pairs[0])
        lines = []
        lines.append('- (instancetype)initWith%s' % ' '.join(pairs))
        lines.append('{')
        lines.append('    if (!(self = [super init]))')
        lines.append('        return nil;')
        lines.append('')

        required_pointer_members = filter(lambda member: ObjCGenerator.is_type_objc_pointer_type(member.type), required_members)
        if required_pointer_members:
            for member in required_pointer_members:
                var_name = ObjCGenerator.identifier_to_objc_identifier(member.member_name)
                lines.append('    THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(%s, @"%s");' % (var_name, var_name))
                objc_array_class = self.objc_class_for_array_type(member.type)
                if objc_array_class and objc_array_class.startswith(self.objc_prefix()):
                    lines.append('    THROW_EXCEPTION_FOR_BAD_TYPE_IN_ARRAY(%s, [%s class]);' % (var_name, objc_array_class))
            lines.append('')

        for member in required_members:
            var_name = ObjCGenerator.identifier_to_objc_identifier(member.member_name)
            lines.append('    self.%s = %s;' % (var_name, var_name))

        lines.append('')
        lines.append('    return self;')
        lines.append('}')
        return '\n'.join(lines)
开发者ID:caiolima,项目名称:webkit,代码行数:34,代码来源:generate_objc_protocol_types_implementation.py

示例2: _generate_event

# 需要导入模块: from objc_generator import ObjCGenerator [as 别名]
# 或者: from objc_generator.ObjCGenerator import identifier_to_objc_identifier [as 别名]
    def _generate_event(self, domain, event):
        lines = []
        lines.append(self._generate_event_signature(domain, event))
        lines.append('{')
        lines.append('    InspectorFrontendChannel* frontendChannel = _controller->frontendChannel();')
        lines.append('    if (!frontendChannel)')
        lines.append('        return;')
        lines.append('')

        required_pointer_parameters = filter(lambda parameter: not parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type), event.event_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))

        optional_pointer_parameters = filter(lambda parameter: parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type), event.event_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))

        if required_pointer_parameters or optional_pointer_parameters:
            lines.append('')

        lines.append('    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();')
        lines.append('    jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("%s.%s"));' % (domain.domain_name, event.event_name))
        if event.event_parameters:
            lines.extend(self._generate_event_out_parameters(domain, event))
        lines.append('    frontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());')
        lines.append('}')
        return '\n'.join(lines)
开发者ID:samcook88,项目名称:webkit,代码行数:31,代码来源:generate_objc_frontend_dispatcher_implementation.py

示例3: _generate_event

# 需要导入模块: from objc_generator import ObjCGenerator [as 别名]
# 或者: from objc_generator.ObjCGenerator import identifier_to_objc_identifier [as 别名]
    def _generate_event(self, domain, event):
        lines = []
        lines.append(self._generate_event_signature(domain, event))
        lines.append('{')
        lines.append('    const FrontendRouter& router = _controller->frontendRouter();')
        lines.append('')

        required_pointer_parameters = filter(lambda parameter: not parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type), event.event_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 = self.objc_class_for_array_type(parameter.type)
            if objc_array_class and objc_array_class.startswith(self.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), event.event_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 = self.objc_class_for_array_type(parameter.type)
            if objc_array_class and objc_array_class.startswith(self.objc_prefix()):
                lines.append('    THROW_EXCEPTION_FOR_BAD_TYPE_IN_OPTIONAL_ARRAY(%s, [%s class]);' % (var_name, objc_array_class))

        if required_pointer_parameters or optional_pointer_parameters:
            lines.append('')

        lines.append('    Ref<InspectorObject> jsonMessage = InspectorObject::create();')
        lines.append('    jsonMessage->setString(ASCIILiteral("method"), ASCIILiteral("%s.%s"));' % (domain.domain_name, event.event_name))
        if event.event_parameters:
            lines.extend(self._generate_event_out_parameters(domain, event))
        lines.append('    router.sendEvent(jsonMessage->toJSONString());')
        lines.append('}')
        return '\n'.join(lines)
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:35,代码来源:generate_objc_frontend_dispatcher_implementation.py

示例4: _generate_success_block_for_command

# 需要导入模块: from objc_generator import ObjCGenerator [as 别名]
# 或者: from objc_generator.ObjCGenerator import identifier_to_objc_identifier [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)
开发者ID:rhythmkay,项目名称:webkit,代码行数:50,代码来源:generate_objc_backend_dispatcher_implementation.py

示例5: _generate_init_method_for_payload

# 需要导入模块: from objc_generator import ObjCGenerator [as 别名]
# 或者: from objc_generator.ObjCGenerator import identifier_to_objc_identifier [as 别名]
    def _generate_init_method_for_payload(self, domain, declaration):
        lines = []
        lines.append('- (instancetype)initWithPayload:(nonnull NSDictionary<NSString *, id> *)payload')
        lines.append('{')
        lines.append('    if (!(self = [super init]))')
        lines.append('        return nil;')
        lines.append('')

        for member in declaration.type_members:
            member_name = member.member_name

            if not member.is_optional:
                lines.append('    THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"%s"], @"%s");' % (member_name, member_name))

            objc_type = self.objc_type_for_member(declaration, member)
            var_name = ObjCGenerator.identifier_to_objc_identifier(member_name)
            conversion_expression = self.payload_to_objc_expression_for_member(declaration, member)
            if isinstance(member.type, EnumType):
                lines.append('    std::optional<%s> %s = %s;' % (objc_type, var_name, conversion_expression))
                if not member.is_optional:
                    lines.append('    THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(%s, @"%s");' % (var_name, member_name))
                    lines.append('    self.%s = %s.value();' % (var_name, var_name))
                else:
                    lines.append('    if (%s)' % var_name)
                    lines.append('        self.%s = %s.value();' % (var_name, var_name))
            else:
                lines.append('    self.%s = %s;' % (var_name, conversion_expression))

            lines.append('')

        lines.append('    return self;')
        lines.append('}')
        return '\n'.join(lines)
开发者ID:mjparme,项目名称:openjdk-jfx,代码行数:35,代码来源:generate_objc_protocol_types_implementation.py

示例6: _generate_init_method_for_required_members

# 需要导入模块: from objc_generator import ObjCGenerator [as 别名]
# 或者: from objc_generator.ObjCGenerator import identifier_to_objc_identifier [as 别名]
 def _generate_init_method_for_required_members(self, domain, declaration, required_members):
     pairs = []
     for member in required_members:
         objc_type = ObjCGenerator.objc_type_for_member(declaration, member)
         var_name = ObjCGenerator.identifier_to_objc_identifier(member.member_name)
         pairs.append('%s:(%s)%s' % (var_name, objc_type, var_name))
     pairs[0] = ucfirst(pairs[0])
     return '- (instancetype)initWith%s;' % ' '.join(pairs)
开发者ID:B-Stefan,项目名称:webkit,代码行数:10,代码来源:generate_objc_header.py

示例7: _generate_setter_for_member

# 需要导入模块: from objc_generator import ObjCGenerator [as 别名]
# 或者: from objc_generator.ObjCGenerator import identifier_to_objc_identifier [as 别名]
 def _generate_setter_for_member(self, domain, declaration, member):
     objc_type = ObjCGenerator.objc_type_for_member(declaration, member)
     var_name = ObjCGenerator.identifier_to_objc_identifier(member.member_name)
     setter_method = ObjCGenerator.objc_setter_method_for_member(declaration, member)
     conversion_expression = ObjCGenerator.objc_to_protocol_expression_for_member(declaration, member, var_name)
     lines = []
     lines.append('- (void)set%s:(%s)%s' % (ucfirst(var_name), objc_type, var_name))
     lines.append('{')
     lines.append('    [super %s:%s forKey:@"%s"];' % (setter_method, conversion_expression, member.member_name))
     lines.append('}')
     return '\n'.join(lines)
开发者ID:samcook88,项目名称:webkit,代码行数:13,代码来源:generate_objc_protocol_types_implementation.py

示例8: _generate_getter_for_member

# 需要导入模块: from objc_generator import ObjCGenerator [as 别名]
# 或者: from objc_generator.ObjCGenerator import identifier_to_objc_identifier [as 别名]
 def _generate_getter_for_member(self, domain, declaration, member):
     objc_type = self.objc_type_for_member(declaration, member)
     var_name = ObjCGenerator.identifier_to_objc_identifier(member.member_name)
     getter_method = ObjCGenerator.objc_getter_method_for_member(declaration, member)
     basic_expression = '[super %s:@"%s"]' % (getter_method, member.member_name)
     conversion_expression = self.protocol_to_objc_expression_for_member(declaration, member, basic_expression)
     lines = []
     lines.append('- (%s)%s' % (objc_type, var_name))
     lines.append('{')
     lines.append('    return %s;' % conversion_expression)
     lines.append('}')
     return '\n'.join(lines)
开发者ID:caiolima,项目名称:webkit,代码行数:14,代码来源:generate_objc_protocol_types_implementation.py

示例9: _generate_setter_for_member

# 需要导入模块: from objc_generator import ObjCGenerator [as 别名]
# 或者: from objc_generator.ObjCGenerator import identifier_to_objc_identifier [as 别名]
 def _generate_setter_for_member(self, domain, declaration, member):
     objc_type = self.objc_type_for_member(declaration, member)
     var_name = ObjCGenerator.identifier_to_objc_identifier(member.member_name)
     setter_method = ObjCGenerator.objc_setter_method_for_member(declaration, member)
     conversion_expression = self.objc_to_protocol_expression_for_member(declaration, member, var_name)
     lines = []
     lines.append('- (void)set%s:(%s)%s' % (ucfirst(var_name), objc_type, var_name))
     lines.append('{')
     objc_array_class = self.objc_class_for_array_type(member.type)
     if objc_array_class and objc_array_class.startswith(self.objc_prefix()):
         lines.append('    THROW_EXCEPTION_FOR_BAD_TYPE_IN_ARRAY(%s, [%s class]);' % (var_name, objc_array_class))
     lines.append('    [super %s:%s forKey:@"%s"];' % (setter_method, conversion_expression, member.member_name))
     lines.append('}')
     return '\n'.join(lines)
开发者ID:caiolima,项目名称:webkit,代码行数:16,代码来源:generate_objc_protocol_types_implementation.py

示例10: _generate_member_property

# 需要导入模块: from objc_generator import ObjCGenerator [as 别名]
# 或者: from objc_generator.ObjCGenerator import identifier_to_objc_identifier [as 别名]
 def _generate_member_property(self, declaration, member):
     accessor_type = ObjCGenerator.objc_accessor_type_for_member(member)
     objc_type = ObjCGenerator.objc_type_for_member(declaration, member)
     return '@property (nonatomic, %s) %s;' % (accessor_type, join_type_and_name(objc_type, ObjCGenerator.identifier_to_objc_identifier(member.member_name)))
开发者ID:B-Stefan,项目名称:webkit,代码行数:6,代码来源:generate_objc_header.py


注:本文中的objc_generator.ObjCGenerator.identifier_to_objc_identifier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。