parameterRemap.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Filename: parameterRemap.h
  2. // Created by: drose (01Aug00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #ifndef PARAMETERREMAP_H
  15. #define PARAMETERREMAP_H
  16. #include "dtoolbase.h"
  17. #include "interrogate_interface.h"
  18. class CPPType;
  19. class CPPExpression;
  20. ////////////////////////////////////////////////////////////////////
  21. // Class : ParameterRemap
  22. // Description : An abstract base class for a number of different
  23. // kinds of ways to remap parameters for passing to
  24. // wrapper functions.
  25. //
  26. // Certain kinds of function parameters that are legal
  27. // in C++ (for instance, passing by reference, or
  28. // passing structures as concrete values) are not legal
  29. // for a typical scripting language. We map these types
  30. // of parameters to something equivalent (for instance,
  31. // a reference becomes a pointer).
  32. //
  33. // For each kind of possible remapping, we define a
  34. // class derived from ParameterRemap that defines the
  35. // exact nature of the remap.
  36. ////////////////////////////////////////////////////////////////////
  37. class ParameterRemap {
  38. public:
  39. INLINE ParameterRemap(CPPType *orig_type);
  40. virtual ~ParameterRemap();
  41. INLINE bool is_valid() const;
  42. INLINE CPPType *get_orig_type() const;
  43. INLINE CPPType *get_new_type() const;
  44. INLINE CPPType *get_temporary_type() const;
  45. INLINE bool has_default_value() const;
  46. INLINE CPPExpression *get_default_value() const;
  47. INLINE void set_default_value(CPPExpression *expr);
  48. virtual void pass_parameter(ostream &out, const string &variable_name);
  49. virtual string prepare_return_expr(ostream &out, int indent_level,
  50. const string &expression);
  51. virtual string get_return_expr(const string &expression);
  52. virtual string temporary_to_return(const string &temporary);
  53. virtual bool return_value_needs_management();
  54. virtual FunctionIndex get_return_value_destructor();
  55. virtual bool return_value_should_be_simple();
  56. virtual bool new_type_is_atomic_string();
  57. virtual bool is_this();
  58. protected:
  59. bool _is_valid;
  60. CPPType *_orig_type;
  61. CPPType *_new_type;
  62. CPPType *_temporary_type;
  63. CPPExpression *_default_value;
  64. };
  65. #include "parameterRemap.I"
  66. #endif