3 * @brief System class for the EJS Object Model
5 /********************************** Copyright *********************************/
7 * Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved.
9 /********************************** Includes **********************************/
13 /******************************************************************************/
14 /************************************ Methods *********************************/
15 /******************************************************************************/
18 * function int random()
21 static int randomProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
23 ejsTrace(ep, "random()\n");
27 /******************************************************************************/
29 * function void yield()
32 static int yieldProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
34 ejsTrace(ep, "yield()\n");
38 /******************************************************************************/
40 * function void sleep(int milliSeconds)
43 static int sleepProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
45 ejsTrace(ep, "sleep()\n");
50 /******************************************************************************/
52 * function void exit(int status)
54 * Exit the widget with the given status. All JavaScript processing ceases.
57 static int exitProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
62 if ((argc == 1) && ejsVarIsInteger(argv[0])) {
63 status = argv[0]->integer;
69 /******************************************************************************/
70 /******************************** Initialization ******************************/
71 /******************************************************************************/
73 int ejsDefineSystemClass(Ejs *ep)
78 * We create the system class and define static methods on it.
79 * NOTE: There is no object instance
81 systemClass = ejsDefineClass(ep, "System", "Object", 0);
82 if (systemClass == 0) {
83 return MPR_ERR_CANT_INITIALIZE;
86 ejsDefineCMethod(ep, systemClass, "exit", exitProc, EJS_NO_LOCAL);
89 ejsDefineCMethod(ep, systemClass, "random", randomProc, EJS_NO_LOCAL);
90 ejsDefineCMethod(ep, systemClass, "yield", yieldProc, EJS_NO_LOCAL);
91 ejsDefineCMethod(ep, systemClass, "sleep", sleepProc, EJS_NO_LOCAL);
96 ejsSetPropertyToString(systemClass, "name", "");
99 return ejsObjHasErrors(systemClass) ? MPR_ERR_CANT_INITIALIZE : 0;
102 /******************************************************************************/
110 * vim600: sw=4 ts=4 fdm=marker