CSClassWriter.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //
  2. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  3. // LICENSE: Atomic Game Engine Editor and Tools EULA
  4. // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
  5. // license information: https://github.com/AtomicGameEngine/AtomicGameEngine
  6. //
  7. #include <Atomic/IO/FileSystem.h>
  8. #include "../JSBind.h"
  9. #include "../JSBModule.h"
  10. #include "../JSBPackage.h"
  11. #include "../JSBEnum.h"
  12. #include "../JSBClass.h"
  13. #include "../JSBFunction.h"
  14. #include "CSClassWriter.h"
  15. #include "CSFunctionWriter.h"
  16. namespace ToolCore
  17. {
  18. CSClassWriter::CSClassWriter(JSBClass *klass) : JSBClassWriter(klass)
  19. {
  20. }
  21. void CSClassWriter::WriteFunctions(String& source)
  22. {
  23. for (unsigned i = 0; i < klass_->functions_.Size(); i++)
  24. {
  25. JSBFunction* function = klass_->functions_.At(i);
  26. if (function->Skip())
  27. continue;
  28. if (function->IsDestructor())
  29. continue;
  30. CSFunctionWriter writer(function);
  31. writer.GenerateSource(source);
  32. }
  33. }
  34. void CSClassWriter::GenerateSource(String& sourceOut)
  35. {
  36. String source = "";
  37. if (klass_->IsNumberArray())
  38. return;
  39. source.AppendWithFormat("ClassID csb_%s_GetClassID()\n{\n", klass_->GetNativeName().CString());
  40. source.AppendWithFormat("return %s::GetClassIDStatic();\n}\n", klass_->GetNativeName().CString());
  41. WriteFunctions(source);
  42. sourceOut += source;
  43. }
  44. }