mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
samples: add Terra samples
source: https://github.com/zdevito/terra/tree/master/tests
This commit is contained in:
25
samples/Terra/objc.t
Normal file
25
samples/Terra/objc.t
Normal file
@@ -0,0 +1,25 @@
|
||||
local f = assert(io.popen("uname", 'r'))
|
||||
local s = assert(f:read('*a'))
|
||||
f:close()
|
||||
|
||||
if s~="Darwin\n" then
|
||||
print("Warning, not running test b/c this isn't a mac")
|
||||
else
|
||||
|
||||
local OC = require("lib/objc")
|
||||
|
||||
terra main()
|
||||
OC.NSAutoreleasePool:new()
|
||||
var str = OC.NSString:stringWithUTF8String("the number of hacks is overwhelming...")
|
||||
var err = OC.NSError:errorWithDomain_code_userInfo(str,12,nil)
|
||||
var alert = OC.NSAlert:alertWithError(err)
|
||||
|
||||
var imgname = OC.NSString:stringWithUTF8String("foo.png")
|
||||
var img = OC.NSImage:alloc():initByReferencingFile(imgname)
|
||||
alert:setIcon(img)
|
||||
alert:runModal()
|
||||
end
|
||||
|
||||
terralib.saveobj("objc",{main = main}, { "-framework", "Foundation", "-framework", "Cocoa" })
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user