JSBFunction.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 "JSBFunction.h"
  8. namespace ToolCore
  9. {
  10. void JSBFunction::Process()
  11. {
  12. if (skip_)
  13. {
  14. return;
  15. }
  16. // if not already marked as a getter
  17. if (!isGetter_)
  18. {
  19. if (!parameters_.Size() && returnType_)
  20. {
  21. if (name_.Length() > 3 && name_.StartsWith("Get") && isupper(name_[3]))
  22. {
  23. String pname = name_.Substring(3);
  24. class_->SetSkipFunction(pname);
  25. isGetter_ = true;
  26. propertyName_ = pname;
  27. }
  28. }
  29. }
  30. if (!isSetter_)
  31. {
  32. if (parameters_.Size() == 1 && !returnType_)
  33. {
  34. if (name_.Length() > 3 && name_.StartsWith("Set") && isupper(name_[3]))
  35. {
  36. String pname = name_.Substring(3);
  37. class_->SetSkipFunction(pname);
  38. isSetter_ = true;
  39. propertyName_ = pname;
  40. }
  41. }
  42. }
  43. if (isGetter_)
  44. class_->AddPropertyFunction(this);
  45. if (isSetter_)
  46. class_->AddPropertyFunction(this);
  47. }
  48. bool JSBFunction::Match(JSBFunction* func)
  49. {
  50. if (func->Skip() || func->GetName() != name_)
  51. return false;
  52. if (!returnType_)
  53. {
  54. if (func->GetReturnType())
  55. return false;
  56. }
  57. else
  58. {
  59. if (!returnType_->Match(func->GetReturnType()))
  60. return false;
  61. }
  62. Vector<JSBFunctionType*>& fparams = func->GetParameters();
  63. if (parameters_.Size() != fparams.Size())
  64. return false;
  65. for ( unsigned j = 0; j < fparams.Size(); j++)
  66. {
  67. if (!parameters_[j]->Match(fparams[j]))
  68. return false;
  69. }
  70. return true;
  71. }
  72. JSBClass* JSBFunction::GetReturnClass()
  73. {
  74. if (!returnType_)
  75. return 0;
  76. if (!returnType_->type_->asClassType())
  77. return 0;
  78. return returnType_->type_->asClassType()->class_;
  79. }
  80. }