functionRemap.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // Filename: functionRemap.h
  2. // Created by: drose (19Sep01)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, 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://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef FUNCTIONREMAP_H
  19. #define FUNCTIONREMAP_H
  20. #include "dtoolbase.h"
  21. #include "interrogate_interface.h"
  22. #include "vector_string.h"
  23. #include <vector>
  24. class InterrogateBuilder;
  25. class InterrogateType;
  26. class InterrogateFunction;
  27. class ParameterRemap;
  28. class CPPType;
  29. class CPPInstance;
  30. class CPPStructType;
  31. class CPPScope;
  32. class CPPFunctionType;
  33. class InterfaceMaker;
  34. ////////////////////////////////////////////////////////////////////
  35. // Class : FunctionRemap
  36. // Description : This class describes how to remap a C++ function (and
  37. // its list of parameters and return type) to a wrapped
  38. // function, for a particular scripting language.
  39. //
  40. // The InterfaceMaker class will create one of these for
  41. // each function, including one for each instance of an
  42. // overloaded function.
  43. ////////////////////////////////////////////////////////////////////
  44. class FunctionRemap {
  45. public:
  46. FunctionRemap(const InterrogateType &itype,
  47. const InterrogateFunction &ifunc,
  48. CPPInstance *cppfunc, int num_default_parameters,
  49. InterfaceMaker *interface_maker);
  50. ~FunctionRemap();
  51. string get_parameter_name(int n) const;
  52. string call_function(ostream &out, int indent_level,
  53. bool convert_result, const string &container,
  54. const vector_string &pexprs = vector_string()) const;
  55. void write_orig_prototype(ostream &out, int indent_level) const;
  56. FunctionWrapperIndex make_wrapper_entry(FunctionIndex function_index);
  57. class Parameter {
  58. public:
  59. bool _has_name;
  60. string _name;
  61. ParameterRemap *_remap;
  62. };
  63. enum Type {
  64. T_normal,
  65. T_constructor,
  66. T_destructor,
  67. T_typecast_method,
  68. T_assignment_method,
  69. T_typecast,
  70. T_getter,
  71. T_setter
  72. };
  73. typedef vector<Parameter> Parameters;
  74. Parameters _parameters;
  75. ParameterRemap *_return_type;
  76. bool _void_return;
  77. bool _ForcedVoidReturn;
  78. bool _has_this;
  79. bool _blocking;
  80. bool _const_method;
  81. int _first_true_parameter;
  82. int _num_default_parameters;
  83. Type _type;
  84. string _expression;
  85. string _function_signature;
  86. string _hash;
  87. string _unique_name;
  88. string _reported_name;
  89. string _wrapper_name;
  90. FunctionWrapperIndex _wrapper_index;
  91. bool _return_value_needs_management;
  92. FunctionIndex _return_value_destructor;
  93. bool _manage_reference_count;
  94. CPPType *_cpptype;
  95. CPPScope *_cppscope;
  96. CPPInstance *_cppfunc;
  97. CPPFunctionType *_ftype;
  98. bool _is_valid;
  99. private:
  100. string get_call_str(const string &container, const vector_string &pexprs) const;
  101. string get_parameter_expr(int n, const vector_string &pexprs) const;
  102. bool setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_maker);
  103. };
  104. #endif