mirror of
https://github.com/boostorg/python.git
synced 2026-01-20 04:42:28 +00:00
Compare commits
1 Commits
boost-0.9.
...
boost-0.9.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1a1e3be8a |
24
pyste/src/Pyste/IncludeExporter.py
Normal file
24
pyste/src/Pyste/IncludeExporter.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import os.path
|
||||
from Exporter import Exporter
|
||||
|
||||
#==============================================================================
|
||||
# IncludeExporter
|
||||
#==============================================================================
|
||||
class IncludeExporter(Exporter):
|
||||
'''Writes an include declaration to the module. Useful to add extra code
|
||||
for use in the Wrappers.
|
||||
This class just reimplements the Parse method to do nothing: the
|
||||
WriteInclude in Exporter already does the work for us.
|
||||
'''
|
||||
|
||||
def __init__(self, info, parser_tail=None):
|
||||
Exporter.__init__(self, info, parser_tail)
|
||||
|
||||
def Parse(self, parser):
|
||||
pass
|
||||
|
||||
def Name(self):
|
||||
return '__all__'
|
||||
|
||||
def Header(self):
|
||||
return None # means "don't try to parse me!"
|
||||
@@ -81,6 +81,20 @@ class ClassInfo(DeclarationInfo):
|
||||
exporter.interface_file = exporters.current_interface
|
||||
|
||||
|
||||
#==============================================================================
|
||||
# IncludeInfo
|
||||
#==============================================================================
|
||||
class IncludeInfo(DeclarationInfo):
|
||||
|
||||
def __init__(self, include):
|
||||
DeclarationInfo.__init__(self)
|
||||
self._Attribute('include', include)
|
||||
exporter = IncludeExporter(InfoWrapper(self))
|
||||
if exporter not in exporters.exporters:
|
||||
exporters.exporters.append(exporter)
|
||||
exporter.interface_file = exporters.current_interface
|
||||
|
||||
|
||||
#==============================================================================
|
||||
# templates
|
||||
#==============================================================================
|
||||
|
||||
@@ -43,7 +43,7 @@ from CppParser import CppParser, CppParserError
|
||||
import time
|
||||
from declarations import Typedef
|
||||
|
||||
__version__ = '0.9.16'
|
||||
__version__ = '0.9.15'
|
||||
|
||||
def RecursiveIncludes(include):
|
||||
'Return a list containg the include dir and all its subdirectories'
|
||||
@@ -167,7 +167,7 @@ def CreateContext():
|
||||
# infos
|
||||
context['Function'] = infos.FunctionInfo
|
||||
context['Class'] = infos.ClassInfo
|
||||
context['Include'] = lambda header: infos.CodeInfo('#include <%s>\n' % header, 'include')
|
||||
context['Include'] = infos.IncludeInfo
|
||||
context['Template'] = infos.ClassTemplateInfo
|
||||
context['Enum'] = infos.EnumInfo
|
||||
context['AllFromHeader'] = infos.HeaderInfo
|
||||
@@ -193,6 +193,7 @@ def CreateContext():
|
||||
context['manage_new_object'] = manage_new_object
|
||||
# utils
|
||||
context['Wrapper'] = exporterutils.FunctionWrapper
|
||||
context['header_code'] = lambda code: infos.CodeInfo(code, 'include')
|
||||
context['declaration_code'] = lambda code: infos.CodeInfo(code, 'declaration')
|
||||
context['global_declaration_code'] = lambda code: infos.CodeInfo(code, 'declaration-outside')
|
||||
context['module_code'] = lambda code: infos.CodeInfo(code, 'module')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Class('A', 'code_test.h')
|
||||
Include('string')
|
||||
header_code('#include <string>\n')
|
||||
global_declaration_code('''
|
||||
int get(A& a) { return a.x; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user