diff --git a/js/src/js.c b/js/src/js.c index 0c4cce823ad..223159af8b5 100644 --- a/js/src/js.c +++ b/js/src/js.c @@ -130,8 +130,10 @@ static JSObject * split_setup(JSContext *cx); #ifdef EDITLINE +JS_BEGIN_EXTERN_C extern char *readline(const char *prompt); extern void add_history(char *line); +JS_END_EXTERN_C #endif static JSBool @@ -634,7 +636,7 @@ ReadLine(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) from = stdin; buflength = 0; bufsize = BUFSIZE; - buf = JS_malloc(cx, bufsize); + buf = (char *) JS_malloc(cx, bufsize); if (!buf) return JS_FALSE; @@ -651,7 +653,7 @@ ReadLine(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) /* Else, grow our buffer for another pass. */ bufsize *= 2; if (bufsize > buflength) { - tmp = JS_realloc(cx, buf, bufsize); + tmp = (char *) JS_realloc(cx, buf, bufsize); } else { JS_ReportOutOfMemory(cx); tmp = NULL; @@ -673,7 +675,7 @@ ReadLine(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) } /* Shrink the buffer to the real size. */ - tmp = JS_realloc(cx, buf, buflength); + tmp = (char *) JS_realloc(cx, buf, buflength); if (!tmp) { JS_free(cx, buf); return JS_FALSE; @@ -916,7 +918,7 @@ UpdateSwitchTableBounds(JSScript *script, uintN offset, jsint low, high, n; pc = script->code + offset; - op = *pc; + op = (JSOp) *pc; switch (op) { case JSOP_TABLESWITCHX: jmplen = JUMPX_OFFSET_LEN; @@ -1922,7 +1924,7 @@ split_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op, switch (enum_op) { case JSENUMERATE_INIT: - cpx = JS_GetPrivate(cx, obj); + cpx = (ComplexObject *) JS_GetPrivate(cx, obj); if (!cpx->isInner && cpx->inner) obj = cpx->inner; @@ -2007,7 +2009,7 @@ split_mark(JSContext *cx, JSObject *obj, void *arg) { ComplexObject *cpx; - cpx = JS_GetPrivate(cx, obj); + cpx = (ComplexObject *) JS_GetPrivate(cx, obj); if (!cpx->isInner && cpx->inner) { /* Mark the inner object. */ @@ -2022,7 +2024,7 @@ split_outerObject(JSContext *cx, JSObject *obj) { ComplexObject *cpx; - cpx = JS_GetPrivate(cx, obj); + cpx = (ComplexObject *) JS_GetPrivate(cx, obj); return cpx->isInner ? cpx->outer : obj; } @@ -2031,7 +2033,7 @@ split_innerObject(JSContext *cx, JSObject *obj) { ComplexObject *cpx; - cpx = JS_GetPrivate(cx, obj); + cpx = (ComplexObject *) JS_GetPrivate(cx, obj); return !cpx->isInner ? cpx->inner : obj; } @@ -2055,7 +2057,7 @@ split_create_outer(JSContext *cx) ComplexObject *cpx; JSObject *obj; - cpx = JS_malloc(cx, sizeof *obj); + cpx = (ComplexObject *) JS_malloc(cx, sizeof *obj); if (!cpx) return NULL; cpx->outer = NULL; @@ -2085,7 +2087,7 @@ split_create_inner(JSContext *cx, JSObject *outer) JS_ASSERT(JS_GET_CLASS(cx, outer) == &split_global_class.base); - cpx = JS_malloc(cx, sizeof *cpx); + cpx = (ComplexObject *) JS_malloc(cx, sizeof *cpx); if (!cpx) return NULL; cpx->outer = outer; @@ -2098,7 +2100,7 @@ split_create_inner(JSContext *cx, JSObject *outer) return NULL; } - outercpx = JS_GetPrivate(cx, outer); + outercpx = (ComplexObject *) JS_GetPrivate(cx, outer); outercpx->inner = obj; return obj; @@ -2109,7 +2111,7 @@ split_get_private(JSContext *cx, JSObject *obj) { do { if (JS_GET_CLASS(cx, obj) == &split_global_class.base) - return JS_GetPrivate(cx, obj); + return (ComplexObject *) JS_GetPrivate(cx, obj); obj = JS_GetParent(cx, obj); } while (obj); diff --git a/js/src/jsapi.c b/js/src/jsapi.c index d9a5917cf03..04ac0573772 100644 --- a/js/src/jsapi.c +++ b/js/src/jsapi.c @@ -1142,6 +1142,8 @@ JS_SetGlobalObject(JSContext *cx, JSObject *obj) #endif } +JS_BEGIN_EXTERN_C + JSObject * js_InitFunctionAndObjectClasses(JSContext *cx, JSObject *obj) { @@ -1224,6 +1226,8 @@ out: return fun_proto; } +JS_END_EXTERN_C + JS_PUBLIC_API(JSBool) JS_InitStandardClasses(JSContext *cx, JSObject *obj) { @@ -3701,7 +3705,7 @@ JS_ClearScope(JSContext *cx, JSObject *obj) /* Clear cached class objects on the global object. */ if (JS_GET_CLASS(cx, obj)->flags & JSCLASS_IS_GLOBAL) { - JSProtoKey key; + int key; for (key = JSProto_Null; key < JSProto_LIMIT; key++) JS_SetReservedSlot(cx, obj, key, JSVAL_VOID); diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 606a2fab623..737049f5fd9 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -79,7 +79,7 @@ JS_BEGIN_EXTERN_C /* Objects, strings, and doubles are GC'ed. */ #define JSVAL_IS_GCTHING(v) (!((v) & JSVAL_INT) && !JSVAL_IS_BOOLEAN(v)) -#define JSVAL_TO_GCTHING(v) ((void *)JSVAL_CLRTAG(v)) +#define JSVAL_TO_GCTHING(v) ((JSGCThing *)JSVAL_CLRTAG(v)) #define JSVAL_TO_OBJECT(v) ((JSObject *)JSVAL_TO_GCTHING(v)) #define JSVAL_TO_DOUBLE(v) ((jsdouble *)JSVAL_TO_GCTHING(v)) #define JSVAL_TO_STRING(v) ((JSString *)JSVAL_TO_GCTHING(v)) @@ -1237,9 +1237,10 @@ struct JSExtendedClass { #define JSCLASS_CACHED_PROTO_WIDTH 8 #define JSCLASS_CACHED_PROTO_MASK JS_BITMASK(JSCLASS_CACHED_PROTO_WIDTH) #define JSCLASS_HAS_CACHED_PROTO(key) ((key) << JSCLASS_CACHED_PROTO_SHIFT) -#define JSCLASS_CACHED_PROTO_KEY(clasp) (((clasp)->flags \ - >> JSCLASS_CACHED_PROTO_SHIFT) \ - & JSCLASS_CACHED_PROTO_MASK) +#define JSCLASS_CACHED_PROTO_KEY(clasp) ((JSProtoKey) \ + (((clasp)->flags \ + >> JSCLASS_CACHED_PROTO_SHIFT) \ + & JSCLASS_CACHED_PROTO_MASK)) /* Initializer for unused members of statically initialized JSClass structs. */ #define JSCLASS_NO_OPTIONAL_MEMBERS 0,0,0,0,0,0,0,0 diff --git a/js/src/jsatom.c b/js/src/jsatom.c index 808be1eb804..e2aab797f13 100644 --- a/js/src/jsatom.c +++ b/js/src/jsatom.c @@ -820,14 +820,14 @@ js_ValueToStringAtom(JSContext *cx, jsval v) JS_STATIC_DLL_CALLBACK(JSHashNumber) js_hash_atom_ptr(const void *key) { - const JSAtom *atom = key; + const JSAtom *atom = (const JSAtom *) key; return atom->number; } JS_STATIC_DLL_CALLBACK(void *) js_alloc_temp_space(void *priv, size_t size) { - JSContext *cx = priv; + JSContext *cx = (JSContext *) priv; void *space; JS_ARENA_ALLOCATE(space, &cx->tempPool, size); @@ -844,7 +844,7 @@ js_free_temp_space(void *priv, void *item) JS_STATIC_DLL_CALLBACK(JSHashEntry *) js_alloc_temp_entry(void *priv, const void *key) { - JSContext *cx = priv; + JSContext *cx = (JSContext *) priv; JSAtomListElement *ale; JS_ARENA_ALLOCATE_TYPE(ale, JSAtomListElement, &cx->tempPool); @@ -949,7 +949,7 @@ JS_STATIC_DLL_CALLBACK(intN) js_map_atom(JSHashEntry *he, intN i, void *arg) { JSAtomListElement *ale = (JSAtomListElement *)he; - JSAtom **vector = arg; + JSAtom **vector = (JSAtom **) arg; vector[ALE_INDEX(ale)] = ALE_ATOM(ale); return HT_ENUMERATE_NEXT; diff --git a/js/src/jsatom.h b/js/src/jsatom.h index 3b216be3128..a0ae79ea73c 100644 --- a/js/src/jsatom.h +++ b/js/src/jsatom.h @@ -95,7 +95,7 @@ struct JSAtomListElement { #define ALE_ATOM(ale) ((JSAtom *) (ale)->entry.key) #define ALE_INDEX(ale) ((jsatomid) JS_PTR_TO_UINT32((ale)->entry.value)) -#define ALE_JSOP(ale) ((JSOp) (ale)->entry.value) +#define ALE_JSOP(ale) ((JSOp) JS_PTR_TO_UINT32((ale)->entry.value)) #define ALE_VALUE(ale) ((jsval) (ale)->entry.value) #define ALE_NEXT(ale) ((JSAtomListElement *) (ale)->entry.next) diff --git a/js/src/jscntxt.h b/js/src/jscntxt.h index 6e104c8a363..67d224ffa07 100644 --- a/js/src/jscntxt.h +++ b/js/src/jscntxt.h @@ -839,7 +839,8 @@ class JSAutoTempValueRooter #define JSVERSION_MASK 0x0FFF /* see JSVersion in jspubtd.h */ #define JSVERSION_HAS_XML 0x1000 /* flag induced by XML option */ -#define JSVERSION_NUMBER(cx) ((cx)->version & JSVERSION_MASK) +#define JSVERSION_NUMBER(cx) ((JSVersion)((cx)->version & \ + JSVERSION_MASK)) #define JS_HAS_XML_OPTION(cx) ((cx)->version & JSVERSION_HAS_XML || \ JSVERSION_NUMBER(cx) >= JSVERSION_1_6) diff --git a/js/src/jsdbgapi.c b/js/src/jsdbgapi.c index 0c918388efc..83ab5119682 100644 --- a/js/src/jsdbgapi.c +++ b/js/src/jsdbgapi.c @@ -545,7 +545,7 @@ js_watch_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp) if (nslots <= JS_ARRAY_LENGTH(smallv)) { argv = smallv; } else { - argv = JS_malloc(cx, nslots * sizeof(jsval)); + argv = (jsval *) JS_malloc(cx, nslots * sizeof(jsval)); if (!argv) { DBG_LOCK(rt); DropWatchPointAndUnlock(cx, wp, JSWP_HELD); @@ -1107,7 +1107,7 @@ JS_GetScriptLineExtent(JSContext *cx, JSScript *script) JS_PUBLIC_API(JSVersion) JS_GetScriptVersion(JSContext *cx, JSScript *script) { - return script->version & JSVERSION_MASK; + return (JSVersion) (script->version & JSVERSION_MASK); } /***************************************************************************/ diff --git a/js/src/jsdhash.c b/js/src/jsdhash.c index 311871d4f07..8db9d709615 100644 --- a/js/src/jsdhash.c +++ b/js/src/jsdhash.c @@ -102,7 +102,7 @@ JS_DHashStringKey(JSDHashTable *table, const void *key) const unsigned char *s; h = 0; - for (s = key; *s != '\0'; s++) + for (s = (const unsigned char *) key; *s != '\0'; s++) h = (h >> (JS_DHASH_BITS - 4)) ^ (h << 4) ^ *s; return h; } @@ -132,7 +132,8 @@ JS_DHashMatchStringKey(JSDHashTable *table, /* XXX tolerate null keys on account of sloppy Mozilla callers. */ return stub->key == key || - (stub->key && key && strcmp(stub->key, key) == 0); + (stub->key && key && + strcmp((const char *) stub->key, (const char *) key) == 0); } JS_PUBLIC_API(void) @@ -215,7 +216,7 @@ JS_DHashTableInit(JSDHashTable *table, const JSDHashTableOps *ops, void *data, fprintf(stderr, "jsdhash: for the table at address %p, the given entrySize" " of %lu %s favors chaining over double hashing.\n", - (void *)table, + (void *) table, (unsigned long) entrySize, (entrySize > 16 * sizeof(void*)) ? "definitely" : "probably"); } @@ -239,7 +240,8 @@ JS_DHashTableInit(JSDHashTable *table, const JSDHashTableOps *ops, void *data, table->generation = 0; nbytes = capacity * entrySize; - table->entryStore = ops->allocTable(table, nbytes + ENTRY_STORE_EXTRA); + table->entryStore = (char *) ops->allocTable(table, + nbytes + ENTRY_STORE_EXTRA); if (!table->entryStore) return JS_FALSE; memset(table->entryStore, 0, nbytes); @@ -526,7 +528,8 @@ ChangeTable(JSDHashTable *table, int deltaLog2) entrySize = table->entrySize; nbytes = newCapacity * entrySize; - newEntryStore = table->ops->allocTable(table, nbytes + ENTRY_STORE_EXTRA); + newEntryStore = (char *) table->ops->allocTable(table, + nbytes + ENTRY_STORE_EXTRA); if (!newEntryStore) return JS_FALSE; diff --git a/js/src/jsdtoa.c b/js/src/jsdtoa.c index 29381623a3c..231790d3c0f 100644 --- a/js/src/jsdtoa.c +++ b/js/src/jsdtoa.c @@ -2100,6 +2100,7 @@ js_dtoa(double d, int mode, JSBool biasUp, int ndigits, Bigint *b, *b1, *delta, *mlo, *mhi, *S; double d2, ds, eps; char *s; + const char *cs; if (word0(d) & Sign_bit) { /* set sign for everything, including 0's and NaNs */ @@ -2112,13 +2113,13 @@ js_dtoa(double d, int mode, JSBool biasUp, int ndigits, if ((word0(d) & Exp_mask) == Exp_mask) { /* Infinity or NaN */ *decpt = 9999; - s = !word1(d) && !(word0(d) & Frac_mask) ? "Infinity" : "NaN"; - if ((s[0] == 'I' && bufsize < 9) || (s[0] == 'N' && bufsize < 4)) { + cs = !word1(d) && !(word0(d) & Frac_mask) ? "Infinity" : "NaN"; + if ((cs[0] == 'I' && bufsize < 9) || (cs[0] == 'N' && bufsize < 4)) { JS_ASSERT(JS_FALSE); /* JS_SetError(JS_BUFFER_OVERFLOW_ERROR, 0); */ return JS_FALSE; } - strcpy(buf, s); + strcpy(buf, cs); if (rve) { *rve = buf[3] ? buf + 8 : buf + 3; JS_ASSERT(**rve == '\0'); diff --git a/js/src/jsemit.c b/js/src/jsemit.c index 54d82429511..487dc15d41b 100644 --- a/js/src/jsemit.c +++ b/js/src/jsemit.c @@ -1307,7 +1307,7 @@ EmitBackPatchOp(JSContext *cx, JSCodeGenerator *cg, JSOp op, ptrdiff_t *lastp) */ #define EMIT_UINT16_IMM_OP(op, i) \ JS_BEGIN_MACRO \ - if (js_Emit3(cx, cg, op, UINT16_HI(i), UINT16_LO(i)) < 0) \ + if (js_Emit3(cx, cg, (JSOp)(op), UINT16_HI(i), UINT16_LO(i)) < 0) \ return JS_FALSE; \ JS_END_MACRO @@ -1782,19 +1782,19 @@ IndexRegExpClone(JSContext *cx, JSParseNode *pn, JSAtomListElement *ale, return JS_TRUE; } -static int +static JSOp EmitBigIndexPrefix(JSContext *cx, JSCodeGenerator *cg, jsatomid atomIndex) { if (atomIndex < JS_BIT(16)) return JSOP_NOP; atomIndex >>= 16; if (atomIndex <= JSOP_ATOMBASE3 - JSOP_ATOMBASE1 + 1) { - if (js_Emit1(cx, cg, JSOP_ATOMBASE1 + atomIndex - 1) < 0) - return -1; + if (js_Emit1(cx, cg, (JSOp)(JSOP_ATOMBASE1 + atomIndex - 1)) < 0) + return (JSOp)-1; return JSOP_RESETBASE0; } if (js_Emit2(cx, cg, JSOP_ATOMBASE, (JSOp)atomIndex) < 0) - return -1; + return (JSOp)-1; return JSOP_RESETBASE; } @@ -1811,7 +1811,7 @@ EmitBigIndexPrefix(JSContext *cx, JSCodeGenerator *cg, jsatomid atomIndex) static JSBool EmitAtomIndexOp(JSContext *cx, JSOp op, jsatomid atomIndex, JSCodeGenerator *cg) { - int bigSuffix; + JSOp bigSuffix; bigSuffix = EmitBigIndexPrefix(cx, cg, atomIndex); if (bigSuffix < 0) @@ -1827,7 +1827,7 @@ EmitAtomIndexOp(JSContext *cx, JSOp op, jsatomid atomIndex, JSCodeGenerator *cg) */ #define EMIT_ATOM_INDEX_OP(op, atomIndex) \ JS_BEGIN_MACRO \ - if (!EmitAtomIndexOp(cx, op, atomIndex, cg)) \ + if (!EmitAtomIndexOp(cx, (JSOp) op, atomIndex, cg)) \ return JS_FALSE; \ JS_END_MACRO @@ -1858,7 +1858,7 @@ static JSBool EmitIndexConstOp(JSContext *cx, JSOp op, uintN slot, jsatomid atomIndex, JSCodeGenerator *cg) { - int bigSuffix; + JSOp bigSuffix; ptrdiff_t off; jsbytecode *pc; @@ -1874,7 +1874,7 @@ EmitIndexConstOp(JSContext *cx, JSOp op, uintN slot, jsatomid atomIndex, SET_UINT16(pc, slot); pc += 2; SET_ATOM_INDEX(pc, atomIndex); - return bigSuffix == 0 || js_Emit1(cx, cg, bigSuffix) >= 0; + return bigSuffix == JSOP_NOP || js_Emit1(cx, cg, bigSuffix) >= 0; } /* @@ -1935,7 +1935,7 @@ BindNameToSlot(JSContext *cx, JSTreeContext *tc, JSParseNode *pn, JS_ASSERT(stmt->flags & SIF_SCOPE); JS_ASSERT(slot >= 0); - op = pn->pn_op; + op = PN_OP(pn); switch (op) { case JSOP_NAME: op = JSOP_GETLOCAL; break; case JSOP_SETNAME: op = JSOP_SETLOCAL; break; @@ -2005,7 +2005,7 @@ BindNameToSlot(JSContext *cx, JSTreeContext *tc, JSParseNode *pn, if (fp->scopeChain != obj) return JS_TRUE; - op = pn->pn_op; + op = PN_OP(pn); getter = NULL; #ifdef __GNUC__ attrs = slot = 0; /* quell GCC overwarning */ @@ -2326,7 +2326,7 @@ EmitNameOp(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn, if (!BindNameToSlot(cx, &cg->treeContext, pn, 0)) return JS_FALSE; - op = pn->pn_op; + op = PN_OP(pn); if (callContext) { switch (op) { @@ -2482,7 +2482,7 @@ EmitPropOp(JSContext *cx, JSParseNode *pn, JSOp op, JSCodeGenerator *cg, CG_OFFSET(cg) - pndown->pn_offset) < 0) { return JS_FALSE; } - if (!EmitAtomOp(cx, pndot, pndot->pn_op, cg)) + if (!EmitAtomOp(cx, pndot, PN_OP(pndot), cg)) return JS_FALSE; /* Reverse the pn_expr link again. */ @@ -3751,7 +3751,7 @@ EmitVariables(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn, */ JS_ASSERT(forInVar); JS_ASSERT(pn->pn_count == 1); - if (!EmitDestructuringDecls(cx, cg, pn->pn_op, pn2)) + if (!EmitDestructuringDecls(cx, cg, PN_OP(pn), pn2)) return JS_FALSE; break; } @@ -3774,7 +3774,8 @@ EmitVariables(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn, JS_ASSERT(noteIndex < 0 && !pn2->pn_next); op = JSOP_POP; if (!MaybeEmitGroupAssignment(cx, cg, - inLetHead ? JSOP_POP : pn->pn_op, + inLetHead ? JSOP_POP : + PN_OP(pn), pn2, &op)) { return JS_FALSE; } @@ -3785,7 +3786,7 @@ EmitVariables(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn, } pn3 = pn2->pn_left; - if (!EmitDestructuringDecls(cx, cg, pn->pn_op, pn3)) + if (!EmitDestructuringDecls(cx, cg, PN_OP(pn), pn3)) return JS_FALSE; #if JS_HAS_BLOCK_SCOPE @@ -3834,7 +3835,7 @@ EmitVariables(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn, * we will emit at the bottom of this function. */ if (!EmitDestructuringOps(cx, cg, - inLetHead ? JSOP_POP : pn->pn_op, + inLetHead ? JSOP_POP : PN_OP(pn), pn3)) { return JS_FALSE; } @@ -3849,7 +3850,7 @@ EmitVariables(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn, return JS_FALSE; JS_ASSERT(pn2->pn_slot >= 0 || !let); - op = pn2->pn_op; + op = PN_OP(pn2); if (op == JSOP_ARGUMENTS) { /* JSOP_ARGUMENTS => no initializer */ JS_ASSERT(!pn2->pn_expr && !let); @@ -3858,7 +3859,7 @@ EmitVariables(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn, atomIndex = 0; /* quell GCC overwarning */ #endif } else { - if (!MaybeEmitVarDecl(cx, cg, pn->pn_op, pn2, &atomIndex)) + if (!MaybeEmitVarDecl(cx, cg, PN_OP(pn), pn2, &atomIndex)) return JS_FALSE; pn3 = pn2->pn_expr; @@ -4097,7 +4098,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) js_NewSrcNote(cx, cg, SRC_GENEXP) < 0) { return JS_FALSE; } - EMIT_ATOM_INDEX_OP(pn->pn_op, atomIndex); + EMIT_ATOM_INDEX_OP(PN_OP(pn), atomIndex); break; } @@ -4399,7 +4400,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) * any side effects. So we hoist only i in the let case. */ pn3 = pn2->pn_left; - type = pn3->pn_type; + type = PN_TYPE(pn3); cg->treeContext.flags |= TCF_IN_FOR_INIT; if (TOKEN_TYPE_IS_DECL(type) && !js_EmitTree(cx, cg, pn3)) return JS_FALSE; @@ -4421,7 +4422,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) #else JS_ASSERT(pn->pn_op == JSOP_FORIN || pn->pn_op == JSOP_FOREACH); #endif - if (js_Emit1(cx, cg, pn->pn_op) < 0) + if (js_Emit1(cx, cg, PN_OP(pn)) < 0) return JS_FALSE; top = CG_OFFSET(cg); @@ -4452,7 +4453,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) JS_ASSERT(pn3->pn_type == TOK_RB || pn3->pn_type == TOK_RC); } if (pn3->pn_type == TOK_RB || pn3->pn_type == TOK_RC) { - op = pn2->pn_left->pn_op; + op = PN_OP(pn2->pn_left); goto destructuring_for; } #else @@ -4482,7 +4483,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) /* FALL THROUGH */ case TOK_NAME: if (pn3->pn_slot >= 0) { - op = pn3->pn_op; + op = PN_OP(pn3); switch (op) { case JSOP_GETARG: /* FALL THROUGH */ case JSOP_SETARG: op = JSOP_FORARG; break; @@ -4498,7 +4499,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) pn3->pn_op = JSOP_FORNAME; if (!BindNameToSlot(cx, &cg->treeContext, pn3, 0)) return JS_FALSE; - op = pn3->pn_op; + op = PN_OP(pn3); } if (pn3->pn_slot >= 0) { if (pn3->pn_attrs & JSPROP_READONLY) { @@ -5228,7 +5229,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) if (pn->pn_arity == PN_UNARY) { if (!js_EmitTree(cx, cg, pn->pn_kid)) return JS_FALSE; - if (js_Emit1(cx, cg, pn->pn_op) < 0) + if (js_Emit1(cx, cg, PN_OP(pn)) < 0) return JS_FALSE; break; } @@ -5448,7 +5449,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) JS_ASSERT(0); } - op = pn->pn_op; + op = PN_OP(pn); #if JS_HAS_GETTER_SETTER if (op == JSOP_GETTER || op == JSOP_SETTER) { /* We'll emit these prefix bytecodes after emitting the r.h.s. */ @@ -5667,7 +5668,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) pn2 = pn->pn_head; if (!js_EmitTree(cx, cg, pn2)) return JS_FALSE; - op = pn->pn_op; + op = PN_OP(pn); while ((pn2 = pn2->pn_next) != NULL) { if (!js_EmitTree(cx, cg, pn2)) return JS_FALSE; @@ -5682,7 +5683,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) if (pn->pn_arity == PN_NAME) { if (!js_EmitTree(cx, cg, pn->pn_expr)) return JS_FALSE; - if (!EmitAtomOp(cx, pn, pn->pn_op, cg)) + if (!EmitAtomOp(cx, pn, PN_OP(pn), cg)) return JS_FALSE; break; } @@ -5704,7 +5705,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) #if JS_HAS_XML_SUPPORT cg->treeContext.flags |= oldflags & TCF_IN_FOR_INIT; #endif - if (js_Emit1(cx, cg, pn->pn_op) < 0) + if (js_Emit1(cx, cg, PN_OP(pn)) < 0) return JS_FALSE; } break; @@ -5721,7 +5722,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) uintN oldflags; /* Unary op, including unary +/-. */ - op = pn->pn_op; + op = PN_OP(pn); #if JS_HAS_XML_SUPPORT if (op == JSOP_XMLNAME) { if (!EmitXMLName(cx, pn, op, cg)) @@ -5751,13 +5752,13 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) /* Emit lvalue-specialized code for ++/-- operators. */ pn2 = pn->pn_kid; JS_ASSERT(pn2->pn_type != TOK_RP); - op = pn->pn_op; + op = PN_OP(pn); switch (pn2->pn_type) { case TOK_NAME: pn2->pn_op = op; if (!BindNameToSlot(cx, &cg->treeContext, pn2, 0)) return JS_FALSE; - op = pn2->pn_op; + op = PN_OP(pn2); if (pn2->pn_slot >= 0) { if (pn2->pn_attrs & JSPROP_READONLY) { /* Incrementing a declared const: just get its value. */ @@ -5830,7 +5831,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) pn2->pn_op = JSOP_DELNAME; if (!BindNameToSlot(cx, &cg->treeContext, pn2, 0)) return JS_FALSE; - op = pn2->pn_op; + op = PN_OP(pn2); if (op == JSOP_FALSE) { if (js_Emit1(cx, cg, op) < 0) return JS_FALSE; @@ -5916,7 +5917,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) * this bytecode's immediate-indexed atom operand, and push its value * (not a reference to it). */ - ok = EmitPropOp(cx, pn, pn->pn_op, cg, JS_FALSE); + ok = EmitPropOp(cx, pn, PN_OP(pn), cg, JS_FALSE); break; case TOK_LB: @@ -5929,7 +5930,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) * push its value. Set the "obj" register to the result of ToObject * on the left operand. */ - ok = EmitElemOp(cx, pn, pn->pn_op, cg); + ok = EmitElemOp(cx, pn, PN_OP(pn), cg); break; case TOK_NEW: @@ -5949,7 +5950,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) return JS_FALSE; break; case TOK_DOT: - if (!EmitPropOp(cx, pn2, pn2->pn_op, cg, JS_TRUE)) + if (!EmitPropOp(cx, pn2, PN_OP(pn2), cg, JS_TRUE)) return JS_FALSE; break; case TOK_LB: @@ -5996,7 +5997,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) return JS_FALSE; argc = pn->pn_count - 1; - if (js_Emit3(cx, cg, pn->pn_op, ARGC_HI(argc), ARGC_LO(argc)) < 0) + if (js_Emit3(cx, cg, PN_OP(pn), ARGC_HI(argc), ARGC_LO(argc)) < 0) return JS_FALSE; break; } @@ -6025,7 +6026,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) * statements get braces by default from the decompiler. */ noteIndex = -1; - type = pn->pn_expr->pn_type; + type = PN_TYPE(pn->pn_expr); if (type != TOK_CATCH && type != TOK_LET && type != TOK_FOR && (!(stmt = stmtInfo.down) ? !(cg->treeContext.flags & TCF_IN_FUNCTION) @@ -6050,7 +6051,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) if (!js_EmitTree(cx, cg, pn->pn_expr)) return JS_FALSE; - op = pn->pn_op; + op = PN_OP(pn); if (op == JSOP_LEAVEBLOCKEXPR) { if (js_NewSrcNote2(cx, cg, SRC_PCBASE, CG_OFFSET(cg) - top) < 0) return JS_FALSE; @@ -6232,7 +6233,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) return JS_FALSE; #if JS_HAS_GETTER_SETTER - op = pn2->pn_op; + op = PN_OP(pn2); if (op == JSOP_GETTER || op == JSOP_SETTER) { if (js_Emit1(cx, cg, op) < 0) return JS_FALSE; @@ -6299,7 +6300,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) #endif case TOK_STRING: case TOK_OBJECT: - ok = EmitAtomOp(cx, pn, pn->pn_op, cg); + ok = EmitAtomOp(cx, pn, PN_OP(pn), cg); break; case TOK_NUMBER: @@ -6310,7 +6311,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) case TOK_ANYNAME: #endif case TOK_PRIMARY: - if (js_Emit1(cx, cg, pn->pn_op) < 0) + if (js_Emit1(cx, cg, PN_OP(pn)) < 0) return JS_FALSE; break; @@ -6325,7 +6326,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) case TOK_XMLELEM: case TOK_XMLLIST: if (pn->pn_op == JSOP_XMLOBJECT) { - ok = EmitAtomOp(cx, pn, pn->pn_op, cg); + ok = EmitAtomOp(cx, pn, PN_OP(pn), cg); break; } @@ -6362,7 +6363,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) return JS_FALSE; EMIT_ATOM_INDEX_OP(JSOP_STRING, ALE_INDEX(ale)); } - if (js_Emit1(cx, cg, pn->pn_op) < 0) + if (js_Emit1(cx, cg, PN_OP(pn)) < 0) return JS_FALSE; } #ifdef DEBUG @@ -6373,7 +6374,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) case TOK_XMLPTAGC: if (pn->pn_op == JSOP_XMLOBJECT) { - ok = EmitAtomOp(cx, pn, pn->pn_op, cg); + ok = EmitAtomOp(cx, pn, PN_OP(pn), cg); break; } /* FALL THROUGH */ @@ -6432,7 +6433,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) if (js_Emit1(cx, cg, JSOP_ADD) < 0) return JS_FALSE; - if ((pn->pn_extra & PNX_XMLROOT) && js_Emit1(cx, cg, pn->pn_op) < 0) + if ((pn->pn_extra & PNX_XMLROOT) && js_Emit1(cx, cg, PN_OP(pn)) < 0) return JS_FALSE; break; } @@ -6448,7 +6449,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) } } else { JS_ASSERT(pn->pn_arity == PN_NULLARY); - ok = EmitAtomOp(cx, pn, pn->pn_op, cg); + ok = EmitAtomOp(cx, pn, PN_OP(pn), cg); } break; diff --git a/js/src/jsemit.h b/js/src/jsemit.h index d5b977fdcd2..08ebcc1830a 100644 --- a/js/src/jsemit.h +++ b/js/src/jsemit.h @@ -602,8 +602,9 @@ typedef enum JSSrcNoteType { | ((d) & SN_XDELTA_MASK))) #define SN_IS_XDELTA(sn) ((*(sn) >> SN_DELTA_BITS) >= SRC_XDELTA) -#define SN_TYPE(sn) (SN_IS_XDELTA(sn) ? SRC_XDELTA \ - : *(sn) >> SN_DELTA_BITS) +#define SN_TYPE(sn) ((JSSrcNoteType)(SN_IS_XDELTA(sn) \ + ? SRC_XDELTA \ + : *(sn) >> SN_DELTA_BITS)) #define SN_SET_TYPE(sn,type) SN_MAKE_NOTE(sn, type, SN_DELTA(sn)) #define SN_IS_GETTABLE(sn) (SN_TYPE(sn) < SRC_NEWLINE) diff --git a/js/src/jsexn.c b/js/src/jsexn.c index d83382f1e15..6fd2acb3c1d 100644 --- a/js/src/jsexn.c +++ b/js/src/jsexn.c @@ -631,7 +631,7 @@ StackTraceToString(JSContext *cx, JSExnPrivate *priv) ptr_ = JS_realloc(cx, stackbuf, (stackmax+1) * sizeof(jschar)); \ if (!ptr_) \ goto bad; \ - stackbuf = ptr_; \ + stackbuf = (jschar *) ptr_; \ } \ stackbuf[stacklen++] = (c); \ JS_END_MACRO @@ -650,7 +650,7 @@ StackTraceToString(JSContext *cx, JSExnPrivate *priv) ptr_ = JS_realloc(cx, stackbuf, (stackmax+1) * sizeof(jschar)); \ if (!ptr_) \ goto bad; \ - stackbuf = ptr_; \ + stackbuf = (jschar *) ptr_; \ } \ js_strncpy(stackbuf + stacklen, JSSTRING_CHARS(str_), length_); \ stacklen += length_; \ @@ -700,7 +700,7 @@ StackTraceToString(JSContext *cx, JSExnPrivate *priv) */ void *shrunk = JS_realloc(cx, stackbuf, (stacklen+1) * sizeof(jschar)); if (shrunk) - stackbuf = shrunk; + stackbuf = (jschar *) shrunk; } stackbuf[stacklen] = 0; @@ -835,7 +835,7 @@ exn_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) name_length = JSSTRING_LENGTH(name); message_length = JSSTRING_LENGTH(message); length = (name_length ? name_length + 2 : 0) + message_length; - cp = chars = (jschar*) JS_malloc(cx, (length + 1) * sizeof(jschar)); + cp = chars = (jschar *) JS_malloc(cx, (length + 1) * sizeof(jschar)); if (!chars) return JS_FALSE; @@ -936,7 +936,7 @@ exn_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) } } - cp = chars = (jschar*) JS_malloc(cx, (length + 1) * sizeof(jschar)); + cp = chars = (jschar *) JS_malloc(cx, (length + 1) * sizeof(jschar)); if (!chars) return JS_FALSE; @@ -1153,7 +1153,7 @@ js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp) /* Find the exception index associated with this error. */ errorNumber = (JSErrNum) reportp->errorNumber; errorString = js_GetLocalizedErrorMessage(cx, NULL, NULL, errorNumber); - exn = errorString ? errorString->exnType : JSEXN_NONE; + exn = errorString ? (JSExnType) errorString->exnType : JSEXN_NONE; JS_ASSERT(exn < JSEXN_LIMIT); #if defined( DEBUG_mccabe ) && defined ( PRINTNAMES ) diff --git a/js/src/jsfun.c b/js/src/jsfun.c index e01a31aa996..67c6a4878d1 100644 --- a/js/src/jsfun.c +++ b/js/src/jsfun.c @@ -545,7 +545,7 @@ args_or_call_trace(JSTracer *trc, JSObject *obj) { JSStackFrame *fp; - fp = JS_GetPrivate(trc->context, obj); + fp = (JSStackFrame *) JS_GetPrivate(trc->context, obj); if (fp && (fp->flags & JSFRAME_GENERATOR)) { JS_CALL_OBJECT_TRACER(trc, FRAME_TO_GENERATOR(fp)->obj, "FRAME_TO_GENERATOR(fp)->obj"); @@ -797,7 +797,7 @@ call_enumerate(JSContext *cx, JSObject *obj) JS_ASSERT(JSID_IS_ATOM(sprop->id)); atom = JSID_TO_ATOM(sprop->id); JS_ASSERT(atom->flags & ATOM_HIDDEN); - atom = atom->entry.value; + atom = (JSAtom *) atom->entry.value; if (!js_LookupProperty(cx, obj, ATOM_TO_JSID(atom), &pobj, &prop)) return JS_FALSE; diff --git a/js/src/jsgc.c b/js/src/jsgc.c index e2de7c179c1..0fe0295b58a 100644 --- a/js/src/jsgc.c +++ b/js/src/jsgc.c @@ -940,7 +940,7 @@ js_gcroot_mapper(JSDHashTable *table, JSDHashEntryHdr *hdr, uint32 number, GCRootMapArgs *args = (GCRootMapArgs *) arg; JSGCRootHashEntry *rhe = (JSGCRootHashEntry *)hdr; intN mapflags; - JSDHashOperator op; + int op; mapflags = args->map(rhe->root, rhe->name, args->data); @@ -956,7 +956,7 @@ js_gcroot_mapper(JSDHashTable *table, JSDHashEntryHdr *hdr, uint32 number, op |= JS_DHASH_REMOVE; #endif - return op; + return (JSDHashOperator) op; } uint32 @@ -1741,7 +1741,7 @@ js_LockGCThingRT(JSRuntime *rt, void *thing) goto done; } if (!lhe->thing) { - lhe->thing = thing; + lhe->thing = (JSGCThing *) thing; lhe->count = deep ? 1 : 2; } else { JS_ASSERT(lhe->count >= 1); @@ -2033,7 +2033,7 @@ ScanDelayedChildren(JSTracer *trc) * XXX: inline js_GetGCThingFlags() to use already available * pi. */ - thing = (void *)((jsuword)pi + thingOffset); + thing = (JSGCThing *)((jsuword)pi + thingOffset); flagp = js_GetGCThingFlags(thing); if (thingsPerUnscannedChunk != 1) { /* diff --git a/js/src/jsinterp.c b/js/src/jsinterp.c index 476660c5cab..4f7a94c38fb 100644 --- a/js/src/jsinterp.c +++ b/js/src/jsinterp.c @@ -299,7 +299,7 @@ js_AllocStack(JSContext *cx, uintN nslots, void **markp) /* Callers don't check for zero nslots: we do to avoid empty segments. */ if (nslots == 0) { *markp = NULL; - return JS_ARENA_MARK(&cx->stackPool); + return (jsval *) JS_ARENA_MARK(&cx->stackPool); } /* Allocate 2 extra slots for the stack segment header we'll likely need. */ @@ -2181,12 +2181,13 @@ js_Interpret(JSContext *cx, jsbytecode *pc, jsval *result) METER_OP_INIT(op); /* to nullify first METER_OP_PAIR */ # define DO_OP() JS_EXTENSION_(goto *jumpTable[op]) -# define DO_NEXT_OP(n) do { METER_OP_PAIR(op, pc[n]); op = *(pc += (n)); \ +# define DO_NEXT_OP(n) do { METER_OP_PAIR(op, pc[n]); \ + op = (JSOp) *(pc += (n)); \ DO_OP(); } while (0) # define BEGIN_CASE(OP) L_##OP: # define END_CASE(OP) DO_NEXT_OP(OP##_LENGTH); # define END_VARLEN_CASE DO_NEXT_OP(len); -# define EMPTY_CASE(OP) BEGIN_CASE(OP) op = *++pc; DO_OP(); +# define EMPTY_CASE(OP) BEGIN_CASE(OP) op = (JSOp) *++pc; DO_OP(); #else # define DO_OP() goto do_op # define DO_NEXT_OP(n) goto advance_pc @@ -2221,8 +2222,8 @@ js_Interpret(JSContext *cx, jsbytecode *pc, jsval *result) * the most part -- web browsers select version before compiling and not * at run-time. */ - currentVersion = script->version; - originalVersion = cx->version; + currentVersion = (JSVersion) script->version; + originalVersion = (JSVersion) cx->version; if (currentVersion != originalVersion) js_SetVersion(cx, currentVersion); @@ -3958,9 +3959,9 @@ interrupt: } /* Switch to new version if currentVersion wasn't overridden. */ - newifp->callerVersion = cx->version; + newifp->callerVersion = (JSVersion) cx->version; if (JS_LIKELY(cx->version == currentVersion)) { - currentVersion = script->version; + currentVersion = (JSVersion) script->version; if (currentVersion != cx->version) js_SetVersion(cx, currentVersion); } @@ -3975,7 +3976,7 @@ interrupt: JS_RUNTIME_METER(rt, inlineCalls); /* Load first opcode and dispatch it (safe since JSOP_STOP). */ - op = *pc; + op = (JSOp) *pc; DO_OP(); bad_inline_call: diff --git a/js/src/jsiter.c b/js/src/jsiter.c index e3531fc3364..fb417f6abf0 100644 --- a/js/src/jsiter.c +++ b/js/src/jsiter.c @@ -61,6 +61,7 @@ #include "jsnum.h" #include "jsobj.h" #include "jsopcode.h" +#include "jsscan.h" #include "jsscope.h" #include "jsscript.h" @@ -68,8 +69,6 @@ #include "jsxml.h" #endif -extern const char js_throw_str[]; /* from jsscan.h */ - #define JSSLOT_ITER_STATE (JSSLOT_PRIVATE) #define JSSLOT_ITER_FLAGS (JSSLOT_PRIVATE + 1) diff --git a/js/src/jsiter.h b/js/src/jsiter.h index aa9de91b71b..8108b4a6bff 100644 --- a/js/src/jsiter.h +++ b/js/src/jsiter.h @@ -39,6 +39,9 @@ #ifndef jsiter_h___ #define jsiter_h___ + +JS_BEGIN_EXTERN_C + /* * JavaScript iterators. */ @@ -114,4 +117,6 @@ extern JSClass js_StopIterationClass; extern JSObject * js_InitIteratorClasses(JSContext *cx, JSObject *obj); +JS_END_EXTERN_C + #endif /* jsiter_h___ */ diff --git a/js/src/jskwgen.c b/js/src/jskwgen.c index 5ae39bd99db..2b76217a41e 100644 --- a/js/src/jskwgen.c +++ b/js/src/jskwgen.c @@ -353,7 +353,7 @@ generate_letter_switch(struct gen_opt *opt, unsigned *columns; unsigned i; - columns = malloc(sizeof(columns[0]) * current_length); + columns = (unsigned *) malloc(sizeof(columns[0]) * current_length); if (!columns) { perror("malloc"); exit(EXIT_FAILURE); @@ -384,7 +384,7 @@ generate_switch(struct gen_opt *opt) } line(opt, " */"); - indexes = malloc(sizeof(indexes[0]) * nelem); + indexes = (unsigned *) malloc(sizeof(indexes[0]) * nelem); if (!indexes) { perror("malloc"); exit(EXIT_FAILURE); diff --git a/js/src/jsobj.c b/js/src/jsobj.c index 47a1189bc14..32b8e6b6e96 100644 --- a/js/src/jsobj.c +++ b/js/src/jsobj.c @@ -222,8 +222,11 @@ obj_setSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp) /* __parent__ is readonly and permanent, only __proto__ may be set. */ propid = ATOM_TO_JSID(cx->runtime->atomState.protoAtom); - if (!OBJ_CHECK_ACCESS(cx, obj, propid, JSACC_PROTO|JSACC_WRITE, vp, &attrs)) + if (!OBJ_CHECK_ACCESS(cx, obj, propid, + (JSAccessMode)(JSACC_PROTO|JSACC_WRITE), vp, + &attrs)) { return JS_FALSE; + } return js_SetProtoOrParent(cx, obj, slot, pobj); } @@ -2528,6 +2531,8 @@ bad: goto out; } +JS_BEGIN_EXTERN_C + JS_STATIC_DLL_CALLBACK(JSObject *) js_InitNullClass(JSContext *cx, JSObject *obj) { @@ -2545,6 +2550,8 @@ static JSObjectOp lazy_prototype_init[JSProto_LIMIT] = { #undef JS_PROTO }; +JS_END_EXTERN_C + JSBool js_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, JSObject **objp) @@ -2637,7 +2644,7 @@ js_FindClassObject(JSContext *cx, JSObject *start, jsid id, jsval *vp) return JS_FALSE; if (JSID_IS_INT(id)) { - key = JSID_TO_INT(id); + key = (JSProtoKey) JSID_TO_INT(id); JS_ASSERT(key != JSProto_Null); if (!js_GetClassObject(cx, obj, key, &cobj)) return JS_FALSE; @@ -3545,7 +3552,7 @@ js_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp) JSOp op; uintN flags; - op = *pc; + op = (JSOp) *pc; if (op == JSOP_GETXPROP) { flags = JSREPORT_ERROR; } else { @@ -4694,7 +4701,7 @@ js_XDRObject(JSXDRState *xdr, JSObject **objp) if (xdr->mode == JSXDR_DECODE) { if (classDef) { /* NB: we know that JSProto_Null is 0 here, for backward compat. */ - protoKey = classDef >> 1; + protoKey = (JSProtoKey) (classDef >> 1); classKey = (protoKey != JSProto_Null) ? INT_TO_JSID(protoKey) : ATOM_TO_JSID(atom); diff --git a/js/src/jsopcode.c b/js/src/jsopcode.c index d277e6dd68c..fbb5c279cc6 100644 --- a/js/src/jsopcode.c +++ b/js/src/jsopcode.c @@ -1274,7 +1274,7 @@ GetLocal(SprintStack *ss, jsint i) #if JS_HAS_DESTRUCTURING #define LOCAL_ASSERT(expr) LOCAL_ASSERT_RV(expr, NULL) -#define LOAD_OP_DATA(pc) (oplen = (cs = &js_CodeSpec[op = *pc])->length) +#define LOAD_OP_DATA(pc) (oplen = (cs = &js_CodeSpec[op=(JSOp)*pc])->length) static jsbytecode * DecompileDestructuring(SprintStack *ss, jsbytecode *pc, jsbytecode *endpc); @@ -1826,9 +1826,13 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop) * operand. */ if (mode == JOF_PROP) { - op = (format & JOF_SET) ? JSOP_GETPROP2 : JSOP_GETPROP; + op = (JSOp) ((format & JOF_SET) + ? JSOP_GETPROP2 + : JSOP_GETPROP); } else if (mode == JOF_ELEM) { - op = (format & JOF_SET) ? JSOP_GETELEM2 : JSOP_GETELEM; + op = (JSOp) ((format & JOF_SET) + ? JSOP_GETELEM2 + : JSOP_GETELEM); } else { /* * Zero mode means precisely that op is uncategorized @@ -1889,7 +1893,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop) * expansion: x = x op y (replace y by z = w to see the * problem). */ - op = pc[oplen]; + op = (JSOp) pc[oplen]; LOCAL_ASSERT(op != saveop); } rval = POP_STR(); @@ -2581,6 +2585,8 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop) jp->indent += 4; len = 0; break; + default: + break; } todo = -2; @@ -2750,7 +2756,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop) * destructuring patterns yield zero-count blocks). */ pos = ss->top; - while ((op = ss->opcodes[--pos]) != JSOP_ENTERBLOCK && + while ((op = (JSOp) ss->opcodes[--pos]) != JSOP_ENTERBLOCK && op != JSOP_NEWINIT) { if (pos == 0) break; @@ -3215,8 +3221,10 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop) case JSOP_DUP2: rval = GetStr(ss, ss->top-2); todo = SprintCString(&ss->sprinter, rval); - if (todo < 0 || !PushOff(ss, todo, ss->opcodes[ss->top-2])) + if (todo < 0 || !PushOff(ss, todo, + (JSOp) ss->opcodes[ss->top-2])) { return NULL; + } /* FALL THROUGH */ case JSOP_DUP: @@ -3259,7 +3267,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop) #endif rval = GetStr(ss, ss->top-1); - saveop = ss->opcodes[ss->top-1]; + saveop = (JSOp) ss->opcodes[ss->top-1]; todo = SprintCString(&ss->sprinter, rval); break; @@ -3341,7 +3349,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop) * Special case: new (x(y)(z)) must be parenthesized like so. * Same for new (x(y).z) -- contrast with new x(y).z. */ - op = ss->opcodes[ss->top-1]; + op = (JSOp) ss->opcodes[ss->top-1]; lval = PopStr(ss, (saveop == JSOP_NEW && (op == JSOP_CALL || op == JSOP_EVAL || @@ -5049,7 +5057,7 @@ js_DecompileValueGenerator(JSContext *cx, intN spindex, jsval v, jmpoff = js_GetSrcNoteOffset(sn, 0); if (pc + jmpoff < begin) { pc += jmpoff; - op = *pc; + op = (JSOp) *pc; JS_ASSERT(op == JSOP_GOTO || op == JSOP_GOTOX); cs = &js_CodeSpec[op]; oplen = cs->length; @@ -5159,7 +5167,7 @@ js_DecompileValueGenerator(JSContext *cx, intN spindex, jsval v, } jp->dvgfence = end; if (js_DecompileCode(jp, script, begin, (uintN)len, (uintN)pcdepth)) { - name = (jp->sprinter.base) ? jp->sprinter.base : ""; + name = (jp->sprinter.base) ? jp->sprinter.base : (char *) ""; name = JS_strdup(cx, name); } js_DestroyPrinter(jp); diff --git a/js/src/jsparse.c b/js/src/jsparse.c index ffac48641a1..b81f2320558 100644 --- a/js/src/jsparse.c +++ b/js/src/jsparse.c @@ -4633,7 +4633,7 @@ MemberExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc, pn3 = PrimaryExpr(cx, ts, tc, tt, JS_TRUE); if (!pn3) return NULL; - tt = pn3->pn_type; + tt = PN_TYPE(pn3); if (tt == TOK_NAME) { pn2->pn_op = JSOP_GETPROP; pn2->pn_expr = pn; @@ -4686,7 +4686,7 @@ MemberExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc, pn3 = PrimaryExpr(cx, ts, tc, tt, JS_TRUE); if (!pn3) return NULL; - tt = pn3->pn_type; + tt = PN_TYPE(pn3); if (tt == TOK_NAME) { pn3->pn_type = TOK_STRING; pn3->pn_arity = PN_NULLARY; @@ -5668,7 +5668,7 @@ PrimaryExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc, op = JSOP_SETTER; else goto property_name; - + ts->flags |= TSF_KEYWORD_IS_NAME; tt = js_GetToken(cx, ts); ts->flags &= ~TSF_KEYWORD_IS_NAME; @@ -5681,7 +5681,7 @@ PrimaryExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc, return NULL; pn3->pn_atom = CURRENT_TOKEN(ts).t_atom; pn3->pn_slot = -1; - + /* We have to fake a 'function' token here. */ CURRENT_TOKEN(ts).t_op = JSOP_NOP; CURRENT_TOKEN(ts).type = TOK_FUNCTION; @@ -6181,7 +6181,7 @@ FoldXMLConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc) uint32 i, j; JS_ASSERT(pn->pn_arity == PN_LIST); - tt = pn->pn_type; + tt = PN_TYPE(pn); pnp = &pn->pn_head; pn1 = *pnp; accum = NULL; @@ -6680,7 +6680,7 @@ js_FoldConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc) break; } if (!pn2) { - JSOp op = pn->pn_op; + JSOp op = PN_OP(pn); pn2 = pn1->pn_next; pn3 = pn2->pn_next; @@ -6699,7 +6699,7 @@ js_FoldConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc) return JS_FALSE; } if (pn1->pn_type == TOK_NUMBER && pn2->pn_type == TOK_NUMBER) { - if (!FoldBinaryNumeric(cx, pn->pn_op, pn1, pn2, pn, tc)) + if (!FoldBinaryNumeric(cx, PN_OP(pn), pn1, pn2, pn, tc)) return JS_FALSE; } } diff --git a/js/src/jsparse.h b/js/src/jsparse.h index efa0a2c5098..41031fbf90d 100644 --- a/js/src/jsparse.h +++ b/js/src/jsparse.h @@ -378,6 +378,9 @@ struct JSParseNode { (pn)->pn_type == TOK_STRING || \ ((pn)->pn_type == TOK_PRIMARY && (pn)->pn_op != JSOP_THIS)) +#define PN_OP(pn) ((JSOp)(pn)->pn_op) +#define PN_TYPE(pn) ((JSTokenType)(pn)->pn_type) + /* * Compute a pointer to the last JSParseNode element in a singly-linked list. * NB: list must be non-empty for correct PN_LAST usage! diff --git a/js/src/jsproto.tbl b/js/src/jsproto.tbl index 18f2355945c..f84f7ab6117 100644 --- a/js/src/jsproto.tbl +++ b/js/src/jsproto.tbl @@ -72,7 +72,8 @@ /* * Enumerator codes in the second column must not change -- they are part of - * the JS XDR API. + * the JS XDR API. Client modules including jsproto.tbl should consider + * wrapping the inclusion with JS_BEGIN_EXTERN_C and JS_END_EXTERN_C. */ JS_PROTO(Null, 0, js_InitNullClass) JS_PROTO(Object, 1, js_InitFunctionAndObjectClasses) diff --git a/js/src/jsregexp.c b/js/src/jsregexp.c index 6289a48d73b..5404f150feb 100644 --- a/js/src/jsregexp.c +++ b/js/src/jsregexp.c @@ -70,7 +70,7 @@ typedef enum REOp { #undef REOP_DEF } REOp; -#define REOP_IS_SIMPLE(op) ((op) <= (unsigned)REOP_NCLASS) +#define REOP_IS_SIMPLE(op) ((op) <= REOP_NCLASS) #ifdef REGEXP_DEBUG const char *reop_names[] = { @@ -1652,7 +1652,7 @@ EmitREBytecode(CompilerState *state, JSRegExp *re, size_t treeDepth, emitStateSP->continueOp = REOP_ENDALT; ++emitStateSP; JS_ASSERT((size_t)(emitStateSP - emitStateStack) <= treeDepth); - t = t->u.kid2; + t = (RENode *) t->u.kid2; op = t->op; JS_ASSERT(op < REOP_LIMIT); continue; @@ -1756,7 +1756,7 @@ EmitREBytecode(CompilerState *state, JSRegExp *re, size_t treeDepth, emitStateSP->jumpToJumpFlag = JS_FALSE; ++emitStateSP; JS_ASSERT((size_t)(emitStateSP - emitStateStack) <= treeDepth); - t = t->kid; + t = (RENode *) t->kid; op = t->op; JS_ASSERT(op < REOP_LIMIT); continue; @@ -1906,7 +1906,7 @@ EmitREBytecode(CompilerState *state, JSRegExp *re, size_t treeDepth, break; --emitStateSP; t = emitStateSP->continueNode; - op = emitStateSP->continueOp; + op = (REOp) emitStateSP->continueOp; } } @@ -3021,7 +3021,7 @@ ExecuteREBytecode(REGlobalData *gData, REMatchState *x) case REOP_ENDCHILD: /* marks the end of a quantifier child */ pc = curState[-1].continue_pc; - op = curState[-1].continue_op; + op = (REOp) curState[-1].continue_op; if (!result) result = x; @@ -3219,7 +3219,7 @@ ExecuteREBytecode(REGlobalData *gData, REMatchState *x) (REBackTrackData *) ((char *)backTrackData - backTrackData->sz); x->cp = backTrackData->cp; pc = backTrackData->backtrack_pc; - op = backTrackData->backtrack_op; + op = (REOp) backTrackData->backtrack_op; JS_ASSERT(op < REOP_LIMIT); gData->stateStackTop = backTrackData->saveStateStackTop; JS_ASSERT(gData->stateStackTop); @@ -4278,7 +4278,7 @@ js_CloneRegExpObject(JSContext *cx, JSObject *obj, JSObject *parent) clone = js_NewObject(cx, &js_RegExpClass, NULL, parent); if (!clone) return NULL; - re = JS_GetPrivate(cx, obj); + re = (JSRegExp *) JS_GetPrivate(cx, obj); if (!JS_SetPrivate(cx, clone, re) || !js_SetLastIndex(cx, clone, 0)) { cx->weakRoots.newborn[GCX_OBJECT] = NULL; return NULL; diff --git a/js/src/jsregexp.h b/js/src/jsregexp.h index 90712b19d92..3aa3dac4de2 100644 --- a/js/src/jsregexp.h +++ b/js/src/jsregexp.h @@ -50,6 +50,8 @@ #include "jsdhash.h" #endif +JS_BEGIN_EXTERN_C + struct JSRegExpStatics { JSString *input; /* input string to match (perl $_, GC root) */ JSBool multiline; /* whether input contains newlines (perl $*) */ @@ -180,4 +182,6 @@ js_GetLastIndex(JSContext *cx, JSObject *obj, jsdouble *lastIndex); extern JSBool js_SetLastIndex(JSContext *cx, JSObject *obj, jsdouble lastIndex); +JS_END_EXTERN_C + #endif /* jsregexp_h___ */ diff --git a/js/src/jsscan.c b/js/src/jsscan.c index adf472b1841..87122e0558f 100644 --- a/js/src/jsscan.c +++ b/js/src/jsscan.c @@ -202,7 +202,7 @@ GrowTokenBuf(JSStringBuffer *sb, size_t newlength) size_t tbsize; JSArenaPool *pool; - cx = sb->data; + cx = (JSContext*) sb->data; base = sb->base; offset = PTRDIFF(sb->ptr, base, jschar); pool = &cx->tempPool; @@ -577,13 +577,13 @@ ReportCompileErrorNumber(JSContext *cx, void *handle, uintN flags, switch (flags & JSREPORT_HANDLE) { case JSREPORT_TS: - ts = handle; + ts = (JSTokenStream *) handle; break; case JSREPORT_CG: - cg = handle; + cg = (JSCodeGenerator *) handle; break; case JSREPORT_PN: - pn = handle; + pn = (JSParseNode *) handle; ts = pn->pn_ts; break; } @@ -790,7 +790,7 @@ GrowStringBuffer(JSStringBuffer *sb, size_t newlength) JS_ASSERT(offset >= 0); newlength += offset + 1; if ((size_t)offset < newlength && newlength < ~(size_t)0 / sizeof(jschar)) - bp = realloc(sb->base, newlength * sizeof(jschar)); + bp = (jschar *) realloc(sb->base, newlength * sizeof(jschar)); else bp = NULL; if (!bp) { @@ -1101,6 +1101,10 @@ js_GetToken(JSContext *cx, JSTokenStream *ts) JSAtom *atom; JSBool hadUnicodeEscape; const struct keyword *kw; + JSBool inTarget; + size_t targetLength; + ptrdiff_t contentIndex; + #define INIT_TOKENBUF() (ts->tokenbuf.ptr = ts->tokenbuf.base) #define TOKENBUF_LENGTH() PTRDIFF(ts->tokenbuf.ptr, ts->tokenbuf.base, jschar) @@ -1700,9 +1704,9 @@ retry: /* Check for processing instruction. */ if (MatchChar(ts, '?')) { - JSBool inTarget = JS_TRUE; - size_t targetLength = 0; - ptrdiff_t contentIndex = -1; + inTarget = JS_TRUE; + targetLength = 0; + contentIndex = -1; INIT_TOKENBUF(); while ((c = GetChar(ts)) != '?' || PeekChar(ts) != '>') { diff --git a/js/src/jsscope.c b/js/src/jsscope.c index 216df18d9fa..e2e333ff0c1 100644 --- a/js/src/jsscope.c +++ b/js/src/jsscope.c @@ -519,7 +519,7 @@ NewPropTreeKidsChunk(JSRuntime *rt) { PropTreeKidsChunk *chunk; - chunk = calloc(1, sizeof *chunk); + chunk = (PropTreeKidsChunk *) calloc(1, sizeof *chunk); if (!chunk) return NULL; JS_ASSERT(((jsuword)chunk & CHUNKY_KIDS_TAG) == 0); diff --git a/js/src/jsscope.h b/js/src/jsscope.h index 84b9399cb5c..6fedaa83193 100644 --- a/js/src/jsscope.h +++ b/js/src/jsscope.h @@ -52,6 +52,8 @@ # include "jslock.h" #endif +JS_BEGIN_EXTERN_C + /* * Given P independent, non-unique properties each of size S words mapped by * all scopes in a runtime, construct a property tree of N nodes each of size @@ -401,4 +403,6 @@ js_InitPropertyTree(JSRuntime *rt); extern void js_FinishPropertyTree(JSRuntime *rt); +JS_END_EXTERN_C + #endif /* jsscope_h___ */ diff --git a/js/src/jsscript.c b/js/src/jsscript.c index 474606d9636..e57eb40d0aa 100644 --- a/js/src/jsscript.c +++ b/js/src/jsscript.c @@ -1053,7 +1053,7 @@ js_InitScriptClass(JSContext *cx, JSObject *obj) JS_STATIC_DLL_CALLBACK(int) js_compare_strings(const void *k1, const void *k2) { - return strcmp(k1, k2) == 0; + return strcmp((const char *) k1, (const char *) k2) == 0; } /* Shared with jsatom.c to save code space. */ @@ -1076,7 +1076,8 @@ typedef struct ScriptFilenameEntry { JS_STATIC_DLL_CALLBACK(JSHashEntry *) js_alloc_sftbl_entry(void *priv, const void *key) { - size_t nbytes = offsetof(ScriptFilenameEntry, filename) + strlen(key) + 1; + size_t nbytes = offsetof(ScriptFilenameEntry, filename) + + strlen((const char *) key) + 1; return (JSHashEntry *) malloc(JS_MAX(nbytes, sizeof(JSHashEntry))); } diff --git a/js/src/jsstr.c b/js/src/jsstr.c index 816101a3e7a..14729b24908 100644 --- a/js/src/jsstr.c +++ b/js/src/jsstr.c @@ -182,7 +182,7 @@ js_ConcatStrings(JSContext *cx, JSString *left, JSString *right) if (!ldep) { JS_free(cx, s); } else { - s = JS_realloc(cx, ls, (ln + 1) * sizeof(jschar)); + s = (jschar *) JS_realloc(cx, ls, (ln + 1) * sizeof(jschar)); if (s) left->chars = s; } @@ -4559,7 +4559,8 @@ AddCharsToURI(JSContext *cx, JSString *str, const jschar *chars, size_t length) if (!str->chars || JS_HOWMANY(total, URI_CHUNK) > JS_HOWMANY(str->length + 1, URI_CHUNK)) { total = JS_ROUNDUP(total, URI_CHUNK); - newchars = JS_realloc(cx, str->chars, total * sizeof(jschar)); + newchars = (jschar *) JS_realloc(cx, str->chars, + total * sizeof(jschar)); if (!newchars) return JS_FALSE; str->chars = newchars; diff --git a/js/src/jsxdrapi.c b/js/src/jsxdrapi.c index 64037016f23..f26f91205ce 100644 --- a/js/src/jsxdrapi.c +++ b/js/src/jsxdrapi.c @@ -93,7 +93,7 @@ typedef struct JSXDRMemState { void *data_ = JS_realloc((xdr)->cx, MEM_BASE(xdr), limit_); \ if (!data_) \ return 0; \ - MEM_BASE(xdr) = data_; \ + MEM_BASE(xdr) = (char *) data_; \ MEM_LIMIT(xdr) = limit_; \ } \ } else { \ @@ -244,7 +244,7 @@ JS_XDRNewMem(JSContext *cx, JSXDRMode mode) return NULL; JS_XDRInitBase(xdr, mode, cx); if (mode == JSXDR_ENCODE) { - if (!(MEM_BASE(xdr) = JS_malloc(cx, MEM_BLOCK))) { + if (!(MEM_BASE(xdr) = (char *) JS_malloc(cx, MEM_BLOCK))) { JS_free(cx, xdr); return NULL; } @@ -273,7 +273,7 @@ JS_XDRMemSetData(JSXDRState *xdr, void *data, uint32 len) if (xdr->ops != &xdrmem_ops) return; MEM_LIMIT(xdr) = len; - MEM_BASE(xdr) = data; + MEM_BASE(xdr) = (char *) data; MEM_COUNT(xdr) = 0; } @@ -301,7 +301,7 @@ JS_XDRDestroy(JSXDRState *xdr) if (xdr->registry) { JS_free(cx, xdr->registry); if (xdr->reghash) - JS_DHashTableDestroy(xdr->reghash); + JS_DHashTableDestroy((JSDHashTable *) xdr->reghash); } JS_free(cx, xdr); } @@ -775,7 +775,8 @@ JS_XDRRegisterClass(JSXDRState *xdr, JSClass *clasp, uint32 *idp) registry[numclasses] = clasp; if (xdr->reghash) { JSRegHashEntry *entry = (JSRegHashEntry *) - JS_DHashTableOperate(xdr->reghash, clasp->name, JS_DHASH_ADD); + JS_DHashTableOperate((JSDHashTable *) xdr->reghash, + clasp->name, JS_DHASH_ADD); if (!entry) { JS_ReportOutOfMemory(xdr->cx); return JS_FALSE; @@ -807,8 +808,8 @@ JS_XDRFindClassIdByName(JSXDRState *xdr, const char *name) for (i = 0; i < numclasses; i++) { JSClass *clasp = xdr->registry[i]; entry = (JSRegHashEntry *) - JS_DHashTableOperate(xdr->reghash, clasp->name, - JS_DHASH_ADD); + JS_DHashTableOperate((JSDHashTable *) xdr->reghash, + clasp->name, JS_DHASH_ADD); entry->name = clasp->name; entry->index = i; } @@ -818,7 +819,8 @@ JS_XDRFindClassIdByName(JSXDRState *xdr, const char *name) /* If we managed to create reghash, use it for O(1) Find. */ if (xdr->reghash) { entry = (JSRegHashEntry *) - JS_DHashTableOperate(xdr->reghash, name, JS_DHASH_LOOKUP); + JS_DHashTableOperate((JSDHashTable *) xdr->reghash, + name, JS_DHASH_LOOKUP); if (JS_DHASH_ENTRY_IS_BUSY(&entry->hdr)) return CLASS_INDEX_TO_ID(entry->index); } diff --git a/js/src/jsxml.c b/js/src/jsxml.c index 8972286be29..f7e554dd7f5 100644 --- a/js/src/jsxml.c +++ b/js/src/jsxml.c @@ -1247,7 +1247,7 @@ XMLArrayTruncate(JSContext *cx, JSXMLArray *array, uint32 length) free(array->vector); vector = NULL; } else { - vector = realloc(array->vector, length * sizeof(void *)); + vector = (void **) realloc(array->vector, length * sizeof(void *)); if (!vector) return; } @@ -2596,7 +2596,7 @@ GeneratePrefix(JSContext *cx, JSString *uri, JSXMLArray *decls) bp = (jschar *) cp; newlength = length; if (STARTS_WITH_XML(cp, length) || !IsXMLName(cp, length)) { - newlength = length + 2 + (size_t) log10(decls->length); + newlength = length + 2 + (size_t) log10((double) decls->length); bp = (jschar *) JS_malloc(cx, (newlength + 1) * sizeof(jschar)); if (!bp) @@ -2621,7 +2621,7 @@ GeneratePrefix(JSContext *cx, JSString *uri, JSXMLArray *decls) !memcmp(JSSTRING_CHARS(ns->prefix), bp, newlength * sizeof(jschar))) { if (bp == cp) { - newlength = length + 2 + (size_t) log10(n); + newlength = length + 2 + (size_t) log10((double) n); bp = (jschar *) JS_malloc(cx, (newlength + 1) * sizeof(jschar)); if (!bp) @@ -2631,7 +2631,7 @@ GeneratePrefix(JSContext *cx, JSString *uri, JSXMLArray *decls) ++serial; JS_ASSERT(serial <= n); - dp = bp + length + 2 + (size_t) log10(serial); + dp = bp + length + 2 + (size_t) log10((double) serial); *dp = 0; for (m = serial; m != 0; m /= 10) *--dp = (jschar)('0' + m % 10); @@ -3428,7 +3428,7 @@ DeepCopyInLRS(JSContext *cx, JSXML *xml, uintN flags) /* Our caller must be protecting newborn objects. */ JS_ASSERT(cx->localRootStack); - copy = js_NewXML(cx, xml->xml_class); + copy = js_NewXML(cx, (JSXMLClass) xml->xml_class); if (!copy) return NULL; qn = xml->name; @@ -5248,7 +5248,7 @@ xml_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op, break; case JSENUMERATE_NEXT: - cursor = JSVAL_TO_PRIVATE(*statep); + cursor = (JSXMLArrayCursor *) JSVAL_TO_PRIVATE(*statep); if (cursor && cursor->array && (index = cursor->index) < length) { *idp = INT_TO_JSID(index); cursor->index = index + 1; @@ -5257,7 +5257,7 @@ xml_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op, /* FALL THROUGH */ case JSENUMERATE_DESTROY: - cursor = JSVAL_TO_PRIVATE(*statep); + cursor = (JSXMLArrayCursor *) JSVAL_TO_PRIVATE(*statep); if (cursor) { XMLArrayCursorFinish(cursor); JS_free(cx, cursor); @@ -5384,7 +5384,7 @@ xml_enumerateValues(JSContext *cx, JSObject *obj, JSIterateOp enum_op, break; case JSENUMERATE_NEXT: - cursor = JSVAL_TO_PRIVATE(*statep); + cursor = (JSXMLArrayCursor *) JSVAL_TO_PRIVATE(*statep); if (cursor && cursor->array && (index = cursor->index) < length) { while (!(kid = XMLARRAY_MEMBER(&xml->xml_kids, index, JSXML))) { if (++index == length) @@ -5402,7 +5402,7 @@ xml_enumerateValues(JSContext *cx, JSObject *obj, JSIterateOp enum_op, /* FALL THROUGH */ case JSENUMERATE_DESTROY: - cursor = JSVAL_TO_PRIVATE(*statep); + cursor = (JSXMLArrayCursor *) JSVAL_TO_PRIVATE(*statep); if (cursor) { destroy: XMLArrayCursorFinish(cursor); @@ -7389,7 +7389,7 @@ XMLList(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) } #define JSXML_LIST_SIZE (offsetof(JSXML, u) + sizeof(struct JSXMLListVar)) -#define JSXML_ELEMENT_SIZE (offsetof(JSXML, u) + sizeof(struct JSXMLVar)) +#define JSXML_ELEMENT_SIZE (offsetof(JSXML, u) + sizeof(struct JSXMLElemVar)) #define JSXML_LEAF_SIZE (offsetof(JSXML, u) + sizeof(JSString *)) static size_t sizeof_JSXML[JSXML_CLASS_LIMIT] = { diff --git a/js/src/jsxml.h b/js/src/jsxml.h index 9a79130a59b..652a1a2cadd 100644 --- a/js/src/jsxml.h +++ b/js/src/jsxml.h @@ -39,6 +39,8 @@ #ifndef jsxml_h___ #define jsxml_h___ +JS_BEGIN_EXTERN_C + #include "jsstddef.h" #include "jspubtd.h" @@ -152,6 +154,18 @@ typedef enum JSXMLClass { #include "jsclist.h" #endif +typedef struct JSXMLListVar { + JSXMLArray kids; /* NB: must come first */ + JSXML *target; + JSXMLQName *targetprop; +} JSXMLListVar; + +typedef struct JSXMLElemVar { + JSXMLArray kids; /* NB: must come first */ + JSXMLArray namespaces; + JSXMLArray attrs; +} JSXMLElemVar; + struct JSXML { #ifdef DEBUG_notme JSCList links; @@ -164,16 +178,8 @@ struct JSXML { uint16 xml_class; /* discriminates u, below */ uint16 xml_flags; /* flags, see below */ union { - struct JSXMLListVar { - JSXMLArray kids; /* NB: must come first */ - JSXML *target; - JSXMLQName *targetprop; - } list; - struct JSXMLVar { - JSXMLArray kids; /* NB: must come first */ - JSXMLArray namespaces; - JSXMLArray attrs; - } elem; + struct JSXMLListVar list; + struct JSXMLElemVar elem; JSString *value; } u; @@ -334,4 +340,6 @@ js_MakeXMLCommentString(JSContext *cx, JSString *str); extern JSString * js_MakeXMLPIString(JSContext *cx, JSString *name, JSString *str); +JS_END_EXTERN_C + #endif /* jsxml_h___ */