|
OpenSDN source code
|


Public Member Functions | |
| t_py_generator (t_program *program, const std::map< std::string, std::string > &parsed_options, const std::string &option_string) | |
| void | init_generator () |
| void | close_generator () |
| void | generate_typedef (t_typedef *ttypedef) |
| void | generate_enum (t_enum *tenum) |
| void | generate_const (t_const *tconst) |
| void | generate_struct (t_struct *tstruct) |
| void | generate_xception (t_struct *txception) |
| void | generate_service (t_service *tservice) |
| std::string | render_const_value (t_type *type, t_const_value *value) |
| void | generate_py_struct (t_struct *tstruct, bool is_exception) |
| void | generate_py_struct_definition (std::ofstream &out, t_struct *tstruct, bool is_xception=false, bool is_result=false) |
| void | generate_py_struct_reader (std::ofstream &out, t_struct *tstruct) |
| void | generate_py_struct_writer (std::ofstream &out, t_struct *tstruct) |
| void | generate_py_struct_required_validator (std::ofstream &out, t_struct *tstruct) |
| void | generate_py_function_helpers (t_function *tfunction) |
| void | generate_service_helpers (t_service *tservice) |
| void | generate_service_interface (t_service *tservice) |
| void | generate_service_client (t_service *tservice) |
| void | generate_service_remote (t_service *tservice) |
| void | generate_service_server (t_service *tservice) |
| void | generate_process_function (t_service *tservice, t_function *tfunction) |
| void | generate_deserialize_field (std::ofstream &out, t_field *tfield, std::string prefix="", bool inclass=false) |
| void | generate_deserialize_struct (std::ofstream &out, t_struct *tstruct, std::string prefix="") |
| void | generate_deserialize_container (std::ofstream &out, t_type *ttype, std::string prefix="") |
| void | generate_deserialize_set_element (std::ofstream &out, t_set *tset, std::string prefix="") |
| void | generate_deserialize_map_element (std::ofstream &out, t_map *tmap, std::string prefix="") |
| void | generate_deserialize_list_element (std::ofstream &out, t_list *tlist, std::string prefix="") |
| void | generate_serialize_field (std::ofstream &out, t_field *tfield, std::string prefix="") |
| void | generate_serialize_struct (std::ofstream &out, t_struct *tstruct, std::string prefix="") |
| void | generate_serialize_container (std::ofstream &out, t_type *ttype, std::string prefix="") |
| void | generate_serialize_map_element (std::ofstream &out, t_map *tmap, std::string kiter, std::string viter) |
| void | generate_serialize_set_element (std::ofstream &out, t_set *tmap, std::string iter) |
| void | generate_serialize_list_element (std::ofstream &out, t_list *tlist, std::string iter) |
| void | generate_python_docstring (std::ofstream &out, t_struct *tstruct) |
| void | generate_python_docstring (std::ofstream &out, t_function *tfunction) |
| void | generate_python_docstring (std::ofstream &out, t_doc *tdoc, t_struct *tstruct, const char *subheader) |
| void | generate_python_docstring (std::ofstream &out, t_doc *tdoc) |
| std::string | py_autogen_comment () |
| std::string | future_imports () |
| std::string | py_imports () |
| std::string | render_includes () |
| std::string | render_fastbinary_includes () |
| std::string | declare_argument (t_field *tfield) |
| std::string | render_field_default_value (t_field *tfield) |
| std::string | type_name (t_type *ttype) |
| std::string | function_signature (t_function *tfunction, std::string prefix="") |
| std::string | function_signature_if (t_function *tfunction, std::string prefix="") |
| std::string | argument_list (t_struct *tstruct) |
| std::string | type_to_enum (t_type *ttype) |
| std::string | type_to_spec_args (t_type *ttype) |
Public Member Functions inherited from t_generator | |
| t_generator (t_program *program) | |
| virtual | ~t_generator () |
| virtual void | generate_program () |
| const t_program * | get_program () const |
| void | generate_docstring_comment (std::ofstream &out, const std::string &comment_start, const std::string &line_prefix, const std::string &contents, const std::string &comment_end) |
| virtual std::string | escape_string (const std::string &in) const |
| std::string | get_escaped_string (t_const_value *constval) |
Static Public Member Functions | |
| static bool | is_valid_namespace (const std::string &sub_namespace) |
| static std::string | get_real_py_module (const t_program *program, bool gen_twisted) |
Static Public Member Functions inherited from t_generator | |
| static bool | is_valid_namespace (const std::string &sub_namespace) |
| static t_type * | get_true_type (t_type *type) |
Private Attributes | |
| bool | gen_newstyle_ |
| bool | gen_dynamic_ |
| bool | gen_dynbase_ |
| std::string | gen_dynbaseclass_ |
| std::string | gen_dynbaseclass_exc_ |
| std::string | import_dynbase_ |
| bool | gen_slots_ |
| std::string | copy_options_ |
| bool | gen_twisted_ |
| bool | gen_utf8strings_ |
| std::ofstream | f_types_ |
| std::ofstream | f_consts_ |
| std::ofstream | f_service_ |
| std::string | package_dir_ |
Additional Inherited Members | |
Protected Member Functions inherited from t_generator | |
| virtual void | generate_consts (std::vector< t_const * > consts) |
| virtual std::string | get_program_name (t_program *tprogram) |
| virtual std::string | get_service_name (t_service *tservice) |
| virtual std::string | get_out_dir () const |
| std::string | tmp (std::string name) |
| void | indent_up () |
| void | indent_down () |
| std::string | indent () |
| std::ostream & | indent (std::ostream &os) |
| std::string | capitalize (std::string in) |
| std::string | decapitalize (std::string in) |
| std::string | lowercase (std::string in) |
| std::string | uppercase (std::string in) |
| std::string | underscore (std::string in) |
| std::string | camelcase (std::string in) |
Protected Attributes inherited from t_generator | |
| t_program * | program_ |
| std::string | program_name_ |
| std::string | service_name_ |
| std::string | out_dir_base_ |
| std::map< char, std::string > | escape_ |
Python code generator.
Definition at line 48 of file t_py_generator.cc.
|
inline |
Definition at line 50 of file t_py_generator.cc.
| string t_py_generator::argument_list | ( | t_struct * | tstruct | ) |
Renders a field list
Definition at line 4054 of file t_py_generator.cc.

