Exemplo n.º 1
0
 def __web_api_declaration(self, api):
     declaration = ''
     declaration += '- (void){0}'.format(
         string_utils.first_char_to_lower(api.alias))
     if len(api.input_var_list) > 0:
         if len(api.input_var_list) == 1:
             declaration += 'By'
         else:
             declaration += 'With'
         for i, input_var in enumerate(api.input_var_list):
             input_name = string_utils.to_objc_property_name(input_var.name)
             if i == 0:
                 input_name = string_utils.first_char_to_upper(input_name)
             declaration += '{0}:({1}){2} '.format(
                 input_name, input_var.var_type.to_objc_getter_string(),
                 string_utils.first_char_to_lower(input_name))
         declaration += 'success:(void (^)('
     else:
         declaration += 'Success:(void (^)('
     if len(api.output_var_list) > 0:
         for i, output_var in enumerate(api.output_var_list):
             declaration += output_var.var_type.to_objc_getter_string()
             declaration += string_utils.to_objc_property_name(
                 output_var.name)
             if i != len(api.output_var_list) - 1:
                 declaration += ', '
     declaration += '))successBlock failure:(void (^)(NSError *error))failureBlock'
     return declaration
Exemplo n.º 2
0
 def __web_api_declaration(self, api, config):
     declaration = ''
     declaration += '- (void){0}'.format(string_utils.first_char_to_lower(api.alias))
     if len(api.input_var_list) > 0:
             if len(api.input_var_list) == 1:
                 declaration += 'By'
             else:
                 declaration += 'With'
             for i, input_var in enumerate(api.input_var_list):
                 input_name = string_utils.to_objc_property_name(input_var.name)
                 if i == 0:
                     input_name = string_utils.first_char_to_upper(input_name)
                 declaration += '{0}:({1}){2} '.format(input_name,
                                                       input_var.var_type.to_objc_getter_string(config),
                                                       string_utils.first_char_to_lower(input_name))
             declaration += 'success:(void (^)('
     else:
         declaration += 'Success:(void (^)('
     if len(api.output_var_list) > 0:
         for i, output_var in enumerate(api.output_var_list):
             declaration += output_var.var_type.to_objc_getter_string(config)
             declaration += string_utils.to_objc_property_name(output_var.name)
             if i != len(api.output_var_list) - 1:
                 declaration += ', '
     declaration += '))successBlock failure:(void (^)(NSError *error))failureBlock'
     return declaration
Exemplo n.º 3
0
    def __init__(self, name, var_type_string):
        """Init JavaVariable with name and type string declares in VarType.

        Args:
            name: A string descries Variable name.
            var_type_string: A string declares in VarType.
        """
        var_type = VarType.instance_from_string(var_type_string)

        self.__name_str = to_objc_property_name(name)
        self.__title_style_name = to_title_style_name(name)
        self.__var_type = var_type
        self.__java_enum = ''
    def __init__(self, name, var_type_string):
        """Init JavaVariable with name and type string declares in VarType.

        Args:
            name: A string descries Variable name.
            var_type_string: A string declares in VarType.
        """
        var_type = VarType.instance_from_string(var_type_string)

        self.__name_str = to_objc_property_name(name)
        self.__title_style_name = to_title_style_name(name)
        self.__var_type = var_type
        self.__java_enum = ''
Exemplo n.º 5
0
    def generate_web_api_implementations(self, config):
        """Generates Objective-C++ web api implementations.

        Args:
            config: A <Config> object represents user-defined info.

        Returns:
            A string which is Objective-C++ web api implementations.
        """
        impl = ''
        for api in self.apis:
            impl += self.__web_api_declaration(api, config)
            impl += ' {\n'
            impl += string_utils.indent(2)
            impl += '_coreManagerHandler->\n'
            impl += string_utils.indent(2)
            impl += api.alias + '('
            for input_var in api.input_var_list:
                impl += input_var.cast_to_cpp_parameter()
                impl += ', '
            impl += '[successBlock, failureBlock](bool success, const std::string& errorUTF8String'
            for output_var in api.output_var_list:
                impl += ', {0}'.format(output_var.objc_wrapper_from_cpp_parameter(config))
            impl += ') {\n'
            impl += string_utils.indent(4)
            impl += 'if (success) {\n'
            for output_var in api.output_var_list:
                impl += output_var.objc_form_cpp_parameter(6, config)
                impl += _OBJC_BR

            impl += string_utils.indent(6)
            impl += 'successBlock('

            for i, output_var in enumerate(api.output_var_list):
                if i != 0:
                    impl += ', '
                impl += string_utils.to_objc_property_name(output_var.name)

            impl += ');\n'
            impl += string_utils.indent(4)
            impl += '} else {\n'
            impl += string_utils.indent(6)
            impl += 'NSString *error = [NSString stringWithUTF8String:errorUTF8String.c_str()];\n'
            impl += string_utils.indent(6)
            impl += 'failureBlock({0}(error));\n'.format(config.objc_error_method)
            impl += string_utils.indent(4)
            impl += '}\n'
            impl += string_utils.indent(2)
            impl += '});\n}'
            impl += _OBJC_BR
        return impl
    def __convert_bys_to_input_parameters(self, by_list):
        """Returns (taskId, username, displayName).

        Args:
            by_list: Where bys.

        Returns:
            A string which is like (taskId, username, displayName).
        """
        list = []
        list.append('mNativeHandler')
        for by in by_list:
            by = string_utils.to_objc_property_name(by)
            list.append(by)
        parameters = ', '.join(list)
        parameters = '({0})'.format(parameters)
        return parameters
    def __convert_bys_to_input_parameters(self, by_list):
        """Returns (taskId, username, displayName).

        Args:
            by_list: Where bys.

        Returns:
            A string which is like (taskId, username, displayName).
        """
        list = []
        list.append('mNativeHandler')
        for by in by_list:
            by = string_utils.to_objc_property_name(by)
            list.append(by)
        parameters = ', '.join(list)
        parameters = '({0})'.format(parameters)
        return parameters
