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) |
![]() | |
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 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 | |
![]() | |
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) |
![]() | |
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 45 of file t_py_generator.cc.
|
inline |
Definition at line 47 of file t_py_generator.cc.
string t_py_generator::argument_list | ( | t_struct * | tstruct | ) |
Renders a field list
Definition at line 4051 of file t_py_generator.cc.
|
virtual |
Closes the type files
Reimplemented from t_generator.
Definition at line 574 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 3990 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 4022 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 4036 of file t_py_generator.cc.
string t_py_generator::future_imports | ( | ) |
Prints standard future imports
Definition at line 566 of file t_py_generator.cc.
|
virtual |
Generate a constant value
Reimplemented from t_generator.
Definition at line 644 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 3460 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 3337 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 3624 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 3568 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 3609 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 3444 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 605 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 3143 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 2514 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 813 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 1063 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_struct * | tstruct | ||
) |
void t_py_generator::generate_python_docstring | ( | std::ofstream & | out, |
t_function * | tfunction | ||
) |
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_doc * | tdoc | ||
) |
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 3643 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 3908 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 3862 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 3898 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 3755 of file t_py_generator.cc.
|
virtual |
Generates a thrift service
tservice | The service definition |
Implements t_generator.
Definition at line 2451 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 2582 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 2495 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 2537 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 2858 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 3028 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 595 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 792 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 378 of file t_py_generator.cc.
|
inlinestatic |
Definition at line 287 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 553 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 658 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 474 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 4007 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 458 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 4082 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 4167 of file t_py_generator.cc.
|
private |
Definition at line 326 of file t_py_generator.cc.
|
private |
Definition at line 360 of file t_py_generator.cc.
|
private |
Definition at line 361 of file t_py_generator.cc.
|
private |
File streams
Definition at line 359 of file t_py_generator.cc.
|
private |
True if we should generate dynamic style classes.
Definition at line 316 of file t_py_generator.cc.
|
private |
Definition at line 318 of file t_py_generator.cc.
|
private |
Definition at line 319 of file t_py_generator.cc.
|
private |
Definition at line 320 of file t_py_generator.cc.
|
private |
True if we should generate new-style classes.
Definition at line 311 of file t_py_generator.cc.
|
private |
Definition at line 324 of file t_py_generator.cc.
|
private |
True if we should generate Twisted-friendly RPC services.
Definition at line 331 of file t_py_generator.cc.
|
private |
True if strings should be encoded using utf-8.
Definition at line 336 of file t_py_generator.cc.
|
private |
Definition at line 322 of file t_py_generator.cc.
|
private |
Definition at line 367 of file t_py_generator.cc.