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
|
|
|
* vim: set ts=4 sw=4 et tw=78:
|
|
|
|
|
*
|
|
|
|
|
* ***** 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 SpiderMonkey E4X code, released August, 2004.
|
|
|
|
|
*
|
|
|
|
|
* 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 ***** */
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
#include "jsversion.h"
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
#if JS_HAS_XML_SUPPORT
|
|
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include "jstypes.h"
|
2025-02-05 12:40:54 +10:00
|
|
|
#include "jsstdint.h"
|
2018-09-08 18:08:48 +08:00
|
|
|
#include "jsbit.h"
|
|
|
|
|
#include "jsprf.h"
|
|
|
|
|
#include "jsutil.h"
|
|
|
|
|
#include "jsapi.h"
|
|
|
|
|
#include "jsarray.h"
|
|
|
|
|
#include "jsatom.h"
|
|
|
|
|
#include "jsbool.h"
|
|
|
|
|
#include "jscntxt.h"
|
|
|
|
|
#include "jsfun.h"
|
|
|
|
|
#include "jsgc.h"
|
|
|
|
|
#include "jsinterp.h"
|
|
|
|
|
#include "jslock.h"
|
|
|
|
|
#include "jsnum.h"
|
|
|
|
|
#include "jsobj.h"
|
|
|
|
|
#include "jsopcode.h"
|
|
|
|
|
#include "jsparse.h"
|
|
|
|
|
#include "jsscan.h"
|
|
|
|
|
#include "jsscope.h"
|
|
|
|
|
#include "jsscript.h"
|
|
|
|
|
#include "jsstr.h"
|
|
|
|
|
#include "jsxml.h"
|
2025-02-03 12:35:24 +10:00
|
|
|
#include "jsstaticcheck.h"
|
2025-02-05 12:40:54 +10:00
|
|
|
#include "jsvector.h"
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
#include "jsatominlines.h"
|
2025-02-05 12:40:54 +10:00
|
|
|
#include "jscntxtinlines.h"
|
2025-03-19 21:25:58 +10:00
|
|
|
#include "jsinterpinlines.h"
|
2025-02-05 12:40:54 +10:00
|
|
|
#include "jsobjinlines.h"
|
2025-03-19 21:25:58 +10:00
|
|
|
#include "jsstrinlines.h"
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
#include <string.h> /* for #ifdef DEBUG memset calls */
|
|
|
|
|
#endif
|
|
|
|
|
|
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
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
/*
|
|
|
|
|
* NOTES
|
|
|
|
|
* - in the js shell, you must use the -x command line option, or call
|
|
|
|
|
* options('xml') before compiling anything that uses XML literals
|
|
|
|
|
*
|
|
|
|
|
* TODO
|
|
|
|
|
* - XXXbe patrol
|
|
|
|
|
* - Fuse objects and their JSXML* private data into single GC-things
|
|
|
|
|
* - fix function::foo vs. x.(foo == 42) collision using proper namespacing
|
|
|
|
|
* - JSCLASS_DOCUMENT_OBSERVER support -- live two-way binding to Gecko's DOM!
|
|
|
|
|
*/
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
static inline bool
|
|
|
|
|
js_EnterLocalRootScope(JSContext *cx)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
js_LeaveLocalRootScope(JSContext *cx)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
js_LeaveLocalRootScopeWithResult(JSContext *cx, jsval rval)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
js_LeaveLocalRootScopeWithResult(JSContext *cx, Value rval)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
js_LeaveLocalRootScopeWithResult(JSContext *cx, void *rval)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
#ifdef XML_METERING
|
2018-09-08 18:08:48 +08:00
|
|
|
static struct {
|
|
|
|
|
jsrefcount qname;
|
2025-02-03 12:35:24 +10:00
|
|
|
jsrefcount xmlnamespace;
|
2018-09-08 18:08:48 +08:00
|
|
|
jsrefcount xml;
|
|
|
|
|
jsrefcount xmlobj;
|
|
|
|
|
} xml_stats;
|
|
|
|
|
|
|
|
|
|
#define METER(x) JS_ATOMIC_INCREMENT(&(x))
|
|
|
|
|
#define UNMETER(x) JS_ATOMIC_DECREMENT(&(x))
|
|
|
|
|
#else
|
|
|
|
|
#define METER(x) /* nothing */
|
|
|
|
|
#define UNMETER(x) /* nothing */
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Random utilities and global functions.
|
|
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
const char js_AttributeName_str[] = "AttributeName";
|
2018-09-08 18:08:48 +08:00
|
|
|
const char js_isXMLName_str[] = "isXMLName";
|
|
|
|
|
const char js_XMLList_str[] = "XMLList";
|
|
|
|
|
const char js_localName_str[] = "localName";
|
|
|
|
|
const char js_xml_parent_str[] = "parent";
|
|
|
|
|
const char js_prefix_str[] = "prefix";
|
|
|
|
|
const char js_toXMLString_str[] = "toXMLString";
|
|
|
|
|
const char js_uri_str[] = "uri";
|
|
|
|
|
|
|
|
|
|
const char js_amp_entity_str[] = "&";
|
|
|
|
|
const char js_gt_entity_str[] = ">";
|
|
|
|
|
const char js_lt_entity_str[] = "<";
|
|
|
|
|
const char js_quot_entity_str[] = """;
|
2025-02-05 12:40:54 +10:00
|
|
|
const char js_leftcurly_entity_str[] = "{";
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
#define IS_STAR(str) ((str)->length() == 1 && *(str)->chars() == '*')
|
2025-02-03 12:35:24 +10:00
|
|
|
|
|
|
|
|
static JSBool
|
2025-02-05 12:40:54 +10:00
|
|
|
GetXMLFunction(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
2025-02-03 12:35:24 +10:00
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
IsDeclared(const JSObject *obj)
|
|
|
|
|
{
|
|
|
|
|
jsval v;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_ASSERT(obj->getClass() == &js_NamespaceClass);
|
2025-02-05 12:40:54 +10:00
|
|
|
v = obj->getNamespaceDeclared();
|
2025-02-03 12:35:24 +10:00
|
|
|
JS_ASSERT(JSVAL_IS_VOID(v) || v == JSVAL_TRUE);
|
|
|
|
|
return v == JSVAL_TRUE;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
static JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
xml_isXMLName(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
*vp = BOOLEAN_TO_JSVAL(js_IsXMLName(cx, argc ? vp[2] : JSVAL_VOID));
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
/*
|
|
|
|
|
* This wrapper is needed because NewBuiltinClassInstance doesn't
|
|
|
|
|
* call the constructor, and we need a place to set the
|
|
|
|
|
* HAS_EQUALITY bit.
|
|
|
|
|
*/
|
|
|
|
|
static inline JSObject *
|
|
|
|
|
NewBuiltinClassInstanceXML(JSContext *cx, Class *clasp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *obj = NewBuiltinClassInstance(cx, clasp);
|
|
|
|
|
if (obj)
|
|
|
|
|
obj->syncSpecialEquality();
|
|
|
|
|
return obj;
|
2025-02-05 12:40:54 +10:00
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
#define DEFINE_GETTER(name,code) \
|
|
|
|
|
static JSBool \
|
2025-03-19 21:25:58 +10:00
|
|
|
name(JSContext *cx, JSObject *obj, jsid id, jsval *vp) \
|
2025-02-05 12:40:54 +10:00
|
|
|
{ \
|
|
|
|
|
code; \
|
|
|
|
|
return true; \
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Namespace class and library functions.
|
|
|
|
|
*/
|
|
|
|
|
DEFINE_GETTER(NamePrefix_getter,
|
2025-03-19 21:25:58 +10:00
|
|
|
if (obj->getClass() == &js_NamespaceClass) *vp = obj->getNamePrefixVal())
|
2025-02-05 12:40:54 +10:00
|
|
|
DEFINE_GETTER(NameURI_getter,
|
2025-03-19 21:25:58 +10:00
|
|
|
if (obj->getClass() == &js_NamespaceClass) *vp = obj->getNameURIVal())
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
static JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
namespace_equality(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSObject *obj2;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_ASSERT(v->isObjectOrNull());
|
|
|
|
|
obj2 = v->toObjectOrNull();
|
|
|
|
|
*bp = (!obj2 || obj2->getClass() != &js_NamespaceClass)
|
2025-02-03 12:35:24 +10:00
|
|
|
? JS_FALSE
|
2025-03-19 21:25:58 +10:00
|
|
|
: EqualStrings(obj->getNameURI(), obj2->getNameURI());
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_FRIEND_DATA(Class) js_NamespaceClass = {
|
|
|
|
|
"Namespace",
|
|
|
|
|
JSCLASS_CONSTRUCT_PROTOTYPE |
|
|
|
|
|
JSCLASS_HAS_RESERVED_SLOTS(JSObject::NAMESPACE_CLASS_RESERVED_SLOTS) |
|
2023-07-12 13:27:26 +10:00
|
|
|
JSCLASS_MARK_IS_TRACE | JSCLASS_HAS_CACHED_PROTO(JSProto_Namespace),
|
2025-03-19 21:25:58 +10:00
|
|
|
PropertyStub, /* addProperty */
|
|
|
|
|
PropertyStub, /* delProperty */
|
|
|
|
|
PropertyStub, /* getProperty */
|
|
|
|
|
StrictPropertyStub, /* setProperty */
|
|
|
|
|
EnumerateStub,
|
|
|
|
|
ResolveStub,
|
|
|
|
|
ConvertStub,
|
|
|
|
|
FinalizeStub,
|
|
|
|
|
NULL, /* reserved0 */
|
|
|
|
|
NULL, /* checkAccess */
|
|
|
|
|
NULL, /* call */
|
|
|
|
|
NULL, /* construct */
|
|
|
|
|
NULL, /* xdrObject */
|
|
|
|
|
NULL, /* hasInstance */
|
|
|
|
|
NULL, /* mark */
|
|
|
|
|
{
|
|
|
|
|
namespace_equality,
|
|
|
|
|
NULL, /* outerObject */
|
|
|
|
|
NULL, /* innerObject */
|
|
|
|
|
NULL, /* iteratorObject */
|
|
|
|
|
NULL, /* wrappedObject */
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define NAMESPACE_ATTRS \
|
|
|
|
|
(JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_SHARED)
|
|
|
|
|
|
|
|
|
|
static JSPropertySpec namespace_props[] = {
|
2025-02-05 12:40:54 +10:00
|
|
|
{js_prefix_str, 0, NAMESPACE_ATTRS, NamePrefix_getter, 0},
|
|
|
|
|
{js_uri_str, 0, NAMESPACE_ATTRS, NameURI_getter, 0},
|
2018-09-08 18:08:48 +08:00
|
|
|
{0,0,0,0,0}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
namespace_toString(JSContext *cx, uintN argc, Value *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *obj = ToObject(cx, &vp[1]);
|
|
|
|
|
if (!obj)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
if (!JS_InstanceOf(cx, obj, Jsvalify(&js_NamespaceClass), Jsvalify(vp + 2)))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
*vp = Valueify(obj->getNameURIVal());
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSFunctionSpec namespace_methods[] = {
|
2025-02-03 12:35:24 +10:00
|
|
|
JS_FN(js_toString_str, namespace_toString, 0,0),
|
2023-07-12 13:27:26 +10:00
|
|
|
JS_FS_END
|
2018-09-08 18:08:48 +08:00
|
|
|
};
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
static JSObject *
|
2025-03-19 21:25:58 +10:00
|
|
|
NewXMLNamespace(JSContext *cx, JSLinearString *prefix, JSLinearString *uri, JSBool declared)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSObject *obj;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
obj = NewBuiltinClassInstanceXML(cx, &js_NamespaceClass);
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!obj)
|
2025-03-19 21:25:58 +10:00
|
|
|
return JS_FALSE;
|
|
|
|
|
JS_ASSERT(JSVAL_IS_VOID(obj->getNamePrefixVal()));
|
|
|
|
|
JS_ASSERT(JSVAL_IS_VOID(obj->getNameURIVal()));
|
2025-02-05 12:40:54 +10:00
|
|
|
JS_ASSERT(JSVAL_IS_VOID(obj->getNamespaceDeclared()));
|
2025-02-03 12:35:24 +10:00
|
|
|
if (prefix)
|
2025-03-19 21:25:58 +10:00
|
|
|
obj->setNamePrefix(prefix);
|
2025-02-03 12:35:24 +10:00
|
|
|
if (uri)
|
2025-03-19 21:25:58 +10:00
|
|
|
obj->setNameURI(uri);
|
2025-02-03 12:35:24 +10:00
|
|
|
if (declared)
|
2025-02-05 12:40:54 +10:00
|
|
|
obj->setNamespaceDeclared(JSVAL_TRUE);
|
2025-02-03 12:35:24 +10:00
|
|
|
METER(xml_stats.xmlnamespace);
|
2018-09-08 18:08:48 +08:00
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* QName class and library functions.
|
|
|
|
|
*/
|
2025-02-05 12:40:54 +10:00
|
|
|
DEFINE_GETTER(QNameNameURI_getter,
|
2025-03-19 21:25:58 +10:00
|
|
|
if (obj->getClass() == &js_QNameClass)
|
|
|
|
|
*vp = JSVAL_IS_VOID(obj->getNameURIVal()) ? JSVAL_NULL : obj->getNameURIVal())
|
2025-02-05 12:40:54 +10:00
|
|
|
DEFINE_GETTER(QNameLocalName_getter,
|
2025-03-19 21:25:58 +10:00
|
|
|
if (obj->getClass() == &js_QNameClass)
|
|
|
|
|
*vp = obj->getQNameLocalNameVal())
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
static JSBool
|
2025-02-03 12:35:24 +10:00
|
|
|
qname_identity(JSObject *qna, JSObject *qnb)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *uri1 = qna->getNameURI();
|
|
|
|
|
JSLinearString *uri2 = qnb->getNameURI();
|
2025-02-03 12:35:24 +10:00
|
|
|
|
|
|
|
|
if (!uri1 ^ !uri2)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (uri1 && !EqualStrings(uri1, uri2))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
return EqualStrings(qna->getQNameLocalName(), qnb->getQNameLocalName());
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
qname_equality(JSContext *cx, JSObject *qn, const Value *v, JSBool *bp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSObject *obj2;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
obj2 = v->toObjectOrNull();
|
|
|
|
|
*bp = (!obj2 || obj2->getClass() != &js_QNameClass)
|
2025-02-03 12:35:24 +10:00
|
|
|
? JS_FALSE
|
|
|
|
|
: qname_identity(qn, obj2);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_FRIEND_DATA(Class) js_QNameClass = {
|
|
|
|
|
"QName",
|
|
|
|
|
JSCLASS_CONSTRUCT_PROTOTYPE |
|
|
|
|
|
JSCLASS_HAS_RESERVED_SLOTS(JSObject::QNAME_CLASS_RESERVED_SLOTS) |
|
2023-07-12 13:27:26 +10:00
|
|
|
JSCLASS_MARK_IS_TRACE | JSCLASS_HAS_CACHED_PROTO(JSProto_QName),
|
2025-03-19 21:25:58 +10:00
|
|
|
PropertyStub, /* addProperty */
|
|
|
|
|
PropertyStub, /* delProperty */
|
|
|
|
|
PropertyStub, /* getProperty */
|
|
|
|
|
StrictPropertyStub, /* setProperty */
|
|
|
|
|
EnumerateStub,
|
|
|
|
|
ResolveStub,
|
|
|
|
|
ConvertStub,
|
|
|
|
|
FinalizeStub,
|
|
|
|
|
NULL, /* reserved0 */
|
|
|
|
|
NULL, /* checkAccess */
|
|
|
|
|
NULL, /* call */
|
|
|
|
|
NULL, /* construct */
|
|
|
|
|
NULL, /* xdrObject */
|
|
|
|
|
NULL, /* hasInstance */
|
|
|
|
|
NULL, /* mark */
|
|
|
|
|
{
|
|
|
|
|
qname_equality,
|
|
|
|
|
NULL, /* outerObject */
|
|
|
|
|
NULL, /* innerObject */
|
|
|
|
|
NULL, /* iteratorObject */
|
|
|
|
|
NULL, /* wrappedObject */
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Classes for the ECMA-357-internal types AttributeName and AnyName, which
|
|
|
|
|
* are like QName, except that they have no property getters. They share the
|
|
|
|
|
* qname_toString method, and therefore are exposed as constructable objects
|
|
|
|
|
* in this implementation.
|
|
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_FRIEND_DATA(Class) js_AttributeNameClass = {
|
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
|
|
|
js_AttributeName_str,
|
2025-02-03 12:35:24 +10:00
|
|
|
JSCLASS_CONSTRUCT_PROTOTYPE |
|
2025-03-19 21:25:58 +10:00
|
|
|
JSCLASS_HAS_RESERVED_SLOTS(JSObject::QNAME_CLASS_RESERVED_SLOTS) |
|
|
|
|
|
JSCLASS_MARK_IS_TRACE | JSCLASS_IS_ANONYMOUS,
|
|
|
|
|
PropertyStub, /* addProperty */
|
|
|
|
|
PropertyStub, /* delProperty */
|
|
|
|
|
PropertyStub, /* getProperty */
|
|
|
|
|
StrictPropertyStub, /* setProperty */
|
|
|
|
|
EnumerateStub,
|
|
|
|
|
ResolveStub,
|
|
|
|
|
ConvertStub,
|
|
|
|
|
FinalizeStub
|
2018-09-08 18:08:48 +08:00
|
|
|
};
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_FRIEND_DATA(Class) js_AnyNameClass = {
|
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
|
|
|
js_AnyName_str,
|
2025-02-03 12:35:24 +10:00
|
|
|
JSCLASS_CONSTRUCT_PROTOTYPE |
|
2025-03-19 21:25:58 +10:00
|
|
|
JSCLASS_HAS_RESERVED_SLOTS(JSObject::QNAME_CLASS_RESERVED_SLOTS) |
|
|
|
|
|
JSCLASS_MARK_IS_TRACE | JSCLASS_IS_ANONYMOUS,
|
|
|
|
|
PropertyStub, /* addProperty */
|
|
|
|
|
PropertyStub, /* delProperty */
|
|
|
|
|
PropertyStub, /* getProperty */
|
|
|
|
|
StrictPropertyStub, /* setProperty */
|
|
|
|
|
EnumerateStub,
|
|
|
|
|
ResolveStub,
|
|
|
|
|
ConvertStub,
|
|
|
|
|
FinalizeStub
|
2018-09-08 18:08:48 +08:00
|
|
|
};
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
#define QNAME_ATTRS (JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_SHARED)
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
static JSPropertySpec qname_props[] = {
|
2025-02-05 12:40:54 +10:00
|
|
|
{js_uri_str, 0, QNAME_ATTRS, QNameNameURI_getter, 0},
|
|
|
|
|
{js_localName_str, 0, QNAME_ATTRS, QNameLocalName_getter, 0},
|
2018-09-08 18:08:48 +08:00
|
|
|
{0,0,0,0,0}
|
|
|
|
|
};
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
static JSString *
|
|
|
|
|
ConvertQNameToString(JSContext *cx, JSObject *obj)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_ASSERT(obj->isQName());
|
|
|
|
|
JSString *uri = obj->getNameURI();
|
|
|
|
|
JSString *str;
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!uri) {
|
2018-09-08 18:08:48 +08:00
|
|
|
/* No uri means wildcard qualifier. */
|
|
|
|
|
str = ATOM_TO_STRING(cx->runtime->atomState.starQualifierAtom);
|
2025-02-05 12:40:54 +10:00
|
|
|
} else if (uri->empty()) {
|
2018-09-08 18:08:48 +08:00
|
|
|
/* Empty string for uri means localName is in no namespace. */
|
|
|
|
|
str = cx->runtime->emptyString;
|
|
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
JSString *qualstr = ATOM_TO_STRING(cx->runtime->atomState.qualifierAtom);
|
2025-02-03 12:35:24 +10:00
|
|
|
str = js_ConcatStrings(cx, uri, qualstr);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!str)
|
2025-03-19 21:25:58 +10:00
|
|
|
return NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
str = js_ConcatStrings(cx, str, obj->getQNameLocalName());
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!str)
|
2025-03-19 21:25:58 +10:00
|
|
|
return NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (obj->getClass() == &js_AttributeNameClass) {
|
|
|
|
|
size_t length = str->length();
|
|
|
|
|
jschar *chars = (jschar *) cx->malloc((length + 2) * sizeof(jschar));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!chars)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
*chars = '@';
|
2025-03-19 21:25:58 +10:00
|
|
|
const jschar *strChars = str->getChars(cx);
|
|
|
|
|
if (!strChars) {
|
|
|
|
|
cx->free(chars);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
js_strncpy(chars + 1, strChars, length);
|
2018-09-08 18:08:48 +08:00
|
|
|
chars[++length] = 0;
|
2023-07-12 13:27:26 +10:00
|
|
|
str = js_NewString(cx, chars, length);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!str) {
|
2025-02-05 12:40:54 +10:00
|
|
|
cx->free(chars);
|
2025-03-19 21:25:58 +10:00
|
|
|
return NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
return str;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
static JSBool
|
|
|
|
|
qname_toString(JSContext *cx, uintN argc, Value *vp)
|
|
|
|
|
{
|
|
|
|
|
JSObject *obj = ToObject(cx, &vp[1]);
|
|
|
|
|
if (!obj)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!InstanceOf(cx, obj, &js_QNameClass, vp + 2))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
JSString *str = ConvertQNameToString(cx, obj);
|
|
|
|
|
if (!str)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
vp->setString(str);
|
|
|
|
|
return true;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSFunctionSpec qname_methods[] = {
|
2025-02-03 12:35:24 +10:00
|
|
|
JS_FN(js_toString_str, qname_toString, 0,0),
|
2023-07-12 13:27:26 +10:00
|
|
|
JS_FS_END
|
2018-09-08 18:08:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
static void
|
2025-03-19 21:25:58 +10:00
|
|
|
InitXMLQName(JSObject *obj, JSLinearString *uri, JSLinearString *prefix,
|
|
|
|
|
JSLinearString *localName)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_ASSERT(obj->isQName());
|
|
|
|
|
JS_ASSERT(JSVAL_IS_VOID(obj->getNamePrefixVal()));
|
|
|
|
|
JS_ASSERT(JSVAL_IS_VOID(obj->getNameURIVal()));
|
|
|
|
|
JS_ASSERT(JSVAL_IS_VOID(obj->getQNameLocalNameVal()));
|
2025-02-03 12:35:24 +10:00
|
|
|
if (uri)
|
2025-03-19 21:25:58 +10:00
|
|
|
obj->setNameURI(uri);
|
2025-02-03 12:35:24 +10:00
|
|
|
if (prefix)
|
2025-03-19 21:25:58 +10:00
|
|
|
obj->setNamePrefix(prefix);
|
2025-02-03 12:35:24 +10:00
|
|
|
if (localName)
|
2025-03-19 21:25:58 +10:00
|
|
|
obj->setQNameLocalName(localName);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
static JSObject *
|
2025-03-19 21:25:58 +10:00
|
|
|
NewXMLQName(JSContext *cx, JSLinearString *uri, JSLinearString *prefix,
|
|
|
|
|
JSLinearString *localName)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *obj = NewBuiltinClassInstanceXML(cx, &js_QNameClass);
|
|
|
|
|
if (!obj)
|
|
|
|
|
return NULL;
|
|
|
|
|
InitXMLQName(obj, uri, prefix, localName);
|
|
|
|
|
METER(xml_stats.qname);
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
static JSObject *
|
|
|
|
|
NewXMLAttributeName(JSContext *cx, JSLinearString *uri, JSLinearString *prefix,
|
|
|
|
|
JSLinearString *localName)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* AttributeName is an internal anonymous class which instances are not
|
|
|
|
|
* exposed to scripts.
|
|
|
|
|
*/
|
|
|
|
|
JSObject *obj = NewNonFunction<WithProto::Given>(cx, &js_AttributeNameClass, NULL, NULL);
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!obj)
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_ASSERT(obj->isQName());
|
2025-02-03 12:35:24 +10:00
|
|
|
InitXMLQName(obj, uri, prefix, localName);
|
|
|
|
|
METER(xml_stats.qname);
|
2018-09-08 18:08:48 +08:00
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSObject *
|
2025-03-19 21:25:58 +10:00
|
|
|
js_ConstructXMLQNameObject(JSContext *cx, const Value &nsval, const Value &lnval)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
Value argv[2];
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ECMA-357 11.1.2,
|
|
|
|
|
* The _QualifiedIdentifier : PropertySelector :: PropertySelector_
|
|
|
|
|
* production, step 2.
|
|
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
if (nsval.isObject() &&
|
|
|
|
|
nsval.toObject().getClass() == &js_AnyNameClass) {
|
|
|
|
|
argv[0].setNull();
|
|
|
|
|
} else {
|
|
|
|
|
argv[0] = nsval;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
argv[1] = lnval;
|
2025-03-19 21:25:58 +10:00
|
|
|
return js_ConstructObject(cx, &js_QNameClass, NULL, NULL, 2, argv);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
IsXMLName(const jschar *cp, size_t n)
|
|
|
|
|
{
|
|
|
|
|
JSBool rv;
|
|
|
|
|
jschar c;
|
|
|
|
|
|
|
|
|
|
rv = JS_FALSE;
|
|
|
|
|
if (n != 0 && JS_ISXMLNSSTART(*cp)) {
|
|
|
|
|
while (--n != 0) {
|
|
|
|
|
c = *++cp;
|
|
|
|
|
if (!JS_ISXMLNS(c))
|
|
|
|
|
return rv;
|
|
|
|
|
}
|
|
|
|
|
rv = JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
return rv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSBool
|
|
|
|
|
js_IsXMLName(JSContext *cx, jsval v)
|
|
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *name = NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSErrorReporter older;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Inline specialization of the QName constructor called with v passed as
|
|
|
|
|
* the only argument, to compute the localName for the constructed qname,
|
|
|
|
|
* without actually allocating the object or computing its uri and prefix.
|
|
|
|
|
* See ECMA-357 13.1.2.1 step 1 and 13.3.2.
|
|
|
|
|
*/
|
|
|
|
|
if (!JSVAL_IS_PRIMITIVE(v) &&
|
2025-02-05 12:40:54 +10:00
|
|
|
JSVAL_TO_OBJECT(v)->isQName()) {
|
2025-03-19 21:25:58 +10:00
|
|
|
name = JSVAL_TO_OBJECT(v)->getQNameLocalName();
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
|
|
|
|
older = JS_SetErrorReporter(cx, NULL);
|
2025-03-19 21:25:58 +10:00
|
|
|
JSString *str = js_ValueToString(cx, Valueify(v));
|
|
|
|
|
if (str)
|
|
|
|
|
name = str->ensureLinear(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
JS_SetErrorReporter(cx, older);
|
|
|
|
|
if (!name) {
|
|
|
|
|
JS_ClearPendingException(cx);
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
return IsXMLName(name->chars(), name->length());
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
/*
|
|
|
|
|
* When argc is -1, it indicates argv is empty but the code should behave as
|
|
|
|
|
* if argc is 1 and argv[0] is JSVAL_VOID.
|
|
|
|
|
*/
|
2018-09-08 18:08:48 +08:00
|
|
|
static JSBool
|
2025-02-03 12:35:24 +10:00
|
|
|
NamespaceHelper(JSContext *cx, JSObject *obj, intN argc, jsval *argv,
|
2023-07-12 13:27:26 +10:00
|
|
|
jsval *rval)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
jsval urival, prefixval;
|
|
|
|
|
JSObject *uriobj;
|
|
|
|
|
JSBool isNamespace, isQName;
|
2025-03-19 21:25:58 +10:00
|
|
|
Class *clasp;
|
|
|
|
|
JSLinearString *empty, *prefix, *uri;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
isNamespace = isQName = JS_FALSE;
|
|
|
|
|
#ifdef __GNUC__ /* suppress bogus gcc warnings */
|
2025-02-03 12:35:24 +10:00
|
|
|
uriobj = NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
#endif
|
2025-02-03 12:35:24 +10:00
|
|
|
if (argc <= 0) {
|
|
|
|
|
urival = JSVAL_VOID;
|
|
|
|
|
} else {
|
|
|
|
|
urival = argv[argc > 1];
|
|
|
|
|
if (!JSVAL_IS_PRIMITIVE(urival)) {
|
|
|
|
|
uriobj = JSVAL_TO_OBJECT(urival);
|
2025-02-05 12:40:54 +10:00
|
|
|
clasp = uriobj->getClass();
|
2025-03-19 21:25:58 +10:00
|
|
|
isNamespace = (clasp == &js_NamespaceClass);
|
|
|
|
|
isQName = (clasp == &js_QNameClass);
|
2025-02-03 12:35:24 +10:00
|
|
|
}
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!obj) {
|
2018-09-08 18:08:48 +08:00
|
|
|
/* Namespace called as function. */
|
|
|
|
|
if (argc == 1 && isNamespace) {
|
|
|
|
|
/* Namespace called with one Namespace argument is identity. */
|
|
|
|
|
*rval = urival;
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
obj = NewBuiltinClassInstanceXML(cx, &js_NamespaceClass);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!obj)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
*rval = OBJECT_TO_JSVAL(obj);
|
2025-02-03 12:35:24 +10:00
|
|
|
METER(xml_stats.xmlnamespace);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
empty = cx->runtime->emptyString;
|
2025-03-19 21:25:58 +10:00
|
|
|
obj->setNamePrefix(empty);
|
|
|
|
|
obj->setNameURI(empty);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
if (argc == 1 || argc == -1) {
|
2018-09-08 18:08:48 +08:00
|
|
|
if (isNamespace) {
|
2025-02-05 12:40:54 +10:00
|
|
|
obj->setNameURI(uriobj->getNameURI());
|
|
|
|
|
obj->setNamePrefix(uriobj->getNamePrefix());
|
2025-03-19 21:25:58 +10:00
|
|
|
} else if (isQName && (uri = uriobj->getNameURI())) {
|
|
|
|
|
obj->setNameURI(uri);
|
2025-02-05 12:40:54 +10:00
|
|
|
obj->setNamePrefix(uriobj->getNamePrefix());
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
JSString *str = js_ValueToString(cx, Valueify(urival));
|
|
|
|
|
if (!str)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
uri = str->ensureLinear(cx);
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!uri)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
obj->setNameURI(uri);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!uri->empty())
|
2025-03-19 21:25:58 +10:00
|
|
|
obj->clearNamePrefix();
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
} else if (argc == 2) {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!isQName || !(uri = uriobj->getNameURI())) {
|
|
|
|
|
JSString *str = js_ValueToString(cx, Valueify(urival));
|
|
|
|
|
if (!str)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
uri = str->ensureLinear(cx);
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!uri)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
obj->setNameURI(uri);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
prefixval = argv[0];
|
2025-02-05 12:40:54 +10:00
|
|
|
if (uri->empty()) {
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!JSVAL_IS_VOID(prefixval)) {
|
2025-03-19 21:25:58 +10:00
|
|
|
JSString *str = js_ValueToString(cx, Valueify(prefixval));
|
|
|
|
|
if (!str)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!str->empty()) {
|
|
|
|
|
JSAutoByteString bytes;
|
|
|
|
|
if (js_ValueToPrintable(cx, StringValue(str), &bytes)) {
|
|
|
|
|
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
|
|
|
|
JSMSG_BAD_XML_NAMESPACE, bytes.ptr());
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (JSVAL_IS_VOID(prefixval) || !js_IsXMLName(cx, prefixval)) {
|
2025-03-19 21:25:58 +10:00
|
|
|
obj->clearNamePrefix();
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
JSString *str = js_ValueToString(cx, Valueify(prefixval));
|
|
|
|
|
if (!str)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
prefix = str->ensureLinear(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!prefix)
|
|
|
|
|
return JS_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
obj->setNamePrefix(prefix);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
Namespace(JSContext *cx, uintN argc, Value *vp)
|
2023-07-12 13:27:26 +10:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *thisobj = NULL;
|
|
|
|
|
(void)IsConstructing_PossiblyWithGivenThisObject(vp, &thisobj);
|
|
|
|
|
return NamespaceHelper(cx, thisobj, argc, Jsvalify(vp + 2), Jsvalify(vp));
|
2023-07-12 13:27:26 +10:00
|
|
|
}
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
/*
|
|
|
|
|
* When argc is -1, it indicates argv is empty but the code should behave as
|
|
|
|
|
* if argc is 1 and argv[0] is JSVAL_VOID.
|
|
|
|
|
*/
|
2023-07-12 13:27:26 +10:00
|
|
|
static JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
QNameHelper(JSContext *cx, JSObject *obj, intN argc, jsval *argv, jsval *rval)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
jsval nameval, nsval;
|
|
|
|
|
JSBool isQName, isNamespace;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *qn;
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *uri, *prefix, *name;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *obj2;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
if (argc <= 0) {
|
|
|
|
|
nameval = JSVAL_VOID;
|
|
|
|
|
isQName = JS_FALSE;
|
|
|
|
|
} else {
|
|
|
|
|
nameval = argv[argc > 1];
|
|
|
|
|
isQName =
|
|
|
|
|
!JSVAL_IS_PRIMITIVE(nameval) &&
|
2025-03-19 21:25:58 +10:00
|
|
|
JSVAL_TO_OBJECT(nameval)->getClass() == &js_QNameClass;
|
2025-02-03 12:35:24 +10:00
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!obj) {
|
2018-09-08 18:08:48 +08:00
|
|
|
/* QName called as function. */
|
|
|
|
|
if (argc == 1 && isQName) {
|
|
|
|
|
/* QName called with one QName argument is identity. */
|
|
|
|
|
*rval = nameval;
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
/* Create and return a new QName object exactly as if constructed. */
|
|
|
|
|
obj = NewBuiltinClassInstanceXML(cx, &js_QNameClass);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!obj)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
*rval = OBJECT_TO_JSVAL(obj);
|
2025-02-03 12:35:24 +10:00
|
|
|
METER(xml_stats.qname);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
if (isQName) {
|
|
|
|
|
/* If namespace is not specified and name is a QName, clone it. */
|
2025-02-03 12:35:24 +10:00
|
|
|
qn = JSVAL_TO_OBJECT(nameval);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (argc == 1) {
|
2025-03-19 21:25:58 +10:00
|
|
|
uri = qn->getNameURI();
|
|
|
|
|
prefix = qn->getNamePrefix();
|
|
|
|
|
name = qn->getQNameLocalName();
|
2018-09-08 18:08:48 +08:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Namespace and qname were passed -- use the qname's localName. */
|
2025-03-19 21:25:58 +10:00
|
|
|
nameval = qn->getQNameLocalNameVal();
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (argc == 0) {
|
|
|
|
|
name = cx->runtime->emptyString;
|
2025-02-03 12:35:24 +10:00
|
|
|
} else if (argc < 0) {
|
|
|
|
|
name = ATOM_TO_STRING(cx->runtime->atomState.typeAtoms[JSTYPE_VOID]);
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
JSString *str = js_ValueToString(cx, Valueify(nameval));
|
|
|
|
|
if (!str)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
name = str->ensureLinear(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!name)
|
|
|
|
|
return JS_FALSE;
|
2025-02-03 12:35:24 +10:00
|
|
|
argv[argc > 1] = STRING_TO_JSVAL(name);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
if (argc > 1 && !JSVAL_IS_VOID(argv[0])) {
|
|
|
|
|
nsval = argv[0];
|
|
|
|
|
} else if (IS_STAR(name)) {
|
|
|
|
|
nsval = JSVAL_NULL;
|
|
|
|
|
} else {
|
|
|
|
|
if (!js_GetDefaultXMLNamespace(cx, &nsval))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
JS_ASSERT(!JSVAL_IS_PRIMITIVE(nsval));
|
2025-02-05 12:40:54 +10:00
|
|
|
JS_ASSERT(JSVAL_TO_OBJECT(nsval)->getClass() ==
|
2025-03-19 21:25:58 +10:00
|
|
|
&js_NamespaceClass);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (JSVAL_IS_NULL(nsval)) {
|
|
|
|
|
/* NULL prefix represents *undefined* in ECMA-357 13.3.2 5(a). */
|
2025-03-19 21:25:58 +10:00
|
|
|
prefix = uri = NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
|
|
|
|
/*
|
|
|
|
|
* Inline specialization of the Namespace constructor called with
|
|
|
|
|
* nsval passed as the only argument, to compute the uri and prefix
|
|
|
|
|
* for the constructed namespace, without actually allocating the
|
|
|
|
|
* object or computing other members. See ECMA-357 13.3.2 6(a) and
|
|
|
|
|
* 13.2.2.
|
|
|
|
|
*/
|
|
|
|
|
isNamespace = isQName = JS_FALSE;
|
|
|
|
|
if (!JSVAL_IS_PRIMITIVE(nsval)) {
|
2025-02-03 12:35:24 +10:00
|
|
|
obj2 = JSVAL_TO_OBJECT(nsval);
|
2025-03-19 21:25:58 +10:00
|
|
|
isNamespace = (obj2->getClass() == &js_NamespaceClass);
|
|
|
|
|
isQName = (obj2->getClass() == &js_QNameClass);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
#ifdef __GNUC__ /* suppress bogus gcc warnings */
|
2025-02-03 12:35:24 +10:00
|
|
|
else obj2 = NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (isNamespace) {
|
2025-03-19 21:25:58 +10:00
|
|
|
uri = obj2->getNameURI();
|
|
|
|
|
prefix = obj2->getNamePrefix();
|
|
|
|
|
} else if (isQName && (uri = obj2->getNameURI())) {
|
2025-02-03 12:35:24 +10:00
|
|
|
JS_ASSERT(argc > 1);
|
2025-03-19 21:25:58 +10:00
|
|
|
prefix = obj2->getNamePrefix();
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
2025-02-03 12:35:24 +10:00
|
|
|
JS_ASSERT(argc > 1);
|
2025-03-19 21:25:58 +10:00
|
|
|
JSString *str = js_ValueToString(cx, Valueify(nsval));
|
|
|
|
|
if (!str)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
uri = str->ensureLinear(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!uri)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
argv[0] = STRING_TO_JSVAL(uri); /* local root */
|
|
|
|
|
|
|
|
|
|
/* NULL here represents *undefined* in ECMA-357 13.2.2 3(c)iii. */
|
2025-02-05 12:40:54 +10:00
|
|
|
prefix = uri->empty() ? cx->runtime->emptyString : NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out:
|
2025-02-03 12:35:24 +10:00
|
|
|
InitXMLQName(obj, uri, prefix, name);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
static JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
QName(JSContext *cx, uintN argc, Value *vp)
|
2023-07-12 13:27:26 +10:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *thisobj = NULL;
|
|
|
|
|
(void)IsConstructing_PossiblyWithGivenThisObject(vp, &thisobj);
|
|
|
|
|
return QNameHelper(cx, thisobj, argc, Jsvalify(vp + 2), Jsvalify(vp));
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* XMLArray library functions.
|
|
|
|
|
*/
|
|
|
|
|
static JSBool
|
|
|
|
|
namespace_identity(const void *a, const void *b)
|
|
|
|
|
{
|
2025-02-03 12:35:24 +10:00
|
|
|
const JSObject *nsa = (const JSObject *) a;
|
|
|
|
|
const JSObject *nsb = (const JSObject *) b;
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *prefixa = nsa->getNamePrefix();
|
|
|
|
|
JSLinearString *prefixb = nsb->getNamePrefix();
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
if (prefixa && prefixb) {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!EqualStrings(prefixa, prefixb))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
} else {
|
2025-02-03 12:35:24 +10:00
|
|
|
if (prefixa || prefixb)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
return EqualStrings(nsa->getNameURI(), nsb->getNameURI());
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
attr_identity(const void *a, const void *b)
|
|
|
|
|
{
|
|
|
|
|
const JSXML *xmla = (const JSXML *) a;
|
|
|
|
|
const JSXML *xmlb = (const JSXML *) b;
|
|
|
|
|
|
|
|
|
|
return qname_identity(xmla->name, xmlb->name);
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
void
|
|
|
|
|
JSXMLArrayCursor::trace(JSTracer *trc) {
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
size_t index = 0;
|
|
|
|
|
#endif
|
|
|
|
|
for (JSXMLArrayCursor *cursor = this; cursor; cursor = cursor->next)
|
|
|
|
|
js::gc::MarkGCThing(trc, cursor->root, "cursor_root", index++);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
static void
|
2023-07-12 13:27:26 +10:00
|
|
|
XMLArrayCursorTrace(JSTracer *trc, JSXMLArrayCursor *cursor)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
cursor->trace(trc);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
/* NB: called with null cx from the GC, via xml_trace => JSXMLArray::trim. */
|
|
|
|
|
bool
|
|
|
|
|
JSXMLArray::setCapacity(JSContext *cx, uint32 newCapacity)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
if (newCapacity == 0) {
|
2018-09-08 18:08:48 +08:00
|
|
|
/* We could let realloc(p, 0) free this, but purify gets confused. */
|
2025-03-19 21:25:58 +10:00
|
|
|
if (vector) {
|
2025-02-05 12:40:54 +10:00
|
|
|
if (cx)
|
2025-03-19 21:25:58 +10:00
|
|
|
cx->free(vector);
|
2025-02-05 12:40:54 +10:00
|
|
|
else
|
2025-03-19 21:25:58 +10:00
|
|
|
js_free(vector);
|
2025-02-05 12:40:54 +10:00
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
vector = NULL;
|
|
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
void **tmp;
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
if (
|
|
|
|
|
#if JS_BITS_PER_WORD == 32
|
2025-03-19 21:25:58 +10:00
|
|
|
(size_t)newCapacity > ~(size_t)0 / sizeof(void *) ||
|
2023-07-12 13:27:26 +10:00
|
|
|
#endif
|
2025-03-19 21:25:58 +10:00
|
|
|
!(tmp = (void **) js_realloc(vector, newCapacity * sizeof(void *)))) {
|
2018-09-08 18:08:48 +08:00
|
|
|
if (cx)
|
|
|
|
|
JS_ReportOutOfMemory(cx);
|
2025-03-19 21:25:58 +10:00
|
|
|
return false;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
vector = tmp;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
capacity = JSXML_PRESET_CAPACITY | newCapacity;
|
|
|
|
|
return true;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
void
|
|
|
|
|
JSXMLArray::trim()
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
if (capacity & JSXML_PRESET_CAPACITY)
|
2018-09-08 18:08:48 +08:00
|
|
|
return;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (length < capacity)
|
|
|
|
|
setCapacity(NULL, length);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
void
|
|
|
|
|
JSXMLArray::finish(JSContext *cx)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
cx->free(vector);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
while (JSXMLArrayCursor *cursor = cursors)
|
2025-02-05 12:40:54 +10:00
|
|
|
cursor->disconnect();
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2025-03-19 21:25:58 +10:00
|
|
|
memset(this, 0xd5, sizeof *this);
|
2018-09-08 18:08:48 +08:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define XML_NOT_FOUND ((uint32) -1)
|
|
|
|
|
|
|
|
|
|
static uint32
|
|
|
|
|
XMLArrayFindMember(const JSXMLArray *array, void *elt, JSIdentityOp identity)
|
|
|
|
|
{
|
|
|
|
|
void **vector;
|
|
|
|
|
uint32 i, n;
|
|
|
|
|
|
|
|
|
|
/* The identity op must not reallocate array->vector. */
|
|
|
|
|
vector = array->vector;
|
|
|
|
|
if (identity) {
|
|
|
|
|
for (i = 0, n = array->length; i < n; i++) {
|
|
|
|
|
if (identity(vector[i], elt))
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for (i = 0, n = array->length; i < n; i++) {
|
|
|
|
|
if (vector[i] == elt)
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return XML_NOT_FOUND;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Grow array vector capacity by powers of two to LINEAR_THRESHOLD, and after
|
|
|
|
|
* that, grow by LINEAR_INCREMENT. Both must be powers of two, and threshold
|
|
|
|
|
* should be greater than increment.
|
|
|
|
|
*/
|
|
|
|
|
#define LINEAR_THRESHOLD 256
|
|
|
|
|
#define LINEAR_INCREMENT 32
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
XMLArrayAddMember(JSContext *cx, JSXMLArray *array, uint32 index, void *elt)
|
|
|
|
|
{
|
|
|
|
|
uint32 capacity, i;
|
|
|
|
|
int log2;
|
|
|
|
|
void **vector;
|
|
|
|
|
|
|
|
|
|
if (index >= array->length) {
|
|
|
|
|
if (index >= JSXML_CAPACITY(array)) {
|
|
|
|
|
/* Arrange to clear JSXML_PRESET_CAPACITY from array->capacity. */
|
|
|
|
|
capacity = index + 1;
|
|
|
|
|
if (index >= LINEAR_THRESHOLD) {
|
|
|
|
|
capacity = JS_ROUNDUP(capacity, LINEAR_INCREMENT);
|
|
|
|
|
} else {
|
|
|
|
|
JS_CEILING_LOG2(log2, capacity);
|
|
|
|
|
capacity = JS_BIT(log2);
|
|
|
|
|
}
|
2023-07-12 13:27:26 +10:00
|
|
|
if (
|
|
|
|
|
#if JS_BITS_PER_WORD == 32
|
|
|
|
|
(size_t)capacity > ~(size_t)0 / sizeof(void *) ||
|
|
|
|
|
#endif
|
2018-09-08 18:08:48 +08:00
|
|
|
!(vector = (void **)
|
2025-02-05 12:40:54 +10:00
|
|
|
js_realloc(array->vector, capacity * sizeof(void *)))) {
|
2018-09-08 18:08:48 +08:00
|
|
|
JS_ReportOutOfMemory(cx);
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
array->capacity = capacity;
|
|
|
|
|
array->vector = vector;
|
|
|
|
|
for (i = array->length; i < index; i++)
|
|
|
|
|
vector[i] = NULL;
|
|
|
|
|
}
|
|
|
|
|
array->length = index + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
array->vector[index] = elt;
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
XMLArrayInsert(JSContext *cx, JSXMLArray *array, uint32 i, uint32 n)
|
|
|
|
|
{
|
|
|
|
|
uint32 j;
|
|
|
|
|
JSXMLArrayCursor *cursor;
|
|
|
|
|
|
|
|
|
|
j = array->length;
|
|
|
|
|
JS_ASSERT(i <= j);
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!array->setCapacity(cx, j + n))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
array->length = j + n;
|
|
|
|
|
JS_ASSERT(n != (uint32)-1);
|
|
|
|
|
while (j != i) {
|
|
|
|
|
--j;
|
|
|
|
|
array->vector[j + n] = array->vector[j];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (cursor = array->cursors; cursor; cursor = cursor->next) {
|
|
|
|
|
if (cursor->index > i)
|
|
|
|
|
cursor->index += n;
|
|
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void *
|
|
|
|
|
XMLArrayDelete(JSContext *cx, JSXMLArray *array, uint32 index, JSBool compress)
|
|
|
|
|
{
|
|
|
|
|
uint32 length;
|
|
|
|
|
void **vector, *elt;
|
|
|
|
|
JSXMLArrayCursor *cursor;
|
|
|
|
|
|
|
|
|
|
length = array->length;
|
|
|
|
|
if (index >= length)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
vector = array->vector;
|
|
|
|
|
elt = vector[index];
|
|
|
|
|
if (compress) {
|
|
|
|
|
while (++index < length)
|
|
|
|
|
vector[index-1] = vector[index];
|
|
|
|
|
array->length = length - 1;
|
|
|
|
|
array->capacity = JSXML_CAPACITY(array);
|
|
|
|
|
} else {
|
|
|
|
|
vector[index] = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (cursor = array->cursors; cursor; cursor = cursor->next) {
|
|
|
|
|
if (cursor->index > index)
|
|
|
|
|
--cursor->index;
|
|
|
|
|
}
|
|
|
|
|
return elt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
XMLArrayTruncate(JSContext *cx, JSXMLArray *array, uint32 length)
|
|
|
|
|
{
|
|
|
|
|
void **vector;
|
|
|
|
|
|
|
|
|
|
JS_ASSERT(!array->cursors);
|
|
|
|
|
if (length >= array->length)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (length == 0) {
|
|
|
|
|
if (array->vector)
|
2025-02-05 12:40:54 +10:00
|
|
|
cx->free(array->vector);
|
2018-09-08 18:08:48 +08:00
|
|
|
vector = NULL;
|
|
|
|
|
} else {
|
2025-02-05 12:40:54 +10:00
|
|
|
vector = (void **) js_realloc(array->vector, length * sizeof(void *));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!vector)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (array->length > length)
|
|
|
|
|
array->length = length;
|
|
|
|
|
array->capacity = length;
|
|
|
|
|
array->vector = vector;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define XMLARRAY_FIND_MEMBER(a,e,f) XMLArrayFindMember(a, (void *)(e), f)
|
|
|
|
|
#define XMLARRAY_HAS_MEMBER(a,e,f) (XMLArrayFindMember(a, (void *)(e), f) != \
|
|
|
|
|
XML_NOT_FOUND)
|
|
|
|
|
#define XMLARRAY_MEMBER(a,i,t) (((i) < (a)->length) \
|
|
|
|
|
? (t *) (a)->vector[i] \
|
|
|
|
|
: NULL)
|
|
|
|
|
#define XMLARRAY_SET_MEMBER(a,i,e) JS_BEGIN_MACRO \
|
|
|
|
|
if ((a)->length <= (i)) \
|
|
|
|
|
(a)->length = (i) + 1; \
|
|
|
|
|
((a)->vector[i] = (void *)(e)); \
|
|
|
|
|
JS_END_MACRO
|
|
|
|
|
#define XMLARRAY_ADD_MEMBER(x,a,i,e)XMLArrayAddMember(x, a, i, (void *)(e))
|
|
|
|
|
#define XMLARRAY_INSERT(x,a,i,n) XMLArrayInsert(x, a, i, n)
|
|
|
|
|
#define XMLARRAY_APPEND(x,a,e) XMLARRAY_ADD_MEMBER(x, a, (a)->length, (e))
|
|
|
|
|
#define XMLARRAY_DELETE(x,a,i,c,t) ((t *) XMLArrayDelete(x, a, i, c))
|
|
|
|
|
#define XMLARRAY_TRUNCATE(x,a,n) XMLArrayTruncate(x, a, n)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Define XML setting property strings and constants early, so everyone can
|
2025-02-05 12:40:54 +10:00
|
|
|
* use the same names.
|
2018-09-08 18:08:48 +08:00
|
|
|
*/
|
|
|
|
|
static const char js_ignoreComments_str[] = "ignoreComments";
|
|
|
|
|
static const char js_ignoreProcessingInstructions_str[]
|
|
|
|
|
= "ignoreProcessingInstructions";
|
|
|
|
|
static const char js_ignoreWhitespace_str[] = "ignoreWhitespace";
|
|
|
|
|
static const char js_prettyPrinting_str[] = "prettyPrinting";
|
|
|
|
|
static const char js_prettyIndent_str[] = "prettyIndent";
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
#define XSF_IGNORE_COMMENTS JS_BIT(0)
|
|
|
|
|
#define XSF_IGNORE_PROCESSING_INSTRUCTIONS JS_BIT(1)
|
|
|
|
|
#define XSF_IGNORE_WHITESPACE JS_BIT(2)
|
|
|
|
|
#define XSF_PRETTY_PRINTING JS_BIT(3)
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
static JSPropertySpec xml_static_props[] = {
|
2025-02-05 12:40:54 +10:00
|
|
|
{js_ignoreComments_str, 0, JSPROP_PERMANENT, NULL, NULL},
|
|
|
|
|
{js_ignoreProcessingInstructions_str, 0, JSPROP_PERMANENT, NULL, NULL},
|
|
|
|
|
{js_ignoreWhitespace_str, 0, JSPROP_PERMANENT, NULL, NULL},
|
|
|
|
|
{js_prettyPrinting_str, 0, JSPROP_PERMANENT, NULL, NULL},
|
|
|
|
|
{js_prettyIndent_str, 0, JSPROP_PERMANENT, NULL, NULL},
|
2018-09-08 18:08:48 +08:00
|
|
|
{0,0,0,0,0}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Macros for special-casing xml:, xmlns= and xmlns:foo= in ParseNodeToQName. */
|
|
|
|
|
#define IS_XML(str) \
|
2025-02-05 12:40:54 +10:00
|
|
|
(str->length() == 3 && IS_XML_CHARS(str->chars()))
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
#define IS_XMLNS(str) \
|
2025-02-05 12:40:54 +10:00
|
|
|
(str->length() == 5 && IS_XMLNS_CHARS(str->chars()))
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
#define IS_XML_CHARS(chars) \
|
|
|
|
|
(JS_TOLOWER((chars)[0]) == 'x' && \
|
|
|
|
|
JS_TOLOWER((chars)[1]) == 'm' && \
|
|
|
|
|
JS_TOLOWER((chars)[2]) == 'l')
|
|
|
|
|
|
|
|
|
|
#define HAS_NS_AFTER_XML(chars) \
|
|
|
|
|
(JS_TOLOWER((chars)[3]) == 'n' && \
|
|
|
|
|
JS_TOLOWER((chars)[4]) == 's')
|
|
|
|
|
|
|
|
|
|
#define IS_XMLNS_CHARS(chars) \
|
|
|
|
|
(IS_XML_CHARS(chars) && HAS_NS_AFTER_XML(chars))
|
|
|
|
|
|
|
|
|
|
#define STARTS_WITH_XML(chars,length) \
|
|
|
|
|
(length >= 3 && IS_XML_CHARS(chars))
|
|
|
|
|
|
|
|
|
|
static const char xml_namespace_str[] = "http://www.w3.org/XML/1998/namespace";
|
|
|
|
|
static const char xmlns_namespace_str[] = "http://www.w3.org/2000/xmlns/";
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
static JSObject *
|
2025-02-05 12:40:54 +10:00
|
|
|
ParseNodeToQName(Parser *parser, JSParseNode *pn,
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXMLArray *inScopeNSes, JSBool isAttributeName)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
JSContext *cx = parser->context;
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *str, *uri, *prefix, *localName;
|
2018-09-08 18:08:48 +08:00
|
|
|
size_t length, offset;
|
|
|
|
|
const jschar *start, *limit, *colon;
|
|
|
|
|
uint32 n;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *ns;
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *nsprefix;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
JS_ASSERT(pn->pn_arity == PN_NULLARY);
|
2025-03-19 21:25:58 +10:00
|
|
|
str = pn->pn_atom;
|
|
|
|
|
start = str->chars();
|
|
|
|
|
length = str->length();
|
2018-09-08 18:08:48 +08:00
|
|
|
JS_ASSERT(length != 0 && *start != '@');
|
|
|
|
|
JS_ASSERT(length != 1 || *start != '*');
|
|
|
|
|
|
|
|
|
|
uri = cx->runtime->emptyString;
|
|
|
|
|
limit = start + length;
|
|
|
|
|
colon = js_strchr_limit(start, ':', limit);
|
|
|
|
|
if (colon) {
|
2025-02-05 12:40:54 +10:00
|
|
|
offset = colon - start;
|
2023-07-12 13:27:26 +10:00
|
|
|
prefix = js_NewDependentString(cx, str, 0, offset);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!prefix)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (STARTS_WITH_XML(start, offset)) {
|
|
|
|
|
if (offset == 3) {
|
2025-03-19 21:25:58 +10:00
|
|
|
uri = JS_ASSERT_STRING_IS_FLAT(JS_InternString(cx, xml_namespace_str));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!uri)
|
|
|
|
|
return NULL;
|
|
|
|
|
} else if (offset == 5 && HAS_NS_AFTER_XML(start)) {
|
2025-03-19 21:25:58 +10:00
|
|
|
uri = JS_ASSERT_STRING_IS_FLAT(JS_InternString(cx, xmlns_namespace_str));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!uri)
|
|
|
|
|
return NULL;
|
|
|
|
|
} else {
|
|
|
|
|
uri = NULL;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
uri = NULL;
|
|
|
|
|
n = inScopeNSes->length;
|
|
|
|
|
while (n != 0) {
|
|
|
|
|
--n;
|
2025-02-03 12:35:24 +10:00
|
|
|
ns = XMLARRAY_MEMBER(inScopeNSes, n, JSObject);
|
2025-03-19 21:25:58 +10:00
|
|
|
nsprefix = ns->getNamePrefix();
|
|
|
|
|
if (nsprefix && EqualStrings(nsprefix, prefix)) {
|
|
|
|
|
uri = ns->getNameURI();
|
2018-09-08 18:08:48 +08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!uri) {
|
2025-03-19 21:25:58 +10:00
|
|
|
Value v = StringValue(prefix);
|
|
|
|
|
JSAutoByteString bytes;
|
|
|
|
|
if (js_ValueToPrintable(parser->context, v, &bytes)) {
|
|
|
|
|
ReportCompileErrorNumber(parser->context, &parser->tokenStream, pn,
|
|
|
|
|
JSREPORT_ERROR, JSMSG_BAD_XML_NAMESPACE, bytes.ptr());
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
localName = js_NewStringCopyN(parser->context, colon + 1, length - (offset + 1));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!localName)
|
|
|
|
|
return NULL;
|
|
|
|
|
} else {
|
|
|
|
|
if (isAttributeName) {
|
|
|
|
|
/*
|
|
|
|
|
* An unprefixed attribute is not in any namespace, so set prefix
|
|
|
|
|
* as well as uri to the empty string.
|
|
|
|
|
*/
|
|
|
|
|
prefix = uri;
|
|
|
|
|
} else {
|
|
|
|
|
/*
|
|
|
|
|
* Loop from back to front looking for the closest declared default
|
|
|
|
|
* namespace.
|
|
|
|
|
*/
|
|
|
|
|
n = inScopeNSes->length;
|
|
|
|
|
while (n != 0) {
|
|
|
|
|
--n;
|
2025-02-03 12:35:24 +10:00
|
|
|
ns = XMLARRAY_MEMBER(inScopeNSes, n, JSObject);
|
2025-03-19 21:25:58 +10:00
|
|
|
nsprefix = ns->getNamePrefix();
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!nsprefix || nsprefix->empty()) {
|
2025-03-19 21:25:58 +10:00
|
|
|
uri = ns->getNameURI();
|
2018-09-08 18:08:48 +08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
prefix = uri->empty() ? parser->context->runtime->emptyString : NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
localName = str;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
return NewXMLQName(parser->context, uri, prefix, localName);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSString *
|
|
|
|
|
ChompXMLWhitespace(JSContext *cx, JSString *str)
|
|
|
|
|
{
|
|
|
|
|
size_t length, newlength, offset;
|
|
|
|
|
const jschar *cp, *start, *end;
|
|
|
|
|
jschar c;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
length = str->length();
|
|
|
|
|
start = str->getChars(cx);
|
|
|
|
|
if (!start)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
for (cp = start, end = cp + length; cp < end; cp++) {
|
2018-09-08 18:08:48 +08:00
|
|
|
c = *cp;
|
|
|
|
|
if (!JS_ISXMLSPACE(c))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
while (end > cp) {
|
|
|
|
|
c = end[-1];
|
|
|
|
|
if (!JS_ISXMLSPACE(c))
|
|
|
|
|
break;
|
|
|
|
|
--end;
|
|
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
newlength = end - cp;
|
2018-09-08 18:08:48 +08:00
|
|
|
if (newlength == length)
|
|
|
|
|
return str;
|
2025-02-05 12:40:54 +10:00
|
|
|
offset = cp - start;
|
2023-07-12 13:27:26 +10:00
|
|
|
return js_NewDependentString(cx, str, offset, newlength);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSXML *
|
2025-02-05 12:40:54 +10:00
|
|
|
ParseNodeToXML(Parser *parser, JSParseNode *pn,
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXMLArray *inScopeNSes, uintN flags)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
JSContext *cx = parser->context;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSXML *xml, *kid, *attr, *attrj;
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *str;
|
2018-09-08 18:08:48 +08:00
|
|
|
uint32 length, n, i, j;
|
|
|
|
|
JSParseNode *pn2, *pn3, *head, **pnp;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *ns;
|
|
|
|
|
JSObject *qn, *attrjqn;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSXMLClass xml_class;
|
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
|
|
|
int stackDummy;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!JS_CHECK_STACK_SIZE(cx->stackLimit, &stackDummy)) {
|
2025-02-05 12:40:54 +10:00
|
|
|
ReportCompileErrorNumber(cx, &parser->tokenStream, pn, JSREPORT_ERROR,
|
|
|
|
|
JSMSG_OVER_RECURSED);
|
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
|
|
|
return NULL;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
#define PN2X_SKIP_CHILD ((JSXML *) 1)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Cases return early to avoid common code that gets an outermost xml's
|
|
|
|
|
* object, which protects GC-things owned by xml and its descendants from
|
|
|
|
|
* garbage collection.
|
|
|
|
|
*/
|
|
|
|
|
xml = NULL;
|
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_EnterLocalRootScope(cx))
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
switch (pn->pn_type) {
|
|
|
|
|
case TOK_XMLELEM:
|
|
|
|
|
length = inScopeNSes->length;
|
|
|
|
|
pn2 = pn->pn_head;
|
2025-02-05 12:40:54 +10:00
|
|
|
xml = ParseNodeToXML(parser, pn2, inScopeNSes, flags);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!xml)
|
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
|
n = pn->pn_count;
|
|
|
|
|
JS_ASSERT(n >= 2);
|
|
|
|
|
n -= 2;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!xml->xml_kids.setCapacity(cx, n))
|
2018-09-08 18:08:48 +08:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
while ((pn2 = pn2->pn_next) != NULL) {
|
|
|
|
|
if (!pn2->pn_next) {
|
|
|
|
|
/* Don't append the end tag! */
|
|
|
|
|
JS_ASSERT(pn2->pn_type == TOK_XMLETAGO);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((flags & XSF_IGNORE_WHITESPACE) &&
|
|
|
|
|
n > 1 && pn2->pn_type == TOK_XMLSPACE) {
|
|
|
|
|
--n;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
kid = ParseNodeToXML(parser, pn2, inScopeNSes, flags);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (kid == PN2X_SKIP_CHILD) {
|
|
|
|
|
--n;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!kid)
|
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
|
/* Store kid in xml right away, to protect it from GC. */
|
|
|
|
|
XMLARRAY_SET_MEMBER(&xml->xml_kids, i, kid);
|
|
|
|
|
kid->parent = xml;
|
|
|
|
|
++i;
|
|
|
|
|
|
|
|
|
|
/* XXX where is this documented in an XML spec, or in E4X? */
|
|
|
|
|
if ((flags & XSF_IGNORE_WHITESPACE) &&
|
|
|
|
|
n > 1 && kid->xml_class == JSXML_CLASS_TEXT) {
|
2025-03-19 21:25:58 +10:00
|
|
|
JSString *str = ChompXMLWhitespace(cx, kid->xml_value);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!str)
|
|
|
|
|
goto fail;
|
|
|
|
|
kid->xml_value = str;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JS_ASSERT(i == n);
|
|
|
|
|
if (n < pn->pn_count - 2)
|
2025-03-19 21:25:58 +10:00
|
|
|
xml->xml_kids.trim();
|
2018-09-08 18:08:48 +08:00
|
|
|
XMLARRAY_TRUNCATE(cx, inScopeNSes, length);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TOK_XMLLIST:
|
|
|
|
|
xml = js_NewXML(cx, JSXML_CLASS_LIST);
|
|
|
|
|
if (!xml)
|
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
|
n = pn->pn_count;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!xml->xml_kids.setCapacity(cx, n))
|
2018-09-08 18:08:48 +08:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
for (pn2 = pn->pn_head; pn2; pn2 = pn2->pn_next) {
|
|
|
|
|
/*
|
|
|
|
|
* Always ignore insignificant whitespace in lists -- we shouldn't
|
|
|
|
|
* condition this on an XML.ignoreWhitespace setting when the list
|
|
|
|
|
* constructor is XMLList (note XML/XMLList unification hazard).
|
|
|
|
|
*/
|
|
|
|
|
if (pn2->pn_type == TOK_XMLSPACE) {
|
|
|
|
|
--n;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
kid = ParseNodeToXML(parser, pn2, inScopeNSes, flags);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (kid == PN2X_SKIP_CHILD) {
|
|
|
|
|
--n;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!kid)
|
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
|
XMLARRAY_SET_MEMBER(&xml->xml_kids, i, kid);
|
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (n < pn->pn_count)
|
2025-03-19 21:25:58 +10:00
|
|
|
xml->xml_kids.trim();
|
2018-09-08 18:08:48 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TOK_XMLSTAGO:
|
|
|
|
|
case TOK_XMLPTAGC:
|
|
|
|
|
length = inScopeNSes->length;
|
|
|
|
|
pn2 = pn->pn_head;
|
|
|
|
|
JS_ASSERT(pn2->pn_type == TOK_XMLNAME);
|
|
|
|
|
if (pn2->pn_arity == PN_LIST)
|
|
|
|
|
goto syntax;
|
|
|
|
|
|
|
|
|
|
xml = js_NewXML(cx, JSXML_CLASS_ELEMENT);
|
|
|
|
|
if (!xml)
|
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
|
/* First pass: check syntax and process namespace declarations. */
|
|
|
|
|
JS_ASSERT(pn->pn_count >= 1);
|
|
|
|
|
n = pn->pn_count - 1;
|
|
|
|
|
pnp = &pn2->pn_next;
|
|
|
|
|
head = *pnp;
|
|
|
|
|
while ((pn2 = *pnp) != NULL) {
|
|
|
|
|
size_t length;
|
|
|
|
|
const jschar *chars;
|
|
|
|
|
|
|
|
|
|
if (pn2->pn_type != TOK_XMLNAME || pn2->pn_arity != PN_NULLARY)
|
|
|
|
|
goto syntax;
|
|
|
|
|
|
|
|
|
|
/* Enforce "Well-formedness constraint: Unique Att Spec". */
|
|
|
|
|
for (pn3 = head; pn3 != pn2; pn3 = pn3->pn_next->pn_next) {
|
|
|
|
|
if (pn3->pn_atom == pn2->pn_atom) {
|
2025-03-19 21:25:58 +10:00
|
|
|
Value v = StringValue(ATOM_TO_STRING(pn2->pn_atom));
|
|
|
|
|
JSAutoByteString bytes;
|
|
|
|
|
if (js_ValueToPrintable(cx, v, &bytes)) {
|
|
|
|
|
ReportCompileErrorNumber(cx, &parser->tokenStream, pn2,
|
|
|
|
|
JSREPORT_ERROR, JSMSG_DUPLICATE_XML_ATTR,
|
|
|
|
|
bytes.ptr());
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
goto fail;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JSAtom *atom = pn2->pn_atom;
|
2018-09-08 18:08:48 +08:00
|
|
|
pn2 = pn2->pn_next;
|
|
|
|
|
JS_ASSERT(pn2);
|
|
|
|
|
if (pn2->pn_type != TOK_XMLATTR)
|
|
|
|
|
goto syntax;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
chars = atom->chars();
|
|
|
|
|
length = atom->length();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (length >= 5 &&
|
|
|
|
|
IS_XMLNS_CHARS(chars) &&
|
|
|
|
|
(length == 5 || chars[5] == ':')) {
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *uri, *prefix;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
uri = ATOM_TO_STRING(pn2->pn_atom);
|
|
|
|
|
if (length == 5) {
|
|
|
|
|
/* 10.3.2.1. Step 6(h)(i)(1)(a). */
|
|
|
|
|
prefix = cx->runtime->emptyString;
|
|
|
|
|
} else {
|
2023-07-12 13:27:26 +10:00
|
|
|
prefix = js_NewStringCopyN(cx, chars + 6, length - 6);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!prefix)
|
|
|
|
|
goto fail;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Once the new ns is appended to xml->xml_namespaces, it is
|
|
|
|
|
* protected from GC by the object that owns xml -- which is
|
|
|
|
|
* either xml->object if outermost, or the object owning xml's
|
|
|
|
|
* oldest ancestor if !outermost.
|
|
|
|
|
*/
|
2025-02-03 12:35:24 +10:00
|
|
|
ns = NewXMLNamespace(cx, prefix, uri, JS_TRUE);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ns)
|
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Don't add a namespace that's already in scope. If someone
|
|
|
|
|
* extracts a child property from its parent via [[Get]], then
|
|
|
|
|
* we enforce the invariant, noted many times in ECMA-357, that
|
|
|
|
|
* the child's namespaces form a possibly-improper superset of
|
|
|
|
|
* its ancestors' namespaces.
|
|
|
|
|
*/
|
|
|
|
|
if (!XMLARRAY_HAS_MEMBER(inScopeNSes, ns, namespace_identity)) {
|
|
|
|
|
if (!XMLARRAY_APPEND(cx, inScopeNSes, ns) ||
|
|
|
|
|
!XMLARRAY_APPEND(cx, &xml->xml_namespaces, ns)) {
|
|
|
|
|
goto fail;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JS_ASSERT(n >= 2);
|
|
|
|
|
n -= 2;
|
|
|
|
|
*pnp = pn2->pn_next;
|
|
|
|
|
/* XXXbe recycle pn2 */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pnp = &pn2->pn_next;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
xml->xml_namespaces.trim();
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
/* Second pass: process tag name and attributes, using namespaces. */
|
|
|
|
|
pn2 = pn->pn_head;
|
2025-02-05 12:40:54 +10:00
|
|
|
qn = ParseNodeToQName(parser, pn2, inScopeNSes, JS_FALSE);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!qn)
|
|
|
|
|
goto fail;
|
|
|
|
|
xml->name = qn;
|
|
|
|
|
|
|
|
|
|
JS_ASSERT((n & 1) == 0);
|
|
|
|
|
n >>= 1;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!xml->xml_attrs.setCapacity(cx, n))
|
2018-09-08 18:08:48 +08:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
|
for (i = 0; (pn2 = pn2->pn_next) != NULL; i++) {
|
2025-02-05 12:40:54 +10:00
|
|
|
qn = ParseNodeToQName(parser, pn2, inScopeNSes, JS_TRUE);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!qn) {
|
|
|
|
|
xml->xml_attrs.length = i;
|
|
|
|
|
goto fail;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Enforce "Well-formedness constraint: Unique Att Spec", part 2:
|
|
|
|
|
* this time checking local name and namespace URI.
|
|
|
|
|
*/
|
|
|
|
|
for (j = 0; j < i; j++) {
|
|
|
|
|
attrj = XMLARRAY_MEMBER(&xml->xml_attrs, j, JSXML);
|
|
|
|
|
attrjqn = attrj->name;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (EqualStrings(attrjqn->getNameURI(), qn->getNameURI()) &&
|
|
|
|
|
EqualStrings(attrjqn->getQNameLocalName(), qn->getQNameLocalName())) {
|
|
|
|
|
Value v = StringValue(ATOM_TO_STRING(pn2->pn_atom));
|
|
|
|
|
JSAutoByteString bytes;
|
|
|
|
|
if (js_ValueToPrintable(cx, v, &bytes)) {
|
|
|
|
|
ReportCompileErrorNumber(cx, &parser->tokenStream, pn2,
|
|
|
|
|
JSREPORT_ERROR, JSMSG_DUPLICATE_XML_ATTR,
|
|
|
|
|
bytes.ptr());
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
goto fail;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pn2 = pn2->pn_next;
|
|
|
|
|
JS_ASSERT(pn2);
|
|
|
|
|
JS_ASSERT(pn2->pn_type == TOK_XMLATTR);
|
|
|
|
|
|
|
|
|
|
attr = js_NewXML(cx, JSXML_CLASS_ATTRIBUTE);
|
|
|
|
|
if (!attr)
|
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
|
XMLARRAY_SET_MEMBER(&xml->xml_attrs, i, attr);
|
|
|
|
|
attr->parent = xml;
|
|
|
|
|
attr->name = qn;
|
|
|
|
|
attr->xml_value = ATOM_TO_STRING(pn2->pn_atom);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Point tag closes its own namespace scope. */
|
|
|
|
|
if (pn->pn_type == TOK_XMLPTAGC)
|
|
|
|
|
XMLARRAY_TRUNCATE(cx, inScopeNSes, length);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TOK_XMLSPACE:
|
|
|
|
|
case TOK_XMLTEXT:
|
|
|
|
|
case TOK_XMLCDATA:
|
|
|
|
|
case TOK_XMLCOMMENT:
|
|
|
|
|
case TOK_XMLPI:
|
|
|
|
|
str = ATOM_TO_STRING(pn->pn_atom);
|
|
|
|
|
qn = NULL;
|
|
|
|
|
if (pn->pn_type == TOK_XMLCOMMENT) {
|
|
|
|
|
if (flags & XSF_IGNORE_COMMENTS)
|
|
|
|
|
goto skip_child;
|
|
|
|
|
xml_class = JSXML_CLASS_COMMENT;
|
|
|
|
|
} else if (pn->pn_type == TOK_XMLPI) {
|
|
|
|
|
if (IS_XML(str)) {
|
2025-03-19 21:25:58 +10:00
|
|
|
Value v = StringValue(str);
|
|
|
|
|
JSAutoByteString bytes;
|
|
|
|
|
if (js_ValueToPrintable(cx, v, &bytes)) {
|
|
|
|
|
ReportCompileErrorNumber(cx, &parser->tokenStream, pn,
|
|
|
|
|
JSREPORT_ERROR, JSMSG_RESERVED_ID, bytes.ptr());
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
goto fail;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flags & XSF_IGNORE_PROCESSING_INSTRUCTIONS)
|
|
|
|
|
goto skip_child;
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
qn = ParseNodeToQName(parser, pn, inScopeNSes, JS_FALSE);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!qn)
|
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
|
str = pn->pn_atom2
|
|
|
|
|
? ATOM_TO_STRING(pn->pn_atom2)
|
|
|
|
|
: cx->runtime->emptyString;
|
|
|
|
|
xml_class = JSXML_CLASS_PROCESSING_INSTRUCTION;
|
|
|
|
|
} else {
|
|
|
|
|
/* CDATA section content, or element text. */
|
|
|
|
|
xml_class = JSXML_CLASS_TEXT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xml = js_NewXML(cx, xml_class);
|
|
|
|
|
if (!xml)
|
|
|
|
|
goto fail;
|
|
|
|
|
xml->name = qn;
|
|
|
|
|
if (pn->pn_type == TOK_XMLSPACE)
|
|
|
|
|
xml->xml_flags |= XMLF_WHITESPACE_TEXT;
|
|
|
|
|
xml->xml_value = str;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
goto syntax;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
js_LeaveLocalRootScopeWithResult(cx, xml);
|
2018-09-08 18:08:48 +08:00
|
|
|
return xml;
|
|
|
|
|
|
|
|
|
|
skip_child:
|
|
|
|
|
js_LeaveLocalRootScope(cx);
|
|
|
|
|
return PN2X_SKIP_CHILD;
|
|
|
|
|
|
|
|
|
|
#undef PN2X_SKIP_CHILD
|
|
|
|
|
|
|
|
|
|
syntax:
|
2025-02-05 12:40:54 +10:00
|
|
|
ReportCompileErrorNumber(cx, &parser->tokenStream, pn, JSREPORT_ERROR, JSMSG_BAD_XML_MARKUP);
|
2018-09-08 18:08:48 +08:00
|
|
|
fail:
|
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
|
|
|
js_LeaveLocalRootScope(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* XML helper, object-ops, and library functions. We start with the helpers,
|
|
|
|
|
* in ECMA-357 order, but merging XML (9.1) and XMLList (9.2) helpers.
|
|
|
|
|
*/
|
|
|
|
|
static JSBool
|
|
|
|
|
GetXMLSetting(JSContext *cx, const char *name, jsval *vp)
|
|
|
|
|
{
|
|
|
|
|
jsval v;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!js_FindClassObject(cx, NULL, JSProto_XML, Valueify(&v)))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
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 (!VALUE_IS_FUNCTION(cx, v)) {
|
2018-09-08 18:08:48 +08:00
|
|
|
*vp = JSVAL_VOID;
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
return JS_GetProperty(cx, JSVAL_TO_OBJECT(v), name, vp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
GetBooleanXMLSetting(JSContext *cx, const char *name, JSBool *bp)
|
|
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
jsval v;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
return GetXMLSetting(cx, name, &v) && JS_ValueToBoolean(cx, v, bp);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
GetUint32XMLSetting(JSContext *cx, const char *name, uint32 *uip)
|
|
|
|
|
{
|
|
|
|
|
jsval v;
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
return GetXMLSetting(cx, name, &v) && JS_ValueToECMAUint32(cx, v, uip);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
GetXMLSettingFlags(JSContext *cx, uintN *flagsp)
|
|
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
JSBool flag[4];
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!GetBooleanXMLSetting(cx, js_ignoreComments_str, &flag[0]) ||
|
|
|
|
|
!GetBooleanXMLSetting(cx, js_ignoreProcessingInstructions_str, &flag[1]) ||
|
|
|
|
|
!GetBooleanXMLSetting(cx, js_ignoreWhitespace_str, &flag[2]) ||
|
|
|
|
|
!GetBooleanXMLSetting(cx, js_prettyPrinting_str, &flag[3])) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*flagsp = 0;
|
|
|
|
|
for (size_t n = 0; n < 4; ++n)
|
|
|
|
|
if (flag[n])
|
|
|
|
|
*flagsp |= JS_BIT(n);
|
|
|
|
|
return true;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSXML *
|
|
|
|
|
ParseXMLSource(JSContext *cx, JSString *src)
|
|
|
|
|
{
|
|
|
|
|
jsval nsval;
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *uri;
|
2018-09-08 18:08:48 +08:00
|
|
|
size_t urilen, srclen, length, offset, dstlen;
|
|
|
|
|
jschar *chars;
|
|
|
|
|
const jschar *srcp, *endp;
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXML *xml;
|
|
|
|
|
const char *filename;
|
2018-09-08 18:08:48 +08:00
|
|
|
uintN lineno;
|
|
|
|
|
JSOp op;
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
static const char prefix[] = "<parent xmlns=\"";
|
|
|
|
|
static const char middle[] = "\">";
|
2018-09-08 18:08:48 +08:00
|
|
|
static const char suffix[] = "</parent>";
|
|
|
|
|
|
|
|
|
|
#define constrlen(constr) (sizeof(constr) - 1)
|
|
|
|
|
|
|
|
|
|
if (!js_GetDefaultXMLNamespace(cx, &nsval))
|
|
|
|
|
return NULL;
|
2025-03-19 21:25:58 +10:00
|
|
|
uri = JSVAL_TO_OBJECT(nsval)->getNameURI();
|
2025-02-05 12:40:54 +10:00
|
|
|
uri = js_EscapeAttributeValue(cx, uri, JS_FALSE);
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!uri)
|
|
|
|
|
return NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
urilen = uri->length();
|
|
|
|
|
srclen = src->length();
|
2018-09-08 18:08:48 +08:00
|
|
|
length = constrlen(prefix) + urilen + constrlen(middle) + srclen +
|
|
|
|
|
constrlen(suffix);
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
chars = (jschar *) cx->malloc((length + 1) * sizeof(jschar));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!chars)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
dstlen = length;
|
|
|
|
|
js_InflateStringToBuffer(cx, prefix, constrlen(prefix), chars, &dstlen);
|
|
|
|
|
offset = dstlen;
|
2025-02-05 12:40:54 +10:00
|
|
|
js_strncpy(chars + offset, uri->chars(), urilen);
|
2018-09-08 18:08:48 +08:00
|
|
|
offset += urilen;
|
|
|
|
|
dstlen = length - offset + 1;
|
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
|
|
|
js_InflateStringToBuffer(cx, middle, constrlen(middle), chars + offset,
|
|
|
|
|
&dstlen);
|
2018-09-08 18:08:48 +08:00
|
|
|
offset += dstlen;
|
2025-03-19 21:25:58 +10:00
|
|
|
srcp = src->getChars(cx);
|
|
|
|
|
if (!srcp) {
|
|
|
|
|
cx->free(chars);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
js_strncpy(chars + offset, srcp, srclen);
|
|
|
|
|
offset += srclen;
|
|
|
|
|
dstlen = length - offset + 1;
|
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
|
|
|
js_InflateStringToBuffer(cx, suffix, constrlen(suffix), chars + offset,
|
|
|
|
|
&dstlen);
|
2018-09-08 18:08:48 +08:00
|
|
|
chars [offset + dstlen] = 0;
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
LeaveTrace(cx);
|
2023-07-12 13:27:26 +10:00
|
|
|
xml = NULL;
|
2025-02-05 12:40:54 +10:00
|
|
|
FrameRegsIter i(cx);
|
|
|
|
|
for (; !i.done() && !i.pc(); ++i)
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_ASSERT(!i.fp()->isScriptFrame());
|
2023-07-12 13:27:26 +10:00
|
|
|
filename = NULL;
|
|
|
|
|
lineno = 1;
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!i.done()) {
|
|
|
|
|
JSStackFrame *fp = i.fp();
|
|
|
|
|
op = (JSOp) *i.pc();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (op == JSOP_TOXML || op == JSOP_TOXMLLIST) {
|
2025-03-19 21:25:58 +10:00
|
|
|
filename = fp->script()->filename;
|
2025-02-05 12:40:54 +10:00
|
|
|
lineno = js_FramePCToLineNumber(cx, fp);
|
2023-07-12 13:27:26 +10:00
|
|
|
for (endp = srcp + srclen; srcp < endp; srcp++) {
|
2018-09-08 18:08:48 +08:00
|
|
|
if (*srcp == '\n')
|
|
|
|
|
--lineno;
|
2023-07-12 13:27:26 +10:00
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
{
|
|
|
|
|
Parser parser(cx);
|
2025-03-19 21:25:58 +10:00
|
|
|
if (parser.init(chars, length, filename, lineno, cx->findVersion())) {
|
|
|
|
|
JSObject *scopeChain = GetScopeChain(cx);
|
|
|
|
|
if (!scopeChain) {
|
|
|
|
|
cx->free(chars);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
JSParseNode *pn = parser.parseXMLText(scopeChain, false);
|
|
|
|
|
uintN flags;
|
|
|
|
|
if (pn && GetXMLSettingFlags(cx, &flags)) {
|
|
|
|
|
AutoNamespaceArray namespaces(cx);
|
|
|
|
|
if (namespaces.array.setCapacity(cx, 1))
|
|
|
|
|
xml = ParseNodeToXML(&parser, pn, &namespaces.array, flags);
|
2025-02-05 12:40:54 +10:00
|
|
|
}
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
cx->free(chars);
|
2018-09-08 18:08:48 +08:00
|
|
|
return xml;
|
|
|
|
|
|
|
|
|
|
#undef constrlen
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Errata in 10.3.1, 10.4.1, and 13.4.4.24 (at least).
|
|
|
|
|
*
|
|
|
|
|
* 10.3.1 Step 6(a) fails to NOTE that implementations that do not enforce
|
|
|
|
|
* the constraint:
|
|
|
|
|
*
|
|
|
|
|
* for all x belonging to XML:
|
|
|
|
|
* x.[[InScopeNamespaces]] >= x.[[Parent]].[[InScopeNamespaces]]
|
|
|
|
|
*
|
|
|
|
|
* must union x.[[InScopeNamespaces]] into x[0].[[InScopeNamespaces]] here
|
|
|
|
|
* (in new sub-step 6(a), renumbering the others to (b) and (c)).
|
|
|
|
|
*
|
|
|
|
|
* Same goes for 10.4.1 Step 7(a).
|
|
|
|
|
*
|
|
|
|
|
* In order for XML.prototype.namespaceDeclarations() to work correctly, the
|
|
|
|
|
* default namespace thereby unioned into x[0].[[InScopeNamespaces]] must be
|
|
|
|
|
* flagged as not declared, so that 13.4.4.24 Step 8(a) can exclude all such
|
|
|
|
|
* undeclared namespaces associated with x not belonging to ancestorNS.
|
|
|
|
|
*/
|
|
|
|
|
static JSXML *
|
|
|
|
|
OrphanXMLChild(JSContext *cx, JSXML *xml, uint32 i)
|
|
|
|
|
{
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *ns;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
ns = XMLARRAY_MEMBER(&xml->xml_namespaces, 0, JSObject);
|
2018-09-08 18:08:48 +08:00
|
|
|
xml = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
|
|
|
|
|
if (!ns || !xml)
|
|
|
|
|
return xml;
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_ELEMENT) {
|
|
|
|
|
if (!XMLARRAY_APPEND(cx, &xml->xml_namespaces, ns))
|
|
|
|
|
return NULL;
|
2025-02-05 12:40:54 +10:00
|
|
|
ns->setNamespaceDeclared(JSVAL_VOID);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
xml->parent = NULL;
|
|
|
|
|
return xml;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSObject *
|
|
|
|
|
ToXML(JSContext *cx, jsval v)
|
|
|
|
|
{
|
|
|
|
|
JSObject *obj;
|
|
|
|
|
JSXML *xml;
|
2025-03-19 21:25:58 +10:00
|
|
|
Class *clasp;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSString *str;
|
|
|
|
|
uint32 length;
|
|
|
|
|
|
|
|
|
|
if (JSVAL_IS_PRIMITIVE(v)) {
|
|
|
|
|
if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v))
|
|
|
|
|
goto bad;
|
|
|
|
|
} else {
|
|
|
|
|
obj = JSVAL_TO_OBJECT(v);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (obj->isXML()) {
|
|
|
|
|
xml = (JSXML *) obj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
if (xml->xml_kids.length != 1)
|
|
|
|
|
goto bad;
|
|
|
|
|
xml = XMLARRAY_MEMBER(&xml->xml_kids, 0, JSXML);
|
|
|
|
|
if (xml) {
|
|
|
|
|
JS_ASSERT(xml->xml_class != JSXML_CLASS_LIST);
|
|
|
|
|
return js_GetXMLObject(cx, xml);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
clasp = obj->getClass();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (clasp->flags & JSCLASS_DOCUMENT_OBSERVER) {
|
|
|
|
|
JS_ASSERT(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (clasp != &js_StringClass &&
|
|
|
|
|
clasp != &js_NumberClass &&
|
|
|
|
|
clasp != &js_BooleanClass) {
|
|
|
|
|
goto bad;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
str = js_ValueToString(cx, Valueify(v));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!str)
|
|
|
|
|
return NULL;
|
2025-02-05 12:40:54 +10:00
|
|
|
if (str->empty()) {
|
2018-09-08 18:08:48 +08:00
|
|
|
length = 0;
|
|
|
|
|
#ifdef __GNUC__ /* suppress bogus gcc warnings */
|
|
|
|
|
xml = NULL;
|
|
|
|
|
#endif
|
|
|
|
|
} else {
|
|
|
|
|
xml = ParseXMLSource(cx, str);
|
|
|
|
|
if (!xml)
|
|
|
|
|
return NULL;
|
|
|
|
|
length = JSXML_LENGTH(xml);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (length == 0) {
|
|
|
|
|
obj = js_NewXMLObject(cx, JSXML_CLASS_TEXT);
|
|
|
|
|
if (!obj)
|
|
|
|
|
return NULL;
|
|
|
|
|
} else if (length == 1) {
|
|
|
|
|
xml = OrphanXMLChild(cx, xml, 0);
|
|
|
|
|
if (!xml)
|
|
|
|
|
return NULL;
|
|
|
|
|
obj = js_GetXMLObject(cx, xml);
|
|
|
|
|
if (!obj)
|
|
|
|
|
return NULL;
|
|
|
|
|
} else {
|
|
|
|
|
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_SYNTAX_ERROR);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
return obj;
|
|
|
|
|
|
|
|
|
|
bad:
|
2023-07-12 13:27:26 +10:00
|
|
|
js_ReportValueError(cx, JSMSG_BAD_XML_CONVERSION,
|
2025-03-19 21:25:58 +10:00
|
|
|
JSDVG_IGNORE_STACK, Valueify(v), NULL);
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
Append(JSContext *cx, JSXML *list, JSXML *kid);
|
|
|
|
|
|
|
|
|
|
static JSObject *
|
|
|
|
|
ToXMLList(JSContext *cx, jsval v)
|
|
|
|
|
{
|
|
|
|
|
JSObject *obj, *listobj;
|
|
|
|
|
JSXML *xml, *list, *kid;
|
2025-03-19 21:25:58 +10:00
|
|
|
Class *clasp;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSString *str;
|
|
|
|
|
uint32 i, length;
|
|
|
|
|
|
|
|
|
|
if (JSVAL_IS_PRIMITIVE(v)) {
|
|
|
|
|
if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v))
|
|
|
|
|
goto bad;
|
|
|
|
|
} else {
|
|
|
|
|
obj = JSVAL_TO_OBJECT(v);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (obj->isXML()) {
|
|
|
|
|
xml = (JSXML *) obj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (xml->xml_class != JSXML_CLASS_LIST) {
|
|
|
|
|
listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
|
|
|
|
|
if (!listobj)
|
|
|
|
|
return NULL;
|
2025-02-05 12:40:54 +10:00
|
|
|
list = (JSXML *) listobj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!Append(cx, list, xml))
|
|
|
|
|
return NULL;
|
|
|
|
|
return listobj;
|
|
|
|
|
}
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
clasp = obj->getClass();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (clasp->flags & JSCLASS_DOCUMENT_OBSERVER) {
|
|
|
|
|
JS_ASSERT(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (clasp != &js_StringClass &&
|
|
|
|
|
clasp != &js_NumberClass &&
|
|
|
|
|
clasp != &js_BooleanClass) {
|
|
|
|
|
goto bad;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
str = js_ValueToString(cx, Valueify(v));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!str)
|
|
|
|
|
return NULL;
|
2025-02-05 12:40:54 +10:00
|
|
|
if (str->empty()) {
|
2018-09-08 18:08:48 +08:00
|
|
|
xml = NULL;
|
|
|
|
|
length = 0;
|
|
|
|
|
} else {
|
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_EnterLocalRootScope(cx))
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
xml = ParseXMLSource(cx, str);
|
|
|
|
|
if (!xml) {
|
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
|
|
|
js_LeaveLocalRootScope(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
length = JSXML_LENGTH(xml);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
|
|
|
|
|
if (listobj) {
|
2025-02-05 12:40:54 +10:00
|
|
|
list = (JSXML *) listobj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
|
kid = OrphanXMLChild(cx, xml, i);
|
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 (!kid || !Append(cx, list, kid)) {
|
2018-09-08 18:08:48 +08:00
|
|
|
listobj = NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (xml)
|
2025-03-19 21:25:58 +10:00
|
|
|
js_LeaveLocalRootScopeWithResult(cx, listobj);
|
2018-09-08 18:08:48 +08:00
|
|
|
return listobj;
|
|
|
|
|
|
|
|
|
|
bad:
|
2023-07-12 13:27:26 +10:00
|
|
|
js_ReportValueError(cx, JSMSG_BAD_XMLLIST_CONVERSION,
|
2025-03-19 21:25:58 +10:00
|
|
|
JSDVG_IGNORE_STACK, Valueify(v), NULL);
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ECMA-357 10.2.1 Steps 5-7 pulled out as common subroutines of XMLToXMLString
|
|
|
|
|
* and their library-public js_* counterparts. The guts of MakeXMLCDataString,
|
|
|
|
|
* MakeXMLCommentString, and MakeXMLPIString are further factored into a common
|
|
|
|
|
* MakeXMLSpecialString subroutine.
|
|
|
|
|
*
|
2025-03-19 21:25:58 +10:00
|
|
|
* These functions mutate sb, leaving it empty.
|
2018-09-08 18:08:48 +08:00
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
static JSFlatString *
|
|
|
|
|
MakeXMLSpecialString(JSContext *cx, StringBuffer &sb,
|
2018-09-08 18:08:48 +08:00
|
|
|
JSString *str, JSString *str2,
|
|
|
|
|
const jschar *prefix, size_t prefixlength,
|
|
|
|
|
const jschar *suffix, size_t suffixlength)
|
|
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(prefix, prefixlength) || !sb.append(str))
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
2025-02-05 12:40:54 +10:00
|
|
|
if (str2 && !str2->empty()) {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(' ') || !sb.append(str2))
|
2025-02-05 12:40:54 +10:00
|
|
|
return NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(suffix, suffixlength))
|
2025-02-05 12:40:54 +10:00
|
|
|
return NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
return sb.finishString();
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
static JSFlatString *
|
|
|
|
|
MakeXMLCDATAString(JSContext *cx, StringBuffer &sb, JSString *str)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
static const jschar cdata_prefix_ucNstr[] = {'<', '!', '[',
|
|
|
|
|
'C', 'D', 'A', 'T', 'A',
|
|
|
|
|
'['};
|
|
|
|
|
static const jschar cdata_suffix_ucNstr[] = {']', ']', '>'};
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
return MakeXMLSpecialString(cx, sb, str, NULL,
|
2018-09-08 18:08:48 +08:00
|
|
|
cdata_prefix_ucNstr, 9,
|
|
|
|
|
cdata_suffix_ucNstr, 3);
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
static JSFlatString *
|
|
|
|
|
MakeXMLCommentString(JSContext *cx, StringBuffer &sb, JSString *str)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
static const jschar comment_prefix_ucNstr[] = {'<', '!', '-', '-'};
|
|
|
|
|
static const jschar comment_suffix_ucNstr[] = {'-', '-', '>'};
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
return MakeXMLSpecialString(cx, sb, str, NULL,
|
2018-09-08 18:08:48 +08:00
|
|
|
comment_prefix_ucNstr, 4,
|
|
|
|
|
comment_suffix_ucNstr, 3);
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
static JSFlatString *
|
|
|
|
|
MakeXMLPIString(JSContext *cx, StringBuffer &sb, JSString *name,
|
2018-09-08 18:08:48 +08:00
|
|
|
JSString *value)
|
|
|
|
|
{
|
|
|
|
|
static const jschar pi_prefix_ucNstr[] = {'<', '?'};
|
|
|
|
|
static const jschar pi_suffix_ucNstr[] = {'?', '>'};
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
return MakeXMLSpecialString(cx, sb, name, value,
|
2018-09-08 18:08:48 +08:00
|
|
|
pi_prefix_ucNstr, 2,
|
|
|
|
|
pi_suffix_ucNstr, 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ECMA-357 10.2.1 17(d-g) pulled out into a common subroutine that appends
|
|
|
|
|
* equals, a double quote, an attribute value, and a closing double quote.
|
|
|
|
|
*/
|
2025-02-05 12:40:54 +10:00
|
|
|
static bool
|
2025-03-19 21:25:58 +10:00
|
|
|
AppendAttributeValue(JSContext *cx, StringBuffer &sb, JSString *valstr)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append('='))
|
2025-02-05 12:40:54 +10:00
|
|
|
return false;
|
2023-07-12 13:27:26 +10:00
|
|
|
valstr = js_EscapeAttributeValue(cx, valstr, JS_TRUE);
|
2025-03-19 21:25:58 +10:00
|
|
|
return valstr && sb.append(valstr);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ECMA-357 10.2.1.1 EscapeElementValue helper method.
|
2025-02-05 12:40:54 +10:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
* These functions mutate sb, leaving it empty.
|
2018-09-08 18:08:48 +08:00
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
static JSFlatString *
|
|
|
|
|
EscapeElementValue(JSContext *cx, StringBuffer &sb, JSString *str, uint32 toSourceFlag)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
size_t length = str->length();
|
|
|
|
|
const jschar *start = str->getChars(cx);
|
|
|
|
|
if (!start)
|
|
|
|
|
return NULL;
|
2025-02-05 12:40:54 +10:00
|
|
|
|
|
|
|
|
for (const jschar *cp = start, *end = start + length; cp != end; ++cp) {
|
|
|
|
|
jschar c = *cp;
|
|
|
|
|
switch (*cp) {
|
|
|
|
|
case '<':
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(js_lt_entity_str))
|
2025-02-05 12:40:54 +10:00
|
|
|
return NULL;
|
|
|
|
|
break;
|
|
|
|
|
case '>':
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(js_gt_entity_str))
|
2025-02-05 12:40:54 +10:00
|
|
|
return NULL;
|
|
|
|
|
break;
|
|
|
|
|
case '&':
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(js_amp_entity_str))
|
2025-02-05 12:40:54 +10:00
|
|
|
return NULL;
|
|
|
|
|
break;
|
|
|
|
|
case '{':
|
|
|
|
|
/*
|
|
|
|
|
* If EscapeElementValue is called by toSource/uneval, we also need
|
|
|
|
|
* to escape '{'. See bug 463360.
|
|
|
|
|
*/
|
|
|
|
|
if (toSourceFlag) {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(js_leftcurly_entity_str))
|
2025-02-05 12:40:54 +10:00
|
|
|
return NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/* FALL THROUGH */
|
|
|
|
|
default:
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(c))
|
2025-02-05 12:40:54 +10:00
|
|
|
return NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
return sb.finishString();
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ECMA-357 10.2.1.2 EscapeAttributeValue helper method.
|
2025-02-05 12:40:54 +10:00
|
|
|
*
|
2025-03-19 21:25:58 +10:00
|
|
|
* These functions mutate sb, leaving it empty.
|
2018-09-08 18:08:48 +08:00
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
static JSFlatString *
|
|
|
|
|
EscapeAttributeValue(JSContext *cx, StringBuffer &sb, JSString *str, JSBool quote)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
size_t length = str->length();
|
|
|
|
|
const jschar *start = str->getChars(cx);
|
|
|
|
|
if (!start)
|
|
|
|
|
return NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (quote && !sb.append('"'))
|
2025-02-05 12:40:54 +10:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
for (const jschar *cp = start, *end = start + length; cp != end; ++cp) {
|
|
|
|
|
jschar c = *cp;
|
|
|
|
|
switch (c) {
|
|
|
|
|
case '"':
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(js_quot_entity_str))
|
2025-02-05 12:40:54 +10:00
|
|
|
return NULL;
|
|
|
|
|
break;
|
|
|
|
|
case '<':
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(js_lt_entity_str))
|
2025-02-05 12:40:54 +10:00
|
|
|
return NULL;
|
|
|
|
|
break;
|
|
|
|
|
case '&':
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(js_amp_entity_str))
|
2025-02-05 12:40:54 +10:00
|
|
|
return NULL;
|
|
|
|
|
break;
|
|
|
|
|
case '\n':
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append("
"))
|
2025-02-05 12:40:54 +10:00
|
|
|
return NULL;
|
|
|
|
|
break;
|
|
|
|
|
case '\r':
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append("
"))
|
2025-02-05 12:40:54 +10:00
|
|
|
return NULL;
|
|
|
|
|
break;
|
|
|
|
|
case '\t':
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append("	"))
|
2025-02-05 12:40:54 +10:00
|
|
|
return NULL;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(c))
|
2025-02-05 12:40:54 +10:00
|
|
|
return NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (quote && !sb.append('"'))
|
2025-02-05 12:40:54 +10:00
|
|
|
return NULL;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
return sb.finishString();
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 13.3.5.4 [[GetNamespace]]([InScopeNamespaces]) */
|
2025-02-03 12:35:24 +10:00
|
|
|
static JSObject *
|
|
|
|
|
GetNamespace(JSContext *cx, JSObject *qn, const JSXMLArray *inScopeNSes)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *uri, *prefix, *nsprefix;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *match, *ns;
|
2018-09-08 18:08:48 +08:00
|
|
|
uint32 i, n;
|
|
|
|
|
jsval argv[2];
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
uri = qn->getNameURI();
|
|
|
|
|
prefix = qn->getNamePrefix();
|
2025-02-03 12:35:24 +10:00
|
|
|
JS_ASSERT(uri);
|
|
|
|
|
if (!uri) {
|
2025-03-19 21:25:58 +10:00
|
|
|
JSAutoByteString bytes;
|
|
|
|
|
const char *s = !prefix ?
|
|
|
|
|
js_undefined_str
|
|
|
|
|
: js_ValueToPrintable(cx, StringValue(prefix), &bytes);
|
|
|
|
|
if (s)
|
|
|
|
|
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_XML_NAMESPACE, s);
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Look for a matching namespace in inScopeNSes, if provided. */
|
|
|
|
|
match = NULL;
|
|
|
|
|
if (inScopeNSes) {
|
|
|
|
|
for (i = 0, n = inScopeNSes->length; i < n; i++) {
|
2025-02-03 12:35:24 +10:00
|
|
|
ns = XMLARRAY_MEMBER(inScopeNSes, i, JSObject);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ns)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Erratum, very tricky, and not specified in ECMA-357 13.3.5.4:
|
2025-02-03 12:35:24 +10:00
|
|
|
* If we preserve prefixes, we must match null prefix against
|
|
|
|
|
* an empty prefix of ns, in order to avoid generating redundant
|
2018-09-08 18:08:48 +08:00
|
|
|
* prefixed and default namespaces for cases such as:
|
|
|
|
|
*
|
|
|
|
|
* x = <t xmlns="http://foo.com"/>
|
|
|
|
|
* print(x.toXMLString());
|
|
|
|
|
*
|
|
|
|
|
* Per 10.3.2.1, the namespace attribute in t has an empty string
|
|
|
|
|
* prefix (*not* a null prefix), per 10.3.2.1 Step 6(h)(i)(1):
|
|
|
|
|
*
|
|
|
|
|
* 1. If the [local name] property of a is "xmlns"
|
|
|
|
|
* a. Map ns.prefix to the empty string
|
|
|
|
|
*
|
|
|
|
|
* But t's name has a null prefix in this implementation, meaning
|
|
|
|
|
* *undefined*, per 10.3.2.1 Step 6(c)'s NOTE (which refers to
|
|
|
|
|
* the http://www.w3.org/TR/xml-infoset/ spec, item 2.2.3, without
|
|
|
|
|
* saying how "no value" maps to an ECMA-357 value -- but it must
|
|
|
|
|
* map to the *undefined* prefix value).
|
|
|
|
|
*
|
|
|
|
|
* Since "" != undefined (or null, in the current implementation)
|
|
|
|
|
* the ECMA-357 spec will fail to match in [[GetNamespace]] called
|
|
|
|
|
* on t with argument {} U {(prefix="", uri="http://foo.com")}.
|
|
|
|
|
* This spec bug leads to ToXMLString results that duplicate the
|
|
|
|
|
* declared namespace.
|
|
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
if (EqualStrings(ns->getNameURI(), uri)) {
|
|
|
|
|
nsprefix = ns->getNamePrefix();
|
2025-02-03 12:35:24 +10:00
|
|
|
if (nsprefix == prefix ||
|
|
|
|
|
((nsprefix && prefix)
|
2025-03-19 21:25:58 +10:00
|
|
|
? EqualStrings(nsprefix, prefix)
|
2025-02-05 12:40:54 +10:00
|
|
|
: (nsprefix ? nsprefix : prefix)->empty())) {
|
2025-02-03 12:35:24 +10:00
|
|
|
match = ns;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If we didn't match, make a new namespace from qn. */
|
|
|
|
|
if (!match) {
|
2025-02-03 12:35:24 +10:00
|
|
|
argv[0] = prefix ? STRING_TO_JSVAL(prefix) : JSVAL_VOID;
|
|
|
|
|
argv[1] = STRING_TO_JSVAL(uri);
|
2025-03-19 21:25:58 +10:00
|
|
|
ns = js_ConstructObject(cx, &js_NamespaceClass, NULL, NULL,
|
|
|
|
|
2, Valueify(argv));
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!ns)
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
2025-02-03 12:35:24 +10:00
|
|
|
match = ns;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
return match;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
static JSLinearString *
|
|
|
|
|
GeneratePrefix(JSContext *cx, JSLinearString *uri, JSXMLArray *decls)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
const jschar *cp, *start, *end;
|
|
|
|
|
size_t length, newlength, offset;
|
|
|
|
|
uint32 i, n, m, serial;
|
|
|
|
|
jschar *bp, *dp;
|
|
|
|
|
JSBool done;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *ns;
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *nsprefix, *prefix;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
JS_ASSERT(!uri->empty());
|
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
|
|
|
/*
|
|
|
|
|
* If there are no *declared* namespaces, skip all collision detection and
|
|
|
|
|
* return a short prefix quickly; an example of such a situation:
|
|
|
|
|
*
|
|
|
|
|
* var x = <f/>;
|
|
|
|
|
* var n = new Namespace("http://example.com/");
|
|
|
|
|
* x.@n::att = "val";
|
|
|
|
|
* x.toXMLString();
|
|
|
|
|
*
|
|
|
|
|
* This is necessary for various log10 uses below to be valid.
|
|
|
|
|
*/
|
|
|
|
|
if (decls->length == 0)
|
2025-03-19 21:25:58 +10:00
|
|
|
return js_NewStringCopyZ(cx, "a");
|
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
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
/*
|
|
|
|
|
* Try peeling off the last filename suffix or pathname component till
|
|
|
|
|
* we have a valid XML name. This heuristic will prefer "xul" given
|
|
|
|
|
* ".../there.is.only.xul", "xbl" given ".../xbl", and "xbl2" given any
|
|
|
|
|
* likely URI of the form ".../xbl2/2005".
|
|
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
start = uri->chars();
|
|
|
|
|
end = start + uri->length();
|
2023-07-12 13:27:26 +10:00
|
|
|
cp = end;
|
2018-09-08 18:08:48 +08:00
|
|
|
while (--cp > start) {
|
|
|
|
|
if (*cp == '.' || *cp == '/' || *cp == ':') {
|
|
|
|
|
++cp;
|
2025-02-05 12:40:54 +10:00
|
|
|
length = end - cp;
|
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 (IsXMLName(cp, length) && !STARTS_WITH_XML(cp, length))
|
2018-09-08 18:08:48 +08:00
|
|
|
break;
|
|
|
|
|
end = --cp;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
length = end - cp;
|
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
|
|
|
/*
|
|
|
|
|
* If the namespace consisted only of non-XML names or names that begin
|
|
|
|
|
* case-insensitively with "xml", arbitrarily create a prefix consisting
|
|
|
|
|
* of 'a's of size length (allowing dp-calculating code to work with or
|
|
|
|
|
* without this branch executing) plus the space for storing a hyphen and
|
|
|
|
|
* the serial number (avoiding reallocation if a collision happens).
|
|
|
|
|
*/
|
|
|
|
|
bp = (jschar *) cp;
|
|
|
|
|
newlength = length;
|
|
|
|
|
if (STARTS_WITH_XML(cp, length) || !IsXMLName(cp, length)) {
|
2023-07-12 13:27:26 +10:00
|
|
|
newlength = length + 2 + (size_t) log10((double) decls->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
|
|
|
bp = (jschar *)
|
2025-02-05 12:40:54 +10:00
|
|
|
cx->malloc((newlength + 1) * sizeof(jschar));
|
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 (!bp)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
bp[newlength] = 0;
|
|
|
|
|
for (i = 0; i < newlength; i++)
|
|
|
|
|
bp[i] = 'a';
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
/*
|
|
|
|
|
* Now search through decls looking for a collision. If we collide with
|
|
|
|
|
* an existing prefix, start tacking on a hyphen and a serial number.
|
|
|
|
|
*/
|
|
|
|
|
serial = 0;
|
|
|
|
|
do {
|
|
|
|
|
done = JS_TRUE;
|
|
|
|
|
for (i = 0, n = decls->length; i < n; i++) {
|
2025-02-03 12:35:24 +10:00
|
|
|
ns = XMLARRAY_MEMBER(decls, i, JSObject);
|
2025-03-19 21:25:58 +10:00
|
|
|
if (ns && (nsprefix = ns->getNamePrefix()) &&
|
2025-02-05 12:40:54 +10:00
|
|
|
nsprefix->length() == newlength &&
|
|
|
|
|
!memcmp(nsprefix->chars(), bp,
|
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
|
|
|
newlength * sizeof(jschar))) {
|
|
|
|
|
if (bp == cp) {
|
2023-07-12 13:27:26 +10:00
|
|
|
newlength = length + 2 + (size_t) log10((double) n);
|
2018-09-08 18:08:48 +08:00
|
|
|
bp = (jschar *)
|
2025-02-05 12:40:54 +10:00
|
|
|
cx->malloc((newlength + 1) * sizeof(jschar));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!bp)
|
|
|
|
|
return NULL;
|
|
|
|
|
js_strncpy(bp, cp, length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
++serial;
|
|
|
|
|
JS_ASSERT(serial <= n);
|
2023-07-12 13:27:26 +10:00
|
|
|
dp = bp + length + 2 + (size_t) log10((double) serial);
|
2018-09-08 18:08:48 +08:00
|
|
|
*dp = 0;
|
|
|
|
|
for (m = serial; m != 0; m /= 10)
|
|
|
|
|
*--dp = (jschar)('0' + m % 10);
|
|
|
|
|
*--dp = '-';
|
|
|
|
|
JS_ASSERT(dp == bp + length);
|
|
|
|
|
|
|
|
|
|
done = JS_FALSE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} while (!done);
|
|
|
|
|
|
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 (bp == cp) {
|
2025-02-05 12:40:54 +10:00
|
|
|
offset = cp - start;
|
2023-07-12 13:27:26 +10:00
|
|
|
prefix = js_NewDependentString(cx, uri, offset, length);
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
2023-07-12 13:27:26 +10:00
|
|
|
prefix = js_NewString(cx, bp, newlength);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!prefix)
|
2025-02-05 12:40:54 +10:00
|
|
|
cx->free(bp);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
return prefix;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
namespace_match(const void *a, const void *b)
|
|
|
|
|
{
|
2025-02-03 12:35:24 +10:00
|
|
|
const JSObject *nsa = (const JSObject *) a;
|
|
|
|
|
const JSObject *nsb = (const JSObject *) b;
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *prefixa, *prefixb = nsb->getNamePrefix();
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
if (prefixb) {
|
2025-03-19 21:25:58 +10:00
|
|
|
prefixa = nsa->getNamePrefix();
|
|
|
|
|
return prefixa && EqualStrings(prefixa, prefixb);
|
2025-02-03 12:35:24 +10:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
return EqualStrings(nsa->getNameURI(), nsb->getNameURI());
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ECMA-357 10.2.1 and 10.2.2 */
|
2023-07-12 13:27:26 +10:00
|
|
|
#define TO_SOURCE_FLAG 0x80000000
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
static JSString *
|
|
|
|
|
XMLToXMLString(JSContext *cx, JSXML *xml, const JSXMLArray *ancestorNSes,
|
2023-07-12 13:27:26 +10:00
|
|
|
uint32 indentLevel)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSBool pretty, indentKids;
|
2025-03-19 21:25:58 +10:00
|
|
|
StringBuffer sb(cx);
|
|
|
|
|
JSString *str;
|
|
|
|
|
JSLinearString *prefix, *nsuri;
|
2023-07-12 13:27:26 +10:00
|
|
|
uint32 i, n, nextIndentLevel;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *ns, *ns2;
|
2025-03-19 21:25:58 +10:00
|
|
|
AutoNamespaceArray empty(cx), decls(cx), ancdecls(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
if (!GetBooleanXMLSetting(cx, js_prettyPrinting_str, &pretty))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
if (pretty) {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.appendN(' ', indentLevel & ~TO_SOURCE_FLAG))
|
2023-07-12 13:27:26 +10:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
str = NULL;
|
|
|
|
|
|
|
|
|
|
switch (xml->xml_class) {
|
|
|
|
|
case JSXML_CLASS_TEXT:
|
|
|
|
|
/* Step 4. */
|
|
|
|
|
if (pretty) {
|
|
|
|
|
str = ChompXMLWhitespace(cx, xml->xml_value);
|
|
|
|
|
if (!str)
|
|
|
|
|
return NULL;
|
|
|
|
|
} else {
|
|
|
|
|
str = xml->xml_value;
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
return EscapeElementValue(cx, sb, str, indentLevel & TO_SOURCE_FLAG);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
case JSXML_CLASS_ATTRIBUTE:
|
|
|
|
|
/* Step 5. */
|
2025-03-19 21:25:58 +10:00
|
|
|
return EscapeAttributeValue(cx, sb, xml->xml_value,
|
2023-07-12 13:27:26 +10:00
|
|
|
(indentLevel & TO_SOURCE_FLAG) != 0);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
case JSXML_CLASS_COMMENT:
|
|
|
|
|
/* Step 6. */
|
2025-03-19 21:25:58 +10:00
|
|
|
return MakeXMLCommentString(cx, sb, xml->xml_value);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
case JSXML_CLASS_PROCESSING_INSTRUCTION:
|
|
|
|
|
/* Step 7. */
|
2025-03-19 21:25:58 +10:00
|
|
|
return MakeXMLPIString(cx, sb, xml->name->getQNameLocalName(),
|
2025-02-03 12:35:24 +10:00
|
|
|
xml->xml_value);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
case JSXML_CLASS_LIST:
|
|
|
|
|
/* ECMA-357 10.2.2. */
|
2025-02-05 12:40:54 +10:00
|
|
|
{
|
|
|
|
|
JSXMLArrayCursor cursor(&xml->xml_kids);
|
|
|
|
|
i = 0;
|
|
|
|
|
while (JSXML *kid = (JSXML *) cursor.getNext()) {
|
|
|
|
|
if (pretty && i != 0) {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append('\n'))
|
2025-02-05 12:40:54 +10:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
JSString *kidstr = XMLToXMLString(cx, kid, ancestorNSes, indentLevel);
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!kidstr || !sb.append(kidstr))
|
2025-02-05 12:40:54 +10:00
|
|
|
return NULL;
|
|
|
|
|
++i;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (sb.empty())
|
2018-09-08 18:08:48 +08:00
|
|
|
return cx->runtime->emptyString;
|
2025-03-19 21:25:58 +10:00
|
|
|
return sb.finishString();
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
default:;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* After this point, control must flow through label out: to exit. */
|
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_EnterLocalRootScope(cx))
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* ECMA-357 10.2.1 step 8 onward: handle ToXMLString on an XML element. */
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!ancestorNSes)
|
|
|
|
|
ancestorNSes = &empty.array;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
/* Clone in-scope namespaces not in ancestorNSes into decls. */
|
2025-02-05 12:40:54 +10:00
|
|
|
{
|
|
|
|
|
JSXMLArrayCursor cursor(&xml->xml_namespaces);
|
|
|
|
|
while ((ns = (JSObject *) cursor.getNext()) != NULL) {
|
|
|
|
|
if (!IsDeclared(ns))
|
|
|
|
|
continue;
|
|
|
|
|
if (!XMLARRAY_HAS_MEMBER(ancestorNSes, ns, namespace_identity)) {
|
|
|
|
|
/* NOTE: may want to exclude unused namespaces here. */
|
2025-03-19 21:25:58 +10:00
|
|
|
ns2 = NewXMLNamespace(cx, ns->getNamePrefix(), ns->getNameURI(), JS_TRUE);
|
|
|
|
|
if (!ns2 || !XMLARRAY_APPEND(cx, &decls.array, ns2))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Union ancestorNSes and decls into ancdecls. Note that ancdecls does
|
|
|
|
|
* not own its member references. In the spec, ancdecls has no name, but
|
|
|
|
|
* is always written out as (AncestorNamespaces U namespaceDeclarations).
|
|
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
|
|
|
|
|
if (!ancdecls.array.setCapacity(cx, ancestorNSes->length + decls.length()))
|
2018-09-08 18:08:48 +08:00
|
|
|
goto out;
|
|
|
|
|
for (i = 0, n = ancestorNSes->length; i < n; i++) {
|
2025-02-03 12:35:24 +10:00
|
|
|
ns2 = XMLARRAY_MEMBER(ancestorNSes, i, JSObject);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ns2)
|
|
|
|
|
continue;
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_ASSERT(!XMLARRAY_HAS_MEMBER(&decls.array, ns2, namespace_identity));
|
|
|
|
|
if (!XMLARRAY_APPEND(cx, &ancdecls.array, ns2))
|
2018-09-08 18:08:48 +08:00
|
|
|
goto out;
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
for (i = 0, n = decls.length(); i < n; i++) {
|
|
|
|
|
ns2 = XMLARRAY_MEMBER(&decls.array, i, JSObject);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ns2)
|
|
|
|
|
continue;
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_ASSERT(!XMLARRAY_HAS_MEMBER(&ancdecls.array, ns2, namespace_identity));
|
|
|
|
|
if (!XMLARRAY_APPEND(cx, &ancdecls.array, ns2))
|
2018-09-08 18:08:48 +08:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Step 11, except we don't clone ns unless its prefix is undefined. */
|
2025-03-19 21:25:58 +10:00
|
|
|
ns = GetNamespace(cx, xml->name, &ancdecls.array);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ns)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
/* Step 12 (NULL means *undefined* here), plus the deferred ns cloning. */
|
2025-03-19 21:25:58 +10:00
|
|
|
prefix = ns->getNamePrefix();
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!prefix) {
|
2018-09-08 18:08:48 +08:00
|
|
|
/*
|
|
|
|
|
* Create a namespace prefix that isn't used by any member of decls.
|
|
|
|
|
* Assign the new prefix to a copy of ns. Flag this namespace as if
|
|
|
|
|
* it were declared, for assertion-testing's sake later below.
|
|
|
|
|
*
|
2025-02-03 12:35:24 +10:00
|
|
|
* Erratum: if prefix and xml->name are both null (*undefined* in
|
2018-09-08 18:08:48 +08:00
|
|
|
* ECMA-357), we know that xml was named using the default namespace
|
|
|
|
|
* (proof: see GetNamespace and the Namespace constructor called with
|
|
|
|
|
* two arguments). So we ought not generate a new prefix here, when
|
|
|
|
|
* we can declare ns as the default namespace for xml.
|
|
|
|
|
*
|
|
|
|
|
* This helps descendants inherit the namespace instead of redundantly
|
|
|
|
|
* redeclaring it with generated prefixes in each descendant.
|
|
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
nsuri = ns->getNameURI();
|
|
|
|
|
if (!xml->name->getNamePrefix()) {
|
2018-09-08 18:08:48 +08:00
|
|
|
prefix = cx->runtime->emptyString;
|
|
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
prefix = GeneratePrefix(cx, nsuri, &ancdecls.array);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!prefix)
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2025-02-03 12:35:24 +10:00
|
|
|
ns = NewXMLNamespace(cx, prefix, nsuri, JS_TRUE);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ns)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* If the xml->name was unprefixed, we must remove any declared default
|
|
|
|
|
* namespace from decls before appending ns. How can you get a default
|
|
|
|
|
* namespace in decls that doesn't match the one from name? Apparently
|
|
|
|
|
* by calling x.setNamespace(ns) where ns has no prefix. The other way
|
|
|
|
|
* to fix this is to update x's in-scope namespaces when setNamespace
|
|
|
|
|
* is called, but that's not specified by ECMA-357.
|
|
|
|
|
*
|
|
|
|
|
* Likely Erratum here, depending on whether the lack of update to x's
|
|
|
|
|
* in-scope namespace in XML.prototype.setNamespace (13.4.4.36) is an
|
|
|
|
|
* erratum or not. Note that changing setNamespace to update the list
|
|
|
|
|
* of in-scope namespaces will change x.namespaceDeclarations().
|
|
|
|
|
*/
|
2025-02-05 12:40:54 +10:00
|
|
|
if (prefix->empty()) {
|
2025-03-19 21:25:58 +10:00
|
|
|
i = XMLArrayFindMember(&decls.array, ns, namespace_match);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (i != XML_NOT_FOUND)
|
2025-03-19 21:25:58 +10:00
|
|
|
XMLArrayDelete(cx, &decls.array, i, JS_TRUE);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* In the spec, ancdecls has no name, but is always written out as
|
|
|
|
|
* (AncestorNamespaces U namespaceDeclarations). Since we compute
|
|
|
|
|
* that union in ancdecls, any time we append a namespace strong
|
|
|
|
|
* ref to decls, we must also append a weak ref to ancdecls. Order
|
|
|
|
|
* matters here: code at label out: releases strong refs in decls.
|
|
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!XMLARRAY_APPEND(cx, &ancdecls.array, ns) ||
|
|
|
|
|
!XMLARRAY_APPEND(cx, &decls.array, ns)) {
|
2018-09-08 18:08:48 +08:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
/* Format the element or point-tag into sb. */
|
|
|
|
|
if (!sb.append('<'))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!prefix->empty()) {
|
|
|
|
|
if (!sb.append(prefix) || !sb.append(':'))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(xml->name->getQNameLocalName()))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Step 16 makes a union to avoid writing two loops in step 17, to share
|
|
|
|
|
* common attribute value appending spec-code. We prefer two loops for
|
|
|
|
|
* faster code and less data overhead.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Step 17(b): append attributes. */
|
2025-02-05 12:40:54 +10:00
|
|
|
{
|
|
|
|
|
JSXMLArrayCursor cursor(&xml->xml_attrs);
|
|
|
|
|
while (JSXML *attr = (JSXML *) cursor.getNext()) {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(' '))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
2025-03-19 21:25:58 +10:00
|
|
|
ns2 = GetNamespace(cx, attr->name, &ancdecls.array);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!ns2)
|
|
|
|
|
goto out;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
/* 17(b)(ii): NULL means *undefined* here. */
|
2025-03-19 21:25:58 +10:00
|
|
|
prefix = ns2->getNamePrefix();
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!prefix) {
|
2025-03-19 21:25:58 +10:00
|
|
|
prefix = GeneratePrefix(cx, ns2->getNameURI(), &ancdecls.array);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!prefix)
|
|
|
|
|
goto out;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
/* Again, we avoid copying ns2 until we know it's prefix-less. */
|
2025-03-19 21:25:58 +10:00
|
|
|
ns2 = NewXMLNamespace(cx, prefix, ns2->getNameURI(), JS_TRUE);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!ns2)
|
|
|
|
|
goto out;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
/*
|
|
|
|
|
* In the spec, ancdecls has no name, but is always written out as
|
|
|
|
|
* (AncestorNamespaces U namespaceDeclarations). Since we compute
|
|
|
|
|
* that union in ancdecls, any time we append a namespace strong
|
|
|
|
|
* ref to decls, we must also append a weak ref to ancdecls. Order
|
|
|
|
|
* matters here: code at label out: releases strong refs in decls.
|
|
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!XMLARRAY_APPEND(cx, &ancdecls.array, ns2) ||
|
|
|
|
|
!XMLARRAY_APPEND(cx, &decls.array, ns2)) {
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
/* 17(b)(iii). */
|
|
|
|
|
if (!prefix->empty()) {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(prefix) || !sb.append(':'))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
/* 17(b)(iv). */
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(attr->name->getQNameLocalName()))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
/* 17(d-g). */
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!AppendAttributeValue(cx, sb, attr->xml_value))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
|
|
|
|
}
|
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
|
|
|
/* Step 17(c): append XML namespace declarations. */
|
2025-02-05 12:40:54 +10:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSXMLArrayCursor cursor(&decls.array);
|
2025-02-05 12:40:54 +10:00
|
|
|
while (JSObject *ns3 = (JSObject *) cursor.getNext()) {
|
|
|
|
|
JS_ASSERT(IsDeclared(ns3));
|
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-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(" xmlns"))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
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
|
|
|
/* 17(c)(ii): NULL means *undefined* here. */
|
2025-03-19 21:25:58 +10:00
|
|
|
prefix = ns3->getNamePrefix();
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!prefix) {
|
2025-03-19 21:25:58 +10:00
|
|
|
prefix = GeneratePrefix(cx, ns3->getNameURI(), &ancdecls.array);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!prefix)
|
|
|
|
|
goto out;
|
2025-03-19 21:25:58 +10:00
|
|
|
ns3->setNamePrefix(prefix);
|
2025-02-05 12:40:54 +10: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
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
/* 17(c)(iii). */
|
|
|
|
|
if (!prefix->empty()) {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(':') || !sb.append(prefix))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
|
|
|
|
}
|
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
|
|
|
/* 17(d-g). */
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!AppendAttributeValue(cx, sb, ns3->getNameURI()))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
/* Step 18: handle point tags. */
|
|
|
|
|
n = xml->xml_kids.length;
|
|
|
|
|
if (n == 0) {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append("/>"))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
|
|
|
|
/* Steps 19 through 25: handle element content, and open the end-tag. */
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append('>'))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
|
|
|
|
{
|
|
|
|
|
JSXML *kid;
|
|
|
|
|
indentKids = n > 1 ||
|
|
|
|
|
(n == 1 &&
|
|
|
|
|
(kid = XMLARRAY_MEMBER(&xml->xml_kids, 0, JSXML)) &&
|
|
|
|
|
kid->xml_class != JSXML_CLASS_TEXT);
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
if (pretty && indentKids) {
|
|
|
|
|
if (!GetUint32XMLSetting(cx, js_prettyIndent_str, &i))
|
|
|
|
|
goto out;
|
|
|
|
|
nextIndentLevel = indentLevel + i;
|
|
|
|
|
} else {
|
2023-07-12 13:27:26 +10:00
|
|
|
nextIndentLevel = indentLevel & TO_SOURCE_FLAG;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
{
|
|
|
|
|
JSXMLArrayCursor cursor(&xml->xml_kids);
|
|
|
|
|
while (JSXML *kid = (JSXML *) cursor.getNext()) {
|
|
|
|
|
if (pretty && indentKids) {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append('\n'))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JSString *kidstr = XMLToXMLString(cx, kid, &ancdecls.array, nextIndentLevel);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!kidstr)
|
|
|
|
|
goto out;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(kidstr))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pretty && indentKids) {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append('\n') ||
|
|
|
|
|
!sb.appendN(' ', indentLevel & ~TO_SOURCE_FLAG))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append("</"))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
/* Step 26. */
|
2025-03-19 21:25:58 +10:00
|
|
|
prefix = ns->getNamePrefix();
|
2025-02-05 12:40:54 +10:00
|
|
|
if (prefix && !prefix->empty()) {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(prefix) || !sb.append(':'))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Step 27. */
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!sb.append(xml->name->getQNameLocalName()) || !sb.append('>'))
|
2025-02-05 12:40:54 +10:00
|
|
|
goto out;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
str = sb.finishString();
|
2018-09-08 18:08:48 +08:00
|
|
|
out:
|
2025-03-19 21:25:58 +10:00
|
|
|
js_LeaveLocalRootScopeWithResult(cx, str);
|
2018-09-08 18:08:48 +08:00
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ECMA-357 10.2 */
|
|
|
|
|
static JSString *
|
2023-07-12 13:27:26 +10:00
|
|
|
ToXMLString(JSContext *cx, jsval v, uint32 toSourceFlag)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSObject *obj;
|
|
|
|
|
JSString *str;
|
|
|
|
|
JSXML *xml;
|
|
|
|
|
|
|
|
|
|
if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) {
|
|
|
|
|
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
|
|
|
|
JSMSG_BAD_XML_CONVERSION,
|
2023-07-12 13:27:26 +10:00
|
|
|
JSVAL_IS_NULL(v) ? js_null_str : js_undefined_str);
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (JSVAL_IS_BOOLEAN(v) || JSVAL_IS_NUMBER(v))
|
2025-03-19 21:25:58 +10:00
|
|
|
return js_ValueToString(cx, Valueify(v));
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
if (JSVAL_IS_STRING(v)) {
|
2025-03-19 21:25:58 +10:00
|
|
|
StringBuffer sb(cx);
|
|
|
|
|
return EscapeElementValue(cx, sb, JSVAL_TO_STRING(v), toSourceFlag);
|
2025-02-05 12:40:54 +10:00
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
obj = JSVAL_TO_OBJECT(v);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!obj->isXML()) {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!DefaultValue(cx, obj, JSTYPE_STRING, Valueify(&v)))
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
2025-03-19 21:25:58 +10:00
|
|
|
str = js_ValueToString(cx, Valueify(v));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!str)
|
|
|
|
|
return NULL;
|
2025-03-19 21:25:58 +10:00
|
|
|
StringBuffer sb(cx);
|
|
|
|
|
return EscapeElementValue(cx, sb, str, toSourceFlag);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Handle non-element cases in this switch, returning from each case. */
|
2025-02-05 12:40:54 +10:00
|
|
|
xml = (JSXML *) obj->getPrivate();
|
2023-07-12 13:27:26 +10:00
|
|
|
return XMLToXMLString(cx, xml, NULL, toSourceFlag | 0);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
static JSObject *
|
2018-09-08 18:08:48 +08:00
|
|
|
ToAttributeName(JSContext *cx, jsval v)
|
|
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *name, *uri, *prefix;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSObject *obj;
|
2025-03-19 21:25:58 +10:00
|
|
|
Class *clasp;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *qn;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
if (JSVAL_IS_STRING(v)) {
|
2025-03-19 21:25:58 +10:00
|
|
|
name = JSVAL_TO_STRING(v)->ensureLinear(cx);
|
|
|
|
|
if (!name)
|
|
|
|
|
return NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
uri = prefix = cx->runtime->emptyString;
|
|
|
|
|
} else {
|
|
|
|
|
if (JSVAL_IS_PRIMITIVE(v)) {
|
2023-07-12 13:27:26 +10:00
|
|
|
js_ReportValueError(cx, JSMSG_BAD_XML_ATTR_NAME,
|
2025-03-19 21:25:58 +10:00
|
|
|
JSDVG_IGNORE_STACK, Valueify(v), NULL);
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obj = JSVAL_TO_OBJECT(v);
|
2025-02-05 12:40:54 +10:00
|
|
|
clasp = obj->getClass();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (clasp == &js_AttributeNameClass)
|
2025-02-03 12:35:24 +10:00
|
|
|
return obj;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (clasp == &js_QNameClass) {
|
2025-02-03 12:35:24 +10:00
|
|
|
qn = obj;
|
2025-03-19 21:25:58 +10:00
|
|
|
uri = qn->getNameURI();
|
|
|
|
|
prefix = qn->getNamePrefix();
|
|
|
|
|
name = qn->getQNameLocalName();
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
|
|
|
|
if (clasp == &js_AnyNameClass) {
|
|
|
|
|
name = ATOM_TO_STRING(cx->runtime->atomState.starAtom);
|
|
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
JSString *str = js_ValueToString(cx, Valueify(v));
|
|
|
|
|
if (!str)
|
|
|
|
|
return NULL;
|
|
|
|
|
name = str->ensureLinear(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!name)
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
uri = prefix = cx->runtime->emptyString;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
qn = NewXMLAttributeName(cx, uri, prefix, name);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!qn)
|
|
|
|
|
return NULL;
|
|
|
|
|
return qn;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
static void
|
2025-03-19 21:25:58 +10:00
|
|
|
ReportBadXMLName(JSContext *cx, const Value &idval)
|
2023-07-12 13:27:26 +10:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
js_ReportValueError(cx, JSMSG_BAD_XML_NAME, JSDVG_IGNORE_STACK, idval, NULL);
|
2023-07-12 13:27:26 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2025-02-03 12:35:24 +10:00
|
|
|
IsFunctionQName(JSContext *cx, JSObject *qn, jsid *funidp)
|
2023-07-12 13:27:26 +10:00
|
|
|
{
|
|
|
|
|
JSAtom *atom;
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *uri;
|
2023-07-12 13:27:26 +10:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
atom = cx->runtime->atomState.functionNamespaceURIAtom;
|
|
|
|
|
uri = qn->getNameURI();
|
|
|
|
|
if (uri &&
|
2025-02-03 12:35:24 +10:00
|
|
|
(uri == ATOM_TO_STRING(atom) ||
|
2025-03-19 21:25:58 +10:00
|
|
|
EqualStrings(uri, ATOM_TO_STRING(atom)))) {
|
|
|
|
|
return JS_ValueToId(cx, STRING_TO_JSVAL(qn->getQNameLocalName()), funidp);
|
2023-07-12 13:27:26 +10:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
*funidp = JSID_VOID;
|
2023-07-12 13:27:26 +10:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSBool
|
|
|
|
|
js_IsFunctionQName(JSContext *cx, JSObject *obj, jsid *funidp)
|
|
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
if (obj->getClass() == &js_QNameClass)
|
2025-02-03 12:35:24 +10:00
|
|
|
return IsFunctionQName(cx, obj, funidp);
|
2025-03-19 21:25:58 +10:00
|
|
|
*funidp = JSID_VOID;
|
2023-07-12 13:27:26 +10:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
static JSObject *
|
2018-09-08 18:08:48 +08:00
|
|
|
ToXMLName(JSContext *cx, jsval v, jsid *funidp)
|
|
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSAtom *atomizedName;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSString *name;
|
|
|
|
|
JSObject *obj;
|
2025-03-19 21:25:58 +10:00
|
|
|
Class *clasp;
|
2018-09-08 18:08:48 +08:00
|
|
|
uint32 index;
|
|
|
|
|
|
|
|
|
|
if (JSVAL_IS_STRING(v)) {
|
|
|
|
|
name = JSVAL_TO_STRING(v);
|
|
|
|
|
} else {
|
|
|
|
|
if (JSVAL_IS_PRIMITIVE(v)) {
|
2025-03-19 21:25:58 +10:00
|
|
|
ReportBadXMLName(cx, Valueify(v));
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obj = JSVAL_TO_OBJECT(v);
|
2025-02-05 12:40:54 +10:00
|
|
|
clasp = obj->getClass();
|
2025-03-19 21:25:58 +10:00
|
|
|
if (clasp == &js_AttributeNameClass || clasp == &js_QNameClass)
|
2018-09-08 18:08:48 +08:00
|
|
|
goto out;
|
|
|
|
|
if (clasp == &js_AnyNameClass) {
|
|
|
|
|
name = ATOM_TO_STRING(cx->runtime->atomState.starAtom);
|
|
|
|
|
goto construct;
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
name = js_ValueToString(cx, Valueify(v));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!name)
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
atomizedName = js_AtomizeString(cx, name, 0);
|
|
|
|
|
if (!atomizedName)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
/*
|
|
|
|
|
* ECMA-357 10.6.1 step 1 seems to be incorrect. The spec says:
|
|
|
|
|
*
|
|
|
|
|
* 1. If ToString(ToNumber(P)) == ToString(P), throw a TypeError exception
|
|
|
|
|
*
|
|
|
|
|
* First, _P_ should be _s_, to refer to the given string.
|
|
|
|
|
*
|
|
|
|
|
* Second, why does ToXMLName applied to the string type throw TypeError
|
|
|
|
|
* only for numeric literals without any leading or trailing whitespace?
|
|
|
|
|
*
|
|
|
|
|
* If the idea is to reject uint32 property names, then the check needs to
|
|
|
|
|
* be stricter, to exclude hexadecimal and floating point literals.
|
|
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
if (js_IdIsIndex(ATOM_TO_JSID(atomizedName), &index))
|
2018-09-08 18:08:48 +08:00
|
|
|
goto bad;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (*atomizedName->chars() == '@') {
|
2025-02-05 12:40:54 +10:00
|
|
|
name = js_NewDependentString(cx, name, 1, name->length() - 1);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!name)
|
|
|
|
|
return NULL;
|
2025-03-19 21:25:58 +10:00
|
|
|
*funidp = JSID_VOID;
|
2018-09-08 18:08:48 +08:00
|
|
|
return ToAttributeName(cx, STRING_TO_JSVAL(name));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
construct:
|
|
|
|
|
v = STRING_TO_JSVAL(name);
|
2025-03-19 21:25:58 +10:00
|
|
|
obj = js_ConstructObject(cx, &js_QNameClass, NULL, NULL, 1, Valueify(&v));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!obj)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
out:
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!IsFunctionQName(cx, obj, funidp))
|
2023-07-12 13:27:26 +10:00
|
|
|
return NULL;
|
2025-02-03 12:35:24 +10:00
|
|
|
return obj;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
bad:
|
2025-03-19 21:25:58 +10:00
|
|
|
JSAutoByteString bytes;
|
|
|
|
|
if (js_ValueToPrintable(cx, StringValue(name), &bytes))
|
|
|
|
|
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_XML_NAME, bytes.ptr());
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ECMA-357 9.1.1.13 XML [[AddInScopeNamespace]]. */
|
|
|
|
|
static JSBool
|
2025-02-03 12:35:24 +10:00
|
|
|
AddInScopeNamespace(JSContext *cx, JSXML *xml, JSObject *ns)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *prefix, *prefix2;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *match, *ns2;
|
2018-09-08 18:08:48 +08:00
|
|
|
uint32 i, n, m;
|
|
|
|
|
|
|
|
|
|
if (xml->xml_class != JSXML_CLASS_ELEMENT)
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
|
|
|
|
|
/* NULL means *undefined* here -- see ECMA-357 9.1.1.13 step 2. */
|
2025-03-19 21:25:58 +10:00
|
|
|
prefix = ns->getNamePrefix();
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!prefix) {
|
2018-09-08 18:08:48 +08:00
|
|
|
match = NULL;
|
|
|
|
|
for (i = 0, n = xml->xml_namespaces.length; i < n; i++) {
|
2025-02-03 12:35:24 +10:00
|
|
|
ns2 = XMLARRAY_MEMBER(&xml->xml_namespaces, i, JSObject);
|
2025-03-19 21:25:58 +10:00
|
|
|
if (ns2 && EqualStrings(ns2->getNameURI(), ns->getNameURI())) {
|
2018-09-08 18:08:48 +08:00
|
|
|
match = ns2;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!match && !XMLARRAY_ADD_MEMBER(cx, &xml->xml_namespaces, n, ns))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (prefix->empty() && xml->name->getNameURI()->empty())
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
match = NULL;
|
|
|
|
|
#ifdef __GNUC__ /* suppress bogus gcc warnings */
|
|
|
|
|
m = XML_NOT_FOUND;
|
|
|
|
|
#endif
|
|
|
|
|
for (i = 0, n = xml->xml_namespaces.length; i < n; i++) {
|
2025-02-03 12:35:24 +10:00
|
|
|
ns2 = XMLARRAY_MEMBER(&xml->xml_namespaces, i, JSObject);
|
2025-03-19 21:25:58 +10:00
|
|
|
if (ns2 && (prefix2 = ns2->getNamePrefix()) &&
|
|
|
|
|
EqualStrings(prefix2, prefix)) {
|
2018-09-08 18:08:48 +08:00
|
|
|
match = ns2;
|
|
|
|
|
m = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
if (match && !EqualStrings(match->getNameURI(), ns->getNameURI())) {
|
2018-09-08 18:08:48 +08:00
|
|
|
ns2 = XMLARRAY_DELETE(cx, &xml->xml_namespaces, m, JS_TRUE,
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject);
|
2018-09-08 18:08:48 +08:00
|
|
|
JS_ASSERT(ns2 == match);
|
2025-03-19 21:25:58 +10:00
|
|
|
match->clearNamePrefix();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!AddInScopeNamespace(cx, xml, match))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (!XMLARRAY_APPEND(cx, &xml->xml_namespaces, ns))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* OPTION: enforce that descendants have superset namespaces. */
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ECMA-357 9.2.1.6 XMLList [[Append]]. */
|
|
|
|
|
static JSBool
|
|
|
|
|
Append(JSContext *cx, JSXML *list, JSXML *xml)
|
|
|
|
|
{
|
|
|
|
|
uint32 i, j, k, n;
|
|
|
|
|
JSXML *kid;
|
|
|
|
|
|
|
|
|
|
JS_ASSERT(list->xml_class == JSXML_CLASS_LIST);
|
|
|
|
|
i = list->xml_kids.length;
|
|
|
|
|
n = 1;
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
list->xml_target = xml->xml_target;
|
|
|
|
|
list->xml_targetprop = xml->xml_targetprop;
|
|
|
|
|
n = JSXML_LENGTH(xml);
|
|
|
|
|
k = i + n;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!list->xml_kids.setCapacity(cx, k))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
for (j = 0; j < n; j++) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, j, JSXML);
|
|
|
|
|
if (kid)
|
|
|
|
|
XMLARRAY_SET_MEMBER(&list->xml_kids, i + j, kid);
|
|
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list->xml_target = xml->parent;
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_PROCESSING_INSTRUCTION)
|
|
|
|
|
list->xml_targetprop = NULL;
|
|
|
|
|
else
|
|
|
|
|
list->xml_targetprop = xml->name;
|
|
|
|
|
if (!XMLARRAY_ADD_MEMBER(cx, &list->xml_kids, i, xml))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ECMA-357 9.1.1.7 XML [[DeepCopy]] and 9.2.1.7 XMLList [[DeepCopy]]. */
|
|
|
|
|
static JSXML *
|
|
|
|
|
DeepCopyInLRS(JSContext *cx, JSXML *xml, uintN flags);
|
|
|
|
|
|
|
|
|
|
static JSXML *
|
|
|
|
|
DeepCopy(JSContext *cx, JSXML *xml, JSObject *obj, uintN flags)
|
|
|
|
|
{
|
|
|
|
|
JSXML *copy;
|
|
|
|
|
|
|
|
|
|
/* Our caller may not be protecting newborns with a local root scope. */
|
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_EnterLocalRootScope(cx))
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
copy = DeepCopyInLRS(cx, xml, flags);
|
|
|
|
|
if (copy) {
|
|
|
|
|
if (obj) {
|
|
|
|
|
/* Caller provided the object for this copy, hook 'em up. */
|
2025-02-05 12:40:54 +10:00
|
|
|
obj->setPrivate(copy);
|
|
|
|
|
copy->object = obj;
|
|
|
|
|
} else if (!js_GetXMLObject(cx, copy)) {
|
2018-09-08 18:08:48 +08:00
|
|
|
copy = NULL;
|
2025-02-05 12:40:54 +10:00
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
js_LeaveLocalRootScopeWithResult(cx, copy);
|
2018-09-08 18:08:48 +08:00
|
|
|
return copy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* (i) We must be in a local root scope (InLRS).
|
|
|
|
|
* (ii) parent must have a rooted object.
|
|
|
|
|
* (iii) from's owning object must be locked if not thread-local.
|
|
|
|
|
*/
|
|
|
|
|
static JSBool
|
|
|
|
|
DeepCopySetInLRS(JSContext *cx, JSXMLArray *from, JSXMLArray *to, JSXML *parent,
|
|
|
|
|
uintN flags)
|
|
|
|
|
{
|
|
|
|
|
uint32 j, n;
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXML *kid2;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSString *str;
|
|
|
|
|
|
|
|
|
|
n = from->length;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!to->setCapacity(cx, n))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXMLArrayCursor cursor(from);
|
2018-09-08 18:08:48 +08:00
|
|
|
j = 0;
|
2025-02-05 12:40:54 +10:00
|
|
|
while (JSXML *kid = (JSXML *) cursor.getNext()) {
|
2018-09-08 18:08:48 +08:00
|
|
|
if ((flags & XSF_IGNORE_COMMENTS) &&
|
|
|
|
|
kid->xml_class == JSXML_CLASS_COMMENT) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if ((flags & XSF_IGNORE_PROCESSING_INSTRUCTIONS) &&
|
|
|
|
|
kid->xml_class == JSXML_CLASS_PROCESSING_INSTRUCTION) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if ((flags & XSF_IGNORE_WHITESPACE) &&
|
|
|
|
|
(kid->xml_flags & XMLF_WHITESPACE_TEXT)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
kid2 = DeepCopyInLRS(cx, kid, flags);
|
|
|
|
|
if (!kid2) {
|
|
|
|
|
to->length = j;
|
2025-02-05 12:40:54 +10:00
|
|
|
return JS_FALSE;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((flags & XSF_IGNORE_WHITESPACE) &&
|
|
|
|
|
n > 1 && kid2->xml_class == JSXML_CLASS_TEXT) {
|
|
|
|
|
str = ChompXMLWhitespace(cx, kid2->xml_value);
|
|
|
|
|
if (!str) {
|
|
|
|
|
to->length = j;
|
2025-02-05 12:40:54 +10:00
|
|
|
return JS_FALSE;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
kid2->xml_value = str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XMLARRAY_SET_MEMBER(to, j, kid2);
|
|
|
|
|
++j;
|
|
|
|
|
if (parent->xml_class != JSXML_CLASS_LIST)
|
|
|
|
|
kid2->parent = parent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (j < n)
|
2025-03-19 21:25:58 +10:00
|
|
|
to->trim();
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSXML *
|
|
|
|
|
DeepCopyInLRS(JSContext *cx, JSXML *xml, uintN flags)
|
|
|
|
|
{
|
|
|
|
|
JSXML *copy;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *qn;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSBool ok;
|
|
|
|
|
uint32 i, n;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *ns, *ns2;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
JS_CHECK_RECURSION(cx, return NULL);
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
copy = js_NewXML(cx, JSXMLClass(xml->xml_class));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!copy)
|
|
|
|
|
return NULL;
|
|
|
|
|
qn = xml->name;
|
|
|
|
|
if (qn) {
|
2025-03-19 21:25:58 +10:00
|
|
|
qn = NewXMLQName(cx, qn->getNameURI(), qn->getNamePrefix(), qn->getQNameLocalName());
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!qn) {
|
|
|
|
|
ok = JS_FALSE;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
copy->name = qn;
|
|
|
|
|
copy->xml_flags = xml->xml_flags;
|
|
|
|
|
|
|
|
|
|
if (JSXML_HAS_VALUE(xml)) {
|
|
|
|
|
copy->xml_value = xml->xml_value;
|
|
|
|
|
ok = JS_TRUE;
|
|
|
|
|
} else {
|
|
|
|
|
ok = DeepCopySetInLRS(cx, &xml->xml_kids, ©->xml_kids, copy, flags);
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
copy->xml_target = xml->xml_target;
|
|
|
|
|
copy->xml_targetprop = xml->xml_targetprop;
|
|
|
|
|
} else {
|
|
|
|
|
n = xml->xml_namespaces.length;
|
2025-03-19 21:25:58 +10:00
|
|
|
ok = copy->xml_namespaces.setCapacity(cx, n);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
for (i = 0; i < n; i++) {
|
2025-02-03 12:35:24 +10:00
|
|
|
ns = XMLARRAY_MEMBER(&xml->xml_namespaces, i, JSObject);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ns)
|
|
|
|
|
continue;
|
2025-03-19 21:25:58 +10:00
|
|
|
ns2 = NewXMLNamespace(cx, ns->getNamePrefix(), ns->getNameURI(),
|
2025-02-03 12:35:24 +10:00
|
|
|
IsDeclared(ns));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ns2) {
|
|
|
|
|
copy->xml_namespaces.length = i;
|
|
|
|
|
ok = JS_FALSE;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
XMLARRAY_SET_MEMBER(©->xml_namespaces, i, ns2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ok = DeepCopySetInLRS(cx, &xml->xml_attrs, ©->xml_attrs, copy,
|
|
|
|
|
0);
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (!ok)
|
|
|
|
|
return NULL;
|
|
|
|
|
return copy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ECMA-357 9.1.1.4 XML [[DeleteByIndex]]. */
|
2023-07-12 13:27:26 +10:00
|
|
|
static void
|
|
|
|
|
DeleteByIndex(JSContext *cx, JSXML *xml, uint32 index)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSXML *kid;
|
|
|
|
|
|
|
|
|
|
if (JSXML_HAS_KIDS(xml) && index < xml->xml_kids.length) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, index, JSXML);
|
|
|
|
|
if (kid)
|
|
|
|
|
kid->parent = NULL;
|
|
|
|
|
XMLArrayDelete(cx, &xml->xml_kids, index, JS_TRUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
typedef JSBool (*JSXMLNameMatcher)(JSObject *nameqn, JSXML *xml);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
static JSBool
|
2025-02-03 12:35:24 +10:00
|
|
|
MatchAttrName(JSObject *nameqn, JSXML *attr)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *attrqn = attr->name;
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *localName = nameqn->getQNameLocalName();
|
|
|
|
|
JSLinearString *uri;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
return (IS_STAR(localName) ||
|
2025-03-19 21:25:58 +10:00
|
|
|
EqualStrings(attrqn->getQNameLocalName(), localName)) &&
|
|
|
|
|
(!(uri = nameqn->getNameURI()) ||
|
|
|
|
|
EqualStrings(attrqn->getNameURI(), uri));
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2025-02-03 12:35:24 +10:00
|
|
|
MatchElemName(JSObject *nameqn, JSXML *elem)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *localName = nameqn->getQNameLocalName();
|
|
|
|
|
JSLinearString *uri;
|
2025-02-03 12:35:24 +10:00
|
|
|
|
|
|
|
|
return (IS_STAR(localName) ||
|
2018-09-08 18:08:48 +08:00
|
|
|
(elem->xml_class == JSXML_CLASS_ELEMENT &&
|
2025-03-19 21:25:58 +10:00
|
|
|
EqualStrings(elem->name->getQNameLocalName(), localName))) &&
|
|
|
|
|
(!(uri = nameqn->getNameURI()) ||
|
2018-09-08 18:08:48 +08:00
|
|
|
(elem->xml_class == JSXML_CLASS_ELEMENT &&
|
2025-03-19 21:25:58 +10:00
|
|
|
EqualStrings(elem->name->getNameURI(), uri)));
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ECMA-357 9.1.1.8 XML [[Descendants]] and 9.2.1.8 XMLList [[Descendants]]. */
|
|
|
|
|
static JSBool
|
2025-02-03 12:35:24 +10:00
|
|
|
DescendantsHelper(JSContext *cx, JSXML *xml, JSObject *nameqn, JSXML *list)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
uint32 i, n;
|
|
|
|
|
JSXML *attr, *kid;
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
JS_CHECK_RECURSION(cx, return JS_FALSE);
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
if (xml->xml_class == JSXML_CLASS_ELEMENT &&
|
2025-02-05 12:40:54 +10:00
|
|
|
nameqn->getClass() == &js_AttributeNameClass) {
|
2018-09-08 18:08:48 +08:00
|
|
|
for (i = 0, n = xml->xml_attrs.length; i < n; i++) {
|
|
|
|
|
attr = XMLARRAY_MEMBER(&xml->xml_attrs, i, JSXML);
|
|
|
|
|
if (attr && MatchAttrName(nameqn, attr)) {
|
|
|
|
|
if (!Append(cx, list, attr))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0, n = JSXML_LENGTH(xml); i < n; i++) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
|
|
|
|
|
if (!kid)
|
|
|
|
|
continue;
|
2025-02-05 12:40:54 +10:00
|
|
|
if (nameqn->getClass() != &js_AttributeNameClass &&
|
2018-09-08 18:08:48 +08:00
|
|
|
MatchElemName(nameqn, kid)) {
|
|
|
|
|
if (!Append(cx, list, kid))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (!DescendantsHelper(cx, kid, nameqn, list))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSXML *
|
|
|
|
|
Descendants(JSContext *cx, JSXML *xml, jsval id)
|
|
|
|
|
{
|
|
|
|
|
jsid funid;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *nameqn;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSObject *listobj;
|
|
|
|
|
JSXML *list, *kid;
|
|
|
|
|
uint32 i, n;
|
|
|
|
|
JSBool ok;
|
|
|
|
|
|
|
|
|
|
nameqn = ToXMLName(cx, id, &funid);
|
|
|
|
|
if (!nameqn)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
|
|
|
|
|
if (!listobj)
|
|
|
|
|
return NULL;
|
2025-02-05 12:40:54 +10:00
|
|
|
list = (JSXML *) listobj->getPrivate();
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!JSID_IS_VOID(funid))
|
2018-09-08 18:08:48 +08:00
|
|
|
return list;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Protect nameqn's object and strings from GC by linking list to it
|
2025-02-05 12:40:54 +10:00
|
|
|
* temporarily. The newborn GC root for the last allocated object
|
|
|
|
|
* protects listobj, which protects list. Any other object allocations
|
|
|
|
|
* occurring beneath DescendantsHelper use local roots.
|
2018-09-08 18:08:48 +08:00
|
|
|
*/
|
|
|
|
|
list->name = nameqn;
|
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_EnterLocalRootScope(cx))
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
ok = JS_TRUE;
|
|
|
|
|
for (i = 0, n = xml->xml_kids.length; i < n; i++) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
|
|
|
|
|
if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) {
|
|
|
|
|
ok = DescendantsHelper(cx, kid, nameqn, list);
|
|
|
|
|
if (!ok)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ok = DescendantsHelper(cx, xml, nameqn, list);
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
js_LeaveLocalRootScopeWithResult(cx, list);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ok)
|
|
|
|
|
return NULL;
|
|
|
|
|
list->name = NULL;
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Recursive (JSXML *) parameterized version of Equals. */
|
|
|
|
|
static JSBool
|
|
|
|
|
XMLEquals(JSContext *cx, JSXML *xml, JSXML *vxml, JSBool *bp)
|
|
|
|
|
{
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *qn, *vqn;
|
2018-09-08 18:08:48 +08:00
|
|
|
uint32 i, j, n;
|
|
|
|
|
JSXML *kid, *vkid, *attr, *vattr;
|
|
|
|
|
JSObject *xobj, *vobj;
|
|
|
|
|
|
|
|
|
|
retry:
|
|
|
|
|
if (xml->xml_class != vxml->xml_class) {
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST && xml->xml_kids.length == 1) {
|
|
|
|
|
xml = XMLARRAY_MEMBER(&xml->xml_kids, 0, JSXML);
|
|
|
|
|
if (xml)
|
|
|
|
|
goto retry;
|
|
|
|
|
}
|
|
|
|
|
if (vxml->xml_class == JSXML_CLASS_LIST && vxml->xml_kids.length == 1) {
|
|
|
|
|
vxml = XMLARRAY_MEMBER(&vxml->xml_kids, 0, JSXML);
|
|
|
|
|
if (vxml)
|
|
|
|
|
goto retry;
|
|
|
|
|
}
|
|
|
|
|
*bp = JS_FALSE;
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qn = xml->name;
|
|
|
|
|
vqn = vxml->name;
|
|
|
|
|
if (qn) {
|
|
|
|
|
*bp = vqn &&
|
2025-03-19 21:25:58 +10:00
|
|
|
EqualStrings(qn->getQNameLocalName(), vqn->getQNameLocalName()) &&
|
|
|
|
|
EqualStrings(qn->getNameURI(), vqn->getNameURI());
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
|
|
|
|
*bp = vqn == NULL;
|
|
|
|
|
}
|
|
|
|
|
if (!*bp)
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
|
|
|
|
|
if (JSXML_HAS_VALUE(xml)) {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!EqualStrings(cx, xml->xml_value, vxml->xml_value, bp))
|
|
|
|
|
return JS_FALSE;
|
2018-09-08 18:08:48 +08:00
|
|
|
} else if (xml->xml_kids.length != vxml->xml_kids.length) {
|
|
|
|
|
*bp = JS_FALSE;
|
|
|
|
|
} else {
|
2025-02-05 12:40:54 +10:00
|
|
|
{
|
|
|
|
|
JSXMLArrayCursor cursor(&xml->xml_kids);
|
|
|
|
|
JSXMLArrayCursor vcursor(&vxml->xml_kids);
|
|
|
|
|
for (;;) {
|
|
|
|
|
kid = (JSXML *) cursor.getNext();
|
|
|
|
|
vkid = (JSXML *) vcursor.getNext();
|
|
|
|
|
if (!kid || !vkid) {
|
|
|
|
|
*bp = !kid && !vkid;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
xobj = js_GetXMLObject(cx, kid);
|
|
|
|
|
vobj = js_GetXMLObject(cx, vkid);
|
|
|
|
|
if (!xobj || !vobj ||
|
2025-03-19 21:25:58 +10:00
|
|
|
!js_TestXMLEquality(cx, ObjectValue(*xobj), ObjectValue(*vobj), bp))
|
2025-02-05 12:40:54 +10:00
|
|
|
return JS_FALSE;
|
|
|
|
|
if (!*bp)
|
|
|
|
|
break;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*bp && xml->xml_class == JSXML_CLASS_ELEMENT) {
|
|
|
|
|
n = xml->xml_attrs.length;
|
|
|
|
|
if (n != vxml->xml_attrs.length)
|
|
|
|
|
*bp = JS_FALSE;
|
|
|
|
|
for (i = 0; *bp && i < n; i++) {
|
|
|
|
|
attr = XMLARRAY_MEMBER(&xml->xml_attrs, i, JSXML);
|
|
|
|
|
if (!attr)
|
|
|
|
|
continue;
|
|
|
|
|
j = XMLARRAY_FIND_MEMBER(&vxml->xml_attrs, attr, attr_identity);
|
|
|
|
|
if (j == XML_NOT_FOUND) {
|
|
|
|
|
*bp = JS_FALSE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
vattr = XMLARRAY_MEMBER(&vxml->xml_attrs, j, JSXML);
|
|
|
|
|
if (!vattr)
|
|
|
|
|
continue;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!EqualStrings(cx, attr->xml_value, vattr->xml_value, bp))
|
|
|
|
|
return JS_FALSE;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ECMA-357 9.1.1.9 XML [[Equals]] and 9.2.1.9 XMLList [[Equals]]. */
|
|
|
|
|
static JSBool
|
|
|
|
|
Equals(JSContext *cx, JSXML *xml, jsval v, JSBool *bp)
|
|
|
|
|
{
|
|
|
|
|
JSObject *vobj;
|
|
|
|
|
JSXML *vxml;
|
|
|
|
|
|
|
|
|
|
if (JSVAL_IS_PRIMITIVE(v)) {
|
|
|
|
|
*bp = JS_FALSE;
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
if (xml->xml_kids.length == 1) {
|
|
|
|
|
vxml = XMLARRAY_MEMBER(&xml->xml_kids, 0, JSXML);
|
|
|
|
|
if (!vxml)
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
vobj = js_GetXMLObject(cx, vxml);
|
|
|
|
|
if (!vobj)
|
|
|
|
|
return JS_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
return js_TestXMLEquality(cx, ObjectValue(*vobj), Valueify(v), bp);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
if (JSVAL_IS_VOID(v) && xml->xml_kids.length == 0)
|
|
|
|
|
*bp = JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
vobj = JSVAL_TO_OBJECT(v);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!vobj->isXML()) {
|
2018-09-08 18:08:48 +08:00
|
|
|
*bp = JS_FALSE;
|
|
|
|
|
} else {
|
2025-02-05 12:40:54 +10:00
|
|
|
vxml = (JSXML *) vobj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!XMLEquals(cx, xml, vxml, bp))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
CheckCycle(JSContext *cx, JSXML *xml, JSXML *kid)
|
|
|
|
|
{
|
|
|
|
|
JS_ASSERT(kid->xml_class != JSXML_CLASS_LIST);
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
if (xml == kid) {
|
|
|
|
|
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
|
|
|
|
JSMSG_CYCLIC_VALUE, js_XML_str);
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
} while ((xml = xml->parent) != NULL);
|
|
|
|
|
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ECMA-357 9.1.1.11 XML [[Insert]]. */
|
|
|
|
|
static JSBool
|
|
|
|
|
Insert(JSContext *cx, JSXML *xml, uint32 i, jsval v)
|
|
|
|
|
{
|
|
|
|
|
uint32 j, n;
|
|
|
|
|
JSXML *vxml, *kid;
|
|
|
|
|
JSObject *vobj;
|
|
|
|
|
JSString *str;
|
|
|
|
|
|
|
|
|
|
if (!JSXML_HAS_KIDS(xml))
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
|
|
|
|
|
n = 1;
|
|
|
|
|
vxml = NULL;
|
|
|
|
|
if (!JSVAL_IS_PRIMITIVE(v)) {
|
|
|
|
|
vobj = JSVAL_TO_OBJECT(v);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (vobj->isXML()) {
|
|
|
|
|
vxml = (JSXML *) vobj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (vxml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
n = vxml->xml_kids.length;
|
|
|
|
|
if (n == 0)
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
for (j = 0; j < n; j++) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&vxml->xml_kids, j, JSXML);
|
|
|
|
|
if (!kid)
|
|
|
|
|
continue;
|
|
|
|
|
if (!CheckCycle(cx, xml, kid))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
} else if (vxml->xml_class == JSXML_CLASS_ELEMENT) {
|
|
|
|
|
/* OPTION: enforce that descendants have superset namespaces. */
|
|
|
|
|
if (!CheckCycle(cx, xml, vxml))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!vxml) {
|
2025-03-19 21:25:58 +10:00
|
|
|
str = js_ValueToString(cx, Valueify(v));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!str)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
vxml = js_NewXML(cx, JSXML_CLASS_TEXT);
|
|
|
|
|
if (!vxml)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
vxml->xml_value = str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (i > xml->xml_kids.length)
|
|
|
|
|
i = xml->xml_kids.length;
|
|
|
|
|
|
|
|
|
|
if (!XMLArrayInsert(cx, &xml->xml_kids, i, n))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
if (vxml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
for (j = 0; j < n; j++) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&vxml->xml_kids, j, JSXML);
|
|
|
|
|
if (!kid)
|
|
|
|
|
continue;
|
|
|
|
|
kid->parent = xml;
|
|
|
|
|
XMLARRAY_SET_MEMBER(&xml->xml_kids, i + j, kid);
|
|
|
|
|
|
|
|
|
|
/* OPTION: enforce that descendants have superset namespaces. */
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
vxml->parent = xml;
|
|
|
|
|
XMLARRAY_SET_MEMBER(&xml->xml_kids, i, vxml);
|
|
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
IndexToId(JSContext *cx, uint32 index, jsid *idp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSAtom *atom;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSString *str;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (index <= JSID_INT_MAX) {
|
|
|
|
|
*idp = INT_TO_JSID(index);
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
|
|
|
|
str = js_NumberToString(cx, (jsdouble) index);
|
|
|
|
|
if (!str)
|
|
|
|
|
return JS_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
atom = js_AtomizeString(cx, str, 0);
|
|
|
|
|
if (!atom)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
*idp = ATOM_TO_JSID(atom);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ECMA-357 9.1.1.12 XML [[Replace]]. */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
Replace(JSContext *cx, JSXML *xml, uint32 i, jsval v)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
uint32 n;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSXML *vxml, *kid;
|
|
|
|
|
JSObject *vobj;
|
|
|
|
|
JSString *str;
|
|
|
|
|
|
|
|
|
|
if (!JSXML_HAS_KIDS(xml))
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 9.1.1.12
|
|
|
|
|
* [[Replace]] handles _i >= x.[[Length]]_ by incrementing _x.[[Length]_.
|
|
|
|
|
* It should therefore constrain callers to pass in _i <= x.[[Length]]_.
|
|
|
|
|
*/
|
|
|
|
|
n = xml->xml_kids.length;
|
2023-07-12 13:27:26 +10:00
|
|
|
if (i > n)
|
2018-09-08 18:08:48 +08:00
|
|
|
i = n;
|
|
|
|
|
|
|
|
|
|
vxml = NULL;
|
|
|
|
|
if (!JSVAL_IS_PRIMITIVE(v)) {
|
|
|
|
|
vobj = JSVAL_TO_OBJECT(v);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (vobj->isXML())
|
|
|
|
|
vxml = (JSXML *) vobj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
switch (vxml ? JSXMLClass(vxml->xml_class) : JSXML_CLASS_LIMIT) {
|
2018-09-08 18:08:48 +08:00
|
|
|
case JSXML_CLASS_ELEMENT:
|
|
|
|
|
/* OPTION: enforce that descendants have superset namespaces. */
|
|
|
|
|
if (!CheckCycle(cx, xml, vxml))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
case JSXML_CLASS_COMMENT:
|
|
|
|
|
case JSXML_CLASS_PROCESSING_INSTRUCTION:
|
|
|
|
|
case JSXML_CLASS_TEXT:
|
|
|
|
|
goto do_replace;
|
|
|
|
|
|
|
|
|
|
case JSXML_CLASS_LIST:
|
2023-07-12 13:27:26 +10:00
|
|
|
if (i < n)
|
|
|
|
|
DeleteByIndex(cx, xml, i);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!Insert(cx, xml, i, v))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2025-03-19 21:25:58 +10:00
|
|
|
str = js_ValueToString(cx, Valueify(v));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!str)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
vxml = js_NewXML(cx, JSXML_CLASS_TEXT);
|
|
|
|
|
if (!vxml)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
vxml->xml_value = str;
|
|
|
|
|
|
|
|
|
|
do_replace:
|
|
|
|
|
vxml->parent = xml;
|
|
|
|
|
if (i < n) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
|
|
|
|
|
if (kid)
|
|
|
|
|
kid->parent = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (!XMLARRAY_ADD_MEMBER(cx, &xml->xml_kids, i, vxml))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/* ECMA-357 9.1.1.3 XML [[Delete]], 9.2.1.3 XML [[Delete]] qname cases. */
|
|
|
|
|
static void
|
2025-02-03 12:35:24 +10:00
|
|
|
DeleteNamedProperty(JSContext *cx, JSXML *xml, JSObject *nameqn,
|
2023-07-12 13:27:26 +10:00
|
|
|
JSBool attributes)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSXMLArray *array;
|
2023-07-12 13:27:26 +10:00
|
|
|
uint32 index, deleteCount;
|
|
|
|
|
JSXML *kid;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSXMLNameMatcher matcher;
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
2018-09-08 18:08:48 +08:00
|
|
|
array = &xml->xml_kids;
|
2023-07-12 13:27:26 +10:00
|
|
|
for (index = 0; index < array->length; index++) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(array, index, JSXML);
|
|
|
|
|
if (kid && kid->xml_class == JSXML_CLASS_ELEMENT)
|
|
|
|
|
DeleteNamedProperty(cx, kid, nameqn, attributes);
|
|
|
|
|
}
|
|
|
|
|
} else if (xml->xml_class == JSXML_CLASS_ELEMENT) {
|
|
|
|
|
if (attributes) {
|
|
|
|
|
array = &xml->xml_attrs;
|
|
|
|
|
matcher = MatchAttrName;
|
|
|
|
|
} else {
|
|
|
|
|
array = &xml->xml_kids;
|
|
|
|
|
matcher = MatchElemName;
|
|
|
|
|
}
|
|
|
|
|
deleteCount = 0;
|
|
|
|
|
for (index = 0; index < array->length; index++) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(array, index, JSXML);
|
|
|
|
|
if (kid && matcher(nameqn, kid)) {
|
|
|
|
|
kid->parent = NULL;
|
|
|
|
|
XMLArrayDelete(cx, array, index, JS_FALSE);
|
|
|
|
|
++deleteCount;
|
|
|
|
|
} else if (deleteCount != 0) {
|
|
|
|
|
XMLARRAY_SET_MEMBER(array,
|
|
|
|
|
index - deleteCount,
|
|
|
|
|
array->vector[index]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
array->length -= deleteCount;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2023-07-12 13:27:26 +10:00
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/* ECMA-357 9.2.1.3 index case. */
|
|
|
|
|
static void
|
|
|
|
|
DeleteListElement(JSContext *cx, JSXML *xml, uint32 index)
|
|
|
|
|
{
|
|
|
|
|
JSXML *kid, *parent;
|
|
|
|
|
uint32 kidIndex;
|
|
|
|
|
|
|
|
|
|
JS_ASSERT(xml->xml_class == JSXML_CLASS_LIST);
|
|
|
|
|
|
|
|
|
|
if (index < xml->xml_kids.length) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, index, JSXML);
|
|
|
|
|
if (kid) {
|
2018-09-08 18:08:48 +08:00
|
|
|
parent = kid->parent;
|
|
|
|
|
if (parent) {
|
|
|
|
|
JS_ASSERT(parent != xml);
|
|
|
|
|
JS_ASSERT(JSXML_HAS_KIDS(parent));
|
|
|
|
|
|
|
|
|
|
if (kid->xml_class == JSXML_CLASS_ATTRIBUTE) {
|
2023-07-12 13:27:26 +10:00
|
|
|
DeleteNamedProperty(cx, parent, kid->name, JS_TRUE);
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
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
|
|
|
kidIndex = XMLARRAY_FIND_MEMBER(&parent->xml_kids, kid,
|
|
|
|
|
NULL);
|
|
|
|
|
JS_ASSERT(kidIndex != XML_NOT_FOUND);
|
2023-07-12 13:27:26 +10:00
|
|
|
DeleteByIndex(cx, parent, kidIndex);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
2023-07-12 13:27:26 +10:00
|
|
|
XMLArrayDelete(cx, &xml->xml_kids, index, JS_TRUE);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
SyncInScopeNamespaces(JSContext *cx, JSXML *xml)
|
|
|
|
|
{
|
|
|
|
|
JSXMLArray *nsarray;
|
|
|
|
|
uint32 i, n;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *ns;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
nsarray = &xml->xml_namespaces;
|
|
|
|
|
while ((xml = xml->parent) != NULL) {
|
|
|
|
|
for (i = 0, n = xml->xml_namespaces.length; i < n; i++) {
|
2025-02-03 12:35:24 +10:00
|
|
|
ns = XMLARRAY_MEMBER(&xml->xml_namespaces, i, JSObject);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (ns && !XMLARRAY_HAS_MEMBER(nsarray, ns, namespace_identity)) {
|
|
|
|
|
if (!XMLARRAY_APPEND(cx, nsarray, ns))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
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 JSBool
|
2025-02-03 12:35:24 +10:00
|
|
|
GetNamedProperty(JSContext *cx, JSXML *xml, JSObject* nameqn, JSXML *list)
|
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
|
|
|
{
|
|
|
|
|
JSXMLArray *array;
|
|
|
|
|
JSXMLNameMatcher matcher;
|
2023-07-12 13:27:26 +10:00
|
|
|
JSBool attrs;
|
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
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXMLArrayCursor cursor(&xml->xml_kids);
|
|
|
|
|
while (JSXML *kid = (JSXML *) cursor.getNext()) {
|
2023-07-12 13:27:26 +10:00
|
|
|
if (kid->xml_class == JSXML_CLASS_ELEMENT &&
|
|
|
|
|
!GetNamedProperty(cx, kid, nameqn, list)) {
|
2025-02-05 12:40:54 +10:00
|
|
|
return JS_FALSE;
|
2023-07-12 13:27:26 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (xml->xml_class == JSXML_CLASS_ELEMENT) {
|
2025-02-05 12:40:54 +10:00
|
|
|
attrs = (nameqn->getClass() == &js_AttributeNameClass);
|
2023-07-12 13:27:26 +10:00
|
|
|
if (attrs) {
|
|
|
|
|
array = &xml->xml_attrs;
|
|
|
|
|
matcher = MatchAttrName;
|
|
|
|
|
} else {
|
|
|
|
|
array = &xml->xml_kids;
|
|
|
|
|
matcher = MatchElemName;
|
|
|
|
|
}
|
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
|
|
|
JSXMLArrayCursor cursor(array);
|
|
|
|
|
while (JSXML *kid = (JSXML *) cursor.getNext()) {
|
2023-07-12 13:27:26 +10:00
|
|
|
if (matcher(nameqn, kid)) {
|
|
|
|
|
if (!attrs &&
|
|
|
|
|
kid->xml_class == JSXML_CLASS_ELEMENT &&
|
|
|
|
|
!SyncInScopeNamespaces(cx, kid)) {
|
2025-02-05 12:40:54 +10:00
|
|
|
return JS_FALSE;
|
2023-07-12 13:27:26 +10:00
|
|
|
}
|
|
|
|
|
if (!Append(cx, list, kid))
|
2025-02-05 12:40:54 +10:00
|
|
|
return JS_FALSE;
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
return JS_TRUE;
|
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
|
|
|
}
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
/* ECMA-357 9.1.1.1 XML [[Get]] and 9.2.1.1 XMLList [[Get]]. */
|
|
|
|
|
static JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSXML *xml, *list, *kid;
|
|
|
|
|
uint32 index;
|
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
|
|
|
JSObject *kidobj, *listobj;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *nameqn;
|
2018-09-08 18:08:48 +08:00
|
|
|
jsid funid;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
xml = (JSXML *) GetInstancePrivate(cx, obj, &js_XMLClass, NULL);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!xml)
|
2025-02-05 12:40:54 +10:00
|
|
|
return true;
|
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
|
|
|
if (js_IdIsIndex(id, &index)) {
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!JSXML_HAS_KIDS(xml)) {
|
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
|
|
|
*vp = (index == 0) ? OBJECT_TO_JSVAL(obj) : JSVAL_VOID;
|
|
|
|
|
} else {
|
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
|
|
|
* ECMA-357 9.2.1.1 starts here.
|
|
|
|
|
*
|
2018-09-08 18:08:48 +08:00
|
|
|
* Erratum: 9.2 is not completely clear that indexed properties
|
|
|
|
|
* correspond to kids, but that's what it seems to say, and it's
|
|
|
|
|
* what any sane user would want.
|
|
|
|
|
*/
|
|
|
|
|
if (index < xml->xml_kids.length) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, index, JSXML);
|
|
|
|
|
if (!kid) {
|
|
|
|
|
*vp = JSVAL_VOID;
|
2025-02-05 12:40:54 +10:00
|
|
|
return true;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
kidobj = js_GetXMLObject(cx, kid);
|
|
|
|
|
if (!kidobj)
|
2025-02-05 12:40:54 +10:00
|
|
|
return false;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
*vp = OBJECT_TO_JSVAL(kidobj);
|
|
|
|
|
} else {
|
|
|
|
|
*vp = JSVAL_VOID;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
return true;
|
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
|
|
|
}
|
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
|
|
|
/*
|
|
|
|
|
* ECMA-357 9.2.1.1/9.1.1.1 qname case.
|
|
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
nameqn = ToXMLName(cx, IdToJsval(id), &funid);
|
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 (!nameqn)
|
2025-02-05 12:40:54 +10:00
|
|
|
return false;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!JSID_IS_VOID(funid))
|
2025-02-05 12:40:54 +10:00
|
|
|
return GetXMLFunction(cx, obj, funid, vp);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
jsval roots[2] = { OBJECT_TO_JSVAL(nameqn), JSVAL_NULL };
|
2025-03-19 21:25:58 +10:00
|
|
|
AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(roots), Valueify(roots));
|
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
|
|
|
listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!listobj)
|
|
|
|
|
return false;
|
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
|
|
|
roots[1] = OBJECT_TO_JSVAL(listobj);
|
|
|
|
|
|
|
|
|
|
list = (JSXML *) listobj->getPrivate();
|
|
|
|
|
if (!GetNamedProperty(cx, xml, nameqn, list))
|
|
|
|
|
return false;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
/*
|
|
|
|
|
* Erratum: ECMA-357 9.1.1.1 misses that [[Append]] sets the
|
|
|
|
|
* given list's [[TargetProperty]] to the property that is being
|
|
|
|
|
* appended. This means that any use of the internal [[Get]]
|
|
|
|
|
* property returns a list which, when used by e.g. [[Insert]]
|
|
|
|
|
* duplicates the last element matched by id. See bug 336921.
|
|
|
|
|
*/
|
|
|
|
|
list->xml_target = xml;
|
|
|
|
|
list->xml_targetprop = nameqn;
|
|
|
|
|
*vp = OBJECT_TO_JSVAL(listobj);
|
|
|
|
|
return true;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSXML *
|
|
|
|
|
CopyOnWrite(JSContext *cx, JSXML *xml, JSObject *obj)
|
|
|
|
|
{
|
|
|
|
|
JS_ASSERT(xml->object != obj);
|
|
|
|
|
|
|
|
|
|
xml = DeepCopy(cx, xml, obj, 0);
|
|
|
|
|
if (!xml)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
JS_ASSERT(xml->object == obj);
|
|
|
|
|
return xml;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define CHECK_COPY_ON_WRITE(cx,xml,obj) \
|
|
|
|
|
(xml->object == obj ? xml : CopyOnWrite(cx, xml, obj))
|
|
|
|
|
|
|
|
|
|
static JSString *
|
|
|
|
|
KidToString(JSContext *cx, JSXML *xml, uint32 index)
|
|
|
|
|
{
|
|
|
|
|
JSXML *kid;
|
|
|
|
|
JSObject *kidobj;
|
|
|
|
|
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, index, JSXML);
|
|
|
|
|
if (!kid)
|
|
|
|
|
return cx->runtime->emptyString;
|
|
|
|
|
kidobj = js_GetXMLObject(cx, kid);
|
|
|
|
|
if (!kidobj)
|
|
|
|
|
return NULL;
|
2025-03-19 21:25:58 +10:00
|
|
|
return js_ValueToString(cx, ObjectValue(*kidobj));
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/* Forward declared -- its implementation uses other statics that call it. */
|
|
|
|
|
static JSBool
|
|
|
|
|
ResolveValue(JSContext *cx, JSXML *list, JSXML **result);
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
/* ECMA-357 9.1.1.2 XML [[Put]] and 9.2.1.2 XMLList [[Put]]. */
|
|
|
|
|
static JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
PutProperty(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSBool ok, primitiveAssign;
|
|
|
|
|
enum { OBJ_ROOT, ID_ROOT, VAL_ROOT };
|
|
|
|
|
JSXML *xml, *vxml, *rxml, *kid, *attr, *parent, *copy, *kid2, *match;
|
|
|
|
|
JSObject *vobj, *nameobj, *attrobj, *parentobj, *kidobj, *copyobj;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *targetprop, *nameqn, *attrqn;
|
2023-07-12 13:27:26 +10:00
|
|
|
uint32 index, i, j, k, n, q, matchIndex;
|
|
|
|
|
jsval attrval, nsval;
|
2018-09-08 18:08:48 +08:00
|
|
|
jsid funid;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *ns;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
xml = (JSXML *) GetInstancePrivate(cx, obj, &js_XMLClass, NULL);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!xml)
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
|
|
|
|
|
xml = CHECK_COPY_ON_WRITE(cx, xml, obj);
|
|
|
|
|
if (!xml)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
/* Precompute vxml for 9.2.1.2 2(c)(vii)(2-3) and 2(d) and 9.1.1.2 1. */
|
|
|
|
|
vxml = NULL;
|
|
|
|
|
if (!JSVAL_IS_PRIMITIVE(*vp)) {
|
|
|
|
|
vobj = JSVAL_TO_OBJECT(*vp);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (vobj->isXML())
|
|
|
|
|
vxml = (JSXML *) vobj->getPrivate();
|
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
|
|
|
ok = js_EnterLocalRootScope(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ok)
|
|
|
|
|
return JS_FALSE;
|
2025-02-05 12:40:54 +10:00
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
MUST_FLOW_THROUGH("out");
|
2025-02-05 12:40:54 +10:00
|
|
|
jsval roots[3];
|
2018-09-08 18:08:48 +08:00
|
|
|
roots[OBJ_ROOT] = OBJECT_TO_JSVAL(obj);
|
2025-03-19 21:25:58 +10:00
|
|
|
roots[ID_ROOT] = IdToJsval(id);
|
2018-09-08 18:08:48 +08:00
|
|
|
roots[VAL_ROOT] = *vp;
|
2025-03-19 21:25:58 +10:00
|
|
|
AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(roots), Valueify(roots));
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
if (js_IdIsIndex(id, &index)) {
|
|
|
|
|
if (xml->xml_class != JSXML_CLASS_LIST) {
|
|
|
|
|
/* See NOTE in spec: this variation is reserved for future use. */
|
2025-03-19 21:25:58 +10:00
|
|
|
ReportBadXMLName(cx, IdToValue(id));
|
2023-07-12 13:27:26 +10:00
|
|
|
goto bad;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Step 1 of ECMA-357 9.2.1.2 index case sets i to the property index.
|
|
|
|
|
*/
|
|
|
|
|
i = index;
|
|
|
|
|
|
|
|
|
|
/* 2(a-b). */
|
|
|
|
|
if (xml->xml_target) {
|
|
|
|
|
ok = ResolveValue(cx, xml->xml_target, &rxml);
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
if (!rxml)
|
|
|
|
|
goto out;
|
|
|
|
|
JS_ASSERT(rxml->object);
|
|
|
|
|
} else {
|
|
|
|
|
rxml = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 2(c). */
|
|
|
|
|
if (index >= xml->xml_kids.length) {
|
|
|
|
|
/* 2(c)(i). */
|
|
|
|
|
if (rxml) {
|
|
|
|
|
if (rxml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
if (rxml->xml_kids.length != 1)
|
|
|
|
|
goto out;
|
|
|
|
|
rxml = XMLARRAY_MEMBER(&rxml->xml_kids, 0, JSXML);
|
|
|
|
|
if (!rxml)
|
|
|
|
|
goto out;
|
|
|
|
|
ok = js_GetXMLObject(cx, rxml) != NULL;
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Erratum: ECMA-357 9.2.1.2 step 2(c)(ii) sets
|
|
|
|
|
* _y.[[Parent]] = r_ where _r_ is the result of
|
|
|
|
|
* [[ResolveValue]] called on _x.[[TargetObject]] in
|
|
|
|
|
* 2(a)(i). This can result in text parenting text:
|
|
|
|
|
*
|
|
|
|
|
* var MYXML = new XML();
|
|
|
|
|
* MYXML.appendChild(new XML("<TEAM>Giants</TEAM>"));
|
|
|
|
|
*
|
|
|
|
|
* (testcase from Werner Sharp <wsharp@macromedia.com>).
|
|
|
|
|
*
|
|
|
|
|
* To match insertChildAfter, insertChildBefore,
|
|
|
|
|
* prependChild, and setChildren, we should silently
|
|
|
|
|
* do nothing in this case.
|
|
|
|
|
*/
|
|
|
|
|
if (!JSXML_HAS_KIDS(rxml))
|
2018-09-08 18:08:48 +08:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/* 2(c)(ii) is distributed below as several js_NewXML calls. */
|
|
|
|
|
targetprop = xml->xml_targetprop;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!targetprop || IS_STAR(targetprop->getQNameLocalName())) {
|
2023-07-12 13:27:26 +10:00
|
|
|
/* 2(c)(iv)(1-2), out of order w.r.t. 2(c)(iii). */
|
|
|
|
|
kid = js_NewXML(cx, JSXML_CLASS_TEXT);
|
|
|
|
|
if (!kid)
|
|
|
|
|
goto bad;
|
|
|
|
|
} else {
|
2025-02-03 12:35:24 +10:00
|
|
|
nameobj = targetprop;
|
2025-02-05 12:40:54 +10:00
|
|
|
if (nameobj->getClass() == &js_AttributeNameClass) {
|
2018-09-08 18:08:48 +08:00
|
|
|
/*
|
2023-07-12 13:27:26 +10:00
|
|
|
* 2(c)(iii)(1-3).
|
|
|
|
|
* Note that rxml can't be null here, because target
|
|
|
|
|
* and targetprop are non-null.
|
2018-09-08 18:08:48 +08:00
|
|
|
*/
|
2023-07-12 13:27:26 +10:00
|
|
|
ok = GetProperty(cx, rxml->object, id, &attrval);
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
if (JSVAL_IS_PRIMITIVE(attrval)) /* no such attribute */
|
|
|
|
|
goto out;
|
|
|
|
|
attrobj = JSVAL_TO_OBJECT(attrval);
|
2025-02-05 12:40:54 +10:00
|
|
|
attr = (JSXML *) attrobj->getPrivate();
|
2023-07-12 13:27:26 +10:00
|
|
|
if (JSXML_LENGTH(attr) != 0)
|
2018-09-08 18:08:48 +08:00
|
|
|
goto out;
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
kid = js_NewXML(cx, JSXML_CLASS_ATTRIBUTE);
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
2023-07-12 13:27:26 +10:00
|
|
|
/* 2(c)(v). */
|
|
|
|
|
kid = js_NewXML(cx, JSXML_CLASS_ELEMENT);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!kid)
|
|
|
|
|
goto bad;
|
|
|
|
|
|
|
|
|
|
/* An important bit of 2(c)(ii). */
|
|
|
|
|
kid->name = targetprop;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/* Final important bit of 2(c)(ii). */
|
|
|
|
|
kid->parent = rxml;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/* 2(c)(vi-vii). */
|
|
|
|
|
i = xml->xml_kids.length;
|
|
|
|
|
if (kid->xml_class != JSXML_CLASS_ATTRIBUTE) {
|
|
|
|
|
/*
|
|
|
|
|
* 2(c)(vii)(1) tests whether _y.[[Parent]]_ is not null.
|
|
|
|
|
* y.[[Parent]] is here called kid->parent, which we know
|
|
|
|
|
* from 2(c)(ii) is _r_, here called rxml. So let's just
|
|
|
|
|
* test that! Erratum, the spec should be simpler here.
|
|
|
|
|
*/
|
|
|
|
|
if (rxml) {
|
|
|
|
|
JS_ASSERT(JSXML_HAS_KIDS(rxml));
|
|
|
|
|
n = rxml->xml_kids.length;
|
|
|
|
|
j = n - 1;
|
|
|
|
|
if (n != 0 && i != 0) {
|
|
|
|
|
for (n = j, j = 0; j < n; j++) {
|
|
|
|
|
if (rxml->xml_kids.vector[j] ==
|
|
|
|
|
xml->xml_kids.vector[i-1]) {
|
|
|
|
|
break;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
kidobj = js_GetXMLObject(cx, kid);
|
|
|
|
|
if (!kidobj)
|
|
|
|
|
goto bad;
|
|
|
|
|
ok = Insert(cx, rxml, j + 1, OBJECT_TO_JSVAL(kidobj));
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/*
|
|
|
|
|
* 2(c)(vii)(2-3).
|
|
|
|
|
* Erratum: [[PropertyName]] in 2(c)(vii)(3) must be a
|
|
|
|
|
* typo for [[TargetProperty]].
|
|
|
|
|
*/
|
|
|
|
|
if (vxml) {
|
|
|
|
|
kid->name = (vxml->xml_class == JSXML_CLASS_LIST)
|
|
|
|
|
? vxml->xml_targetprop
|
|
|
|
|
: vxml->name;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/* 2(c)(viii). */
|
|
|
|
|
ok = Append(cx, xml, kid);
|
|
|
|
|
if (!ok)
|
2018-09-08 18:08:48 +08:00
|
|
|
goto out;
|
2023-07-12 13:27:26 +10:00
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/* 2(d). */
|
|
|
|
|
if (!vxml ||
|
|
|
|
|
vxml->xml_class == JSXML_CLASS_TEXT ||
|
|
|
|
|
vxml->xml_class == JSXML_CLASS_ATTRIBUTE) {
|
|
|
|
|
ok = JS_ConvertValue(cx, *vp, JSTYPE_STRING, vp);
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
roots[VAL_ROOT] = *vp;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/* 2(e). */
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
|
|
|
|
|
if (!kid)
|
|
|
|
|
goto out;
|
|
|
|
|
parent = kid->parent;
|
|
|
|
|
if (kid->xml_class == JSXML_CLASS_ATTRIBUTE) {
|
2025-02-03 12:35:24 +10:00
|
|
|
nameobj = kid->name;
|
2025-02-05 12:40:54 +10:00
|
|
|
if (nameobj->getClass() != &js_AttributeNameClass) {
|
2025-03-19 21:25:58 +10:00
|
|
|
nameobj = NewXMLAttributeName(cx, nameobj->getNameURI(), nameobj->getNamePrefix(),
|
|
|
|
|
nameobj->getQNameLocalName());
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!nameobj)
|
|
|
|
|
goto bad;
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
id = OBJECT_TO_JSID(nameobj);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
if (parent) {
|
|
|
|
|
/* 2(e)(i). */
|
|
|
|
|
parentobj = js_GetXMLObject(cx, parent);
|
|
|
|
|
if (!parentobj)
|
2018-09-08 18:08:48 +08:00
|
|
|
goto bad;
|
2025-03-19 21:25:58 +10:00
|
|
|
ok = PutProperty(cx, parentobj, id, strict, vp);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/* 2(e)(ii). */
|
|
|
|
|
ok = GetProperty(cx, parentobj, id, vp);
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
2025-02-05 12:40:54 +10:00
|
|
|
attr = (JSXML *) JSVAL_TO_OBJECT(*vp)->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
/* 2(e)(iii) - the length check comes from the bug 375406. */
|
|
|
|
|
if (attr->xml_kids.length != 0)
|
|
|
|
|
xml->xml_kids.vector[i] = attr->xml_kids.vector[0];
|
2023-07-12 13:27:26 +10:00
|
|
|
}
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/* 2(f). */
|
|
|
|
|
else if (vxml && vxml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
/*
|
|
|
|
|
* 2(f)(i)
|
|
|
|
|
*
|
|
|
|
|
* Erratum: the spec says to create a shallow copy _c_ of _V_, but
|
|
|
|
|
* if we do that we never change the parent of each child in the
|
|
|
|
|
* list. Since [[Put]] when called on an XML object deeply copies
|
|
|
|
|
* the provided list _V_, we also do so here. Perhaps the shallow
|
|
|
|
|
* copy was a misguided optimization?
|
|
|
|
|
*/
|
|
|
|
|
copy = DeepCopyInLRS(cx, vxml, 0);
|
|
|
|
|
if (!copy)
|
|
|
|
|
goto bad;
|
|
|
|
|
copyobj = js_GetXMLObject(cx, copy);
|
|
|
|
|
if (!copyobj)
|
|
|
|
|
goto bad;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
JS_ASSERT(parent != xml);
|
|
|
|
|
if (parent) {
|
|
|
|
|
q = XMLARRAY_FIND_MEMBER(&parent->xml_kids, kid, NULL);
|
|
|
|
|
JS_ASSERT(q != XML_NOT_FOUND);
|
|
|
|
|
ok = Replace(cx, parent, q, OBJECT_TO_JSVAL(copyobj));
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
#ifdef DEBUG
|
|
|
|
|
/* Erratum: this loop in the spec is useless. */
|
|
|
|
|
for (j = 0, n = copy->xml_kids.length; j < n; j++) {
|
|
|
|
|
kid2 = XMLARRAY_MEMBER(&parent->xml_kids, q + j, JSXML);
|
|
|
|
|
JS_ASSERT(XMLARRAY_MEMBER(©->xml_kids, j, JSXML)
|
|
|
|
|
== kid2);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2023-07-12 13:27:26 +10:00
|
|
|
#endif
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/*
|
|
|
|
|
* 2(f)(iv-vi).
|
|
|
|
|
* Erratum: notice the unhandled zero-length V basis case and
|
|
|
|
|
* the off-by-one errors for the n != 0 cases in the spec.
|
|
|
|
|
*/
|
|
|
|
|
n = copy->xml_kids.length;
|
|
|
|
|
if (n == 0) {
|
|
|
|
|
XMLArrayDelete(cx, &xml->xml_kids, i, JS_TRUE);
|
|
|
|
|
} else {
|
|
|
|
|
ok = XMLArrayInsert(cx, &xml->xml_kids, i + 1, n - 1);
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
for (j = 0; j < n; j++)
|
|
|
|
|
xml->xml_kids.vector[i + j] = copy->xml_kids.vector[j];
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/* 2(g). */
|
|
|
|
|
else if (vxml || JSXML_HAS_VALUE(kid)) {
|
|
|
|
|
if (parent) {
|
|
|
|
|
q = XMLARRAY_FIND_MEMBER(&parent->xml_kids, kid, NULL);
|
|
|
|
|
JS_ASSERT(q != XML_NOT_FOUND);
|
|
|
|
|
ok = Replace(cx, parent, q, *vp);
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
vxml = XMLARRAY_MEMBER(&parent->xml_kids, q, JSXML);
|
|
|
|
|
if (!vxml)
|
|
|
|
|
goto out;
|
|
|
|
|
roots[VAL_ROOT] = *vp = OBJECT_TO_JSVAL(vxml->object);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/*
|
|
|
|
|
* 2(g)(iii).
|
|
|
|
|
* Erratum: _V_ may not be of type XML, but all index-named
|
|
|
|
|
* properties _x[i]_ in an XMLList _x_ must be of type XML,
|
|
|
|
|
* according to 9.2.1.1 Overview and other places in the spec.
|
|
|
|
|
*
|
|
|
|
|
* Thanks to 2(d), we know _V_ (*vp here) is either a string
|
|
|
|
|
* or an XML/XMLList object. If *vp is a string, call ToXML
|
|
|
|
|
* on it to satisfy the constraint.
|
|
|
|
|
*/
|
|
|
|
|
if (!vxml) {
|
|
|
|
|
JS_ASSERT(JSVAL_IS_STRING(*vp));
|
|
|
|
|
vobj = ToXML(cx, *vp);
|
|
|
|
|
if (!vobj)
|
2018-09-08 18:08:48 +08:00
|
|
|
goto bad;
|
2023-07-12 13:27:26 +10:00
|
|
|
roots[VAL_ROOT] = *vp = OBJECT_TO_JSVAL(vobj);
|
2025-02-05 12:40:54 +10:00
|
|
|
vxml = (JSXML *) vobj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2023-07-12 13:27:26 +10:00
|
|
|
XMLARRAY_SET_MEMBER(&xml->xml_kids, i, vxml);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 2(h). */
|
|
|
|
|
else {
|
|
|
|
|
kidobj = js_GetXMLObject(cx, kid);
|
|
|
|
|
if (!kidobj)
|
|
|
|
|
goto bad;
|
2025-03-19 21:25:58 +10:00
|
|
|
id = ATOM_TO_JSID(cx->runtime->atomState.starAtom);
|
|
|
|
|
ok = PutProperty(cx, kidobj, id, strict, vp);
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/*
|
|
|
|
|
* ECMA-357 9.2.1.2/9.1.1.2 qname case.
|
|
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
nameqn = ToXMLName(cx, IdToJsval(id), &funid);
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!nameqn)
|
|
|
|
|
goto bad;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!JSID_IS_VOID(funid)) {
|
|
|
|
|
ok = js_SetProperty(cx, obj, funid, Valueify(vp), false);
|
2023-07-12 13:27:26 +10:00
|
|
|
goto out;
|
|
|
|
|
}
|
2025-02-03 12:35:24 +10:00
|
|
|
nameobj = nameqn;
|
2023-07-12 13:27:26 +10:00
|
|
|
roots[ID_ROOT] = OBJECT_TO_JSVAL(nameobj);
|
|
|
|
|
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
2018-09-08 18:08:48 +08:00
|
|
|
/*
|
2023-07-12 13:27:26 +10:00
|
|
|
* Step 3 of 9.2.1.2.
|
2018-09-08 18:08:48 +08:00
|
|
|
* Erratum: if x.[[Length]] > 1 or [[ResolveValue]] returns null
|
|
|
|
|
* or an r with r.[[Length]] != 1, throw TypeError.
|
|
|
|
|
*/
|
|
|
|
|
n = JSXML_LENGTH(xml);
|
|
|
|
|
if (n > 1)
|
|
|
|
|
goto type_error;
|
|
|
|
|
if (n == 0) {
|
|
|
|
|
ok = ResolveValue(cx, xml, &rxml);
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
if (!rxml || JSXML_LENGTH(rxml) != 1)
|
|
|
|
|
goto type_error;
|
|
|
|
|
ok = Append(cx, xml, rxml);
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
JS_ASSERT(JSXML_LENGTH(xml) == 1);
|
2023-07-12 13:27:26 +10:00
|
|
|
xml = XMLARRAY_MEMBER(&xml->xml_kids, 0, JSXML);
|
|
|
|
|
if (!xml)
|
2018-09-08 18:08:48 +08:00
|
|
|
goto out;
|
2023-07-12 13:27:26 +10:00
|
|
|
JS_ASSERT(xml->xml_class != JSXML_CLASS_LIST);
|
|
|
|
|
obj = js_GetXMLObject(cx, xml);
|
|
|
|
|
if (!obj)
|
2018-09-08 18:08:48 +08:00
|
|
|
goto bad;
|
2023-07-12 13:27:26 +10:00
|
|
|
roots[OBJ_ROOT] = OBJECT_TO_JSVAL(obj);
|
|
|
|
|
|
|
|
|
|
/* FALL THROUGH to non-list case */
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2023-07-12 13:27:26 +10:00
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
/*
|
|
|
|
|
* ECMA-357 9.1.1.2.
|
|
|
|
|
* Erratum: move steps 3 and 4 to before 1 and 2, to avoid wasted
|
|
|
|
|
* effort in ToString or [[DeepCopy]].
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (JSXML_HAS_VALUE(xml))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
if (!vxml ||
|
|
|
|
|
vxml->xml_class == JSXML_CLASS_TEXT ||
|
|
|
|
|
vxml->xml_class == JSXML_CLASS_ATTRIBUTE) {
|
|
|
|
|
ok = JS_ConvertValue(cx, *vp, JSTYPE_STRING, vp);
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
} else {
|
|
|
|
|
rxml = DeepCopyInLRS(cx, vxml, 0);
|
|
|
|
|
if (!rxml || !js_GetXMLObject(cx, rxml))
|
|
|
|
|
goto bad;
|
|
|
|
|
vxml = rxml;
|
|
|
|
|
*vp = OBJECT_TO_JSVAL(vxml->object);
|
|
|
|
|
}
|
|
|
|
|
roots[VAL_ROOT] = *vp;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 6.
|
|
|
|
|
* Erratum: why is this done here, so early? use is way later....
|
|
|
|
|
*/
|
|
|
|
|
ok = js_GetDefaultXMLNamespace(cx, &nsval);
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
if (nameobj->getClass() == &js_AttributeNameClass) {
|
2018-09-08 18:08:48 +08:00
|
|
|
/* 7(a). */
|
|
|
|
|
if (!js_IsXMLName(cx, OBJECT_TO_JSVAL(nameobj)))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
/* 7(b-c). */
|
|
|
|
|
if (vxml && vxml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
n = vxml->xml_kids.length;
|
|
|
|
|
if (n == 0) {
|
|
|
|
|
*vp = STRING_TO_JSVAL(cx->runtime->emptyString);
|
|
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
JSString *left = KidToString(cx, vxml, 0);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!left)
|
|
|
|
|
goto bad;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JSString *space = cx->runtime->atomState.spaceAtom;
|
2018-09-08 18:08:48 +08:00
|
|
|
for (i = 1; i < n; i++) {
|
|
|
|
|
left = js_ConcatStrings(cx, left, space);
|
|
|
|
|
if (!left)
|
|
|
|
|
goto bad;
|
2025-03-19 21:25:58 +10:00
|
|
|
JSString *right = KidToString(cx, vxml, i);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!right)
|
|
|
|
|
goto bad;
|
|
|
|
|
left = js_ConcatStrings(cx, left, right);
|
|
|
|
|
if (!left)
|
|
|
|
|
goto bad;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
roots[VAL_ROOT] = *vp = STRING_TO_JSVAL(left);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ok = JS_ConvertValue(cx, *vp, JSTYPE_STRING, vp);
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
roots[VAL_ROOT] = *vp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 7(d-e). */
|
|
|
|
|
match = NULL;
|
|
|
|
|
for (i = 0, n = xml->xml_attrs.length; i < n; i++) {
|
|
|
|
|
attr = XMLARRAY_MEMBER(&xml->xml_attrs, i, JSXML);
|
|
|
|
|
if (!attr)
|
|
|
|
|
continue;
|
|
|
|
|
attrqn = attr->name;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (EqualStrings(attrqn->getQNameLocalName(), nameqn->getQNameLocalName())) {
|
|
|
|
|
JSLinearString *uri = nameqn->getNameURI();
|
|
|
|
|
if (!uri || EqualStrings(attrqn->getNameURI(), uri)) {
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!match) {
|
|
|
|
|
match = attr;
|
|
|
|
|
} else {
|
|
|
|
|
DeleteNamedProperty(cx, xml, attrqn, JS_TRUE);
|
|
|
|
|
--i;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 7(f). */
|
|
|
|
|
attr = match;
|
|
|
|
|
if (!attr) {
|
|
|
|
|
/* 7(f)(i-ii). */
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *uri = nameqn->getNameURI();
|
|
|
|
|
JSLinearString *left, *right;
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!uri) {
|
2018-09-08 18:08:48 +08:00
|
|
|
left = right = cx->runtime->emptyString;
|
|
|
|
|
} else {
|
2025-02-03 12:35:24 +10:00
|
|
|
left = uri;
|
2025-03-19 21:25:58 +10:00
|
|
|
right = nameqn->getNamePrefix();
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
nameqn = NewXMLQName(cx, left, right, nameqn->getQNameLocalName());
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!nameqn)
|
|
|
|
|
goto bad;
|
|
|
|
|
|
|
|
|
|
/* 7(f)(iii). */
|
|
|
|
|
attr = js_NewXML(cx, JSXML_CLASS_ATTRIBUTE);
|
|
|
|
|
if (!attr)
|
|
|
|
|
goto bad;
|
|
|
|
|
attr->parent = xml;
|
|
|
|
|
attr->name = nameqn;
|
|
|
|
|
|
|
|
|
|
/* 7(f)(iv). */
|
|
|
|
|
ok = XMLARRAY_ADD_MEMBER(cx, &xml->xml_attrs, n, attr);
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
/* 7(f)(v-vi). */
|
|
|
|
|
ns = GetNamespace(cx, nameqn, NULL);
|
|
|
|
|
if (!ns)
|
|
|
|
|
goto bad;
|
|
|
|
|
ok = AddInScopeNamespace(cx, xml, ns);
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 7(g). */
|
|
|
|
|
attr->xml_value = JSVAL_TO_STRING(*vp);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 8-9. */
|
|
|
|
|
if (!js_IsXMLName(cx, OBJECT_TO_JSVAL(nameobj)) &&
|
2025-03-19 21:25:58 +10:00
|
|
|
!IS_STAR(nameqn->getQNameLocalName())) {
|
2018-09-08 18:08:48 +08:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 10-11. */
|
2025-03-19 21:25:58 +10:00
|
|
|
id = JSID_VOID;
|
|
|
|
|
primitiveAssign = !vxml && !IS_STAR(nameqn->getQNameLocalName());
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
/* 12. */
|
|
|
|
|
k = n = xml->xml_kids.length;
|
2023-07-12 13:27:26 +10:00
|
|
|
matchIndex = XML_NOT_FOUND;
|
2018-09-08 18:08:48 +08:00
|
|
|
kid2 = NULL;
|
|
|
|
|
while (k != 0) {
|
|
|
|
|
--k;
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, k, JSXML);
|
|
|
|
|
if (kid && MatchElemName(nameqn, kid)) {
|
2023-07-12 13:27:26 +10:00
|
|
|
if (matchIndex != XML_NOT_FOUND)
|
|
|
|
|
DeleteByIndex(cx, xml, matchIndex);
|
|
|
|
|
matchIndex = k;
|
2018-09-08 18:08:48 +08:00
|
|
|
kid2 = kid;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Erratum: ECMA-357 specified child insertion inconsistently:
|
|
|
|
|
* insertChildBefore and insertChildAfter insert an arbitrary XML
|
|
|
|
|
* instance, and therefore can create cycles, but appendChild as
|
|
|
|
|
* specified by the "Overview" of 13.4.4.3 calls [[DeepCopy]] on
|
|
|
|
|
* its argument. But the "Semantics" in 13.4.4.3 do not include
|
|
|
|
|
* any [[DeepCopy]] call.
|
|
|
|
|
*
|
|
|
|
|
* Fixing this (https://bugzilla.mozilla.org/show_bug.cgi?id=312692)
|
|
|
|
|
* required adding cycle detection, and allowing duplicate kids to
|
|
|
|
|
* be created (see comment 6 in the bug). Allowing duplicate kid
|
|
|
|
|
* references means the loop above will delete all but the lowest
|
|
|
|
|
* indexed reference, and each [[DeleteByIndex]] nulls the kid's
|
|
|
|
|
* parent. Thus the need to restore parent here. This is covered
|
|
|
|
|
* by https://bugzilla.mozilla.org/show_bug.cgi?id=327564.
|
|
|
|
|
*/
|
|
|
|
|
if (kid2) {
|
|
|
|
|
JS_ASSERT(kid2->parent == xml || !kid2->parent);
|
|
|
|
|
if (!kid2->parent)
|
|
|
|
|
kid2->parent = xml;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 13. */
|
2023-07-12 13:27:26 +10:00
|
|
|
if (matchIndex == XML_NOT_FOUND) {
|
2018-09-08 18:08:48 +08:00
|
|
|
/* 13(a). */
|
2023-07-12 13:27:26 +10:00
|
|
|
matchIndex = n;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
/* 13(b). */
|
|
|
|
|
if (primitiveAssign) {
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *uri = nameqn->getNameURI();
|
|
|
|
|
JSLinearString *left, *right;
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!uri) {
|
|
|
|
|
ns = JSVAL_TO_OBJECT(nsval);
|
2025-03-19 21:25:58 +10:00
|
|
|
left = ns->getNameURI();
|
|
|
|
|
right = ns->getNamePrefix();
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
2025-02-03 12:35:24 +10:00
|
|
|
left = uri;
|
2025-03-19 21:25:58 +10:00
|
|
|
right = nameqn->getNamePrefix();
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
nameqn = NewXMLQName(cx, left, right, nameqn->getQNameLocalName());
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!nameqn)
|
|
|
|
|
goto bad;
|
|
|
|
|
|
|
|
|
|
/* 13(b)(iii). */
|
|
|
|
|
vobj = js_NewXMLObject(cx, JSXML_CLASS_ELEMENT);
|
|
|
|
|
if (!vobj)
|
|
|
|
|
goto bad;
|
2025-02-05 12:40:54 +10:00
|
|
|
vxml = (JSXML *) vobj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
vxml->parent = xml;
|
|
|
|
|
vxml->name = nameqn;
|
|
|
|
|
|
|
|
|
|
/* 13(b)(iv-vi). */
|
|
|
|
|
ns = GetNamespace(cx, nameqn, NULL);
|
|
|
|
|
if (!ns)
|
|
|
|
|
goto bad;
|
2023-07-12 13:27:26 +10:00
|
|
|
ok = Replace(cx, xml, matchIndex, OBJECT_TO_JSVAL(vobj));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
ok = AddInScopeNamespace(cx, vxml, ns);
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 14. */
|
|
|
|
|
if (primitiveAssign) {
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXMLArrayCursor cursor(&xml->xml_kids);
|
2023-07-12 13:27:26 +10:00
|
|
|
cursor.index = matchIndex;
|
2025-02-05 12:40:54 +10:00
|
|
|
kid = (JSXML *) cursor.getCurrent();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (JSXML_HAS_KIDS(kid)) {
|
2025-03-19 21:25:58 +10:00
|
|
|
kid->xml_kids.finish(cx);
|
|
|
|
|
kid->xml_kids.init();
|
|
|
|
|
ok = kid->xml_kids.setCapacity(cx, 1);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 14(b-c). */
|
|
|
|
|
/* XXXbe Erratum? redundant w.r.t. 7(b-c) else clause above */
|
|
|
|
|
if (ok) {
|
|
|
|
|
ok = JS_ConvertValue(cx, *vp, JSTYPE_STRING, vp);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (ok && !JSVAL_TO_STRING(*vp)->empty()) {
|
2018-09-08 18:08:48 +08:00
|
|
|
roots[VAL_ROOT] = *vp;
|
2025-02-05 12:40:54 +10:00
|
|
|
if ((JSXML *) cursor.getCurrent() == kid)
|
2023-07-12 13:27:26 +10:00
|
|
|
ok = Replace(cx, kid, 0, *vp);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* 15(a). */
|
2023-07-12 13:27:26 +10:00
|
|
|
ok = Replace(cx, xml, matchIndex, *vp);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out:
|
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
|
|
|
js_LeaveLocalRootScope(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
return ok;
|
|
|
|
|
|
|
|
|
|
type_error:
|
2025-03-19 21:25:58 +10:00
|
|
|
{
|
|
|
|
|
JSAutoByteString bytes;
|
|
|
|
|
if (js_ValueToPrintable(cx, IdToValue(id), &bytes))
|
|
|
|
|
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_XMLLIST_PUT, bytes.ptr());
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
bad:
|
|
|
|
|
ok = JS_FALSE;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ECMA-357 9.1.1.10 XML [[ResolveValue]], 9.2.1.10 XMLList [[ResolveValue]]. */
|
|
|
|
|
static JSBool
|
|
|
|
|
ResolveValue(JSContext *cx, JSXML *list, JSXML **result)
|
|
|
|
|
{
|
|
|
|
|
JSXML *target, *base;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *targetprop;
|
2025-03-19 21:25:58 +10:00
|
|
|
jsid id;
|
|
|
|
|
jsval tv;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
if (list->xml_class != JSXML_CLASS_LIST || list->xml_kids.length != 0) {
|
|
|
|
|
if (!js_GetXMLObject(cx, list))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
*result = list;
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
target = list->xml_target;
|
|
|
|
|
targetprop = list->xml_targetprop;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!target || !targetprop || IS_STAR(targetprop->getQNameLocalName())) {
|
2018-09-08 18:08:48 +08:00
|
|
|
*result = NULL;
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
if (targetprop->getClass() == &js_AttributeNameClass) {
|
2018-09-08 18:08:48 +08:00
|
|
|
*result = NULL;
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!ResolveValue(cx, target, &base))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
if (!base) {
|
|
|
|
|
*result = NULL;
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
if (!js_GetXMLObject(cx, base))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
id = OBJECT_TO_JSID(targetprop);
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!GetProperty(cx, base->object, id, &tv))
|
|
|
|
|
return JS_FALSE;
|
2025-02-05 12:40:54 +10:00
|
|
|
target = (JSXML *) JSVAL_TO_OBJECT(tv)->getPrivate();
|
2023-07-12 13:27:26 +10:00
|
|
|
|
|
|
|
|
if (JSXML_LENGTH(target) == 0) {
|
|
|
|
|
if (base->xml_class == JSXML_CLASS_LIST && JSXML_LENGTH(base) > 1) {
|
|
|
|
|
*result = NULL;
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
tv = STRING_TO_JSVAL(cx->runtime->emptyString);
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!PutProperty(cx, base->object, id, false, &tv))
|
2023-07-12 13:27:26 +10:00
|
|
|
return JS_FALSE;
|
|
|
|
|
if (!GetProperty(cx, base->object, id, &tv))
|
|
|
|
|
return JS_FALSE;
|
2025-02-05 12:40:54 +10:00
|
|
|
target = (JSXML *) JSVAL_TO_OBJECT(tv)->getPrivate();
|
2023-07-12 13:27:26 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*result = target;
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2025-02-03 12:35:24 +10:00
|
|
|
HasNamedProperty(JSXML *xml, JSObject *nameqn)
|
2023-07-12 13:27:26 +10:00
|
|
|
{
|
|
|
|
|
JSBool found;
|
|
|
|
|
JSXMLArray *array;
|
|
|
|
|
JSXMLNameMatcher matcher;
|
|
|
|
|
uint32 i, n;
|
|
|
|
|
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
found = JS_FALSE;
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXMLArrayCursor cursor(&xml->xml_kids);
|
|
|
|
|
while (JSXML *kid = (JSXML *) cursor.getNext()) {
|
2023-07-12 13:27:26 +10:00
|
|
|
found = HasNamedProperty(kid, nameqn);
|
|
|
|
|
if (found)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_ELEMENT) {
|
2025-02-05 12:40:54 +10:00
|
|
|
if (nameqn->getClass() == &js_AttributeNameClass) {
|
2023-07-12 13:27:26 +10:00
|
|
|
array = &xml->xml_attrs;
|
|
|
|
|
matcher = MatchAttrName;
|
|
|
|
|
} else {
|
|
|
|
|
array = &xml->xml_kids;
|
|
|
|
|
matcher = MatchElemName;
|
|
|
|
|
}
|
|
|
|
|
for (i = 0, n = array->length; i < n; i++) {
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXML *kid = XMLARRAY_MEMBER(array, i, JSXML);
|
2023-07-12 13:27:26 +10:00
|
|
|
if (kid && matcher(nameqn, kid))
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
HasIndexedProperty(JSXML *xml, uint32 i)
|
|
|
|
|
{
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST)
|
|
|
|
|
return i < JSXML_LENGTH(xml);
|
|
|
|
|
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_ELEMENT)
|
|
|
|
|
return i == 0;
|
|
|
|
|
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
HasSimpleContent(JSXML *xml);
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
HasFunctionProperty(JSContext *cx, JSObject *obj, jsid funid, JSBool *found)
|
|
|
|
|
{
|
|
|
|
|
JSObject *pobj;
|
|
|
|
|
JSProperty *prop;
|
|
|
|
|
JSXML *xml;
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
JS_ASSERT(obj->getClass() == &js_XMLClass);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!js_LookupProperty(cx, obj, funid, &pobj, &prop))
|
2025-02-05 12:40:54 +10:00
|
|
|
return false;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!prop) {
|
2025-02-05 12:40:54 +10:00
|
|
|
xml = (JSXML *) obj->getPrivate();
|
2023-07-12 13:27:26 +10:00
|
|
|
if (HasSimpleContent(xml)) {
|
2025-02-05 12:40:54 +10:00
|
|
|
AutoObjectRooter tvr(cx);
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/*
|
|
|
|
|
* Search in String.prototype to set found whenever
|
2025-02-05 12:40:54 +10:00
|
|
|
* GetXMLFunction returns existing function.
|
2023-07-12 13:27:26 +10:00
|
|
|
*/
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!js_GetClassPrototype(cx, NULL, JSProto_String, tvr.addr()))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
JS_ASSERT(tvr.object());
|
|
|
|
|
if (!js_LookupProperty(cx, tvr.object(), funid, &pobj, &prop))
|
|
|
|
|
return false;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
2023-07-12 13:27:26 +10:00
|
|
|
*found = (prop != NULL);
|
2025-02-05 12:40:54 +10:00
|
|
|
return true;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ECMA-357 9.1.1.6 XML [[HasProperty]] and 9.2.1.5 XMLList [[HasProperty]]. */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
HasProperty(JSContext *cx, JSObject *obj, jsval id, JSBool *found)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXML *xml;
|
2025-03-19 21:25:58 +10:00
|
|
|
bool isIndex;
|
2023-07-12 13:27:26 +10:00
|
|
|
uint32 i;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *qn;
|
2018-09-08 18:08:48 +08:00
|
|
|
jsid funid;
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
xml = (JSXML *) obj->getPrivate();
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!js_IdValIsIndex(cx, id, &i, &isIndex))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
if (isIndex) {
|
2023-07-12 13:27:26 +10:00
|
|
|
*found = HasIndexedProperty(xml, i);
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
|
|
|
|
qn = ToXMLName(cx, id, &funid);
|
|
|
|
|
if (!qn)
|
|
|
|
|
return JS_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!JSID_IS_VOID(funid)) {
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!HasFunctionProperty(cx, obj, funid, found))
|
|
|
|
|
return JS_FALSE;
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
2023-07-12 13:27:26 +10:00
|
|
|
*found = HasNamedProperty(xml, qn);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xml_finalize(JSContext *cx, JSObject *obj)
|
|
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXML *xml = (JSXML *) obj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!xml)
|
|
|
|
|
return;
|
|
|
|
|
if (xml->object == obj)
|
|
|
|
|
xml->object = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_trace_vector(JSTracer *trc, JSXML **vec, uint32 len)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
uint32 i;
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXML *xml;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
2023-07-12 13:27:26 +10:00
|
|
|
xml = vec[i];
|
|
|
|
|
if (xml) {
|
|
|
|
|
JS_SET_TRACING_INDEX(trc, "xml_vector", i);
|
2025-03-19 21:25:58 +10:00
|
|
|
Mark(trc, xml);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2025-03-19 21:25:58 +10:00
|
|
|
* XML objects are native. Thus xml_lookupProperty must return a valid
|
|
|
|
|
* Shape pointer parameter via *propp to signify "property found". Since the
|
|
|
|
|
* only call to xml_lookupProperty is via JSObject::lookupProperty, and then
|
|
|
|
|
* only from js_FindProperty (in jsobj.c, called from jsinterp.c) or from
|
|
|
|
|
* JSOP_IN case in the interpreter, the only time we add a Shape here is when
|
|
|
|
|
* an unqualified name is being accessed or when "name in xml" is called.
|
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
|
|
|
* This scope property keeps the JSOP_NAME code in js_Interpret happy by
|
2025-03-19 21:25:58 +10:00
|
|
|
* giving it an shape with (getter, setter) == (GetProperty, PutProperty).
|
2018-09-08 18:08:48 +08:00
|
|
|
*
|
|
|
|
|
* NB: xml_deleteProperty must take care to remove any property added here.
|
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
|
|
|
*
|
|
|
|
|
* FIXME This clashes with the function namespace implementation which also
|
|
|
|
|
* uses native properties. Effectively after xml_lookupProperty any property
|
|
|
|
|
* stored previously using assignments to xml.function::name will be removed.
|
2025-02-05 12:40:54 +10:00
|
|
|
* We partially workaround the problem in GetXMLFunction. There we take
|
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
|
|
|
* advantage of the fact that typically function:: is used to access the
|
|
|
|
|
* functions from XML.prototype. So when js_GetProperty returns a non-function
|
|
|
|
|
* property, we assume that it represents the result of GetProperty setter
|
|
|
|
|
* hiding the function and use an extra prototype chain lookup to recover it.
|
|
|
|
|
* For a proper solution see bug 355257.
|
2023-07-12 13:27:26 +10:00
|
|
|
*/
|
2018-09-08 18:08:48 +08:00
|
|
|
static JSBool
|
|
|
|
|
xml_lookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
|
|
|
|
|
JSProperty **propp)
|
|
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSBool found;
|
|
|
|
|
JSXML *xml;
|
|
|
|
|
uint32 i;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *qn;
|
2023-07-12 13:27:26 +10:00
|
|
|
jsid funid;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
xml = (JSXML *) obj->getPrivate();
|
2025-03-19 21:25:58 +10:00
|
|
|
if (js_IdIsIndex(id, &i)) {
|
2023-07-12 13:27:26 +10:00
|
|
|
found = HasIndexedProperty(xml, i);
|
|
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
qn = ToXMLName(cx, IdToJsval(id), &funid);
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!qn)
|
|
|
|
|
return JS_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!JSID_IS_VOID(funid))
|
2023-07-12 13:27:26 +10:00
|
|
|
return js_LookupProperty(cx, obj, funid, objp, propp);
|
|
|
|
|
found = HasNamedProperty(xml, qn);
|
|
|
|
|
}
|
|
|
|
|
if (!found) {
|
|
|
|
|
*objp = NULL;
|
|
|
|
|
*propp = NULL;
|
|
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
const Shape *shape =
|
|
|
|
|
js_AddNativeProperty(cx, obj, id,
|
|
|
|
|
Valueify(GetProperty), Valueify(PutProperty),
|
|
|
|
|
SHAPE_INVALID_SLOT, JSPROP_ENUMERATE,
|
|
|
|
|
0, 0);
|
|
|
|
|
if (!shape)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
*objp = obj;
|
2025-03-19 21:25:58 +10:00
|
|
|
*propp = (JSProperty *) shape;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
xml_defineProperty(JSContext *cx, JSObject *obj, jsid id, const Value *v,
|
|
|
|
|
PropertyOp getter, StrictPropertyOp setter, uintN attrs)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
if (IsFunctionObject(*v) || getter || setter ||
|
2018-09-08 18:08:48 +08:00
|
|
|
(attrs & JSPROP_ENUMERATE) == 0 ||
|
|
|
|
|
(attrs & (JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_SHARED))) {
|
2025-03-19 21:25:58 +10:00
|
|
|
return js_DefineProperty(cx, obj, id, v, getter, setter, attrs);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
jsval tmp = Jsvalify(*v);
|
|
|
|
|
return PutProperty(cx, obj, id, false, &tmp);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
xml_getProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
if (JSID_IS_DEFAULT_XML_NAMESPACE(id)) {
|
|
|
|
|
vp->setUndefined();
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
return GetProperty(cx, obj, id, Jsvalify(vp));
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
xml_setProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
return PutProperty(cx, obj, id, strict, Jsvalify(vp));
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2025-02-05 12:40:54 +10:00
|
|
|
xml_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSBool found;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!HasProperty(cx, obj, IdToJsval(id), &found))
|
2025-02-05 12:40:54 +10:00
|
|
|
return false;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
*attrsp = found ? JSPROP_ENUMERATE : 0;
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2025-02-05 12:40:54 +10:00
|
|
|
xml_setAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSBool found;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!HasProperty(cx, obj, IdToJsval(id), &found))
|
2025-02-05 12:40:54 +10:00
|
|
|
return false;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
if (found) {
|
|
|
|
|
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
|
|
|
|
JSMSG_CANT_SET_XML_ATTRS);
|
2025-02-05 12:40:54 +10:00
|
|
|
return false;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
return true;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
xml_deleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool strict)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXML *xml;
|
|
|
|
|
jsval idval;
|
|
|
|
|
uint32 index;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *nameqn;
|
2023-07-12 13:27:26 +10:00
|
|
|
jsid funid;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
idval = IdToJsval(id);
|
2025-02-05 12:40:54 +10:00
|
|
|
xml = (JSXML *) obj->getPrivate();
|
2025-03-19 21:25:58 +10:00
|
|
|
if (js_IdIsIndex(id, &index)) {
|
2023-07-12 13:27:26 +10:00
|
|
|
if (xml->xml_class != JSXML_CLASS_LIST) {
|
|
|
|
|
/* See NOTE in spec: this variation is reserved for future use. */
|
2025-03-19 21:25:58 +10:00
|
|
|
ReportBadXMLName(cx, IdToValue(id));
|
|
|
|
|
return false;
|
2023-07-12 13:27:26 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ECMA-357 9.2.1.3. */
|
|
|
|
|
DeleteListElement(cx, xml, index);
|
|
|
|
|
} else {
|
|
|
|
|
nameqn = ToXMLName(cx, idval, &funid);
|
|
|
|
|
if (!nameqn)
|
2025-03-19 21:25:58 +10:00
|
|
|
return false;
|
|
|
|
|
if (!JSID_IS_VOID(funid))
|
|
|
|
|
return js_DeleteProperty(cx, obj, funid, rval, false);
|
2023-07-12 13:27:26 +10:00
|
|
|
|
|
|
|
|
DeleteNamedProperty(cx, xml, nameqn,
|
2025-02-05 12:40:54 +10:00
|
|
|
nameqn->getClass() == &js_AttributeNameClass);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/*
|
|
|
|
|
* If this object has its own (mutable) scope, then we may have added a
|
|
|
|
|
* property to the scope in xml_lookupProperty for it to return to mean
|
|
|
|
|
* "found" and to provide a handle for access operations to call the
|
|
|
|
|
* property's getter or setter. But now it's time to remove any such
|
|
|
|
|
* property, to purge the property cache and remove the scope entry.
|
|
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!obj->nativeEmpty() && !js_DeleteProperty(cx, obj, id, rval, false))
|
|
|
|
|
return false;
|
2023-07-12 13:27:26 +10:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
rval->setBoolean(true);
|
|
|
|
|
return true;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JSBool
|
|
|
|
|
xml_convert(JSContext *cx, JSObject *obj, JSType type, Value *rval)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
return js_TryMethod(cx, obj, cx->runtime->atomState.toStringAtom, 0, NULL, rval);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
xml_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op, Value *statep, jsid *idp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSXML *xml;
|
|
|
|
|
uint32 length, index;
|
|
|
|
|
JSXMLArrayCursor *cursor;
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
xml = (JSXML *)obj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
length = JSXML_LENGTH(xml);
|
|
|
|
|
|
|
|
|
|
switch (enum_op) {
|
|
|
|
|
case JSENUMERATE_INIT:
|
2025-03-19 21:25:58 +10:00
|
|
|
case JSENUMERATE_INIT_ALL:
|
2018-09-08 18:08:48 +08:00
|
|
|
if (length == 0) {
|
2025-03-19 21:25:58 +10:00
|
|
|
statep->setInt32(0);
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
2025-02-05 12:40:54 +10:00
|
|
|
cursor = cx->create<JSXMLArrayCursor>(&xml->xml_kids);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!cursor)
|
|
|
|
|
return JS_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
statep->setPrivate(cursor);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
if (idp)
|
|
|
|
|
*idp = INT_TO_JSID(length);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case JSENUMERATE_NEXT:
|
2025-03-19 21:25:58 +10:00
|
|
|
if (statep->isInt32(0)) {
|
|
|
|
|
statep->setNull();
|
2025-02-05 12:40:54 +10:00
|
|
|
break;
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
cursor = (JSXMLArrayCursor *) statep->toPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (cursor && cursor->array && (index = cursor->index) < length) {
|
|
|
|
|
*idp = INT_TO_JSID(index);
|
|
|
|
|
cursor->index = index + 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/* FALL THROUGH */
|
|
|
|
|
|
|
|
|
|
case JSENUMERATE_DESTROY:
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!statep->isInt32(0)) {
|
|
|
|
|
cursor = (JSXMLArrayCursor *) statep->toPrivate();
|
2025-02-05 12:40:54 +10:00
|
|
|
if (cursor)
|
|
|
|
|
cx->destroy(cursor);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
statep->setNull();
|
2018-09-08 18:08:48 +08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
static JSType
|
|
|
|
|
xml_typeOf(JSContext *cx, JSObject *obj)
|
|
|
|
|
{
|
|
|
|
|
return JSTYPE_XML;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
static JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
xml_hasInstance(JSContext *cx, JSObject *obj, const Value *, JSBool *bp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
static void
|
|
|
|
|
xml_trace(JSTracer *trc, JSObject *obj)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXML *xml = (JSXML *) obj->getPrivate();
|
2023-07-12 13:27:26 +10:00
|
|
|
if (xml)
|
|
|
|
|
JS_CALL_TRACER(trc, xml, JSTRACE_XML, "private");
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
static JSBool
|
|
|
|
|
xml_fix(JSContext *cx, JSObject *obj, bool *success, AutoIdVector *props)
|
|
|
|
|
{
|
|
|
|
|
JS_ASSERT(obj->isExtensible());
|
|
|
|
|
*success = false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
static void
|
|
|
|
|
xml_clear(JSContext *cx, JSObject *obj)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
HasSimpleContent(JSXML *xml)
|
|
|
|
|
{
|
|
|
|
|
JSXML *kid;
|
|
|
|
|
JSBool simple;
|
|
|
|
|
uint32 i, n;
|
|
|
|
|
|
|
|
|
|
again:
|
|
|
|
|
switch (xml->xml_class) {
|
|
|
|
|
case JSXML_CLASS_COMMENT:
|
|
|
|
|
case JSXML_CLASS_PROCESSING_INSTRUCTION:
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
case JSXML_CLASS_LIST:
|
|
|
|
|
if (xml->xml_kids.length == 0)
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
if (xml->xml_kids.length == 1) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, 0, JSXML);
|
|
|
|
|
if (kid) {
|
|
|
|
|
xml = kid;
|
|
|
|
|
goto again;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* FALL THROUGH */
|
|
|
|
|
default:
|
|
|
|
|
simple = JS_TRUE;
|
|
|
|
|
for (i = 0, n = JSXML_LENGTH(xml); i < n; i++) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
|
|
|
|
|
if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) {
|
|
|
|
|
simple = JS_FALSE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
}
|
|
|
|
|
return simple;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
/*
|
|
|
|
|
* 11.2.2.1 Step 3(d) onward.
|
|
|
|
|
*/
|
|
|
|
|
JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
js_GetXMLMethod(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_ASSERT(JS_InstanceOf(cx, obj, Jsvalify(&js_XMLClass), NULL));
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
if (JSID_IS_OBJECT(id)) {
|
|
|
|
|
jsid funid;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!js_IsFunctionQName(cx, JSID_TO_OBJECT(id), &funid))
|
|
|
|
|
return JS_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!JSID_IS_VOID(funid))
|
2025-02-05 12:40:54 +10:00
|
|
|
id = funid;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* As our callers have a bad habit of passing a pointer to an unrooted
|
|
|
|
|
* local value as vp, we use a proper root here.
|
|
|
|
|
*/
|
|
|
|
|
AutoValueRooter tvr(cx);
|
2025-03-19 21:25:58 +10:00
|
|
|
JSBool ok = GetXMLFunction(cx, obj, id, Jsvalify(tvr.addr()));
|
2025-02-05 12:40:54 +10:00
|
|
|
*vp = tvr.value();
|
|
|
|
|
return ok;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
js_TestXMLEquality(JSContext *cx, const Value &v1, const Value &v2, JSBool *bp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSXML *xml, *vxml;
|
|
|
|
|
JSObject *vobj;
|
|
|
|
|
JSBool ok;
|
|
|
|
|
JSString *str, *vstr;
|
|
|
|
|
jsdouble d, d2;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *obj;
|
|
|
|
|
jsval v;
|
|
|
|
|
if (v1.isObject() && v1.toObject().isXML()) {
|
|
|
|
|
obj = &v1.toObject();
|
|
|
|
|
v = Jsvalify(v2);
|
|
|
|
|
} else {
|
|
|
|
|
v = Jsvalify(v1);
|
|
|
|
|
obj = &v2.toObject();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JS_ASSERT(JS_InstanceOf(cx, obj, Jsvalify(&js_XMLClass), NULL));
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
xml = (JSXML *) obj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
vxml = NULL;
|
|
|
|
|
if (!JSVAL_IS_PRIMITIVE(v)) {
|
|
|
|
|
vobj = JSVAL_TO_OBJECT(v);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (vobj->isXML())
|
|
|
|
|
vxml = (JSXML *) vobj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
ok = Equals(cx, xml, v, bp);
|
|
|
|
|
} else if (vxml) {
|
|
|
|
|
if (vxml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
ok = Equals(cx, vxml, OBJECT_TO_JSVAL(obj), bp);
|
|
|
|
|
} else {
|
|
|
|
|
if (((xml->xml_class == JSXML_CLASS_TEXT ||
|
|
|
|
|
xml->xml_class == JSXML_CLASS_ATTRIBUTE) &&
|
|
|
|
|
HasSimpleContent(vxml)) ||
|
|
|
|
|
((vxml->xml_class == JSXML_CLASS_TEXT ||
|
|
|
|
|
vxml->xml_class == JSXML_CLASS_ATTRIBUTE) &&
|
|
|
|
|
HasSimpleContent(xml))) {
|
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
|
|
|
ok = js_EnterLocalRootScope(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (ok) {
|
2025-03-19 21:25:58 +10:00
|
|
|
ok = (str = js_ValueToString(cx, ObjectValue(*obj))) &&
|
|
|
|
|
(vstr = js_ValueToString(cx, Valueify(v)));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (ok)
|
2025-03-19 21:25:58 +10:00
|
|
|
ok = EqualStrings(cx, str, vstr, bp);
|
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
|
|
|
js_LeaveLocalRootScope(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ok = XMLEquals(cx, xml, vxml, bp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
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
|
|
|
ok = js_EnterLocalRootScope(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (ok) {
|
|
|
|
|
if (HasSimpleContent(xml)) {
|
2025-03-19 21:25:58 +10:00
|
|
|
ok = (str = js_ValueToString(cx, ObjectValue(*obj))) &&
|
|
|
|
|
(vstr = js_ValueToString(cx, Valueify(v)));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (ok)
|
2025-03-19 21:25:58 +10:00
|
|
|
ok = EqualStrings(cx, str, vstr, bp);
|
2018-09-08 18:08:48 +08:00
|
|
|
} else if (JSVAL_IS_STRING(v) || JSVAL_IS_NUMBER(v)) {
|
2025-03-19 21:25:58 +10:00
|
|
|
str = js_ValueToString(cx, ObjectValue(*obj));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!str) {
|
|
|
|
|
ok = JS_FALSE;
|
|
|
|
|
} else if (JSVAL_IS_STRING(v)) {
|
2025-03-19 21:25:58 +10:00
|
|
|
ok = EqualStrings(cx, str, JSVAL_TO_STRING(v), bp);
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
2023-07-12 13:27:26 +10:00
|
|
|
ok = JS_ValueToNumber(cx, STRING_TO_JSVAL(str), &d);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (ok) {
|
|
|
|
|
d2 = JSVAL_IS_INT(v) ? JSVAL_TO_INT(v)
|
2025-03-19 21:25:58 +10:00
|
|
|
: JSVAL_TO_DOUBLE(v);
|
2018-09-08 18:08:48 +08:00
|
|
|
*bp = JSDOUBLE_COMPARE(d, ==, d2, JS_FALSE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
*bp = JS_FALSE;
|
|
|
|
|
}
|
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
|
|
|
js_LeaveLocalRootScope(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
js_ConcatenateXML(JSContext *cx, JSObject *obj, JSObject *robj, Value *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSBool ok;
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *listobj;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSXML *list, *lxml, *rxml;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_ASSERT(JS_InstanceOf(cx, obj, Jsvalify(&js_XMLClass), NULL));
|
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
|
|
|
ok = js_EnterLocalRootScope(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ok)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
|
|
|
|
|
if (!listobj) {
|
|
|
|
|
ok = JS_FALSE;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
list = (JSXML *) listobj->getPrivate();
|
|
|
|
|
lxml = (JSXML *) obj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
ok = Append(cx, list, lxml);
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_ASSERT(robj->isXML());
|
|
|
|
|
rxml = (JSXML *) robj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
ok = Append(cx, list, rxml);
|
|
|
|
|
if (!ok)
|
|
|
|
|
goto out;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
vp->setObject(*listobj);
|
2018-09-08 18:08:48 +08:00
|
|
|
out:
|
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
|
|
|
js_LeaveLocalRootScopeWithResult(cx, *vp);
|
2018-09-08 18:08:48 +08:00
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_FRIEND_DATA(Class) js_XMLClass = {
|
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
|
|
|
js_XML_str,
|
2023-07-12 13:27:26 +10:00
|
|
|
JSCLASS_HAS_PRIVATE | JSCLASS_MARK_IS_TRACE |
|
|
|
|
|
JSCLASS_HAS_CACHED_PROTO(JSProto_XML),
|
2025-03-19 21:25:58 +10:00
|
|
|
PropertyStub, /* addProperty */
|
|
|
|
|
PropertyStub, /* delProperty */
|
|
|
|
|
PropertyStub, /* getProperty */
|
|
|
|
|
StrictPropertyStub, /* setProperty */
|
|
|
|
|
EnumerateStub,
|
|
|
|
|
ResolveStub,
|
|
|
|
|
xml_convert,
|
|
|
|
|
xml_finalize,
|
|
|
|
|
NULL, /* reserved0 */
|
|
|
|
|
NULL, /* checkAccess */
|
|
|
|
|
NULL, /* call */
|
|
|
|
|
NULL, /* construct */
|
|
|
|
|
NULL, /* xdrObject */
|
|
|
|
|
xml_hasInstance,
|
|
|
|
|
JS_CLASS_TRACE(xml_trace),
|
|
|
|
|
JS_NULL_CLASS_EXT,
|
|
|
|
|
{
|
|
|
|
|
xml_lookupProperty,
|
|
|
|
|
xml_defineProperty,
|
|
|
|
|
xml_getProperty,
|
|
|
|
|
xml_setProperty,
|
|
|
|
|
xml_getAttributes,
|
|
|
|
|
xml_setAttributes,
|
|
|
|
|
xml_deleteProperty,
|
|
|
|
|
xml_enumerate,
|
|
|
|
|
xml_typeOf,
|
|
|
|
|
NULL, /* trace */
|
|
|
|
|
xml_fix,
|
|
|
|
|
NULL, /* thisObject */
|
|
|
|
|
xml_clear
|
|
|
|
|
}
|
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
|
|
|
static JSXML *
|
2023-07-12 13:27:26 +10:00
|
|
|
StartNonListXMLMethod(JSContext *cx, jsval *vp, JSObject **objp)
|
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
|
|
|
{
|
|
|
|
|
JSXML *xml;
|
|
|
|
|
JSFunction *fun;
|
2023-07-12 13:27:26 +10:00
|
|
|
char numBuf[12];
|
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
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
JS_ASSERT(VALUE_IS_FUNCTION(cx, *vp));
|
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-03-19 21:25:58 +10:00
|
|
|
*objp = ToObject(cx, Valueify(&vp[1]));
|
|
|
|
|
if (!*objp)
|
|
|
|
|
return NULL;
|
|
|
|
|
xml = (JSXML *) GetInstancePrivate(cx, *objp, &js_XMLClass, Valueify(vp + 2));
|
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 (!xml || xml->xml_class != JSXML_CLASS_LIST)
|
|
|
|
|
return xml;
|
|
|
|
|
|
|
|
|
|
if (xml->xml_kids.length == 1) {
|
|
|
|
|
xml = XMLARRAY_MEMBER(&xml->xml_kids, 0, JSXML);
|
|
|
|
|
if (xml) {
|
|
|
|
|
*objp = js_GetXMLObject(cx, xml);
|
|
|
|
|
if (!*objp)
|
|
|
|
|
return NULL;
|
2023-07-12 13:27:26 +10:00
|
|
|
vp[1] = OBJECT_TO_JSVAL(*objp);
|
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
|
|
|
return xml;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
fun = GET_FUNCTION_PRIVATE(cx, JSVAL_TO_OBJECT(*vp));
|
|
|
|
|
JS_snprintf(numBuf, sizeof numBuf, "%u", xml->xml_kids.length);
|
2025-03-19 21:25:58 +10:00
|
|
|
JSAutoByteString funNameBytes;
|
|
|
|
|
if (const char *funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
|
|
|
|
|
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NON_LIST_XML_METHOD,
|
|
|
|
|
funName, numBuf);
|
|
|
|
|
}
|
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
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/* Beware: these two are not bracketed by JS_BEGIN/END_MACRO. */
|
2018-09-08 18:08:48 +08:00
|
|
|
#define XML_METHOD_PROLOG \
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *obj = ToObject(cx, Valueify(&vp[1])); \
|
|
|
|
|
if (!obj) \
|
|
|
|
|
return JS_FALSE; \
|
|
|
|
|
JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); \
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!xml) \
|
|
|
|
|
return JS_FALSE
|
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 NON_LIST_XML_METHOD_PROLOG \
|
2023-07-12 13:27:26 +10:00
|
|
|
JSObject *obj; \
|
|
|
|
|
JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); \
|
|
|
|
|
if (!xml) \
|
|
|
|
|
return JS_FALSE; \
|
|
|
|
|
JS_ASSERT(xml->xml_class != JSXML_CLASS_LIST)
|
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
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_addNamespace(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *ns;
|
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
|
|
|
NON_LIST_XML_METHOD_PROLOG;
|
2018-09-08 18:08:48 +08:00
|
|
|
if (xml->xml_class != JSXML_CLASS_ELEMENT)
|
2023-07-12 13:27:26 +10:00
|
|
|
goto done;
|
2018-09-08 18:08:48 +08:00
|
|
|
xml = CHECK_COPY_ON_WRITE(cx, xml, obj);
|
|
|
|
|
if (!xml)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!NamespaceHelper(cx, NULL, argc == 0 ? -1 : 1, vp + 2, vp))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
2023-07-12 13:27:26 +10:00
|
|
|
JS_ASSERT(!JSVAL_IS_PRIMITIVE(*vp));
|
2025-02-03 12:35:24 +10:00
|
|
|
|
|
|
|
|
ns = JSVAL_TO_OBJECT(*vp);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!AddInScopeNamespace(cx, xml, ns))
|
|
|
|
|
return JS_FALSE;
|
2025-02-05 12:40:54 +10:00
|
|
|
ns->setNamespaceDeclared(JSVAL_TRUE);
|
2023-07-12 13:27:26 +10:00
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
*vp = OBJECT_TO_JSVAL(obj);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_appendChild(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
jsval v;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSObject *vobj;
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXML *vxml;
|
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
|
|
|
NON_LIST_XML_METHOD_PROLOG;
|
2018-09-08 18:08:48 +08:00
|
|
|
xml = CHECK_COPY_ON_WRITE(cx, xml, obj);
|
|
|
|
|
if (!xml)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
jsid name;
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!js_GetAnyName(cx, &name))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
if (!GetProperty(cx, obj, name, &v))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
JS_ASSERT(!JSVAL_IS_PRIMITIVE(v));
|
|
|
|
|
vobj = JSVAL_TO_OBJECT(v);
|
2025-02-05 12:40:54 +10:00
|
|
|
JS_ASSERT(vobj->isXML());
|
|
|
|
|
vxml = (JSXML *) vobj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
JS_ASSERT(vxml->xml_class == JSXML_CLASS_LIST);
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!IndexToId(cx, vxml->xml_kids.length, &name))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
2025-02-03 12:35:24 +10:00
|
|
|
*vp = (argc != 0) ? vp[2] : JSVAL_VOID;
|
2025-03-19 21:25:58 +10:00
|
|
|
|
|
|
|
|
if (!PutProperty(cx, JSVAL_TO_OBJECT(v), name, false, vp))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = OBJECT_TO_JSVAL(obj);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_attribute(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *qn;
|
|
|
|
|
|
|
|
|
|
if (argc == 0) {
|
2025-03-19 21:25:58 +10:00
|
|
|
js_ReportMissingArg(cx, Valueify(*vp), 0);
|
2025-02-03 12:35:24 +10:00
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
qn = ToAttributeName(cx, vp[2]);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!qn)
|
|
|
|
|
return JS_FALSE;
|
2025-02-03 12:35:24 +10:00
|
|
|
vp[2] = OBJECT_TO_JSVAL(qn); /* local root */
|
2023-07-12 13:27:26 +10:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
jsid id = OBJECT_TO_JSID(qn);
|
|
|
|
|
JSObject *obj = ToObject(cx, Valueify(&vp[1]));
|
|
|
|
|
if (!obj)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
return GetProperty(cx, obj, id, vp);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_attributes(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
jsval name = ATOM_TO_JSVAL(cx->runtime->atomState.starAtom);
|
2025-02-05 12:40:54 +10:00
|
|
|
JSObject *qn = ToAttributeName(cx, name);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!qn)
|
|
|
|
|
return JS_FALSE;
|
2025-02-05 12:40:54 +10:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
AutoObjectRooter tvr(cx, qn);
|
|
|
|
|
jsid id = OBJECT_TO_JSID(qn);
|
|
|
|
|
JSObject *obj = ToObject(cx, Valueify(&vp[1]));
|
|
|
|
|
if (!obj)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
return GetProperty(cx, obj, id, vp);
|
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
|
|
|
static JSXML *
|
|
|
|
|
xml_list_helper(JSContext *cx, JSXML *xml, jsval *rval)
|
|
|
|
|
{
|
|
|
|
|
JSObject *listobj;
|
|
|
|
|
JSXML *list;
|
|
|
|
|
|
|
|
|
|
listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
|
|
|
|
|
if (!listobj)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
*rval = OBJECT_TO_JSVAL(listobj);
|
2025-02-05 12:40:54 +10:00
|
|
|
list = (JSXML *) listobj->getPrivate();
|
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
|
|
|
list->xml_target = xml;
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
static JSBool
|
|
|
|
|
ValueToId(JSContext *cx, jsval v, AutoIdRooter *idr)
|
|
|
|
|
{
|
|
|
|
|
if (JSVAL_IS_INT(v)) {
|
|
|
|
|
jsint i = JSVAL_TO_INT(v);
|
|
|
|
|
if (INT_FITS_IN_JSID(i))
|
|
|
|
|
*idr->addr() = INT_TO_JSID(i);
|
|
|
|
|
else if (!js_ValueToStringId(cx, Valueify(v), idr->addr()))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
} else if (JSVAL_IS_STRING(v)) {
|
|
|
|
|
JSAtom *atom = js_AtomizeString(cx, JSVAL_TO_STRING(v), 0);
|
|
|
|
|
if (!atom)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
*idr->addr() = ATOM_TO_JSID(atom);
|
|
|
|
|
} else if (!JSVAL_IS_PRIMITIVE(v)) {
|
|
|
|
|
*idr->addr() = OBJECT_TO_JSID(JSVAL_TO_OBJECT(v));
|
|
|
|
|
} else {
|
|
|
|
|
ReportBadXMLName(cx, Valueify(v));
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
static JSBool
|
|
|
|
|
xml_child_helper(JSContext *cx, JSObject *obj, JSXML *xml, jsval name,
|
|
|
|
|
jsval *rval)
|
|
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
bool isIndex;
|
2018-09-08 18:08:48 +08:00
|
|
|
uint32 index;
|
|
|
|
|
JSXML *kid;
|
|
|
|
|
JSObject *kidobj;
|
|
|
|
|
|
|
|
|
|
/* ECMA-357 13.4.4.6 */
|
|
|
|
|
JS_ASSERT(xml->xml_class != JSXML_CLASS_LIST);
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!js_IdValIsIndex(cx, name, &index, &isIndex))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
if (isIndex) {
|
2018-09-08 18:08:48 +08:00
|
|
|
if (index >= JSXML_LENGTH(xml)) {
|
|
|
|
|
*rval = JSVAL_VOID;
|
|
|
|
|
} else {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, index, JSXML);
|
|
|
|
|
if (!kid) {
|
|
|
|
|
*rval = JSVAL_VOID;
|
|
|
|
|
} else {
|
|
|
|
|
kidobj = js_GetXMLObject(cx, kid);
|
|
|
|
|
if (!kidobj)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
*rval = OBJECT_TO_JSVAL(kidobj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
AutoIdRooter idr(cx);
|
|
|
|
|
if (!ValueToId(cx, name, &idr))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
return GetProperty(cx, obj, idr.id(), rval);
|
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
|
|
|
/* XML and XMLList */
|
2018-09-08 18:08:48 +08:00
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_child(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
jsval v;
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXML *list, *vxml;
|
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
|
|
|
JSObject *kidobj;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
XML_METHOD_PROLOG;
|
2025-03-19 21:25:58 +10:00
|
|
|
jsval name = argc != 0 ? vp[2] : JSVAL_VOID;
|
2018-09-08 18:08:48 +08:00
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
/* ECMA-357 13.5.4.4 */
|
2023-07-12 13:27:26 +10:00
|
|
|
list = xml_list_helper(cx, xml, vp);
|
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 (!list)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXMLArrayCursor cursor(&xml->xml_kids);
|
|
|
|
|
while (JSXML *kid = (JSXML *) cursor.getNext()) {
|
2018-09-08 18:08:48 +08:00
|
|
|
kidobj = js_GetXMLObject(cx, kid);
|
|
|
|
|
if (!kidobj)
|
2025-02-05 12:40:54 +10:00
|
|
|
return JS_FALSE;
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!xml_child_helper(cx, kidobj, kid, name, &v))
|
2025-02-05 12:40:54 +10:00
|
|
|
return JS_FALSE;
|
2018-09-08 18:08:48 +08:00
|
|
|
if (JSVAL_IS_VOID(v)) {
|
|
|
|
|
/* The property didn't exist in this kid. */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JS_ASSERT(!JSVAL_IS_PRIMITIVE(v));
|
2025-02-05 12:40:54 +10:00
|
|
|
vxml = (JSXML *) JSVAL_TO_OBJECT(v)->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
if ((!JSXML_HAS_KIDS(vxml) || vxml->xml_kids.length != 0) &&
|
|
|
|
|
!Append(cx, list, vxml)) {
|
2025-02-05 12:40:54 +10:00
|
|
|
return JS_FALSE;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
return JS_TRUE;
|
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
|
|
|
/* ECMA-357 Edition 2 13.3.4.6 (note 13.3, not 13.4 as in Edition 1). */
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!xml_child_helper(cx, obj, xml, name, vp))
|
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
|
|
|
return JS_FALSE;
|
2023-07-12 13:27:26 +10:00
|
|
|
if (JSVAL_IS_VOID(*vp) && !xml_list_helper(cx, xml, vp))
|
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
|
|
|
return JS_FALSE;
|
|
|
|
|
return JS_TRUE;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_childIndex(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXML *parent;
|
2018-09-08 18:08:48 +08:00
|
|
|
uint32 i, n;
|
|
|
|
|
|
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
|
|
|
NON_LIST_XML_METHOD_PROLOG;
|
2018-09-08 18:08:48 +08:00
|
|
|
parent = xml->parent;
|
|
|
|
|
if (!parent || xml->xml_class == JSXML_CLASS_ATTRIBUTE) {
|
2025-03-19 21:25:58 +10:00
|
|
|
*vp = DOUBLE_TO_JSVAL(js_NaN);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
for (i = 0, n = JSXML_LENGTH(parent); i < n; i++) {
|
|
|
|
|
if (XMLARRAY_MEMBER(&parent->xml_kids, i, JSXML) == xml)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
JS_ASSERT(i < n);
|
2025-03-19 21:25:58 +10:00
|
|
|
if (i <= JSVAL_INT_MAX)
|
|
|
|
|
*vp = INT_TO_JSVAL(i);
|
|
|
|
|
else
|
|
|
|
|
*vp = DOUBLE_TO_JSVAL(i);
|
|
|
|
|
return JS_TRUE;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_children(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *obj = ToObject(cx, Valueify(&vp[1]));
|
|
|
|
|
if (!obj)
|
|
|
|
|
return false;
|
|
|
|
|
jsid name = ATOM_TO_JSID(cx->runtime->atomState.starAtom);
|
|
|
|
|
return GetProperty(cx, obj, name, vp);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_comments_helper(JSContext *cx, JSObject *obj, JSXML *xml, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXML *list, *kid, *vxml;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSBool ok;
|
|
|
|
|
uint32 i, n;
|
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
|
|
|
JSObject *kidobj;
|
2018-09-08 18:08:48 +08:00
|
|
|
jsval v;
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
list = xml_list_helper(cx, xml, vp);
|
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 (!list)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
ok = JS_TRUE;
|
|
|
|
|
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
/* 13.5.4.6 Step 2. */
|
|
|
|
|
for (i = 0, n = JSXML_LENGTH(xml); i < n; i++) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
|
|
|
|
|
if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) {
|
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
|
|
|
ok = js_EnterLocalRootScope(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ok)
|
|
|
|
|
break;
|
|
|
|
|
kidobj = js_GetXMLObject(cx, kid);
|
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 (kidobj) {
|
2023-07-12 13:27:26 +10:00
|
|
|
ok = xml_comments_helper(cx, kidobj, kid, &v);
|
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
|
|
|
} else {
|
|
|
|
|
ok = JS_FALSE;
|
|
|
|
|
v = JSVAL_NULL;
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
js_LeaveLocalRootScopeWithResult(cx, Valueify(v));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ok)
|
|
|
|
|
break;
|
2025-02-05 12:40:54 +10:00
|
|
|
vxml = (JSXML *) JSVAL_TO_OBJECT(v)->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (JSXML_LENGTH(vxml) != 0) {
|
|
|
|
|
ok = Append(cx, list, vxml);
|
|
|
|
|
if (!ok)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* 13.4.4.9 Step 2. */
|
|
|
|
|
for (i = 0, n = JSXML_LENGTH(xml); i < n; i++) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
|
|
|
|
|
if (kid && kid->xml_class == JSXML_CLASS_COMMENT) {
|
|
|
|
|
ok = Append(cx, list, kid);
|
|
|
|
|
if (!ok)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
static JSBool
|
|
|
|
|
xml_comments(JSContext *cx, uintN argc, jsval *vp)
|
|
|
|
|
{
|
|
|
|
|
XML_METHOD_PROLOG;
|
|
|
|
|
return xml_comments_helper(cx, obj, xml, vp);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_contains(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
jsval value;
|
|
|
|
|
JSBool eq;
|
|
|
|
|
JSObject *kidobj;
|
|
|
|
|
|
|
|
|
|
XML_METHOD_PROLOG;
|
2025-02-03 12:35:24 +10:00
|
|
|
value = argc != 0 ? vp[2] : JSVAL_VOID;
|
2018-09-08 18:08:48 +08:00
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
eq = JS_FALSE;
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXMLArrayCursor cursor(&xml->xml_kids);
|
|
|
|
|
while (JSXML *kid = (JSXML *) cursor.getNext()) {
|
2018-09-08 18:08:48 +08:00
|
|
|
kidobj = js_GetXMLObject(cx, kid);
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!kidobj || !js_TestXMLEquality(cx, ObjectValue(*kidobj), Valueify(value), &eq))
|
2025-02-05 12:40:54 +10:00
|
|
|
return JS_FALSE;
|
2018-09-08 18:08:48 +08:00
|
|
|
if (eq)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!js_TestXMLEquality(cx, ObjectValue(*obj), Valueify(value), &eq))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = BOOLEAN_TO_JSVAL(eq);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_copy(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXML *copy;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
XML_METHOD_PROLOG;
|
|
|
|
|
copy = DeepCopy(cx, xml, NULL, 0);
|
|
|
|
|
if (!copy)
|
|
|
|
|
return JS_FALSE;
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = OBJECT_TO_JSVAL(copy->object);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_descendants(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
jsval name;
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXML *list;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
XML_METHOD_PROLOG;
|
2025-03-19 21:25:58 +10:00
|
|
|
name = argc == 0 ? ATOM_TO_JSVAL(cx->runtime->atomState.starAtom) : vp[2];
|
2018-09-08 18:08:48 +08:00
|
|
|
list = Descendants(cx, xml, name);
|
|
|
|
|
if (!list)
|
|
|
|
|
return JS_FALSE;
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = OBJECT_TO_JSVAL(list->object);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_elements_helper(JSContext *cx, JSObject *obj, JSXML *xml,
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *nameqn, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXML *list, *vxml;
|
2023-07-12 13:27:26 +10:00
|
|
|
jsval v;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSBool ok;
|
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
|
|
|
JSObject *kidobj;
|
2018-09-08 18:08:48 +08:00
|
|
|
uint32 i, n;
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
list = xml_list_helper(cx, xml, vp);
|
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 (!list)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
list->xml_targetprop = nameqn;
|
|
|
|
|
ok = JS_TRUE;
|
|
|
|
|
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
/* 13.5.4.6 */
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXMLArrayCursor cursor(&xml->xml_kids);
|
|
|
|
|
while (JSXML *kid = (JSXML *) cursor.getNext()) {
|
2018-09-08 18:08:48 +08:00
|
|
|
if (kid->xml_class == JSXML_CLASS_ELEMENT) {
|
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
|
|
|
ok = js_EnterLocalRootScope(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ok)
|
|
|
|
|
break;
|
|
|
|
|
kidobj = js_GetXMLObject(cx, kid);
|
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 (kidobj) {
|
2023-07-12 13:27:26 +10:00
|
|
|
ok = xml_elements_helper(cx, kidobj, kid, nameqn, &v);
|
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
|
|
|
} else {
|
|
|
|
|
ok = JS_FALSE;
|
|
|
|
|
v = JSVAL_NULL;
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
js_LeaveLocalRootScopeWithResult(cx, Valueify(v));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ok)
|
|
|
|
|
break;
|
2025-02-05 12:40:54 +10:00
|
|
|
vxml = (JSXML *) JSVAL_TO_OBJECT(v)->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (JSXML_LENGTH(vxml) != 0) {
|
|
|
|
|
ok = Append(cx, list, vxml);
|
|
|
|
|
if (!ok)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for (i = 0, n = JSXML_LENGTH(xml); i < n; i++) {
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXML *kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (kid && kid->xml_class == JSXML_CLASS_ELEMENT &&
|
|
|
|
|
MatchElemName(nameqn, kid)) {
|
|
|
|
|
ok = Append(cx, list, kid);
|
|
|
|
|
if (!ok)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
static JSBool
|
|
|
|
|
xml_elements(JSContext *cx, uintN argc, jsval *vp)
|
|
|
|
|
{
|
|
|
|
|
jsval name;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *nameqn;
|
2023-07-12 13:27:26 +10:00
|
|
|
jsid funid;
|
|
|
|
|
|
|
|
|
|
XML_METHOD_PROLOG;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
name = (argc == 0) ? ATOM_TO_JSVAL(cx->runtime->atomState.starAtom) : vp[2];
|
2023-07-12 13:27:26 +10:00
|
|
|
nameqn = ToXMLName(cx, name, &funid);
|
|
|
|
|
if (!nameqn)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!JSID_IS_VOID(funid))
|
2023-07-12 13:27:26 +10:00
|
|
|
return xml_list_helper(cx, xml, vp) != NULL;
|
|
|
|
|
|
|
|
|
|
return xml_elements_helper(cx, obj, xml, nameqn, vp);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_hasOwnProperty(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
jsval name;
|
2023-07-12 13:27:26 +10:00
|
|
|
JSBool found;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *obj = ToObject(cx, Valueify(&vp[1]));
|
|
|
|
|
if (!obj)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
if (!InstanceOf(cx, obj, &js_XMLClass, Valueify(vp + 2)))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
name = argc != 0 ? vp[2] : JSVAL_VOID;
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!HasProperty(cx, obj, name, &found))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
2023-07-12 13:27:26 +10:00
|
|
|
if (found) {
|
|
|
|
|
*vp = JSVAL_TRUE;
|
|
|
|
|
return JS_TRUE;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
return js_HasOwnPropertyHelper(cx, js_LookupProperty, argc, Valueify(vp));
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_hasComplexContent(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXML *kid;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSObject *kidobj;
|
|
|
|
|
uint32 i, n;
|
|
|
|
|
|
|
|
|
|
XML_METHOD_PROLOG;
|
|
|
|
|
again:
|
|
|
|
|
switch (xml->xml_class) {
|
|
|
|
|
case JSXML_CLASS_ATTRIBUTE:
|
|
|
|
|
case JSXML_CLASS_COMMENT:
|
|
|
|
|
case JSXML_CLASS_PROCESSING_INSTRUCTION:
|
|
|
|
|
case JSXML_CLASS_TEXT:
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = JSVAL_FALSE;
|
2018-09-08 18:08:48 +08:00
|
|
|
break;
|
|
|
|
|
case JSXML_CLASS_LIST:
|
|
|
|
|
if (xml->xml_kids.length == 0) {
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = JSVAL_TRUE;
|
2018-09-08 18:08:48 +08:00
|
|
|
} else if (xml->xml_kids.length == 1) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, 0, JSXML);
|
|
|
|
|
if (kid) {
|
|
|
|
|
kidobj = js_GetXMLObject(cx, kid);
|
|
|
|
|
if (!kidobj)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
obj = kidobj;
|
2025-02-05 12:40:54 +10:00
|
|
|
xml = (JSXML *) obj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
goto again;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* FALL THROUGH */
|
|
|
|
|
default:
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = JSVAL_FALSE;
|
2018-09-08 18:08:48 +08:00
|
|
|
for (i = 0, n = xml->xml_kids.length; i < n; i++) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
|
|
|
|
|
if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) {
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = JSVAL_TRUE;
|
2018-09-08 18:08:48 +08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_hasSimpleContent(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
XML_METHOD_PROLOG;
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = BOOLEAN_TO_JSVAL(HasSimpleContent(xml));
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
FindInScopeNamespaces(JSContext *cx, JSXML *xml, JSXMLArray *nsarray)
|
|
|
|
|
{
|
|
|
|
|
uint32 length, i, j, n;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *ns, *ns2;
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *prefix, *prefix2;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
length = nsarray->length;
|
|
|
|
|
do {
|
|
|
|
|
if (xml->xml_class != JSXML_CLASS_ELEMENT)
|
|
|
|
|
continue;
|
|
|
|
|
for (i = 0, n = xml->xml_namespaces.length; i < n; i++) {
|
2025-02-03 12:35:24 +10:00
|
|
|
ns = XMLARRAY_MEMBER(&xml->xml_namespaces, i, JSObject);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ns)
|
|
|
|
|
continue;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
prefix = ns->getNamePrefix();
|
2018-09-08 18:08:48 +08:00
|
|
|
for (j = 0; j < length; j++) {
|
2025-02-03 12:35:24 +10:00
|
|
|
ns2 = XMLARRAY_MEMBER(nsarray, j, JSObject);
|
|
|
|
|
if (ns2) {
|
2025-03-19 21:25:58 +10:00
|
|
|
prefix2 = ns2->getNamePrefix();
|
2025-02-03 12:35:24 +10:00
|
|
|
if ((prefix2 && prefix)
|
2025-03-19 21:25:58 +10:00
|
|
|
? EqualStrings(prefix2, prefix)
|
|
|
|
|
: EqualStrings(ns2->getNameURI(), ns->getNameURI())) {
|
2025-02-03 12:35:24 +10:00
|
|
|
break;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (j == length) {
|
|
|
|
|
if (!XMLARRAY_APPEND(cx, nsarray, ns))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
++length;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} while ((xml = xml->parent) != NULL);
|
|
|
|
|
JS_ASSERT(length == nsarray->length);
|
|
|
|
|
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
/*
|
|
|
|
|
* Populate a new JS array with elements of array and place the result into
|
|
|
|
|
* rval. rval must point to a rooted location.
|
|
|
|
|
*/
|
|
|
|
|
static bool
|
|
|
|
|
NamespacesToJSArray(JSContext *cx, JSXMLArray *array, jsval *rval)
|
|
|
|
|
{
|
|
|
|
|
JSObject *arrayobj = NewDenseEmptyArray(cx);
|
|
|
|
|
if (!arrayobj)
|
|
|
|
|
return false;
|
|
|
|
|
*rval = OBJECT_TO_JSVAL(arrayobj);
|
2025-02-05 12:40:54 +10:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
AutoValueRooter tvr(cx);
|
|
|
|
|
for (uint32 i = 0, n = array->length; i < n; i++) {
|
|
|
|
|
JSObject *ns = XMLARRAY_MEMBER(array, i, JSObject);
|
|
|
|
|
if (!ns)
|
|
|
|
|
continue;
|
|
|
|
|
tvr.set(ObjectValue(*ns));
|
|
|
|
|
if (!arrayobj->setProperty(cx, INT_TO_JSID(i), tvr.addr(), false))
|
2025-02-05 12:40:54 +10:00
|
|
|
return false;
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
return true;
|
|
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_inScopeNamespaces(JSContext *cx, uintN argc, jsval *vp)
|
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
|
|
|
NON_LIST_XML_METHOD_PROLOG;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
AutoNamespaceArray namespaces(cx);
|
2025-03-19 21:25:58 +10:00
|
|
|
return FindInScopeNamespaces(cx, xml, &namespaces.array) &&
|
|
|
|
|
NamespacesToJSArray(cx, &namespaces.array, vp);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_insertChildAfter(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
jsval arg;
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXML *kid;
|
2018-09-08 18:08:48 +08:00
|
|
|
uint32 i;
|
|
|
|
|
|
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
|
|
|
NON_LIST_XML_METHOD_PROLOG;
|
2025-02-03 12:35:24 +10:00
|
|
|
*vp = OBJECT_TO_JSVAL(obj);
|
|
|
|
|
if (!JSXML_HAS_KIDS(xml) || argc == 0)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
arg = vp[2];
|
2018-09-08 18:08:48 +08:00
|
|
|
if (JSVAL_IS_NULL(arg)) {
|
|
|
|
|
kid = NULL;
|
|
|
|
|
i = 0;
|
|
|
|
|
} else {
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!VALUE_IS_XML(arg))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
2025-02-05 12:40:54 +10:00
|
|
|
kid = (JSXML *) JSVAL_TO_OBJECT(arg)->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
i = XMLARRAY_FIND_MEMBER(&xml->xml_kids, kid, NULL);
|
|
|
|
|
if (i == XML_NOT_FOUND)
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xml = CHECK_COPY_ON_WRITE(cx, xml, obj);
|
|
|
|
|
if (!xml)
|
|
|
|
|
return JS_FALSE;
|
2025-02-03 12:35:24 +10:00
|
|
|
return Insert(cx, xml, i, argc >= 2 ? vp[3] : JSVAL_VOID);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_insertChildBefore(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
jsval arg;
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXML *kid;
|
2018-09-08 18:08:48 +08:00
|
|
|
uint32 i;
|
|
|
|
|
|
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
|
|
|
NON_LIST_XML_METHOD_PROLOG;
|
2025-02-03 12:35:24 +10:00
|
|
|
*vp = OBJECT_TO_JSVAL(obj);
|
|
|
|
|
if (!JSXML_HAS_KIDS(xml) || argc == 0)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
arg = vp[2];
|
2018-09-08 18:08:48 +08:00
|
|
|
if (JSVAL_IS_NULL(arg)) {
|
|
|
|
|
kid = NULL;
|
|
|
|
|
i = xml->xml_kids.length;
|
|
|
|
|
} else {
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!VALUE_IS_XML(arg))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
2025-02-05 12:40:54 +10:00
|
|
|
kid = (JSXML *) JSVAL_TO_OBJECT(arg)->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
i = XMLARRAY_FIND_MEMBER(&xml->xml_kids, kid, NULL);
|
|
|
|
|
if (i == XML_NOT_FOUND)
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xml = CHECK_COPY_ON_WRITE(cx, xml, obj);
|
|
|
|
|
if (!xml)
|
|
|
|
|
return JS_FALSE;
|
2025-02-03 12:35:24 +10:00
|
|
|
return Insert(cx, xml, i, argc >= 2 ? vp[3] : JSVAL_VOID);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_length(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
XML_METHOD_PROLOG;
|
|
|
|
|
if (xml->xml_class != JSXML_CLASS_LIST) {
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = JSVAL_ONE;
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
uint32 l = xml->xml_kids.length;
|
|
|
|
|
if (l <= JSVAL_INT_MAX)
|
|
|
|
|
*vp = INT_TO_JSVAL(l);
|
|
|
|
|
else
|
|
|
|
|
*vp = DOUBLE_TO_JSVAL(l);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_localName(JSContext *cx, uintN argc, jsval *vp)
|
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
|
|
|
NON_LIST_XML_METHOD_PROLOG;
|
2025-03-19 21:25:58 +10:00
|
|
|
*vp = xml->name ? xml->name->getQNameLocalNameVal() : JSVAL_NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_name(JSContext *cx, uintN argc, jsval *vp)
|
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
|
|
|
NON_LIST_XML_METHOD_PROLOG;
|
2025-02-03 12:35:24 +10:00
|
|
|
*vp = OBJECT_TO_JSVAL(xml->name);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_namespace(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *prefix, *nsprefix;
|
2018-09-08 18:08:48 +08:00
|
|
|
jsuint i, length;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *ns;
|
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
|
|
|
NON_LIST_XML_METHOD_PROLOG;
|
|
|
|
|
if (argc == 0 && !JSXML_HAS_NAME(xml)) {
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = JSVAL_NULL;
|
2025-02-05 12:40:54 +10:00
|
|
|
return true;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (argc == 0) {
|
|
|
|
|
prefix = NULL;
|
|
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
JSString *str = js_ValueToString(cx, Valueify(vp[2]));
|
|
|
|
|
if (!str)
|
|
|
|
|
return false;
|
|
|
|
|
prefix = str->ensureLinear(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!prefix)
|
2025-02-05 12:40:54 +10:00
|
|
|
return false;
|
2023-07-12 13:27:26 +10:00
|
|
|
vp[2] = STRING_TO_JSVAL(prefix); /* local root */
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
AutoNamespaceArray inScopeNSes(cx);
|
|
|
|
|
if (!FindInScopeNamespaces(cx, xml, &inScopeNSes.array))
|
|
|
|
|
return false;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
if (!prefix) {
|
|
|
|
|
ns = GetNamespace(cx, xml->name, &inScopeNSes.array);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!ns)
|
|
|
|
|
return false;
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
|
|
|
|
ns = NULL;
|
|
|
|
|
for (i = 0, length = inScopeNSes.array.length; i < length; i++) {
|
2025-02-03 12:35:24 +10:00
|
|
|
ns = XMLARRAY_MEMBER(&inScopeNSes.array, i, JSObject);
|
|
|
|
|
if (ns) {
|
2025-03-19 21:25:58 +10:00
|
|
|
nsprefix = ns->getNamePrefix();
|
|
|
|
|
if (nsprefix && EqualStrings(nsprefix, prefix))
|
2025-02-03 12:35:24 +10:00
|
|
|
break;
|
|
|
|
|
ns = NULL;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
*vp = (!ns) ? JSVAL_VOID : OBJECT_TO_JSVAL(ns);
|
2025-02-05 12:40:54 +10:00
|
|
|
return true;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_namespaceDeclarations(JSContext *cx, uintN argc, jsval *vp)
|
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
|
|
|
NON_LIST_XML_METHOD_PROLOG;
|
|
|
|
|
if (JSXML_HAS_VALUE(xml))
|
2025-02-05 12:40:54 +10:00
|
|
|
return true;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
AutoNamespaceArray ancestors(cx);
|
|
|
|
|
AutoNamespaceArray declared(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXML *yml = xml;
|
2018-09-08 18:08:48 +08:00
|
|
|
while ((yml = yml->parent) != NULL) {
|
|
|
|
|
JS_ASSERT(yml->xml_class == JSXML_CLASS_ELEMENT);
|
2025-02-05 12:40:54 +10:00
|
|
|
for (uint32 i = 0, n = yml->xml_namespaces.length; i < n; i++) {
|
|
|
|
|
JSObject *ns = XMLARRAY_MEMBER(&yml->xml_namespaces, i, JSObject);
|
|
|
|
|
if (ns && !XMLARRAY_HAS_MEMBER(&ancestors.array, ns, namespace_match)) {
|
|
|
|
|
if (!XMLARRAY_APPEND(cx, &ancestors.array, ns))
|
|
|
|
|
return false;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
for (uint32 i = 0, n = xml->xml_namespaces.length; i < n; i++) {
|
|
|
|
|
JSObject *ns = XMLARRAY_MEMBER(&xml->xml_namespaces, i, JSObject);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ns)
|
|
|
|
|
continue;
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!IsDeclared(ns))
|
2018-09-08 18:08:48 +08:00
|
|
|
continue;
|
|
|
|
|
if (!XMLARRAY_HAS_MEMBER(&ancestors.array, ns, namespace_match)) {
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!XMLARRAY_APPEND(cx, &declared.array, ns))
|
|
|
|
|
return false;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
return NamespacesToJSArray(cx, &declared.array, vp);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const char js_attribute_str[] = "attribute";
|
|
|
|
|
static const char js_text_str[] = "text";
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/* Exported to jsgc.c #ifdef DEBUG. */
|
2018-09-08 18:08:48 +08:00
|
|
|
const char *js_xml_class_str[] = {
|
|
|
|
|
"list",
|
|
|
|
|
"element",
|
|
|
|
|
js_attribute_str,
|
|
|
|
|
"processing-instruction",
|
|
|
|
|
js_text_str,
|
|
|
|
|
"comment"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_nodeKind(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSString *str;
|
|
|
|
|
|
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
|
|
|
NON_LIST_XML_METHOD_PROLOG;
|
2018-09-08 18:08:48 +08:00
|
|
|
str = JS_InternString(cx, js_xml_class_str[xml->xml_class]);
|
|
|
|
|
if (!str)
|
|
|
|
|
return JS_FALSE;
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = STRING_TO_JSVAL(str);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
static void
|
|
|
|
|
NormalizingDelete(JSContext *cx, JSXML *xml, uint32 index)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST)
|
2023-07-12 13:27:26 +10:00
|
|
|
DeleteListElement(cx, xml, index);
|
|
|
|
|
else
|
|
|
|
|
DeleteByIndex(cx, xml, index);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_normalize_helper(JSContext *cx, JSObject *obj, JSXML *xml)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXML *kid, *kid2;
|
2018-09-08 18:08:48 +08:00
|
|
|
uint32 i, n;
|
|
|
|
|
JSObject *kidobj;
|
|
|
|
|
JSString *str;
|
|
|
|
|
|
|
|
|
|
if (!JSXML_HAS_KIDS(xml))
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
|
|
|
|
|
xml = CHECK_COPY_ON_WRITE(cx, xml, obj);
|
|
|
|
|
if (!xml)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
for (i = 0, n = xml->xml_kids.length; i < n; i++) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
|
|
|
|
|
if (!kid)
|
|
|
|
|
continue;
|
|
|
|
|
if (kid->xml_class == JSXML_CLASS_ELEMENT) {
|
|
|
|
|
kidobj = js_GetXMLObject(cx, kid);
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!kidobj || !xml_normalize_helper(cx, kidobj, kid))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
} else if (kid->xml_class == JSXML_CLASS_TEXT) {
|
|
|
|
|
while (i + 1 < n &&
|
|
|
|
|
(kid2 = XMLARRAY_MEMBER(&xml->xml_kids, i + 1, JSXML)) &&
|
|
|
|
|
kid2->xml_class == JSXML_CLASS_TEXT) {
|
|
|
|
|
str = js_ConcatStrings(cx, kid->xml_value, kid2->xml_value);
|
|
|
|
|
if (!str)
|
|
|
|
|
return JS_FALSE;
|
2023-07-12 13:27:26 +10:00
|
|
|
NormalizingDelete(cx, xml, i + 1);
|
2018-09-08 18:08:48 +08:00
|
|
|
n = xml->xml_kids.length;
|
|
|
|
|
kid->xml_value = str;
|
|
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
if (kid->xml_value->empty()) {
|
2023-07-12 13:27:26 +10:00
|
|
|
NormalizingDelete(cx, xml, i);
|
2018-09-08 18:08:48 +08:00
|
|
|
n = xml->xml_kids.length;
|
|
|
|
|
--i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
static JSBool
|
|
|
|
|
xml_normalize(JSContext *cx, uintN argc, jsval *vp)
|
|
|
|
|
{
|
|
|
|
|
XML_METHOD_PROLOG;
|
|
|
|
|
*vp = OBJECT_TO_JSVAL(obj);
|
|
|
|
|
return xml_normalize_helper(cx, obj, xml);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_parent(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXML *parent, *kid;
|
2018-09-08 18:08:48 +08:00
|
|
|
uint32 i, n;
|
|
|
|
|
JSObject *parentobj;
|
|
|
|
|
|
|
|
|
|
XML_METHOD_PROLOG;
|
|
|
|
|
parent = xml->parent;
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = JSVAL_VOID;
|
2018-09-08 18:08:48 +08:00
|
|
|
n = xml->xml_kids.length;
|
|
|
|
|
if (n == 0)
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, 0, JSXML);
|
|
|
|
|
if (!kid)
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
parent = kid->parent;
|
|
|
|
|
for (i = 1; i < n; i++) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
|
|
|
|
|
if (kid && kid->parent != parent)
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!parent) {
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = JSVAL_NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parentobj = js_GetXMLObject(cx, parent);
|
|
|
|
|
if (!parentobj)
|
|
|
|
|
return JS_FALSE;
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = OBJECT_TO_JSVAL(parentobj);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_processingInstructions_helper(JSContext *cx, JSObject *obj, JSXML *xml,
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *nameqn, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXML *list, *vxml;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSBool ok;
|
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
|
|
|
JSObject *kidobj;
|
2023-07-12 13:27:26 +10:00
|
|
|
jsval v;
|
2018-09-08 18:08:48 +08:00
|
|
|
uint32 i, n;
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
list = xml_list_helper(cx, xml, vp);
|
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 (!list)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
list->xml_targetprop = nameqn;
|
|
|
|
|
ok = JS_TRUE;
|
|
|
|
|
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
/* 13.5.4.17 Step 4 (misnumbered 9 -- Erratum?). */
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXMLArrayCursor cursor(&xml->xml_kids);
|
|
|
|
|
while (JSXML *kid = (JSXML *) cursor.getNext()) {
|
2018-09-08 18:08:48 +08:00
|
|
|
if (kid->xml_class == JSXML_CLASS_ELEMENT) {
|
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
|
|
|
ok = js_EnterLocalRootScope(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ok)
|
|
|
|
|
break;
|
|
|
|
|
kidobj = js_GetXMLObject(cx, kid);
|
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 (kidobj) {
|
2023-07-12 13:27:26 +10:00
|
|
|
ok = xml_processingInstructions_helper(cx, kidobj, kid,
|
|
|
|
|
nameqn, &v);
|
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
|
|
|
} else {
|
|
|
|
|
ok = JS_FALSE;
|
|
|
|
|
v = JSVAL_NULL;
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
js_LeaveLocalRootScopeWithResult(cx, Valueify(v));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ok)
|
|
|
|
|
break;
|
2025-02-05 12:40:54 +10:00
|
|
|
vxml = (JSXML *) JSVAL_TO_OBJECT(v)->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (JSXML_LENGTH(vxml) != 0) {
|
|
|
|
|
ok = Append(cx, list, vxml);
|
|
|
|
|
if (!ok)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* 13.4.4.28 Step 4. */
|
|
|
|
|
for (i = 0, n = JSXML_LENGTH(xml); i < n; i++) {
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXML *kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
|
2025-02-03 12:35:24 +10:00
|
|
|
if (kid && kid->xml_class == JSXML_CLASS_PROCESSING_INSTRUCTION) {
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *localName = nameqn->getQNameLocalName();
|
2025-02-03 12:35:24 +10:00
|
|
|
if (IS_STAR(localName) ||
|
2025-03-19 21:25:58 +10:00
|
|
|
EqualStrings(localName, kid->name->getQNameLocalName())) {
|
2025-02-03 12:35:24 +10:00
|
|
|
ok = Append(cx, list, kid);
|
|
|
|
|
if (!ok)
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_processingInstructions(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
jsval name;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *nameqn;
|
2023-07-12 13:27:26 +10:00
|
|
|
jsid funid;
|
|
|
|
|
|
|
|
|
|
XML_METHOD_PROLOG;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
name = (argc == 0) ? ATOM_TO_JSVAL(cx->runtime->atomState.starAtom) : vp[2];
|
2023-07-12 13:27:26 +10:00
|
|
|
nameqn = ToXMLName(cx, name, &funid);
|
|
|
|
|
if (!nameqn)
|
|
|
|
|
return JS_FALSE;
|
2025-02-03 12:35:24 +10:00
|
|
|
vp[2] = OBJECT_TO_JSVAL(nameqn);
|
2023-07-12 13:27:26 +10:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!JSID_IS_VOID(funid))
|
2023-07-12 13:27:26 +10:00
|
|
|
return xml_list_helper(cx, xml, vp) != NULL;
|
|
|
|
|
|
|
|
|
|
return xml_processingInstructions_helper(cx, obj, xml, nameqn, vp);
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
static JSBool
|
|
|
|
|
xml_prependChild(JSContext *cx, uintN argc, jsval *vp)
|
|
|
|
|
{
|
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
|
|
|
NON_LIST_XML_METHOD_PROLOG;
|
2018-09-08 18:08:48 +08:00
|
|
|
xml = CHECK_COPY_ON_WRITE(cx, xml, obj);
|
|
|
|
|
if (!xml)
|
|
|
|
|
return JS_FALSE;
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = OBJECT_TO_JSVAL(obj);
|
2025-02-03 12:35:24 +10:00
|
|
|
return Insert(cx, xml, 0, argc != 0 ? vp[2] : JSVAL_VOID);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_propertyIsEnumerable(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
bool isIndex;
|
2018-09-08 18:08:48 +08:00
|
|
|
uint32 index;
|
|
|
|
|
|
|
|
|
|
XML_METHOD_PROLOG;
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = JSVAL_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (argc != 0) {
|
|
|
|
|
if (!js_IdValIsIndex(cx, vp[2], &index, &isIndex))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
if (isIndex) {
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
/* 13.5.4.18. */
|
|
|
|
|
*vp = BOOLEAN_TO_JSVAL(index < xml->xml_kids.length);
|
|
|
|
|
} else {
|
|
|
|
|
/* 13.4.4.30. */
|
|
|
|
|
*vp = BOOLEAN_TO_JSVAL(index == 0);
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
namespace_full_match(const void *a, const void *b)
|
|
|
|
|
{
|
2025-02-03 12:35:24 +10:00
|
|
|
const JSObject *nsa = (const JSObject *) a;
|
|
|
|
|
const JSObject *nsb = (const JSObject *) b;
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *prefixa = nsa->getNamePrefix();
|
|
|
|
|
JSLinearString *prefixb;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
if (prefixa) {
|
2025-03-19 21:25:58 +10:00
|
|
|
prefixb = nsb->getNamePrefix();
|
|
|
|
|
if (prefixb && !EqualStrings(prefixa, prefixb))
|
2025-02-03 12:35:24 +10:00
|
|
|
return JS_FALSE;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
return EqualStrings(nsa->getNameURI(), nsb->getNameURI());
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2025-02-03 12:35:24 +10:00
|
|
|
xml_removeNamespace_helper(JSContext *cx, JSXML *xml, JSObject *ns)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *thisns, *attrns;
|
2018-09-08 18:08:48 +08:00
|
|
|
uint32 i, n;
|
|
|
|
|
JSXML *attr, *kid;
|
|
|
|
|
|
|
|
|
|
thisns = GetNamespace(cx, xml->name, &xml->xml_namespaces);
|
|
|
|
|
JS_ASSERT(thisns);
|
|
|
|
|
if (thisns == ns)
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
|
|
|
|
|
for (i = 0, n = xml->xml_attrs.length; i < n; i++) {
|
|
|
|
|
attr = XMLARRAY_MEMBER(&xml->xml_attrs, i, JSXML);
|
|
|
|
|
if (!attr)
|
|
|
|
|
continue;
|
|
|
|
|
attrns = GetNamespace(cx, attr->name, &xml->xml_namespaces);
|
|
|
|
|
JS_ASSERT(attrns);
|
|
|
|
|
if (attrns == ns)
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i = XMLARRAY_FIND_MEMBER(&xml->xml_namespaces, ns, namespace_full_match);
|
|
|
|
|
if (i != XML_NOT_FOUND)
|
|
|
|
|
XMLArrayDelete(cx, &xml->xml_namespaces, i, JS_TRUE);
|
|
|
|
|
|
|
|
|
|
for (i = 0, n = xml->xml_kids.length; i < n; i++) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
|
|
|
|
|
if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) {
|
|
|
|
|
if (!xml_removeNamespace_helper(cx, kid, ns))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_removeNamespace(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *ns;
|
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
|
|
|
NON_LIST_XML_METHOD_PROLOG;
|
2018-09-08 18:08:48 +08:00
|
|
|
if (xml->xml_class != JSXML_CLASS_ELEMENT)
|
2023-07-12 13:27:26 +10:00
|
|
|
goto done;
|
2018-09-08 18:08:48 +08:00
|
|
|
xml = CHECK_COPY_ON_WRITE(cx, xml, obj);
|
|
|
|
|
if (!xml)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!NamespaceHelper(cx, NULL, argc == 0 ? -1 : 1, vp + 2, vp))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
2023-07-12 13:27:26 +10:00
|
|
|
JS_ASSERT(!JSVAL_IS_PRIMITIVE(*vp));
|
2025-02-03 12:35:24 +10:00
|
|
|
ns = JSVAL_TO_OBJECT(*vp);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
/* NOTE: remove ns from each ancestor if not used by that ancestor. */
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!xml_removeNamespace_helper(cx, xml, ns))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
done:
|
|
|
|
|
*vp = OBJECT_TO_JSVAL(obj);
|
|
|
|
|
return JS_TRUE;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_replace(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
jsval value;
|
|
|
|
|
JSXML *vxml, *kid;
|
|
|
|
|
uint32 index, i;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *nameqn;
|
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
|
|
|
NON_LIST_XML_METHOD_PROLOG;
|
2018-09-08 18:08:48 +08:00
|
|
|
if (xml->xml_class != JSXML_CLASS_ELEMENT)
|
2023-07-12 13:27:26 +10:00
|
|
|
goto done;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
if (argc <= 1) {
|
2025-03-19 21:25:58 +10:00
|
|
|
value = ATOM_TO_JSVAL(cx->runtime->atomState.typeAtoms[JSTYPE_VOID]);
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
2025-02-03 12:35:24 +10:00
|
|
|
value = vp[3];
|
2025-02-05 12:40:54 +10:00
|
|
|
vxml = VALUE_IS_XML(value)
|
|
|
|
|
? (JSXML *) JSVAL_TO_OBJECT(value)->getPrivate()
|
2025-02-03 12:35:24 +10:00
|
|
|
: NULL;
|
|
|
|
|
if (!vxml) {
|
|
|
|
|
if (!JS_ConvertValue(cx, value, JSTYPE_STRING, &vp[3]))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
value = vp[3];
|
|
|
|
|
} else {
|
|
|
|
|
vxml = DeepCopy(cx, vxml, NULL, 0);
|
|
|
|
|
if (!vxml)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
value = vp[3] = OBJECT_TO_JSVAL(vxml->object);
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xml = CHECK_COPY_ON_WRITE(cx, xml, obj);
|
|
|
|
|
if (!xml)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
bool haveIndex;
|
|
|
|
|
if (argc == 0) {
|
|
|
|
|
haveIndex = false;
|
|
|
|
|
} else {
|
|
|
|
|
if (!js_IdValIsIndex(cx, vp[2], &index, &haveIndex))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!haveIndex) {
|
2023-07-12 13:27:26 +10:00
|
|
|
/*
|
|
|
|
|
* Call function QName per spec, not ToXMLName, to avoid attribute
|
|
|
|
|
* names.
|
|
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!QNameHelper(cx, NULL, argc == 0 ? -1 : 1, vp + 2, vp))
|
2023-07-12 13:27:26 +10:00
|
|
|
return JS_FALSE;
|
|
|
|
|
JS_ASSERT(!JSVAL_IS_PRIMITIVE(*vp));
|
2025-02-03 12:35:24 +10:00
|
|
|
nameqn = JSVAL_TO_OBJECT(*vp);
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
i = xml->xml_kids.length;
|
|
|
|
|
index = XML_NOT_FOUND;
|
|
|
|
|
while (i != 0) {
|
|
|
|
|
--i;
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
|
|
|
|
|
if (kid && MatchElemName(nameqn, kid)) {
|
|
|
|
|
if (i != XML_NOT_FOUND)
|
|
|
|
|
DeleteByIndex(cx, xml, i);
|
|
|
|
|
index = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (index == XML_NOT_FOUND)
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!Replace(cx, xml, index, value))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
done:
|
|
|
|
|
*vp = OBJECT_TO_JSVAL(obj);
|
|
|
|
|
return JS_TRUE;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_setChildren(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSObject *obj;
|
|
|
|
|
|
|
|
|
|
if (!StartNonListXMLMethod(cx, vp, &obj))
|
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
|
|
|
return JS_FALSE;
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
*vp = argc != 0 ? vp[2] : JSVAL_VOID; /* local root */
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!PutProperty(cx, obj, ATOM_TO_JSID(cx->runtime->atomState.starAtom), false, vp))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = OBJECT_TO_JSVAL(obj);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_setLocalName(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
jsval name;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *nameqn;
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *namestr;
|
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
|
|
|
NON_LIST_XML_METHOD_PROLOG;
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!JSXML_HAS_NAME(xml))
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
if (argc == 0) {
|
|
|
|
|
namestr = ATOM_TO_STRING(cx->runtime->atomState.typeAtoms[JSTYPE_VOID]);
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
2023-07-12 13:27:26 +10:00
|
|
|
name = vp[2];
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!JSVAL_IS_PRIMITIVE(name) &&
|
2025-03-19 21:25:58 +10:00
|
|
|
JSVAL_TO_OBJECT(name)->getClass() == &js_QNameClass) {
|
2025-02-03 12:35:24 +10:00
|
|
|
nameqn = JSVAL_TO_OBJECT(name);
|
2025-03-19 21:25:58 +10:00
|
|
|
namestr = nameqn->getQNameLocalName();
|
2025-02-03 12:35:24 +10:00
|
|
|
} else {
|
|
|
|
|
if (!JS_ConvertValue(cx, name, JSTYPE_STRING, &vp[2]))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
name = vp[2];
|
2025-03-19 21:25:58 +10:00
|
|
|
namestr = JSVAL_TO_STRING(name)->ensureLinear(cx);
|
|
|
|
|
if (!namestr)
|
|
|
|
|
return JS_FALSE;
|
2025-02-03 12:35:24 +10:00
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xml = CHECK_COPY_ON_WRITE(cx, xml, obj);
|
|
|
|
|
if (!xml)
|
|
|
|
|
return JS_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (namestr)
|
|
|
|
|
xml->name->setQNameLocalName(namestr);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_setName(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
jsval name;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *nameqn;
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXML *nsowner;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSXMLArray *nsarray;
|
|
|
|
|
uint32 i, n;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *ns;
|
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
|
|
|
NON_LIST_XML_METHOD_PROLOG;
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!JSXML_HAS_NAME(xml))
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
if (argc == 0) {
|
2025-03-19 21:25:58 +10:00
|
|
|
name = ATOM_TO_JSVAL(cx->runtime->atomState.typeAtoms[JSTYPE_VOID]);
|
2025-02-03 12:35:24 +10:00
|
|
|
} else {
|
|
|
|
|
name = vp[2];
|
|
|
|
|
if (!JSVAL_IS_PRIMITIVE(name) &&
|
2025-03-19 21:25:58 +10:00
|
|
|
JSVAL_TO_OBJECT(name)->getClass() == &js_QNameClass &&
|
|
|
|
|
!(nameqn = JSVAL_TO_OBJECT(name))->getNameURI()) {
|
|
|
|
|
name = vp[2] = nameqn->getQNameLocalNameVal();
|
2025-02-03 12:35:24 +10:00
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
nameqn = js_ConstructObject(cx, &js_QNameClass, NULL, NULL, 1, Valueify(&name));
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!nameqn)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
/* ECMA-357 13.4.4.35 Step 4. */
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_PROCESSING_INSTRUCTION)
|
2025-03-19 21:25:58 +10:00
|
|
|
nameqn->setNameURI(cx->runtime->emptyString);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
xml = CHECK_COPY_ON_WRITE(cx, xml, obj);
|
|
|
|
|
if (!xml)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
xml->name = nameqn;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Erratum: nothing in 13.4.4.35 talks about making the name match the
|
|
|
|
|
* in-scope namespaces, either by finding an in-scope namespace with a
|
|
|
|
|
* matching uri and setting the new name's prefix to that namespace's
|
|
|
|
|
* prefix, or by extending the in-scope namespaces for xml (which are in
|
|
|
|
|
* xml->parent if xml is an attribute or a PI).
|
|
|
|
|
*/
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_ELEMENT) {
|
|
|
|
|
nsowner = xml;
|
|
|
|
|
} else {
|
|
|
|
|
if (!xml->parent || xml->parent->xml_class != JSXML_CLASS_ELEMENT)
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
nsowner = xml->parent;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (nameqn->getNamePrefix()) {
|
2018-09-08 18:08:48 +08:00
|
|
|
/*
|
|
|
|
|
* The name being set has a prefix, which originally came from some
|
|
|
|
|
* namespace object (which may be the null namespace, where both the
|
|
|
|
|
* prefix and uri are the empty string). We must go through a full
|
|
|
|
|
* GetNamespace in case that namespace is in-scope in nsowner.
|
|
|
|
|
*
|
|
|
|
|
* If we find such an in-scope namespace, we return true right away,
|
|
|
|
|
* in this block. Otherwise, we fall through to the final return of
|
|
|
|
|
* AddInScopeNamespace(cx, nsowner, ns).
|
|
|
|
|
*/
|
|
|
|
|
ns = GetNamespace(cx, nameqn, &nsowner->xml_namespaces);
|
|
|
|
|
if (!ns)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
/* XXXbe have to test membership to see whether GetNamespace added */
|
|
|
|
|
if (XMLARRAY_HAS_MEMBER(&nsowner->xml_namespaces, ns, NULL))
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
} else {
|
|
|
|
|
/*
|
2025-02-03 12:35:24 +10:00
|
|
|
* At this point, we know prefix of nameqn is null, so its uri can't
|
2018-09-08 18:08:48 +08:00
|
|
|
* be the empty string (the null namespace always uses the empty string
|
|
|
|
|
* for both prefix and uri).
|
|
|
|
|
*
|
|
|
|
|
* This means we must inline GetNamespace and specialize it to match
|
|
|
|
|
* uri only, never prefix. If we find a namespace with nameqn's uri
|
|
|
|
|
* already in nsowner->xml_namespaces, then all that we need do is set
|
2025-02-03 12:35:24 +10:00
|
|
|
* prefix of nameqn to that namespace's prefix.
|
2018-09-08 18:08:48 +08:00
|
|
|
*
|
|
|
|
|
* If no such namespace exists, we can create one without going through
|
2025-02-03 12:35:24 +10:00
|
|
|
* the constructor, because we know uri of nameqn is non-empty (so
|
|
|
|
|
* prefix does not need to be converted from null to empty by QName).
|
2018-09-08 18:08:48 +08:00
|
|
|
*/
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_ASSERT(!nameqn->getNameURI()->empty());
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
nsarray = &nsowner->xml_namespaces;
|
|
|
|
|
for (i = 0, n = nsarray->length; i < n; i++) {
|
2025-02-03 12:35:24 +10:00
|
|
|
ns = XMLARRAY_MEMBER(nsarray, i, JSObject);
|
2025-03-19 21:25:58 +10:00
|
|
|
if (ns && EqualStrings(ns->getNameURI(), nameqn->getNameURI())) {
|
2025-02-05 12:40:54 +10:00
|
|
|
nameqn->setNamePrefix(ns->getNamePrefix());
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
ns = NewXMLNamespace(cx, NULL, nameqn->getNameURI(), JS_TRUE);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ns)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!AddInScopeNamespace(cx, nsowner, ns))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
vp[0] = JSVAL_VOID;
|
|
|
|
|
return JS_TRUE;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_setNamespace(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *qn;
|
|
|
|
|
JSObject *ns;
|
2018-09-08 18:08:48 +08:00
|
|
|
jsval qnargv[2];
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXML *nsowner;
|
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
|
|
|
NON_LIST_XML_METHOD_PROLOG;
|
|
|
|
|
if (!JSXML_HAS_NAME(xml))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
|
|
|
|
|
xml = CHECK_COPY_ON_WRITE(cx, xml, obj);
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!xml)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
ns = js_ConstructObject(cx, &js_NamespaceClass, NULL, obj,
|
|
|
|
|
argc == 0 ? 0 : 1, Valueify(vp + 2));
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!ns)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
2025-02-03 12:35:24 +10:00
|
|
|
vp[0] = OBJECT_TO_JSVAL(ns);
|
2025-02-05 12:40:54 +10:00
|
|
|
ns->setNamespaceDeclared(JSVAL_TRUE);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
qnargv[0] = OBJECT_TO_JSVAL(ns);
|
2025-02-03 12:35:24 +10:00
|
|
|
qnargv[1] = OBJECT_TO_JSVAL(xml->name);
|
2025-03-19 21:25:58 +10:00
|
|
|
qn = js_ConstructObject(cx, &js_QNameClass, NULL, NULL, 2, Valueify(qnargv));
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!qn)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
xml->name = qn;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Erratum: the spec fails to update the governing in-scope namespaces.
|
|
|
|
|
* See the erratum noted in xml_setName, above.
|
|
|
|
|
*/
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_ELEMENT) {
|
|
|
|
|
nsowner = xml;
|
|
|
|
|
} else {
|
|
|
|
|
if (!xml->parent || xml->parent->xml_class != JSXML_CLASS_ELEMENT)
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
nsowner = xml->parent;
|
|
|
|
|
}
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!AddInScopeNamespace(cx, nsowner, ns))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
vp[0] = JSVAL_VOID;
|
|
|
|
|
return JS_TRUE;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_text_helper(JSContext *cx, JSObject *obj, JSXML *xml, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXML *list, *kid, *vxml;
|
2018-09-08 18:08:48 +08:00
|
|
|
uint32 i, n;
|
|
|
|
|
JSBool ok;
|
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
|
|
|
JSObject *kidobj;
|
2018-09-08 18:08:48 +08:00
|
|
|
jsval v;
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
list = xml_list_helper(cx, xml, vp);
|
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 (!list)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
ok = JS_TRUE;
|
|
|
|
|
for (i = 0, n = xml->xml_kids.length; i < n; i++) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
|
|
|
|
|
if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) {
|
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
|
|
|
ok = js_EnterLocalRootScope(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ok)
|
|
|
|
|
break;
|
|
|
|
|
kidobj = js_GetXMLObject(cx, kid);
|
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 (kidobj) {
|
2023-07-12 13:27:26 +10:00
|
|
|
ok = xml_text_helper(cx, kidobj, kid, &v);
|
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
|
|
|
} else {
|
|
|
|
|
ok = JS_FALSE;
|
|
|
|
|
v = JSVAL_NULL;
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
js_LeaveLocalRootScopeWithResult(cx, Valueify(v));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!ok)
|
|
|
|
|
return JS_FALSE;
|
2025-02-05 12:40:54 +10:00
|
|
|
vxml = (JSXML *) JSVAL_TO_OBJECT(v)->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (JSXML_LENGTH(vxml) != 0 && !Append(cx, list, vxml))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for (i = 0, n = JSXML_LENGTH(xml); i < n; i++) {
|
|
|
|
|
kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
|
|
|
|
|
if (kid && kid->xml_class == JSXML_CLASS_TEXT) {
|
|
|
|
|
if (!Append(cx, list, kid))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_text(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
XML_METHOD_PROLOG;
|
|
|
|
|
return xml_text_helper(cx, obj, xml, vp);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSString *
|
|
|
|
|
xml_toString_helper(JSContext *cx, JSXML *xml)
|
|
|
|
|
{
|
|
|
|
|
JSString *str, *kidstr;
|
|
|
|
|
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_ATTRIBUTE ||
|
|
|
|
|
xml->xml_class == JSXML_CLASS_TEXT) {
|
|
|
|
|
return xml->xml_value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!HasSimpleContent(xml))
|
2023-07-12 13:27:26 +10:00
|
|
|
return ToXMLString(cx, OBJECT_TO_JSVAL(xml->object), 0);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
str = cx->runtime->emptyString;
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!js_EnterLocalRootScope(cx))
|
|
|
|
|
return NULL;
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXMLArrayCursor cursor(&xml->xml_kids);
|
|
|
|
|
while (JSXML *kid = (JSXML *) cursor.getNext()) {
|
2018-09-08 18:08:48 +08:00
|
|
|
if (kid->xml_class != JSXML_CLASS_COMMENT &&
|
|
|
|
|
kid->xml_class != JSXML_CLASS_PROCESSING_INSTRUCTION) {
|
|
|
|
|
kidstr = xml_toString_helper(cx, kid);
|
|
|
|
|
if (!kidstr) {
|
|
|
|
|
str = NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
str = js_ConcatStrings(cx, str, kidstr);
|
|
|
|
|
if (!str)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
js_LeaveLocalRootScopeWithResult(cx, str);
|
2018-09-08 18:08:48 +08:00
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_toSource(JSContext *cx, uintN argc, jsval *vp)
|
|
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *obj = ToObject(cx, Valueify(&vp[1]));
|
|
|
|
|
if (!obj)
|
2023-07-12 13:27:26 +10:00
|
|
|
return JS_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
JSString *str = ToXMLString(cx, OBJECT_TO_JSVAL(obj), TO_SOURCE_FLAG);
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!str)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
*vp = STRING_TO_JSVAL(str);
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
xml_toString(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSString *str;
|
|
|
|
|
|
|
|
|
|
XML_METHOD_PROLOG;
|
|
|
|
|
str = xml_toString_helper(cx, xml);
|
|
|
|
|
if (!str)
|
|
|
|
|
return JS_FALSE;
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = STRING_TO_JSVAL(str);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_toXMLString(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *obj = ToObject(cx, Valueify(&vp[1]));
|
|
|
|
|
if (!obj)
|
2023-07-12 13:27:26 +10:00
|
|
|
return JS_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
JSString *str = ToXMLString(cx, OBJECT_TO_JSVAL(obj), 0);
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!str)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
*vp = STRING_TO_JSVAL(str);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/* XML and XMLList */
|
|
|
|
|
static JSBool
|
|
|
|
|
xml_valueOf(JSContext *cx, uintN argc, jsval *vp)
|
|
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *obj = ToObject(cx, Valueify(&vp[1]));
|
|
|
|
|
if (!obj)
|
|
|
|
|
return false;
|
|
|
|
|
*vp = OBJECT_TO_JSVAL(obj);
|
|
|
|
|
return true;
|
2023-07-12 13:27:26 +10:00
|
|
|
}
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
static JSFunctionSpec xml_methods[] = {
|
2025-02-03 12:35:24 +10:00
|
|
|
JS_FN("addNamespace", xml_addNamespace, 1,0),
|
|
|
|
|
JS_FN("appendChild", xml_appendChild, 1,0),
|
|
|
|
|
JS_FN(js_attribute_str, xml_attribute, 1,0),
|
|
|
|
|
JS_FN("attributes", xml_attributes, 0,0),
|
|
|
|
|
JS_FN("child", xml_child, 1,0),
|
|
|
|
|
JS_FN("childIndex", xml_childIndex, 0,0),
|
|
|
|
|
JS_FN("children", xml_children, 0,0),
|
|
|
|
|
JS_FN("comments", xml_comments, 0,0),
|
|
|
|
|
JS_FN("contains", xml_contains, 1,0),
|
|
|
|
|
JS_FN("copy", xml_copy, 0,0),
|
|
|
|
|
JS_FN("descendants", xml_descendants, 1,0),
|
|
|
|
|
JS_FN("elements", xml_elements, 1,0),
|
|
|
|
|
JS_FN("hasOwnProperty", xml_hasOwnProperty, 1,0),
|
|
|
|
|
JS_FN("hasComplexContent", xml_hasComplexContent, 1,0),
|
|
|
|
|
JS_FN("hasSimpleContent", xml_hasSimpleContent, 1,0),
|
|
|
|
|
JS_FN("inScopeNamespaces", xml_inScopeNamespaces, 0,0),
|
|
|
|
|
JS_FN("insertChildAfter", xml_insertChildAfter, 2,0),
|
|
|
|
|
JS_FN("insertChildBefore", xml_insertChildBefore, 2,0),
|
|
|
|
|
JS_FN(js_length_str, xml_length, 0,0),
|
|
|
|
|
JS_FN(js_localName_str, xml_localName, 0,0),
|
|
|
|
|
JS_FN(js_name_str, xml_name, 0,0),
|
|
|
|
|
JS_FN(js_namespace_str, xml_namespace, 1,0),
|
|
|
|
|
JS_FN("namespaceDeclarations", xml_namespaceDeclarations, 0,0),
|
|
|
|
|
JS_FN("nodeKind", xml_nodeKind, 0,0),
|
|
|
|
|
JS_FN("normalize", xml_normalize, 0,0),
|
|
|
|
|
JS_FN(js_xml_parent_str, xml_parent, 0,0),
|
|
|
|
|
JS_FN("processingInstructions",xml_processingInstructions,1,0),
|
|
|
|
|
JS_FN("prependChild", xml_prependChild, 1,0),
|
|
|
|
|
JS_FN("propertyIsEnumerable", xml_propertyIsEnumerable, 1,0),
|
|
|
|
|
JS_FN("removeNamespace", xml_removeNamespace, 1,0),
|
|
|
|
|
JS_FN("replace", xml_replace, 2,0),
|
|
|
|
|
JS_FN("setChildren", xml_setChildren, 1,0),
|
|
|
|
|
JS_FN("setLocalName", xml_setLocalName, 1,0),
|
|
|
|
|
JS_FN("setName", xml_setName, 1,0),
|
|
|
|
|
JS_FN("setNamespace", xml_setNamespace, 1,0),
|
|
|
|
|
JS_FN(js_text_str, xml_text, 0,0),
|
|
|
|
|
JS_FN(js_toSource_str, xml_toSource, 0,0),
|
|
|
|
|
JS_FN(js_toString_str, xml_toString, 0,0),
|
|
|
|
|
JS_FN(js_toXMLString_str, xml_toXMLString, 0,0),
|
|
|
|
|
JS_FN(js_valueOf_str, xml_valueOf, 0,0),
|
2023-07-12 13:27:26 +10:00
|
|
|
JS_FS_END
|
2018-09-08 18:08:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
CopyXMLSettings(JSContext *cx, JSObject *from, JSObject *to)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
const char *name;
|
|
|
|
|
jsval v;
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
/* Note: PRETTY_INDENT is not a boolean setting. */
|
|
|
|
|
for (i = 0; xml_static_props[i].name; i++) {
|
2018-09-08 18:08:48 +08:00
|
|
|
name = xml_static_props[i].name;
|
|
|
|
|
if (!JS_GetProperty(cx, from, name, &v))
|
2025-02-05 12:40:54 +10:00
|
|
|
return false;
|
|
|
|
|
if (name == js_prettyIndent_str) {
|
|
|
|
|
if (!JSVAL_IS_NUMBER(v))
|
|
|
|
|
continue;
|
|
|
|
|
} else {
|
|
|
|
|
if (!JSVAL_IS_BOOLEAN(v))
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (!JS_SetProperty(cx, to, name, &v))
|
|
|
|
|
return false;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
return true;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
|
|
|
|
SetDefaultXMLSettings(JSContext *cx, JSObject *obj)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
jsval v;
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
/* Note: PRETTY_INDENT is not a boolean setting. */
|
|
|
|
|
for (i = 0; xml_static_props[i].name; i++) {
|
|
|
|
|
v = (xml_static_props[i].name != js_prettyIndent_str)
|
|
|
|
|
? JSVAL_TRUE : INT_TO_JSVAL(2);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!JS_SetProperty(cx, obj, xml_static_props[i].name, &v))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
return true;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_settings(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *settings = JS_NewObject(cx, NULL, NULL, NULL);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!settings)
|
2025-03-19 21:25:58 +10:00
|
|
|
return false;
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = OBJECT_TO_JSVAL(settings);
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *obj = ToObject(cx, Valueify(&vp[1]));
|
|
|
|
|
if (!obj)
|
|
|
|
|
return false;
|
|
|
|
|
return CopyXMLSettings(cx, obj, settings);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_setSettings(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *settings;
|
2018-09-08 18:08:48 +08:00
|
|
|
jsval v;
|
|
|
|
|
JSBool ok;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *obj = ToObject(cx, Valueify(&vp[1]));
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!obj)
|
|
|
|
|
return JS_FALSE;
|
2025-02-03 12:35:24 +10:00
|
|
|
v = (argc == 0) ? JSVAL_VOID : vp[2];
|
2018-09-08 18:08:48 +08:00
|
|
|
if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) {
|
|
|
|
|
ok = SetDefaultXMLSettings(cx, obj);
|
|
|
|
|
} else {
|
|
|
|
|
if (JSVAL_IS_PRIMITIVE(v))
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
settings = JSVAL_TO_OBJECT(v);
|
|
|
|
|
ok = CopyXMLSettings(cx, settings, obj);
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_defaultSettings(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSObject *settings;
|
|
|
|
|
|
|
|
|
|
settings = JS_NewObject(cx, NULL, NULL, NULL);
|
|
|
|
|
if (!settings)
|
|
|
|
|
return JS_FALSE;
|
2023-07-12 13:27:26 +10:00
|
|
|
*vp = OBJECT_TO_JSVAL(settings);
|
2018-09-08 18:08:48 +08:00
|
|
|
return SetDefaultXMLSettings(cx, settings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSFunctionSpec xml_static_methods[] = {
|
2025-02-03 12:35:24 +10:00
|
|
|
JS_FN("settings", xml_settings, 0,0),
|
|
|
|
|
JS_FN("setSettings", xml_setSettings, 1,0),
|
|
|
|
|
JS_FN("defaultSettings", xml_defaultSettings, 0,0),
|
2023-07-12 13:27:26 +10:00
|
|
|
JS_FS_END
|
2018-09-08 18:08:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
XML(JSContext *cx, uintN argc, Value *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSXML *xml, *copy;
|
|
|
|
|
JSObject *xobj, *vobj;
|
2025-03-19 21:25:58 +10:00
|
|
|
Class *clasp;
|
|
|
|
|
|
|
|
|
|
jsval v = argc ? Jsvalify(vp[2]) : JSVAL_VOID;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v))
|
|
|
|
|
v = STRING_TO_JSVAL(cx->runtime->emptyString);
|
|
|
|
|
|
|
|
|
|
xobj = ToXML(cx, v);
|
|
|
|
|
if (!xobj)
|
|
|
|
|
return JS_FALSE;
|
2025-02-05 12:40:54 +10:00
|
|
|
xml = (JSXML *) xobj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (IsConstructing(vp) && !JSVAL_IS_PRIMITIVE(v)) {
|
2018-09-08 18:08:48 +08:00
|
|
|
vobj = JSVAL_TO_OBJECT(v);
|
2025-02-05 12:40:54 +10:00
|
|
|
clasp = vobj->getClass();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (clasp == &js_XMLClass ||
|
|
|
|
|
(clasp->flags & JSCLASS_DOCUMENT_OBSERVER)) {
|
2025-03-19 21:25:58 +10:00
|
|
|
copy = DeepCopy(cx, xml, NULL, 0);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!copy)
|
|
|
|
|
return JS_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
vp->setObject(*copy->object);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
|
|
|
|
|
vp->setObject(*xobj);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
XMLList(JSContext *cx, uintN argc, jsval *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
|
|
|
|
JSObject *vobj, *listobj;
|
|
|
|
|
JSXML *xml, *list;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
jsval v = argc ? vp[2] : JSVAL_VOID;
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v))
|
|
|
|
|
v = STRING_TO_JSVAL(cx->runtime->emptyString);
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
if (IsConstructing(Valueify(vp)) && !JSVAL_IS_PRIMITIVE(v)) {
|
2018-09-08 18:08:48 +08:00
|
|
|
vobj = JSVAL_TO_OBJECT(v);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (vobj->isXML()) {
|
|
|
|
|
xml = (JSXML *) vobj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
|
|
|
|
|
if (!listobj)
|
|
|
|
|
return JS_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
*vp = OBJECT_TO_JSVAL(listobj);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
list = (JSXML *) listobj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!Append(cx, list, xml))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Toggle on XML support since the script has explicitly requested it. */
|
|
|
|
|
listobj = ToXMLList(cx, v);
|
|
|
|
|
if (!listobj)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
*vp = OBJECT_TO_JSVAL(listobj);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_notme
|
|
|
|
|
JSCList xml_leaks = JS_INIT_STATIC_CLIST(&xml_leaks);
|
|
|
|
|
uint32 xml_serial;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
JSXML *
|
|
|
|
|
js_NewXML(JSContext *cx, JSXMLClass xml_class)
|
|
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXML *xml = js_NewGCXML(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!xml)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
xml->object = NULL;
|
|
|
|
|
xml->domnode = NULL;
|
|
|
|
|
xml->parent = NULL;
|
|
|
|
|
xml->name = NULL;
|
|
|
|
|
xml->xml_class = xml_class;
|
|
|
|
|
xml->xml_flags = 0;
|
|
|
|
|
if (JSXML_CLASS_HAS_VALUE(xml_class)) {
|
|
|
|
|
xml->xml_value = cx->runtime->emptyString;
|
|
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
xml->xml_kids.init();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
xml->xml_target = NULL;
|
|
|
|
|
xml->xml_targetprop = NULL;
|
|
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
xml->xml_namespaces.init();
|
|
|
|
|
xml->xml_attrs.init();
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_notme
|
|
|
|
|
JS_APPEND_LINK(&xml->links, &xml_leaks);
|
|
|
|
|
xml->serial = xml_serial++;
|
|
|
|
|
#endif
|
|
|
|
|
METER(xml_stats.xml);
|
|
|
|
|
return xml;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
void
|
2023-07-12 13:27:26 +10:00
|
|
|
js_TraceXML(JSTracer *trc, JSXML *xml)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
if (xml->object)
|
2025-03-19 21:25:58 +10:00
|
|
|
MarkObject(trc, *xml->object, "object");
|
2023-07-12 13:27:26 +10:00
|
|
|
if (xml->name)
|
2025-03-19 21:25:58 +10:00
|
|
|
MarkObject(trc, *xml->name, "name");
|
2023-07-12 13:27:26 +10:00
|
|
|
if (xml->parent)
|
|
|
|
|
JS_CALL_TRACER(trc, xml->parent, JSTRACE_XML, "xml_parent");
|
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 (JSXML_HAS_VALUE(xml)) {
|
2023-07-12 13:27:26 +10:00
|
|
|
if (xml->xml_value)
|
2025-03-19 21:25:58 +10:00
|
|
|
MarkString(trc, xml->xml_value, "value");
|
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
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_trace_vector(trc,
|
2025-02-03 12:35:24 +10:00
|
|
|
(JSXML **) xml->xml_kids.vector,
|
|
|
|
|
xml->xml_kids.length);
|
2023-07-12 13:27:26 +10:00
|
|
|
XMLArrayCursorTrace(trc, xml->xml_kids.cursors);
|
|
|
|
|
if (IS_GC_MARKING_TRACER(trc))
|
2025-03-19 21:25:58 +10:00
|
|
|
xml->xml_kids.trim();
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
if (xml->xml_target)
|
2023-07-12 13:27:26 +10:00
|
|
|
JS_CALL_TRACER(trc, xml->xml_target, JSTRACE_XML, "target");
|
2025-02-03 12:35:24 +10:00
|
|
|
if (xml->xml_targetprop)
|
2025-03-19 21:25:58 +10:00
|
|
|
MarkObject(trc, *xml->xml_targetprop, "targetprop");
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
MarkObjectRange(trc, xml->xml_namespaces.length,
|
|
|
|
|
(JSObject **) xml->xml_namespaces.vector,
|
|
|
|
|
"xml_namespaces");
|
2023-07-12 13:27:26 +10:00
|
|
|
XMLArrayCursorTrace(trc, xml->xml_namespaces.cursors);
|
|
|
|
|
if (IS_GC_MARKING_TRACER(trc))
|
2025-03-19 21:25:58 +10:00
|
|
|
xml->xml_namespaces.trim();
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
xml_trace_vector(trc,
|
2025-02-03 12:35:24 +10:00
|
|
|
(JSXML **) xml->xml_attrs.vector,
|
|
|
|
|
xml->xml_attrs.length);
|
2023-07-12 13:27:26 +10:00
|
|
|
XMLArrayCursorTrace(trc, xml->xml_attrs.cursors);
|
|
|
|
|
if (IS_GC_MARKING_TRACER(trc))
|
2025-03-19 21:25:58 +10:00
|
|
|
xml->xml_attrs.trim();
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSObject *
|
|
|
|
|
js_NewXMLObject(JSContext *cx, JSXMLClass xml_class)
|
|
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXML *xml = js_NewXML(cx, xml_class);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!xml)
|
|
|
|
|
return NULL;
|
2025-02-05 12:40:54 +10:00
|
|
|
|
|
|
|
|
AutoXMLRooter root(cx, xml);
|
|
|
|
|
return js_GetXMLObject(cx, xml);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static JSObject *
|
|
|
|
|
NewXMLObject(JSContext *cx, JSXML *xml)
|
|
|
|
|
{
|
|
|
|
|
JSObject *obj;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
obj = NewNonFunction<WithProto::Class>(cx, &js_XMLClass, NULL, NULL);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!obj)
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
2025-02-05 12:40:54 +10:00
|
|
|
obj->setPrivate(xml);
|
2018-09-08 18:08:48 +08:00
|
|
|
METER(xml_stats.xmlobj);
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSObject *
|
|
|
|
|
js_GetXMLObject(JSContext *cx, JSXML *xml)
|
|
|
|
|
{
|
|
|
|
|
JSObject *obj;
|
|
|
|
|
|
|
|
|
|
obj = xml->object;
|
|
|
|
|
if (obj) {
|
2025-02-05 12:40:54 +10:00
|
|
|
JS_ASSERT(obj->getPrivate() == xml);
|
2018-09-08 18:08:48 +08:00
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obj = NewXMLObject(cx, xml);
|
|
|
|
|
if (!obj)
|
|
|
|
|
return NULL;
|
|
|
|
|
xml->object = obj;
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSObject *
|
|
|
|
|
js_InitNamespaceClass(JSContext *cx, JSObject *obj)
|
|
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
return js_InitClass(cx, obj, NULL, &js_NamespaceClass, Namespace, 2,
|
2018-09-08 18:08:48 +08:00
|
|
|
namespace_props, namespace_methods, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSObject *
|
|
|
|
|
js_InitQNameClass(JSContext *cx, JSObject *obj)
|
|
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
return js_InitClass(cx, obj, NULL, &js_QNameClass, QName, 2,
|
2018-09-08 18:08:48 +08:00
|
|
|
qname_props, qname_methods, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSObject *
|
|
|
|
|
js_InitXMLClass(JSContext *cx, JSObject *obj)
|
|
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSObject *proto, *pobj;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSFunction *fun;
|
|
|
|
|
JSXML *xml;
|
|
|
|
|
JSProperty *prop;
|
2025-03-19 21:25:58 +10:00
|
|
|
Shape *shape;
|
2023-07-12 13:27:26 +10:00
|
|
|
jsval cval, vp[3];
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
/* Define the isXMLName function. */
|
|
|
|
|
if (!JS_DefineFunction(cx, obj, js_isXMLName_str, xml_isXMLName, 1, 0))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* Define the XML class constructor and prototype. */
|
2025-03-19 21:25:58 +10:00
|
|
|
proto = js_InitClass(cx, obj, NULL, &js_XMLClass, XML, 1,
|
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
|
|
|
NULL, xml_methods,
|
2018-09-08 18:08:48 +08:00
|
|
|
xml_static_props, xml_static_methods);
|
|
|
|
|
if (!proto)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
xml = js_NewXML(cx, JSXML_CLASS_TEXT);
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!xml)
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
2025-02-05 12:40:54 +10:00
|
|
|
proto->setPrivate(xml);
|
2018-09-08 18:08:48 +08:00
|
|
|
xml->object = proto;
|
|
|
|
|
METER(xml_stats.xmlobj);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Prepare to set default settings on the XML constructor we just made.
|
2025-02-05 12:40:54 +10:00
|
|
|
* NB: We can't use JS_GetConstructor, because it calls
|
|
|
|
|
* JSObject::getProperty, which is xml_getProperty, which creates a new
|
|
|
|
|
* XMLList every time! We must instead call js_LookupProperty directly.
|
2018-09-08 18:08:48 +08:00
|
|
|
*/
|
|
|
|
|
if (!js_LookupProperty(cx, proto,
|
|
|
|
|
ATOM_TO_JSID(cx->runtime->atomState.constructorAtom),
|
|
|
|
|
&pobj, &prop)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
JS_ASSERT(prop);
|
2025-03-19 21:25:58 +10:00
|
|
|
shape = (Shape *) prop;
|
|
|
|
|
cval = Jsvalify(pobj->nativeGetSlot(shape->slot));
|
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
|
|
|
JS_ASSERT(VALUE_IS_FUNCTION(cx, cval));
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
/* Set default settings. */
|
2023-07-12 13:27:26 +10:00
|
|
|
vp[0] = JSVAL_NULL;
|
|
|
|
|
vp[1] = cval;
|
|
|
|
|
vp[2] = JSVAL_VOID;
|
|
|
|
|
if (!xml_setSettings(cx, 1, vp))
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* Define the XMLList function and give it the same prototype as XML. */
|
2025-03-19 21:25:58 +10:00
|
|
|
fun = JS_DefineFunction(cx, obj, js_XMLList_str, XMLList, 1, JSFUN_CONSTRUCTOR);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!fun)
|
|
|
|
|
return NULL;
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!js_SetClassPrototype(cx, FUN_OBJECT(fun), proto,
|
2018-09-08 18:08:48 +08:00
|
|
|
JSPROP_READONLY | JSPROP_PERMANENT)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
return proto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSObject *
|
|
|
|
|
js_InitXMLClasses(JSContext *cx, JSObject *obj)
|
|
|
|
|
{
|
|
|
|
|
if (!js_InitNamespaceClass(cx, obj))
|
|
|
|
|
return NULL;
|
|
|
|
|
if (!js_InitQNameClass(cx, obj))
|
|
|
|
|
return NULL;
|
|
|
|
|
return js_InitXMLClass(cx, obj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
js_GetFunctionNamespace(JSContext *cx, Value *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *global = cx->hasfp() ? cx->fp()->scopeChain().getGlobal() : cx->globalObject;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
*vp = global->getReservedSlot(JSRESERVED_GLOBAL_FUNCTION_NS);
|
|
|
|
|
if (vp->isUndefined()) {
|
|
|
|
|
JSRuntime *rt = cx->runtime;
|
|
|
|
|
JSLinearString *prefix = rt->atomState.typeAtoms[JSTYPE_FUNCTION];
|
|
|
|
|
JSLinearString *uri = rt->atomState.functionNamespaceURIAtom;
|
|
|
|
|
JSObject *obj = NewXMLNamespace(cx, prefix, uri, JS_FALSE);
|
|
|
|
|
if (!obj)
|
|
|
|
|
return false;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
/*
|
|
|
|
|
* Avoid entraining any in-scope Object.prototype. The loss of
|
|
|
|
|
* Namespace.prototype is not detectable, as there is no way to
|
|
|
|
|
* refer to this instance in scripts. When used to qualify method
|
|
|
|
|
* names, its prefix and uri references are copied to the QName.
|
|
|
|
|
* The parent remains set and links back to global.
|
|
|
|
|
*/
|
|
|
|
|
obj->clearProto();
|
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-03-19 21:25:58 +10:00
|
|
|
vp->setObject(*obj);
|
|
|
|
|
if (!js_SetReservedSlot(cx, global, JSRESERVED_GLOBAL_FUNCTION_NS, *vp))
|
|
|
|
|
return false;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
|
|
|
|
|
return true;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Note the asymmetry between js_GetDefaultXMLNamespace and js_SetDefaultXML-
|
|
|
|
|
* Namespace. Get searches fp->scopeChain for JS_DEFAULT_XML_NAMESPACE_ID,
|
2025-02-05 12:40:54 +10:00
|
|
|
* while Set sets JS_DEFAULT_XML_NAMESPACE_ID in fp->varobj. There's no
|
|
|
|
|
* requirement that fp->varobj lie directly on fp->scopeChain, although
|
|
|
|
|
* it should be reachable using the prototype chain from a scope object (cf.
|
|
|
|
|
* JSOPTION_VAROBJFIX in jsapi.h).
|
2018-09-08 18:08:48 +08:00
|
|
|
*
|
|
|
|
|
* If Get can't find JS_DEFAULT_XML_NAMESPACE_ID along the scope chain, it
|
|
|
|
|
* creates a default namespace via 'new Namespace()'. In contrast, Set uses
|
|
|
|
|
* its v argument as the uri of a new Namespace, with "" as the prefix. See
|
|
|
|
|
* ECMA-357 12.1 and 12.1.1. Note that if Set is called with a Namespace n,
|
|
|
|
|
* the default XML namespace will be set to ("", n.uri). So the uri string
|
|
|
|
|
* is really the only usefully stored value of the default namespace.
|
|
|
|
|
*/
|
|
|
|
|
JSBool
|
|
|
|
|
js_GetDefaultXMLNamespace(JSContext *cx, jsval *vp)
|
|
|
|
|
{
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *ns, *obj, *tmp;
|
2018-09-08 18:08:48 +08:00
|
|
|
jsval v;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *scopeChain = GetScopeChain(cx);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
obj = NULL;
|
2025-03-19 21:25:58 +10:00
|
|
|
for (tmp = scopeChain; tmp; tmp = tmp->getParent()) {
|
|
|
|
|
Class *clasp = tmp->getClass();
|
2025-02-05 12:40:54 +10:00
|
|
|
if (clasp == &js_BlockClass || clasp == &js_WithClass)
|
|
|
|
|
continue;
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!tmp->getProperty(cx, JS_DEFAULT_XML_NAMESPACE_ID, Valueify(&v)))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
if (!JSVAL_IS_PRIMITIVE(v)) {
|
|
|
|
|
*vp = v;
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
obj = tmp;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
ns = js_ConstructObject(cx, &js_NamespaceClass, NULL, obj, 0, NULL);
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!ns)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
2025-02-03 12:35:24 +10:00
|
|
|
v = OBJECT_TO_JSVAL(ns);
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!obj->defineProperty(cx, JS_DEFAULT_XML_NAMESPACE_ID, Valueify(v),
|
|
|
|
|
PropertyStub, StrictPropertyStub, JSPROP_PERMANENT)) {
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
*vp = v;
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
js_SetDefaultXMLNamespace(JSContext *cx, const Value &v)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
Value argv[2];
|
|
|
|
|
argv[0].setString(cx->runtime->emptyString);
|
2018-09-08 18:08:48 +08:00
|
|
|
argv[1] = v;
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *ns = js_ConstructObject(cx, &js_NamespaceClass, NULL, NULL, 2, argv);
|
2025-02-03 12:35:24 +10:00
|
|
|
if (!ns)
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JSStackFrame *fp = js_GetTopStackFrame(cx);
|
|
|
|
|
JSObject &varobj = fp->varobj(cx);
|
|
|
|
|
if (!varobj.defineProperty(cx, JS_DEFAULT_XML_NAMESPACE_ID, ObjectValue(*ns),
|
|
|
|
|
PropertyStub, StrictPropertyStub, JSPROP_PERMANENT)) {
|
2025-02-05 12:40:54 +10:00
|
|
|
return JS_FALSE;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
js_ToAttributeName(JSContext *cx, Value *vp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *qn;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
qn = ToAttributeName(cx, Jsvalify(*vp));
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!qn)
|
|
|
|
|
return JS_FALSE;
|
2025-03-19 21:25:58 +10:00
|
|
|
vp->setObject(*qn);
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JSFlatString *
|
2023-07-12 13:27:26 +10:00
|
|
|
js_EscapeAttributeValue(JSContext *cx, JSString *str, JSBool quote)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
StringBuffer sb(cx);
|
|
|
|
|
return EscapeAttributeValue(cx, sb, str, quote);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSString *
|
|
|
|
|
js_AddAttributePart(JSContext *cx, JSBool isName, JSString *str, JSString *str2)
|
|
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
size_t len = str->length();
|
|
|
|
|
const jschar *chars = str->getChars(cx);
|
|
|
|
|
if (!chars)
|
|
|
|
|
return NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
size_t len2 = str2->length();
|
|
|
|
|
const jschar *chars2 = str2->getChars(cx);
|
|
|
|
|
if (!chars2)
|
|
|
|
|
return NULL;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
size_t newlen = (isName) ? len + 1 + len2 : len + 2 + len2 + 1;
|
|
|
|
|
jschar *newchars = (jschar *) cx->malloc((newlen+1) * sizeof(jschar));
|
|
|
|
|
if (!newchars)
|
2018-09-08 18:08:48 +08:00
|
|
|
return NULL;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
js_strncpy(newchars, chars, len);
|
|
|
|
|
newchars += len;
|
2018-09-08 18:08:48 +08:00
|
|
|
if (isName) {
|
2025-03-19 21:25:58 +10:00
|
|
|
*newchars++ = ' ';
|
|
|
|
|
js_strncpy(newchars, chars2, len2);
|
|
|
|
|
newchars += len2;
|
2018-09-08 18:08:48 +08:00
|
|
|
} else {
|
2025-03-19 21:25:58 +10:00
|
|
|
*newchars++ = '=';
|
|
|
|
|
*newchars++ = '"';
|
|
|
|
|
js_strncpy(newchars, chars2, len2);
|
|
|
|
|
newchars += len2;
|
|
|
|
|
*newchars++ = '"';
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
*newchars = 0;
|
|
|
|
|
return js_NewString(cx, newchars - newlen, newlen);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JSFlatString *
|
2018-09-08 18:08:48 +08:00
|
|
|
js_EscapeElementValue(JSContext *cx, JSString *str)
|
|
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
StringBuffer sb(cx);
|
|
|
|
|
return EscapeElementValue(cx, sb, str, 0);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSString *
|
2025-03-19 21:25:58 +10:00
|
|
|
js_ValueToXMLString(JSContext *cx, const Value &v)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
return ToXMLString(cx, Jsvalify(v), 0);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
js_GetAnyName(JSContext *cx, jsid *idp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
JSObject *global = cx->hasfp() ? cx->fp()->scopeChain().getGlobal() : cx->globalObject;
|
|
|
|
|
Value v = global->getReservedSlot(JSProto_AnyName);
|
|
|
|
|
if (v.isUndefined()) {
|
|
|
|
|
JSObject *obj = NewNonFunction<WithProto::Given>(cx, &js_AnyNameClass, NULL, global);
|
|
|
|
|
if (!obj)
|
|
|
|
|
return false;
|
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-03-19 21:25:58 +10:00
|
|
|
JS_ASSERT(!obj->getProto());
|
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-03-19 21:25:58 +10:00
|
|
|
JSRuntime *rt = cx->runtime;
|
|
|
|
|
InitXMLQName(obj, rt->emptyString, rt->emptyString,
|
|
|
|
|
ATOM_TO_STRING(rt->atomState.starAtom));
|
|
|
|
|
METER(xml_stats.qname);
|
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-03-19 21:25:58 +10:00
|
|
|
v.setObject(*obj);
|
|
|
|
|
if (!js_SetReservedSlot(cx, global, JSProto_AnyName, v))
|
|
|
|
|
return false;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
*idp = OBJECT_TO_JSID(&v.toObject());
|
|
|
|
|
return true;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSBool
|
2025-03-19 21:25:58 +10:00
|
|
|
js_FindXMLProperty(JSContext *cx, const Value &nameval, JSObject **objp, jsid *idp)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSObject *nameobj;
|
|
|
|
|
jsval v;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *qn;
|
2023-07-12 13:27:26 +10:00
|
|
|
jsid funid;
|
|
|
|
|
JSObject *obj, *target, *proto, *pobj;
|
|
|
|
|
JSXML *xml;
|
|
|
|
|
JSBool found;
|
2018-09-08 18:08:48 +08:00
|
|
|
JSProperty *prop;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JS_ASSERT(nameval.isObject());
|
|
|
|
|
nameobj = &nameval.toObject();
|
2025-02-05 12:40:54 +10:00
|
|
|
if (nameobj->getClass() == &js_AnyNameClass) {
|
2025-03-19 21:25:58 +10:00
|
|
|
v = ATOM_TO_JSVAL(cx->runtime->atomState.starAtom);
|
|
|
|
|
nameobj = js_ConstructObject(cx, &js_QNameClass, NULL, NULL, 1,
|
|
|
|
|
Valueify(&v));
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!nameobj)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
} else {
|
2025-02-05 12:40:54 +10:00
|
|
|
JS_ASSERT(nameobj->getClass() == &js_AttributeNameClass ||
|
2025-03-19 21:25:58 +10:00
|
|
|
nameobj->getClass() == &js_QNameClass);
|
2023-07-12 13:27:26 +10:00
|
|
|
}
|
|
|
|
|
|
2025-02-03 12:35:24 +10:00
|
|
|
qn = nameobj;
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!IsFunctionQName(cx, qn, &funid))
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_FALSE;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
obj = &js_GetTopStackFrame(cx)->scopeChain();
|
2018-09-08 18:08:48 +08:00
|
|
|
do {
|
2023-07-12 13:27:26 +10:00
|
|
|
/* Skip any With object that can wrap XML. */
|
|
|
|
|
target = obj;
|
2025-02-05 12:40:54 +10:00
|
|
|
while (target->getClass() == &js_WithClass) {
|
|
|
|
|
proto = target->getProto();
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!proto)
|
|
|
|
|
break;
|
|
|
|
|
target = proto;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
if (target->isXML()) {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (JSID_IS_VOID(funid)) {
|
2025-02-05 12:40:54 +10:00
|
|
|
xml = (JSXML *) target->getPrivate();
|
2023-07-12 13:27:26 +10:00
|
|
|
found = HasNamedProperty(xml, qn);
|
|
|
|
|
} else {
|
|
|
|
|
if (!HasFunctionProperty(cx, target, funid, &found))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (found) {
|
|
|
|
|
*idp = OBJECT_TO_JSID(nameobj);
|
|
|
|
|
*objp = target;
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
2025-03-19 21:25:58 +10:00
|
|
|
} else if (!JSID_IS_VOID(funid)) {
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!target->lookupProperty(cx, funid, &pobj, &prop))
|
2023-07-12 13:27:26 +10:00
|
|
|
return JS_FALSE;
|
|
|
|
|
if (prop) {
|
|
|
|
|
*idp = funid;
|
|
|
|
|
*objp = target;
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-02-05 12:40:54 +10:00
|
|
|
} while ((obj = obj->getParent()) != NULL);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
JSAutoByteString printable;
|
|
|
|
|
JSString *str = ConvertQNameToString(cx, nameobj);
|
|
|
|
|
if (str && js_ValueToPrintable(cx, StringValue(str), &printable)) {
|
|
|
|
|
JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage, NULL,
|
|
|
|
|
JSMSG_UNDEFINED_XML_NAME, printable.ptr());
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
static JSBool
|
|
|
|
|
GetXMLFunction(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
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
|
|
|
JS_ASSERT(obj->isXML());
|
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
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* See comments before xml_lookupProperty about the need for the proto
|
|
|
|
|
* chain lookup.
|
|
|
|
|
*/
|
2025-02-05 12:40:54 +10:00
|
|
|
JSObject *target = obj;
|
|
|
|
|
AutoObjectRooter tvr(cx);
|
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
|
|
|
for (;;) {
|
2025-03-19 21:25:58 +10:00
|
|
|
if (!js_GetProperty(cx, target, id, Valueify(vp)))
|
2025-02-05 12:40:54 +10:00
|
|
|
return false;
|
|
|
|
|
if (VALUE_IS_FUNCTION(cx, *vp))
|
|
|
|
|
return true;
|
|
|
|
|
target = target->getProto();
|
2025-03-19 21:25:58 +10:00
|
|
|
if (target == NULL || !target->isNative())
|
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
|
|
|
break;
|
2025-02-05 12:40:54 +10:00
|
|
|
tvr.setObject(target);
|
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
|
|
|
JSXML *xml = (JSXML *) obj->getPrivate();
|
|
|
|
|
if (!HasSimpleContent(xml))
|
|
|
|
|
return true;
|
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
|
|
|
/* Search in String.prototype to implement 11.2.2.1 Step 3(f). */
|
|
|
|
|
if (!js_GetClassPrototype(cx, NULL, JSProto_String, tvr.addr()))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
JS_ASSERT(tvr.object());
|
2025-03-19 21:25:58 +10:00
|
|
|
return tvr.object()->getProperty(cx, id, Valueify(vp));
|
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
|
|
|
}
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
static JSXML *
|
|
|
|
|
GetPrivate(JSContext *cx, JSObject *obj, const char *method)
|
|
|
|
|
{
|
|
|
|
|
JSXML *xml;
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
xml = (JSXML *) GetInstancePrivate(cx, obj, &js_XMLClass, NULL);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!xml) {
|
|
|
|
|
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
|
|
|
|
JSMSG_INCOMPATIBLE_METHOD,
|
2025-02-05 12:40:54 +10:00
|
|
|
js_XML_str, method, obj->getClass()->name);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
return xml;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSBool
|
|
|
|
|
js_GetXMLDescendants(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|
|
|
|
{
|
|
|
|
|
JSXML *xml, *list;
|
|
|
|
|
|
|
|
|
|
xml = GetPrivate(cx, obj, "descendants internal method");
|
|
|
|
|
if (!xml)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
list = Descendants(cx, xml, id);
|
|
|
|
|
if (!list)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
*vp = OBJECT_TO_JSVAL(list->object);
|
|
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSBool
|
|
|
|
|
js_DeleteXMLListElements(JSContext *cx, JSObject *listobj)
|
|
|
|
|
{
|
|
|
|
|
JSXML *list;
|
|
|
|
|
uint32 n;
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
list = (JSXML *) listobj->getPrivate();
|
2023-07-12 13:27:26 +10:00
|
|
|
for (n = list->xml_kids.length; n != 0; --n)
|
|
|
|
|
DeleteListElement(cx, list, 0);
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
return JS_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
struct JSXMLFilter
|
|
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
JSXML *list;
|
|
|
|
|
JSXML *result;
|
|
|
|
|
JSXML *kid;
|
|
|
|
|
JSXMLArrayCursor cursor;
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXMLFilter(JSXML *list, JSXMLArray *array)
|
|
|
|
|
: list(list), result(NULL), kid(NULL), cursor(array) {}
|
|
|
|
|
|
|
|
|
|
~JSXMLFilter() {}
|
|
|
|
|
};
|
2023-07-12 13:27:26 +10:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xmlfilter_trace(JSTracer *trc, JSObject *obj)
|
|
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXMLFilter *filter = (JSXMLFilter *) obj->getPrivate();
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!filter)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
JS_ASSERT(filter->list);
|
|
|
|
|
JS_CALL_TRACER(trc, filter->list, JSTRACE_XML, "list");
|
|
|
|
|
if (filter->result)
|
|
|
|
|
JS_CALL_TRACER(trc, filter->result, JSTRACE_XML, "result");
|
|
|
|
|
if (filter->kid)
|
|
|
|
|
JS_CALL_TRACER(trc, filter->kid, JSTRACE_XML, "kid");
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* We do not need to trace the cursor as that would be done when
|
|
|
|
|
* tracing the filter->list.
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xmlfilter_finalize(JSContext *cx, JSObject *obj)
|
|
|
|
|
{
|
2025-02-05 12:40:54 +10:00
|
|
|
JSXMLFilter *filter = (JSXMLFilter *) obj->getPrivate();
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!filter)
|
|
|
|
|
return;
|
|
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
cx->destroy(filter);
|
2023-07-12 13:27:26 +10:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
Class js_XMLFilterClass = {
|
2023-07-12 13:27:26 +10:00
|
|
|
"XMLFilter",
|
2025-02-05 12:40:54 +10:00
|
|
|
JSCLASS_HAS_PRIVATE | JSCLASS_IS_ANONYMOUS | JSCLASS_MARK_IS_TRACE,
|
2025-03-19 21:25:58 +10:00
|
|
|
PropertyStub, /* addProperty */
|
|
|
|
|
PropertyStub, /* delProperty */
|
|
|
|
|
PropertyStub, /* getProperty */
|
|
|
|
|
StrictPropertyStub, /* setProperty */
|
|
|
|
|
EnumerateStub,
|
|
|
|
|
ResolveStub,
|
|
|
|
|
ConvertStub,
|
|
|
|
|
xmlfilter_finalize,
|
|
|
|
|
NULL, /* reserved0 */
|
|
|
|
|
NULL, /* checkAccess */
|
|
|
|
|
NULL, /* call */
|
|
|
|
|
NULL, /* construct */
|
|
|
|
|
NULL, /* xdrObject */
|
|
|
|
|
NULL, /* hasInstance */
|
|
|
|
|
JS_CLASS_TRACE(xmlfilter_trace)
|
2023-07-12 13:27:26 +10:00
|
|
|
};
|
|
|
|
|
|
2018-09-08 18:08:48 +08:00
|
|
|
JSBool
|
2023-07-12 13:27:26 +10:00
|
|
|
js_StepXMLListFilter(JSContext *cx, JSBool initialized)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2023-07-12 13:27:26 +10:00
|
|
|
jsval *sp;
|
|
|
|
|
JSObject *obj, *filterobj, *resobj, *kidobj;
|
|
|
|
|
JSXML *xml, *list;
|
|
|
|
|
JSXMLFilter *filter;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-02-05 12:40:54 +10:00
|
|
|
LeaveTrace(cx);
|
2025-03-19 21:25:58 +10:00
|
|
|
sp = Jsvalify(cx->regs->sp);
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!initialized) {
|
|
|
|
|
/*
|
|
|
|
|
* We haven't iterated yet, so initialize the filter based on the
|
|
|
|
|
* value stored in sp[-2].
|
|
|
|
|
*/
|
2025-02-05 12:40:54 +10:00
|
|
|
if (!VALUE_IS_XML(sp[-2])) {
|
2025-03-19 21:25:58 +10:00
|
|
|
js_ReportValueError(cx, JSMSG_NON_XML_FILTER, -2, Valueify(sp[-2]), NULL);
|
2023-07-12 13:27:26 +10:00
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
obj = JSVAL_TO_OBJECT(sp[-2]);
|
2025-02-05 12:40:54 +10:00
|
|
|
xml = (JSXML *) obj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
if (xml->xml_class == JSXML_CLASS_LIST) {
|
|
|
|
|
list = xml;
|
|
|
|
|
} else {
|
|
|
|
|
obj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
|
|
|
|
|
if (!obj)
|
|
|
|
|
return JS_FALSE;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/*
|
|
|
|
|
* Root just-created obj. sp[-2] cannot be used yet for rooting
|
|
|
|
|
* as it may be the only root holding xml.
|
|
|
|
|
*/
|
|
|
|
|
sp[-1] = OBJECT_TO_JSVAL(obj);
|
2025-02-05 12:40:54 +10:00
|
|
|
list = (JSXML *) obj->getPrivate();
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!Append(cx, list, xml))
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2025-03-19 21:25:58 +10:00
|
|
|
filterobj = NewNonFunction<WithProto::Given>(cx, &js_XMLFilterClass, NULL, NULL);
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!filterobj)
|
|
|
|
|
return JS_FALSE;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/*
|
2025-02-05 12:40:54 +10:00
|
|
|
* Init all filter fields before setPrivate exposes it to
|
2023-07-12 13:27:26 +10:00
|
|
|
* xmlfilter_trace or xmlfilter_finalize.
|
|
|
|
|
*/
|
2025-02-05 12:40:54 +10:00
|
|
|
filter = cx->create<JSXMLFilter>(list, &list->xml_kids);
|
|
|
|
|
if (!filter)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
filterobj->setPrivate(filter);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
/* Store filterobj to use in the later iterations. */
|
|
|
|
|
sp[-2] = OBJECT_TO_JSVAL(filterobj);
|
2018-09-08 18:08:48 +08:00
|
|
|
|
2023-07-12 13:27:26 +10:00
|
|
|
resobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
|
|
|
|
|
if (!resobj)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
|
|
/* This also roots resobj. */
|
2025-02-05 12:40:54 +10:00
|
|
|
filter->result = (JSXML *) resobj->getPrivate();
|
2023-07-12 13:27:26 +10:00
|
|
|
} else {
|
|
|
|
|
/* We have iterated at least once. */
|
|
|
|
|
JS_ASSERT(!JSVAL_IS_PRIMITIVE(sp[-2]));
|
2025-02-05 12:40:54 +10:00
|
|
|
JS_ASSERT(JSVAL_TO_OBJECT(sp[-2])->getClass() == &js_XMLFilterClass);
|
|
|
|
|
filter = (JSXMLFilter *) JSVAL_TO_OBJECT(sp[-2])->getPrivate();
|
2023-07-12 13:27:26 +10:00
|
|
|
JS_ASSERT(filter->kid);
|
|
|
|
|
|
|
|
|
|
/* Check if the filter expression wants to append the element. */
|
2025-03-19 21:25:58 +10:00
|
|
|
if (js_ValueToBoolean(Valueify(sp[-1])) &&
|
2023-07-12 13:27:26 +10:00
|
|
|
!Append(cx, filter->result, filter->kid)) {
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
2023-07-12 13:27:26 +10:00
|
|
|
|
|
|
|
|
/* Do the iteration. */
|
2025-02-05 12:40:54 +10:00
|
|
|
filter->kid = (JSXML *) filter->cursor.getNext();
|
2023-07-12 13:27:26 +10:00
|
|
|
if (!filter->kid) {
|
|
|
|
|
/*
|
|
|
|
|
* Do not defer finishing the cursor until the next GC cycle to avoid
|
|
|
|
|
* accumulation of dead cursors associated with filter->list.
|
|
|
|
|
*/
|
2025-02-05 12:40:54 +10:00
|
|
|
filter->cursor.disconnect();
|
2023-07-12 13:27:26 +10:00
|
|
|
JS_ASSERT(filter->result->object);
|
|
|
|
|
sp[-2] = OBJECT_TO_JSVAL(filter->result->object);
|
|
|
|
|
kidobj = NULL;
|
|
|
|
|
} else {
|
|
|
|
|
kidobj = js_GetXMLObject(cx, filter->kid);
|
|
|
|
|
if (!kidobj)
|
|
|
|
|
return JS_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Null as kidobj at sp[-1] signals filter termination. */
|
|
|
|
|
sp[-1] = OBJECT_TO_JSVAL(kidobj);
|
|
|
|
|
return JS_TRUE;
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSObject *
|
2025-03-19 21:25:58 +10:00
|
|
|
js_ValueToXMLObject(JSContext *cx, const Value &v)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
return ToXML(cx, Jsvalify(v));
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSObject *
|
2025-03-19 21:25:58 +10:00
|
|
|
js_ValueToXMLListObject(JSContext *cx, const Value &v)
|
2018-09-08 18:08:48 +08:00
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
return ToXMLList(cx, Jsvalify(v));
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSObject *
|
|
|
|
|
js_NewXMLSpecialObject(JSContext *cx, JSXMLClass xml_class, JSString *name,
|
|
|
|
|
JSString *value)
|
|
|
|
|
{
|
|
|
|
|
uintN flags;
|
|
|
|
|
JSObject *obj;
|
|
|
|
|
JSXML *xml;
|
2025-02-03 12:35:24 +10:00
|
|
|
JSObject *qn;
|
2018-09-08 18:08:48 +08:00
|
|
|
|
|
|
|
|
if (!GetXMLSettingFlags(cx, &flags))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if ((xml_class == JSXML_CLASS_COMMENT &&
|
|
|
|
|
(flags & XSF_IGNORE_COMMENTS)) ||
|
|
|
|
|
(xml_class == JSXML_CLASS_PROCESSING_INSTRUCTION &&
|
|
|
|
|
(flags & XSF_IGNORE_PROCESSING_INSTRUCTIONS))) {
|
|
|
|
|
return js_NewXMLObject(cx, JSXML_CLASS_TEXT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obj = js_NewXMLObject(cx, xml_class);
|
|
|
|
|
if (!obj)
|
|
|
|
|
return NULL;
|
2025-02-05 12:40:54 +10:00
|
|
|
xml = (JSXML *) obj->getPrivate();
|
2018-09-08 18:08:48 +08:00
|
|
|
if (name) {
|
2025-03-19 21:25:58 +10:00
|
|
|
JSLinearString *linearName = name->ensureLinear(cx);
|
|
|
|
|
if (!linearName)
|
|
|
|
|
return NULL;
|
|
|
|
|
qn = NewXMLQName(cx, cx->runtime->emptyString, NULL, linearName);
|
2018-09-08 18:08:48 +08:00
|
|
|
if (!qn)
|
|
|
|
|
return NULL;
|
|
|
|
|
xml->name = qn;
|
|
|
|
|
}
|
|
|
|
|
xml->xml_value = value;
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSString *
|
|
|
|
|
js_MakeXMLCDATAString(JSContext *cx, JSString *str)
|
|
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
StringBuffer sb(cx);
|
|
|
|
|
return MakeXMLCDATAString(cx, sb, str);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSString *
|
|
|
|
|
js_MakeXMLCommentString(JSContext *cx, JSString *str)
|
|
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
StringBuffer sb(cx);
|
|
|
|
|
return MakeXMLCommentString(cx, sb, str);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSString *
|
|
|
|
|
js_MakeXMLPIString(JSContext *cx, JSString *name, JSString *str)
|
|
|
|
|
{
|
2025-03-19 21:25:58 +10:00
|
|
|
StringBuffer sb(cx);
|
|
|
|
|
return MakeXMLPIString(cx, sb, name, str);
|
2018-09-08 18:08:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* JS_HAS_XML_SUPPORT */
|