Skip to content

Instantly share code, notes, and snippets.

@iffy
Created October 24, 2018 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iffy/7965d17fb688b4471abb7c350d61708c to your computer and use it in GitHub Desktop.
Save iffy/7965d17fb688b4471abb7c350d61708c to your computer and use it in GitHub Desktop.

v1

$ nim objc -r v1_manual.nim 
Hint: used config file '/Users/matt/lib/Nim/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: v1_manual [Processing]
CC: v1_manual
CC: stdlib_system
Error: execution of an external compiler program 'clang -c  -w  -I/Users/matt/lib/Nim/lib -o /Users/matt/.cache/nim/v1_manual_d/v1_manual.m.o /Users/matt/.cache/nim/v1_manual_d/v1_manual.m' failed with exit code: 1

/Users/matt/.cache/nim/v1_manual_d/v1_manual.m:26:20: error: cannot find interface declaration for 'Object', superclass of 'Greeter'
@interface Greeter:Object
~~~~~~~~~~~~~~~~~~ ^
1 error generated.

v2

$ nim objc -r v2_fixedformacos.nim 
Hint: used config file '/Users/matt/lib/Nim/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: v2_fixedformacos [Processing]
CC: v2_fixedformacos
CC: stdlib_system
Hint:  [Link]
Hint: operation successful (12366 lines compiled; 0.659 sec total; 16.367MiB peakmem; Debug Build) [SuccessX]
Hint: /private/tmp/usingobjc/v2_fixedformacos  [Exec]
Hello, World!

v3

$ nim objc -r v3_splitobjc.nim 
Hint: used config file '/Users/matt/lib/Nim/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: v3_splitobjc [Processing]
CC: guts
CC: v3_splitobjc
CC: stdlib_system
Error: execution of an external compiler program 'clang -c  -w  -I/Users/matt/lib/Nim/lib -o /Users/matt/.cache/nim/v3_splitobjc_d/v3_splitobjc.m.o /Users/matt/.cache/nim/v3_splitobjc_d/v3_splitobjc.m' failed with exit code: 1

/Users/matt/.cache/nim/v3_splitobjc_d/v3_splitobjc.m:109:32: error: use of undeclared identifier 'Greeter'; did you mean 'kNeuter'?
        g_BZv9cU0hhtS3bt9bM3OBgSaQ = [Greeter new];
                                      ^~~~~~~
                                      kNeuter
/System/Library/Frameworks/ApplicationServices.framework/Frameworks/SpeechSynthesis.framework/Headers/SpeechSynthesis.h:149:3: note: 'kNeuter' declared here
  kNeuter                       = 0,
  ^
1 error generated.
#include <Cocoa/Cocoa.h>
@interface Greeter:NSObject
{
}
- (void)greet:(long)x y:(long)dummy;
@end
#include <stdio.h>
@implementation Greeter
- (void)greet:(long)x y:(long)dummy
{
printf("Hello, World!\n");
}
@end
#include <stdlib.h>
{.passL: "-lobjc".}
{.emit: """
#include <objc/Object.h>
@interface Greeter:Object
{
}
- (void)greet:(long)x y:(long)dummy;
@end
#include <stdio.h>
@implementation Greeter
- (void)greet:(long)x y:(long)dummy
{
printf("Hello, World!\n");
}
@end
#include <stdlib.h>
""".}
type
Id {.importc: "id", header: "<objc/Object.h>", final.} = distinct int
proc newGreeter: Id {.importobjc: "Greeter new", nodecl.}
proc greet(self: Id, x, y: int) {.importobjc: "greet", nodecl.}
proc free(self: Id) {.importobjc: "free", nodecl.}
var g = newGreeter()
g.greet(12, 34)
g.free()
{.emit: """
#include <Cocoa/Cocoa.h>
@interface Greeter:NSObject
{
}
- (void)greet:(long)x y:(long)dummy;
@end
#include <stdio.h>
@implementation Greeter
- (void)greet:(long)x y:(long)dummy
{
printf("Hello, World!\n");
}
@end
#include <stdlib.h>
""".}
type
Id {.importc: "id", header: "<Cocoa/Cocoa.h>", final.} = distinct int
proc newGreeter: Id {.importobjc: "Greeter new", nodecl.}
proc greet(self: Id, x, y: int) {.importobjc: "greet", nodecl.}
var g = newGreeter()
g.greet(12, 34)
{.compile: "guts.m" .}
type
Id {.importc: "id", header: "<Cocoa/Cocoa.h>", final.} = distinct int
proc newGreeter: Id {.importobjc: "Greeter new", nodecl.}
proc greet(self: Id, x, y: int) {.importobjc: "greet", nodecl.}
var g = newGreeter()
g.greet(12, 34)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment