Ejemplo n.º 1
0
    def function_by_signature(self, name, returns, parameters):
        method = DocsMethod(0)
        method.name = name
        method.parameters = parameters
        method.syntax = name + "("
        for p in self.get_parameter_names(parameters):
            method.syntax = method.syntax + p + ", "
        method.syntax = method.syntax.rstrip(', ')
        method.syntax = method.syntax + ")"
        method.returns = returns
        method.new = True
        for function in self.function_list:
            if function.name == name:
                dst_parameters_types = self.get_parameter_types(function.parameters.replace('const ',''))
                src_parameters_types = self.get_parameter_types(parameters.replace('const ',''))

                if(len(src_parameters_types)==len(dst_parameters_types)):
                    a = -1
                    for i in range(len(src_parameters_types)):
                        if src_parameters_types[i] != dst_parameters_types[i]:
                            break
                        else:
                            a = i
                    if a == len(src_parameters_types)-1:
                        function.new = False
                        function.parameters = parameters
                        return function
                        
        self.function_list.append(method)   
        return method
Ejemplo n.º 2
0
    def function_by_signature(self, name, returns, parameters):
        method = DocsMethod(0)
        method.name = name
        method.parameters = parameters
        method.syntax = name + "("
        for p in self.get_parameter_names(parameters):
            method.syntax = method.syntax + p + ", "
        method.syntax = method.syntax.rstrip(', ')
        method.syntax = method.syntax + ")"
        method.returns = returns
        method.new = True
        found = False
        for function in self.function_list:
            if function.name == name:
                dst_parameters_types = self.get_parameter_types(function.parameters)
                src_parameters_types = self.get_parameter_types(parameters)

                if(len(src_parameters_types)==len(dst_parameters_types)):
                    a = -1
                    for i in range(len(src_parameters_types)):
                        if src_parameters_types[i] != dst_parameters_types[i]:
                            break
                        else:
                            a = i
                    if a == len(src_parameters_types)-1:
                        function.new = False
                        return function
                        found = True
                        #print 'found ' + function.name
                        break
        if not found:
            #print 'not found ' + method.name
            #clazzmethod = method
            self.function_list.append(method)   
        return method
Ejemplo n.º 3
0
def parse_function(element):
    if re.match('.*operator\s*\[\s*\]', element) is None:
        clean_element = remove_links(element)
    else:
        clean_element = element
    clean_element = html_encode_templates(clean_element)
    #print re.match('operator\b*\[\b*\]\b*\(.*\)',element) is None
    #print clean_element
    m = DocsMethod(0)
    function_name = ""
    function_return = ""
    function = clean_element.split('(')[0].lstrip(' ').rstrip(' ').split(' ')
    print str(function) + ": " + str(
        len(function)) + ": " + function[len(function) - 1]

    #print function
    if len(function) > 1:
        if element.find("operator") != -1 and len(function) > 2:
            function_name = function[len(function) -
                                     2] + function[len(function) - 1]
        else:
            function_name = function[len(function) - 1]
            print function_name
        for r in function[:len(function) - 1]:
            if r == 'static':
                m.static = True
                continue
            if r == 'operator':
                continue
            if r == 'virtual':
                continue

            function_return = function_return + " " + r
    else:
        function_name = function[0]
    #print clean_element

    if clean_element.rfind('const') > clean_element.rfind(')'):
        clean_element = clean_element[:clean_element.rfind('const')]
        m.constant = True

    function_parameters = clean_element.split('(')[1].strip('\n').strip(
        ' ').strip(')').strip(' ')

    m.name = function_name
    m.returns = function_return
    m.parameters = function_parameters
    m.syntax = function_name + "("
    for p in get_parameter_names(function_parameters):
        m.syntax = m.syntax + p + ", "
    m.syntax = m.syntax.rstrip(', ')
    m.syntax = m.syntax + ")"
    return m
