Skip to content

Commit

Permalink
Prefix internal methods with _ to make docs easier to grok
Browse files Browse the repository at this point in the history
  • Loading branch information
virtuald committed Sep 25, 2019
1 parent 22d7160 commit d19d93b
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions CppHeaderParser/CppHeaderParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2049,7 +2049,7 @@ def finalize(self):
cls["abstract"] = True
break

def evaluate_struct_stack(self):
def _evaluate_struct_stack(self):
"""Create a Struct out of the name stack (but not its parts)"""
# print( 'eval struct stack', self.nameStack )
# if self.braceDepth != len(self.nameSpaces): return
Expand Down Expand Up @@ -2209,7 +2209,7 @@ def parse_method_type(self, stack):
info["returns_fundamental"] = is_fundamental(info["returns"])
return info

def evaluate_method_stack(self):
def _evaluate_method_stack(self):
"""Create a method out of the name stack"""

if self.curStruct:
Expand Down Expand Up @@ -2302,7 +2302,7 @@ def _parse_typedef(self, stack, namespace=""):
if s:
return r

def evaluate_typedef(self):
def _evaluate_typedef(self):
ns = self.cur_namespace(add_double_colon=True)
res = self._parse_typedef(self.stack, ns)
if res:
Expand All @@ -2311,7 +2311,7 @@ def evaluate_typedef(self):
if name not in self.typedefs_order:
self.typedefs_order.append(name)

def evaluate_property_stack(self):
def _evaluate_property_stack(self):
"""Create a Property out of the name stack"""
global parseHistory
assert self.stack[-1] == ";"
Expand Down Expand Up @@ -2367,7 +2367,7 @@ def evaluate_property_stack(self):
self.stack = orig_stack[
:
] # Not maintained for mucking, but this path it doesnt matter
self.evaluate_property_stack()
self._evaluate_property_stack()
return

newVar = CppVariable(self.nameStack)
Expand All @@ -2389,7 +2389,7 @@ def evaluate_property_stack(self):

self.stack = [] # CLEAR STACK

def evaluate_class_stack(self):
def _evaluate_class_stack(self):
"""Create a Class out of the name stack (but not its parts)"""
# dont support sub classes today
# print( 'eval class stack', self.nameStack )
Expand Down Expand Up @@ -2737,15 +2737,15 @@ def __init__(self, headerFileName, argType="file", encoding=None, **kwargs):
self.nameStack = self.nameStack[:classLocationNS]
self.stack = self.stack[:classLocationS]
try:
self.evaluate_stack()
self._evaluate_stack()
except:
debug_print("Error processing #define magic... Oh well")
# Process rest of stack
self.nameStack = origNameStack[classLocationNS:]
self.stack = origStack[classLocationS:]

if len(self.nameStack) and not is_enum_namestack(self.nameStack):
self.evaluate_stack()
self._evaluate_stack()
else:
self.nameStack.append(tok.value)
if self.stack and self.stack[0] == "class":
Expand All @@ -2761,7 +2761,7 @@ def __init__(self, headerFileName, argType="file", encoding=None, **kwargs):
if len(self.nameStack) and is_enum_namestack(self.nameStack):
self.nameStack.append(tok.value)
elif self.braceDepth < 10:
self.evaluate_stack()
self._evaluate_stack()
else:
self.nameStack = []
self.braceDepth -= 1
Expand Down Expand Up @@ -2906,14 +2906,14 @@ def __init__(self, headerFileName, argType="file", encoding=None, **kwargs):
self.stack = self.nameStack + [";"]
self.nameStack = self.nameStack[0:1]
debug_print("pre eval anon stack")
self.evaluate_stack(tok.type)
self._evaluate_stack(tok.type)
debug_print("post eval anon stack")
self.nameStack = saved_namestack
self.stack = saved_stack
self.anon_union_counter = [-1, 0]

if self.braceDepth < 10:
self.evaluate_stack(tok.type)
self._evaluate_stack(tok.type)
self.stack = []
self.nameStack = []

