当前位置: 首页>>代码示例>>C++>>正文


C++ Tcl_GetStringFromObj函数代码示例

本文整理汇总了C++中Tcl_GetStringFromObj函数的典型用法代码示例。如果您正苦于以下问题:C++ Tcl_GetStringFromObj函数的具体用法?C++ Tcl_GetStringFromObj怎么用?C++ Tcl_GetStringFromObj使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Tcl_GetStringFromObj函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Tcl_GetStringFromObj

c4_View MkView::View(Tcl_Interp *interp, Tcl_Obj *obj) {
  const char *name = Tcl_GetStringFromObj(obj, 0);
  Tcl_CmdInfo ci;

  if (!Tcl_GetCommandInfo(interp, (char*)name, &ci) || ci.objProc != MkView
    ::Dispatcher) {
    //Fail("no such view");
    c4_View temp;
    return temp;
  } else {
    MkView *v = (MkView*)ci.objClientData;
    return v->view;
  }
}
开发者ID:electric-cloud,项目名称:metakit,代码行数:14,代码来源:mk4too.cpp

示例2: TclpInitLibraryPath

void
TclpInitLibraryPath(
    char **valuePtr,
    int *lengthPtr,
    Tcl_Encoding *encodingPtr)
{
#define LIBRARY_SIZE	    64
    Tcl_Obj *pathPtr;
    char installLib[LIBRARY_SIZE];
    char *bytes;

    pathPtr = Tcl_NewObj();

    /*
     * Initialize the substring used when locating the script library. The
     * installLib variable computes the script library path relative to the
     * installed DLL.
     */

    sprintf(installLib, "lib/tcl%s", TCL_VERSION);

    /*
     * Look for the library relative to the TCL_LIBRARY env variable. If the
     * last dirname in the TCL_LIBRARY path does not match the last dirname in
     * the installLib variable, use the last dir name of installLib in
     * addition to the orginal TCL_LIBRARY path.
     */

    AppendEnvironment(pathPtr, installLib);

    /*
     * Look for the library in its default location.
     */

    Tcl_ListObjAppendElement(NULL, pathPtr,
	    TclGetProcessGlobalValue(&defaultLibraryDir));

    /*
     * Look for the library in its source checkout location.
     */

    Tcl_ListObjAppendElement(NULL, pathPtr,
	    TclGetProcessGlobalValue(&sourceLibraryDir));

    *encodingPtr = NULL;
    bytes = Tcl_GetStringFromObj(pathPtr, lengthPtr);
    *valuePtr = ckalloc((unsigned int)(*lengthPtr)+1);
    memcpy(*valuePtr, bytes, (size_t)(*lengthPtr)+1);
    Tcl_DecrRefCount(pathPtr);
}
开发者ID:Brucegx,项目名称:Appstore719,代码行数:50,代码来源:tclWinInit.c

示例3: ObjToSqliteContextValue

void ObjToSqliteContextValue(Tcl_Obj *objP, sqlite3_context *sqlctxP)
{
    unsigned char *data;
    int len;
    if (objP->typePtr) {
        /*
         * Note there is no return code checking here. Once the typePtr
         * is checked, the corresponding Tcl_Get* function should
         * always succeed.
         */

        if (objP->typePtr == gTclStringTypeP) {
            /*
             * Do nothing, fall thru below to handle as default type.
             * This check is here just so the most common case of text
             * columns does not needlessly go through other type checks.
             */
        } else if (objP->typePtr == gTclIntTypeP) {
            int ival;
            Tcl_GetIntFromObj(NULL, objP, &ival);
            sqlite3_result_int(sqlctxP, ival);
            return;
        } else if (objP->typePtr == gTclWideIntTypeP) {
            Tcl_WideInt i64val;
            Tcl_GetWideIntFromObj(NULL, objP, &i64val);
            sqlite3_result_int64(sqlctxP, i64val);
            return;
        } else if (objP->typePtr == gTclDoubleTypeP) {
            double dval;
            Tcl_GetDoubleFromObj(NULL, objP, &dval);
            sqlite3_result_double(sqlctxP, dval);
            return;
        } else if (objP->typePtr == gTclBooleanTypeP ||
                   objP->typePtr == gTclBooleanStringTypeP) {
            int bval;
            Tcl_GetBooleanFromObj(NULL, objP, &bval);
            sqlite3_result_int(sqlctxP, bval);
            return;
        } else if (objP->typePtr == gTclByteArrayTypeP) {
            /* TBD */
            data = Tcl_GetByteArrayFromObj(objP, &len);
            sqlite3_result_blob(sqlctxP, data, len, SQLITE_TRANSIENT);
            return;
        }
    }

    /* Handle everything else as text by default */
    data = (unsigned char *)Tcl_GetStringFromObj(objP, &len);
    sqlite3_result_text(sqlctxP, data, len, SQLITE_TRANSIENT);
}
开发者ID:digsrc,项目名称:windowstoolset,代码行数:50,代码来源:vtables.c

示例4: TSP_Util_lang_convert_string_var

/* convert to a string from a var */
Tcl_DString*
TSP_Util_lang_convert_string_var(Tcl_DString* targetVarName, Tcl_Obj* sourceVarName) {
    char* str;
    int len;
    if (targetVarName != NULL) {
        Tcl_DStringSetLength(targetVarName, 0);
    } else {
        targetVarName = (Tcl_DString*) ckalloc(sizeof(Tcl_DString));;
        Tcl_DStringInit(targetVarName);
    }
    str = Tcl_GetStringFromObj(sourceVarName, &len);
    Tcl_DStringAppend(targetVarName, str, len);
    return targetVarName;
}
开发者ID:bovine,项目名称:tsp,代码行数:15,代码来源:TSP_util.c

示例5: TclVerifyLocalLiteralTable

void
TclVerifyLocalLiteralTable(
    CompileEnv *envPtr)		/* Points to CompileEnv whose literal table is
				 * to be validated. */
{
    register LiteralTable *localTablePtr = &(envPtr->localLitTable);
    register LiteralEntry *localPtr;
    char *bytes;
    register int i;
    int length, count;

    count = 0;
    for (i=0 ; i<localTablePtr->numBuckets ; i++) {
	for (localPtr=localTablePtr->buckets[i] ; localPtr!=NULL;
		localPtr=localPtr->nextPtr) {
	    count++;
	    if (localPtr->refCount != -1) {
		bytes = Tcl_GetStringFromObj(localPtr->objPtr, &length);
		Tcl_Panic("TclVerifyLocalLiteralTable: local literal \"%.*s\" had bad refCount %d",
			(length>60? 60 : length), bytes, localPtr->refCount);
	    }
	    if (TclLookupLiteralEntry((Tcl_Interp *) envPtr->iPtr,
		    localPtr->objPtr) == NULL) {
		bytes = Tcl_GetStringFromObj(localPtr->objPtr, &length);
		Tcl_Panic("TclVerifyLocalLiteralTable: local literal \"%.*s\" is not global",
			(length>60? 60 : length), bytes);
	    }
	    if (localPtr->objPtr->bytes == NULL) {
		Tcl_Panic("TclVerifyLocalLiteralTable: literal has NULL string rep");
	    }
	}
    }
    if (count != localTablePtr->numEntries) {
	Tcl_Panic("TclVerifyLocalLiteralTable: local literal table had %d entries, should be %d",
		count, localTablePtr->numEntries);
    }
}
开发者ID:aosm,项目名称:tcl,代码行数:37,代码来源:tclLiteral.c

示例6: remove_region_attrs

void
remove_region_attrs(Tcl_Obj *obj)
{
    int len = 0;
    Tcl_Obj **objs;
    char *key;
    int i, j;
    int found_material = 0;

    if (Tcl_ListObjGetElements(INTERP, obj, &len, &objs) != TCL_OK) {
	fprintf(stderr, "Cannot get length of attributes for %s\n",
		Tcl_GetStringFromObj(obj, NULL));
	bu_exit(1, NULL);
    }

    if (len == 0)
	return;

    for (i=len-1; i>0; i -= 2) {

	key = Tcl_GetStringFromObj(objs[i-1], NULL);
	j = 0;
	while (region_attrs[j]) {
	    if (BU_STR_EQUAL(key, region_attrs[j])) {
		Tcl_ListObjReplace(INTERP, obj, i-1, 2, 0, NULL);
		break;
	    }
	    j++;
	}
	if (!found_material && BU_STR_EQUAL(key, "material")) {
	    found_material = 1;
	    if (!bu_strncmp(Tcl_GetStringFromObj(objs[i], NULL), "gift", 4)) {
		Tcl_ListObjReplace(INTERP, obj, i-1, 2, 0, NULL);
	    }
	}
    }
}
开发者ID:kanzure,项目名称:brlcad,代码行数:37,代码来源:gdiff.c

示例7: TclNativeCreateNativeRep

ClientData
TclNativeCreateNativeRep(
    Tcl_Obj *pathPtr)
{
    char *nativePathPtr;
    Tcl_DString ds;
    Tcl_Obj *validPathPtr;
    int len;
    char *str;

    if (TclFSCwdIsNative()) {
	/*
	 * The cwd is native, which means we can use the translated path
	 * without worrying about normalization (this will also usually be
	 * shorter so the utf-to-external conversion will be somewhat faster).
	 */

	validPathPtr = Tcl_FSGetTranslatedPath(NULL, pathPtr);
	if (validPathPtr == NULL) {
	    return NULL;
	}
    } else {
	/*
	 * Make sure the normalized path is set.
	 */

	validPathPtr = Tcl_FSGetNormalizedPath(NULL, pathPtr);
	if (validPathPtr == NULL) {
	    return NULL;
	}
	Tcl_IncrRefCount(validPathPtr);
    }

    str = Tcl_GetStringFromObj(validPathPtr, &len);
    Tcl_UtfToExternalDString(NULL, str, len, &ds);
    len = Tcl_DStringLength(&ds) + sizeof(char);
    if (strlen(Tcl_DStringValue(&ds)) < len - sizeof(char)) {
	/* See bug [3118489]: NUL in filenames */
	Tcl_DecrRefCount(validPathPtr);
	Tcl_DStringFree(&ds);
	return NULL;
    }
    Tcl_DecrRefCount(validPathPtr);
    nativePathPtr = ckalloc((unsigned) len);
    memcpy((void*)nativePathPtr, (void*)Tcl_DStringValue(&ds), (size_t) len);

    Tcl_DStringFree(&ds);
    return (ClientData)nativePathPtr;
}
开发者ID:Starlink,项目名称:tcl,代码行数:49,代码来源:tclUnixFile.c

示例8: TclSwitchCompare

/*
 * TclSwitchCompare
 *
 *   Performs a partial string comparison for a single switch. This behavior
 *   is consistent with Tcl commands that accept one switch argument, such
 *   as 'string match' and 'string map'.
 *
 * Arguments:
 *   objPtr     - The string value of this object is compared against "name".
 *   switchName - Full name of the switch.
 *
 * Returns:
 *   If "name" and the string value of "objPtr" match partially or completely,
 *   the return value is non-zero. If they do not match, the return value is zero.
 */
int
TclSwitchCompare(
    Tcl_Obj *objPtr,
    const char *switchName
    )
{
    int optionLength;
    char *option = Tcl_GetStringFromObj(objPtr, &optionLength);

    /*
     * The user supplied switch must be at least two characters in
     * length, to account for the switch prefix and first letter.
     */
    return (optionLength > 2 && strncmp(switchName, option, optionLength) == 0);
}
开发者ID:MalaGaM,项目名称:nxscripts,代码行数:30,代码来源:nxUtil.c

示例9: TnmGetPositiveFromObj

int
TnmGetPositiveFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *intPtr)
{
    int code;

    code = Tcl_GetIntFromObj(interp, objPtr, intPtr);
    if (code != TCL_OK || *intPtr < 1) {
	Tcl_ResetResult(interp);
	Tcl_AppendResult(interp, "expected positive integer but got \"",
			 Tcl_GetStringFromObj(objPtr, NULL), "\"",
			 (char *) NULL);
	return TCL_ERROR;
    }
    return TCL_OK;
}
开发者ID:flightaware,项目名称:scotty,代码行数:15,代码来源:tnmUtil.c

示例10: CloseLibraryResource

static void
CloseLibraryResource()
{
    if (ourResFile != kResFileNotOpened) {
#ifdef TCL_REGISTER_LIBRARY
        int length;
        TclMacUnRegisterResourceFork(
	        Tcl_GetStringFromObj(ourResToken, &length),
                NULL);
        Tcl_DecrRefCount(ourResToken);
#endif
	CloseResFile(ourResFile);
	ourResFile = kResFileNotOpened;
    }
}
开发者ID:AndresGG,项目名称:sn-8.4,代码行数:15,代码来源:tclMacLibrary.c

示例11: LiquidValidate_Command

static int LiquidValidate_Command(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
    // * Check the number of arguments
    if (objc != 3)
    {
        Tcl_WrongNumArgs(interp, 1, objv, "<templates> <root template>");
        return TCL_ERROR;
    }

    // Parse the data into a file system
    TclLiquid::FileSystem fileSystem(interp,
                                     objv[1]);

    // Get the template name
    const char* templateNameChars = Tcl_GetStringFromObj(objv[2], NULL);
    std::string templateName(templateNameChars);

    // Try to get the template source
    std::string templateSource;

    if (!fileSystem.TryFind(templateName,
                            templateSource))
        LiquidError(LiquidDataError, "Template not found in template list");

    // Try to parse the template
    Liquid::ParserError parserError;
    Liquid::RenderError renderError;
    Liquid::Strainer strainer;

    Liquid::Template* templ = Liquid::Template::Parse(templateSource,
                                                      strainer,
                                                      parserError);

    if (!templ)
    {
        // Set the error
        std::stringstream errorStream;
        errorStream << parserError;

        LiquidError(LiquidParseError,
                    errorStream.str().c_str());
    }

    // Clean up the data.
    delete templ;

    return TCL_OK;
}
开发者ID:23,项目名称:openliquid,代码行数:48,代码来源:TclLiquid.cpp

示例12: TnmGetTableKeyFromObj

int
TnmGetTableKeyFromObj(Tcl_Interp *interp, TnmTable *table, Tcl_Obj *objPtr, char *what)
{
    char *name;
    int value;

    name = Tcl_GetStringFromObj(objPtr, NULL);
    value = TnmGetTableKey(table, name);
    if (value == -1 && interp) {
	Tcl_ResetResult(interp);
	Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "unknown ",
			       what, " \"", name, "\": should be ",
			       TnmGetTableValues(table), (char *) NULL);
    }
    return value;
}
开发者ID:flightaware,项目名称:scotty,代码行数:16,代码来源:tnmUtil.c

示例13: TSP_Util_lang_get_string_var

/* string must be used immediately */
Tcl_DString*
TSP_Util_lang_get_string_var(Tcl_Obj* sourceVarName) {
    static int doInit = 1;
    static Tcl_DString ds;
    int len;
    char* str;
    if (doInit) {
        Tcl_DStringInit(&ds);
        doInit = 0;
    } else {
        Tcl_DStringSetLength(&ds, 0);
    }
    str = Tcl_GetStringFromObj(sourceVarName, &len);
    Tcl_DStringAppend(&ds, str, len);
    return &ds;
}
开发者ID:bovine,项目名称:tsp,代码行数:17,代码来源:TSP_util.c

示例14: Get_parts

/*************************************************************************
* FUNCTION      :   RPMPRoblem_Obj::Get_stringrep                        *
* ARGUMENTS     :   none                                                 *
* RETURNS       :   Tcl_Alloc'ed string rep of an object                 *
* EXCEPTIONS    :   none                                                 *
* PURPOSE       :   Return the string rep of an RPM header               *
*************************************************************************/
char *RPMPRoblem_Obj::Get_stringrep(int &len)
{
   // Get our parts as a TCL list
   Tcl_Obj *name    = Get_parts();
   Tcl_IncrRefCount(name);
   // we must return dynamaically allocated space, so allocate that
   int   size = 0;
   char *from = Tcl_GetStringFromObj(name,&size);
   char *space = Tcl_Alloc(size+1);
   assert(space);
   strncpy(space,from,size);
   space[size] = 0;
   Tcl_DecrRefCount(name);
   len = size;
   return space;
}
开发者ID:avokhmin,项目名称:RPM5,代码行数:23,代码来源:problem.cpp

示例15: GroupCmd

static int
GroupCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
    TnmMapItem *itemPtr = (TnmMapItem *) clientData;
    int result = TnmMapItemObjCmd(itemPtr, interp, objc, objv);

    if (result == TCL_CONTINUE) {
	Tcl_AppendResult(interp, "bad option \"", 
			 Tcl_GetStringFromObj(objv[1], NULL),
			 "\": should be ", (char *) NULL);
	TnmMapItemCmdList(itemPtr, interp);
	result = TCL_ERROR;
    }

    return result;
}
开发者ID:flightaware,项目名称:scotty,代码行数:16,代码来源:tnmMapGroup.c


注:本文中的Tcl_GetStringFromObj函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。