OLD | NEW |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 1999--2020 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1999--2020 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 6 LilyPond is free software: you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation, either version 3 of the License, or | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 297 |
298 void protect_smob (SCM smob); | 298 void protect_smob (SCM smob); |
299 void unprotect_smob (SCM smob); | 299 void unprotect_smob (SCM smob); |
300 | 300 |
301 // The Smob_core class is not templated and contains material not | 301 // The Smob_core class is not templated and contains material not |
302 // depending on the Super class. | 302 // depending on the Super class. |
303 | 303 |
304 class Smob_core { | 304 class Smob_core { |
305 protected: | 305 protected: |
306 SCM self_scm_; | 306 SCM self_scm_; |
307 Smob_core () : self_scm_ (SCM_UNDEFINED) { }; | 307 Smob_core () : self_scm_ (SCM_UNDEFINED) { |
| 308 count++; |
| 309 maybe_grow_heap(); |
| 310 }; |
| 311 ~Smob_core() { count--; } |
| 312 static size_t count; |
| 313 void maybe_grow_heap(); |
308 public: | 314 public: |
309 SCM self_scm () const { return self_scm_; } | 315 SCM self_scm () const { return self_scm_; } |
310 Listener get_listener (SCM callback); | 316 Listener get_listener (SCM callback); |
311 }; | 317 }; |
312 | 318 |
313 template <class Super> | 319 template <class Super> |
314 class Smob : public Smob_core, public Smob_base<Super> { | 320 class Smob : public Smob_core, public Smob_base<Super> { |
315 private: | 321 private: |
316 Smob (const Smob<Super> &) = delete; | 322 Smob (const Smob<Super> &) = delete; |
317 Smob& operator= (const Smob<Super> &) = delete; | 323 Smob& operator= (const Smob<Super> &) = delete; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 if (parsed_objects_should_be_dead) \ | 382 if (parsed_objects_should_be_dead) \ |
377 pass_here.checkin (arg); \ | 383 pass_here.checkin (arg); \ |
378 } while (0) | 384 } while (0) |
379 #else | 385 #else |
380 #define ASSERT_LIVE_IS_ALLOWED(arg) do { (void)(arg); } \ | 386 #define ASSERT_LIVE_IS_ALLOWED(arg) do { (void)(arg); } \ |
381 while (0) | 387 while (0) |
382 #endif | 388 #endif |
383 | 389 |
384 #include "smobs.tcc" | 390 #include "smobs.tcc" |
385 #endif /* SMOBS_HH */ | 391 #endif /* SMOBS_HH */ |
OLD | NEW |