Expand Down Expand Up @@ -2954,7 +2954,7 @@ def __init__(self, headerFileName, argType="file", encoding=None, **kwargs):
]:
del self.__dict__[key]

def evaluate_stack(self, token=None):
def _evaluate_stack(self, token=None):
"""Evaluates the current name stack"""
global doxygenCommentCache

Expand Down Expand Up @@ -2992,7 +2992,7 @@ def evaluate_stack(self, token=None):
except:
pass

# if 'typedef' in self.nameStack: self.evaluate_typedef() # allows nested typedefs, probably a bad idea
# if 'typedef' in self.nameStack: self._evaluate_typedef() # allows nested typedefs, probably a bad idea
if (
not self.curClass
and "typedef" in self.nameStack
Expand All @@ -3003,7 +3003,7 @@ def evaluate_stack(self, token=None):
and not is_enum_namestack(self.nameStack)
):
trace_print("STACK", self.stack)
self.evaluate_typedef()
self._evaluate_typedef()
return

elif len(self.nameStack) == 0:
Expand All @@ -3026,7 +3026,7 @@ def evaluate_stack(self, token=None):

elif is_enum_namestack(self.nameStack):
debug_print("trace")
self.evaluate_enum_stack()
self._evaluate_enum_stack()

elif self._method_body and (self.braceDepth + 1) > self._method_body:
trace_print("INSIDE METHOD DEF")
Expand All @@ -3046,10 +3046,10 @@ def evaluate_stack(self, token=None):
# Special case of a method defined outside a class that has a body
pass
else:
self.evaluate_method_stack()
self._evaluate_method_stack()
else:
# Free function
self.evaluate_method_stack()
self._evaluate_method_stack()
elif (
len(self.nameStack) == 1
and len(self.nameStackHistory) > self.braceDepth
Expand Down Expand Up @@ -3078,7 +3078,7 @@ def evaluate_stack(self, token=None):
):
pass
else:
self.evaluate_property_stack() # catches class props and structs in a namespace
self._evaluate_property_stack() # catches class props and structs in a namespace

elif (
self.nameStack[0] in ("class", "struct", "union")
Expand All @@ -3087,14 +3087,14 @@ def evaluate_stack(self, token=None):
):
# Parsing a union can reuse much of the class parsing
debug_print("trace")
self.evaluate_class_stack()
self._evaluate_class_stack()

elif not self.curClass:
debug_print("trace")
if is_enum_namestack(self.nameStack):
self.evaluate_enum_stack()
self._evaluate_enum_stack()
elif self.curStruct and self.stack[-1] == ";":
self.evaluate_property_stack() # this catches fields of global structs
self._evaluate_property_stack() # this catches fields of global structs
self.nameStack = []
doxygenCommentCache = ""
elif self.braceDepth < 1:
Expand All @@ -3118,7 +3118,7 @@ def evaluate_stack(self, token=None):
doxygenCommentCache = ""
self.curTemplate = None

def evaluate_enum_stack(self):
def _evaluate_enum_stack(self):
"""Create an Enum out of the name stack"""
debug_print("evaluating enum")
newEnum = CppEnum(self.nameStack)
Expand All @@ -3142,10 +3142,10 @@ def evaluate_enum_stack(self):
instanceType = newEnum["name"]
for instance in newEnum["instances"]:
self.nameStack = [instanceType, instance]
self.evaluate_property_stack()
self._evaluate_property_stack()
del newEnum["instances"]

def strip_parent_keys(self):
def _strip_parent_keys(self):
"""Strip all parent (and method) keys to prevent loops"""
obj_queue = [self]
while len(obj_queue):
Expand Down Expand Up @@ -3195,7 +3195,7 @@ def toJSON(self, indent=4):
"""Converts a parsed structure to JSON"""
import json

self.strip_parent_keys()
self._strip_parent_keys()
try:
del self.__dict__["classes_order"]
except:
Expand Down

0 comments on commit d19d93b

Please sign in to comment.