2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-28 07:22:31 +00:00
Files
python/pyste/src/HeaderExporter.py
Bruno da Silva de Oliveira c7ea0aacd6 - Lots of fixes in the documentation
- Fixed support for return_opaque_pointer policy


[SVN r18199]
2003-04-08 01:01:32 +00:00

75 lines
2.4 KiB
Python

from Exporter import Exporter
from ClassExporter import ClassExporter
from FunctionExporter import FunctionExporter
from EnumExporter import EnumExporter
from infos import *
from declarations import *
import os.path
import exporters
#==============================================================================
# HeaderExporter
#==============================================================================
class HeaderExporter(Exporter):
'Exports all declarations found in the given header'
def __init__(self, info, parser_tail=None):
Exporter.__init__(self, info, parser_tail)
def WriteInclude(self, codeunit):
pass
def SetDeclarations(self, declarations):
def IsInternalName(name):
'''Returns true if the given name looks like a internal compiler
structure'''
return name.startswith('__')
Exporter.SetDeclarations(self, declarations)
header = os.path.normpath(self.parser_header)
for decl in declarations:
# check if this declaration is in the header
location = os.path.normpath(decl.location[0])
if location != header or IsInternalName(decl.name):
continue
# ok, check the type of the declaration and export it accordingly
self.HandleDeclaration(decl)
def HandleDeclaration(self, decl):
'''Dispatch the declaration to the appropriate method, that must create
a suitable info object for a Exporter, create a Exporter, set its
declarations and append it to the list of exporters.
'''
dispatch_table = {
Class : ClassExporter,
Enumeration : EnumExporter,
Function : FunctionExporter,
}
for decl_type, exporter_type in dispatch_table.items():
if type(decl) == decl_type:
self.HandleExporter(decl, exporter_type)
break
def HandleExporter(self, decl, exporter_type):
info = self.info[decl.name]
info.name = decl.FullName()
info.include = self.info.include
exporter = exporter_type(info)
exporter.SetDeclarations(self.declarations)
exporters.exporters.append(exporter)
def Unit(self):
return None # doesn't write anything by himself
def Order(self):
return self.info.include