GNUnet  0.11.x
Functions | Variables
find_typedefs Namespace Reference

Functions

def get_td_from_function_signature (line, file, num)
 
def get_td_from_simple_type (line, file, num)
 
def find_typedefs (file)
 
def scan_dir (d)
 

Variables

bool debug = False
 
 arg = os.getcwd()
 

Function Documentation

◆ get_td_from_function_signature()

def find_typedefs.get_td_from_function_signature (   line,
  file,
  num 
)

Definition at line 10 of file find_typedefs.py.

References len.

Referenced by find_typedefs().

10 def get_td_from_function_signature(line, file, num):
11  left_paren = line.find('(')
12  if left_paren > 0:
13  left_paren += 1
14  li = line[left_paren:]
15  right_paren = line.find(')')
16  if right_paren > 0 and right_paren > left_paren and line[
17  right_paren:].find('(') >= 0:
18  fname = line[:right_paren]
19  fname = fname.lstrip(' ').lstrip('*').lstrip(' ').rstrip(' ')
20  if len(fname) > 0:
21  if debug:
22  print("from {0}:{1}".format(file, num))
23  print("-T {0}".format(fname))
24 
25 
def get_td_from_function_signature(line, file, num)
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the caller graph for this function:

◆ get_td_from_simple_type()

def find_typedefs.get_td_from_simple_type (   line,
  file,
  num 
)

Definition at line 26 of file find_typedefs.py.

References len.

Referenced by find_typedefs().

26 def get_td_from_simple_type(line, file, num):
27  line = line.rstrip(' ').rstrip('\t').rstrip(' ').rstrip('\t')
28  right_space = line.rfind(' ')
29  right_tab = line.rfind('\t')
30  sep = right_tab if right_tab > right_space else right_space
31  sep += 1
32  tname = line[sep:]
33  tname = tname.lstrip('*')
34  if len(tname) > 0:
35  if debug:
36  print("from {0}:{1}".format(file, num))
37  print("-T {0}".format(tname))
38 
39 
def get_td_from_simple_type(line, file, num)
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the caller graph for this function:

◆ find_typedefs()

def find_typedefs.find_typedefs (   file)

Definition at line 40 of file find_typedefs.py.

References get_td_from_function_signature(), get_td_from_simple_type(), and len.

40 def find_typedefs(file):
41  with open(file, 'rb') as f:
42  td = False
43  td_struct = False
44  td_level = 0
45  td_line = []
46  data = f.read()
47  for i, l in enumerate(data.splitlines(False)):
48  # Don't try to be too smart: only count lines that begin with 'typedef '
49  l = l.rstrip(' ').rstrip('\t')
50  if len(l) == 0:
51  continue
52  if not td:
53  if l[:8] != 'typedef ':
54  continue
55  else:
56  td = True
57  if l[8:].lstrip(' ').lstrip('\t')[:6] == 'struct':
58  td_struct = True
59  if td_struct:
60  leftcbrace = l.find('{')
61  if leftcbrace >= 0:
62  if td_level == 0:
63  td_line.append(l[:leftcbrace])
64  l = l[leftcbrace + 1:]
65  td_level += 1
66  rightcbrace = l.rfind('}')
67  if rightcbrace >= 0:
68  td_level -= 1
69  if td_level == 0:
70  td_line.append(l[rightcbrace + 1:])
71  else:
72  td_line.append(l)
73  if len(l) > 0 and l[-1] == ';' and (not td_struct or td_level == 0):
74  td_line = ' '.join(td_line)
75  td_line = td_line[:-1]
76  if len(td_line) > 0:
77  if td_line[-1] == ')':
78  get_td_from_function_signature(td_line, file, i)
79  else:
80  get_td_from_simple_type(td_line, file, i)
81  td_line = []
82  td = False
83  td_struct = False
84  td_level = 0
85 
86 
def find_typedefs(file)
def get_td_from_function_signature(line, file, num)
def get_td_from_simple_type(line, file, num)
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:

◆ scan_dir()

def find_typedefs.scan_dir (   d)

Definition at line 87 of file find_typedefs.py.

References len.

87 def scan_dir(d):
88  for dirpath, dirs, files in os.walk(d):
89  for f in files:
90  if re.match(r'(?!lt_).+\.(c|cc|h)$', f):
91  file = os.path.join(dirpath, f)
92  find_typedefs(file)
93 
94 

Variable Documentation

◆ debug

bool find_typedefs.debug = False

Definition at line 7 of file find_typedefs.py.

Referenced by bus_call(), and gnunet_gst_bus_call().

◆ arg

find_typedefs.arg = os.getcwd()