interfaceMakerPythonSimple.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Filename: interfaceMakerPythonSimple.h
  2. // Created by: drose (01Oct01)
  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 INTERFACEMAKERPYTHONSIMPLE_H
  19. #define INTERFACEMAKERPYTHONSIMPLE_H
  20. #include "dtoolbase.h"
  21. #include "interfaceMakerPython.h"
  22. #include "interrogate_interface.h"
  23. class FunctionRemap;
  24. ////////////////////////////////////////////////////////////////////
  25. // Class : InterfaceMakerPythonSimple
  26. // Description : An InterfaceMaker for generating simple Python
  27. // function wrappers around C++ code. This allows the
  28. // C++ code to be called by Python, but not necessarily
  29. // in a user-friendly or object-oriented way.
  30. //
  31. // You probably want to use InterfaceMakerPythonObj for
  32. // a full object-oriented solution. This InterfaceMaker
  33. // is primarily useful as a stopgap for our old
  34. // Python-based FFI system.
  35. ////////////////////////////////////////////////////////////////////
  36. class InterfaceMakerPythonSimple : public InterfaceMakerPython {
  37. public:
  38. InterfaceMakerPythonSimple(InterrogateModuleDef *def);
  39. virtual ~InterfaceMakerPythonSimple();
  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. protected:
  45. virtual string get_wrapper_prefix();
  46. virtual string get_unique_prefix();
  47. virtual void
  48. record_function_wrapper(InterrogateFunction &ifunc,
  49. FunctionWrapperIndex wrapper_index);
  50. private:
  51. void write_prototype_for(ostream &out, Function *func);
  52. void write_function_for(ostream &out, Function *func);
  53. void write_function_instance(ostream &out, Function *func,
  54. FunctionRemap *remap);
  55. void pack_return_value(ostream &out, int indent_level,
  56. FunctionRemap *remap, string return_expr);
  57. };
  58. #endif