Exemple #1
0
PUBLIC void ejsConfigureWorkerType(Ejs *ejs)
{
    EjsType     *type;
    EjsPot      *prototype;

    if ((type = ejsFinalizeScriptType(ejs, N("ejs", "Worker"), sizeof(EjsWorker), manageWorker, 
            EJS_TYPE_POT | EJS_TYPE_MUTABLE_INSTANCES)) == 0) {
        return;
    }
    prototype = type->prototype;
    ejsBindConstructor(ejs, type, workerConstructor);
    ejsBindMethod(ejs, type, ES_Worker_exit, workerExit);
    ejsBindMethod(ejs, type, ES_Worker_join, workerJoin);
    ejsBindMethod(ejs, type, ES_Worker_lookup, workerLookup);
    ejsBindMethod(ejs, type, ES_Worker_fork, workerFork);
    ejsBindMethod(ejs, prototype, ES_Worker_clone, workerClone);
    ejsBindMethod(ejs, prototype, ES_Worker_eval, workerEval);
    ejsBindMethod(ejs, prototype, ES_Worker_load, workerLoad);
    ejsBindMethod(ejs, prototype, ES_Worker_preload, workerPreload);
    ejsBindMethod(ejs, prototype, ES_Worker_preeval, workerPreeval);
    ejsBindMethod(ejs, prototype, ES_Worker_postMessage, workerPostMessage);
    ejsBindMethod(ejs, prototype, ES_Worker_terminate, workerTerminate);
    ejsBindMethod(ejs, prototype, ES_Worker_waitForMessage, workerWaitForMessage);

    ejsAddImmutable(ejs, S_Event, N("ejs", "Event"), ejsGetTypeByName(ejs, N("ejs", "Event")));
    ejsAddImmutable(ejs, S_ErrorEvent, N("ejs", "ErrorEvent"), ejsGetTypeByName(ejs, N("ejs", "ErrorEvent")));
}
Exemple #2
0
/*
    Shape loadable module entry point. This will be called by the Ejscript loader 
    after the Shape.mod file is loaded and before Shape initializers are run. 

    Module entry points be named [NAME]ModuleInit where "[NAME]" is the name of 
    the module starting with a lower case letter and  with any "." characters 
    converted to underscores.
 */
int configureSampleTypes(Ejs *ejs)
{
    EjsType     *type;

    mprLog(1, "Loading Sample module");

    /*
        Get the Shape class object. This will be created from the mod file for us.
     */
    type = ejsGetTypeByName(ejs, N("nclass", "Shape"));
    if (type == 0) {
        mprError("Can't find type Shape");
        return MPR_ERR_CANT_ACCESS;
    }

    /*
        Bind the C functions to the JavaScript functions. We use the slot definitions generated
        by ejsmod from Shape.es.
     */
    ejsBindConstructor(ejs, type, constructor);
    ejsBindMethod(ejs, type, ES_nclass_Shape_area, area);
    return 0;
}