> /* DREAMWEAVER jschang, Macromedia - (formerly JS_AliasElement)
> * JS_AliasElementToProperty assigns the array element so that it is an
> * alias to the named property. I changed the name so that it is more
> * descriptive and because I needed to add the function
> * JS_AliasPropertyToElement.
> *
> * HACK snewman 3/22/01: this seems to be a function we added back in the JS
> * 1.2 days based on JS_AliasProperty -- I haven't checked with Jeff, but
> * the code looks similar to JS_AliasProperty. It had been copied without
> * modification into the JS1.5rc2 code. While updating to JS1.5rc3, I
> * looked to see if JS_AliasProperty had changed since JS1.2, and indeed
> * it has -- this code:
> *
> * JS_ReportError(cx, "can't alias %s to %s in class %s",
> * alias, name, OBJ_GET_CLASS(cx, obj2)->name);
> *
> * was changed to this:
> *
> * JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_ALIAS,
> * alias, name, OBJ_GET_CLASS(cx, obj2)->name);
> *
> * and this:
> *
> * scope = (JSScope *) obj->map;
> *
> * was changed to this:
> *
> * scope = OBJ_SCOPE(obj);
> *
> * I've applied the scope change here, and in JS_AliasPropertyToElement
> * (below). Probably the ReportError change should be made as well, but
> * this would require some research, and I doubt that it's important.
> * (Famous last words...)
> *
> * cbank - 9/9/04 same story, this time JS1.5rc2 to JS1.5rc6a
> *
> * changes mirrored:
> *
> * JSScope *scope;
> *
> * was changed to this:
> *
> * JSScopeProperty *sprop;
> *
> *
> *
> * if (obj2 != obj || !OBJ_IS_NATIVE(obj2)) {
> *
> * was changed to this:
> *
> * if (obj2 != obj || !OBJ_IS_NATIVE(obj)) {
> *
> *
> *
> * scope = OBJ_SCOPE(obj);
> * ok = (scope->ops->add(cx, scope, INT_TO_JSVAL(alias), (JSScopeProperty *)prop)
> *
> * was changed to this:
> *
> * sprop = (JSScopeProperty *)prop;
> * ok = (js_AddNativeProperty(cx, obj, INT_TO_JSVAL(alias),
> * sprop->getter, sprop->setter, sprop->slot,
> * sprop->attrs, sprop->flags | SPROP_IS_ALIAS,
> * sprop->shortid)
> *
> */
> JS_PUBLIC_API(JSBool)
> JS_AliasElementToProperty(JSContext *cx, JSObject *obj, const char *name, jsint alias)
> {
> JSObject *obj2;
> JSProperty *prop;
> JSBool ok;
> JSScopeProperty *sprop;
>
> CHECK_REQUEST(cx);
> if (!LookupProperty(cx, obj, name, &obj2, &prop))
> return JS_FALSE;
> if (!prop) {
> js_ReportIsNotDefined(cx, name);
> return JS_FALSE;
> }
> if (obj2 != obj || !OBJ_IS_NATIVE(obj)) {
> OBJ_DROP_PROPERTY(cx, obj2, prop);
> JS_ReportError(cx, "can't alias array element %ld to %s in class %s",
> (long)alias, name, OBJ_GET_CLASS(cx, obj2)->name);
> return JS_FALSE;
> }
> sprop = (JSScopeProperty *)prop;
> ok = (js_AddNativeProperty(cx, obj, INT_TO_JSVAL(alias),
> sprop->getter, sprop->setter, sprop->slot,
> sprop->attrs, sprop->flags | SPROP_IS_ALIAS,
> sprop->shortid)
> != NULL);
> OBJ_DROP_PROPERTY(cx, obj, prop);
> return ok;
> }
>
> /* DREAMWEAVER
> * jschang, Macromedia - (new function added 11/12/99 for OptionsArray setter function)
> * JS_AliasPropertyToElement assigns the named property so that it is an
> * alias to the specified array element.
> *
> * snewman 3/22/01: see comments for JS_AliasElementToProperty (above).
> */
> JS_PUBLIC_API(JSBool)
> JS_AliasPropertyToElement(JSContext *cx, JSObject *obj, jsint index, const char *alias)
> {
> JSObject *obj2;
> JSProperty *prop;
> JSBool ok;
> JSAtom *atom;
> JSScopeProperty *sprop;
>
> CHECK_REQUEST(cx);
> if (!OBJ_LOOKUP_PROPERTY(cx, obj, INT_TO_JSVAL(index), &obj2, &prop))
> return JS_FALSE;
> if (!prop) {
> JS_ReportError(cx, "array element %ld is not defined", (long)index);
> return JS_FALSE;
> }
> if (obj2 != obj || !OBJ_IS_NATIVE(obj)) {
> OBJ_DROP_PROPERTY(cx, obj2, prop);
> JS_ReportError(cx, "can't alias %s to array element %ld in class %s",
> alias, (long)index, OBJ_GET_CLASS(cx, obj2)->name);
> return JS_FALSE;
> }
>
> atom = js_Atomize(cx, alias, strlen(alias), 0);
> if (!atom) {
> ok = JS_FALSE;
> } else {
> sprop = (JSScopeProperty *)prop;
> ok = (js_AddNativeProperty(cx, obj, (jsid)atom,
> sprop->getter, sprop->setter, sprop->slot,
> sprop->attrs, sprop->flags | SPROP_IS_ALIAS,
> sprop->shortid)
> != NULL);
> }
> OBJ_DROP_PROPERTY(cx, obj, prop);
> return ok;
> }
>
> // DREAMWEAVER added this function
> extern JS_PUBLIC_API(JSBool)
> JS_DoubleIsNaN(jsdouble n);
>
< JS_NewArrayObject(JSContext *cx, jsint length, jsval *vector);
---
> JS_NewArrayObject(JSContext *cx, jsint length, jsval *vector_arg);
> // DREAMWEAVER added this function
> extern JS_PUBLIC_API(JSBool)
> JS_AliasElementToProperty(JSContext *cx, JSObject *obj, const char *name, jsint alias);
>
> // DREAMWEAVER added this function
> extern JS_PUBLIC_API(JSBool)
> JS_AliasPropertyToElement(JSContext *cx, JSObject *obj, jsint index, const char *alias);
>
> // DREAMWEAVER - add these macros so on windows we get line numbers on memory leaks
> #if defined(XP_WIN) && defined (_DEBUG) //for debug builds only
> #define _CRTDBG_MAP_ALLOC
> #include <crtdbg.h>
> #endif
>
< if (!OBJ_SET_PROPERTY(cx, obj, id, &vector[index]))
---
>
> // DREAMWEAVER CHANGE
> // original code was JS_PropertyStub, JS_PropertyStub instead of
> // NULL, NULL
> //
> // An explanation from DaveG:
> //
> // > Let's suppose the user's document contains a [select] tag:
> // >
> // > [select name="mySelectTag"]
> // > [option]one[/option]
> // > [option]two[/option]
> // > [/select]
> // >
> // > That tag can be accessed through the DOM as follows:
> // >
> // > theSelect = document.forms[0].mySelectTag
> // > alert("first option = " + theSelect.options[0]);
> // > theSelect.options[0] = "new first option";
> // >
> // > In order to implement that functionality, I found that I needed to override
> // > the default implementation of the Array type. I implemented the options
> // > property on the select object so that it returns an OptionsArray object
> // > instead of an Array object. The OptionsArray type is a subclass of Array,
> // > but it has its own implementation for getting the value of options[0] (the
> // > value is sucked out of the corresponding TTAG_OPTION Run in the Run tree)
> // > and setting the value of options[0] (the value is the Run tree is updated).
> // >
> // > I found that I needed to change the base implementation of Array, so that I
> // > could create a sub-class of it (OptionsArray).
> if (!OBJ_DEFINE_PROPERTY(cx, obj, id, vector[index],
> NULL, NULL, // DaveG: use getter/setter defined for class
> JSPROP_ENUMERATE,
> NULL))
> // DREAMWEAVER: Added this function
> extern JSBool
> JS_InitArrayObject(JSContext *cx, JSObject *obj, jsuint length, jsval *vector);
>
< #define JS_HAS_EXPORT_IMPORT 0 /* has export fun; import obj.fun */
---
> /* DREAMWEAVER - enable JS_HAS_EXPORT_IMPORT */
> #define JS_HAS_EXPORT_IMPORT 1 /* has export fun; import obj.fun */
> // DREAMWEAVER - add these macros so on windows we get line numbers on memory leaks
> #if defined(XP_WIN) && defined (_DEBUG) //for debug builds only
> #define _CRTDBG_MAP_ALLOC
> #include <crtdbg.h>
> #endif
>
> // DREAMWEAVER: see jsprofiler.h
> #ifdef DREAMWEAVER_JAVASCRIPT_PROFILING
> fun->dummyFunction = -1;
> #endif
>
>
> // DREAMWEAVER: see jsprofiler.h
> #include "project/jsprofiler.h"
>
> /************************* BEGIN DREAMWEAVER CHANGE **************************/
> /**************************** mmorearty 12/31/03 *****************************/
>
> /* Added the tooMuchGC variable, and the js_EnableTooMuchGC and
> * js_DisableTooMuchGC functions.
> *
> * We did not add the TOO_MUCH_GC flag -- that is something that the JS engine
> * already had. However, we added the ability to turn it on and off at
> * run-time, by calling JS_EnableTooMuchGC and JS_DisableTooMuchGC.
> */
> #ifdef TOO_MUCH_GC
> static JSBool tooMuchGC = JS_TRUE;
> #endif
>
> /* DREAMWEAVER added this function. Note, if the JS engine was compiled
> * without TOO_MUCH_GC defined, then this function does nothing.
> */
> JS_PUBLIC_API(void)
> js_EnableTooMuchGC(JSContext *cx)
> {
> #ifdef TOO_MUCH_GC
> tooMuchGC = JS_TRUE;
> #endif
> }
>
> /* DREAMWEAVER added this function. Note, if the JS engine was compiled
> * without TOO_MUCH_GC defined, then this function does nothing.
> */
> JS_PUBLIC_API(void)
> js_DisableTooMuchGC(JSContext *cx)
> {
> #ifdef TOO_MUCH_GC
> tooMuchGC = JS_FALSE;
> #endif
> }
>
> /************************* END DREAMWEAVER CHANGE **************************/
>
> /* DREAMWEAVER CHANGE [mmorearty 12/31/03]
> *
> * In the original, the entire contents of this #ifdef were:
> *
> * #ifdef TOO_MUCH_GC
> * js_GC(cx, GC_KEEP_ATOMS);
> * tried_gc = JS_TRUE;
> * #else
> * tried_gc = JS_FALSE;
> * #endif
> *
> * We have added the check of the 'tooMuchGC' variable.
> */
> if (tooMuchGC) {
> } else {
> tried_gc = JS_FALSE;
> }
> /* DREAMWEAVER CHANGE
> *
> * Set rt->gcPoke if TOO_MUCH_GC is defined.
> *
> * If TOO_MUCH_GC is defined, that tells the JavaScript engine to do
> * way more garbage collections than is actually necessary -- it will
> * cause a GC every single time anyone tries to create an object on
> * the GC heap. This is useful for debugging.
> *
> * But ironically, there is one class of GC-related bugs which could
> * crash under normal execution, but will never crash if TOO_MUCH_GC
> * is defined. That happens if you have code like this:
> *
> * someObj = JS_NewObject(...); // this can cause a GC
> * anotherObj = JS_NewObject(...); // this can cause a GC
> *
> * In this case, if TOO_MUCH_GC is defined, the second call to
> * JS_NewObject will *not* cause a GC. That is because the GC engine
> * keeps track of whether, since the last GC, anything happened that
> * might have caused any objects to become potential candidates for
> * collection. For example, every time you call JS_RemoveRoot, the
> * GC engine knows that there is now probably at least one object that
> * could be freed by the next GC.
> *
> * If TOO_MUCH_GC is defined, then here is what the above code would
> * cause to happen:
> *
> * (1) The first call to JS_NewObject causes a GC to happen. As part
> * of the process of doing a GC, rt->gcPoke is set to JS_FALSE.
> * (2) When the second call to JS_NewObject is made, js_GC() will get
> * called, but since rt->gcPoke is still JS_FALSE, js_GC() knows
> * that no objects have been freed up since the last garbage
> * collection. So, js_GC() just exits without actually attempting
> * a GC.
> *
> * However, if TOO_MUCH_GC is *not* defined, here is what the above
> * code might cause to happen:
> *
> * (1) Some earlier code caused rt->gcPoke to be set to JS_TRUE.
> * (2) The first JS_NewObject call does not cause a GC to happen,
> * since none is necessary (there is enough available memory
> * to create the object without performing a GC).
> * (3) When the second call to JS_NewObject is made, there is not
> * enough memory, so a GC is performed.
> * (4) The first object might get freed, leading to a crash later.
> *
> * Notice that in the first scenario, with TOO_MUCH_GC defined, the
> * second call to JS_NewObject did *not* cause a GC; but in the second
> * scenario, with TOO_MUCH_GC undefined, the second call to
> * JS_NewObject *did* cause a GC!
> *
> * What I want is for the first scenario to cause a GC. So, that is
> * why I have added the following 'rt->gcPoke = JS_TRUE' statement.
> *
> * [mmorearty 12/30/03]
> */
> #ifdef TOO_MUCH_GC
> if (tooMuchGC)
> rt->gcPoke = JS_TRUE;
> #endif
> /* END DREAMWEAVER CHANGE */
>
> // DREAMWEAVER added this function. Note, if the JS engine was
> // compiled without TOO_MUCH_GC defined, then this function does
> // nothing.
> extern void
> js_EnableTooMuchGC(JSContext *cx);
>
> // DREAMWEAVER added this function. Note, if the JS engine was
> // compiled without TOO_MUCH_GC defined, then this function does
> // nothing.
> extern void
> js_DisableTooMuchGC(JSContext *cx);
>
> // DREAMWEAVER: added JavaScript profiling - see jsprofiler.h
> #include "project/jsprofiler.h"
>
> // DREAMWEAVER: inserted this declaration (see usage below).
> extern JSBool JSCallNativeSafe (JSNative native, JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
> jsval *rval);
>
> // DREAMWEAVER snewman 3/28/01: added prototype to eliminate compiler
> // warning.
> JS_FRIEND_API(jsval *)
> js_AllocRawStack(JSContext *cx, uintN nslots, void **markp);
>
> // DREAMWEAVER snewman 3/28/01: added prototype to eliminate compiler
> // warning.
> JS_FRIEND_API(void)
> js_FreeRawStack(JSContext *cx, void *mark);
>
< ok = native(cx, frame.thisp, argc, frame.argv, &frame.rval);
---
> // DREAMWEAVER: patched to call JSCallNativeSafe instead of calling
> // the native function directly. JSCallNativeSafe catches C++
> // exceptions and turns them into an error result.
> ok = JSCallNativeSafe(native, cx, frame.thisp, argc, frame.argv, &frame.rval);
> // DREAMWEAVER: added JavaScript profiling - see jsprofiler.h
> #ifdef DREAMWEAVER_JAVASCRIPT_PROFILING
> JSBool
> js_Interpret(JSContext *cx, jsval *result)
> {
> return jsprofiler_Interpret(cx, result);
> }
>
> JSBool
> js_InterpretInternal(JSContext *cx, jsval *result)
> #else
> #endif
< * The contents of this file are subject to the Netscape 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/NPL/
---
> * ***** BEGIN LICENSE BLOCK *****
> * Version: MPL 1.1/GPL 2.0/LGPL 2.1
< * Software distributed under the License is distributed on an "AS
< * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express oqr
< * implied. See the License for the specific language governing
< * rights and limitations under the License.
---
> * 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 Initial Developer of the Original Code is Netscape
< * Communications Corporation. Portions created by Netscape are
< * Copyright (C) 1998 Netscape Communications Corporation. All
< * Rights Reserved.
---
> * 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.
< * Alternatively, the contents of this file may be used under the
< * terms of the GNU Public License (the "GPL"), in which case the
< * provisions of the GPL are applicable instead of those above.
< * If you wish to allow use of your version of this file only
< * under the terms of the GPL and not to allow others to use your
< * version of this file under the NPL, indicate your decision by
< * deleting the provisions above and replace them with the notice
< * and other provisions required by the GPL. If you do not delete
< * the provisions above, a recipient may use your version of this
< * file under either the NPL or the GPL.
< */
---
> * 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 ***** */
< JSPackedBool constructing; /* true if called via new operator */
< uint8 overrides; /* bit-set of overridden Call properties */
< uint8 special; /* special frame type flags, see below */
< JSPackedBool reserved; /* reserved for future use */
---
> uint32 flags; /* frame flags -- see below */
> JSAtomMap *objAtomMap; /* object atom map, non-null only if we
> hit a regexp object literal */
< /* JS special stack frame flags. */
< #define JSFRAME_DEBUGGER 0x1 /* frame for JS_EvaluateInStackFrame */
< #define JSFRAME_EVAL 0x2 /* frame for obj_eval */
---
> /* JS stack frame flags. */
> #define JSFRAME_CONSTRUCTING 0x01 /* frame is for a constructor invocation */
> #define JSFRAME_INTERNAL 0x02 /* internal call, not invoked by a script */
> #define JSFRAME_SKIP_CALLER 0x04 /* skip one link when evaluating f.caller
> for this invocation of f */
> #define JSFRAME_ASSIGNING 0x08 /* a complex (not simplex JOF_ASSIGNING) op
> is currently assigning to a property */
> #define JSFRAME_DEBUGGER 0x10 /* frame for JS_EvaluateInStackFrame */
> #define JSFRAME_EVAL 0x20 /* frame for obj_eval */
> #define JSFRAME_SPECIAL 0x30 /* special evaluation frame flags */
> #define JSFRAME_COMPILING 0x40 /* frame is being used by compiler */
> #define JSFRAME_COMPILE_N_GO 0x80 /* compiler-and-go mode, can optimize name
> references based on scope chain */
>
> #define JSFRAME_OVERRIDE_SHIFT 24 /* override bit-set params; see jsfun.c */
> #define JSFRAME_OVERRIDE_BITS 8
> #define JS_PROPERTY_CACHE_METERING 1
>
< uint32 _prefills; \
< uint32 _fills = (cache)->fills; \
---
> uint32 prefills_; \
> uint32 fills_ = (cache)->fills; \
< _prefills = _fills; \
---
> prefills_ = fills_; \
< } while ((_fills = (cache)->fills) != _prefills); \
---
> } while ((fills_ = (cache)->fills) != prefills_); \
> JSBool disabled;
> #ifdef JS_PROPERTY_CACHE_METERING
> # define PCMETER(x) x
> #else
> # define PCMETER(x) /* nothing */
> #endif
< #define PROPERTY_CACHE_FILL(cx, cache, obj, id, prop) \
---
> #define PROPERTY_CACHE_FILL(cache, obj, id, sprop) \
< uintN _hashIndex = (uintN)PROPERTY_CACHE_HASH(obj, id); \
< JSPropertyCache *_cache = (cache); \
< JSPropertyCacheEntry *_pce = &_cache->table[_hashIndex]; \
< JSPropertyCacheEntry _entry; \
< JSProperty *_pce_prop; \
< PCE_LOAD(_cache, _pce, _entry); \
< _pce_prop = PCE_PROPERTY(_entry); \
< if (_pce_prop && _pce_prop != prop) \
< _cache->recycles++; \
< PCE_OBJECT(_entry) = obj; \
< PCE_PROPERTY(_entry) = prop; \
< _cache->empty = JS_FALSE; \
< _cache->fills++; \
< PCE_STORE(_cache, _pce, _entry); \
---
> JSPropertyCache *cache_ = (cache); \
> if (!cache_->disabled) { \
> uintN hashIndex_ = (uintN) PROPERTY_CACHE_HASH(obj, id); \
> JSPropertyCacheEntry *pce_ = &cache_->table[hashIndex_]; \
> JSPropertyCacheEntry entry_; \
> JSScopeProperty *pce_sprop_; \
> PCE_LOAD(cache_, pce_, entry_); \
> pce_sprop_ = PCE_PROPERTY(entry_); \
> PCMETER(if (pce_sprop_ && pce_sprop_ != sprop) \
> cache_->recycles++); \
> PCE_OBJECT(entry_) = obj; \
> PCE_PROPERTY(entry_) = sprop; \
> cache_->empty = JS_FALSE; \
> PCMETER(cache_->fills++); \
> PCE_STORE(cache_, pce_, entry_); \
> } \
< #define PROPERTY_CACHE_TEST(cache, obj, id, prop) \
---
> #define PROPERTY_CACHE_TEST(cache, obj, id, sprop) \
< uintN _hashIndex = (uintN)PROPERTY_CACHE_HASH(obj, id); \
< JSPropertyCache *_cache = (cache); \
< JSPropertyCacheEntry *_pce = &_cache->table[_hashIndex]; \
< JSPropertyCacheEntry _entry; \
< JSProperty *_pce_prop; \
< PCE_LOAD(_cache, _pce, _entry); \
< _pce_prop = PCE_PROPERTY(_entry); \
< _cache->tests++; \
< if (_pce_prop && \
< sym_id(((JSScopeProperty *)_pce_prop)->symbols) == id && \
< PCE_OBJECT(_entry) == obj) { \
< prop = _pce_prop; \
---
> uintN hashIndex_ = (uintN) PROPERTY_CACHE_HASH(obj, id); \
> JSPropertyCache *cache_ = (cache); \
> JSPropertyCacheEntry *pce_ = &cache_->table[hashIndex_]; \
> JSPropertyCacheEntry entry_; \
> JSScopeProperty *pce_sprop_; \
> PCE_LOAD(cache_, pce_, entry_); \
> pce_sprop_ = PCE_PROPERTY(entry_); \
> PCMETER(cache_->tests++); \
> if (pce_sprop_ && \
> PCE_OBJECT(entry_) == obj && \
> pce_sprop_->id == id) { \
> sprop = pce_sprop_; \
< _cache->misses++; \
< prop = NULL; \
---
> PCMETER(cache_->misses++); \
> sprop = NULL; \
< js_FlushPropertyCacheByProp(JSContext *cx, JSProperty *prop);
---
> js_DisablePropertyCache(JSContext *cx);
>
> extern void
> js_EnablePropertyCache(JSContext *cx);
< * Consolidated js_Invoke flags. NB: JSINVOKE_CONSTRUCT must be 1 or JS_TRUE
< * (see js_Invoke's initialization of frame.constructing).
---
> * Consolidated js_Invoke flags simply rename the low JSFRAME_* flags.
< #define JSINVOKE_CONSTRUCT 0x1 /* construct object rather than call */
< #define JSINVOKE_INTERNAL 0x2 /* internal call, not from a script */
---
> #define JSINVOKE_CONSTRUCT JSFRAME_CONSTRUCTING
> #define JSINVOKE_INTERNAL JSFRAME_INTERNAL
> #define JSINVOKE_SKIP_CALLER JSFRAME_SKIP_CALLER
< #define JS_USE_FDLIBM_MATH 1
---
>
> // DREAMWEAVER: changed this from 1 to 0
> #define JS_USE_FDLIBM_MATH 0
>
> // DREAMWEAVER: tweaked definition of fd_copysign
> #ifdef XP_OS2_VACPP /* OS2TODO */
> #define fd_copysign
> #elif defined (_WIN32)
> #define fd_copysign _copysign
> #else
> #endif
>
> /* DREAMWEAVER added following prototype to eliminate compiler warnings */
> JS_PUBLIC_API(JSBool) resolving_MatchEntry(JSDHashTable *table, const JSDHashEntryHdr *hdr, const void *ptr);
>
< if (!OBJ_LOOKUP_PROPERTY(cx, proto, id, objp, propp))
---
> /* DREAMWEAVER - orginal code, see note below
> * if (!OBJ_LOOKUP_PROPERTY(cx, proto, id, objp, propp))
> * return JS_FALSE;
> */
>
> /* DREAMWEAVER
> * DaveG - if the lookup didn't find the property, do a get_property to
> * see if the prop exists. If it does, define the property now.
> *
> * snewman 2/22/01: this is necessary because Dreamweaver defines
> * object classes with additional properties, but doesn't quite
> * follow the rules when doing so. See dw_js_notes.txt for details.
> *
> * The full change we've made to this routine is as follows:
> *
> * 1. Insert the declarations of ret and val, above.
> * 2. Convert the next line to assign the result of OBJ_LOOKUP_PROPERTY
> * into ret, instead of returning it directly.
> * 3. Insert the following seven lines (the "if (ret && *propp == NULL)"
> * and the code inside it).
> * 4. Add "if (!ret) {return JS_FALSE}" to match orginal logic
> */
> ret = OBJ_LOOKUP_PROPERTY(cx, proto, id, objp, propp);
>
> if (ret && *propp == NULL) {
> val = JSVAL_VOID;
> OBJ_GET_PROPERTY(cx, proto, id, &val);
> if (val != JSVAL_VOID) {
> OBJ_DEFINE_PROPERTY(cx, proto, id, val, NULL, NULL, 0, NULL);
> OBJ_LOOKUP_PROPERTY(cx, proto, id, objp, propp);
> }
> }
> if (!ret) {
> }
> /* DREAMWEAVER added prototypes to get rid of compiler warnings */
> void printChar(jschar *cp);
> void printString(JSString *str);
> void printObj(JSContext *cx, JSObject *jsobj);
> void printId(JSContext *cx, jsid id);
> void printAtom(JSAtom *atom);
>
>
< #ifdef XP_UNIX
---
> /* DREAMWEAVER - changes for Mach-O mac, replaced the following define with the one below it.
> * #ifdef XP_UNIX
> */
> #if defined(XP_UNIX) || defined (__MACH__)
>
> // DREAMWEAVER snewman 3/16/01: added this flag to detect re-entrant calls
> // to the JS compiler. I'm getting a wierd illegal-access error when the
> // internal JavaScript debugger contains a compile-time error, and I think
> // it's because this causes us to invoke the compiler reentrantly and it
> // gets mixed up about tempPool.
> JSBool gInCompileTokenStream = JS_FALSE;
>
>
>
> // DREAMWEAVER snewman 3/16/01: see declaration of gInCompileTokenStream.
> JS_ASSERT(!gInCompileTokenStream);
> gInCompileTokenStream = JS_TRUE;
>
>
> // DREAMWEAVER snewman 3/16/01: see declaration of gInCompileTokenStream.
> gInCompileTokenStream = JS_FALSE;
>
>
> // DREAMWEAVER macromedia change - jschang 6/1/01
> // if the containing object has the special property - MM_defineFunctionsOnCompile
> // then define the property now - this is because we need to compile scripts
> // in the document, so we can execute some of the functions selectively later on
> // - JavaScript 1.2 did this autmoatically, but the JavaScript 1.5 only defines the
> // property when you execute the script that contains the function
> // definition, but we can't just execute any old script, we only execute
> // specific behavior functions that we define and have control over.
> //
> // The following code that defines the property is copied and modified from
> // jsinterp.c, js_Interpret, case JSOP_DEFFUN:
> else
> {
> JSStackFrame *fp;
> JSObject *varobj;
> JSBool ok, cond;
> jsval specialPropVal;
> uintN flags, attrs;
>
> fp = cx->fp;
> varobj = fp->varobj;
>
> // check the special property
> if ( JS_GetProperty(cx, varobj, "MM_defineFunctionsOnCompile", &specialPropVal) &&
> JS_TRUE == JSVAL_TO_BOOLEAN(specialPropVal) )
> {
> /*
> * We must be at top-level (default "box", either function body or
> * global) scope, not inside a with or other compound statement in
> * the same compilation unit (ECMA Program).
> *
> * However, we could be in a Program being eval'd from inside a
> * with statement, so we need to distinguish variables object from
> * scope chain head. Hence the two assignments to parent below.
> * First we make sure the function object we're defining has the
> * right scope chain. Then we define its name in fp->varobj.
> *
> * If static link is not current scope, clone fun's object to link
> * to the current scope via parent. This clause exists to enable
> * sharing of compiled functions among multiple equivalent scopes,
> * splitting the cost of compilation evenly among the scopes and
> * amortizing it over a number of executions. Examples include XUL
> * scripts and event handlers shared among Mozilla chrome windows,
> * and server-side JS user-defined functions shared among requests.
> *
> * NB: The Script object exposes compile and exec in the language,
> * such that this clause introduces an incompatible change from old
> * JS versions that supported Script. Such a JS version supported
> * executing a script that defined and called functions scoped by
> * the compile-time static link, not by the exec-time scope chain.
> *
> * We sacrifice compatibility, breaking such scripts, in order to
> * promote compile-cost sharing and amortizing, and because Script
> * is not and will not be standardized.
> */
> /***** jschang - this is in js_Execute: I don't think we need it here
> parent = fp->scopeChain;
> if (OBJ_GET_PARENT(cx, obj) != parent) {
> obj = js_CloneFunctionObject(cx, obj, parent);
> if (!obj) {
> ok = JS_FALSE;
> goto out;
> }
> }
> *****/
>
> /*
> * ECMA requires functions defined when entering Global code to be
> * permanent, and functions defined when entering Eval code to be
> * impermanent.
> */
> attrs = JSPROP_ENUMERATE;
> // We don't want functions to be "permanent" in user docs, because
> // the Timeline code depends on these functions being gone after
> // they are deleted (seems reasonable!) to determine what
> // timelines are on page. redmunds 23May2005 184326
> //if (!(fp->flags & JSFRAME_EVAL))
> // attrs |= JSPROP_PERMANENT;
>
>
> /*
> * Load function flags that are also property attributes. Getters
> * and setters do not need a slot, their value is stored elsewhere
> * in the property itself, not in obj->slots.
> */
> flags = fun->flags & (JSFUN_GETTER | JSFUN_SETTER);
> if (flags)
> attrs |= flags | JSPROP_SHARED;
>
> /*
> * Check for a const property of the same name -- or any kind
> * of property if executing with the strict option. We check
> * here at runtime as well as at compile-time, to handle eval
> * as well as multiple HTML script tags.
> */
> parent = fp->varobj;
> if (js_CheckRedeclaration(cx, parent, (jsid)funAtom, attrs, &cond))
> {
> ok = OBJ_DEFINE_PROPERTY(cx, parent, (jsid)funAtom,
> OBJECT_TO_JSVAL(fun->object),
> (flags & JSFUN_GETTER)
> ? (JSPropertyOp) fun->object
> : NULL,
> (flags & JSFUN_SETTER)
> ? (JSPropertyOp) fun->object
> : NULL,
> attrs,
> NULL);
> }
> }
> }
> // DREAMWEAVER dgeorge 4/23/02: there are lots of Dreamweaver
> // extensions, such as the "Javascript Integration Kit for
> // Macromedia Flash 5", which will break if we stop treating
> // a single equals sign as equality. Therefore, I'm forcing
> // rewrite to be true. Also see the code in CompileOrExecScript
> // (in JSInterp.cpp) to handle this case.
> rewrite = JS_TRUE;
>
> // DREAMWEAVER - add these macros so on windows we get line numbers on memory leaks
> #if defined(XP_WIN) && defined (_DEBUG) //for debug builds only
> #define _CRTDBG_MAP_ALLOC
> #include <crtdbg.h>
> #endif
>
> /* DREAMWEAVER - changes for Mach-O mac, replaced the following define with the one below it.
> * #ifdef XP_MAC
> * #include <MacMemory.h>
> * #endif
> */
> #ifdef __MACH__
> #include <Carbon/Carbon.h>
> #else
> #endif
> /* DREAMWEAVER - change behavior of empty submatches to be empty strings instead of undefined. This fixes the following problem
> var testString = new String("this is a test string");
> var reObj = new RegExp(/\s(foo)|(test)\s/);
> var matchedArray = testString.match(reObj);
> matchedArray[1] == RegExp.$1; //this is false if the property is undefined
> */
< ok = js_DefineProperty(cx, obj, INT_TO_JSVAL(num + 1),
< JSVAL_VOID, NULL, NULL,
< JSPROP_ENUMERATE, NULL);
---
> // ok = js_DefineProperty(cx, obj, INT_TO_JSVAL(num + 1),
> // JSVAL_VOID, NULL, NULL,
> // JSPROP_ENUMERATE, NULL);
> parstr = JSVAL_TO_STRING(JS_GetEmptyStringValue(cx));
> }
< }
---
> //}
> /* DREAMWEAVER - end of change */
< sub = REGEXP_PAREN_SUBSTRING(res, slot);
---
> /* DREAMWEAVER - Macro replaced with function, see comment in jsregexp.h
> * sub = REGEXP_PAREN_SUBSTRING(res, slot);
> */
> sub = js_RegExpParenSubString(res, slot);
> // DREAMWEAVER: See comment in the header file.
> JSRegExpStatics *
> js_GetRegExpStatics(JSContext *cx)
> {
> return &(cx->regExpStatics);
> }
>
> // DREAMWEAVER: See [dgeorge 23-feb-02] comment in header file
> JSSubString *
> js_RegExpParenSubString(JSRegExpStatics *res, jsuint num)
> {
> JSSubString *ret = NULL;
>
> if (num < (jsuint)(res->parenCount))
> {
> if (num < 9)
> {
> ret = &(res->parens[num]);
> }
> else
> {
> ret = &(res->moreParens[num - 9]);
> }
> }
> else
> {
> ret = &js_EmptySubString;
> }
>
> return ret;
> }
>
> *
> * DREAMWEAVER [dgeorge 23-feb-02] I'm replacing the macro with a function because
> * it looks like the macro is being compiled incorrectly in the WinRelease
> * build
> /*
> */
> extern JSSubString *
> js_RegExpParenSubString(JSRegExpStatics *res, jsuint num);
> /* DREAMWEAVER:
> *
> * Added a function to access the statics data structure.
> *
> * We should be able to access the structure by traversing the js_context
> * data structure. However, differences between the compiler flags for
> * the NscpJavaScript library and the Dreamweaver executable cause problems
> * on the Mac (I think the cause is that Enums are ints in Dreamweaver but
> * not in NscpJavaScript). Instead of switching the compiler flag and
> * introducing a lot of risk, I'm adding this function to access the
> * piece of js_context that interests me. [dgeorge 8/00]
> *
> * [snewman 2/14/00: copied this patch from NscpJavaScript to JavaScript_1_5]
> */
> extern JSRegExpStatics *
> js_GetRegExpStatics(JSContext *cx);
> // DREAMWEAVER - add these macros so on windows we get line numbers on memory leaks
> #if defined(XP_WIN) && defined (_DEBUG) //for debug builds only
> #define _CRTDBG_MAP_ALLOC
> #include <crtdbg.h>
> #endif
>
< lineno = (uintN) js_GetSrcNoteOffset(sn, 0);
---
> // DREAMWEAVER snewman 6/15/01: changed this to not update lineno
> // if js_GetSrcNoteOffset returns a smaller value -- otherwise we
> // were having problems debugging the JavaScript code that the
> // template engine generates. For some reason, the last srcnote
> // in that function had a line number of zero.
> uintN temp = (uintN) js_GetSrcNoteOffset(sn, 0);
> if (lineno < temp)
> lineno = temp;
< return REGEXP_PAREN_SUBSTRING(res, num);
---
> // DREAMWEAVER: replacing REGEXP_PAREN_SUBSTRING with js_RegExpParenSubString
> // (see comment from dgeorge in jsregexp.h
> return js_RegExpParenSubString(res, num);
< parsub = REGEXP_PAREN_SUBSTRING(&cx->regExpStatics, num);
---
> // DREAMWEAVER: replacing REGEXP_PAREN_SUBSTRING with js_RegExpParenSubString
> // (see comment from dgeorge in jsregexp.h
> parsub = js_RegExpParenSubString(&cx->regExpStatics, num);
> /* DREAMWEAVER add prototype to get rid of compiler warning */
> void printJSStringStats(JSRuntime *rt);
>
>
> // DREAMWEAVER snewman 3/16/01: tweaked this file to remove all
> // references to "_declspec", to match the changes we had made in the
> // JS 1.2 interpreter. Using _declspec doesn't make sense, because we
> // aren't building a separate DLL -- the interpreter is linked directly
> // into Dreamweaver.
>
>
> // DREAMWEAVER
> #if WIN32
> #define XP_WIN 1
> #elif __powerc
> #define XP_MAC 1
> #endif
>
< #define JS_EXTERN_API(__type) extern __declspec(dllexport) __type
< #define JS_EXPORT_API(__type) __declspec(dllexport) __type
< #define JS_EXTERN_DATA(__type) extern __declspec(dllexport) __type
< #define JS_EXPORT_DATA(__type) __declspec(dllexport) __type
---
> #define JS_EXTERN_API(__type) extern __type
> #define JS_EXPORT_API(__type) __type
> #define JS_EXTERN_DATA(__type) extern __type
> #define JS_EXPORT_DATA(__type) __type
< #define JS_EXTERN_API(__type) extern __declspec(export) __type
< #define JS_EXPORT_API(__type) __declspec(export) __type
< #define JS_EXTERN_DATA(__type) extern __declspec(export) __type
< #define JS_EXPORT_DATA(__type) __declspec(export) __type
---
> #define JS_EXTERN_API(__type) extern __type
> #define JS_EXPORT_API(__type) __type
> #define JS_EXTERN_DATA(__type) extern __type
> #define JS_EXPORT_DATA(__type) __type
< # define JS_IMPORT_API(__x) __declspec(dllimport) __x
---
> # define JS_IMPORT_API(__x) __x
< # define JS_IMPORT_DATA(__x) __declspec(dllimport) __x
---
> # define JS_IMPORT_DATA(__x) __x
> /* DREAMWEAVER - changes for Mach-O mac, replaced the following define with the one below it.
> * #ifdef XP_MAC
> * # include <Types.h>
> * # include <stdarg.h>
> * # include "jsprf.h"
> * #endif
> */
> #ifdef __MACH__
> #include <Carbon/Carbon.h>
> #else
> #endif
>
> // DREAMWEAVER snewman 3/28/01: wrapped JS_Assert in #ifdef DEBUG
> // to avoid compiler warning (no prototype) when DEBUG is turned off.
> #ifdef DEBUG
>
>
> #endif
< #include <windef.h>
< #include <winbase.h>
---
> /* DREAMWEAVER cbank - 9/13/04 - per MSDN documentation for GetSystemTimeAsFileTime,
> * we should include windows.h instead of these two files directly. This eleminates
> * some compiler errors I was seeing.
> *
> * #include <windef.h>
> * #include <winbase.h>
> */
> #include <windows.h>
> /* DREAMWEAVER - changes for Mach-O mac, added __MACH__ clause */
> # ifdef __MACH__
> # include <Carbon/Carbon.h>
> # else
> # include <OSUtils.h>
> # include <TextUtils.h>
> # include <Resources.h>
> # include <Timer.h>
> # include <UTCUtils.h>
> #endif