@@ -29,7 +29,7 @@ def normalize(self, type_str):
29
29
return type_str .replace (' ' , '' )
30
30
31
31
def replace_basic_string (self , cls_name ):
32
-
32
+ print ( "replace_basic_string" , cls_name )
33
33
# Take the lists of all possible string variations
34
34
# and clean them up by replacing ::std by std.
35
35
str_eq = [
@@ -99,10 +99,13 @@ def erase_recursive(self, cls_name):
99
99
return self .no_end_const (cls_name )
100
100
101
101
def erase_allocator (self , cls_name , default_allocator = 'std::allocator' ):
102
+ print ("erase_allocator" , cls_name )
102
103
cls_name = self .replace_basic_string (cls_name )
104
+ print ("erase_allocator" , cls_name )
103
105
c_name , c_args = templates .split (cls_name )
106
+ print ("c_name, c_args" , c_name , c_args )
104
107
if len (c_args ) != 2 :
105
- return
108
+ return None
106
109
value_type = c_args [0 ]
107
110
tmpl = string .Template (
108
111
"$container< $value_type, $allocator<$value_type> >" )
@@ -112,19 +115,24 @@ def erase_allocator(self, cls_name, default_allocator='std::allocator'):
112
115
allocator = default_allocator )
113
116
if self .normalize (cls_name ) == \
114
117
self .normalize (tmpl ):
115
- return templates .join (
118
+ result = templates .join (
116
119
c_name , [self .erase_recursive (value_type )])
120
+ print ("result" , result )
121
+ print ("c_name" , c_name )
122
+ print ("value_type" , value_type )
123
+ print ("erase" , self .erase_recursive (value_type ))
124
+ return result
117
125
118
126
def erase_container (self , cls_name , default_container_name = 'std::deque' ):
119
127
cls_name = self .replace_basic_string (cls_name )
120
128
c_name , c_args = templates .split (cls_name )
121
129
if len (c_args ) != 2 :
122
- return
130
+ return cls_name
123
131
value_type = c_args [0 ]
124
132
dc_no_defaults = self .erase_recursive (c_args [1 ])
125
133
if self .normalize (dc_no_defaults ) != self .normalize (
126
134
templates .join (default_container_name , [value_type ])):
127
- return
135
+ return cls_name
128
136
return templates .join (
129
137
c_name , [self .erase_recursive (value_type )])
130
138
@@ -136,7 +144,7 @@ def erase_container_compare(
136
144
cls_name = self .replace_basic_string (cls_name )
137
145
c_name , c_args = templates .split (cls_name )
138
146
if len (c_args ) != 3 :
139
- return
147
+ return cls_name
140
148
dc_no_defaults = self .erase_recursive (c_args [1 ])
141
149
if self .normalize (dc_no_defaults ) != self .normalize (
142
150
templates .join (default_container_name , [c_args [0 ]])):
@@ -156,7 +164,7 @@ def erase_compare_allocator(
156
164
cls_name = self .replace_basic_string (cls_name )
157
165
c_name , c_args = templates .split (cls_name )
158
166
if len (c_args ) != 3 :
159
- return
167
+ return cls_name
160
168
value_type = c_args [0 ]
161
169
tmpl = string .Template (
162
170
"$container< $value_type, $compare<$value_type>, " +
@@ -179,7 +187,7 @@ def erase_map_compare_allocator(
179
187
cls_name = self .replace_basic_string (cls_name )
180
188
c_name , c_args = templates .split (cls_name )
181
189
if len (c_args ) != 4 :
182
- return
190
+ return cls_name
183
191
key_type = c_args [0 ]
184
192
mapped_type = c_args [1 ]
185
193
tmpls = [
@@ -209,7 +217,7 @@ def erase_hash_allocator(self, cls_name):
209
217
cls_name = self .replace_basic_string (cls_name )
210
218
c_name , c_args = templates .split (cls_name )
211
219
if len (c_args ) < 3 :
212
- return
220
+ return cls_name
213
221
214
222
default_less = 'std::less'
215
223
default_equal_to = 'std::equal_to'
@@ -226,7 +234,7 @@ def erase_hash_allocator(self, cls_name):
226
234
"$container< $value_type, $hash<$value_type >, " +
227
235
"$equal_to<$value_type >, $allocator<$value_type> >" )
228
236
else :
229
- return
237
+ return cls_name
230
238
231
239
value_type = c_args [0 ]
232
240
template = string .Template (tmpl )
@@ -258,7 +266,7 @@ def erase_hashmap_compare_allocator(self, cls_name):
258
266
key_type = c_args [0 ]
259
267
mapped_type = c_args [1 ]
260
268
else :
261
- return
269
+ return cls_name
262
270
263
271
if len (c_args ) == 4 :
264
272
default_hash = 'hash_compare'
@@ -305,7 +313,7 @@ def erase_hashmap_compare_allocator(self, cls_name):
305
313
"$equal_to<$key_type>, " +
306
314
"$allocator< $mapped_type > >" )
307
315
else :
308
- return
316
+ return cls_name
309
317
310
318
for ns in std_namespaces :
311
319
inst = tmpl .substitute (
@@ -520,14 +528,13 @@ def remove_defaults(self, type_or_string):
520
528
std::vector< int >
521
529
522
530
"""
523
-
524
531
name = type_or_string
525
532
if not isinstance (type_or_string , str ):
526
533
name = self .class_declaration (type_or_string ).name
527
534
if not self .remove_defaults_impl :
528
535
return name
529
536
no_defaults = self .remove_defaults_impl (name )
530
- if not no_defaults :
537
+ if no_defaults is None :
531
538
return name
532
539
return no_defaults
533
540
0 commit comments