;
; global_boopsi.a  V3.1
;
; BOOPSI Support Functions in M68K Assembler
;
; Copyright (C) 1990-98 Stefan Becker
;
; This source code is for educational purposes only. You may study it
; and copy ideas or algorithms from it for your own projects. It is
; not allowed to use any of the source codes (in full or in parts)
; in other programs. Especially it is not allowed to create variants
; of ToolManager or ToolManager-like programs from this source code.
;
         XDEF _CoerceMethod
;         XDEF @CoerceMethodA
         XDEF _DoMethod
         XDEF @DoMethodA
         XDEF _DoSuperMethod
         XDEF @DoSuperMethodA

         SECTION  boopsi,code

; ULONG CoerceMethod( struct IClass *, Object *, ULONG, ... );
_CoerceMethod:
         movem.l  A2/A3,-(SP)    ; Save A2/A3
         movem.l  12(SP),A0/A2   ; A0 = IClass, A2 = Object
         lea.l    20(SP),A1      ; A1 = Msg
         move.l   8(A0),A3       ; Class' method dispatcher
                                 ; IClass->cl_Dispatcher.h_Entry
         jsr      (A3)           ; Call dispatcher
         movem.l   (SP)+,A2/A3   ; Restore A2/A3
         rts

; ULONG CoerceMethodA( __A0 struct IClass *, __A2 Object *, __A1 Msg);
;@CoerceMethodA:
;         move.l   8(A0),-(SP)    ; Class' method dispatcher
;                                 ; IClass->cl_Dispatcher.h_Entry
;         rts                     ; Call dispatcher

; ULONG DoMethod( Object *, ULONG, ... );
_DoMethod:
         movem.l  A2/A3,-(SP)    ; Save A2/A3
         move.l   12(SP),A2      ; A2 = Object
         lea.l    16(SP),A1      ; A1 = Msg
         move.l   -4(A2),A0      ; A0 = IClass
                                 ; ((struct _Object *) o - 1)->o_Class
         move.l   8(A0),A3       ; Class' method dispatcher
                                 ; IClass->cl_Dispatcher.h_Entry
         jsr      (A3)           ; Call dispatcher
         movem.l  (SP)+,A2/A3    ; Restore A2/A3
         rts

; ULONG DoMethodA(__A2 Object *, __A1 Msg );
@DoMethodA:
         move.l   -4(A2),A0      ; A0 = IClass
                                 ; ((struct _Object *) o - 1)->o_Class
         move.l   8(A0),-(SP)    ; Class' method dispatcher
                                 ; IClass->cl_Dispatcher.h_Entry
         rts                     ; Call dispatcher

; ULONG DoSuperMethod( struct IClass *, Object *, ULONG, ... );
_DoSuperMethod:
         movem.l  A2/A3,-(SP)    ; Save A2/A3
         movem.l  12(SP),A0/A2   ; A0 = IClass, A2 = Object
         lea.l    20(SP),A1      ; A1 = Msg
         move.l   24(A0),A0      ; A0 = Super class
                                 ; IClass->cl_Super
         move.l   8(A0),A3       ; Class' method dispatcher
                                 ; IClass->cl_Dispatcher.h_Entry
         jsr      (A3)           ; Call dispatcher
         movem.l  (SP)+,A2/A3    ; Restore A2/A3
         rts

; ULONG DoSuperMethodA( __A0 struct IClass *, __A2 Object *, __A1 Msg );
@DoSuperMethodA:
         move.l   24(A0),A0      ; A0 = Super class
                                 ; IClass->cl_Super
         move.l   8(A0),-(SP)    ; Class' method dispatcher
                                 ; IClass->cl_Dispatcher.h_Entry
         rts                     ; Call dispatcher

         END