|
virtual |
Closes the type files
Reimplemented from t_generator.
Definition at line 577 of file t_py_generator.cc.
| string t_py_generator::declare_argument | ( | t_field * | tfield | ) |
Declares an argument, which may include initialization as necessary.
| tfield | The field |
Definition at line 3993 of file t_py_generator.cc.

| string t_py_generator::function_signature | ( | t_function * | tfunction, |
| std::string | prefix = "" |
||
| ) |
Renders a function signature of the form 'type name(args)'
| tfunction | Function definition |
Definition at line 4025 of file t_py_generator.cc.

| string t_py_generator::function_signature_if | ( | t_function * | tfunction, |
| std::string | prefix = "" |
||
| ) |
Renders an interface function signature of the form 'type name(args)'
| tfunction | Function definition |
Definition at line 4039 of file t_py_generator.cc.

| string t_py_generator::future_imports | ( | ) |
Prints standard future imports
Definition at line 569 of file t_py_generator.cc.
|
virtual |
Generate a constant value
Reimplemented from t_generator.
Definition at line 647 of file t_py_generator.cc.

| void t_py_generator::generate_deserialize_container | ( | std::ofstream & | out, |
| t_type * | ttype, | ||
| std::string | prefix = "" |
||
| ) |
Serialize a container by writing out the header followed by data and then a footer.
Definition at line 3463 of file t_py_generator.cc.

| void t_py_generator::generate_deserialize_field | ( | std::ofstream & | out, |
| t_field * | tfield, | ||
| std::string | prefix = "", |
||
| bool | inclass = false |
||
| ) |
Serialization constructs
Deserializes a field of any type.
Definition at line 3340 of file t_py_generator.cc.

| void t_py_generator::generate_deserialize_list_element | ( | std::ofstream & | out, |
| t_list * | tlist, | ||
| std::string | prefix = "" |
||
| ) |
Write a list element
Definition at line 3627 of file t_py_generator.cc.

| void t_py_generator::generate_deserialize_map_element | ( | std::ofstream & | out, |
| t_map * | tmap, | ||
| std::string | prefix = "" |
||
| ) |
Generates code to deserialize a map
Definition at line 3571 of file t_py_generator.cc.

| void t_py_generator::generate_deserialize_set_element | ( | std::ofstream & | out, |
| t_set * | tset, | ||
| std::string | prefix = "" |
||
| ) |
Write a set element
Definition at line 3612 of file t_py_generator.cc.

| void t_py_generator::generate_deserialize_struct | ( | std::ofstream & | out, |
| t_struct * | tstruct, | ||
| std::string | prefix = "" |
||
| ) |
Generates an unserializer for a struct, calling read()
Definition at line 3447 of file t_py_generator.cc.

|
virtual |
Generates code for an enumerated type. Done using a class to scope the values.
| tenum | The enumeration |
Implements t_generator.
Definition at line 608 of file t_py_generator.cc.

| void t_py_generator::generate_process_function | ( | t_service * | tservice, |
| t_function * | tfunction | ||
| ) |
Generates a process function definition.
| tfunction | The function to write a dispatcher for |
Definition at line 3146 of file t_py_generator.cc.

| void t_py_generator::generate_py_function_helpers | ( | t_function * | tfunction | ) |
Generates a struct and helpers for a function.
| tfunction | The function |
Definition at line 2517 of file t_py_generator.cc.

| void t_py_generator::generate_py_struct | ( | t_struct * | tstruct, |
| bool | is_exception | ||
| ) |
| void t_py_generator::generate_py_struct_definition | ( | std::ofstream & | out, |
| t_struct * | tstruct, | ||
| bool | is_xception = false, |
||
| bool | is_result = false |
||
| ) |
Generates a struct definition for a thrift data type.
| tstruct | The struct definition |
Definition at line 816 of file t_py_generator.cc.

| void t_py_generator::generate_py_struct_reader | ( | std::ofstream & | out, |
| t_struct * | tstruct | ||
| ) |
Generates the read method for a struct
Definition at line 1066 of file t_py_generator.cc.

| void t_py_generator::generate_py_struct_required_validator | ( | std::ofstream & | out, |
| t_struct * | tstruct | ||
| ) |
| void t_py_generator::generate_py_struct_writer | ( | std::ofstream & | out, |
| t_struct * | tstruct | ||
| ) |
| void t_py_generator::generate_python_docstring | ( | std::ofstream & | out, |
| t_doc * | tdoc | ||
| ) |
| void t_py_generator::generate_python_docstring | ( | std::ofstream & | out, |
| t_doc * | tdoc, | ||
| t_struct * | tstruct, | ||
| const char * | subheader | ||
| ) |
| void t_py_generator::generate_python_docstring | ( | std::ofstream & | out, |
| t_function * | tfunction | ||
| ) |
| void t_py_generator::generate_python_docstring | ( | std::ofstream & | out, |
| t_struct * | tstruct | ||
| ) |
| void t_py_generator::generate_serialize_container | ( | std::ofstream & | out, |
| t_type * | ttype, | ||
| std::string | prefix = "" |
||
| ) |
| void t_py_generator::generate_serialize_field | ( | std::ofstream & | out, |
| t_field * | tfield, | ||
| std::string | prefix = "" |
||
| ) |
Serializes a field of any type.
| tfield | The field to serialize |
| prefix | Name to prepend to field name |
Definition at line 3646 of file t_py_generator.cc.

| void t_py_generator::generate_serialize_list_element | ( | std::ofstream & | out, |
| t_list * | tlist, | ||
| std::string | iter | ||
| ) |
Serializes the members of a list.
Definition at line 3911 of file t_py_generator.cc.

| void t_py_generator::generate_serialize_map_element | ( | std::ofstream & | out, |
| t_map * | tmap, | ||
| std::string | kiter, | ||
| std::string | viter | ||
| ) |
Serializes the members of a map.
Definition at line 3865 of file t_py_generator.cc.

| void t_py_generator::generate_serialize_set_element | ( | std::ofstream & | out, |
| t_set * | tmap, | ||
| std::string | iter | ||
| ) |
Serializes the members of a set.
Definition at line 3901 of file t_py_generator.cc.

| void t_py_generator::generate_serialize_struct | ( | std::ofstream & | out, |
| t_struct * | tstruct, | ||
| std::string | prefix = "" |
||
| ) |
Serializes all the members of a struct.
| tstruct | The struct to serialize |
| prefix | String prefix to attach to all fields |
Definition at line 3758 of file t_py_generator.cc.

|
virtual |
Generates a thrift service
| tservice | The service definition |
Implements t_generator.
Definition at line 2454 of file t_py_generator.cc.

