Beispiel #1
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);
}
Beispiel #2
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);
}
Beispiel #3
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")));
}
Beispiel #4
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);
}
Beispiel #5
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);
}
Beispiel #6
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);
}
Beispiel #7
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
}
Beispiel #8
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);
}
Beispiel #9
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;
}
Beispiel #10
0
PUBLIC void ejsConfigureJSONType(Ejs *ejs)
{
    ejsFinalizeScriptType(ejs, N("ejs", "JSON"), sizeof(EjsPot), ejsManagePot, EJS_TYPE_POT);
    ejsBindFunction(ejs, ejs->global, ES_deserialize, g_deserialize);
    ejsBindFunction(ejs, ejs->global, ES_serialize, g_serialize);
}