Chapter 16. The ePolyglot Eiffel object hierarchy

Table of Contents
PYTHON_CLIENT and the low level interface
PYTHON_OBJECT
The PYTHON_NUMBER tree
The PYTHON_SEQUNCE tree
The PYTHON_MAPPING tree
PYTHON_FILE
PYTHON_OBJECT_FACTORY
PYTHON_USER_CLASS
PYTHON_MODULE
PYTHON_USER_MODULE

The entire ePolyglot library represents a number of interfaces to Python from Eiffel. In this chapter, each class is listed in short form with a brief blurb describing its use. This is not intended to be a complete tutorial reference (which would be beyond the scope of this document) but rather lists the short form of each class to give an idea of the features available to each.

PYTHON_CLIENT and the low level interface

The SWIG-generated PYTHON_CLIENT_WRAPPER class is the base interface to the Python/C library; it represents the lowest level of interaction between Eiffel and Python. Typically, client applications will inherit from PYTHON_CLIENT and use the initialize_python feature.

PYTHON_CLIENT_WRAPPER

class interface PYTHON_CLIENT_WRAPPER
feature(s) from PYTHON_CLIENT_WRAPPER
   --  external C functions
   py_initialize
   py_is_initialized: INTEGER
   py_finalize
   py_new_interpreter: POINTER
   py_end_interpreter (tstate: POINTER)
   py_set_program_name (name: STRING)
   py_get_program_name: POINTER
   py_get_prefix: POINTER
   py_get_exec_prefix: POINTER
   py_get_program_full_path: POINTER
   py_get_path: POINTER
   py_get_version: POINTER
   py_get_platform: POINTER
   py_get_copyright: POINTER
   py_get_compiler: POINTER
   py_get_build_info: POINTER
   py_run_any_file (fp: POINTER; filename: STRING): INTEGER
   py_run_simple_string (command: STRING): INTEGER
   py_run_simple_file (fp: POINTER; filename: STRING): INTEGER
   py_run_interactive_one (fp: POINTER; filename: STRING): INTEGER
   py_run_interactive_loop (fp: POINTER; filename: STRING): INTEGER
   py_parser_simple_parse_string (str: STRING; start: INTEGER): POINTER
   py_parser_simple_parse_file (fp: POINTER; filename: STRING; start: INTEGER): POINTER
   py_run_string (str: STRING; start: INTEGER; globals: POINTER; locals: POINTER): POINTER
   py_run_file (fp: POINTER; filename: STRING; start: INTEGER; globals: POINTER; locals: POINTER): POINTER
   py_compile_string (str: STRING; filename: STRING; start: INTEGER): POINTER
   Py_eval_input_const: INTEGER
   Py_file_input_const: INTEGER
   Py_single_input_const: INTEGER
   Py_print_raw_const: INTEGER
   py_xincref (o: POINTER)
   py_incref (o: POINTER)
   py_decref (o: POINTER)
   py_xdecref (o: POINTER)
   py_object_ref_count (o: POINTER): INTEGER
   py_err_print
   py_err_occurred: POINTER
   py_err_exception_matches (exc: POINTER): INTEGER
   py_err_given_exception_matches (exc: POINTER; exc2: POINTER): INTEGER
   py_err_clear
   py_err_restore (type: POINTER; value: POINTER; traceback: POINTER)
   py_err_set_string (type: POINTER; message: STRING)
   py_err_set_object (type: POINTER; value: POINTER)
   py_err_set_none (type: POINTER)
   py_err_bad_argument: INTEGER
   py_err_no_memory: POINTER
   py_err_set_from_errno (type: POINTER): POINTER
   py_err_bad_internal_call
   py_err_check_signals: INTEGER
   py_err_set_interrupt
   py_err_new_exception (name: STRING; base: POINTER; dict: POINTER): POINTER
   py_exc_exception_set (p0: POINTER)
   py_exc_exception_get: POINTER
   py_exc_standard_error_set (p0: POINTER)
   py_exc_standard_error_get: POINTER
   py_exc_arithmetic_error_set (p0: POINTER)
   py_exc_arithmetic_error_get: POINTER
   py_exc_lookup_error_set (p0: POINTER)
   py_exc_lookup_error_get: POINTER
   py_exc_assertion_error_set (p0: POINTER)
   py_exc_assertion_error_get: POINTER
   py_exc_attribute_error_set (p0: POINTER)
   py_exc_attribute_error_get: POINTER
   py_exc_eoferror_set (p0: POINTER)
   py_exc_eoferror_get: POINTER
   py_exc_environment_error_set (p0: POINTER)
   py_exc_environment_error_get: POINTER
   py_exc_floating_point_error_set (p0: POINTER)
   py_exc_floating_point_error_get: POINTER
   py_exc_ioerror_set (p0: POINTER)
   py_exc_ioerror_get: POINTER
   py_exc_import_error_set (p0: POINTER)
   py_exc_import_error_get: POINTER
   py_exc_index_error_set (p0: POINTER)
   py_exc_index_error_get: POINTER
   py_exc_key_error_set (p0: POINTER)
   py_exc_key_error_get: POINTER
   py_exc_keyboard_interrupt_set (p0: POINTER)
   py_exc_keyboard_interrupt_get: POINTER
   py_exc_memory_error_set (p0: POINTER)
   py_exc_memory_error_get: POINTER
   py_exc_name_error_set (p0: POINTER)
   py_exc_name_error_get: POINTER
   py_exc_not_implemented_error_set (p0: POINTER)
   py_exc_not_implemented_error_get: POINTER
   py_exc_oserror_set (p0: POINTER)
   py_exc_oserror_get: POINTER
   py_exc_overflow_error_set (p0: POINTER)
   py_exc_overflow_error_get: POINTER
   py_exc_runtime_error_set (p0: POINTER)
   py_exc_runtime_error_get: POINTER
   py_exc_syntax_error_set (p0: POINTER)
   py_exc_syntax_error_get: POINTER
   py_exc_system_error_set (p0: POINTER)
   py_exc_system_error_get: POINTER
   py_exc_system_exit_set (p0: POINTER)
   py_exc_system_exit_get: POINTER
   py_exc_type_error_set (p0: POINTER)
   py_exc_type_error_get: POINTER
   py_exc_value_error_set (p0: POINTER)
   py_exc_value_error_get: POINTER
   py_exc_zero_division_error_set (p0: POINTER)
   py_exc_zero_division_error_get: POINTER
   py_fd_is_interactive (file_pointer: POINTER; filename: STRING): INTEGER
   py_fatal_error (message: STRING)
   py_exit (status: INTEGER)
   py_import_import_module (name: STRING): POINTER
   py_import_import_module_ex (name: STRING; globals: POINTER; locals: POINTER; from_list: POINTER): POINTER
   py_import_import (name: POINTER): POINTER
   py_import_reload_module (module: POINTER): POINTER
   py_import_add_module (name: STRING): POINTER
   py_import_exec_code_module (name: STRING; code_object: POINTER): POINTER
   py_import_get_module_dict: POINTER
   py_import_init
   py_import_cleanup
   py_import_fini
   py_import_find_extension (arg: STRING; arg2: STRING): POINTER
   py_import_fixup_extension (arg: STRING; arg2: STRING): POINTER
   py_import_import_frozen_module (arg: STRING): INTEGER
   py_import_frozen_modules_set (p0: POINTER)
   py_import_frozen_modules_get: POINTER
   py_object_print (o: POINTER; fp: POINTER; flags: INTEGER): INTEGER
   py_object_has_attr_string (o: POINTER; attr_name: STRING): INTEGER
   py_object_has_attr (o: POINTER; attr_name: POINTER): INTEGER
   py_object_get_attr_string (o: POINTER; attr_name: STRING): POINTER
   py_object_get_attr (o: POINTER; attr_name: POINTER): POINTER
   py_object_set_attr_string (o: POINTER; attr_name: STRING; new_value: POINTER): INTEGER
   py_object_set_attr (o: POINTER; attr_name: POINTER; new_value: POINTER): INTEGER
   py_object_del_attr_string (o: POINTER; attr_name: STRING): INTEGER
   py_object_del_attr (o: POINTER; attr_name: POINTER): INTEGER
   wrap_py_object_cmp (o1: POINTER; o2: POINTER): INTEGER
   py_object_compare (o1: POINTER; o2: POINTER): INTEGER
   py_object_repr (o: POINTER): POINTER
   py_object_str (o: POINTER): POINTER
   py_callable_check (o: POINTER): INTEGER
   py_object_call_object (callable_object: POINTER; args: POINTER): POINTER
   py_object_is_true (o: POINTER): INTEGER
   py_object_type (o: POINTER): POINTER
   py_object_length (o: POINTER): INTEGER
   py_object_get_item (o: POINTER; key: POINTER): POINTER
   py_object_set_item (o: POINTER; key: POINTER; new_value: POINTER): INTEGER
   py_object_del_item (o: POINTER; key: POINTER): INTEGER
   py_number_check (o: POINTER): INTEGER
   py_number_add (o1: POINTER; o2: POINTER): POINTER
   py_number_subtract (o1: POINTER; o2: POINTER): POINTER
   py_number_multiply (o1: POINTER; o2: POINTER): POINTER
   py_number_divide (o1: POINTER; o2: POINTER): POINTER
   py_number_remainder (o1: POINTER; o2: POINTER): POINTER
   py_number_divmod (o1: POINTER; o2: POINTER): POINTER
   py_number_power (o1: POINTER; o2: POINTER; o3: POINTER): POINTER
   py_number_negative (o1: POINTER): POINTER
   py_number_positive (o1: POINTER): POINTER
   py_number_absolute (o1: POINTER): POINTER
   py_number_invert (o1: POINTER): POINTER
   py_number_lshift (o1: POINTER; o2: POINTER): POINTER
   py_number_rshift (o1: POINTER; o2: POINTER): POINTER
   py_number_and (o1: POINTER; o2: POINTER): POINTER
   py_number_xor (o1: POINTER; o2: POINTER): POINTER
   py_number_or (o1: POINTER; o2: POINTER): POINTER
   py_number_int (o1: POINTER): POINTER
   py_number_long (o1: POINTER): POINTER
   py_number_float (o1: POINTER): POINTER
   py_sequence_check (o: POINTER): INTEGER
   py_sequence_length (o: POINTER): INTEGER
   py_sequence_concat (o1: POINTER; o2: POINTER): POINTER
   py_sequence_repeat (o: POINTER; count: INTEGER): POINTER
   py_sequence_get_item (o: POINTER; i: INTEGER): POINTER
   py_sequence_get_slice (o: POINTER; i1: INTEGER; i2: INTEGER): POINTER
   py_sequence_set_item (o: POINTER; i: INTEGER; value: POINTER): INTEGER
   py_sequence_del_item (o: POINTER; i: INTEGER): INTEGER
   py_sequence_set_slice (o: POINTER; i1: INTEGER; i2: INTEGER; value: POINTER): INTEGER
   py_sequence_del_slice (o: POINTER; i1: INTEGER; i2: INTEGER): INTEGER
   py_sequence_tuple (o: POINTER): POINTER
   py_sequence_count (o: POINTER; value: POINTER): INTEGER
   py_sequence_contains (o: POINTER; value: POINTER): INTEGER
   py_sequence_index (o: POINTER; value: POINTER): INTEGER
   py_mapping_check (o: POINTER): INTEGER
   py_mapping_length (o: POINTER): INTEGER
   py_mapping_del_item_string (o: POINTER; key: STRING): INTEGER
   py_mapping_del_item (o: POINTER; key: POINTER): INTEGER
   py_mapping_has_key_string (o: POINTER; key: STRING): INTEGER
   py_mapping_has_key (o: POINTER; key: POINTER): INTEGER
   py_mapping_keys (o: POINTER): POINTER
   py_mapping_values (o: POINTER): POINTER
   py_mapping_items (o: POINTER): POINTER
   py_mapping_get_item_string (o: POINTER; key: STRING): POINTER
   py_mapping_set_item_string (o: POINTER; key: STRING; value: POINTER): INTEGER
   py_type_type_set (p0: POINTER)
   py_type_type_get: POINTER
   py_type_check (o: POINTER): INTEGER
   Py_none_const: POINTER
   py_string_type_set (p0: POINTER)
   py_string_type_get: POINTER
   py_string_check (o: POINTER): INTEGER
   py_string_from_string (value: STRING): POINTER
   py_string_from_string_and_size (value: STRING; length: INTEGER): POINTER
   py_string_size (string: POINTER): INTEGER
   py_string_as_string (string: POINTER): POINTER
   py_string_format (format: POINTER; args: POINTER): POINTER
   py_string_intern_from_string (value: STRING): POINTER
   py_buffer_type_set (p0: POINTER)
   py_buffer_type_get: POINTER
   Py_end_of_buffer_const: INTEGER
   py_buffer_check (p: POINTER): INTEGER
   py_buffer_from_object (base: POINTER; offset: INTEGER; size: INTEGER): POINTER
   py_buffer_from_read_write_object (base: POINTER; offset: INTEGER; size: INTEGER): POINTER
   py_buffer_from_memory (pointer: POINTER; size: INTEGER): POINTER
   py_buffer_from_read_write_memory (pointer: POINTER; size: INTEGER): POINTER
   py_buffer_new (size: INTEGER): POINTER
   py_tuple_type_set (p0: POINTER)
   py_tuple_type_get: POINTER
   py_tuple_check (p: POINTER): INTEGER
   py_tuple_new (length: INTEGER): POINTER
   py_tuple_size (p: POINTER): INTEGER
   py_tuple_get_item (p: POINTER; pos: INTEGER): POINTER
   py_tuple_get_slice (p: POINTER; low: INTEGER; high: INTEGER): POINTER
   py_tuple_set_item (p: POINTER; pos: INTEGER; o: POINTER): INTEGER
   py_list_type_set (p0: POINTER)
   py_list_type_get: POINTER
   py_list_check (p: POINTER): INTEGER
   py_list_new (length: INTEGER): POINTER
   py_list_size (list: POINTER): INTEGER
   py_list_get_item (list: POINTER; index: INTEGER): POINTER
   py_list_set_item (list: POINTER; index: INTEGER; item: POINTER): INTEGER
   py_list_insert (list: POINTER; index: INTEGER; item: POINTER): INTEGER
   py_list_append (list: POINTER; item: POINTER): INTEGER
   py_list_get_slice (list: POINTER; low: INTEGER; high: INTEGER): POINTER
   py_list_set_slice (list: POINTER; low: INTEGER; high: INTEGER; itemlist: POINTER): INTEGER
   py_list_sort (list: POINTER): INTEGER
   py_list_reverse (list: POINTER): INTEGER
   py_list_as_tuple (list: POINTER): POINTER
   py_dict_type_set (p0: POINTER)
   py_dict_type_get: POINTER
   py_dict_check (p: POINTER): INTEGER
   py_dict_new: POINTER
   py_dict_clear (p: POINTER)
   py_dict_set_item (p: POINTER; key: POINTER; value: POINTER): INTEGER
   py_dict_set_item_string (p: POINTER; key: STRING; value: POINTER): INTEGER
   py_dict_del_item (p: POINTER; key: POINTER): INTEGER
   py_dict_del_item_string (p: POINTER; key: STRING): INTEGER
   py_dict_get_item (p: POINTER; key: POINTER): POINTER
   py_dict_get_item_string (p: POINTER; key: STRING): POINTER
   py_dict_items (p: POINTER): POINTER
   py_dict_keys (p: POINTER): POINTER
   py_dict_values (p: POINTER): POINTER
   py_dict_size (p: POINTER): INTEGER
   py_int_type_set (p0: POINTER)
   py_int_type_get: POINTER
   py_int_check (o: POINTER): INTEGER
   py_int_from_integer (value: INTEGER): POINTER
   py_int_as_integer (o: POINTER): INTEGER
   py_long_from_integer (value: INTEGER): POINTER
   py_long_as_integer (o: POINTER): INTEGER
   py_long_type_set (p0: POINTER)
   py_long_type_get: POINTER
   py_long_check (p: POINTER): INTEGER
   py_long_from_double (v: DOUBLE): POINTER
   py_long_as_double (pylong: POINTER): DOUBLE
   py_float_type_set (p0: POINTER)
   py_float_type_get: POINTER
   py_float_check (p: POINTER): INTEGER
   py_float_from_double (v: DOUBLE): POINTER
   py_float_as_double (pyfloat: POINTER): DOUBLE
   py_file_type_set (p0: POINTER)
   py_file_type_get: POINTER
   py_file_check (p: POINTER): INTEGER
   py_file_from_string (filename: STRING; mode: STRING): POINTER
   py_file_as_file (p: POINTER): POINTER
   py_file_get_line (p: POINTER; n: INTEGER): POINTER
   py_file_name (p: POINTER): POINTER
   py_file_set_buf_size (p: POINTER; n: INTEGER)
   py_file_soft_space (p: POINTER; newflag: INTEGER): INTEGER
   py_file_write_object (obj: POINTER; p: POINTER; flags: INTEGER): INTEGER
   py_file_write_string (s: STRING; p: POINTER): INTEGER
   py_module_type_set (p0: POINTER)
   py_module_type_get: POINTER
   py_module_check (p: POINTER): INTEGER
   py_module_new (name: STRING): POINTER
   py_module_get_dict (module: POINTER): POINTER
   py_module_get_name (module: POINTER): POINTER
   py_module_get_filename (module: POINTER): POINTER
   py_eval_call_object_with_keywords (p0: POINTER; p1: POINTER; p2: POINTER): POINTER
   py_eval_call_object (callable_object: POINTER; argument_tuple: POINTER): POINTER
   py_eval_get_builtins: POINTER
   py_eval_get_globals: POINTER
   py_eval_get_locals: POINTER
   py_eval_get_frame: POINTER
   py_eval_get_restricted: INTEGER
   wrap_swig_make_ptr (ptr: POINTER): POINTER
   wrap_swig_get_ptr (c: STRING)
