本文整理汇总了C++中PTR2INT函数的典型用法代码示例。如果您正苦于以下问题:C++ PTR2INT函数的具体用法?C++ PTR2INT怎么用?C++ PTR2INT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PTR2INT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TclpMakeTcpClientChannelMode
void *
TclpMakeTcpClientChannelMode(
void *sock, /* The socket to wrap up into a channel. */
int mode) /* ORed combination of TCL_READABLE and
* TCL_WRITABLE to indicate file mode. */
{
TcpState *statePtr;
char channelName[SOCK_CHAN_LENGTH];
statePtr = ckalloc(sizeof(TcpState));
memset(statePtr, 0, sizeof(TcpState));
statePtr->fds.fd = PTR2INT(sock);
statePtr->flags = 0;
sprintf(channelName, SOCK_TEMPLATE, (long)statePtr);
statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
statePtr, mode);
if (Tcl_SetChannelOption(NULL, statePtr->channel, "-translation",
"auto crlf") == TCL_ERROR) {
Tcl_Close(NULL, statePtr->channel);
return NULL;
}
return statePtr->channel;
}
示例2: Tk_InternAtom
Atom
Tk_InternAtom(
Tk_Window tkwin, /* Window token; map name to atom for this
* window's display. */
const char *name) /* Name to turn into atom. */
{
TkDisplay *dispPtr;
Tcl_HashEntry *hPtr;
int isNew;
dispPtr = ((TkWindow *) tkwin)->dispPtr;
if (!dispPtr->atomInit) {
AtomInit(dispPtr);
}
hPtr = Tcl_CreateHashEntry(&dispPtr->nameTable, name, &isNew);
if (isNew) {
Tcl_HashEntry *hPtr2;
Atom atom;
atom = XInternAtom(dispPtr->display, name, False);
Tcl_SetHashValue(hPtr, INT2PTR(atom));
hPtr2 = Tcl_CreateHashEntry(&dispPtr->atomTable, INT2PTR(atom), &isNew);
Tcl_SetHashValue(hPtr2, Tcl_GetHashKey(&dispPtr->nameTable, hPtr));
}
return (Atom)PTR2INT(Tcl_GetHashValue(hPtr));
}
示例3: Tcl_DeleteHashEntry
void
Tcl_DeleteHashEntry(
Tcl_HashEntry *entryPtr)
{
register Tcl_HashEntry *prevPtr;
const Tcl_HashKeyType *typePtr;
Tcl_HashTable *tablePtr;
Tcl_HashEntry **bucketPtr;
#if TCL_HASH_KEY_STORE_HASH
int index;
#endif
tablePtr = entryPtr->tablePtr;
if (tablePtr->keyType == TCL_STRING_KEYS) {
typePtr = &tclStringHashKeyType;
} else if (tablePtr->keyType == TCL_ONE_WORD_KEYS) {
typePtr = &tclOneWordHashKeyType;
} else if (tablePtr->keyType == TCL_CUSTOM_TYPE_KEYS
|| tablePtr->keyType == TCL_CUSTOM_PTR_KEYS) {
typePtr = tablePtr->typePtr;
} else {
typePtr = &tclArrayHashKeyType;
}
#if TCL_HASH_KEY_STORE_HASH
if (typePtr->hashKeyProc == NULL
|| typePtr->flags & TCL_HASH_KEY_RANDOMIZE_HASH) {
index = RANDOM_INDEX(tablePtr, PTR2INT(entryPtr->hash));
} else {
index = PTR2UINT(entryPtr->hash) & tablePtr->mask;
}
bucketPtr = &tablePtr->buckets[index];
#else
bucketPtr = entryPtr->bucketPtr;
#endif
if (*bucketPtr == entryPtr) {
*bucketPtr = entryPtr->nextPtr;
} else {
for (prevPtr = *bucketPtr; ; prevPtr = prevPtr->nextPtr) {
if (prevPtr == NULL) {
Tcl_Panic("malformed bucket chain in Tcl_DeleteHashEntry");
}
if (prevPtr->nextPtr == entryPtr) {
prevPtr->nextPtr = entryPtr->nextPtr;
break;
}
}
}
tablePtr->numEntries--;
if (typePtr->freeEntryProc) {
typePtr->freeEntryProc(entryPtr);
} else {
ckfree((char *) entryPtr);
}
}
示例4: EnumChildrenProc
static BOOL CALLBACK
EnumChildrenProc(
HWND hwnd,
LPARAM lParam)
{
Tcl_Obj *listObj = (Tcl_Obj *) lParam;
Tcl_ListObjAppendElement(NULL, listObj, Tcl_NewLongObj(PTR2INT(hwnd)));
return TRUE;
}
示例5: rdpGetWindowPrivate
void *
rdpGetWindowPrivate(WindowPtr pWindow, rdpDevPrivateKey key)
{
void *rv;
#if XRDP_PRI == 1
rv = pWindow->devPrivates[PTR2INT(key)].ptr;
#else
rv = dixLookupPrivate(&(pWindow->devPrivates), key);
#endif
return rv;
}
示例6: rdpGetPixmapPrivate
void *
rdpGetPixmapPrivate(PixmapPtr pPixmap, rdpDevPrivateKey key)
{
void *rv;
#if XRDP_PRI == 1
rv = pPixmap->devPrivates[PTR2INT(key)].ptr;
#else
rv = dixLookupPrivate(&(pPixmap->devPrivates), key);
#endif
return rv;
}
示例7: rdpGetGCPrivate
void *
rdpGetGCPrivate(GCPtr pGC, rdpDevPrivateKey key)
{
void *rv;
#if XRDP_PRI == 1
rv = pGC->devPrivates[PTR2INT(key)].ptr;
#else
rv = dixLookupPrivate(&(pGC->devPrivates), key);
#endif
return rv;
}
示例8: func
void *
func(void * arg)
{
int i = PTR2INT(arg);
Sleep(i * 10);
pthread_exit(arg);
/* Never reached. */
exit(1);
}
示例9: TestgetwindowinfoObjCmd
static int
TestgetwindowinfoObjCmd(
ClientData clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
long hwnd;
Tcl_Obj *dictObj = NULL, *classObj = NULL, *textObj = NULL;
Tcl_Obj *childrenObj = NULL;
TCHAR buf[512];
int cch, cchBuf = 256;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "hwnd");
return TCL_ERROR;
}
if (Tcl_GetLongFromObj(interp, objv[1], &hwnd) != TCL_OK)
return TCL_ERROR;
cch = GetClassName(INT2PTR(hwnd), buf, cchBuf);
if (cch == 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to get class name: ", -1));
AppendSystemError(interp, GetLastError());
return TCL_ERROR;
} else {
Tcl_DString ds;
Tcl_WinTCharToUtf(buf, -1, &ds);
classObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
Tcl_DStringFree(&ds);
}
dictObj = Tcl_NewDictObj();
Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("class", 5), classObj);
Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("id", 2),
Tcl_NewLongObj(GetWindowLongA(INT2PTR(hwnd), GWL_ID)));
cch = GetWindowText(INT2PTR(hwnd), (LPTSTR)buf, cchBuf);
textObj = Tcl_NewUnicodeObj((LPCWSTR)buf, cch);
Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("text", 4), textObj);
Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("parent", 6),
Tcl_NewLongObj(PTR2INT(GetParent((INT2PTR(hwnd))))));
childrenObj = Tcl_NewListObj(0, NULL);
EnumChildWindows(INT2PTR(hwnd), EnumChildrenProc, (LPARAM)childrenObj);
Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("children", -1), childrenObj);
Tcl_SetObjResult(interp, dictObj);
return TCL_OK;
}
示例10: TestfilewaitCmd
static int
TestfilewaitCmd(
ClientData clientData, /* Not used. */
Tcl_Interp *interp, /* Current interpreter. */
int argc, /* Number of arguments. */
CONST char **argv) /* Argument strings. */
{
int mask, result, timeout;
Tcl_Channel channel;
int fd;
ClientData data;
if (argc != 4) {
Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
" file readable|writable|both timeout\"", NULL);
return TCL_ERROR;
}
channel = Tcl_GetChannel(interp, argv[1], NULL);
if (channel == NULL) {
return TCL_ERROR;
}
if (strcmp(argv[2], "readable") == 0) {
mask = TCL_READABLE;
} else if (strcmp(argv[2], "writable") == 0){
mask = TCL_WRITABLE;
} else if (strcmp(argv[2], "both") == 0){
mask = TCL_WRITABLE|TCL_READABLE;
} else {
Tcl_AppendResult(interp, "bad argument \"", argv[2],
"\": must be readable, writable, or both", NULL);
return TCL_ERROR;
}
if (Tcl_GetChannelHandle(channel,
(mask & TCL_READABLE) ? TCL_READABLE : TCL_WRITABLE,
(ClientData*) &data) != TCL_OK) {
Tcl_SetResult(interp, "couldn't get channel file", TCL_STATIC);
return TCL_ERROR;
}
fd = PTR2INT(data);
if (Tcl_GetInt(interp, argv[3], &timeout) != TCL_OK) {
return TCL_ERROR;
}
result = TclUnixWaitForFile(fd, mask, timeout);
if (result & TCL_READABLE) {
Tcl_AppendElement(interp, "readable");
}
if (result & TCL_WRITABLE) {
Tcl_AppendElement(interp, "writable");
}
return TCL_OK;
}
示例11: NextRestoreFrame
static int
NextRestoreFrame(
ClientData data[],
Tcl_Interp *interp,
int result)
{
Interp *iPtr = (Interp *) interp;
CallContext *contextPtr = data[1];
iPtr->varFramePtr = data[0];
if (contextPtr != NULL) {
contextPtr->index = PTR2INT(data[2]);
}
return result;
}
示例12: Tk_GetElementId
int
Tk_GetElementId(
const char *name) /* Name of the element. */
{
ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr;
int genericId = -1;
char *dot;
/*
* Find the element Id.
*/
entryPtr = Tcl_FindHashEntry(&tsdPtr->elementTable, name);
if (entryPtr) {
return PTR2INT(Tcl_GetHashValue(entryPtr));
}
/*
* Element not found. If the given name was derived, then first search for
* the generic element. If found, create the new derived element.
*/
dot = strchr(name, '.');
if (!dot) {
return -1;
}
genericId = Tk_GetElementId(dot+1);
if (genericId == -1) {
return -1;
}
if (!tsdPtr->elements[genericId].created) {
/*
* The generic element was created implicitly and thus has no real
* existence.
*/
return -1;
} else {
/*
* The generic element was created explicitly. Create the derived
* element.
*/
return CreateElement(name, 1);
}
}
示例13: rdpAllocatePixmapPrivate
rdpDevPrivateKey
rdpAllocatePixmapPrivate(ScreenPtr pScreen, int bytes)
{
rdpDevPrivateKey rv;
#if XRDP_PRI == 1
rv = INT2PTR(AllocatePixmapPrivateIndex());
AllocatePixmapPrivate(pScreen, PTR2INT(rv), bytes);
#elif XRDP_PRI == 2
dixRequestPrivate(&g_privateKeyRecPixmap, bytes);
rv = &g_privateKeyRecPixmap;
#else
dixRegisterPrivateKey(&g_privateKeyRecPixmap, PRIVATE_PIXMAP, bytes);
rv = &g_privateKeyRecPixmap;
#endif
return rv;
}
示例14: rdpAllocateWindowPrivate
rdpDevPrivateKey
rdpAllocateWindowPrivate(ScreenPtr pScreen, int bytes)
{
rdpDevPrivateKey rv;
#if XRDP_PRI == 1
rv = INT2PTR(AllocateWindowPrivateIndex());
AllocateWindowPrivate(pScreen, PTR2INT(rv), bytes);
#elif XRDP_PRI == 2
dixRequestPrivate(&g_privateKeyRecWindow, bytes);
rv = &g_privateKeyRecWindow;
#else
dixRegisterPrivateKey(&g_privateKeyRecWindow, PRIVATE_WINDOW, bytes);
rv = &g_privateKeyRecWindow;
#endif
return rv;
}
示例15: Tcl_MakeFileChannel
Tcl_Channel
Tcl_MakeFileChannel(
ClientData handle, /* OS level handle. */
int mode) /* ORed combination of TCL_READABLE and
* TCL_WRITABLE to indicate file mode. */
{
FileState *fsPtr;
char channelName[16 + TCL_INTEGER_SPACE];
int fd = PTR2INT(handle);
const Tcl_ChannelType *channelTypePtr;
struct sockaddr sockaddr;
socklen_t sockaddrLen = sizeof(sockaddr);
if (mode == 0) {
return NULL;
}
sockaddr.sa_family = AF_UNSPEC;
#ifdef SUPPORTS_TTY
if (isatty(fd)) {
channelTypePtr = &ttyChannelType;
sprintf(channelName, "serial%d", fd);
} else
#endif /* SUPPORTS_TTY */
if ((getsockname(fd, (struct sockaddr *)&sockaddr, &sockaddrLen) == 0)
&& (sockaddrLen > 0)
&& (sockaddr.sa_family == AF_INET || sockaddr.sa_family == AF_INET6)) {
return TclpMakeTcpClientChannelMode(INT2PTR(fd), mode);
} else {
channelTypePtr = &fileChannelType;
sprintf(channelName, "file%d", fd);
}
fsPtr = ckalloc(sizeof(FileState));
fsPtr->fd = fd;
fsPtr->validMask = mode | TCL_EXCEPTION;
fsPtr->channel = Tcl_CreateChannel(channelTypePtr, channelName,
fsPtr, mode);
return fsPtr->channel;
}