24 #include "precompiled.h"
87 const wchar_t* description = pos;
88 pos +=
swprintf_s(pos, 12, L
"js_timer %d", (
int)i)+1;
96 static const char* calibration_script =
100 g_ScriptingHost.RunMemScript(calibration_script, strlen(calibration_script));
104 g_ScriptingHost.RunMemScript(calibration_script, strlen(calibration_script));
105 js_timer_overhead = js_timer_clients[0].
sum;
114 size_t slot = ToPrimitive<size_t>(JS_ARGV(cx, vp)[0]);
120 JS_SET_RVAL(cx, vp, JSVAL_VOID);
128 size_t slot = ToPrimitive<size_t>(JS_ARGV(cx, vp)[0]);
136 js_start_times[slot].SetToZero();
138 JS_SET_RVAL(cx, vp, JSVAL_VOID);
150 JSBool
EndGame(JSContext* cx, uintN argc, jsval* vp)
156 JS_SET_RVAL(cx, vp, JSVAL_VOID);
170 JSBool
GetFps(JSContext* cx, uintN argc, jsval* vp)
176 JS_SET_RVAL(cx, vp, INT_TO_JSVAL(freq));
193 JS_SET_RVAL(cx, vp, JSVAL_VOID);
208 JS_SET_RVAL(cx, vp, JSVAL_VOID);
218 CStr name = ToPrimitive<CStr>(cx, JS_ARGV(cx, vp)[0]);
221 JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(guiObj->GetJSObject()));
223 JS_SET_RVAL(cx, vp, JSVAL_NULL);
257 const int mode = argc? JSVAL_TO_INT(JS_ARGV(cx, vp)[0]) : -1;
274 JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, buf)));
279 void DumpHeap(
const char* basename,
int idx, JSContext* cx)
286 JS_DumpHeap(cx, f, NULL, 0, NULL, (
size_t)-1, NULL);
306 debug_warn(L
"DumpHeaps only available in DEBUG mode");
309 JS_SET_RVAL(cx, vp, JSVAL_VOID);
316 JSBool
IsPaused(JSContext* cx, uintN argc, jsval* vp)
322 JS_ReportError(cx,
"Game is not started");
337 JS_ReportError(cx,
"Game is not started");
350 JS_ReportError(cx,
"Invalid parameter to SetPaused");
353 JS_SET_RVAL(cx, vp, JSVAL_VOID);
370 #define JS_FUNC(script_name, cpp_function, min_params) { script_name, cpp_function, min_params, 0 },
static TimerClient js_timer_clients[MAX_JS_TIMERS]
JSBool SetCursor(JSContext *cx, uintN argc, jsval *vp)
JSBool GetFps(JSContext *cx, uintN argc, jsval *vp)
#define JSU_REQUIRE_NO_PARAMS()
virtual void Pause(bool pauseIt)=0
const OsPath & psLogDir()
ISoundManager * g_SoundManager
TimerClient * timer_AddClient(TimerClient *tc, const wchar_t *description)
make the given TimerClient (usually instantiated as static data) ready for use.
bool ToPrimitive< bool >(JSContext *cx, jsval v, bool &Storage)
Base settings, all objects possess these settings in their m_BaseSettings Instructions can be found i...
JSBool DumpHeaps(JSContext *cx, uintN argc, jsval *vp)
int swprintf_s(wchar_t *buf, size_t max_chars, const wchar_t *fmt,...) WPRINTF_ARGS(3)
bill the difference between t0 and t1 to the client's total.
int sprintf_s(char *buf, size_t max_chars, const char *fmt,...) PRINTF_ARGS(3)
static TimerUnit js_start_times[MAX_JS_TIMERS]
FILE * sys_OpenFile(const OsPath &pathname, const char *mode)
open a file like with fopen (but taking an OsPath argument).
JSBool GetFileMTime(JSContext *cx, uintN argc, jsval *vp)
static TimerUnit js_timer_overhead
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
#define UNUSED2(param)
mark a function local variable or parameter as unused and avoid the corresponding compiler warning...
JSBool IsPaused(JSContext *cx, uintN argc, jsval *vp)
IGUIObject * FindObjectByName(const CStr &name) const
See CGUI::FindObjectByName; applies to the currently active page.
JSBool StartJsTimer(JSContext *cx, uintN argc, jsval *vp)
#define ONCE(ONCE_code__)
execute the code passed as a parameter only the first time this is reached.
bool m_Paused
the game is paused and no updates will be performed if true.
ScriptInterface & GetScriptInterface() const
CGame * g_Game
Globally accessible pointer to the CGame object.
static bool IsInitialised()
static void InitJsTimers()
#define JSU_REQUIRE_PARAMS(exact_number)
PIFrequencyFilter g_frequencyFilter
JSBool ExitProgram(JSContext *cx, uintN argc, jsval *vp)
CSimulation2 * GetSimulation2()
Get the pointer to the simulation2 object.
JSBool GetGUIObjectByName(JSContext *cx, uintN argc, jsval *vp)
JSFunctionSpec ScriptFunctionTable[]
JSBool ReadFile(JSContext *cx, uintN argc, jsval *vp)
JSBool StopJsTimer(JSContext *cx, uintN argc, jsval *vp)
static const size_t MAX_JS_TIMERS
JSBool GetBuildTimestamp(JSContext *cx, uintN argc, jsval *vp)
#define JSU_REQUIRE_MAX_PARAMS(max_number)
JSBool BuildDirEntList(JSContext *cx, uintN argc, jsval *vp)
JSBool SetPaused(JSContext *cx, uintN argc, jsval *vp)
void Subtract(TimerUnit t)
JSBool ReadFileLines(JSContext *cx, uintN argc, jsval *vp)
#define debug_warn(expr)
display the error dialog with the given text.
JSBool ArchiveBuilderCancel(JSContext *cx, uintN argc, jsval *vp)
static wchar_t js_timer_descriptions_buf[MAX_JS_TIMERS *12]
JSContext * GetContext() const
JSBool GetFileSize(JSContext *cx, uintN argc, jsval *vp)
#define JS_FUNC(script_name, cpp_function, min_params)