diff --git a/.gitignore b/.gitignore index d62b97d..ef1d883 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *~ *# *.o +*.a *.so *.dylib *.dSYM diff --git a/Makefile b/Makefile index f588b6c..2471ee3 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ +CC ?= gcc RUSTC ?= rustc +AR ?= ar RUSTFLAGS ?= RUST_SRC = $(shell find . -type f -name '*.rs') @@ -6,16 +8,22 @@ RUST_SRC = $(shell find . -type f -name '*.rs') .PHONY: all all: libcocoa.dummy -libcocoa.dummy: cocoa.rc $(RUST_SRC) +libcocoa.dummy: cocoa.rc $(RUST_SRC) libmsgsend.a $(RUSTC) $(RUSTFLAGS) $< -o $@ touch $@ -cocoa-test: cocoa.rc $(RUST_SRC) +cocoa-test: cocoa.rc $(RUST_SRC) libmsgsend.a $(RUSTC) $(RUSTFLAGS) $< -o $@ --test +libmsgsend.a: msgsend.o + $(AR) rcs libmsgsend.a msgsend.o + +msgsend.o: msgsend.c + $(CC) $< -o $@ -c + check: cocoa-test ./cocoa-test .PHONY: clean clean: - rm -f cocoa-test *.so *.dylib *.dll *.dummy + rm -f cocoa-test *.a *.o *.so *.dylib *.dll *.dummy diff --git a/cocoa.rc b/cocoa.rc index 16ebb76..ad3d0b2 100644 --- a/cocoa.rc +++ b/cocoa.rc @@ -12,4 +12,3 @@ use std; mod appkit; mod base; mod foundation; - diff --git a/cocoa.rs b/cocoa.rs new file mode 100644 index 0000000..c3ccc37 --- /dev/null +++ b/cocoa.rs @@ -0,0 +1,10 @@ + +fn msgSend1Id(theReceiver: base::id, theSelector: base::SEL, id: base::id) { + msgsend::msgSend1IdHACK(theReceiver, theSelector, id); +} + +#[link_args = "-L . -lmsgsend"] +#[nolink] +native mod msgsend { + fn msgSend1IdHACK(theReceiver: base::id, theSelector: base::SEL, id: base::id); +} diff --git a/msgsend.c b/msgsend.c new file mode 100644 index 0000000..ee2a586 --- /dev/null +++ b/msgsend.c @@ -0,0 +1,11 @@ +#include +#include + +void +msgSend1IdHACK(id theReceiver, SEL theSender, id id) { + printf("msgSend1IdHACK\n"); + printf("%ld\n", theReceiver); + printf("%ld\n", theSender); + printf("%ld\n", id); + objc_msgSend(theReceiver, theSender, id); +}