When I create new Cappuccino project using terminal command capp gen MyProject, I get AppController.j that uses many Foundation and AppKit classes, but has just one import statement
@import <Foundation/CPObject.j>
How does Cappuccino import system work? How does application know about CPNotification, CPWindow, CPTextField and other classes used in AppController.j.
Thanks!
Most of the imports are superfluous but it's good to have them because it helps with our static analysis tools to help strip out code when you build for production.
There are two 'environmental' variables defined on the index.html and index-debug.html pages. See here.
OBJJ_INCLUDE_PATHS basically is a list of places for objj to look when importing framework/library code. So for example you do:
@import <Foundation/CPObject.j>
instead of:
@import "Foundation/CPObject.j>
That's because Foundation/CPObject.j lives inside the Frameworks. So Doing@import "Frameworks/Foundation/CPObject.j
is exact the same as using the angle brackets.
That means you move your framework code to any directory you want, and by using the angle bracket syntax, we're able to find those files without a real path.
So how does your application know about all those other classes which aren't directly imported? Well, if you noticed in the index file I linked to above, there is another line specifying where objj can find main(). At the top of that file main.j imports both the Foundation and AppKit frameworks: See Here.
We can follow those imports and see that CPWindow.j gets imported on line 109 of AppKit.j.
So since AppKit.j imports most of AppKit for you, your classes that depend on CPWindow (for example) shouldn't have to manually import it… but it certainly doesn't hurt (files never get imported twice).
But since AppKit and Foundation don't know anything about your own classes that you write, you do need to manually import those.