Diff
Not logged in

Differences From Artifact [906e02115a]:

To Artifact [662213145a]:


1204
1205
1206
1207
1208
1209
1210
1211

1212
1213
1214


1215
1216
1217


1218
1219
1220
1221
1222




1223
1224
1225
1226
1227
1228
1229
1230




1231
1232
1233
1234

1235

1236







1237

1238
1239
1240














1241
1242
1243
1244
1245
1246
1247

1248
1249
1250
1251
1252
1253
1254






1255
1256
1257
1258
1259
1260





1261
1262
1263
1264
1265




1266
1267
1268
1269
1270
1271
1272






1273
1274
1275
1276
1277
1278

1279
1280
1281
1282
1283
1284
1285






1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296










1297
1298
1299
1300
1301




1302
1303
1304

1305
1306
1307
1308
1309
1310
1311
1204
1205
1206
1207
1208
1209
1210

1211
1212


1213
1214
1215


1216
1217

1218



1219
1220
1221
1222
1223
1224
1225
1226




1227
1228
1229
1230
1231
1232
1233
1234
1235

1236
1237
1238
1239
1240
1241
1242
1243
1244

1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268

1269
1270






1271
1272
1273
1274
1275
1276
1277





1278
1279
1280
1281
1282





1283
1284
1285
1286
1287






1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298

1299
1300






1301
1302
1303
1304
1305
1306
1307










1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318




1319
1320
1321
1322

1323

1324
1325
1326
1327
1328
1329
1330
1331







-
+

-
-
+
+

-
-
+
+
-

-
-
-
+
+
+
+




-
-
-
-
+
+
+
+




+
-
+

+
+
+
+
+
+
+
-
+



+
+
+
+
+
+
+
+
+
+
+
+
+
+






-
+

-
-
-
-
-
-
+
+
+
+
+
+

-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+

-
-
-
-
-
-
+
+
+
+
+
+





-
+

-
-
-
-
-
-
+
+
+
+
+
+

-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+

-
-
-
-
+
+
+
+
-

-
+







// TODO: Check whether Tcl_AppendLimitedToObj() can work here.

#define LIMIT 60
#define ELLIPSIFY(str,len) \
	((len) > LIMIT ? LIMIT : (int)(len)), (str), ((len) > LIMIT ? "..." : "")

static void
MethodErrorHandler(
CommonMethErrorHandler(
    Tcl_Interp *interp,
    TCL_UNUSED(Tcl_Obj *) /*methodNameObj*/)
	// We pull the method name out of context instead of from argument
    const char *special)

{
    Tcl_Size nameLen, objectNameLen;
    CallContext *contextPtr = (CallContext *)
    Tcl_Size objectNameLen;
    CallContext *contextPtr = (CallContext *)((Interp *) interp)->varFramePtr->clientData;
	    ((Interp *) interp)->varFramePtr->clientData;
    Method *mPtr = contextPtr->callPtr->chain[contextPtr->index].mPtr;
    const char *objectName, *kindName, *methodName =
	    Tcl_GetStringFromObj(mPtr->namePtr, &nameLen);
    Object *declarerPtr;
    const char *objectName, *kindName = "instance";

    Object *declarerPtr = NULL;


    if (mPtr->declaringObjectPtr != NULL) {
	declarerPtr = mPtr->declaringObjectPtr;
	kindName = "object";
    } else {
	if (mPtr->declaringClassPtr == NULL) {
	    Tcl_Panic("method not declared in class or object");
	}

    } else if (mPtr->declaringClassPtr != NULL) {


	declarerPtr = mPtr->declaringClassPtr->thisPtr;
	kindName = "class";
    }

    if (declarerPtr) {
    objectName = Tcl_GetStringFromObj(TclOOObjectName(interp, declarerPtr),
	objectName = TclGetStringFromObj(TclOOObjectName(interp, declarerPtr),
	    &objectNameLen);
    } else {
	objectName = "unknown or deleted";
	objectNameLen = 18;
    }
    if (!special) {
	Tcl_Size nameLen;
	const char *methodName = TclGetStringFromObj(mPtr->namePtr, &nameLen);
    Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
	Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
	    "\n    (%s \"%.*s%s\" method \"%.*s%s\" line %d)",
	    kindName, ELLIPSIFY(objectName, objectNameLen),
	    ELLIPSIFY(methodName, nameLen), Tcl_GetErrorLine(interp)));
    } else {
	Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
	    "\n    (%s \"%.*s%s\" %s line %d)", kindName,
	    ELLIPSIFY(objectName, objectNameLen), special, Tcl_GetErrorLine(interp)));
    }
}

static void
MethodErrorHandler(
    Tcl_Interp *interp,
    TCL_UNUSED(Tcl_Obj *) /*methodNameObj*/)
	/* We pull the method name out of context instead of from argument */
{
    CommonMethErrorHandler(interp, NULL);
}

static void
ConstructorErrorHandler(
    Tcl_Interp *interp,
    TCL_UNUSED(Tcl_Obj *) /*methodNameObj*/)
	// Ignore. We know it is the constructor.
	/* Ignore. We know it is the constructor. */
{
    CallContext *contextPtr = (CallContext *)
	    ((Interp *) interp)->varFramePtr->clientData;
    Method *mPtr = contextPtr->callPtr->chain[contextPtr->index].mPtr;
    Object *declarerPtr;
    const char *objectName, *kindName;
    Tcl_Size objectNameLen;





    CommonMethErrorHandler(interp, "constructor");

    if (mPtr->declaringObjectPtr != NULL) {
	declarerPtr = mPtr->declaringObjectPtr;
	kindName = "object";
    } else {
	if (mPtr->declaringClassPtr == NULL) {





	    Tcl_Panic("method not declared in class or object");
	}
	declarerPtr = mPtr->declaringClassPtr->thisPtr;
	kindName = "class";
    }
}




    objectName = Tcl_GetStringFromObj(TclOOObjectName(interp, declarerPtr),
	    &objectNameLen);
    Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
	    "\n    (%s \"%.*s%s\" constructor line %d)", kindName,
	    ELLIPSIFY(objectName, objectNameLen), Tcl_GetErrorLine(interp)));
}







static void
DestructorErrorHandler(
    Tcl_Interp *interp,
    TCL_UNUSED(Tcl_Obj *) /*methodNameObj*/)
	// Ignore. We know it is the destructor.
	/* Ignore. We know it is the destructor. */
{
    CallContext *contextPtr = (CallContext *)
	    ((Interp *) interp)->varFramePtr->clientData;
    Method *mPtr = contextPtr->callPtr->chain[contextPtr->index].mPtr;
    Object *declarerPtr;
    const char *objectName, *kindName;
    Tcl_Size objectNameLen;





    CommonMethErrorHandler(interp, "destructor");

    if (mPtr->declaringObjectPtr != NULL) {
	declarerPtr = mPtr->declaringObjectPtr;
	kindName = "object";
    } else {
	if (mPtr->declaringClassPtr == NULL) {
	    Tcl_Panic("method not declared in class or object");
	}
	declarerPtr = mPtr->declaringClassPtr->thisPtr;
	kindName = "class";
    }











    objectName = Tcl_GetStringFromObj(TclOOObjectName(interp, declarerPtr),
	    &objectNameLen);
    Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
	    "\n    (%s \"%.*s%s\" destructor line %d)", kindName,




	    ELLIPSIFY(objectName, objectNameLen), Tcl_GetErrorLine(interp)));
}


/*
 * ----------------------------------------------------------------------
 *
 * DeleteProcedureMethod, CloneProcedureMethod --
 *
 *	How to delete and clone procedure-like methods.
 *