@@ -51,38 +51,43 @@ def _Attribute(self, name, value=None):
5151 self .__attributes [name ] = value
5252
5353
54+ def AddExporter (self , exporter ):
55+ if not exporters .importing :
56+ if exporter not in exporters .exporters :
57+ exporters .exporters .append (exporter )
58+ exporter .interface_file = exporters .current_interface
59+
60+
5461#==============================================================================
5562# FunctionInfo
5663#==============================================================================
5764class FunctionInfo (DeclarationInfo ):
5865
59- def __init__ (self , name , include , tail = None , otherOption = None ):
66+ def __init__ (self , name , include , tail = None , otherOption = None ,
67+ exporter_class = FunctionExporter ):
6068 DeclarationInfo .__init__ (self , otherOption )
6169 self ._Attribute ('name' , name )
6270 self ._Attribute ('include' , include )
6371 self ._Attribute ('exclude' , False )
6472 # create a FunctionExporter
65- exporter = FunctionExporter (InfoWrapper (self ), tail )
66- if exporter not in exporters .exporters :
67- exporters .exporters .append (exporter )
68- exporter .interface_file = exporters .current_interface
73+ exporter = exporter_class (InfoWrapper (self ), tail )
74+ self .AddExporter (exporter )
6975
7076
7177#==============================================================================
7278# ClassInfo
7379#==============================================================================
7480class ClassInfo (DeclarationInfo ):
7581
76- def __init__ (self , name , include , tail = None , otherInfo = None ):
82+ def __init__ (self , name , include , tail = None , otherInfo = None ,
83+ exporter_class = ClassExporter ):
7784 DeclarationInfo .__init__ (self , otherInfo )
7885 self ._Attribute ('name' , name )
7986 self ._Attribute ('include' , include )
8087 self ._Attribute ('exclude' , False )
8188 # create a ClassExporter
82- exporter = ClassExporter (InfoWrapper (self ), tail )
83- if exporter not in exporters .exporters :
84- exporters .exporters .append (exporter )
85- exporter .interface_file = exporters .current_interface
89+ exporter = exporter_class (InfoWrapper (self ), tail )
90+ self .AddExporter (exporter )
8691
8792
8893#==============================================================================
@@ -96,10 +101,12 @@ def GenerateName(name, type_list):
96101
97102class ClassTemplateInfo (DeclarationInfo ):
98103
99- def __init__ (self , name , include ):
104+ def __init__ (self , name , include ,
105+ exporter_class = ClassExporter ):
100106 DeclarationInfo .__init__ (self )
101107 self ._Attribute ('name' , name )
102108 self ._Attribute ('include' , include )
109+ self ._exporter_class = exporter_class
103110
104111
105112 def Instantiate (self , type_list , rename = None ):
@@ -111,7 +118,8 @@ def Instantiate(self, type_list, rename=None):
111118 tail += 'void __instantiate_%s()\n ' % rename
112119 tail += '{ sizeof(%s); }\n \n ' % rename
113120 # create a ClassInfo
114- class_ = ClassInfo (rename , self ._Attribute ('include' ), tail , self )
121+ class_ = ClassInfo (rename , self ._Attribute ('include' ), tail , self ,
122+ exporter_class = self ._exporter_class )
115123 return class_
116124
117125
@@ -125,60 +133,52 @@ def __call__(self, types, rename=None):
125133#==============================================================================
126134class EnumInfo (DeclarationInfo ):
127135
128- def __init__ (self , name , include ):
136+ def __init__ (self , name , include , exporter_class = EnumExporter ):
129137 DeclarationInfo .__init__ (self )
130138 self ._Attribute ('name' , name )
131139 self ._Attribute ('include' , include )
132140 self ._Attribute ('exclude' , False )
133141 self ._Attribute ('export_values' , False )
134- exporter = EnumExporter (InfoWrapper (self ))
135- if exporter not in exporters .exporters :
136- exporters .exporters .append (exporter )
137- exporter .interface_file = exporters .current_interface
142+ exporter = exporter_class (InfoWrapper (self ))
143+ self .AddExporter (exporter )
138144
139145
140146#==============================================================================
141147# HeaderInfo
142148#==============================================================================
143149class HeaderInfo (DeclarationInfo ):
144150
145- def __init__ (self , include ):
151+ def __init__ (self , include , exporter_class = HeaderExporter ):
146152 DeclarationInfo .__init__ (self )
147153 self ._Attribute ('include' , include )
148- exporter = HeaderExporter (InfoWrapper (self ))
149- if exporter not in exporters .exporters :
150- exporters .exporters .append (exporter )
151- exporter .interface_file = exporters .current_interface
154+ exporter = exporter_class (InfoWrapper (self ))
155+ self .AddExporter (exporter )
152156
153157
154158#==============================================================================
155159# VarInfo
156160#==============================================================================
157161class VarInfo (DeclarationInfo ):
158162
159- def __init__ (self , name , include ):
163+ def __init__ (self , name , include , exporter_class = VarExporter ):
160164 DeclarationInfo .__init__ (self )
161165 self ._Attribute ('name' , name )
162166 self ._Attribute ('include' , include )
163- exporter = VarExporter (InfoWrapper (self ))
164- if exporter not in exporters .exporters :
165- exporters .exporters .append (exporter )
166- exporter .interface_file = exporters .current_interface
167+ exporter = exporter_class (InfoWrapper (self ))
168+ self .AddExporter (exporter )
167169
168170
169171#==============================================================================
170172# CodeInfo
171173#==============================================================================
172174class CodeInfo (DeclarationInfo ):
173175
174- def __init__ (self , code , section ):
176+ def __init__ (self , code , section , exporter_class = CodeExporter ):
175177 DeclarationInfo .__init__ (self )
176178 self ._Attribute ('code' , code )
177179 self ._Attribute ('section' , section )
178- exporter = CodeExporter (InfoWrapper (self ))
179- if exporter not in exporters .exporters :
180- exporters .exporters .append (exporter )
181- exporter .interface_file = exporters .current_interface
180+ exporter = exporter_class (InfoWrapper (self ))
181+ self .AddExporter (exporter )
182182
183183
184184#==============================================================================
0 commit comments