Le 19 oct. 2013 à 15:01, Uli Kusterer <witness.of.teacht...@gmx.net> a écrit :
> On 19 Oct 2013, at 01:17, Shane Stanley <sstan...@myriad-com.com.au> wrote: >> On 19 Oct 2013, at 3:15 AM, Uli Kusterer <witness.of.teacht...@gmx.net> >> wrote: >> >>> this is what you'd do if you wanted to make e.g. CoreFoundation APIs >>> accessible to a scripting language >> >> That's along the lines of what I had in mind, although in this case for >> basic things like the trig functions in Math.h. > > So, is this supposed to just directly hand off some standard functions you > decide to map into your library, like PHP exposes most of the standard C > library? In that case I’d probably just write a little script that generates > wrappers that translate between your language’s calling convention and the > one of the C library, and enter them in a global variable with a struct that > maps the plain-text name to the function pointer. > > Whether you actually want to regex-parse the headers (like I did here for my > Hammer programming language: > https://github.com/uliwitness/Forge/blob/master/headerimport.php) or whether > you want to just hand-write a short, easily parsed list of the functions and > their argument types is up to you. The latter requires less maintenance if > you plan to only selectively import a few native calls, as regex-parsing of > C/ObjC headers is rather optimistic and tends to break every couple of system > releases. > To parse C/Obj-C/C++ headers, you can also use libclang which is design to do that. I used it to parse C header and generate boilerplate code some times ago, and it worked quite well with very few code to write on my side. > If you, on the other hand, want to support creation of actual headers by > users of your language and adding of new functions w/o recompiling, you’re > prolly best off with a foreign function interface like libffi. > > Cheers, > -- Uli Kusterer > “The Witnesses of TeachText are everywhere...” > http://stacksmith.org > > > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org > > This email sent to devli...@shadowlab.org -- Jean-Daniel _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com