cppClosureType.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file cppClosureType.h
  10. * @author rdb
  11. * @date 2017-01-14
  12. */
  13. #ifndef CPPCLOSURETYPE_H
  14. #define CPPCLOSURETYPE_H
  15. #include "dtoolbase.h"
  16. #include "cppFunctionType.h"
  17. /**
  18. * The type of a lambda expression. This is like a function, but with
  19. * additional captures defined.
  20. */
  21. class CPPClosureType : public CPPFunctionType {
  22. public:
  23. enum CaptureType {
  24. CT_none,
  25. CT_by_reference,
  26. CT_by_value,
  27. };
  28. CPPClosureType(CaptureType default_capture = CT_none);
  29. CPPClosureType(const CPPClosureType &copy);
  30. void operator = (const CPPClosureType &copy);
  31. struct Capture {
  32. string _name;
  33. CaptureType _type;
  34. CPPExpression *_initializer;
  35. };
  36. typedef vector<Capture> Captures;
  37. Captures _captures;
  38. CaptureType _default_capture;
  39. void add_capture(string name, CaptureType type, CPPExpression *initializer = NULL);
  40. virtual bool is_fully_specified() const;
  41. virtual bool is_default_constructible() const;
  42. virtual bool is_copy_constructible() const;
  43. virtual bool is_destructible() const;
  44. virtual void output(ostream &out, int indent_level, CPPScope *scope,
  45. bool complete) const;
  46. virtual SubType get_subtype() const;
  47. virtual CPPClosureType *as_closure_type();
  48. protected:
  49. virtual bool is_equal(const CPPDeclaration *other) const;
  50. virtual bool is_less(const CPPDeclaration *other) const;
  51. };
  52. #endif