Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
hdr_parser.CppHeaderParser Class Reference
Inheritance diagram for hdr_parser.CppHeaderParser:

Public Member Functions

 __init__ (self)
 batch_replace (self, s, pairs)
 get_macro_arg (self, arg_str, npos)
 parse_arg (self, arg_str, argno)
 parse_enum (self, decl_str)
 parse_class_decl (self, decl_str)
 parse_func_decl_no_wrap (self, decl_str, static_method=False, docstring="")
 parse_func_decl (self, decl_str, docstring="")
 get_dotted_name (self, name)
 parse_stmt (self, stmt, end_token, docstring="")
 find_next_token (self, s, tlist, p=0)
 parse (self, hname, wmode=True)
 print_decls (self, decls)

Public Attributes

int BLOCK_TYPE = 0
int BLOCK_NAME = 1
int PROCESS_FLAG = 2
int PUBLIC_SECTION = 3
int CLASS_DECL = 4
 namespaces = set()
int lineno
 hname
 wrap_mode
list block_stack

Detailed Description

Definition at line 18 of file hdr_parser.py.

Constructor & Destructor Documentation

◆ __init__()

hdr_parser.CppHeaderParser.__init__ ( self)

Definition at line 20 of file hdr_parser.py.

Member Function Documentation

◆ batch_replace()

hdr_parser.CppHeaderParser.batch_replace ( self,
s,
pairs )

Definition at line 29 of file hdr_parser.py.

Referenced by parse_class_decl(), parse_func_decl(), and parse_stmt().

◆ find_next_token()

hdr_parser.CppHeaderParser.find_next_token ( self,
s,
tlist,
p = 0 )
Finds the next token from the 'tlist' in the input 's', starting from position 'p'.
Returns the first occurred token and its position, or ("", len(s)) when no token is found

Definition at line 736 of file hdr_parser.py.

Referenced by parse(), and parse_arg().

◆ get_dotted_name()

hdr_parser.CppHeaderParser.get_dotted_name ( self,
name )
adds the dot-separated container class/namespace names to the bare function/class name, e.g. when we have

namespace cv {
class A {
public:
    f(int);
};
}

the function will convert "A" to "cv.A" and "f" to "cv.A.f".

Definition at line 584 of file hdr_parser.py.

Referenced by parse_enum(), parse_func_decl(), and parse_stmt().

◆ get_macro_arg()

hdr_parser.CppHeaderParser.get_macro_arg ( self,
arg_str,
npos )

Definition at line 34 of file hdr_parser.py.

Referenced by parse_arg(), and parse_func_decl_no_wrap().

◆ parse()

hdr_parser.CppHeaderParser.parse ( self,
hname,
wmode = True )
The main method. Parses the input file.
Returns the list of declarations (that can be print using print_decls)

Definition at line 752 of file hdr_parser.py.

References block_stack, find_next_token(), hname, lineno, gen2.PythonWrapperGenerator.namespaces, gen_java.JavaWrapperGenerator.namespaces, namespaces, parse_stmt(), PROCESS_FLAG, and wrap_mode.

◆ parse_arg()

hdr_parser.CppHeaderParser.parse_arg ( self,
arg_str,
argno )
Parses <arg_type> [arg_name]
Returns arg_type, arg_name, modlist, argno, where
modlist is the list of wrapper-related modifiers (such as "output argument", "has counter", ...)
and argno is the new index of an anonymous argument.
That is, if no arg_str is just an argument type without argument name, the argument name is set to
"arg" + str(argno), and then argno is incremented.

Definition at line 54 of file hdr_parser.py.

References find_next_token(), get_macro_arg(), and lineno.

Referenced by parse_func_decl(), and parse_stmt().

◆ parse_class_decl()

hdr_parser.CppHeaderParser.parse_class_decl ( self,
decl_str )
Parses class/struct declaration start in the form:
   {class|struct} [CV_EXPORTS] <class_name> [: public <base_class1> [, ...]]
Returns class_name1, <list of base_classes>

Definition at line 224 of file hdr_parser.py.

References batch_replace().

Referenced by parse_stmt().

