Closed yairchu closed 1 year ago
I don't know -- I've never used Objective-C.
If its tooling is close to C/C++'s it would probably be pretty easy.
If its tooling is close to C/C++'s it would probably be pretty easy.
Yeah the tooling is close afaik. As a clang user I just compile a .m
file instead of a .c
.
Trying to look on inline-c
's side but I'm having trouble following it.
I see that inlineCode
creates a new ffiImportName
to use, and I understand that emitVerbatim
above it somehow emits the C code for it but I'm not really following how it works.
Ok I still don't know exactly how the internals work but I got it working!
Just changing TH.LangC
to TH.LangObjc
in initialiseModuleState
makes Objective-C work.
Then I can do
cglCtx <- [C.block| void* {
NSOpenGLContext* object = (NSOpenGLContext*) $(void* nsglCtx);
return [object CGLContextObj];
}|]
Instead of
cglCtx <- [C.block| void* {
id object = (id) $(void* nsglCtx);
SEL selector = sel_registerName("CGLContextObj");
Method method = class_getInstanceMethod(object_getClass(object), selector);
IMP imp = method_getImplementation(method);
return ((CGLContextObj (*)(id, SEL))imp)(object, selector);
}|]
How would we like it do work? In a separate module/package like C++? If you have a general design for how this should work then I can make a PR for it.
The right way to do this is in a separate package following the pattern of inline-c-cpp.
On Wed, 10 May 2023 at 15:24, Yair Chuchem @.***> wrote:
Ok I still don't know exactly how the internals work but I got it working!
Just changing TH.LangC to TH.LangObjc in initialiseModuleState makes Objective-C work.
Then I can do
cglCtx <- [C.block| void { NSOpenGLContext object = (NSOpenGLContext) $(void nsglCtx); return [object CGLContextObj]; }|]
Instead of
cglCtx <- [C.block| void { id object = (id) $(void nsglCtx); SEL selector = sel_registerName("CGLContextObj"); Method method = class_getInstanceMethod(object_getClass(object), selector); IMP imp = method_getImplementation(method); return ((CGLContextObj (*)(id, SEL))imp)(object, selector); }|]
How would we like it do work? In a separate module/package like C++? If you have a general design for how this should work then I can make a PR for it.
— Reply to this email directly, view it on GitHub https://github.com/fpco/inline-c/issues/142#issuecomment-1542304919, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEHYOSXBBPOKYJ3YFQY7H3XFOQIPANCNFSM6AAAAAAX4R34EU . You are receiving this because you commented.Message ID: @.***>
Fixed by #143 .
What would it take to support Objective-C too?