Skip to content

Commit

Permalink
Fix msg_send_super on GNUstep.
Browse files Browse the repository at this point in the history
  • Loading branch information
dboris committed May 22, 2024
1 parent a2bce05 commit bb04422
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
7 changes: 7 additions & 0 deletions runtime/function_description.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ module Functions = struct
let copy_method_list =
foreign "class_copyMethodList" (_Class @-> ptr uint @-> returning (ptr _Method))

(** Returns a specified instance method for a given class. *)
let get_instance_method =
foreign "class_getInstanceMethod" (_Class @-> _SEL @-> returning _Method)

(** Returns the function pointer that would be called if a particular message were sent to an instance of a class. *)
let get_method_implementation =
foreign "class_getMethodImplementation" (_Class @-> _SEL @-> returning _IMP)
end

module Object = struct
Expand Down
16 changes: 13 additions & 3 deletions runtime/runtime.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ open Foreign

module Platform = Platform
module Ivar = C.Functions.Ivar
module Method = C.Functions.Method
module Protocol = C.Functions.Protocol
module Inspect = Inspect
module Objc_t = Objc_t
Expand All @@ -20,6 +19,13 @@ module Sel = struct
| _ -> (fun _ _ -> assert false)
end

module Method = struct
include C.Functions.Method

let invoke ~typ ~self m =
foreign "method_invoke" (id @-> _Method @-> typ) self m
end

module Class = struct
include C.Functions.Class

Expand Down Expand Up @@ -149,8 +155,12 @@ module Objc = struct
let msg_send_super ~self ~cmd ~typ =
match Platform.current with
| GNUStep ->
let self = Class.get_superclass self in
msg_send ~self ~cmd ~typ
let self_class = Object.get_class self in
let imp =
Class.get_method_implementation (Class.get_superclass self_class) cmd
in
let imp_fun = coerce _IMP (funptr (id @-> _SEL @-> typ)) imp in
imp_fun self cmd
| _ ->
let objc_super = Objc_super.make self in
foreign "objc_msgSendSuper"
Expand Down

0 comments on commit bb04422

Please sign in to comment.