@@ -159,6 +159,70 @@ def __init__(self, i):
159159 assert mi8b .bar () == 15
160160
161161
162+ def test_multiple_inheritance_python_many_bases ():
163+ from pybind11_tests import (BaseN1 , BaseN2 , BaseN3 , BaseN4 , BaseN5 , BaseN6 , BaseN7 ,
164+ BaseN8 , BaseN9 , BaseN10 , BaseN11 , BaseN12 , BaseN13 , BaseN14 ,
165+ BaseN15 , BaseN16 , BaseN17 )
166+
167+ class MIMany1_4 (BaseN1 , BaseN2 , BaseN3 , BaseN4 ):
168+ def __init__ (self ):
169+ BaseN1 .__init__ (self , 1 )
170+ BaseN2 .__init__ (self , 2 )
171+ BaseN3 .__init__ (self , 3 )
172+ BaseN4 .__init__ (self , 4 )
173+
174+ class MIMany5_8 (BaseN5 , BaseN6 , BaseN7 , BaseN8 ):
175+ def __init__ (self ):
176+ BaseN5 .__init__ (self , 5 )
177+ BaseN6 .__init__ (self , 6 )
178+ BaseN7 .__init__ (self , 7 )
179+ BaseN8 .__init__ (self , 8 )
180+
181+ class MIMany9_16 (BaseN9 , BaseN10 , BaseN11 , BaseN12 , BaseN13 , BaseN14 , BaseN15 , BaseN16 ):
182+ def __init__ (self ):
183+ BaseN9 .__init__ (self , 9 )
184+ BaseN10 .__init__ (self , 10 )
185+ BaseN11 .__init__ (self , 11 )
186+ BaseN12 .__init__ (self , 12 )
187+ BaseN13 .__init__ (self , 13 )
188+ BaseN14 .__init__ (self , 14 )
189+ BaseN15 .__init__ (self , 15 )
190+ BaseN16 .__init__ (self , 16 )
191+
192+ class MIMany1_9 (MIMany1_4 , MIMany5_8 , BaseN9 ):
193+ def __init__ (self ):
194+ MIMany1_4 .__init__ (self )
195+ MIMany5_8 .__init__ (self )
196+ BaseN9 .__init__ (self , 9 )
197+
198+ class MIMany1_17 (MIMany1_4 , MIMany5_8 , MIMany9_16 , BaseN17 ):
199+ def __init__ (self ):
200+ MIMany1_4 .__init__ (self )
201+ MIMany5_8 .__init__ (self )
202+ MIMany9_16 .__init__ (self )
203+ BaseN17 .__init__ (self , 17 )
204+
205+ # Inherits from 4 registered C++ classes: can fit in one pointer on any modern arch:
206+ a = MIMany1_4 ()
207+ for i in range (1 , 4 ):
208+ assert getattr (a , "f" + str (i ))() == 2 * i
209+
210+ # Inherits from 8: requires 1/2 pointers worth of holder flags on 32/64-bit arch:
211+ b = MIMany9_16 ()
212+ for i in range (9 , 16 ):
213+ assert getattr (b , "f" + str (i ))() == 2 * i
214+
215+ # Inherits from 9: requires >= 2 pointers worth of holder flags
216+ c = MIMany1_9 ()
217+ for i in range (1 , 9 ):
218+ assert getattr (c , "f" + str (i ))() == 2 * i
219+
220+ # Inherits from 17: requires >= 3 pointers worth of holder flags
221+ d = MIMany1_17 ()
222+ for i in range (1 , 17 ):
223+ assert getattr (d , "f" + str (i ))() == 2 * i
224+
225+
162226def test_multiple_inheritance_virtbase ():
163227 from pybind11_tests import Base12a , bar_base2a , bar_base2a_sharedptr
164228
0 commit comments