Example #1
0
File: c.py Project: Cyofanni/speect
    def _get_signature_from_title(self, title):
        title_elements = []

        for i in title:
            if xml_extractor_re.match(str(i)):
                elements = xml_extractor_re.findall(str(i))
                title_elements.extend(elements)
            else:
                elements = str(i)
                title_elements.append(elements)
        
        signature = "".join(title_elements)

        # replace double spaces "  " with single space " "
        signature = re.sub("  ", " ", signature)

        # replace pointer space "* " with pointer "*"
        signature = re.sub("\* ", "*", signature)

        m = c_funcptr_sig_re.match(signature)
        if m is None:
            m = c_sig_re.match(signature)
        if m is None:
            raise ValueError('no match')
        rettype, name, arglist, const = m.groups()

        return arglist 
Example #2
0
File: c.py Project: Cyofanni/speect
    def parse_title(self, title):
        signature = self.get_signature_from_title(title)
        m = c_funcptr_sig_re.match(signature)
        if m is None:
            m = c_sig_re.match(signature)
        if m is None:
            raise ValueError('no match')
        rettype, name, arglist, const = m.groups()

        return rettype, name, arglist, const, signature
Example #3
0
    def handle_func_like_macro(self, sig, signode):
        u"""Handles signatures of function-like macros.

        If the objtype is 'function' and the the signature ``sig`` is a
        function-like macro, the name of the macro is returned. Otherwise
        ``False`` is returned.  """

        if not self.objtype == 'function':
            return False

        m = c_funcptr_sig_re.match(sig)  # pylint: disable=invalid-name
        if m is None:
            m = c_sig_re.match(sig)      # pylint: disable=invalid-name
            if m is None:
                raise ValueError('no match')

        rettype, fullname, arglist, _const = m.groups()
        arglist = arglist.strip()
        if rettype or not arglist:
            return False

        arglist = arglist.replace('`', '').replace('\\ ', '') # remove markup
        arglist = [a.strip() for a in arglist.split(",")]

        # has the first argument a type?
        if len(arglist[0].split(" ")) > 1:
            return False

        # This is a function-like macro, it's arguments are typeless!
        signode  += addnodes.desc_name(fullname, fullname)
        paramlist = addnodes.desc_parameterlist()
        signode  += paramlist

        for argname in arglist:
            param = addnodes.desc_parameter('', '', noemph=True)
            # separate by non-breaking space in the output
            param += nodes.emphasis(argname, argname)
            paramlist += param

        self.is_function_like_macro = True
        return fullname