Exemplo n.º 8
0
    def generate_web_api_implementations(self):
        impl = ''
        for api in self.apis:
            impl += self.__web_api_declaration(api)
            impl += ' {\n'
            impl += string_utils.indent(2)
            impl += '_coreManagerHandler->\n'
            impl += string_utils.indent(2)
            impl += api.alias + '('
            for input_var in api.input_var_list:
                impl += input_var.cast_to_cpp_parameter()
                impl += ', '
            impl += '[successBlock, failureBlock](bool success, const std::string& errorUTF8String'
            for output_var in api.output_var_list:
                impl += ', {0}'.format(
                    output_var.objc_wrapper_from_cpp_parameter())
            impl += ') {\n'
            impl += string_utils.indent(4)
            impl += 'if (success) {\n'
            for output_var in api.output_var_list:
                impl += output_var.objc_form_cpp_parameter(6)
                impl += _OBJC_BR

            impl += string_utils.indent(6)
            impl += 'successBlock('

            for i, output_var in enumerate(api.output_var_list):
                if i != 0:
                    impl += ', '
                impl += string_utils.to_objc_property_name(output_var.name)

            impl += ');\n'
            impl += string_utils.indent(4)
            impl += '} else {\n'
            impl += string_utils.indent(6)
            impl += 'NSString *error = [NSString stringWithUTF8String:errorUTF8String.c_str()];\n'
            impl += string_utils.indent(6)
            impl += 'failureBlock(LCCErrorWithNSString(error));\n'
            impl += string_utils.indent(4)
            impl += '}\n'
            impl += string_utils.indent(2)
            impl += '});\n}'
            impl += _OBJC_BR
        return impl
    def generate_web_api_implementations(self):
        impl = ''
        for api in self.apis:
            impl += self.__web_api_declaration(api)
            impl += ' {\n'
            impl += string_utils.indent(2)
            impl += '_coreManagerHandler->\n'
            impl += string_utils.indent(2)
            impl += api.alias + '('
            for input_var in api.input_var_list:
                impl += input_var.cast_to_cpp_parameter()
                impl += ', '
            impl += '[successBlock, failureBlock](bool success, const std::string& errorUTF8String'
            for output_var in api.output_var_list:
                impl += ', {0}'.format(output_var.objc_wrapper_from_cpp_parameter())
            impl += ') {\n'
            impl += string_utils.indent(4)
            impl += 'if (success) {\n'
            for output_var in api.output_var_list:
                impl += output_var.objc_form_cpp_parameter(6)
                impl += _OBJC_BR

            impl += string_utils.indent(6)
            impl += 'successBlock('

            for i, output_var in enumerate(api.output_var_list):
                if i != 0:
                    impl += ', '
                impl += string_utils.to_objc_property_name(output_var.name)

            impl += ');\n'
            impl += string_utils.indent(4)
            impl += '} else {\n'
            impl += string_utils.indent(6)
            impl += 'NSString *error = [NSString stringWithUTF8String:errorUTF8String.c_str()];\n'
            impl += string_utils.indent(6)
            impl += 'failureBlock(LCCErrorWithNSString(error));\n'
            impl += string_utils.indent(4)
            impl += '}\n'
            impl += string_utils.indent(2)
            impl += '});\n}'
            impl += _OBJC_BR
        return impl
Exemplo n.º 10
0
 def __objc_name(self):
     return string_utils.to_objc_property_name(self.name)
Exemplo n.º 11
0
 def to_param_style_name(self):
     """From 'display_name' to 'displayName'.
     """
     return string_utils.to_objc_property_name(self.__name)
 def to_param_style_name(self):
     return string_utils.to_objc_property_name(self.name)
 def to_param_style_name(self):
     return string_utils.to_objc_property_name(self.__name)
Exemplo n.º 14
0
 def to_param_style_name(self):
     """From 'display_name' to 'displayName'.
     """
     return string_utils.to_objc_property_name(self.__name)
 def __objc_name(self):
     return string_utils.to_objc_property_name(self.name)