uliwitness / Stacksmith

An intuitive software erector kit targeted at people new to programming, but with enough potential to stay useful once they've learned, inspired by HyperCard.
http://stacksmith.org
129 stars 13 forks source link

Fix native calls (XCMD replacement) #13

Open uliwitness opened 12 years ago

uliwitness commented 12 years ago

SuperCompiler (where the parser for Forge came from) used to have a feature where you could write MacOS CoreFoundation function calls and Objective C method calls into your Hammer (HyperTalk/SuperTalk) scripts, and thus call system API directly. This got broken with the move from generating C++ source code that is compiled into an XCMD to generating Leonie byte-code.

Make this work again by adding byte-code instructions to Leonie that call native functions and methods, and by fixing the parser to generate the right data types/translate whatever the user passed in. That way, we do not need XCMDs anymore. Even better, with the Stacksmith Canvas, a user could create a plain "NSFileManager" object and write wrappers around NSFileManager methods in there, and then anyone could use it like an XCMD, without having to worry about the memory management or weird ObjC syntax that the creator of this object had to.

This may have repercussions on how we implement the "start using" command. We want real XCMDs and objects like this one to be available to people who "start using" our stack. Maybe just slap on a property "share with users of this stack" ? (I don't like that name, open for suggestions).

uliwitness commented 8 years ago

You can now make native ObjC method calls in Stacksmith again (unless you're in a stack that was loaded from the web, then this functionality is turned off). However, other system API is not yet available.

uliwitness commented 7 years ago

Currently, we get called by the parser when you make your first ObjC call. That's when we parse the frameworkheaders.hhc file. This means that if you try to call a C function system API, it will not work until you've at least done one ObjC call.

Parsing frameworkheaders.hhc (that's done in CParser::LoadNativeHeadersFromFile()) takes quite a while. We need to speed this up so we can just parse all of this at startup. At the least, we could maybe split the C functions and constants from the ObjC classes, and load the C stuff at startup, the ObjC stuff on the first ObjC call?

The script that parses Apple's headers into frameworkheaders.hhc is Forge/headerimport.php, and may have to be changed if we do the latter.