+ void *py_type_printers = nullptr;
+};
+
+/* The return code for some API calls. */
+
+enum ext_lang_rc
+{
+ /* The operation completed successfully. */
+ EXT_LANG_RC_OK,
+
+ /* The operation was not performed (e.g., no pretty-printer). */
+ EXT_LANG_RC_NOP,
+
+ /* There was an error (e.g., Python error while printing a value).
+ When an error occurs no further extension languages are tried.
+ This is to preserve existing behaviour, and because it's convenient
+ for Python developers.
+ Note: This is different than encountering a memory error trying to read
+ a value for pretty-printing. Here we're referring to, e.g., programming
+ errors that trigger an exception in the extension language. */
+ EXT_LANG_RC_ERROR
+};
+
+/* A type which holds its extension language specific xmethod worker data. */
+
+struct xmethod_worker
+{
+ xmethod_worker (const extension_language_defn *extlang)
+ : m_extlang (extlang)
+ {}
+
+ virtual ~xmethod_worker () = default;
+
+ /* Invoke the xmethod encapsulated in this worker and return the result.
+ The method is invoked on OBJ with arguments in the ARGS array. */
+
+ virtual value *invoke (value *obj, gdb::array_view<value *> args) = 0;
+
+ /* Return the arg types of the xmethod encapsulated in this worker.
+ The type of the 'this' object is returned as the first element of
+ the vector. */
+
+ std::vector<type *> get_arg_types ();
+
+ /* Return the type of the result of the xmethod encapsulated in this worker.
+ OBJECT and ARGS are the same as for invoke. */
+
+ type *get_result_type (value *object, gdb::array_view<value *> args);
+
+private:
+
+ /* Return the types of the arguments the method takes. The types
+ are returned in TYPE_ARGS, one per argument. */
+
+ virtual enum ext_lang_rc do_get_arg_types
+ (std::vector<type *> *type_args) = 0;
+
+ /* Fetch the type of the result of the method implemented by this
+ worker. OBJECT and ARGS are the same as for the invoked method.
+ The result type is stored in *RESULT_TYPE. */
+
+ virtual enum ext_lang_rc do_get_result_type
+ (struct value *obj, gdb::array_view<value *> args,
+ struct type **result_type_ptr) = 0;
+
+ /* The language the xmethod worker is implemented in. */
+
+ const extension_language_defn *m_extlang;