Add xmethod interface to the extension language API.

* defs.h (enum lval_type): New enumerator "lval_xcallable".
	* extension-priv.h (struct extension_language_ops): Add the
	xmethod interface.
	* extension.c (new_xmethod_worker, clone_xmethod_worker,
	get_matching_xmethod_workers, get_xmethod_argtypes,
	invoke_xmethod, free_xmethod_worker,
	free_xmethod_worker_vec): New functions.
	* extension.h: #include "common/vec.h".
	New function declarations.
	(struct xmethod_worker): New struct.
	(VEC (xmethod_worker_ptr)): New vector type.
	(xmethod_worker_ptr): New typedef.
	(xmethod_worker_vec): Likewise.
	* gdbtypes.c (gdbtypes_post_init): Initialize "xmethod" field of
	builtin_type.
	* gdbtypes.h (enum type_code): New enumerator TYPE_CODE_XMETHOD.
	(struct builtin_type): New field "xmethod".
	* valarith.c (value_ptradd): Assert that the value argument is not
	lval_xcallable.
	* valops.c (value_must_coerce_to_target): Return 0 for
	lval_xcallable values.
	* value.c (struct value): New field XM_WORKER in the field
	LOCATION.
	(value_address, value_raw_address): Return 0 for lval_xcallable
	values.
	(set_value_address): Assert that the value is not an
	lval_xcallable.
	(value_free): Free the associated xmethod worker when freeing
	lval_xcallable values.
	(set_value_component_location): Assert that the WHOLE value is not
	lval_xcallable.
	(value_of_xmethod, call_xmethod): New functions.
	* value.h: Declare "struct xmethod_worker".
	Declare new functions value_of_xmethod, call_xmethod.
This commit is contained in:
Siva Chandra 2014-05-20 06:30:29 -07:00
parent ef370185fc
commit e81e7f5e38
10 changed files with 341 additions and 5 deletions

View file

@ -179,7 +179,10 @@ enum type_code
TYPE_CODE_MODULE, /**< Fortran module. */
/* * Internal function type. */
TYPE_CODE_INTERNAL_FUNCTION
TYPE_CODE_INTERNAL_FUNCTION,
/* * Methods implemented in extension languages. */
TYPE_CODE_XMETHOD
};
/* * For now allow source to use TYPE_CODE_CLASS for C++ classes, as
@ -1468,6 +1471,9 @@ struct builtin_type
/* * This type is used to represent a GDB internal function. */
struct type *internal_fn;
/* * This type is used to represent an xmethod. */
struct type *xmethod;
};
/* * Return the type table for the specified architecture. */