CSFunctionWriter.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include <Atomic/Container/Str.h>
  24. #include "../JSBFunctionWriter.h"
  25. using namespace Atomic;
  26. namespace ToolCore
  27. {
  28. class JSBPackage;
  29. class JSBFunction;
  30. class CSFunctionWriter : public JSBFunctionWriter
  31. {
  32. public:
  33. CSFunctionWriter(JSBFunction* function);
  34. void GenerateSource(String& sourceOut);
  35. void GenerateNativeSource(String& sourceOut);
  36. void GenerateManagedSource(String& sourceOut);
  37. static void SetWroteConstructor(bool value) { wroteConstructor_ = value; }
  38. static bool GetWroteConstructor() { return wroteConstructor_; }
  39. private:
  40. struct DefaultStructParameter
  41. {
  42. String type;
  43. String parameterName;
  44. String assignment;
  45. };
  46. static bool wroteConstructor_;
  47. Vector<DefaultStructParameter> defaultStructParameters_;
  48. void WriteDefaultStructParameters(String& source);
  49. void GenNativeCallParameters(String& sig);
  50. void WriteNativeFunction(String& source);
  51. void WriteNativeConstructor(String& source);
  52. void WriteNativeParameterMarshal(String& source);
  53. String MapDefaultParameter(JSBFunctionType* parameter);
  54. void GenManagedFunctionParameters(String& sig);
  55. void GenPInvokeCallParameters(String& sig);
  56. void WriteManagedConstructor(String& source);
  57. void WriteManagedDestructor(String& source);
  58. void WriteManagedFunction(String& source);
  59. void WriteManagedPInvokeFunctionSignature(String& source);
  60. };
  61. }