interfaceMakerPythonObj.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Filename: interfaceMakerPythonObj.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 INTERFACEMAKERPYTHONOBJ_H
  19. #define INTERFACEMAKERPYTHONOBJ_H
  20. #include "dtoolbase.h"
  21. #include "interfaceMakerPython.h"
  22. #include "interrogate_interface.h"
  23. #include <map>
  24. class InterrogateType;
  25. class InterrogateFunction;
  26. class FunctionRemap;
  27. class CPPInstance;
  28. class FunctionWriterPtrFromPython;
  29. class FunctionWriterPtrToPython;
  30. ////////////////////////////////////////////////////////////////////
  31. // Class : InterfaceMakerPythonObj
  32. // Description : An InterfaceMaker suitable for generating
  33. // object-oriented Python code, that can be imported and
  34. // used directly by Python.
  35. ////////////////////////////////////////////////////////////////////
  36. class InterfaceMakerPythonObj : public InterfaceMakerPython {
  37. public:
  38. InterfaceMakerPythonObj(InterrogateModuleDef *def);
  39. virtual ~InterfaceMakerPythonObj();
  40. virtual void write_prototypes(ostream &out,ostream *out_h);
  41. virtual void write_functions(ostream &out);
  42. virtual void write_module(ostream &out,ostream *out_h, InterrogateModuleDef *def);
  43. virtual bool synthesize_this_parameter();
  44. static string get_builder_name(CPPType *struct_type);
  45. protected:
  46. virtual string get_wrapper_prefix();
  47. private:
  48. void write_class_wrapper(ostream &out, Object *object);
  49. void write_prototype_for(ostream &out, Function *func);
  50. void write_function_for(ostream &out, Function *func);
  51. void write_function_instance(ostream &out, int indent_level, Function *func,
  52. FunctionRemap *remap, string &expected_params);
  53. void pack_return_value(ostream &out, int indent_level,
  54. FunctionRemap *remap, string return_expr);
  55. FunctionWriterPtrFromPython *get_ptr_from_python(CPPType *type);
  56. FunctionWriterPtrToPython *get_ptr_to_python(CPPType *type);
  57. typedef map<CPPType *, FunctionWriter *> PtrConverter;
  58. PtrConverter _from_python;
  59. PtrConverter _to_python;
  60. };
  61. #endif