end of PYTHON_CLIENT_WRAPPER

PYTHON_CLIENT

class interface PYTHON_CLIENT
feature(s) from PYTHON_CLIENT
   python_object_factory: PYTHON_OBJECT_FACTORY
      -- an instance of python_factory, shared by all objects for the 
      -- purpose of converting arguments, etc.
   python_globals: PYTHON_DICTIONARY
   python_locals: PYTHON_DICTIONARY
   last_python_integer_result: INTEGER
      -- stores the last integer result of a call to the Python API 
      -- --note that this will be replicated for all descendants
   last_python_integer_result_ok: BOOLEAN
      -- did last C call to Python API return an error condition?
   last_python_pointer_result: POINTER
      -- stores the last pointer result of a call to the Python API
      -- note that this will be replicated for all descendants
   last_python_pointer_result_ok: BOOLEAN
      -- did last pointer call to Python API return an error condition?
   evaluated_expression (expr: STRING): PYTHON_OBJECT
      -- evaluates an expression
   initialize_python
      -- handles python initialization--currently just wraps the basic 
      -- call, but may be expanded to fill in sys.argv
   swig_pointer_string (object: ANY): STRING
      -- converts the object's pointer into a swig-compatible Eiffel 
      -- string.  There's a lot of shuffling going on to convert a 
      -- pointer to an eiffel string to a python string to a swig 
      -- pointer, but it may work.
      require
         object /= Void
end of PYTHON_CLIENT