indexing
	description: "Platform independent abstraction of a shared library routine"
	status: "See notice at end of class"
	date: "$Date$"
	revision: "$Revision$"

deferred class interface
	SHARED_LIBRARY_ROUTINE

feature -- Initialization

	make_by_name (lib: SHARED_LIBRARY; f_name: STRING; arg_types: ARRAY [INTEGER]; ret_type: INTEGER)
			-- Connect to the routine f_name in library lib
		require
			library_exists: lib /= void
			meaningful: lib.meaningful
			function_name_non_void: f_name /= void
			function_name_non_empty: not f_name.is_empty
			valid_argument_array: arg_types /= void
			valid_argument_types: valid_argument_types (arg_types)
			valid_return_type: valid_return_type (ret_type)
		ensure
			consistent_f_name: f_name.is_equal (function_name)
			consistent_lib: lib = shared_library
			routine_not_called: not routine_called
	
feature -- Access

	argument_types: ARRAY [INTEGER]
			-- Expected types of the actual arguments

	function_name: STRING
			-- Name of the routine in the library

	library_name: STRING
			-- Name of the associated library for the routine

	return_type: INTEGER
			-- Expected return type

	shared_library: SHARED_LIBRARY
			-- Associated library for the routine

	T_array: INTEGER is 0
			-- (from SHARED_LIBRARY_CONSTANTS)

	T_boolean: INTEGER is 1
			-- (from SHARED_LIBRARY_CONSTANTS)

	T_character: INTEGER is 2
			-- (from SHARED_LIBRARY_CONSTANTS)

	T_double: INTEGER is 3
			-- (from SHARED_LIBRARY_CONSTANTS)

	T_integer: INTEGER is 4
			-- (from SHARED_LIBRARY_CONSTANTS)

	T_no_type: INTEGER is 10
			-- (from SHARED_LIBRARY_CONSTANTS)

	T_pointer: INTEGER is 5
			-- (from SHARED_LIBRARY_CONSTANTS)

	T_real: INTEGER is 6
			-- (from SHARED_LIBRARY_CONSTANTS)

	T_reference: INTEGER is 7
			-- (from SHARED_LIBRARY_CONSTANTS)

	T_short_integer: INTEGER is 8
			-- (from SHARED_LIBRARY_CONSTANTS)

	T_string: INTEGER is 9
			-- (from SHARED_LIBRARY_CONSTANTS)
	
feature -- Status report

	argument_count: INTEGER
			-- Number of arguments required

	boolean_result: BOOLEAN
			-- Value when the routine returns a boolean
		require
			routine_called: routine_called
			valid_return_type: return_type = t_boolean

	character_result: CHARACTER
			-- Value when the routine returns a character
		require
			routine_called: routine_called
			valid_return_type: return_type = t_character

	conforms_to_signature (arguments: ARRAY [ANY]): BOOLEAN
			-- Do the actual arguments arguments conform to the signature?
		require
			valid_array: arguments /= void

	double_result: DOUBLE
			-- Value when the routine returns a double
		require
			routine_called: routine_called
			valid_return_type: return_type = t_double

	error_code: INTEGER
			-- Current status of the routine

	integer_result: INTEGER
			-- Value when the routine returns an integer
		require
			routine_called: routine_called
			valid_return_type: return_type = t_integer or return_type = t_short_integer

	Library_freed: INTEGER is 3
			-- (from SHARED_LIBRARY_CONSTANTS)

	meaningful: BOOLEAN
			-- Is the routine currently callable?

	No_error: INTEGER is 0
			-- (from SHARED_LIBRARY_CONSTANTS)

	No_library: INTEGER is 1
			-- (from SHARED_LIBRARY_CONSTANTS)

	No_routine: INTEGER is 2
			-- (from SHARED_LIBRARY_CONSTANTS)

	pointer_result: POINTER
			-- Value when the routine returns a pointer
		require
			routine_called: routine_called
			valid_return_type: return_type = t_pointer

	real_result: REAL
			-- Value when the routine returns a real
		require
			routine_called: routine_called
			valid_return_type: return_type = t_real

	reference_result: ANY
			-- Value when the routine returns a reference
		require
			routine_called: routine_called
			valid_return_type: return_type = t_reference

	routine_called: BOOLEAN
			-- Has the routine already been called?

	string_result: STRING
			-- Value when the routine returns a string
		require
			routine_called: routine_called
			valid_return_type: return_type = t_string

	valid_argument_types (args: ARRAY [INTEGER]): BOOLEAN
			-- Are all the argument types in args valid?

	valid_return_type (ret_type: INTEGER): BOOLEAN
			-- Is ret_type valid as a return type?
	
feature -- Basic operations

	call (args: ARRAY [ANY])
			-- Call the routine with actual arguments args
		require
			meaningful: meaningful
			valid_array: args /= void
			conformant: conforms_to_signature (args)
		ensure
			routine_called: routine_called
	
invariant

	library_exists: shared_library /= void
	meaningful_only_if_no_error: meaningful implies (error_code = no_error)
	meaningful_library: meaningful implies shared_library.meaningful
		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

indexing
	library: "[
			EiffelBase: Library of reusable components for Eiffel.
	]"
	status: "[
			Copyright 1986-2001 Interactive Software Engineering (ISE).
			For ISE customers the original versions are an ISE product
			covered by the ISE Eiffel license and support agreements.
	]"
	license: "[
			EiffelBase may now be used by anyone as FREE SOFTWARE to
			develop any product, public-domain or commercial, without
			payment to ISE, under the terms of the ISE Free Eiffel Library
			License (IFELL) at http://eiffel.com/products/base/license.html.
	]"
	source: "[
			Interactive Software Engineering Inc.
			ISE Building
			360 Storke Road, Goleta, CA 93117 USA
			Telephone 805-685-1006, Fax 805-685-6869
			Electronic mail <info@eiffel.com>
			Customer support http://support.eiffel.com
	]"
	info: "[
			For latest info see award-winning pages: http://eiffel.com
	]"

end -- class SHARED_LIBRARY_ROUTINE