parameterRemap.h 2.8 KB

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