◆ parse_enum()

hdr_parser.CppHeaderParser.parse_enum ( self,
decl_str )

Definition at line 202 of file hdr_parser.py.

References get_dotted_name().

Referenced by parse_stmt().

◆ parse_func_decl()

hdr_parser.CppHeaderParser.parse_func_decl ( self,
decl_str,
docstring = "" )
Parses the function or method declaration in the form:
[[VISP_EXPORTS] <rettype>]
    [~]<function_name>
    (<arg_type1> <arg_name1>[=<default_value1>] [, <arg_type2> <arg_name2>[=<default_value2>] ...])
    [const] {; | <function_body>}

Returns the function declaration entry:
[<func name>, <return value C-type>, <list of modifiers>, <list of arguments>, <original return type>, <docstring>] (see above)

Definition at line 366 of file hdr_parser.py.

References batch_replace(), block_stack, get_dotted_name(), hname, lineno, parse_arg(), and wrap_mode.

Referenced by parse_stmt().

◆ parse_func_decl_no_wrap()

hdr_parser.CppHeaderParser.parse_func_decl_no_wrap ( self,
decl_str,
static_method = False,
docstring = "" )

Definition at line 252 of file hdr_parser.py.

References get_macro_arg().

◆ parse_stmt()

hdr_parser.CppHeaderParser.parse_stmt ( self,
stmt,
end_token,
docstring = "" )
parses the statement (ending with ';' or '}') or a block head (ending with '{')

The function calls parse_class_decl or parse_func_decl when necessary. It returns
<block_type>, <block_name>, <parse_flag>, <declaration>
where the first 3 values only make sense for blocks (i.e. code blocks, namespaces, classes, enums and such)

Definition at line 617 of file hdr_parser.py.

References batch_replace(), block_stack, BLOCK_TYPE, CLASS_DECL, get_dotted_name(), hname, lineno, parse_arg(), parse_class_decl(), parse_enum(), parse_func_decl(), PUBLIC_SECTION, and wrap_mode.

Referenced by parse().

◆ print_decls()

hdr_parser.CppHeaderParser.print_decls ( self,
decls )
Prints the list of declarations, retrieived by the parse() method

Definition at line 916 of file hdr_parser.py.

Member Data Documentation

◆ BLOCK_NAME

int hdr_parser.CppHeaderParser.BLOCK_NAME = 1

Definition at line 22 of file hdr_parser.py.

◆ block_stack

hdr_parser.CppHeaderParser.block_stack

Definition at line 597 of file hdr_parser.py.

Referenced by parse(), parse_func_decl(), and parse_stmt().

◆ BLOCK_TYPE

int hdr_parser.CppHeaderParser.BLOCK_TYPE = 0

Definition at line 21 of file hdr_parser.py.

Referenced by parse_stmt().

◆ CLASS_DECL

int hdr_parser.CppHeaderParser.CLASS_DECL = 4

Definition at line 25 of file hdr_parser.py.

Referenced by parse_stmt().

◆ hname

hdr_parser.CppHeaderParser.hname

Definition at line 151 of file hdr_parser.py.

Referenced by parse(), parse_func_decl(), and parse_stmt().

◆ lineno

hdr_parser.CppHeaderParser.lineno

Definition at line 37 of file hdr_parser.py.

Referenced by parse(), parse_arg(), parse_func_decl(), and parse_stmt().

◆ namespaces

hdr_parser.CppHeaderParser.namespaces = set()

Definition at line 27 of file hdr_parser.py.

Referenced by parse().

◆ PROCESS_FLAG

int hdr_parser.CppHeaderParser.PROCESS_FLAG = 2

Definition at line 23 of file hdr_parser.py.

Referenced by parse().

◆ PUBLIC_SECTION

int hdr_parser.CppHeaderParser.PUBLIC_SECTION = 3

Definition at line 24 of file hdr_parser.py.

Referenced by parse_stmt().

◆ wrap_mode

hdr_parser.CppHeaderParser.wrap_mode

Definition at line 486 of file hdr_parser.py.

Referenced by parse(), parse_func_decl(), and parse_stmt().