tesseract v5.3.3.20231005
cpp.ast.Function Class Reference
Inheritance diagram for cpp.ast.Function:
cpp.ast._GenericDeclaration cpp.ast.Node cpp.ast.Method

Public Member Functions

def __init__ (self, start, end, name, return_type, parameters, modifiers, templated_types, body, namespace)
 
def IsDeclaration (self)
 
def IsDefinition (self)
 
def IsExportable (self)
 
def Requires (self, node)
 
def __str__ (self)
 
- Public Member Functions inherited from cpp.ast._GenericDeclaration
def __init__ (self, start, end, name, namespace)
 
def FullName (self)
 
- Public Member Functions inherited from cpp.ast.Node
def __init__ (self, start, end)
 
def IsDeclaration (self)
 
def IsDefinition (self)
 
def IsExportable (self)
 
def Requires (self, node)
 
def XXX__str__ (self)
 
def __repr__ (self)
 

Public Attributes

 return_type
 
 parameters
 
 modifiers
 
 body
 
 templated_types
 
- Public Attributes inherited from cpp.ast._GenericDeclaration
 name
 
 namespace
 
- Public Attributes inherited from cpp.ast.Node
 start
 
 end
 

Detailed Description

Definition at line 358 of file ast.py.

Constructor & Destructor Documentation

◆ __init__()

def cpp.ast.Function.__init__ (   self,
  start,
  end,
  name,
  return_type,
  parameters,
  modifiers,
  templated_types,
  body,
  namespace 
)

Reimplemented from cpp.ast._GenericDeclaration.

Reimplemented in cpp.ast.Method.

Definition at line 359 of file ast.py.

360 modifiers, templated_types, body, namespace):
361 _GenericDeclaration.__init__(self, start, end, name, namespace)
362 converter = TypeConverter(namespace)
363 self.return_type = converter.CreateReturnType(return_type)
364 self.parameters = converter.ToParameters(parameters)
365 self.modifiers = modifiers
366 self.body = body
367 self.templated_types = templated_types
368

Member Function Documentation

◆ __str__()

def cpp.ast.Function.__str__ (   self)

Definition at line 389 of file ast.py.

389 def __str__(self):
390 # TODO(nnorwitz): add templated_types.
391 suffix = ('%s %s(%s), 0x%02x, %s' %
392 (self.return_type, self.name, self.parameters,
393 self.modifiers, self.body))
394 return self._TypeStringHelper(suffix)
395
396

◆ IsDeclaration()

def cpp.ast.Function.IsDeclaration (   self)
Returns bool if this node is a declaration.

Reimplemented from cpp.ast.Node.

Definition at line 369 of file ast.py.

369 def IsDeclaration(self):
370 return self.body is None
371

◆ IsDefinition()

def cpp.ast.Function.IsDefinition (   self)
Returns bool if this node is a definition.

Reimplemented from cpp.ast.Node.

Definition at line 372 of file ast.py.

372 def IsDefinition(self):
373 return self.body is not None
374

◆ IsExportable()

def cpp.ast.Function.IsExportable (   self)
Returns bool if this node exportable from a header file.

Reimplemented from cpp.ast.Node.

Definition at line 375 of file ast.py.

375 def IsExportable(self):
376 if self.return_type and 'static' in self.return_type.modifiers:
377 return False
378 return None not in self.namespace
379

◆ Requires()

def cpp.ast.Function.Requires (   self,
  node 
)
Does this AST node require the definition of the node passed in?

Reimplemented from cpp.ast.Node.

Definition at line 380 of file ast.py.

380 def Requires(self, node):
381 if self.parameters:
382 # TODO(nnorwitz): parameters are tokens, do name comparison.
383 for p in self.parameters:
384 if p.name == node.name:
385 return True
386 # TODO(nnorwitz): search in body too.
387 return False
388

Member Data Documentation

◆ body

cpp.ast.Function.body

Definition at line 366 of file ast.py.

◆ modifiers

cpp.ast.Function.modifiers

Definition at line 365 of file ast.py.

◆ parameters

cpp.ast.Function.parameters

Definition at line 364 of file ast.py.

◆ return_type

cpp.ast.Function.return_type

Definition at line 363 of file ast.py.

◆ templated_types

cpp.ast.Function.templated_types

Definition at line 367 of file ast.py.


The documentation for this class was generated from the following file: