本文整理汇总了C++中Tcl_GetIndexFromObj函数的典型用法代码示例。如果您正苦于以下问题:C++ Tcl_GetIndexFromObj函数的具体用法?C++ Tcl_GetIndexFromObj怎么用?C++ Tcl_GetIndexFromObj使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Tcl_GetIndexFromObj函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestExceptionCmd
static int
TestExceptionCmd(
ClientData dummy, /* Unused */
Tcl_Interp* interp, /* Tcl interpreter */
int objc, /* Argument count */
Tcl_Obj *const objv[]) /* Argument vector */
{
static const char *cmds[] = {
"access_violation", "datatype_misalignment", "array_bounds",
"float_denormal", "float_divbyzero", "float_inexact",
"float_invalidop", "float_overflow", "float_stack", "float_underflow",
"int_divbyzero", "int_overflow", "private_instruction", "inpageerror",
"illegal_instruction", "noncontinue", "stack_overflow",
"invalid_disp", "guard_page", "invalid_handle", "ctrl+c",
NULL
};
static const DWORD exceptions[] = {
EXCEPTION_ACCESS_VIOLATION, EXCEPTION_DATATYPE_MISALIGNMENT,
EXCEPTION_ARRAY_BOUNDS_EXCEEDED, EXCEPTION_FLT_DENORMAL_OPERAND,
EXCEPTION_FLT_DIVIDE_BY_ZERO, EXCEPTION_FLT_INEXACT_RESULT,
EXCEPTION_FLT_INVALID_OPERATION, EXCEPTION_FLT_OVERFLOW,
EXCEPTION_FLT_STACK_CHECK, EXCEPTION_FLT_UNDERFLOW,
EXCEPTION_INT_DIVIDE_BY_ZERO, EXCEPTION_INT_OVERFLOW,
EXCEPTION_PRIV_INSTRUCTION, EXCEPTION_IN_PAGE_ERROR,
EXCEPTION_ILLEGAL_INSTRUCTION, EXCEPTION_NONCONTINUABLE_EXCEPTION,
EXCEPTION_STACK_OVERFLOW, EXCEPTION_INVALID_DISPOSITION,
EXCEPTION_GUARD_PAGE, EXCEPTION_INVALID_HANDLE, CONTROL_C_EXIT
};
int cmd;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 0, objv, "<type-of-exception>");
return TCL_ERROR;
}
if (Tcl_GetIndexFromObj(interp, objv[1], cmds, "command", 0,
&cmd) != TCL_OK) {
return TCL_ERROR;
}
/*
* Make sure the GPF dialog doesn't popup.
*/
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
/*
* As Tcl does not handle structured exceptions, this falls all the way
* back up the instruction stack to the C run-time portion that called
* main() where the process will now be terminated with this exception
* code by the default handler the C run-time provides.
*/
/* SMASH! */
RaiseException(exceptions[cmd], EXCEPTION_NONCONTINUABLE, 0, NULL);
/* NOTREACHED */
return TCL_OK;
}
示例2: ctable_parseQuoteType
//
// Convert a type name to a quote type
//
CTABLE_INTERNAL int ctable_parseQuoteType(Tcl_Interp *interp, Tcl_Obj *obj)
{
int index;
if (Tcl_GetIndexFromObj (interp, obj, ctable_quote_names, "type", TCL_EXACT, &index) != TCL_OK)
return -1;
else
return ctable_quote_types[index];
}
示例3: Tk_GetReliefFromObj
int
Tk_GetReliefFromObj(
Tcl_Interp *interp, /* Used for error reporting. */
Tcl_Obj *objPtr, /* The object we are trying to get the value
* from. */
int *resultPtr) /* Where to place the answer. */
{
return Tcl_GetIndexFromObj(interp, objPtr, reliefStrings, "relief", 0,
resultPtr);
}
示例4: menuBarFunc
static int menuBarFunc( ClientData data, Tcl_Interp *interp,
int objc, Tcl_Obj * const objv[] )
{
static const char *cmds[] = { "delete", "configure",
"add", "addBegin", "addEnd", NULL };
enum cmdIdx { DeleteIdx, ConfigureIdx, AddIdx, BeginIdx, EndIdx };
GtkMenuBar *menuBar = GTK_MENU_BAR( data );
int idx;
if( objc < 2 )
{
Tcl_WrongNumArgs( interp, 1, objv, "command" );
return TCL_ERROR;
}
if( Tcl_GetIndexFromObj( interp, objv[1], cmds, "command",
TCL_EXACT, &idx ) != TCL_OK )
return TCL_ERROR;
switch( idx )
{
case DeleteIdx:
return gnoclDelete( interp, GTK_WIDGET( menuBar ), objc, objv );
case ConfigureIdx:
{
int ret = TCL_ERROR;
if( gnoclParseAndSetOptions( interp, objc - 1, objv + 1,
menuBarOptions, G_OBJECT( menuBar ) ) == TCL_OK )
{
ret = configure( interp, menuBar, menuBarOptions );
}
gnoclClearOptions( menuBarOptions );
return ret;
}
break;
case AddIdx:
case BeginIdx:
case EndIdx:
{
if( objc != 3 )
{
Tcl_WrongNumArgs( interp, 2, objv, "widget-list" );
return TCL_ERROR;
}
return gnoclMenuShellAddChildren( interp,
GTK_MENU_SHELL( menuBar ), objv[2], idx != EndIdx );
}
}
return TCL_OK;
}
示例5: Tcl_SeekObjCmd
/* ARGSUSED */
int
Tcl_SeekObjCmd(
ClientData clientData, /* Not used. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Channel chan; /* The channel to tell on. */
Tcl_WideInt offset; /* Where to seek? */
int mode; /* How to seek? */
Tcl_WideInt result; /* Of calling Tcl_Seek. */
int optionIndex;
static const char *originOptions[] = {
"start", "current", "end", NULL
};
static int modeArray[] = {SEEK_SET, SEEK_CUR, SEEK_END};
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 1, objv, "channelId offset ?origin?");
return TCL_ERROR;
}
if (TclGetChannelFromObj(interp, objv[1], &chan, NULL, 0) != TCL_OK) {
return TCL_ERROR;
}
if (Tcl_GetWideIntFromObj(interp, objv[2], &offset) != TCL_OK) {
return TCL_ERROR;
}
mode = SEEK_SET;
if (objc == 4) {
if (Tcl_GetIndexFromObj(interp, objv[3], originOptions, "origin", 0,
&optionIndex) != TCL_OK) {
return TCL_ERROR;
}
mode = modeArray[optionIndex];
}
result = Tcl_Seek(chan, offset, mode);
if (result == Tcl_LongAsWide(-1)) {
/*
* TIP #219.
* Capture error messages put by the driver into the bypass area and
* put them into the regular interpreter result. Fall back to the
* regular message if nothing was found in the bypass.
*/
if (!TclChanCaughtErrorBypass(interp, chan)) {
Tcl_AppendResult(interp, "error during seek on \"",
TclGetString(objv[1]), "\": ",
Tcl_PosixError(interp), NULL);
}
return TCL_ERROR;
}
return TCL_OK;
}
示例6: PanedIdentifyCommand
/* $pw identify ?what? $x $y --
* Return index of sash at $x,$y
*/
static int PanedIdentifyCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
const char *whatTable[] = { "element", "sash", NULL };
enum { IDENTIFY_ELEMENT, IDENTIFY_SASH };
int what = IDENTIFY_SASH;
Paned *pw = recordPtr;
int sashThickness = pw->paned.sashThickness;
int nSashes = Ttk_NumberSlaves(pw->paned.mgr) - 1;
int x, y, pos;
int index;
if (objc < 4 || objc > 5) {
Tcl_WrongNumArgs(interp, 2,objv, "?what? x y");
return TCL_ERROR;
}
if ( Tcl_GetIntFromObj(interp, objv[objc-2], &x) != TCL_OK
|| Tcl_GetIntFromObj(interp, objv[objc-1], &y) != TCL_OK
|| (objc == 5 &&
Tcl_GetIndexFromObj(interp, objv[2], whatTable, "option", 0, &what)
!= TCL_OK)
) {
return TCL_ERROR;
}
pos = pw->paned.orient == TTK_ORIENT_HORIZONTAL ? x : y;
for (index = 0; index < nSashes; ++index) {
Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
if (pane->sashPos <= pos && pos <= pane->sashPos + sashThickness) {
/* Found it. */
switch (what) {
case IDENTIFY_SASH:
Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
return TCL_OK;
case IDENTIFY_ELEMENT:
{
Ttk_Element element =
Ttk_IdentifyElement(SashLayout(pw, index), x, y);
if (element) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj(Ttk_ElementName(element), -1));
}
return TCL_OK;
}
}
}
}
return TCL_OK; /* nothing found - return empty string */
}
示例7: AsmInstructionArgvSet
/*
*----------------------------------------------------------------------
* AsmInstructionArgvSet --
*
* Set argument to be passed to an instruction of the assemble
* code.
*
*----------------------------------------------------------------------
*/
static void
AsmInstructionArgvSet(Tcl_Interp *interp, int from, int to, int currentArg,
AsmInstruction *inst, AsmCompiledProc *asmProc,
Tcl_Obj **wordOv, int verbose) {
int j;
for (j = from; j < to; j += 2, currentArg++) {
int argIndex, intValue;
Tcl_GetIndexFromObj(interp, wordOv[j], asmStatementArgType, "asm cmd arg type", 0, &argIndex);
Tcl_GetIntFromObj(interp, wordOv[j+1], &intValue);
if (verbose != 0) {
fprintf(stderr, "AsmInstructionArgvSet (type %d) arg[%d] := %s[%s]\n",
argIndex, currentArg, ObjStr(wordOv[j]), ObjStr(wordOv[j+1]));
}
switch (argIndex) {
case asmStatementArgTypeObjIdx:
inst->argv[currentArg] = asmProc->slots[intValue];
break;
case asmStatementArgTypeArgIdx:
AsmArgSet(asmProc, intValue, &inst->argv[currentArg]);
break;
case asmStatementArgTypeResultIdx:
inst->argv[currentArg] = NULL;
break;
case asmStatementArgTypeSlotIdx:
case asmStatementArgTypeInstructionIdx:
case asmStatementArgTypeIntIdx:
inst->argv[currentArg] = INT2PTR(intValue);
break;
case asmStatementArgTypeVarIdx:
fprintf(stderr, ".... var set [%d] = %s\n", currentArg, ObjStr(wordOv[j+1]));
inst->argv[currentArg] = wordOv[j+1];
Tcl_IncrRefCount(inst->argv[currentArg]); // TODO: DECR missing
break;
}
/*fprintf(stderr, "[%d] inst %p name %s arg[%d] %s\n", currentAsmInstruction,
inst, ObjStr(inst->argv[0]), currentArg,
inst->argv[currentArg] ? ObjStr(inst->argv[currentArg]) : "NULL");*/
}
}
示例8: InstanceCmd
/* Object command for a PV object */
static int InstanceCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[]) {
pvInfo *info = (pvInfo *) clientData;
if (objc<2) {
Tcl_WrongNumArgs(interp, 1, objv, "subcommand");
return TCL_ERROR;
}
Tcl_Obj *subcommand=objv[1];
int cmdindex;
if (Tcl_GetIndexFromObj(interp, subcommand, pvcmdtable, "subcommand", 0, &cmdindex) != TCL_OK) {
return TCL_ERROR;
}
switch (cmdindex) {
case PUT:
return PutCmd(interp, info, objc, objv);
case GET:
return GetCmd(interp, info, objc, objv);
case MONITOR:
return MonitorCmd(interp, info, objc, objv);
case NAME:
Tcl_SetObjResult(interp, Tcl_NewStringObj(info->name, -1));
return TCL_OK;
case CONNECTED:
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(info->connected));
return TCL_OK;
case NELEM:
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(info->nElem));
return TCL_OK;
case CHID:
Tcl_SetObjResult(interp, Tcl_NewWideIntObj((intptr_t)info->id));
return TCL_OK;
case TYPE:
Tcl_SetObjResult(interp, Tcl_NewStringObj(dbr_type_to_text(info->type), -1));
return TCL_OK;
case DESTROY: {
Tcl_Command self = Tcl_GetCommandFromObj(interp, objv[0]);
if (self != NULL) {
Tcl_DeleteCommandFromToken(interp, self);
}
return TCL_OK;
}
default:
Tcl_SetObjResult(interp, Tcl_NewStringObj("Unknown error", -1));
return TCL_ERROR;
}
}
示例9: NS
/** \brief create the <B>msgque support</B> subcommand
*
* \tclmsgque_man
*
* \param[in] interp current Tcl interpreter
* \param[in] objc number of objects in \e objv
* \param[in] objv array of \e Tcl_Obj objects
* \return Tcl error-code
*/
static int NS(Support) (
Tcl_Interp * interp,
int objc,
struct Tcl_Obj *const *objv
)
{
int index;
Tcl_Obj *Obj = NULL;
static const char *constant[] = {
"thread", "fork", NULL
};
enum constants {
THREAD, FORK,
};
// read the index
if (objc != 3) {
Tcl_WrongNumArgs (interp, 2, objv, "configuration");
return TCL_ERROR;
}
// get the Index
TclErrorCheck (Tcl_GetIndexFromObj (interp, objv[2], constant, "configuration", 0, &index));
// do the work
switch ((enum constants) index) {
case THREAD:
#if defined(MQ_HAS_THREAD)
Obj = Tcl_NewBooleanObj (1);
#else
Obj = Tcl_NewBooleanObj (0);
#endif
break;
case FORK:
#if defined(HAVE_FORK)
Obj = Tcl_NewBooleanObj (1);
#else
Obj = Tcl_NewBooleanObj (0);
#endif
break;
}
Tcl_SetObjResult (interp, Obj);
return TCL_OK;
}
示例10: Tk_GetAnchorFromObj
int
Tk_GetAnchorFromObj(
Tcl_Interp *interp, /* Used for error reporting. */
Tcl_Obj *objPtr, /* The object we are trying to get the value
* from. */
Tk_Anchor *anchorPtr) /* Where to place the Tk_Anchor that
* corresponds to the string value of
* objPtr. */
{
int index, code;
code = Tcl_GetIndexFromObj(interp, objPtr, anchorStrings, "anchor", 0,
&index);
if (code == TCL_OK) {
*anchorPtr = (Tk_Anchor) index;
}
return code;
}
示例11: Tk_GetJustifyFromObj
int
Tk_GetJustifyFromObj(
Tcl_Interp *interp, /* Used for error reporting. */
Tcl_Obj *objPtr, /* The object we are trying to get the value
* from. */
Tk_Justify *justifyPtr) /* Where to place the Tk_Justify that
* corresponds to the string value of
* objPtr. */
{
int index, code;
code = Tcl_GetIndexFromObj(interp, objPtr, justifyStrings,
"justification", 0, &index);
if (code == TCL_OK) {
*justifyPtr = (Tk_Justify) index;
}
return code;
}
示例12: ChanPendingObjCmd
/* ARGSUSED */
static int
ChanPendingObjCmd(
ClientData unused, /* Not used. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_Channel chan;
int index, mode;
static const char *options[] = {"input", "output", NULL};
enum options {PENDING_INPUT, PENDING_OUTPUT};
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "mode channelId");
return TCL_ERROR;
}
if (Tcl_GetIndexFromObj(interp, objv[1], options, "mode", 0,
&index) != TCL_OK) {
return TCL_ERROR;
}
if (TclGetChannelFromObj(interp, objv[2], &chan, &mode, 0) != TCL_OK) {
return TCL_ERROR;
}
switch ((enum options) index) {
case PENDING_INPUT:
if ((mode & TCL_READABLE) == 0) {
Tcl_SetObjResult(interp, Tcl_NewIntObj(-1));
} else {
Tcl_SetObjResult(interp, Tcl_NewIntObj(Tcl_InputBuffered(chan)));
}
break;
case PENDING_OUTPUT:
if ((mode & TCL_WRITABLE) == 0) {
Tcl_SetObjResult(interp, Tcl_NewIntObj(-1));
} else {
Tcl_SetObjResult(interp, Tcl_NewIntObj(Tcl_OutputBuffered(chan)));
}
break;
}
return TCL_OK;
}
示例13: ImgBmapCmd
static int
ImgBmapCmd(
ClientData clientData, /* Information about the image master. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
static const char *const bmapOptions[] = {"cget", "configure", NULL};
BitmapMaster *masterPtr = clientData;
int index;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
return TCL_ERROR;
}
if (Tcl_GetIndexFromObj(interp, objv[1], bmapOptions, "option", 0,
&index) != TCL_OK) {
return TCL_ERROR;
}
switch (index) {
case 0: /* cget */
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "option");
return TCL_ERROR;
}
return Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs,
(char *) masterPtr, Tcl_GetString(objv[2]), 0);
case 1: /* configure */
if (objc == 2) {
return Tk_ConfigureInfo(interp, Tk_MainWindow(interp),
configSpecs, (char *) masterPtr, NULL, 0);
} else if (objc == 3) {
return Tk_ConfigureInfo(interp, Tk_MainWindow(interp),
configSpecs, (char *) masterPtr,
Tcl_GetString(objv[2]), 0);
} else {
return ImgBmapConfigureMaster(masterPtr, objc-2, objv+2,
TK_CONFIG_ARGV_ONLY);
}
default:
Tcl_Panic("bad const entries to bmapOptions in ImgBmapCmd");
return TCL_OK;
}
}
示例14: gnoclSessionCmd
int gnoclSessionCmd( ClientData data, Tcl_Interp *interp,
int objc, Tcl_Obj * const objv[] )
{
static const char *cmd[] = { "configure", NULL };
enum optIdx { ConfigureIdx };
int idx;
static GnomeClient *client = NULL;
if( client == NULL )
client = gnome_master_client();
if( client == NULL )
{
Tcl_SetResult( interp, "Unable to initialize session.", TCL_STATIC );
return TCL_ERROR;
}
if( objc < 2 )
{
Tcl_WrongNumArgs( interp, 1, objv, "command" );
return TCL_ERROR;
}
if( Tcl_GetIndexFromObj( interp, objv[1], cmd, "command", TCL_EXACT,
&idx ) != TCL_OK )
return TCL_ERROR;
switch( idx )
{
case ConfigureIdx:
{
int ret = TCL_ERROR;
if( gnoclParseAndSetOptions( interp, objc - 1, objv + 1,
sessionOptions, G_OBJECT( client ) ) == TCL_OK )
{
ret = configure( interp, client, sessionOptions );
}
gnoclClearOptions( sessionOptions );
return ret;
}
break;
}
return TCL_OK;
}
示例15: command
static int command( Tcl_Interp *interp, int objc, Tcl_Obj * const objv[],
Gnocl_CanvasItemInfo *info )
{
const char *cmds[] = { "appendCoords", NULL };
enum cmdIdx { AppendCoordsIdx };
int idx;
/* canvas itemCommand tag cmd ?-option value? */
if( Tcl_GetIndexFromObj( interp, objv[3], cmds, "command",
TCL_EXACT, &idx ) != TCL_OK )
return TCL_ERROR;
switch( idx )
{
case AppendCoordsIdx:
{
GnomeCanvasPathDef *path;
if( objc != 5 )
{
Tcl_WrongNumArgs( interp, 4, objv, "coords-list" );
return TCL_ERROR;
}
g_object_get( G_OBJECT( info->item), "bpath", &path, NULL );
if( gnoclCanvasAppendPath( interp, objv[4], 0, path )
!= TCL_OK )
return TCL_ERROR;
g_object_set( G_OBJECT( info->item), "bpath", path, NULL );
}
break;
default:
assert( 0 );
return TCL_ERROR;
}
return TCL_OK;
}