interfaceMakerPythonSimple.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file interfaceMakerPythonSimple.h
  10. * @author drose
  11. * @date 2001-10-01
  12. */
  13. #ifndef INTERFACEMAKERPYTHONSIMPLE_H
  14. #define INTERFACEMAKERPYTHONSIMPLE_H
  15. #include "dtoolbase.h"
  16. #include "interfaceMakerPython.h"
  17. #include "interrogate_interface.h"
  18. class FunctionRemap;
  19. /**
  20. * An InterfaceMaker for generating simple Python function wrappers around C++
  21. * code. This allows the C++ code to be called by Python, but not necessarily
  22. * in a user-friendly or object-oriented way.
  23. *
  24. * You probably want to use InterfaceMakerPythonObj for a full object-oriented
  25. * solution. This InterfaceMaker is primarily useful as a stopgap for our old
  26. * Python-based FFI system.
  27. */
  28. class InterfaceMakerPythonSimple : public InterfaceMakerPython {
  29. public:
  30. InterfaceMakerPythonSimple(InterrogateModuleDef *def);
  31. virtual ~InterfaceMakerPythonSimple();
  32. virtual void write_includes(std::ostream &out);
  33. virtual void write_prototypes(std::ostream &out,std::ostream *out_h);
  34. virtual void write_functions(std::ostream &out);
  35. virtual void write_module(std::ostream &out,std::ostream *out_h, InterrogateModuleDef *def);
  36. virtual bool synthesize_this_parameter();
  37. protected:
  38. virtual std::string get_wrapper_prefix();
  39. virtual std::string get_unique_prefix();
  40. virtual void
  41. record_function_wrapper(InterrogateFunction &ifunc,
  42. FunctionWrapperIndex wrapper_index);
  43. private:
  44. void write_prototype_for(std::ostream &out, Function *func);
  45. void write_function_for(std::ostream &out, Function *func);
  46. void write_function_instance(std::ostream &out, Function *func,
  47. FunctionRemap *remap);
  48. void pack_return_value(std::ostream &out, int indent_level,
  49. FunctionRemap *remap, std::string return_expr);
  50. };
  51. #endif