[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

[coco8] Architecture of JSCocoa Interface

The main procedure is activated when the coco8 application start running.

Main procedure will
  1. bind to the JavascriptCore(JSC) library
  2. initialize BridgeSupportController (bridge to C structures, functions and constants)
  3. instatiate JSCocoaController
  4. load the s8 system
  5. run UIApplicationMain

Binding to JavascriptCore

The binding to JSC API is static and to the library provided by iOS.

BridgeSupportController sharedController

The binding to static structures, functions and constant values provided by the executable of application at C level is read at startup from XML files (from application's documents folder or application's bundle).
Read more on [coco8] How we are booting an S8 system in iOS?.

JSCocoaController sharedController

The singleton instance of JSCocoaController set a custom Javascript environment to access native objects from javascript space. As we run S8 on top of Javascript, the access is available to S8 objects using our NativeObject framework.

The definition of the API at global scope is implemented by method initWithGlobalContext: of JSCocoaController.

The native (ObjectiveC) objects are seen from S8 side as handles of NativeObject framework. The handles are instances of "Cocoa box", implemented as
	//
	// Private object, used for holding references to objects, classes, structs
	//
	JSClassDefinition jsCocoaObjectDefinition	= kJSClassDefinitionEmpty;
	jsCocoaObjectDefinition.className		= "JSCocoa box";
	jsCocoaObjectDefinition.initialize		= jsCocoaObject_initialize;
	jsCocoaObjectDefinition.finalize		= jsCocoaObject_finalize;
	jsCocoaObjectDefinition.getProperty		= jsCocoaObject_getProperty;
	jsCocoaObjectDefinition.setProperty		= jsCocoaObject_setProperty;
	jsCocoaObjectDefinition.deleteProperty		= jsCocoaObject_deleteProperty;
	jsCocoaObjectDefinition.getPropertyNames	= jsCocoaObject_getPropertyNames;
	jsCocoaObjectDefinition.callAsConstructor	= jsCocoaObject_callAsConstructor;
	jsCocoaObjectDefinition.convertToType		= jsCocoaObject_convertToType;
	jsCocoaObjectClass				= JSClassCreate(&jsCocoaObjectDefinition);

NoteAll functions prefixed with jsCocoaObject_ are implemented by JSCocoaController, to provide transparent access to ObjectiveC objects from S8 objects through NativeObject framework.

load the S8 system

The S8 system is composed by three ".js" files.
Read more on [coco8] How we are booting an S8 system in iOS?.

The files are loaded in order from documents folder of the application or (if the file do not exist) from application bundle. This strategy make possible to modify/refine the contents by the user; saving the (default) image and settings used by application in the next run.

run UIApplicationMain

The application's delegate is implemented in S8 as all the application.
Read more on