syms.cpp 680 B

12345678910111213141516171819202122232425262728293031
  1. #include "syms.h"
  2. #include <util/generic/vector.h>
  3. #include <util/generic/string.h>
  4. #include <util/generic/singleton.h>
  5. using namespace NPrivate;
  6. namespace {
  7. struct TSym {
  8. const char* Mod;
  9. const char* Name;
  10. void* Sym;
  11. };
  12. struct TSymbols: public TVector<TSym> {
  13. static inline TSymbols* Instance() {
  14. return Singleton<TSymbols>();
  15. }
  16. };
  17. }
  18. void NPrivate::RegisterSymbol(const char* mod, const char* name, void* sym) {
  19. TSymbols::Instance()->push_back(TSym{mod, name, sym});
  20. }
  21. void NPrivate::ForEachSymbol(ICB& cb) {
  22. for (auto& x : *TSymbols::Instance()) {
  23. cb.Apply(x.Mod, x.Name, x.Sym);
  24. }
  25. }