;;; -*- Mode:Common-Lisp; Package:TICLOS; Base:10; Patch-file:T -*-

;;; Reason: Fix CLASS-DIRECT-INITARGS method to not get an error on method names that are 
;;; not defined but do have a definition in a Zmacs buffer.

;;;                           RESTRICTED RIGHTS LEGEND
;;;
;;; Use, duplication, or disclosure by the Government is subject to
;;; restrictions as set forth in subdivision (c)(1)(ii) of the Rights in
;;; Technical Data and Computer Software clause at 52.227-7013.
;;;
;;;   TEXAS INSTRUMENTS INCORPORATED      
;;;   P.O. BOX 149149, M/S 2151             
;;;   AUSTIN, TEXAS 78714
;;;
;;; Copyright (C) 1989 Texas Instruments Incorporated.
;;; All rights reserved.

;;; Written 11/07/89 18:41:22 by GRAY,
;;; while running on Kelvin from band LOD2
;;; With SYSTEM 6.23, VIRTUAL-MEMORY 6.2, EH 6.5, MAKE-SYSTEM 6.2, MICRONET 6.0, LOCAL-FILE 6.1,
;;;  BASIC-PATHNAME 6.2, NETWORK-SUPPORT-COLD 6.2, BASIC-NAMESPACE 6.6, NETWORK-NAMESPACE 6.0,
;;;  DISK-IO 6.1, DISK-LABEL 6.0, BASIC-FILE 6.6, MAC-PATHNAME 6.0, NETWORK-PATHNAME 6.0,
;;;  COMPILER 6.14, TV 6.18, DATALINK 6.0, CHAOSNET 6.4, GC 6.3, MEMORY-AUX 6.0, NVRAM 6.2,
;;;  SYSLOG 6.2, STREAMER-TAPE 6.4, UCL 6.0, INPUT-EDITOR 6.0, METER 6.1, ZWEI 6.8,
;;;  DEBUG-TOOLS 6.3, NETWORK-SUPPORT 6.0, NETWORK-SERVICE 6.2, DATALINK-DISPLAYS 6.0,
;;;  FONT-EDITOR 6.1, SERIAL 6.0, PRINTER 6.3, MAC-PRINTER-TYPES 6.1, PRINTER-TYPES 6.2,
;;;  IMAGEN 6.1, SUGGESTIONS 6.1, MAIL-DAEMON 6.3, MAIL-READER 6.5, TELNET 6.0, VT100 6.0,
;;;  NAMESPACE-EDITOR 6.4, PROFILE 6.2, VISIDOC 6.5, TI-CLOS 6.26, CLEH 6.5, IP 3.56,
;;;  Experimental CLX 6.6, CLUE 6.32, X11M 6.15, Experimental BUG 11.16, Experimental DOCUMENTER 701.0,
;;;  Experimental CONFORMANCE-CHECKER 2.0,  microcode 430, Band Name: 6.0+Scribe,
;;; &c,u430 9/6

;;; BUG REPORT NUMBER:  [none]
;;;
;;; PROBLEM:  User was getting errors when trying to use a generic function 
;;;	for which there were method definitions in a Zmacs buffer that had not 
;;;	been executed.
;;;
;;; SOLUTION:  Fix (:METHOD STANDARD-CLASS :CLASS-DIRECT-INITARGS) to ignore 
;;;	methods whose definition is NIL, which happens when Zmacs puts a 
;;;	ZMACS-BUFFER property on the function spec of an undefined method.
;;;	This fix was copied from the release 7 source, where it had been fixed on 
;;;	8/01/89.
;;;
;;; DEPENDENCIES:  [none]

#!C
; From file MAKE-INSTANCE.LISP#> CLOS; Hotel:
#10R TICLOS#:
(COMPILER-LET ((*PACKAGE* (FIND-PACKAGE "TICLOS"))
                          (SI:*LISP-MODE* :COMMON-LISP)
                          (*READTABLE* SYS:COMMON-LISP-READTABLE)
                          (SI:*READER-SYMBOL-SUBSTITUTIONS* SYS::*COMMON-LISP-SYMBOL-SUBSTITUTIONS*))
  (COMPILER#:PATCH-SOURCE-FILE "SYS: CLOS; MAKE-INSTANCE.#"


;;  11/07/89 DNG - Fixed to not trip on undefined methods [null method object].
(defmethod (standard-class :class-direct-initargs) ()
  (initargs-nunion (mapcar #'car (class-direct-slot-initargs  self))
	  (let ((initargs nil))
	    ;;This shouldn't be an exact search 
 	    (dolist (ms (compute-applicable-methods 'allocate-instance (list self)))
	      (setf initargs (initargs-nunion initargs
					      (copylist* (method-keyword-names ms)))))
	    ;; do an exact search for this one.
	    (dolist (ms (find-method-spec-objects  (generic-function-method-list
						     (get-generic-function-object 'shared-initialize))
						   (list self *t-class*)))
	      (let ((method-object (method-spec-object-method ms)))
		(when (and (not (combined-method-p method-object))
			   (not (null method-object)))
		  (setf initargs (initargs-nunion initargs
						  (copylist* (method-keyword-names method-object)))))))
	    (dolist (ms (find-method-spec-objects  (generic-function-method-list
						     (get-generic-function-object 'initialize-instance))
						   (list self)))
	      (let ((method-object (method-spec-object-method ms)))
		(when (and (not (combined-method-p method-object))
			   (not (null method-object)))
		  (setf initargs (initargs-nunion initargs
						  (copylist* (method-keyword-names method-object)))))))
	    #|(dolist (ms (compute-applicable-methods 'initialize-instance (list self)))
	      (setf initargs (initargs-nunion initargs
					      (copylist* (method-keyword-names ms))))) |#
	    initargs)
	  ))
))