Ejemplo n.º 4
0
def parse_function(element):
    if re.match('.*operator\s*\[\s*\]',element) is None: 
        clean_element = remove_links(element)
    else:
        clean_element = element
    clean_element = html_encode_templates(clean_element)
    #print re.match('operator\b*\[\b*\]\b*\(.*\)',element) is None
    #print clean_element
    m = DocsMethod(0)
    function_name = "" 
    function_return = ""
    function = clean_element.split('(')[0].lstrip(' ').rstrip(' ').split(' ')
    print str(function) + ": " + str(len(function)) + ": " + function[len(function)-1]
    
    #print function
    if len(function)>1:
        if element.find("operator")!=-1 and len(function)>2:
            function_name = function[len(function)-2] + function[len(function)-1]
        else:
            function_name = function[len(function)-1]
            print function_name
        for r in function[:len(function)-1]:
            if r == 'static':
                m.static = True
                continue
            if r == 'operator':
                continue
            if r == 'virtual':
                continue

            function_return = function_return + " " + r
    else:
        function_name = function[0]
    #print clean_element
    
    if clean_element.rfind('const') > clean_element.rfind(')'):
        clean_element = clean_element[:clean_element.rfind('const')]
        m.constant = True
        
    function_parameters = clean_element.split('(')[1].strip('\n').strip(' ').strip(')').strip(' ')
        
    m.name = function_name
    m.returns = function_return
    m.parameters = function_parameters
    m.syntax = function_name + "("
    for p in get_parameter_names(function_parameters):
        m.syntax = m.syntax + p + ", "
    m.syntax = m.syntax.rstrip(', ')
    m.syntax = m.syntax + ")"
    return m
Ejemplo n.º 5
0
 def function_by_signature(self, name, returns, parameters, alternatives,
                           already_found, fuzzy):
     method = DocsMethod(0)
     method.name = name
     method.parameters = parameters
     method.syntax = name + "("
     for p in self.get_parameter_names(parameters):
         method.syntax = method.syntax + p + ", "
     method.syntax = method.syntax.rstrip(', ')
     method.syntax = method.syntax + ")"
     method.returns = returns
     method.new = True
     for function in self.function_list:
         if function.name == name:
             dst_parameters_types = self.get_parameter_types(
                 function.parameters)
             src_parameters_types = self.get_parameter_types(parameters)
             if (len(src_parameters_types) == len(dst_parameters_types)):
                 a = -1
                 for i in range(len(src_parameters_types)):
                     if src_parameters_types[i] != dst_parameters_types[i]:
                         break
                     else:
                         a = i
                 if a == len(src_parameters_types
                             ) - 1 and function.returns == returns:
                     function.new = False
                     function.parameters = parameters
                     function.syntax = method.syntax
                     function.returns = method.returns
                     return function
     if fuzzy and len(alternatives) > 0:
         alternative_func = self.fuzzy_function_search(
             name, returns, parameters, alternatives, already_found)
         if alternative_func != None:
             alternative_func.parameters = method.parameters
             alternative_func.syntax = method.syntax
             alternative_func.returns = method.returns
             return alternative_func
         else:
             self.function_list.append(method)
             return method
     else:
         return None
Ejemplo n.º 6
0
 def function_by_signature(self, name, returns, parameters, alternatives, already_found, fuzzy):
     method = DocsMethod(0)
     method.name = name
     method.parameters = parameters
     method.syntax = name + "("
     for p in self.get_parameter_names(parameters):
         method.syntax = method.syntax + p + ", "
     method.syntax = method.syntax.rstrip(', ')
     method.syntax = method.syntax + ")"
     method.returns = returns
     method.new = True
     for function in self.function_list:
         if function.name == name:
             dst_parameters_types = self.get_parameter_types(function.parameters)
             src_parameters_types = self.get_parameter_types(parameters)
             if(len(src_parameters_types)==len(dst_parameters_types)):
                 a = -1
                 for i in range(len(src_parameters_types)):
                     if src_parameters_types[i] != dst_parameters_types[i]:
                         break
                     else:
                         a = i
                 if a == len(src_parameters_types)-1 and function.returns == returns:
                     function.new = False
                     function.parameters = parameters
                     function.syntax = method.syntax
                     function.returns = method.returns
                     return function
     if fuzzy and len(alternatives)>0:
         alternative_func = self.fuzzy_function_search(name, returns, parameters, alternatives, already_found)
         if alternative_func != None:        
             alternative_func.parameters = method.parameters
             alternative_func.syntax = method.syntax
             alternative_func.returns = method.returns
             return alternative_func
         else:
             self.function_list.append(method)
             return method
     else:
         return None