2025-02-05 12:40:54 +10:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2018-09-08 18:08:48 +08:00
|
|
|
*
|
|
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
|
*
|
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
|
*
|
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
|
* License.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Mozilla Communicator client code, released
|
|
|
|
|
* March 31, 1998.
|
|
|
|
|
*
|
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s):
|
|
|
|
|
*
|
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
|
*
|
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* JS atom table.
|
|
|
|
|
*/
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include "jstypes.h"
|
2025-02-05 12:40:54 +10:00
|
|
|
#include "jsstdint.h"
|
2025-03-19 21:25:58 +10:00
|
|
|
#include "jsutil.h"
|
|
|
|
|
#include "jshash.h"
|
2018-09-08 18:08:48 +08:00
|
|
|
#include "jsprf.h"
|
|
|
|
|
#include "jsapi.h"
|
|
|
|
|
#include "jsatom.h"
|
2025-02-05 12:40:54 +10:00
|
|
|
#include "jsbit.h"
|
2018-09-08 18:08:48 +08:00
|
|
|
#include "jscntxt.h"
|
|
|
|
|
#include "jsgc.h"
|
|
|
|
|
#include "jslock.h"
|
|
|
|
|
#include "jsnum.h"
|
2025-02-05 12:40:54 +10:00
|
|
|
#include "jsparse.h"
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
#include "jsscan.h"
|
2018-09-08 18:08:48 +08:00
|
|
|
#include "jsstr.h"
|
2025-02-05 12:40:54 +10:00
|
|
|
#include "jsversion.h"
|
2025-03-19 21:25:58 +10:00
|
|
|
#include "jsxml.h"
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
#include "jsstrinlines.h"
|
2025-03-19 21:25:58 +10:00
|
|
|
#include "jsatominlines.h"
|
|
|
|
|
#include "jsobjinlines.h"
|
2025-02-05 12:40:54 +10:00
|
|
|
|
|
|
|
|
using namespace js;
|
2025-03-19 21:25:58 +10:00
|
|
|
using namespace js::gc;
|
2025-02-05 12:40:54 +10:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ATOM_HASH assumes that JSHashNumber is 32-bit even on 64-bit systems.
|
|
|
|
|
*/
|
|
|
|
|
JS_STATIC_ASSERT(sizeof(JSHashNumber) == 4);
|
|
|
|
|
JS_STATIC_ASSERT(sizeof(JSAtom *) == JS_BYTES_PER_WORD);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Start and limit offsets for atom pointers in JSAtomState must be aligned
|
|
|
|
|
* on the word boundary.
|
|
|
|
|
*/
|
|
|
|
|
JS_STATIC_ASSERT(ATOM_OFFSET_START % sizeof(JSAtom *) == 0);
|
|
|
|
|
JS_STATIC_ASSERT(ATOM_OFFSET_LIMIT % sizeof(JSAtom *) == 0);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* JS_BOOLEAN_STR and JS_TYPE_STR assume that boolean names starts from the
|
|
|
|
|
* index 1 and type name starts from the index 1+2 atoms in JSAtomState.
|
|
|
|
|
*/
|
|
|
|
|
JS_STATIC_ASSERT(1 * sizeof(JSAtom *) ==
|
|
|
|
|
offsetof(JSAtomState, booleanAtoms) - ATOM_OFFSET_START);
|
|
|
|
|
JS_STATIC_ASSERT((1 + 2) * sizeof(JSAtom *) ==
|
|
|
|
|
offsetof(JSAtomState, typeAtoms) - ATOM_OFFSET_START);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
const char *
|
2025-03-19 21:25:58 +10:00
|
|
|
js_AtomToPrintableString(JSContext *cx, JSAtom *atom, JSAutoByteString *bytes)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
return js_ValueToPrintable(cx, StringValue(ATOM_TO_STRING(atom)), bytes);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
#define JS_PROTO(name,code,init) const char js_##name##_str[] = #name;
|
|
|
|
|
#include "jsproto.tbl"
|
|
|
|
|
#undef JS_PROTO
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/*
|
2025-02-05 12:40:54 +10:00
|
|
|
* String constants for common atoms defined in JSAtomState starting from
|
2023-07-12 13:27:26 +10:00
|
|
|
* JSAtomState.emptyAtom until JSAtomState.lazy.
|
|
|
|
|
*
|
|
|
|
|
* The elements of the array after the first empty string define strings
|
2025-02-05 12:40:54 +10:00
|
|
|
* corresponding to the two boolean literals, false and true, followed by the
|
|
|
|
|
* JSType enumerators from jspubtd.h starting with "undefined" for JSTYPE_VOID
|
|
|
|
|
* (which is special-value 2) and continuing as initialized below. The static
|
|
|
|
|
* asserts check these relations.
|
2023-07-12 13:27:26 +10:00
|
|
|
*/
|
|
|
|
|
JS_STATIC_ASSERT(JSTYPE_LIMIT == 8);
|
2025-02-05 12:40:54 +10:00
|
|
|
JS_STATIC_ASSERT(JSTYPE_VOID == 0);
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
const char *const js_common_atom_names[] = {
|
|
|
|
|
"", /* emptyAtom */
|
2025-02-05 12:40:54 +10:00
|
|
|
js_false_str, /* booleanAtoms[0] */
|
|
|
|
|
js_true_str, /* booleanAtoms[1] */
|
2023-07-12 13:27:26 +10:00
|
|
|
js_undefined_str, /* typeAtoms[JSTYPE_VOID] */
|
|
|
|
|
js_object_str, /* typeAtoms[JSTYPE_OBJECT] */
|
|
|
|
|
js_function_str, /* typeAtoms[JSTYPE_FUNCTION] */
|
|
|
|
|
"string", /* typeAtoms[JSTYPE_STRING] */
|
|
|
|
|
"number", /* typeAtoms[JSTYPE_NUMBER] */
|
|
|
|
|
"boolean", /* typeAtoms[JSTYPE_BOOLEAN] */
|
|
|
|
|
js_null_str, /* typeAtoms[JSTYPE_NULL] */
|
|
|
|
|
"xml", /* typeAtoms[JSTYPE_XML] */
|
|
|
|
|
js_null_str, /* nullAtom */
|
|
|
|
|
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
#define JS_PROTO(name,code,init) js_##name##_str,
|
|
|
|
|
#include "jsproto.tbl"
|
|
|
|
|
#undef JS_PROTO
|
2023-07-12 13:27:26 +10:00
|
|
|
|
|
|
|
|
js_anonymous_str, /* anonymousAtom */
|
2025-02-05 12:40:54 +10:00
|
|
|
js_apply_str, /* applyAtom */
|
2023-07-12 13:27:26 +10:00
|
|
|
js_arguments_str, /* argumentsAtom */
|
|
|
|
|
js_arity_str, /* arityAtom */
|
2025-02-05 12:40:54 +10:00
|
|
|
js_call_str, /* callAtom */
|
2023-07-12 13:27:26 +10:00
|
|
|
js_callee_str, /* calleeAtom */
|
|
|
|
|
js_caller_str, /* callerAtom */
|
|
|
|
|
js_class_prototype_str, /* classPrototypeAtom */
|
|
|
|
|
js_constructor_str, /* constructorAtom */
|
|
|
|
|
js_each_str, /* eachAtom */
|
|
|
|
|
js_eval_str, /* evalAtom */
|
|
|
|
|
js_fileName_str, /* fileNameAtom */
|
|
|
|
|
js_get_str, /* getAtom */
|
2025-03-19 21:25:58 +10:00
|
|
|
js_global_str, /* globalAtom */
|
|
|
|
|
js_ignoreCase_str, /* ignoreCaseAtom */
|
2023-07-12 13:27:26 +10:00
|
|
|
js_index_str, /* indexAtom */
|
|
|
|
|
js_input_str, /* inputAtom */
|
2025-03-19 21:25:58 +10:00
|
|
|
"toISOString", /* toISOStringAtom */
|
2023-07-12 13:27:26 +10:00
|
|
|
js_iterator_str, /* iteratorAtom */
|
2025-03-19 21:25:58 +10:00
|
|
|
js_join_str, /* joinAtom */
|
|
|
|
|
js_lastIndex_str, /* lastIndexAtom */
|
2023-07-12 13:27:26 +10:00
|
|
|
js_length_str, /* lengthAtom */
|
|
|
|
|
js_lineNumber_str, /* lineNumberAtom */
|
|
|
|
|
js_message_str, /* messageAtom */
|
2025-03-19 21:25:58 +10:00
|
|
|
js_multiline_str, /* multilineAtom */
|
2023-07-12 13:27:26 +10:00
|
|
|
js_name_str, /* nameAtom */
|
|
|
|
|
js_next_str, /* nextAtom */
|
|
|
|
|
js_noSuchMethod_str, /* noSuchMethodAtom */
|
2025-03-19 21:25:58 +10:00
|
|
|
"[object Null]", /* objectNullAtom */
|
|
|
|
|
"[object Undefined]", /* objectUndefinedAtom */
|
2023-07-12 13:27:26 +10:00
|
|
|
js_proto_str, /* protoAtom */
|
|
|
|
|
js_set_str, /* setAtom */
|
2025-03-19 21:25:58 +10:00
|
|
|
js_source_str, /* sourceAtom */
|
2023-07-12 13:27:26 +10:00
|
|
|
js_stack_str, /* stackAtom */
|
2025-03-19 21:25:58 +10:00
|
|
|
js_sticky_str, /* stickyAtom */
|
|
|
|
|
js_toGMTString_str, /* toGMTStringAtom */
|
2023-07-12 13:27:26 +10:00
|
|
|
js_toLocaleString_str, /* toLocaleStringAtom */
|
|
|
|
|
js_toSource_str, /* toSourceAtom */
|
|
|
|
|
js_toString_str, /* toStringAtom */
|
2025-03-19 21:25:58 +10:00
|
|
|
js_toUTCString_str, /* toUTCStringAtom */
|
2023-07-12 13:27:26 +10:00
|
|
|
js_valueOf_str, /* valueOfAtom */
|
2025-02-03 12:35:24 +10:00
|
|
|
js_toJSON_str, /* toJSONAtom */
|
2023-07-12 13:27:26 +10:00
|
|
|
"(void 0)", /* void0Atom */
|
2025-02-05 12:40:54 +10:00
|
|
|
js_enumerable_str, /* enumerableAtom */
|
|
|
|
|
js_configurable_str, /* configurableAtom */
|
|
|
|
|
js_writable_str, /* writableAtom */
|
|
|
|
|
js_value_str, /* valueAtom */
|
2025-03-19 21:25:58 +10:00
|
|
|
js_test_str, /* testAtom */
|
2025-02-05 12:40:54 +10:00
|
|
|
"use strict", /* useStrictAtom */
|
2025-03-19 21:25:58 +10:00
|
|
|
"loc", /* locAtom */
|
|
|
|
|
"line", /* lineAtom */
|
|
|
|
|
"Infinity", /* InfinityAtom */
|
|
|
|
|
"NaN", /* NaNAtom */
|
|
|
|
|
"builder", /* builderAtom */
|
2023-07-12 13:27:26 +10:00
|
|
|
|
|
|
|
|
#if JS_HAS_XML_SUPPORT
|
|
|
|
|
js_etago_str, /* etagoAtom */
|
|
|
|
|
js_namespace_str, /* namespaceAtom */
|
|
|
|
|
js_ptagc_str, /* ptagcAtom */
|
|
|
|
|
js_qualifier_str, /* qualifierAtom */
|
|
|
|
|
js_space_str, /* spaceAtom */
|
|
|
|
|
js_stago_str, /* stagoAtom */
|
|
|
|
|
js_star_str, /* starAtom */
|
|
|
|
|
js_starQualifier_str, /* starQualifierAtom */
|
|
|
|
|
js_tagc_str, /* tagcAtom */
|
|
|
|
|
js_xml_str, /* xmlAtom */
|
2025-03-19 21:25:58 +10:00
|
|
|
"@mozilla.org/js/function", /* functionNamespaceURIAtom */
|
2023-07-12 13:27:26 +10:00
|
|
|
#endif
|
2025-02-05 12:40:54 +10:00
|
|
|
|
|
|
|
|
"Proxy", /* ProxyAtom */
|
|
|
|
|
|
|
|
|
|
"getOwnPropertyDescriptor", /* getOwnPropertyDescriptorAtom */
|
|
|
|
|
"getPropertyDescriptor", /* getPropertyDescriptorAtom */
|
|
|
|
|
"defineProperty", /* definePropertyAtom */
|
|
|
|
|
"delete", /* deleteAtom */
|
|
|
|
|
"getOwnPropertyNames", /* getOwnPropertyNames */
|
|
|
|
|
"enumerate", /* enumerateAtom */
|
|
|
|
|
"fix", /* fixAtom */
|
|
|
|
|
|
|
|
|
|
"has", /* hasAtom */
|
|
|
|
|
"hasOwn", /* hasOwnAtom */
|
2025-03-19 21:25:58 +10:00
|
|
|
"keys", /* keysAtom */
|
2025-02-05 12:40:54 +10:00
|
|
|
"iterate" /* iterateAtom */
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
};
|
2025-02-05 12:40:54 +10:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
JS_STATIC_ASSERT(JS_ARRAY_LENGTH(js_common_atom_names) * sizeof(JSAtom *) ==
|
|
|
|
|
LAZY_ATOM_OFFSET_START - ATOM_OFFSET_START);
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
/*
|
|
|
|
|
* Interpreter macros called by the trace recorder assume common atom indexes
|
|
|
|
|
* fit in one byte of immediate operand.
|
|
|
|
|
*/
|
|
|
|
|
JS_STATIC_ASSERT(JS_ARRAY_LENGTH(js_common_atom_names) < 256);
|
|
|
|
|
|
|
|
|
|
const size_t js_common_atom_count = JS_ARRAY_LENGTH(js_common_atom_names);
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
const char js_anonymous_str[] = "anonymous";
|
2025-02-05 12:40:54 +10:00
|
|
|
const char js_apply_str[] = "apply";
|
2018-09-08 18:08:48 +08:00
|
|
|
const char js_arguments_str[] = "arguments";
|
|
|
|
|
const char js_arity_str[] = "arity";
|
2025-02-05 12:40:54 +10:00
|
|
|
const char js_call_str[] = "call";
|
2018-09-08 18:08:48 +08:00
|
|
|
const char js_callee_str[] = "callee";
|
|
|
|
|
const char js_caller_str[] = "caller";
|
|
|
|
|
const char js_class_prototype_str[] = "prototype";
|
|
|
|
|
const char js_constructor_str[] = "constructor";
|
|
|
|
|
const char js_each_str[] = "each";
|
|
|
|
|
const char js_eval_str[] = "eval";
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
const char js_fileName_str[] = "fileName";
|
2018-09-08 18:08:48 +08:00
|
|
|
const char js_get_str[] = "get";
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
const char js_getter_str[] = "getter";
|
2025-03-19 21:25:58 +10:00
|
|
|
const char js_global_str[] = "global";
|
|
|
|
|
const char js_ignoreCase_str[] = "ignoreCase";
|
2018-09-08 18:08:48 +08:00
|
|
|
const char js_index_str[] = "index";
|
|
|
|
|
const char js_input_str[] = "input";
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
const char js_iterator_str[] = "__iterator__";
|
2025-03-19 21:25:58 +10:00
|
|
|
const char js_join_str[] = "join";
|
|
|
|
|
const char js_lastIndex_str[] = "lastIndex";
|
2018-09-08 18:08:48 +08:00
|
|
|
const char js_length_str[] = "length";
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
const char js_lineNumber_str[] = "lineNumber";
|
|
|
|
|
const char js_message_str[] = "message";
|
2025-03-19 21:25:58 +10:00
|
|
|
const char js_multiline_str[] = "multiline";
|
2018-09-08 18:08:48 +08:00
|
|
|
const char js_name_str[] = "name";
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
const char js_next_str[] = "next";
|
2018-09-08 18:08:48 +08:00
|
|
|
const char js_noSuchMethod_str[] = "__noSuchMethod__";
|
|
|
|
|
const char js_object_str[] = "object";
|
|
|
|
|
const char js_proto_str[] = "__proto__";
|
|
|
|
|
const char js_setter_str[] = "setter";
|
|
|
|
|
const char js_set_str[] = "set";
|
2025-03-19 21:25:58 +10:00
|
|
|
const char js_source_str[] = "source";
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
const char js_stack_str[] = "stack";
|
2025-03-19 21:25:58 +10:00
|
|
|
const char js_sticky_str[] = "sticky";
|
|
|
|
|
const char js_toGMTString_str[] = "toGMTString";
|
|
|
|
|
const char js_toLocaleString_str[] = "toLocaleString";
|
2018-09-08 18:08:48 +08:00
|
|
|
const char js_toSource_str[] = "toSource";
|
|
|
|
|
const char js_toString_str[] = "toString";
|
2025-03-19 21:25:58 +10:00
|
|
|
const char js_toUTCString_str[] = "toUTCString";
|
2023-07-12 13:27:26 +10:00
|
|
|
const char js_undefined_str[] = "undefined";
|
2018-09-08 18:08:48 +08:00
|
|
|
const char js_valueOf_str[] = "valueOf";
|
2025-02-03 12:35:24 +10:00
|
|
|
const char js_toJSON_str[] = "toJSON";
|
2025-02-05 12:40:54 +10:00
|
|
|
const char js_enumerable_str[] = "enumerable";
|
|
|
|
|
const char js_configurable_str[] = "configurable";
|
|
|
|
|
const char js_writable_str[] = "writable";
|
|
|
|
|
const char js_value_str[] = "value";
|
2025-03-19 21:25:58 +10:00
|
|
|
const char js_test_str[] = "test";
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
#if JS_HAS_XML_SUPPORT
|
|
|
|
|
const char js_etago_str[] = "</";
|
|
|
|
|
const char js_namespace_str[] = "namespace";
|
|
|
|
|
const char js_ptagc_str[] = "/>";
|
|
|
|
|
const char js_qualifier_str[] = "::";
|
|
|
|
|
const char js_space_str[] = " ";
|
|
|
|
|
const char js_stago_str[] = "<";
|
|
|
|
|
const char js_star_str[] = "*";
|
|
|
|
|
const char js_starQualifier_str[] = "*::";
|
|
|
|
|
const char js_tagc_str[] = ">";
|
|
|
|
|
const char js_xml_str[] = "xml";
|
|
|
|
|
#endif
|
|
|
|
|
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
#if JS_HAS_GENERATORS
|
|
|
|
|
const char js_close_str[] = "close";
|
|
|
|
|
const char js_send_str[] = "send";
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/*
|
|
|
|
|
* Helper macros to access and modify JSAtomHashEntry.
|
|
|
|
|
*/
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
inline AtomEntryType
|
|
|
|
|
StringToInitialAtomEntry(JSString *str)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
return (AtomEntryType) str;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
inline uintN
|
|
|
|
|
AtomEntryFlags(AtomEntryType entry)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
return (uintN) (entry & ATOM_ENTRY_FLAG_MASK);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
/*
|
|
|
|
|
* Conceptually, we have compressed a HashMap<JSAtom *, uint> into a
|
|
|
|
|
* HashMap<size_t>. Here, we promise that we are only changing the "value" of
|
|
|
|
|
* the HashMap entry, so the const_cast is safe.
|
|
|
|
|
*/
|
2023-07-12 13:27:26 +10:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
inline void
|
|
|
|
|
AddAtomEntryFlags(const AtomEntryType &entry, uintN flags)
|
|
|
|
|
{
|
|
|
|
|
const_cast<AtomEntryType &>(entry) |= AtomEntryType(flags);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
inline void
|
|
|
|
|
ClearAtomEntryFlags(const AtomEntryType &entry, uintN flags)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
const_cast<AtomEntryType &>(entry) &= ~AtomEntryType(flags);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/*
|
|
|
|
|
* For a browser build from 2007-08-09 after the browser starts up there are
|
|
|
|
|
* just 55 double atoms, but over 15000 string atoms. Not to penalize more
|
|
|
|
|
* economical embeddings allocating too much memory initially we initialize
|
|
|
|
|
* atomized strings with just 1K entries.
|
|
|
|
|
*/
|
|
|
|
|
#define JS_STRING_HASH_COUNT 1024
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
js_InitAtomState(JSRuntime *rt)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSAtomState *state = &rt->atomState;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_ASSERT(!state->atoms.initialized());
|
|
|
|
|
if (!state->atoms.init(JS_STRING_HASH_COUNT))
|
|
|
|
|
return false;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
#ifdef JS_THREADSAFE
|
|
|
|
|
js_InitLock(&state->lock);
|
|
|
|
|
#endif
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_ASSERT(state->atoms.initialized());
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2023-07-12 13:27:26 +10:00
|
|
|
js_FinishAtomState(JSRuntime *rt)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSAtomState *state = &rt->atomState;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!state->atoms.initialized()) {
|
2023-07-12 13:27:26 +10:00
|
|
|
/*
|
|
|
|
|
* We are called with uninitialized state when JS_NewRuntime fails and
|
|
|
|
|
* calls JS_DestroyRuntime on a partially initialized runtime.
|
|
|
|
|
*/
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
for (AtomSet::Range r = state->atoms.all(); !r.empty(); r.popFront()) {
|
|
|
|
|
JSString *str = AtomEntryToKey(r.front());
|
|
|
|
|
js_FinalizeStringRT(rt, str);
|
|
|
|
|
}
|
2023-07-12 13:27:26 +10:00
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
#ifdef JS_THREADSAFE
|
|
|
|
|
js_FinishLock(&state->lock);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
JSBool
|
|
|
|
|
js_InitCommonAtoms(JSContext *cx)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSAtomState *state = &cx->runtime->atomState;
|
|
|
|
|
uintN i;
|
|
|
|
|
JSAtom **atoms;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
atoms = COMMON_ATOMS_START(state);
|
|
|
|
|
for (i = 0; i < JS_ARRAY_LENGTH(js_common_atom_names); i++, atoms++) {
|
|
|
|
|
*atoms = js_Atomize(cx, js_common_atom_names[i],
|
|
|
|
|
strlen(js_common_atom_names[i]), ATOM_PINNED);
|
|
|
|
|
if (!*atoms)
|
|
|
|
|
return JS_FALSE;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2023-07-12 13:27:26 +10:00
|
|
|
JS_ASSERT((uint8 *)atoms - (uint8 *)state == LAZY_ATOM_OFFSET_START);
|
|
|
|
|
memset(atoms, 0, ATOM_OFFSET_LIMIT - LAZY_ATOM_OFFSET_START);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
cx->runtime->emptyString = ATOM_TO_STRING(state->emptyAtom);
|
2023-07-12 13:27:26 +10:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
void
|
2023-07-12 13:27:26 +10:00
|
|
|
js_FinishCommonAtoms(JSContext *cx)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
cx->runtime->emptyString = NULL;
|
2023-07-12 13:27:26 +10:00
|
|
|
JSAtomState *state = &cx->runtime->atomState;
|
2025-03-19 21:25:58 +10:00
|
|
|
|
|
|
|
|
for (AtomSet::Range r = state->atoms.all(); !r.empty(); r.popFront())
|
|
|
|
|
ClearAtomEntryFlags(r.front(), ATOM_PINNED);
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
#ifdef DEBUG
|
|
|
|
|
memset(COMMON_ATOMS_START(state), JS_FREE_PATTERN,
|
|
|
|
|
ATOM_OFFSET_LIMIT - ATOM_OFFSET_START);
|
|
|
|
|
#endif
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2025-02-05 12:40:54 +10:00
|
|
|
js_TraceAtomState(JSTracer *trc)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
JSRuntime *rt = trc->context->runtime;
|
|
|
|
|
JSAtomState *state = &rt->atomState;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
#ifdef DEBUG
|
|
|
|
|
size_t number = 0;
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
if (rt->gcKeepAtoms) {
|
2025-03-19 21:25:58 +10:00
|
|
|
for (AtomSet::Range r = state->atoms.all(); !r.empty(); r.popFront()) {
|
|
|
|
|
JS_SET_TRACING_INDEX(trc, "locked_atom", number++);
|
|
|
|
|
MarkString(trc, AtomEntryToKey(r.front()));
|
|
|
|
|
}
|
2023-07-12 13:27:26 +10:00
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
for (AtomSet::Range r = state->atoms.all(); !r.empty(); r.popFront()) {
|
|
|
|
|
AtomEntryType entry = r.front();
|
|
|
|
|
uintN flags = AtomEntryFlags(entry);
|
|
|
|
|
if (flags & (ATOM_PINNED | ATOM_INTERNED)) {
|
|
|
|
|
JS_SET_TRACING_INDEX(trc,
|
|
|
|
|
flags & ATOM_PINNED
|
|
|
|
|
? "pinned_atom"
|
|
|
|
|
: "interned_atom",
|
|
|
|
|
number++);
|
|
|
|
|
MarkString(trc, AtomEntryToKey(entry));
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-12 13:27:26 +10:00
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
void
|
|
|
|
|
js_SweepAtomState(JSContext *cx)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSAtomState *state = &cx->runtime->atomState;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
for (AtomSet::Enum e(state->atoms); !e.empty(); e.popFront()) {
|
|
|
|
|
AtomEntryType entry = e.front();
|
|
|
|
|
if (AtomEntryFlags(entry) & (ATOM_PINNED | ATOM_INTERNED)) {
|
|
|
|
|
/* Pinned or interned key cannot be finalized. */
|
|
|
|
|
JS_ASSERT(!IsAboutToBeFinalized(cx, AtomEntryToKey(entry)));
|
|
|
|
|
} else if (IsAboutToBeFinalized(cx, AtomEntryToKey(entry))) {
|
|
|
|
|
e.removeFront();
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
2023-07-12 13:27:26 +10:00
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
JSAtom *
|
2025-03-19 21:25:58 +10:00
|
|
|
js_AtomizeString(JSContext *cx, JSString *strArg, uintN flags)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JS_ASSERT(!(flags & ~(ATOM_PINNED|ATOM_INTERNED|ATOM_TMPSTR|ATOM_NOCOPY)));
|
|
|
|
|
JS_ASSERT_IF(flags & ATOM_NOCOPY, flags & ATOM_TMPSTR);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (strArg->isAtomized())
|
|
|
|
|
return STRING_TO_ATOM(strArg);
|
|
|
|
|
|
|
|
|
|
JSLinearString *str = strArg->ensureLinear(cx);
|
|
|
|
|
if (!str)
|
|
|
|
|
return NULL;
|
2025-02-05 12:40:54 +10:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
const jschar *chars = str->chars();
|
2025-02-05 12:40:54 +10:00
|
|
|
size_t length = str->length();
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JSString *staticStr = JSString::lookupStaticString(chars, length);
|
|
|
|
|
if (staticStr)
|
|
|
|
|
return STRING_TO_ATOM(staticStr);
|
2025-02-05 12:40:54 +10:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JSAtomState *state = &cx->runtime->atomState;
|
|
|
|
|
AtomSet &atoms = state->atoms;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
AutoLockAtomsCompartment lock(cx);
|
|
|
|
|
AtomSet::AddPtr p = atoms.lookupForAdd(str);
|
|
|
|
|
|
|
|
|
|
/* Hashing the string should have flattened it if it was a rope. */
|
|
|
|
|
JS_ASSERT(str->isFlat() || str->isDependent());
|
|
|
|
|
|
|
|
|
|
JSLinearString *key;
|
|
|
|
|
if (p) {
|
|
|
|
|
key = AtomEntryToKey(*p);
|
2023-07-12 13:27:26 +10:00
|
|
|
} else {
|
|
|
|
|
/*
|
2025-03-19 21:25:58 +10:00
|
|
|
* Ensure that any atomized string lives only in the default
|
|
|
|
|
* compartment.
|
2023-07-12 13:27:26 +10:00
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
bool needNewString = !!(flags & ATOM_TMPSTR) ||
|
|
|
|
|
str->asCell()->compartment() != cx->runtime->atomsCompartment;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Unless str is already comes from the default compartment and flat,
|
|
|
|
|
* we have to relookup the key as the last ditch GC invoked from the
|
|
|
|
|
* string allocation or OOM handling may unlock the default
|
|
|
|
|
* compartment lock.
|
|
|
|
|
*/
|
|
|
|
|
if (!needNewString && str->isFlat()) {
|
|
|
|
|
str->flatClearExtensible();
|
2023-07-12 13:27:26 +10:00
|
|
|
key = str;
|
2025-03-19 21:25:58 +10:00
|
|
|
atoms.add(p, StringToInitialAtomEntry(key));
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (needNewString) {
|
|
|
|
|
SwitchToCompartment sc(cx, cx->runtime->atomsCompartment);
|
2023-07-12 13:27:26 +10:00
|
|
|
if (flags & ATOM_NOCOPY) {
|
2025-03-19 21:25:58 +10:00
|
|
|
key = js_NewString(cx, const_cast<jschar *>(str->flatChars()), length);
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!key)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* Finish handing off chars to the GC'ed key string. */
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_ASSERT(flags & ATOM_TMPSTR);
|
|
|
|
|
str->u.chars = NULL;
|
2023-07-12 13:27:26 +10:00
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
key = js_NewStringCopyN(cx, chars, length);
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!key)
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
} else {
|
|
|
|
|
JS_ASSERT(str->isDependent());
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!str->undepend(cx))
|
2023-07-12 13:27:26 +10:00
|
|
|
return NULL;
|
|
|
|
|
key = str;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!atoms.relookupOrAdd(p, key, StringToInitialAtomEntry(key))) {
|
|
|
|
|
JS_ReportOutOfMemory(cx); /* SystemAllocPolicy does not report */
|
|
|
|
|
return NULL;
|
2023-07-12 13:27:26 +10:00
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
key->flatSetAtomized();
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
AddAtomEntryFlags(*p, flags & (ATOM_PINNED | ATOM_INTERNED));
|
2023-07-12 13:27:26 +10:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JSAtom *atom = STRING_TO_ATOM(key);
|
|
|
|
|
return atom;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
JSAtom *
|
2018-09-08 18:08:48 +08:00
|
|
|
js_Atomize(JSContext *cx, const char *bytes, size_t length, uintN flags)
|
|
|
|
|
{
|
|
|
|
|
jschar *chars;
|
2023-07-12 13:27:26 +10:00
|
|
|
JSString str;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSAtom *atom;
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
CHECK_REQUEST(cx);
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
/*
|
|
|
|
|
* Avoiding the malloc in js_InflateString on shorter strings saves us
|
|
|
|
|
* over 20,000 malloc calls on mozilla browser startup. This compares to
|
|
|
|
|
* only 131 calls where the string is longer than a 31 char (net) buffer.
|
|
|
|
|
* The vast majority of atomized strings are already in the hashtable. So
|
|
|
|
|
* js_AtomizeString rarely has to copy the temp string we make.
|
|
|
|
|
*/
|
|
|
|
|
#define ATOMIZE_BUF_MAX 32
|
|
|
|
|
jschar inflated[ATOMIZE_BUF_MAX];
|
|
|
|
|
size_t inflatedLength = ATOMIZE_BUF_MAX - 1;
|
|
|
|
|
|
|
|
|
|
if (length < ATOMIZE_BUF_MAX) {
|
|
|
|
|
js_InflateStringToBuffer(cx, bytes, length, inflated, &inflatedLength);
|
|
|
|
|
inflated[inflatedLength] = 0;
|
|
|
|
|
chars = inflated;
|
|
|
|
|
} else {
|
|
|
|
|
inflatedLength = length;
|
|
|
|
|
chars = js_InflateString(cx, bytes, &inflatedLength);
|
|
|
|
|
if (!chars)
|
|
|
|
|
return NULL;
|
|
|
|
|
flags |= ATOM_NOCOPY;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
str.initFlat(chars, inflatedLength);
|
2023-07-12 13:27:26 +10:00
|
|
|
atom = js_AtomizeString(cx, &str, ATOM_TMPSTR | flags);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (chars != inflated && str.flatChars())
|
|
|
|
|
cx->free(chars);
|
2018-09-08 18:08:48 +08:00
|
|
|
return atom;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
JSAtom *
|
2018-09-08 18:08:48 +08:00
|
|
|
js_AtomizeChars(JSContext *cx, const jschar *chars, size_t length, uintN flags)
|
|
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSString str;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
CHECK_REQUEST(cx);
|
2025-03-19 21:25:58 +10:00
|
|
|
|
|
|
|
|
if (!CheckStringLength(cx, length))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
str.initFlatNotTerminated((jschar *)chars, length);
|
2023-07-12 13:27:26 +10:00
|
|
|
return js_AtomizeString(cx, &str, ATOM_TMPSTR | flags);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
JSAtom *
|
|
|
|
|
js_GetExistingStringAtom(JSContext *cx, const jschar *chars, size_t length)
|
|
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSString str, *str2;
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
JSAtomState *state;
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
if (length == 1) {
|
|
|
|
|
jschar c = *chars;
|
|
|
|
|
if (c < UNIT_STRING_LIMIT)
|
2025-03-19 21:25:58 +10:00
|
|
|
return STRING_TO_ATOM(JSString::unitString(c));
|
2025-02-05 12:40:54 +10:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
str.initFlatNotTerminated((jschar *)chars, length);
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
state = &cx->runtime->atomState;
|
2023-07-12 13:27:26 +10:00
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
JS_LOCK(cx, &state->lock);
|
2025-03-19 21:25:58 +10:00
|
|
|
AtomSet::Ptr p = state->atoms.lookup(str.assertIsFlat());
|
|
|
|
|
str2 = p ? AtomEntryToKey(*p) : NULL;
|
2025-02-03 12:35:24 +10:00
|
|
|
JS_UNLOCK(cx, &state->lock);
|
2023-07-12 13:27:26 +10:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
return str2 ? STRING_TO_ATOM(str2) : NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
#ifdef DEBUG
|
|
|
|
|
JS_FRIEND_API(void)
|
|
|
|
|
js_DumpAtoms(JSContext *cx, FILE *fp)
|
|
|
|
|
{
|
|
|
|
|
JSAtomState *state = &cx->runtime->atomState;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
fprintf(fp, "atoms table contents:\n");
|
|
|
|
|
unsigned number = 0;
|
|
|
|
|
for (AtomSet::Range r = state->atoms.all(); !r.empty(); r.popFront()) {
|
|
|
|
|
AtomEntryType entry = r.front();
|
|
|
|
|
fprintf(fp, "%3u ", number++);
|
|
|
|
|
if (entry == 0) {
|
|
|
|
|
fputs("<uninitialized>", fp);
|
|
|
|
|
} else {
|
|
|
|
|
JSAtom *key = AtomEntryToKey(entry);
|
|
|
|
|
FileEscapedString(fp, key, '"');
|
|
|
|
|
uintN flags = AtomEntryFlags(entry);
|
|
|
|
|
if (flags != 0) {
|
|
|
|
|
fputs((flags & (ATOM_PINNED | ATOM_INTERNED))
|
|
|
|
|
? " pinned | interned"
|
|
|
|
|
: (flags & ATOM_PINNED) ? " pinned" : " interned",
|
|
|
|
|
fp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
putc('\n', fp);
|
|
|
|
|
}
|
2023-07-12 13:27:26 +10:00
|
|
|
putc('\n', fp);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
static JSHashNumber
|
2018-09-08 18:08:48 +08:00
|
|
|
js_hash_atom_ptr(const void *key)
|
|
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
const JSAtom *atom = (const JSAtom *) key;
|
|
|
|
|
return ATOM_HASH(atom);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
#if JS_BITS_PER_WORD == 32
|
|
|
|
|
# define TEMP_SIZE_START_LOG2 5
|
|
|
|
|
#else
|
|
|
|
|
# define TEMP_SIZE_START_LOG2 6
|
|
|
|
|
#endif
|
|
|
|
|
#define TEMP_SIZE_LIMIT_LOG2 (TEMP_SIZE_START_LOG2 + NUM_TEMP_FREELISTS)
|
|
|
|
|
|
|
|
|
|
#define TEMP_SIZE_START JS_BIT(TEMP_SIZE_START_LOG2)
|
|
|
|
|
#define TEMP_SIZE_LIMIT JS_BIT(TEMP_SIZE_LIMIT_LOG2)
|
|
|
|
|
|
|
|
|
|
JS_STATIC_ASSERT(TEMP_SIZE_START >= sizeof(JSHashTable));
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
static void *
|
2018-09-08 18:08:48 +08:00
|
|
|
js_alloc_temp_space(void *priv, size_t size)
|
|
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
Parser *parser = (Parser *) priv;
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
void *space;
|
2025-02-05 12:40:54 +10:00
|
|
|
if (size < TEMP_SIZE_LIMIT) {
|
|
|
|
|
int bin = JS_CeilingLog2(size) - TEMP_SIZE_START_LOG2;
|
|
|
|
|
JS_ASSERT(unsigned(bin) < NUM_TEMP_FREELISTS);
|
|
|
|
|
|
|
|
|
|
space = parser->tempFreeList[bin];
|
|
|
|
|
if (space) {
|
|
|
|
|
parser->tempFreeList[bin] = *(void **)space;
|
|
|
|
|
return space;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
JS_ARENA_ALLOCATE(space, &parser->context->tempPool, size);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!space)
|
2025-02-05 12:40:54 +10:00
|
|
|
js_ReportOutOfScriptQuota(parser->context);
|
2018-09-08 18:08:48 +08:00
|
|
|
return space;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
static void
|
2025-02-05 12:40:54 +10:00
|
|
|
js_free_temp_space(void *priv, void *item, size_t size)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
if (size >= TEMP_SIZE_LIMIT)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Parser *parser = (Parser *) priv;
|
|
|
|
|
int bin = JS_CeilingLog2(size) - TEMP_SIZE_START_LOG2;
|
|
|
|
|
JS_ASSERT(unsigned(bin) < NUM_TEMP_FREELISTS);
|
|
|
|
|
|
|
|
|
|
*(void **)item = parser->tempFreeList[bin];
|
|
|
|
|
parser->tempFreeList[bin] = item;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
static JSHashEntry *
|
2018-09-08 18:08:48 +08:00
|
|
|
js_alloc_temp_entry(void *priv, const void *key)
|
|
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
Parser *parser = (Parser *) priv;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSAtomListElement *ale;
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
ale = parser->aleFreeList;
|
|
|
|
|
if (ale) {
|
|
|
|
|
parser->aleFreeList = ALE_NEXT(ale);
|
|
|
|
|
return &ale->entry;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JS_ARENA_ALLOCATE_TYPE(ale, JSAtomListElement, &parser->context->tempPool);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ale) {
|
2025-02-05 12:40:54 +10:00
|
|
|
js_ReportOutOfScriptQuota(parser->context);
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
return &ale->entry;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
static void
|
2018-09-08 18:08:48 +08:00
|
|
|
js_free_temp_entry(void *priv, JSHashEntry *he, uintN flag)
|
|
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
Parser *parser = (Parser *) priv;
|
|
|
|
|
JSAtomListElement *ale = (JSAtomListElement *) he;
|
|
|
|
|
|
|
|
|
|
ALE_SET_NEXT(ale, parser->aleFreeList);
|
|
|
|
|
parser->aleFreeList = ale;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSHashAllocOps temp_alloc_ops = {
|
|
|
|
|
js_alloc_temp_space, js_free_temp_space,
|
|
|
|
|
js_alloc_temp_entry, js_free_temp_entry
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
JSAtomListElement *
|
2025-02-05 12:40:54 +10:00
|
|
|
JSAtomList::rawLookup(JSAtom *atom, JSHashEntry **&hep)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
if (table) {
|
|
|
|
|
hep = JS_HashTableRawLookup(table, ATOM_HASH(atom), atom);
|
2025-03-19 21:25:58 +10:00
|
|
|
return (JSAtomListElement *) *hep;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSHashEntry **alep = &list;
|
|
|
|
|
hep = NULL;
|
|
|
|
|
JSAtomListElement *ale;
|
|
|
|
|
while ((ale = (JSAtomListElement *)*alep) != NULL) {
|
|
|
|
|
if (ALE_ATOM(ale) == atom) {
|
|
|
|
|
/* Hit, move atom's element to the front of the list. */
|
|
|
|
|
*alep = ale->entry.next;
|
|
|
|
|
ale->entry.next = list;
|
|
|
|
|
list = &ale->entry;
|
|
|
|
|
break;
|
2025-02-05 12:40:54 +10:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
alep = &ale->entry.next;
|
2025-02-05 12:40:54 +10:00
|
|
|
}
|
|
|
|
|
return ale;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define ATOM_LIST_HASH_THRESHOLD 12
|
|
|
|
|
|
|
|
|
|
JSAtomListElement *
|
|
|
|
|
JSAtomList::add(Parser *parser, JSAtom *atom, AddHow how)
|
|
|
|
|
{
|
|
|
|
|
JS_ASSERT(!set);
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
JSAtomListElement *ale, *ale2, *next;
|
|
|
|
|
JSHashEntry **hep;
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
ale = rawLookup(atom, hep);
|
|
|
|
|
if (!ale || how != UNIQUE) {
|
|
|
|
|
if (count < ATOM_LIST_HASH_THRESHOLD && !table) {
|
|
|
|
|
/* Few enough for linear search and no hash table yet needed. */
|
|
|
|
|
ale = (JSAtomListElement *)js_alloc_temp_entry(parser, atom);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ale)
|
|
|
|
|
return NULL;
|
|
|
|
|
ALE_SET_ATOM(ale, atom);
|
2025-02-05 12:40:54 +10:00
|
|
|
|
|
|
|
|
if (how == HOIST) {
|
|
|
|
|
ale->entry.next = NULL;
|
|
|
|
|
hep = (JSHashEntry **) &list;
|
|
|
|
|
while (*hep)
|
|
|
|
|
hep = &(*hep)->next;
|
|
|
|
|
*hep = &ale->entry;
|
|
|
|
|
} else {
|
|
|
|
|
ale->entry.next = list;
|
|
|
|
|
list = &ale->entry;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
2025-02-05 12:40:54 +10:00
|
|
|
/*
|
|
|
|
|
* We should hash, or else we already are hashing, but count was
|
|
|
|
|
* reduced by JSAtomList::rawRemove below ATOM_LIST_HASH_THRESHOLD.
|
|
|
|
|
* Check whether we should create the table.
|
|
|
|
|
*/
|
|
|
|
|
if (!table) {
|
2018-09-08 18:08:48 +08:00
|
|
|
/* No hash table yet, so hep had better be null! */
|
|
|
|
|
JS_ASSERT(!hep);
|
2025-02-05 12:40:54 +10:00
|
|
|
table = JS_NewHashTable(count + 1, js_hash_atom_ptr,
|
|
|
|
|
JS_CompareValues, JS_CompareValues,
|
|
|
|
|
&temp_alloc_ops, parser);
|
|
|
|
|
if (!table)
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Set ht->nentries explicitly, because we are moving entries
|
2025-02-05 12:40:54 +10:00
|
|
|
* from list to ht, not calling JS_HashTable(Raw|)Add.
|
2018-09-08 18:08:48 +08:00
|
|
|
*/
|
2025-02-05 12:40:54 +10:00
|
|
|
table->nentries = count;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
/*
|
|
|
|
|
* Insert each ale on list into the new hash table. Append to
|
|
|
|
|
* the hash chain rather than inserting at the bucket head, to
|
|
|
|
|
* preserve order among entries with the same key.
|
|
|
|
|
*/
|
|
|
|
|
for (ale2 = (JSAtomListElement *)list; ale2; ale2 = next) {
|
2018-09-08 18:08:48 +08:00
|
|
|
next = ALE_NEXT(ale2);
|
2023-07-12 13:27:26 +10:00
|
|
|
ale2->entry.keyHash = ATOM_HASH(ALE_ATOM(ale2));
|
2025-02-05 12:40:54 +10:00
|
|
|
hep = JS_HashTableRawLookup(table, ale2->entry.keyHash,
|
2018-09-08 18:08:48 +08:00
|
|
|
ale2->entry.key);
|
2025-02-05 12:40:54 +10:00
|
|
|
while (*hep)
|
|
|
|
|
hep = &(*hep)->next;
|
2018-09-08 18:08:48 +08:00
|
|
|
*hep = &ale2->entry;
|
2025-02-05 12:40:54 +10:00
|
|
|
ale2->entry.next = NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
list = NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
/* Set hep for insertion of atom's ale, immediately below. */
|
2025-02-05 12:40:54 +10:00
|
|
|
hep = JS_HashTableRawLookup(table, ATOM_HASH(atom), atom);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Finally, add an entry for atom into the hash bucket at hep. */
|
|
|
|
|
ale = (JSAtomListElement *)
|
2025-02-05 12:40:54 +10:00
|
|
|
JS_HashTableRawAdd(table, hep, ATOM_HASH(atom), atom, NULL);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ale)
|
|
|
|
|
return NULL;
|
2025-02-05 12:40:54 +10:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* If hoisting, move ale to the end of its chain after we called
|
|
|
|
|
* JS_HashTableRawAdd, since RawAdd may have grown the table and
|
|
|
|
|
* then recomputed hep to refer to the pointer to the first entry
|
|
|
|
|
* with the given key.
|
|
|
|
|
*/
|
|
|
|
|
if (how == HOIST && ale->entry.next) {
|
|
|
|
|
JS_ASSERT(*hep == &ale->entry);
|
|
|
|
|
*hep = ale->entry.next;
|
|
|
|
|
ale->entry.next = NULL;
|
|
|
|
|
do {
|
|
|
|
|
hep = &(*hep)->next;
|
|
|
|
|
} while (*hep);
|
|
|
|
|
*hep = &ale->entry;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
ALE_SET_INDEX(ale, count++);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
return ale;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
void
|
|
|
|
|
JSAtomList::rawRemove(Parser *parser, JSAtomListElement *ale, JSHashEntry **hep)
|
|
|
|
|
{
|
|
|
|
|
JS_ASSERT(!set);
|
|
|
|
|
JS_ASSERT(count != 0);
|
|
|
|
|
|
|
|
|
|
if (table) {
|
|
|
|
|
JS_ASSERT(hep);
|
|
|
|
|
JS_HashTableRawRemove(table, hep, &ale->entry);
|
|
|
|
|
} else {
|
|
|
|
|
JS_ASSERT(!hep);
|
|
|
|
|
hep = &list;
|
|
|
|
|
while (*hep != &ale->entry) {
|
|
|
|
|
JS_ASSERT(*hep);
|
|
|
|
|
hep = &(*hep)->next;
|
|
|
|
|
}
|
|
|
|
|
*hep = ale->entry.next;
|
|
|
|
|
js_free_temp_entry(parser, &ale->entry, HT_FREE_ENTRY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
--count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSAutoAtomList::~JSAutoAtomList()
|
|
|
|
|
{
|
|
|
|
|
if (table) {
|
|
|
|
|
JS_HashTableDestroy(table);
|
|
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
JSHashEntry *hep = list;
|
2025-02-05 12:40:54 +10:00
|
|
|
while (hep) {
|
|
|
|
|
JSHashEntry *next = hep->next;
|
|
|
|
|
js_free_temp_entry(parser, hep, HT_FREE_ENTRY);
|
|
|
|
|
hep = next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSAtomListElement *
|
|
|
|
|
JSAtomListIterator::operator ()()
|
|
|
|
|
{
|
|
|
|
|
JSAtomListElement *ale;
|
|
|
|
|
JSHashTable *ht;
|
|
|
|
|
|
|
|
|
|
if (index == uint32(-1))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
ale = next;
|
|
|
|
|
if (!ale) {
|
|
|
|
|
ht = list->table;
|
|
|
|
|
if (!ht)
|
|
|
|
|
goto done;
|
|
|
|
|
do {
|
|
|
|
|
if (index == JS_BIT(JS_HASH_BITS - ht->shift))
|
|
|
|
|
goto done;
|
|
|
|
|
next = (JSAtomListElement *) ht->buckets[index++];
|
|
|
|
|
} while (!next);
|
|
|
|
|
ale = next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
next = ALE_NEXT(ale);
|
|
|
|
|
return ale;
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
index = uint32(-1);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
static intN
|
2018-09-08 18:08:48 +08:00
|
|
|
js_map_atom(JSHashEntry *he, intN i, void *arg)
|
|
|
|
|
{
|
|
|
|
|
JSAtomListElement *ale = (JSAtomListElement *)he;
|
2023-07-12 13:27:26 +10:00
|
|
|
JSAtom **vector = (JSAtom **) arg;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
vector[ALE_INDEX(ale)] = ALE_ATOM(ale);
|
|
|
|
|
return HT_ENUMERATE_NEXT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
static jsrefcount js_atom_map_count;
|
|
|
|
|
static jsrefcount js_atom_map_hash_table_count;
|
2018-09-08 18:08:48 +08:00
|
|
|
#endif
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
void
|
2018-09-08 18:08:48 +08:00
|
|
|
js_InitAtomMap(JSContext *cx, JSAtomMap *map, JSAtomList *al)
|
|
|
|
|
{
|
|
|
|
|
JSAtom **vector;
|
|
|
|
|
JSAtomListElement *ale;
|
|
|
|
|
uint32 count;
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/* Map length must already be initialized. */
|
|
|
|
|
JS_ASSERT(al->count == map->length);
|
2018-09-08 18:08:48 +08:00
|
|
|
#ifdef DEBUG
|
|
|
|
|
JS_ATOMIC_INCREMENT(&js_atom_map_count);
|
|
|
|
|
#endif
|
2023-07-12 13:27:26 +10:00
|
|
|
ale = (JSAtomListElement *)al->list;
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ale && !al->table) {
|
2023-07-12 13:27:26 +10:00
|
|
|
JS_ASSERT(!map->vector);
|
|
|
|
|
return;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
count = al->count;
|
2023-07-12 13:27:26 +10:00
|
|
|
vector = map->vector;
|
2018-09-08 18:08:48 +08:00
|
|
|
if (al->table) {
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
JS_ATOMIC_INCREMENT(&js_atom_map_hash_table_count);
|
|
|
|
|
#endif
|
|
|
|
|
JS_HashTableEnumerateEntries(al->table, js_map_atom, vector);
|
|
|
|
|
} else {
|
|
|
|
|
do {
|
|
|
|
|
vector[ALE_INDEX(ale)] = ALE_ATOM(ale);
|
|
|
|
|
} while ((ale = ALE_NEXT(ale)) != NULL);
|
|
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
al->clear();
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
|
|
|
|
|
#if JS_HAS_XML_SUPPORT
|
|
|
|
|
bool
|
|
|
|
|
js_InternNonIntElementIdSlow(JSContext *cx, JSObject *obj, const Value &idval,
|
|
|
|
|
jsid *idp)
|
|
|
|
|
{
|
|
|
|
|
JS_ASSERT(idval.isObject());
|
|
|
|
|
if (obj->isXML()) {
|
|
|
|
|
*idp = OBJECT_TO_JSID(&idval.toObject());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!js_IsFunctionQName(cx, &idval.toObject(), idp))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
if (!JSID_IS_VOID(*idp))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return js_ValueToStringId(cx, idval, idp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
js_InternNonIntElementIdSlow(JSContext *cx, JSObject *obj, const Value &idval,
|
|
|
|
|
jsid *idp, Value *vp)
|
|
|
|
|
{
|
|
|
|
|
JS_ASSERT(idval.isObject());
|
|
|
|
|
if (obj->isXML()) {
|
|
|
|
|
JSObject &idobj = idval.toObject();
|
|
|
|
|
*idp = OBJECT_TO_JSID(&idobj);
|
|
|
|
|
vp->setObject(idobj);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!js_IsFunctionQName(cx, &idval.toObject(), idp))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
if (!JSID_IS_VOID(*idp)) {
|
|
|
|
|
*vp = IdToValue(*idp);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (js_ValueToStringId(cx, idval, idp)) {
|
|
|
|
|
vp->setString(JSID_TO_STRING(*idp));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
#endif
|