diff --git a/source/scripting/JSUtil.cpp b/source/scripting/JSUtil.cpp deleted file mode 100644 index bc7fb75d09..0000000000 --- a/source/scripting/JSUtil.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 2009 Wildfire Games. - * This file is part of 0 A.D. - * - * 0 A.D. is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * 0 A.D. is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with 0 A.D. If not, see . - */ - -#include "precompiled.h" - -#include "SpiderMonkey.h" - -JSBool jsu_report_param_error(JSContext* cx, jsval* vp) -{ - JS_ReportError(cx, "Invalid parameter(s) or count"); - - if (vp) - JS_SET_RVAL(cx, vp, JSVAL_NULL); - - // yes, we had an error, but returning JS_FALSE would cause SpiderMonkey - // to abort. that would be hard to debug. - return JS_TRUE; -} diff --git a/source/scripting/JSUtil.h b/source/scripting/JSUtil.h deleted file mode 100644 index 574b9a2f6f..0000000000 --- a/source/scripting/JSUtil.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (C) 2009 Wildfire Games. - * This file is part of 0 A.D. - * - * 0 A.D. is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * 0 A.D. is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with 0 A.D. If not, see . - */ - -// included from SpiderMonkey.h - -extern JSBool jsu_report_param_error(JSContext* cx, jsval* vp); - - -// consistent argc checking for normal function wrappers: reports an -// error via JS and returns if number of parameters is incorrect. -// .. require exact number (most common case) -#define JSU_REQUIRE_PARAMS(exact_number)\ - if(argc != exact_number)\ - return jsu_report_param_error(cx, vp); -// .. require 0 params (avoids L4 warning "unused argv param") -#define JSU_REQUIRE_NO_PARAMS()\ - if(argc != 0)\ - return jsu_report_param_error(cx, vp); -// .. require a certain range (e.g. due to optional params) -#define JSU_REQUIRE_PARAM_RANGE(min_number, max_number)\ - if(!(min_number <= argc && argc <= max_number))\ - return jsu_report_param_error(cx, vp); -// .. require at most a certain count -#define JSU_REQUIRE_MAX_PARAMS(max_number)\ - if(argc > max_number)\ - return jsu_report_param_error(cx, vp); -// .. require at least a certain count (rarely needed) -#define JSU_REQUIRE_MIN_PARAMS(min_number)\ - if(argc < min_number)\ - return jsu_report_param_error(cx, vp); - -// same as JSU_REQUIRE_PARAMS, but used from C++ functions that are -// a bit further removed from SpiderMonkey, i.e. return a -// C++ bool indicating success, and not taking an rval param. -#define JSU_REQUIRE_PARAMS_CPP(exact_number)\ - if(argc != exact_number)\ - {\ - jsu_report_param_error(cx, 0);\ - return false;\ - } - - -#define JSU_ASSERT(expr, msg)\ -STMT(\ - if(!(expr))\ - {\ - JS_ReportError(cx, msg);\ - return JS_FALSE;\ - }\ -) diff --git a/source/scripting/SpiderMonkey.h b/source/scripting/SpiderMonkey.h deleted file mode 100644 index ed9a0e839f..0000000000 --- a/source/scripting/SpiderMonkey.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2009 Wildfire Games. - * This file is part of 0 A.D. - * - * 0 A.D. is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * 0 A.D. is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with 0 A.D. If not, see . - */ - -#ifndef INCLUDED_SPIDERMONKEY -#define INCLUDED_SPIDERMONKEY - -// Master header for the SpiderMonkey Javascript library. -// -// Include this instead of accessing any headers directly. -// Rationale: they require an OS macro to be set (XP_*). -// Since this is specific to SpiderMonkey, we don't want to saddle -// another obscure header with it (would make reuse harder). -// Instead, do it here where the purpose is clear. -// -// This doesn't go in ScriptingHost.h because some other files -// (notably precompiled.h and i18n/ScriptInterface.cpp) want only these -// definitions without pulling in the whole of ScriptingHost. - -// (Actually that XP_* stuff is handled by the newer scriptinterface -// code instead; this file no longer does anything interesting) - -#include "scriptinterface/ScriptTypes.h" - -#include "JSUtil.h" - -// Make JS debugging a little easier by automatically naming GC roots -// Don't simply #define NAME_ALL_GC_ROOTS, because jsapi.h is horridly broken -#ifndef NDEBUG -# define JS_AddRoot(cx, rp) JS_AddNamedRoot((cx), (rp), __FILE__ ) -#endif - -#endif // INCLUDED_SPIDERMONKEY diff --git a/source/scriptinterface/ScriptTypes.h b/source/scriptinterface/ScriptTypes.h index a899e8a4b8..da03a1d268 100644 --- a/source/scriptinterface/ScriptTypes.h +++ b/source/scriptinterface/ScriptTypes.h @@ -58,8 +58,6 @@ #endif -#include // required by jsutil.h - // SpiderMonkey wants the DEBUG flag #ifndef NDEBUG # ifndef DEBUG