-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP declar an NSApplicationDelegate in crystal and use it from a nib …
…file. Issues regarding IMP signature due to crystal-lang/crystal#214
- Loading branch information
Brian J. Cardiff
committed
Sep 21, 2014
1 parent
5b828b1
commit aef4965
Showing
8 changed files
with
80 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
.crystal | ||
*.app | ||
*.nib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,43 @@ | ||
require "../../src/crocoa" | ||
include Crocoa | ||
|
||
objc_class :MyAppDelegate do | ||
end | ||
|
||
# $x_MyAppDelegate_objc_class_initWithCoder_imp = ->(obj : UInt8*, _cmd : LibObjC::SEL, _coder : UInt8*) { | ||
# `touch /Users/bcardiff/Work/Manas/crystal/crocoa/samples/bundled_application/xx-init-coder.txt` | ||
# obj | ||
# } | ||
# LibObjC.class_addMethod2($x_MyAppDelegate_objc_class.obj, "initWithCoder:".to_sel.to_objc, $x_MyAppDelegate_objc_class_initWithCoder_imp, "@@:@") | ||
|
||
# $x_MyAppDelegate_objc_class_init_imp = ->(obj : UInt8*, _cmd : LibObjC::SEL) { | ||
# `touch /Users/bcardiff/Work/Manas/crystal/crocoa/samples/bundled_application/xx-init.txt` | ||
# obj | ||
# } | ||
# LibObjC.class_addMethod3($x_MyAppDelegate_objc_class.obj, "init".to_sel.to_objc, $x_MyAppDelegate_objc_class_init_imp, "@@:") | ||
|
||
|
||
# a = LibObjC.objc_msgSend($x_MyAppDelegate_objc_class.obj, "alloc".to_sel.to_objc) | ||
# LibObjC.objc_msgSend(a, "init".to_sel.to_objc) | ||
# `touch /Users/bcardiff/Work/Manas/crystal/crocoa/samples/bundled_application/xx-foo.txt` | ||
|
||
LibObjC.class_addProtocol($x_MyAppDelegate_objc_class.obj,LibObjC.objc_getProtocol("NSApplicationDelegate")) | ||
|
||
$AppDel_didFinishLaunching = -> (obj : UInt8*, _cmd : LibObjC::SEL, aNotification : UInt8*) { | ||
Crocoa.nslog "didFinishLaunching" | ||
} | ||
|
||
LibObjC.class_addMethod4($x_MyAppDelegate_objc_class.obj, "applicationDidFinishLaunching:".to_sel.to_objc, $AppDel_didFinishLaunching, "v@:@") | ||
|
||
|
||
LibAppKit.ns_application_main 0u32, nil | ||
|
||
# objc_class :Foo do | ||
# def mySelector() | ||
# $t2.value = $t1.value | ||
# puts "Hi there" | ||
# end | ||
|
||
# objc_export "mySelector:" | ||
# end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require "../spec_helper" | ||
|
||
describe "export" do | ||
|
||
objc_class :MyFooBar do | ||
end | ||
|
||
it "should register classes" do | ||
NSClass.new("MyFooBar").name.should eq("MyFooBar") | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,6 @@ lib LibCF | |
origin : Point | ||
size : Size | ||
end | ||
|
||
fun nslog = NSLog(UInt8*, ...) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Crocoa | ||
class NSCoder < NSObject | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters