summaryrefslogtreecommitdiff
path: root/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystem.c
blob: e035e1c7408440277e6fad052bcc732a8ae03994 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 *	@file 	ejsSystem.c
 *	@brief 	System class for the EJS Object Model
 */
/********************************** Copyright *********************************/
/*
 *	Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved.
 */
/********************************** Includes **********************************/

#include	"ejs.h"

/******************************************************************************/
/************************************ Methods *********************************/
/******************************************************************************/
#if UNUSED
/*
 *	function int random()
 */

static int randomProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
{
	ejsTrace(ep, "random()\n");
	return 0;
}

/******************************************************************************/
/*
 *	function void yield()
 */

static int yieldProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
{
	ejsTrace(ep, "yield()\n");
	return 0;
}

/******************************************************************************/
/*
 *	function void sleep(int milliSeconds)
 */

static int sleepProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
{
	ejsTrace(ep, "sleep()\n");
	return 0;
}

#endif
/******************************************************************************/
/*
 *	function void exit(int status)
 *
 *	Exit the widget with the given status. All JavaScript processing ceases.
 */

static int exitProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv)
{
	int		status;

	status = 0;
	if ((argc == 1) && ejsVarIsInteger(argv[0])) {
		status = argv[0]->integer;
	}
	ejsExit(ep, status);
	return 0;
}

/******************************************************************************/
/******************************** Initialization ******************************/
/******************************************************************************/

int ejsDefineSystemClass(Ejs *ep)
{
	EjsVar	*systemClass;

	/*
	 *	We create the system class and define static methods on it.
	 *	NOTE: There is no object instance
	 */
	systemClass =  ejsDefineClass(ep, "System", "Object", 0);
	if (systemClass == 0) {
		return MPR_ERR_CANT_INITIALIZE;
	}

	ejsDefineCMethod(ep, systemClass, "exit", exitProc, EJS_NO_LOCAL);

#if UNUSED
	ejsDefineCMethod(ep, systemClass, "random", randomProc, EJS_NO_LOCAL);
	ejsDefineCMethod(ep, systemClass, "yield", yieldProc, EJS_NO_LOCAL);
	ejsDefineCMethod(ep, systemClass, "sleep", sleepProc, EJS_NO_LOCAL);

	/*
	 *	Define properties 
	 */
	ejsSetPropertyToString(systemClass, "name", "");
#endif

	return ejsObjHasErrors(systemClass) ? MPR_ERR_CANT_INITIALIZE : 0;
}

/******************************************************************************/

/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * End:
 * vim:tw=78
 * vim600: sw=4 ts=4 fdm=marker
 * vim<600: sw=4 ts=4
 */