Exemplo n.º 1
0
void ejsConfigureErrorType(Ejs *ejs)
{
    defineType(ejs, ES_Error);

    ejsBindMethod(ejs, ejs->errorType, ES_Error_code, (EjsNativeFunction) getCode);
    ejsBindMethod(ejs, ejs->errorType, ES_Error_set_code, (EjsNativeFunction) setCode);

    defineType(ejs, ES_ArgError);
    defineType(ejs, ES_ArithmeticError);
    defineType(ejs, ES_AssertError);
    defineType(ejs, ES_InstructionError);
    defineType(ejs, ES_IOError);
    defineType(ejs, ES_InternalError);
    defineType(ejs, ES_MemoryError);
    defineType(ejs, ES_OutOfBoundsError);
    defineType(ejs, ES_ReferenceError);
    defineType(ejs, ES_ResourceError);
#if ES_SecurityError
    defineType(ejs, ES_SecurityError);
#endif
    defineType(ejs, ES_StateError);
    defineType(ejs, ES_SyntaxError);
    defineType(ejs, ES_TypeError);
    defineType(ejs, ES_URIError);
}
Exemplo n.º 2
0
void ejsConfigureWorkerType(Ejs *ejs)
{
    EjsType     *type;
    EjsName     qname;

    type = (EjsType*) ejsGetPropertyByName(ejs, ejs->global, ejsName(&qname, "ejs.sys", "Worker"));
    if (type) {
        type->instanceSize = sizeof(EjsWorker);
        type->dontPool = 1;
        type->needFinalize = 1;
        type->helpers->destroyVar = (EjsDestroyVarHelper) destroyWorker;
        type->helpers->markVar = (EjsMarkVarHelper) markWorker;
        ejsBindMethod(ejs, type, ES_ejs_sys_Worker_Worker, (EjsNativeFunction) workerConstructor);
        ejsBindMethod(ejs, type, ES_ejs_sys_Worker_eval, (EjsNativeFunction) workerEval);
        ejsBindMethod(ejs, type, ES_ejs_sys_Worker_exit, (EjsNativeFunction) workerExit);
        ejsBindMethod(ejs, type, ES_ejs_sys_Worker_join, (EjsNativeFunction) workerJoin);
        ejsBindMethod(ejs, type, ES_ejs_sys_Worker_load, (EjsNativeFunction) workerLoad);
        ejsBindMethod(ejs, type, ES_ejs_sys_Worker_lookup, (EjsNativeFunction) workerLookup);
        ejsBindMethod(ejs, type, ES_ejs_sys_Worker_preload, (EjsNativeFunction) workerPreload);
        ejsBindMethod(ejs, type, ES_ejs_sys_Worker_postMessage, (EjsNativeFunction) workerPostMessage);
        ejsBindMethod(ejs, type, ES_ejs_sys_Worker_terminate, (EjsNativeFunction) workerTerminate);
        ejsBindMethod(ejs, type, ES_ejs_sys_Worker_waitForMessage, (EjsNativeFunction) workerWaitForMessage);
        ejs->workerType = type;
    }
}
Exemplo n.º 3
0
void ejsConfigureVoidType(Ejs *ejs)
{
    EjsType     *type;

    type = ejs->voidType;

    ejsSetProperty(ejs, ejs->global, ES_undefined, ejs->undefinedValue);

    ejsBindMethod(ejs, type, ES_Object_get, getVoidIterator);
    ejsBindMethod(ejs, type, ES_Object_getValues, getVoidIterator);
}
Exemplo n.º 4
0
PUBLIC void ejsConfigureNullType(Ejs *ejs)
{
    EjsType     *type;
    EjsPot      *prototype;

    if ((type = ejsFinalizeCoreType(ejs, N("ejs", "Null"))) == 0) {
        return;
    }
    prototype = type->prototype;
    ejsBindMethod(ejs, prototype, ES_Null_iterator_get, getNullIterator);
    ejsBindMethod(ejs, prototype, ES_Null_iterator_getValues, getNullIterator);
}
Exemplo n.º 5
0
PUBLIC void ejsConfigureGCType(Ejs *ejs)
{
    EjsType         *type;

    if ((type = ejsFinalizeScriptType(ejs, N("ejs", "GC"), sizeof(EjsPot), ejsManagePot, EJS_TYPE_POT)) == 0) {
        return;
    }
    ejsBindAccess(ejs, type, ES_GC_enabled, gc_enabled, gc_set_enabled);
    ejsBindAccess(ejs, type, ES_GC_newQuota, gc_newQuota, gc_set_newQuota);
    ejsBindMethod(ejs, type, ES_GC_run, gc_run);
    ejsBindMethod(ejs, type, ES_GC_verify, gc_verify);
}
Exemplo n.º 6
0
PUBLIC void ejsConfigureSystemType(Ejs *ejs)
{
    EjsType         *type;

    if ((type = ejsFinalizeScriptType(ejs, N("ejs", "System"), 0, 0, 0)) == 0) {
        return;
    }
    ejsBindMethod(ejs, type, ES_System_hostname, system_hostname);
    ejsBindMethod(ejs, type, ES_System_ipaddr, system_ipaddr);
#if ES_System_tmpdir
    ejsBindMethod(ejs, type, ES_System_tmpdir, system_tmpdir);
#endif
}
Exemplo n.º 7
0
PUBLIC void ejsConfigureMprLogType(Ejs *ejs)
{
    EjsType     *type;
    EjsPot      *prototype;

    if ((type = ejsFinalizeScriptType(ejs, N("ejs", "MprLog"), sizeof(EjsPot), ejsManagePot, EJS_TYPE_POT)) == 0) {
        return;
    }
    prototype = type->prototype;
    ejsBindMethod(ejs, prototype, ES_MprLog_emit, lf_emit);
    ejsBindAccess(ejs, prototype, ES_MprLog_fixed, lf_fixed, lf_set_fixed);
    ejsBindAccess(ejs, prototype, ES_MprLog_level, lf_level, lf_set_level);
    ejsBindMethod(ejs, prototype, ES_MprLog_redirect, lf_redirect);
}
Exemplo n.º 8
0
static int configureDebuggerTypes(Ejs *ejs)
{
    EjsType         *type;
    
    type = (EjsType*) ejsConfigureNativeType(ejs, "ejs.db", "Debugger", sizeof(EjsDebugger));
    type->needFinalize = 1;

    type->helpers = ejsCloneObjectHelpers(ejs, "debugger-helpers");
    type->helpers->destroy = (EjsDestroyHelper) destroyDebuggerDb;

    ejsBindMethod(ejs, type, ES_ejs_db_Debugger_Debugger, debuggerConstructor);
    ejsBindMethod(ejs, type, ES_ejs_db_Debugger_close, debuggerClose);
    ejsBindMethod(ejs, type, ES_ejs_db_Debugger_sql, debuggerSql);
    return 0;
}
Exemplo n.º 9
0
static void defineType(Ejs *ejs, int slotNum)
{
    EjsType     *type;

    type = ejsGetType(ejs, slotNum);
    ejsBindMethod(ejs, type, type->block.numInherited, (EjsNativeFunction) errorConstructor);
}
Exemplo n.º 10
0
void ejsConfigureBooleanType(Ejs *ejs)
{
    EjsType     *type;

    type = ejs->booleanType;

    defineBooleanConstants(ejs);
    ejsBindMethod(ejs, type, ES_Boolean_Boolean, (EjsNativeFunction) booleanConstructor);
}
Exemplo n.º 11
0
void ejsConfigureIteratorType(Ejs *ejs)
{
    EjsType     *type;

    type = ejs->iteratorType;

    /*
     *  Define the "next" method
     */
    ejsBindMethod(ejs, ejs->iteratorType, ES_Iterator_next, (EjsNativeFunction) nextIterator);
}
Exemplo n.º 12
0
EjsType *ejsDefineShapeType(Ejs *ejs)
{
    EjsHelpers      *helpers;
    EjsType         *type;
    EjsPot          *prototype;

    /*
        Get the Shape class object. This will be created from the mod file for us. But we need to set the object
        instance size.
     */
    if ((type = ejsGetPropertyByName(ejs, ejs->global, N(EJS_PUBLIC_NAMESPACE, "Shape"))) == 0) {
        mprError("Can't find class Shape");
        return 0;
    }
    type->instanceSize = sizeof(Shape);
    prototype = type->prototype;

    /*
        Define the helper functions.
     */
    helpers = &type->helpers;
    helpers->clone                  = (EjsCloneHelper) cloneShape;
    helpers->create                 = (EjsCreateHelper) create;
    helpers->getProperty            = (EjsGetPropertyHelper) getProperty;
    helpers->getPropertyCount       = (EjsGetPropertyCountHelper) getPropertyCount;
    helpers->getPropertyName        = (EjsGetPropertyNameHelper) getPropertyName;
    helpers->lookupProperty         = (EjsLookupPropertyHelper) lookupProperty;
    helpers->setProperty            = (EjsSetPropertyHelper) setProperty;

#if UNUSED
    /*
        Other possible helpers. For this sample, the default helpers are sufficient. Override these if required 
        in your native class.
     */
    helpers->castVar                = (EjsCastHelper) castVar;
    helpers->defineProperty         = (EjsDefinePropertyHelper) defineProperty;
    helpers->destroyVar             = (EjsDestroyHelper) destroyVar;
    helpers->deleteProperty         = (EjsDeletePropertyHelper) deleteProperty;
    helpers->deletePropertyByName   = (EjsDeletePropertyByNameHelper) deletePropertyByName;
    helpers->finalizeVar            = (EjsFinalizeHelper) finalizeVar;
    helpers->invokeOperator         = (EjsInvokeOperatorHelper) invokeOperator;
    helpers->markVar                = (EjsMarkHelper) markVar;
    helpers->setPropertyName        = (EjsSetPropertyNameHelper) setPropertyName;
#endif

    /*
        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, prototype, ES_nclass_Shape_area, area);
    return type;
}
Exemplo n.º 13
0
void ejsConfigureDbTypes(Ejs *ejs)
{
    EjsType     *type;
    EjsName     qname;

    ejsName(&qname, "ejs.db", "Database");
    type = (EjsType*) ejsGetPropertyByName(ejs, ejs->global, &qname);
    if (type == 0 || !ejsIsType(type)) {
        ejs->hasError = 1;
        return;
    }

    type->instanceSize = sizeof(EjsDb);
    type->helpers->finalizeVar = (EjsFinalizeVarHelper) finalizeDb;

    ejsBindMethod(ejs, type, ES_ejs_db_Database_Database, (EjsNativeFunction) dbConstructor);
    ejsBindMethod(ejs, type, ES_ejs_db_Database_close, (EjsNativeFunction) closeDb);
    ejsBindMethod(ejs, type, ES_ejs_db_Database_sql, (EjsNativeFunction) sql);

#if UNUSED
    ejsSetAccessors(ejs, type, ES_ejs_db_Database_tables, (EjsNativeFunction) tables, -1, 0);
    ejsBindMethod(ejs, type, ES_ejs_db_Database_start, startDb);
    ejsBindMethod(ejs, type, ES_ejs_db_Database_commit, commitDb);
    ejsBindMethod(ejs, type, ES_ejs_db_Database_rollback, rollbackDb);
#endif
}
Exemplo n.º 14
0
PUBLIC void ejsConfigureRegExpType(Ejs *ejs)
{
    EjsType     *type;
    EjsPot      *prototype;

    if ((type = ejsFinalizeCoreType(ejs, N("ejs", "RegExp"))) == 0) {
        return;
    }
    prototype = type->prototype;
    ejsBindConstructor(ejs, type, regex_Constructor);
    ejsBindMethod(ejs, prototype, ES_RegExp_exec, regex_exec);
    ejsBindAccess(ejs, prototype, ES_RegExp_lastIndex, regex_getLastIndex, regex_setLastIndex);
    ejsBindMethod(ejs, prototype, ES_RegExp_global, regex_getGlobalFlag);
    ejsBindMethod(ejs, prototype, ES_RegExp_ignoreCase, regex_getIgnoreCase);
    ejsBindMethod(ejs, prototype, ES_RegExp_multiline, regex_getMultiline);
    ejsBindMethod(ejs, prototype, ES_RegExp_source, regex_getSource);
    ejsBindMethod(ejs, prototype, ES_RegExp_matched, regex_matched);
    ejsBindMethod(ejs, prototype, ES_RegExp_start, regex_start);
    ejsBindMethod(ejs, prototype, ES_RegExp_sticky, regex_sticky);
    ejsBindMethod(ejs, prototype, ES_RegExp_test, regex_test);
    ejsBindMethod(ejs, prototype, ES_RegExp_toString, ejsRegExpToString);
}
Exemplo n.º 15
0
void ejsConfigureIteratorType(Ejs *ejs)
{
    EjsType     *type;
    EjsPot      *prototype;

    if ((type = ejsFinalizeCoreType(ejs, N(EJS_ITERATOR_NAMESPACE, "Iterator"))) == 0) {
        return;
    }
    prototype = type->prototype;
    ejsBindMethod(ejs, prototype, ES_iterator_Iterator_next, nextIterator);

    if ((type = ejsFinalizeCoreType(ejs, N(EJS_ITERATOR_NAMESPACE, "StopIteration"))) == 0) {
        return;
    }
}
Exemplo n.º 16
0
PUBLIC void ejsConfigureXMLListType(Ejs *ejs)
{
    EjsType     *type;
    EjsPot      *prototype;

    if ((type = ejsFinalizeCoreType(ejs, N("ejs", "XMLList"))) == 0) {
        return;
    }
    prototype = type->prototype;
    ejsBindConstructor(ejs, type, xmlListConstructor);
    ejsBindMethod(ejs, prototype, ES_XMLList_length, xlLength);
    ejsBindMethod(ejs, prototype, ES_XMLList_name, getXmlListNodeName);
    ejsBindMethod(ejs, prototype, ES_XMLList_parent, (EjsProc) xl_parent);
#if FUTURE
    ejsBindMethod(ejs, prototype, "name", name, NULL);
    ejsBindMethod(ejs, prototype, "valueOf", valueOf, NULL);
#endif
    ejsBindMethod(ejs, prototype, ES_XMLList_toJSON, xmlListToJson);
    ejsBindMethod(ejs, prototype, ES_XMLList_toString, xmlListToString);
    ejsBindMethod(ejs, prototype, ES_XMLList_iterator_get, getXmlListIterator);
    ejsBindMethod(ejs, prototype, ES_XMLList_iterator_getValues, getXmlListValues);
}
Exemplo n.º 17
0
MprModule *acmeModuleInit(Ejs *ejs)
{
    MprModule   *module;
    EjsType     *type;
    EjsName     qname;

    mprBreakpoint();
    mprLog(ejs, 1, "Loading Acme module");
    if ((module = mprCreateModule(ejs, "acme", BLD_VERSION, 0, 0, 0)) == 0) {
        return 0;
    }
    type = (EjsType*) ejsGetPropertyByName(ejs, ejs->global, ejsName(&qname, "Acme", "Rocket"));
    if (type == 0) {
        mprError(ejs, "Can't find type %s", qname.name);
        return 0;
    }
    ejsBindMethod(ejs, type, ES_Acme_Rocket_countdown, (EjsNativeFunction) countdown);
    return module;
}
Exemplo n.º 18
0
static int configureZlibTypes(Ejs *ejs)
{
    EjsType     *type;
    
    if ((type = ejsFinalizeScriptType(ejs, N("ejs.zlib", "Zlib"), 0, NULL, 0)) == 0) {
        return 0;
    }
    ejsBindMethod(ejs, type, ES_ejs_zlib_Zlib_compress, zlib_compress);
    ejsBindMethod(ejs, type, ES_ejs_zlib_Zlib_uncompress, zlib_uncompress);
    ejsBindMethod(ejs, type, ES_ejs_zlib_Zlib_compressBytes, zlib_compressBytes);
    ejsBindMethod(ejs, type, ES_ejs_zlib_Zlib_uncompressBytes, zlib_uncompressBytes);
    ejsBindMethod(ejs, type, ES_ejs_zlib_Zlib_compressString, zlib_compressString);
    ejsBindMethod(ejs, type, ES_ejs_zlib_Zlib_uncompressString, zlib_uncompressString);
    return 0;
}
Exemplo n.º 19
0
PUBLIC void ejsConfigureErrorType(Ejs *ejs)
{
    //  OPT simplify
    configureType(ejs, "Error");
    configureType(ejs, "ArgError");
    configureType(ejs, "ArithmeticError");
    configureType(ejs, "AssertError");
    configureType(ejs, "InstructionError");
    configureType(ejs, "IOError");
    configureType(ejs, "InternalError");
    configureType(ejs, "MemoryError");
    configureType(ejs, "OutOfBoundsError");
    configureType(ejs, "ReferenceError");
    configureType(ejs, "ResourceError");
    configureType(ejs, "SecurityError");
    configureType(ejs, "StateError");
    configureType(ejs, "SyntaxError");
    configureType(ejs, "TypeError");
    configureType(ejs, "URIError");

    ejsBindMethod(ejs, ESV(Error), ES_Error_capture, error_capture);
}
Exemplo n.º 20
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;
}
Exemplo n.º 21
0
void ejsConfigureMemoryType(Ejs *ejs)
{
    EjsType         *type;

    type = ejsGetType(ejs, ES_ejs_sys_Memory);

    ejsBindMethod(ejs, type, ES_ejs_sys_Memory_allocated, (EjsNativeFunction) getAllocatedMemory);
    ejsBindMethod(ejs, type, ES_ejs_sys_Memory_set_callback, (EjsNativeFunction) setRedlineCallback);
    ejsBindMethod(ejs, type, ES_ejs_sys_Memory_maximum, (EjsNativeFunction) getMaxMemory);
    ejsBindMethod(ejs, type, ES_ejs_sys_Memory_set_maximum, (EjsNativeFunction) setMaxMemory);
    ejsBindMethod(ejs, type, ES_ejs_sys_Memory_peak, (EjsNativeFunction) getPeakMemory);
    ejsBindMethod(ejs, type, ES_ejs_sys_Memory_redline, (EjsNativeFunction) getRedline);
    ejsBindMethod(ejs, type, ES_ejs_sys_Memory_set_redline, (EjsNativeFunction) setRedline);
    ejsBindMethod(ejs, type, ES_ejs_sys_Memory_resident, (EjsNativeFunction) getResident);
    ejsBindMethod(ejs, type, ES_ejs_sys_Memory_stack, (EjsNativeFunction) getStack);
    ejsBindMethod(ejs, type, ES_ejs_sys_Memory_system, (EjsNativeFunction) getSystemRam);
    ejsBindMethod(ejs, type, ES_ejs_sys_Memory_stats, (EjsNativeFunction) printStats);
}
Exemplo n.º 22
0
PUBLIC void ejsConfigureArrayType(Ejs *ejs)
{
    EjsType     *type;
    EjsPot      *prototype;

    if ((type = ejsFinalizeCoreType(ejs, N("ejs", "Array"))) == 0) {
        return;
    }
    prototype = type->prototype;
    ejsBindConstructor(ejs, type, arrayConstructor);
    ejsBindMethod(ejs, prototype, ES_Array_iterator_get, getArrayIterator);
    ejsBindMethod(ejs, prototype, ES_Array_iterator_getValues, getArrayValues);
    ejsBindMethod(ejs, prototype, ES_Array_clone, cloneArrayMethod);
    ejsBindMethod(ejs, prototype, ES_Array_toString, arrayToString);
    ejsBindMethod(ejs, prototype, ES_Array_append, appendArray);
    ejsBindMethod(ejs, prototype, ES_Array_clear, clearArray);
    ejsBindMethod(ejs, prototype, ES_Array_compact, compactArray);
    ejsBindMethod(ejs, prototype, ES_Array_concat, concatArray);
    ejsBindMethod(ejs, prototype, ES_Array_indexOf, indexOfArray);
    ejsBindMethod(ejs, prototype, ES_Array_insert, insertArray);
    ejsBindMethod(ejs, prototype, ES_Array_join, joinArray);
    ejsBindMethod(ejs, prototype, ES_Array_lastIndexOf, lastArrayIndexOf);
    ejsBindAccess(ejs, prototype, ES_Array_length, getArrayLength, setArrayLength);
    ejsBindMethod(ejs, prototype, ES_Array_pop, popArray);
    ejsBindMethod(ejs, prototype, ES_Array_push, pushArray);
    ejsBindMethod(ejs, prototype, ES_Array_removeElements, removeElements);
    ejsBindMethod(ejs, prototype, ES_Array_reverse, reverseArray);
    ejsBindMethod(ejs, prototype, ES_Array_shift, shiftArray);
    ejsBindMethod(ejs, prototype, ES_Array_slice, sliceArray);
    ejsBindMethod(ejs, prototype, ES_Array_sort, ejsSortArray);
    ejsBindMethod(ejs, prototype, ES_Array_splice, spliceArray);
    ejsBindMethod(ejs, prototype, ES_Array_unique, uniqueArray);
    ejsBindMethod(ejs, prototype, ES_Array_unshift, unshiftArray);

#if FUTURE
    ejsBindMethod(ejs, prototype, ES_Array_toLocaleString, toLocaleString);
    ejsBindMethod(ejs, prototype, ES_Array_toJSONString, toJSONString);
    ejsBindMethod(ejs, prototype, ES_Array_LBRACKET, operLBRACKET);
    ejsBindMethod(ejs, prototype, ES_Array_AND, operAND);
    ejsBindMethod(ejs, prototype, ES_Array_EQ, operEQ);
    ejsBindMethod(ejs, prototype, ES_Array_GT, operGT);
    ejsBindMethod(ejs, prototype, ES_Array_LT, operLT);
    ejsBindMethod(ejs, prototype, ES_Array_LSH, operLSH);
    ejsBindMethod(ejs, prototype, ES_Array_MINUS, operMINUS);
    ejsBindMethod(ejs, prototype, ES_Array_OR, operOR);
    ejsBindMethod(ejs, prototype, ES_Array_AND, operAND);
#endif
}
Exemplo n.º 23
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")));
}
Exemplo n.º 24
0
void ejsConfigureArrayType(Ejs *ejs)
{
    EjsType     *type;

    type = ejs->arrayType;

    /*
     *  We override some object methods
     */
    ejsBindMethod(ejs, type, ES_Object_get, getArrayIterator);
    ejsBindMethod(ejs, type, ES_Object_getValues, getArrayValues);
    ejsBindMethod(ejs, type, ES_Object_clone, (EjsNativeFunction) cloneArrayMethod);
    ejsBindMethod(ejs, type, ES_Object_toString, (EjsNativeFunction) arrayToString);
    ejsBindMethod(ejs, type, ES_Object_length, (EjsNativeFunction) getArrayLength);
    ejsBindMethod(ejs, type, ES_Array_set_length, (EjsNativeFunction) setArrayLength);

    /*
     *  Methods and Operators, including constructor.
     */
    ejsBindMethod(ejs, type, ES_Array_Array, (EjsNativeFunction) arrayConstructor);
    ejsBindMethod(ejs, type, ES_Array_append, (EjsNativeFunction) appendArray);
    ejsBindMethod(ejs, type, ES_Array_clear, (EjsNativeFunction) clearArray);
    ejsBindMethod(ejs, type, ES_Array_compact, (EjsNativeFunction) compactArray);
    ejsBindMethod(ejs, type, ES_Array_concat, (EjsNativeFunction) concatArray);

    ejsBindMethod(ejs, type, ES_Array_indexOf, (EjsNativeFunction) indexOfArray);
    ejsBindMethod(ejs, type, ES_Array_insert, (EjsNativeFunction) insertArray);
    ejsBindMethod(ejs, type, ES_Array_join, (EjsNativeFunction) joinArray);
    ejsBindMethod(ejs, type, ES_Array_lastIndexOf, (EjsNativeFunction) lastArrayIndexOf);
    ejsBindMethod(ejs, type, ES_Array_pop, (EjsNativeFunction) popArray);
    ejsBindMethod(ejs, type, ES_Array_push, (EjsNativeFunction) pushArray);
    ejsBindMethod(ejs, type, ES_Array_reverse, (EjsNativeFunction) reverseArray);
    ejsBindMethod(ejs, type, ES_Array_shift, (EjsNativeFunction) shiftArray);
    ejsBindMethod(ejs, type, ES_Array_slice, (EjsNativeFunction) sliceArray);
    ejsBindMethod(ejs, type, ES_Array_sort, (EjsNativeFunction) sortArray);
    ejsBindMethod(ejs, type, ES_Array_splice, (EjsNativeFunction) spliceArray);
    ejsBindMethod(ejs, type, ES_Array_unique, (EjsNativeFunction) uniqueArray);
    ejsBindMethod(ejs, type, ES_Array_unshift, (EjsNativeFunction) unshiftArray);
}
Exemplo n.º 25
0
void ejsConfigureAppType(Ejs *ejs)
{
    EjsType         *type;

    type = ejsGetType(ejs, ES_ejs_sys_App);

    ejsBindMethod(ejs, type, ES_ejs_sys_App_args, (EjsNativeFunction) getArgs);
    ejsBindMethod(ejs, type, ES_ejs_sys_App_dir, (EjsNativeFunction) currentDir);
    ejsBindMethod(ejs, type, ES_ejs_sys_App_chdir, (EjsNativeFunction) changeCurrentDir);
#if ES_ejs_sys_App_exeDir
    ejsBindMethod(ejs, type, ES_ejs_sys_App_exeDir, (EjsNativeFunction) exeDir);
#endif
#if ES_ejs_sys_App_exePath
    ejsBindMethod(ejs, type, ES_ejs_sys_App_exePath, (EjsNativeFunction) exePath);
#endif
    ejsBindMethod(ejs, type, ES_ejs_sys_App_exit, (EjsNativeFunction) exitApp);
    ejsBindMethod(ejs, type, ES_ejs_sys_App_errorStream, (EjsNativeFunction) getErrorStream);
    ejsBindMethod(ejs, type, ES_ejs_sys_App_getenv, (EjsNativeFunction) getEnvVar);
    ejsBindMethod(ejs, type, ES_ejs_sys_App_putenv, (EjsNativeFunction) putEnvVar);
    ejsBindMethod(ejs, type, ES_ejs_sys_App_inputStream, (EjsNativeFunction) getInputStream);
    ejsBindMethod(ejs, type, ES_ejs_sys_App_noexit, (EjsNativeFunction) noexit);
    ejsBindMethod(ejs, type, ES_ejs_sys_App_outputStream, (EjsNativeFunction) getOutputStream);
    ejsBindMethod(ejs, type, ES_ejs_sys_App_searchPath, (EjsNativeFunction) getSearchPath);
    ejsBindMethod(ejs, type, ES_ejs_sys_App_set_searchPath, (EjsNativeFunction) setSearchPath);
    ejsBindMethod(ejs, type, ES_ejs_sys_App_serviceEvents, (EjsNativeFunction) serviceEvents);
#if ES_ejs_sys_App_sleep
    ejsBindMethod(ejs, type, ES_ejs_sys_App_sleep, (EjsNativeFunction) sleepProc);
#endif
}
Exemplo n.º 26
0
PUBLIC void ejsConfigureUriType(Ejs *ejs)
{
    EjsType     *type;
    EjsPot      *prototype;

    if ((type = ejsFinalizeScriptType(ejs, N("ejs", "Uri"), sizeof(EjsUri), manageUri,
            EJS_TYPE_OBJ | EJS_TYPE_MUTABLE_INSTANCES)) != 0) {
        type->helpers.clone = (EjsCloneHelper) cloneUri;
        //  MOB - Add cast helper to cast from Strings, Paths etc.
        type->helpers.invokeOperator = (EjsInvokeOperatorHelper) invokeUriOperator;

        ejsBindMethod(ejs, type, ES_Uri_decode, uri_decode);
        ejsBindMethod(ejs, type, ES_Uri_decodeComponent, uri_decodeComponent);
        ejsBindMethod(ejs, type, ES_Uri_encode, uri_encode);
        ejsBindMethod(ejs, type, ES_Uri_encodeComponent, uri_encodeComponent);
        ejsBindMethod(ejs, type, ES_Uri_template, uri_template);

        prototype = type->prototype;
        ejsBindConstructor(ejs, type, uri_constructor);
        ejsBindMethod(ejs, prototype, ES_Uri_absolute, uri_absolute);
        ejsBindMethod(ejs, prototype, ES_Uri_basename, uri_basename);
        ejsBindMethod(ejs, prototype, ES_Uri_complete, uri_complete);
        ejsBindMethod(ejs, prototype, ES_Uri_components, uri_components);
        ejsBindMethod(ejs, prototype, ES_Uri_dirname, uri_dirname);
        ejsBindAccess(ejs, prototype, ES_Uri_extension, uri_extension, uri_set_extension);
        ejsBindMethod(ejs, prototype, ES_Uri_hasExtension, uri_hasExtension);
        ejsBindMethod(ejs, prototype, ES_Uri_hasHost, uri_hasHost);
        ejsBindMethod(ejs, prototype, ES_Uri_hasPort, uri_hasPort);
        ejsBindMethod(ejs, prototype, ES_Uri_hasQuery, uri_hasQuery);
        ejsBindMethod(ejs, prototype, ES_Uri_hasReference, uri_hasReference);
        ejsBindMethod(ejs, prototype, ES_Uri_hasScheme, uri_hasScheme);
        ejsBindAccess(ejs, prototype, ES_Uri_host, uri_host, uri_set_host);
        ejsBindMethod(ejs, prototype, ES_Uri_isAbsolute, uri_isAbsolute);
        ejsBindMethod(ejs, prototype, ES_Uri_isDir, uri_isDir);
        ejsBindMethod(ejs, prototype, ES_Uri_join, uri_join);
        ejsBindMethod(ejs, prototype, ES_Uri_joinExt, uri_joinExt);
        ejsBindMethod(ejs, prototype, ES_Uri_local, uri_local);
        ejsBindMethod(ejs, prototype, ES_Uri_mimeType, uri_mimeType);
        ejsBindMethod(ejs, prototype, ES_Uri_normalize, uri_normalize);
        ejsBindAccess(ejs, prototype, ES_Uri_path, uri_path, uri_set_path);
        ejsBindAccess(ejs, prototype, ES_Uri_port, uri_port, uri_set_port);
        ejsBindAccess(ejs, prototype, ES_Uri_scheme, uri_scheme, uri_set_scheme);
        ejsBindAccess(ejs, prototype, ES_Uri_query, uri_query, uri_set_query);
        ejsBindAccess(ejs, prototype, ES_Uri_reference, uri_reference, uri_set_reference);
        ejsBindMethod(ejs, prototype, ES_Uri_replaceExt, uri_replaceExtension);
        ejsBindMethod(ejs, prototype, ES_Uri_relative, uri_relative);
        ejsBindMethod(ejs, prototype, ES_Uri_resolve, uri_resolve);
        ejsBindMethod(ejs, prototype, ES_Uri_same, uri_same);
        ejsBindMethod(ejs, prototype, ES_Uri_toString, uri_toString);
        ejsBindMethod(ejs, prototype, ES_Uri_toLocalString, uri_toLocalString);
        ejsBindMethod(ejs, prototype, ES_Uri_trimExt, uri_trimExt);
        ejsBindAccess(ejs, prototype, ES_Uri_uri, uri_toString, uri_set_uri);
    }
    ejsBindMethod(ejs, ejs->global, ES_decodeURI, decodeURI);
    ejsBindMethod(ejs, ejs->global, ES_decodeURIComponent, decodeURIComponent);
    ejsBindMethod(ejs, ejs->global, ES_encodeURI, encodeURI);
    ejsBindMethod(ejs, ejs->global, ES_encodeURIComponent, encodeURIComponent);
}
Exemplo n.º 27
0
PUBLIC void ejsConfigureXMLType(Ejs *ejs)
{
    EjsType     *type;
    EjsPot      *prototype;

    if ((type = ejsFinalizeCoreType(ejs, N("ejs", "XML"))) == 0) {
        return;
    }
    prototype = type->prototype;
    ejsBindConstructor(ejs, type, xmlConstructor);
    ejsBindMethod(ejs, prototype, ES_XML_length, xmlLength);
    ejsBindMethod(ejs, prototype, ES_XML_load, loadXml);
    ejsBindMethod(ejs, prototype, ES_XML_save, saveXml);
    ejsBindMethod(ejs, prototype, ES_XML_name, getXmlNodeName);
    ejsBindMethod(ejs, prototype, ES_XML_parent, (EjsProc) xml_parent);

    /*
        Override these methods
     */
    ejsBindMethod(ejs, prototype, ES_XML_toString, xmlToString);
    ejsBindMethod(ejs, prototype, ES_XML_toJSON, xmlToJson);
    ejsBindMethod(ejs, prototype, ES_XML_iterator_get, getXmlIterator);
    ejsBindMethod(ejs, prototype, ES_XML_iterator_getValues, getXmlValues);
#if FUTURE
    ejsBindMethod(ejs, prototype, ES_XML_parent, parent);
    ejsBindMethod(ejs, prototype, "valueOf", valueOf, NULL);
#endif
}
Exemplo n.º 28
0
PUBLIC void ejsConfigureFileType(Ejs *ejs)
{
    EjsType     *type;
    EjsPot      *prototype;

    if ((type = ejsFinalizeScriptType(ejs, N("ejs", "File"), sizeof(EjsFile), manageFile,
            EJS_TYPE_OBJ | EJS_TYPE_NUMERIC_INDICIES | EJS_TYPE_VIRTUAL_SLOTS | EJS_TYPE_MUTABLE_INSTANCES)) == 0) {
        return;
    }
    type->helpers.getProperty    = (EjsGetPropertyHelper) getFileProperty;
    type->helpers.lookupProperty = (EjsLookupPropertyHelper) lookupFileProperty;
    type->helpers.setProperty    = (EjsSetPropertyHelper) setFileProperty;

    prototype = type->prototype;
    ejsBindConstructor(ejs, type, fileConstructor);
    ejsBindMethod(ejs, prototype, ES_File_canRead, canReadFile);
    ejsBindMethod(ejs, prototype, ES_File_canWrite, canWriteFile);
    ejsBindMethod(ejs, prototype, ES_File_close, closeFile);
    ejsBindMethod(ejs, prototype, ES_File_iterator_get, getFileIterator);
    ejsBindMethod(ejs, prototype, ES_File_iterator_getValues, getFileValues);
    ejsBindMethod(ejs, prototype, ES_File_isOpen, isFileOpen);
    ejsBindMethod(ejs, prototype, ES_File_open, openFile);
    ejsBindMethod(ejs, prototype, ES_File_options, getFileOptions);
    ejsBindMethod(ejs, prototype, ES_File_path, getFilePath);
    ejsBindAccess(ejs, prototype, ES_File_position, getFilePosition, setFilePosition);
    ejsBindMethod(ejs, prototype, ES_File_readBytes, readFileBytes);
    ejsBindMethod(ejs, prototype, ES_File_readString, readFileString);
    ejsBindMethod(ejs, prototype, ES_File_read, readFile);
    ejsBindMethod(ejs, prototype, ES_File_size, getFileSize);
    ejsBindMethod(ejs, prototype, ES_File_truncate, truncateFile);
    ejsBindMethod(ejs, prototype, ES_File_write, writeFile);
}
Exemplo n.º 29
0
PUBLIC void ejsConfigureAppType(Ejs *ejs)
{
    EjsType     *type;

    if ((type = ejsFinalizeScriptType(ejs, N("ejs", "App"), 0, 0, 0)) == 0) {
        return;
    }
    ejsSetProperty(ejs, type, ES_App__inputStream, ejsCreateFileFromFd(ejs, 0, "stdin", O_RDONLY));
    ejsSetProperty(ejs, type, ES_App__outputStream, ejsCreateFileFromFd(ejs, 1, "stdout", O_WRONLY));
    ejsSetProperty(ejs, type, ES_App__errorStream, ejsCreateFileFromFd(ejs, 2, "stderr", O_WRONLY));

    ejsBindMethod(ejs, type, ES_App_args, app_args);
    ejsBindMethod(ejs, type, ES_App_createSearch, app_createSearch);
    ejsBindMethod(ejs, type, ES_App_dir, app_dir);
    ejsBindMethod(ejs, type, ES_App_chdir, app_chdir);
    ejsBindMethod(ejs, type, ES_App_exeDir, app_exeDir);
    ejsBindMethod(ejs, type, ES_App_exePath, app_exePath);
    ejsBindMethod(ejs, type, ES_App_env, app_env);
    ejsBindMethod(ejs, type, ES_App_exit, app_exit);
    ejsBindMethod(ejs, type, ES_App_getenv, app_getenv);
    ejsBindMethod(ejs, type, ES_App_gid, app_gid);
    ejsBindMethod(ejs, type, ES_App_putenv, app_putenv);
    ejsBindMethod(ejs, type, ES_App_pid, app_pid);
    ejsBindMethod(ejs, type, ES_App_run, app_run);
    ejsBindAccess(ejs, type, ES_App_search, app_search, app_set_search);
    ejsBindMethod(ejs, type, ES_App_sleep, app_sleep);
    ejsBindMethod(ejs, type, ES_App_uid, app_uid);
    ejsBindMethod(ejs, type, ES_App_getpass, app_getpass);
}
Exemplo n.º 30
0
PUBLIC void ejsConfigureMathType(Ejs *ejs)
{
    EjsType     *type;

    if ((type = ejsFinalizeScriptType(ejs, N("ejs", "Math"), sizeof(EjsPot), ejsManagePot, EJS_TYPE_POT)) == 0) {
        return;
    }
    ejsBindMethod(ejs, type, ES_Math_abs, math_abs);
    ejsBindMethod(ejs, type, ES_Math_acos, math_acos);
    ejsBindMethod(ejs, type, ES_Math_asin, math_asin);
    ejsBindMethod(ejs, type, ES_Math_atan, math_atan);
    ejsBindMethod(ejs, type, ES_Math_atan2, math_atan2);
    ejsBindMethod(ejs, type, ES_Math_ceil, math_ceil);
    ejsBindMethod(ejs, type, ES_Math_cos, math_cos);
    ejsBindMethod(ejs, type, ES_Math_exp, math_exp);
    ejsBindMethod(ejs, type, ES_Math_floor, math_floor);
    ejsBindMethod(ejs, type, ES_Math_log, math_log);
    ejsBindMethod(ejs, type, ES_Math_log10, math_log10);
    ejsBindMethod(ejs, type, ES_Math_max, math_max);
    ejsBindMethod(ejs, type, ES_Math_min, math_min);
    ejsBindMethod(ejs, type, ES_Math_pow, math_pow);
    ejsBindMethod(ejs, type, ES_Math_random, math_random);
    ejsBindMethod(ejs, type, ES_Math_round, math_round);
    ejsBindMethod(ejs, type, ES_Math_sin, math_sin);
    ejsBindMethod(ejs, type, ES_Math_sqrt, math_sqrt);
    ejsBindMethod(ejs, type, ES_Math_tan, math_tan);
}