ObjC stuff

1 view
Skip to first unread message

John Skaller2

unread,
Sep 7, 2020, 3:33:13 PM9/7/20
to felix google
OK so a couple of issues.

1. #import is not supported by flx. ObjC headers can be #included but we should be using #import
To be specific, flxg compiler generates a *.resh with a package name and flx translates that
to a *.includes file which is included by the client program and contains a bunch of #includes
specified by the package field ‘includes’, It needs to be upgraded to allow package field
‘imports’ to generate a #import preprocessor directive.

2. cstmt and cexpr in-place code insertions do not support “requires” clauses.
This is not surprising for cexpr. But this can not work automatically:

open class AppKit
{
requires package "appkit";
type NSSound = "NSSound*";
proc play(filename:NSString)=>
cstmt """
{NSSound *sound =
[
[NSSound alloc] initWithContentsOfFile:$1
byReference:NO
]
;
[sound play];}
""" filename ;
}

The thing is, although requires package at the top level inside a class applies
to all C bindings in the class .. play is a Felix procedure, and NSSound type
is not actually used at the Felix level to trigger the package inclusion.

It’s easy in this case to fix it: we should have a NSSound typed variable accepting
the file, and a separate play procedure accepting the NSSound value. That “uses”
the type NSSound and will trigger inclusion of appkit.



John Skaller
ska...@internode.on.net





Reply all
Reply to author
Forward
0 new messages