X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/7deed8c9bfb5aec2b461b2b112c9efb0cd538f8d..b426ab51d0598242a4c2b57d563341db66d71f7b:/src/method-proto.lisp diff --git a/src/method-proto.lisp b/src/method-proto.lisp index 8b3822a..78429ef 100644 --- a/src/method-proto.lisp +++ b/src/method-proto.lisp @@ -85,14 +85,16 @@ (chain-head :initarg :chain-head :type sod-class :reader method-entry-chain-head) (chain-tail :initarg :chain-tail :type sod-class - :reader method-entry-chain-tail)) + :reader method-entry-chain-tail) + (role :initarg :role :type (or :keyword null) :reader method-entry-role)) (:documentation "An entry point into an effective method. - Specifically, this is the entry point to the effective method METHOD - invoked via the vtable for the chain headed by CHAIN-HEAD. The CHAIN-TAIL - is the most specific class on this chain; this is useful because we can - reuse the types of method entries from superclasses on non-primary chains. + Specifically, this is the entry point to the effective METHOD invoked via + the vtable for the chain headed by CHAIN-HEAD, and serving the given ROLE. + The CHAIN-TAIL is the most specific class on this chain; this is useful + because we can reuse the types of method entries from superclasses on + non-primary chains. Each effective method may have several different method entries, because an effective method can be called via vtables attached to different @@ -101,16 +103,22 @@ job of the method entry to adjust the instance pointers correctly for the rest of the effective method. + A vtable can contain more than one entry for the same message. Such + entries are distinguished by their roles. A message always has an entry + with the `nil role. No other roles are currently defined, though they may + be introduced by extensions. + The boundaries between a method entry and the effective method is (intentionally) somewhat fuzzy. In extreme cases, the effective method may not exist at all as a distinct entity in the output because its content is duplicated in all of the method entry functions. This is left up to the effective method protocol.")) -(export 'make-method-entry) -(defgeneric make-method-entry (effective-method chain-head chain-tail) +(export 'make-method-entries) +(defgeneric make-method-entries (effective-method chain-head chain-tail) (:documentation - "Return a METHOD-ENTRY for an EFFECTIVE-METHOD called via CHAIN-HEAD. + "Return a list of `method-entry' objects for an EFFECTIVE-METHOD called + via CHAIN-HEAD. There is no default method for this function. (Maybe when the effective-method/method-entry output protocol has settled down I'll know @@ -180,6 +188,17 @@ (:documentation "Return the C function type for a method entry.")) +(export 'method-entry-slot-name) +(defgeneric method-entry-slot-name (entry) + (:documentation + "Return the `vtmsgs' slot name for a method entry. + + The default method indirects through `method-entry-slot-name-by-role'.")) + +(defgeneric method-entry-slot-name-by-role (entry role name) + (:documentation "Easier implementation for `method-entry-slot-name'.") + (:method ((entry method-entry) (role (eql nil)) name) name)) + (export 'effective-method-basic-argument-names) (defgeneric effective-method-basic-argument-names (method) (:documentation @@ -312,7 +331,8 @@ (return-type (c-type-subtype message-type)) (raw-args (sod-message-argument-tail message)) (arguments (if (varargs-message-p message) - (cons (make-argument *sod-ap* (c-type va-list)) + (cons (make-argument *sod-ap* + (c-type va-list)) (butlast raw-args)) raw-args))) (codegen-push codegen) @@ -332,13 +352,13 @@ "Returns the function name of an effective method.")) (export 'method-entry-function-name) -(defgeneric method-entry-function-name (method chain-head) +(defgeneric method-entry-function-name (method chain-head role) (:documentation "Returns the function name of a method entry. - The method entry is given as an effective method/chain-head pair, rather - than as a method entry object because we want the function name before - we've made the entry object.")) + The method entry is given as an effective method/chain-head/role triple, + rather than as a method entry object because we want the function name + before we've made the entry object.")) (export 'compute-method-entry-functions) (defgeneric compute-method-entry-functions (method)