BsSLPlugin.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "BsSLPrerequisites.h"
  2. #include "BsPath.h"
  3. #include "BsFileSystem.h"
  4. #include "BsDataStream.h"
  5. extern "C" {
  6. #include "BsMMAlloc.h"
  7. #include "BsASTFX.h"
  8. #include "BsParserFX.h"
  9. #include "BsLexerFX.h"
  10. }
  11. namespace BansheeEngine
  12. {
  13. void parseFX(ParseState* parseState, const char* source)
  14. {
  15. yyscan_t scanner;
  16. YY_BUFFER_STATE state;
  17. if (yylex_init_extra(parseState, &scanner)) {
  18. // couldn't initialize
  19. return;
  20. }
  21. state = yy_scan_string(source, scanner);
  22. if (yyparse(parseState, scanner)) {
  23. // error parsing
  24. return;
  25. }
  26. yy_delete_buffer(state, scanner);
  27. yylex_destroy(scanner);
  28. }
  29. /**
  30. * @brief Returns a name of the plugin.
  31. */
  32. extern "C" BS_SL_EXPORT const String& getPluginName()
  33. {
  34. return SystemName;
  35. }
  36. /**
  37. * @brief Entry point to the plugin. Called by the engine when the plugin is loaded.
  38. */
  39. extern "C" BS_SL_EXPORT void* loadPlugin()
  40. {
  41. // TODO - Register importer
  42. // DEBUG
  43. yydebug = 1;
  44. Path exampleFX = "D:\\testFX.txt";
  45. DataStreamPtr file = FileSystem::openFile(exampleFX);
  46. String contents = file->getAsString();
  47. ParseState* parseState = parseStateCreate();
  48. parseFX(parseState, contents.c_str());
  49. int bp = 0;
  50. parseStateDelete(parseState);
  51. return nullptr;
  52. }
  53. }