| void t_py_generator::generate_service_client | ( | t_service * | tservice | ) |
Generates a service client definition.
| tservice | The service to generate a server for. |
Definition at line 2585 of file t_py_generator.cc.

| void t_py_generator::generate_service_helpers | ( | t_service * | tservice | ) |
Sandesh generation code Service-level generation functions
Generates helper functions for a service.
| tservice | The service to generate a header definition for |
Definition at line 2498 of file t_py_generator.cc.

| void t_py_generator::generate_service_interface | ( | t_service * | tservice | ) |
Generates a service interface definition.
| tservice | The service to generate a header definition for |
Definition at line 2540 of file t_py_generator.cc.

| void t_py_generator::generate_service_remote | ( | t_service * | tservice | ) |
Generates a command line tool for making remote requests
| tservice | The service to generate a remote for. |
Definition at line 2861 of file t_py_generator.cc.

| void t_py_generator::generate_service_server | ( | t_service * | tservice | ) |
Generates a service server definition.
| tservice | The service to generate a server for. |
Definition at line 3031 of file t_py_generator.cc.

|
virtual |
|
virtual |
Program-level generation functions
Generates a typedef. This is not done in Python, types are all implicit.
| ttypedef | The type definition |
Implements t_generator.
Definition at line 598 of file t_py_generator.cc.
|
virtual |
Generates a struct definition for a thrift exception. Basically the same as a struct but extends the Exception class.
| txception | The struct definition |
Reimplemented from t_generator.
Definition at line 795 of file t_py_generator.cc.
|
inlinestatic |
|
virtual |
Init and close methods
Prepares for file generation by opening up the necessary file output streams.
| tprogram | The program to generate |
Reimplemented from t_generator.
Definition at line 381 of file t_py_generator.cc.
|
inlinestatic |
Definition at line 290 of file t_py_generator.cc.
| string t_py_generator::py_autogen_comment | ( | ) |
| string t_py_generator::py_imports | ( | ) |
Prints standard thrift imports
Definition at line 556 of file t_py_generator.cc.
| string t_py_generator::render_const_value | ( | t_type * | type, |
| t_const_value * | value | ||
| ) |
Prints the value of a constant with the given type. Note that type checking is NOT performed in this function as it is always run beforehand using the validate_types method in main.cc
Definition at line 661 of file t_py_generator.cc.

| string t_py_generator::render_fastbinary_includes | ( | ) |
Renders all the imports necessary to use the accelerated TBinaryProtocol
Definition at line 477 of file t_py_generator.cc.
| string t_py_generator::render_field_default_value | ( | t_field * | tfield | ) |
Renders a field default value, returns None otherwise.
| tfield | The field |
Definition at line 4010 of file t_py_generator.cc.

| string t_py_generator::render_includes | ( | ) |
Renders all the imports necessary for including another Thrift program
Definition at line 461 of file t_py_generator.cc.
| string t_py_generator::type_name | ( | t_type * | ttype | ) |
| string t_py_generator::type_to_enum | ( | t_type * | type | ) |
Converts the parse type to a Python tyoe
Definition at line 4085 of file t_py_generator.cc.

| string t_py_generator::type_to_spec_args | ( | t_type * | ttype | ) |
See the comment inside generate_py_struct_definition for what this is.
Definition at line 4170 of file t_py_generator.cc.

|
private |
Definition at line 329 of file t_py_generator.cc.
|
private |
Definition at line 363 of file t_py_generator.cc.
|
private |
Definition at line 364 of file t_py_generator.cc.
|
private |
File streams
Definition at line 362 of file t_py_generator.cc.
|
private |
True if we should generate dynamic style classes.
Definition at line 319 of file t_py_generator.cc.
|
private |
Definition at line 321 of file t_py_generator.cc.
|
private |
Definition at line 322 of file t_py_generator.cc.
|
private |
Definition at line 323 of file t_py_generator.cc.
|
private |
True if we should generate new-style classes.
Definition at line 314 of file t_py_generator.cc.
|
private |
Definition at line 327 of file t_py_generator.cc.
|
private |
True if we should generate Twisted-friendly RPC services.
Definition at line 334 of file t_py_generator.cc.
|
private |
True if strings should be encoded using utf-8.
Definition at line 339 of file t_py_generator.cc.
|
private |
Definition at line 325 of file t_py_generator.cc.
|
private |
Definition at line 370 of file t_py_generator.cc.