This commit is contained in:
brendan%mozilla.org 1999-07-28 06:48:44 +00:00
Родитель 710e7dd097
Коммит 2ac2a0d840
12 изменённых файлов: 64 добавлений и 57 удалений

Просмотреть файл

@ -147,7 +147,7 @@ js_DestroyContext(JSContext *cx, JSBool force_gc)
free(cx->lastMessage);
#ifdef JS_THREADSAFE
/* Destroying a context implicitly calls JS_EndRequest(). */
/* Destroying a context implicitly calls JS_EndRequest(). */
if (cx->requestDepth)
JS_EndRequest(cx);
#endif
@ -234,14 +234,14 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
if (callback) {
fmtData = (*callback)(userRef, "Mountain View", errorNumber);
if (fmtData != NULL) {
int totalArgsLength = 0;
int argLengths[10]; /* only {0} thru {9} supported */
size_t totalArgsLength = 0;
size_t argLengths[10]; /* only {0} thru {9} supported */
argCount = fmtData->argCount;
JS_ASSERT(argCount <= 10);
if (argCount > 0) {
/*
* Gather the arguments into an array, and accumulate
* their sizes. We allocate 1 more than necessary and
* their sizes. We allocate 1 more than necessary and
* null it out to act as the caboose when we free the
* pointers later.
*/
@ -253,7 +253,7 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
for (i = 0; i < argCount; i++) {
if (charArgs) {
char *charArg = va_arg(ap, char *);
reportp->messageArgs[i]
reportp->messageArgs[i]
= js_InflateString(cx, charArg, strlen(charArg));
}
else
@ -262,7 +262,7 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
totalArgsLength += argLengths[i];
}
/* NULL-terminate for easy copying. */
reportp->messageArgs[i] = NULL;
reportp->messageArgs[i] = NULL;
}
/*
* Parse the error format, substituting the argument X
@ -274,14 +274,15 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
const jschar *arg;
jschar *out;
int expandedArgs = 0;
int expandedLength
size_t expandedLength
= strlen(fmtData->format)
- (3 * argCount) /* exclude the {n} */
+ totalArgsLength;
/* Note - the above calculation assumes that each argument
* is used once and only once in the expansion !!!
*/
reportp->ucmessage = out
/*
* Note - the above calculation assumes that each argument
* is used once and only once in the expansion !!!
*/
reportp->ucmessage = out
= JS_malloc(cx, (expandedLength + 1) * sizeof(jschar));
if (!out) {
if (reportp->messageArgs) {
@ -311,14 +312,18 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
}
JS_ASSERT(expandedArgs == argCount);
*out = 0;
*messagep = js_DeflateString(cx, reportp->ucmessage,
out - reportp->ucmessage);
*messagep =
js_DeflateString(cx, reportp->ucmessage,
(size_t)(out - reportp->ucmessage));
}
} else { /* 0 arguments, the format string
(if it exists) is the entire message */
} else {
/*
* Zero arguments: the format string (if it exists) is the
* entire message.
*/
if (fmtData->format) {
*messagep = JS_strdup(cx, fmtData->format);
reportp->ucmessage
reportp->ucmessage
= js_InflateString(cx, *messagep, strlen(*messagep));
}
}
@ -396,12 +401,12 @@ js_ReportErrorNumberVA(JSContext *cx, uintN flags, JSErrorCallback callback,
*/
if (errorNumber == JSMSG_UNCAUGHT_EXCEPTION)
report.flags |= JSREPORT_EXCEPTION;
#if JS_HAS_ERROR_EXCEPTIONS
/*
* Only call the error reporter if an exception wasn't raised.
/*
* Only call the error reporter if an exception wasn't raised.
*
* If an exception was raised, then we call the debugErrorHook
* If an exception was raised, then we call the debugErrorHook
* (if present) to give it a chance to see the error before it
* propigates out of scope. This is needed for compatability with
* the old scheme.
@ -422,11 +427,11 @@ js_ReportErrorNumberVA(JSContext *cx, uintN flags, JSErrorCallback callback,
JS_free(cx, message);
if (report.messageArgs) {
int i = 0;
while (report.messageArgs[i])
while (report.messageArgs[i])
JS_free(cx, (void *)report.messageArgs[i++]);
JS_free(cx, (void *)report.messageArgs);
}
if (report.ucmessage)
if (report.ucmessage)
JS_free(cx, (void *)report.ucmessage);
}

Просмотреть файл

@ -2530,7 +2530,7 @@ ret1:
** '+' or '-' after the 'e' in scientific notation
*/
JS_FRIEND_API(void)
JS_cnvtf(char *buf,int bufsz, int prcsn,double fval)
JS_cnvtf(char *buf, size_t bufsz, int prcsn, double fval)
{
intN decpt,sign,numdigits;
char *num, *nump;

Просмотреть файл

@ -47,7 +47,7 @@ JS_strtod(const char *s00, char **se);
* point value.
*/
JS_FRIEND_API(void)
JS_cnvtf(char *buf, intN bufsz, intN prcsn, double dval);
JS_cnvtf(char *buf, size_t bufsz, int prcsn, double dval);
JS_END_EXTERN_C

Просмотреть файл

@ -861,7 +861,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
return JS_FALSE;
if (caseNoteIndex >= 0) {
/* off is the previous JSOP_CASE's bytecode offset. */
if (!js_SetSrcNoteOffset(cx, cg, caseNoteIndex, 0,
if (!js_SetSrcNoteOffset(cx, cg, (uintN)caseNoteIndex, 0,
CG_OFFSET(cg) - off)) {
return JS_FALSE;
}
@ -877,8 +877,10 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
pn3->pn_offset = off;
if (pn3 == pn2->pn_head) {
/* Switch note's second offset is to first JSOP_CASE. */
if (!js_SetSrcNoteOffset(cx, cg, noteIndex, 1, off - top))
if (!js_SetSrcNoteOffset(cx, cg, (uintN)noteIndex, 1,
off - top)) {
return JS_FALSE;
}
}
}
@ -927,7 +929,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
/* Set the SRC_SWITCH note's offset operand to tell end of switch. */
off = CG_OFFSET(cg) - top;
if (!js_SetSrcNoteOffset(cx, cg, noteIndex, 0, off))
if (!js_SetSrcNoteOffset(cx, cg, (uintN)noteIndex, 0, off))
return JS_FALSE;
if (switchop == JSOP_TABLESWITCH) {
@ -1138,13 +1140,13 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
SET_STATEMENT_TOP(&stmtInfo, top);
if (!pn2->pn_kid2) {
/* No loop condition: flag this fact in the source notes. */
if (!js_SetSrcNoteOffset(cx, cg, noteIndex, 0, 0))
if (!js_SetSrcNoteOffset(cx, cg, (uintN)noteIndex, 0, 0))
return JS_FALSE;
beq = 0;
} else {
if (!js_EmitTree(cx, cg, pn2->pn_kid2))
return JS_FALSE;
if (!js_SetSrcNoteOffset(cx, cg, noteIndex, 0,
if (!js_SetSrcNoteOffset(cx, cg, (uintN)noteIndex, 0,
(ptrdiff_t)(CG_OFFSET(cg) - top))) {
return JS_FALSE;
}
@ -1161,7 +1163,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
if (pn2->pn_type != TOK_IN) {
/* Set the second note offset so we can find the update part. */
JS_ASSERT(noteIndex != -1);
if (!js_SetSrcNoteOffset(cx, cg, noteIndex, 1,
if (!js_SetSrcNoteOffset(cx, cg, (uintN)noteIndex, 1,
(ptrdiff_t)(CG_OFFSET(cg) - top))) {
return JS_FALSE;
}
@ -1190,7 +1192,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
}
/* The third note offset helps us find the loop-closing jump. */
if (!js_SetSrcNoteOffset(cx, cg, noteIndex, 2,
if (!js_SetSrcNoteOffset(cx, cg, (uintN)noteIndex, 2,
(ptrdiff_t)(CG_OFFSET(cg) - top))) {
return JS_FALSE;
}
@ -1586,7 +1588,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
EMIT_ATOM_INDEX_OP(op, atomIndex);
tmp = CG_OFFSET(cg);
if (noteIndex >= 0) {
if (!js_SetSrcNoteOffset(cx, cg, noteIndex, 0, tmp - off))
if (!js_SetSrcNoteOffset(cx, cg, (uintN)noteIndex, 0, tmp-off))
return JS_FALSE;
}
if (!pn2->pn_next)
@ -1680,7 +1682,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
return JS_FALSE;
tmp = CG_OFFSET(cg);
if (noteIndex >= 0) {
if (!js_SetSrcNoteOffset(cx, cg, noteIndex, 0, tmp - off))
if (!js_SetSrcNoteOffset(cx, cg, (uintN)noteIndex, 0, tmp-off))
return JS_FALSE;
}
if (!pn2->pn_next)

Просмотреть файл

@ -1772,8 +1772,8 @@ js_ReportIsNotFunction(JSContext *cx, jsval *vp, JSBool constructing)
}
if (str) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
constructing ? JSMSG_NOT_CONSTRUCTOR
: JSMSG_NOT_FUNCTION,
(uintN)(constructing ? JSMSG_NOT_CONSTRUCTOR
: JSMSG_NOT_FUNCTION),
JS_GetStringBytes(str));
}
}

Просмотреть файл

@ -1916,8 +1916,8 @@ js_Interpret(JSContext *cx, jsval *result)
RESTORE_SP(fp);
if (!ok)
goto out;
i = ~i;
PUSH_NUMBER(cx, i);
d = (jsdouble) ~i;
PUSH_NUMBER(cx, d);
break;
case JSOP_NEG:

Просмотреть файл

@ -452,8 +452,8 @@ js_CleanupLocks()
JS_PUBLIC_API(void)
js_InitContextForLocking(JSContext *cx)
{
cx->thread = CurrentThreadId();
JS_ASSERT(Thin_GetWait(cx->thread) == 0);
cx->thread = CurrentThreadId();
JS_ASSERT(Thin_GetWait(cx->thread) == 0);
}
/*

Просмотреть файл

@ -51,8 +51,8 @@ typedef struct JSFatLockTable {
#define JS_ATOMIC_ADDREF(p, i) js_AtomicAdd(p,i)
#define CurrentThreadId() (jsword)PR_GetCurrentThread()
#define JS_CurrentThreadId() js_CurrentThreadId()
#define CurrentThreadId() (jsword)PR_GetCurrentThread()
#define JS_CurrentThreadId() js_CurrentThreadId()
#define JS_NEW_LOCK() PR_NewLock()
#define JS_DESTROY_LOCK(l) PR_DestroyLock(l)
#define JS_ACQUIRE_LOCK(l) PR_Lock(l)

Просмотреть файл

@ -108,11 +108,11 @@ static JSPropertySpec object_props[] = {
static JSBool
obj_getSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
jsint slot;
uint32 slot;
JSAccessMode mode;
uintN attrs;
slot = JSVAL_TO_INT(id);
slot = (uint32) JSVAL_TO_INT(id);
if (id == INT_TO_JSVAL(JSSLOT_PROTO)) {
id = (jsid)cx->runtime->atomState.protoAtom;
mode = JSACC_PROTO;
@ -130,12 +130,12 @@ JS_STATIC_DLL_CALLBACK(JSBool)
obj_setSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
JSObject *obj2;
jsint slot;
uint32 slot;
if (!JSVAL_IS_OBJECT(*vp))
return JS_TRUE;
obj2 = JSVAL_TO_OBJECT(*vp);
slot = JSVAL_TO_INT(id);
slot = (uint32) JSVAL_TO_INT(id);
while (obj2) {
if (obj2 == obj) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
@ -426,7 +426,7 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
/* If id is a non-identifier string, it needs to be quoted. */
if (JSVAL_IS_STRING(id) && !js_IsIdentifier(idstr)) {
idstr = js_QuoteString(cx, idstr, '\'');
idstr = js_QuoteString(cx, idstr, (jschar)'\'');
if (!idstr) {
ok = JS_FALSE;
goto error;
@ -1724,7 +1724,7 @@ js_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
uintN protoattrs;
JSClass *clasp;
jsval pval;
jsint slot;
uint32 slot;
JSString *str;
rt = cx->runtime;
@ -1750,7 +1750,7 @@ js_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
sprop = sym_property(sym);
#if JS_HAS_OBJ_WATCHPOINT
if (!sprop) {
uint32 slot, nslots;
uint32 nslots;
jsval *slots;
/*
@ -2644,7 +2644,7 @@ void printObj(JSObject *jsobj) {
}
void printVal(jsval val) {
fprintf(stderr, "val %d (0x%p) = ", val, (void *)val);
fprintf(stderr, "val %d (0x%p) = ", (int)val, (void *)val);
if (JSVAL_IS_NULL(val)) {
fprintf(stderr, "null\n");
} else if (JSVAL_IS_VOID(val)) {
@ -2666,7 +2666,7 @@ void printVal(jsval val) {
}
void printId(jsid id) {
fprintf(stderr, "id %d (0x%p) is ", id, (void *)id);
fprintf(stderr, "id %d (0x%p) is ", (int)id, (void *)id);
printVal(js_IdToValue(id));
}

Просмотреть файл

@ -665,7 +665,7 @@ DecompileSwitch(SprintStack *ss, TableEntry *table, uintN tableLength,
return JS_FALSE;
jp->indent += 2;
if (JSVAL_IS_STRING(key)) {
rval = QuoteString(&ss->sprinter, str, '"');
rval = QuoteString(&ss->sprinter, str, (jschar)'"');
if (!rval)
return JS_FALSE;
} else {
@ -1619,7 +1619,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
todo = Sprint(&ss->sprinter, buf);
} else if (JSVAL_IS_STRING(key)) {
rval = QuoteString(&ss->sprinter, ATOM_TO_STRING(atom),
'"');
(jschar)'"');
if (!rval)
return JS_FALSE;
todo = Sprint(&ss->sprinter, "%s", rval);

Просмотреть файл

@ -88,7 +88,7 @@ typedef enum JSOp {
#define ARGC_HI(argc) ((jsbytecode)((argc) >> 8))
#define ARGC_LO(argc) ((jsbytecode)(argc))
#define GET_ARGC(pc) (((pc)[1] << 8) | (pc)[2])
#define GET_ARGC(pc) ((uintN)(((pc)[1] << 8) | (pc)[2]))
#define ARGC_LIMIT ((uint32)1 << 16)
/* Synonyms for quick JOF_QARG and JOF_QVAR bytecodes. */

Просмотреть файл

@ -117,7 +117,7 @@ static int fill2(SprintfState *ss, const char *src, int srclen, int width,
}
/* Copy out the source data */
rv = (*ss->stuff)(ss, src, srclen);
rv = (*ss->stuff)(ss, src, (JSUint32)srclen);
if (rv < 0) {
return rv;
}
@ -211,7 +211,7 @@ static int fill_n(SprintfState *ss, const char *src, int srclen, int width,
return rv;
}
}
rv = (*ss->stuff)(ss, src, srclen);
rv = (*ss->stuff)(ss, src, (JSUint32)srclen);
if (rv < 0) {
return rv;
}
@ -326,7 +326,7 @@ static int cvt_f(SprintfState *ss, double d, const char *fmt0, const char *fmt1)
/* Totally bogus % command to sprintf. Just ignore it */
return 0;
}
memcpy(fin, fmt0, amount);
memcpy(fin, fmt0, (size_t)amount);
fin[amount] = 0;
/* Convert floating point using the native sprintf code */
@ -906,7 +906,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap)
i = fmt - dolPt;
if( i < sizeof( pattern ) ){
pattern[0] = '%';
memcpy( &pattern[1], dolPt, i );
memcpy( &pattern[1], dolPt, (size_t)i );
rv = cvt_f(ss, u.d, pattern, &pattern[i+1] );
}
} else