本文整理汇总了C++中INT2PTR函数的典型用法代码示例。如果您正苦于以下问题:C++ INT2PTR函数的具体用法?C++ INT2PTR怎么用?C++ INT2PTR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了INT2PTR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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));
}
示例2: AtomInit
static void
AtomInit(
TkDisplay *dispPtr)/* Display to initialize. */
{
Tcl_HashEntry *hPtr;
Atom atom;
dispPtr->atomInit = 1;
Tcl_InitHashTable(&dispPtr->nameTable, TCL_STRING_KEYS);
Tcl_InitHashTable(&dispPtr->atomTable, TCL_ONE_WORD_KEYS);
for (atom = 1; atom <= XA_LAST_PREDEFINED; atom++) {
const char *name;
int isNew;
hPtr = Tcl_FindHashEntry(&dispPtr->atomTable, INT2PTR(atom));
if (hPtr != NULL) {
continue;
}
name = atomNameArray[atom - 1];
hPtr = Tcl_CreateHashEntry(&dispPtr->nameTable, name, &isNew);
Tcl_SetHashValue(hPtr, INT2PTR(atom));
name = Tcl_GetHashKey(&dispPtr->nameTable, hPtr);
hPtr = Tcl_CreateHashEntry(&dispPtr->atomTable, INT2PTR(atom), &isNew);
Tcl_SetHashValue(hPtr, (char *)name);
}
}
示例3: main
int main(int argc, char **argv) {
int i, key, inmap, insert, data;
void *datap;
struct hashmap_t *map = hashmap_new(5);
srandom(0);
for (i=0; i<10000; i++) {
key = rand()%DATASET_SIZE;
insert = rand()%2;
inmap = test_status[key];
data = test_data[key];
if (inmap && insert) {
/* update */
data++;
hashmap_upsert(map, &key, sizeof(int), INT2PTR(data), &datap);
assert((intptr_t)datap == (intptr_t)test_data[key]);
test_data[key] = data;
} else if ( !inmap && insert) {
/* insert */
hashmap_upsert(map, &key, sizeof(int), INT2PTR(data), &datap);
assert( (intptr_t)datap == 0);
test_status[key] = 1;
} else if (inmap && !insert) {
/* delete */
hashmap_delete(map, &key, sizeof(int), &datap);
assert((intptr_t)datap == (intptr_t)test_data[key]);
test_status[key] = 0;
} else if (!inmap && !insert) {
/* nothing to be deleted */
hashmap_delete(map, &key, sizeof(int), &datap);
assert((intptr_t)datap == 0);
}
}
return 0;
}
示例4: 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;
}
示例5: GetMenuIndicatorGeometry
static void
GetMenuIndicatorGeometry(
TkMenu *menuPtr, /* The menu we are drawing. */
TkMenuEntry *mePtr, /* The entry we are interested in. */
Tk_Font tkfont, /* The precalculated font */
const Tk_FontMetrics *fmPtr,/* The precalculated metrics */
int *widthPtr, /* The resulting width */
int *heightPtr) /* The resulting height */
{
int borderWidth;
if ((mePtr->type == CHECK_BUTTON_ENTRY)
|| (mePtr->type == RADIO_BUTTON_ENTRY)) {
if (!mePtr->hideMargin && mePtr->indicatorOn) {
if ((mePtr->image != NULL) || (mePtr->bitmapPtr != NULL)) {
*widthPtr = (14 * mePtr->height) / 10;
*heightPtr = mePtr->height;
if (mePtr->type == CHECK_BUTTON_ENTRY) {
mePtr->platformEntryData = (TkMenuPlatformEntryData)
INT2PTR((65 * mePtr->height) / 100);
} else {
mePtr->platformEntryData = (TkMenuPlatformEntryData)
INT2PTR((75 * mePtr->height) / 100);
}
} else {
*widthPtr = *heightPtr = mePtr->height;
if (mePtr->type == CHECK_BUTTON_ENTRY) {
mePtr->platformEntryData = (TkMenuPlatformEntryData)
INT2PTR((80 * mePtr->height) / 100);
} else {
mePtr->platformEntryData = (TkMenuPlatformEntryData)
INT2PTR(mePtr->height);
}
}
} else {
Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr,
&borderWidth);
*heightPtr = 0;
*widthPtr = borderWidth;
}
} else {
Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr,
&borderWidth);
*heightPtr = 0;
*widthPtr = borderWidth;
}
}
示例6: ui_bridge_put
static void ui_bridge_put(UI *b, uint8_t *text, size_t size)
{
uint8_t *t = NULL;
if (text) {
t = xmalloc(sizeof(((UCell *)0)->data));
memcpy(t, text, size);
}
UI_CALL(b, put, 3, b, t, INT2PTR(size));
}
示例7: PipeGetHandleProc
static int
PipeGetHandleProc(
ClientData instanceData, /* The pipe state. */
int direction, /* TCL_READABLE or TCL_WRITABLE */
ClientData *handlePtr) /* Where to store the handle. */
{
PipeState *psPtr = (PipeState *) instanceData;
if (direction == TCL_READABLE && psPtr->inFile) {
*handlePtr = (ClientData) INT2PTR(GetFd(psPtr->inFile));
return TCL_OK;
}
if (direction == TCL_WRITABLE && psPtr->outFile) {
*handlePtr = (ClientData) INT2PTR(GetFd(psPtr->outFile));
return TCL_OK;
}
return TCL_ERROR;
}
示例8: TcpGetHandleProc
/* ARGSUSED */
static int
TcpGetHandleProc(
ClientData instanceData, /* The socket state. */
int direction, /* Not used. */
ClientData *handlePtr) /* Where to store the handle. */
{
TcpState *statePtr = instanceData;
*handlePtr = INT2PTR(statePtr->fds.fd);
return TCL_OK;
}
示例9: chat_kickchat
/*==========================================
* チャットルームから蹴り出す
*------------------------------------------
*/
void chat_kickchat(struct map_session_data *sd, const char *kickusername)
{
struct chat_data *cd;
int i;
nullpo_retv(sd);
cd = map_id2cd(sd->chatID);
if(cd == NULL || &sd->bl != (*cd->owner))
return;
for(i = 0; i < cd->users; i++) {
if(strncmp(cd->usersd[i]->status.name, kickusername, 24) == 0) {
linkdb_insert(&cd->ban_list, INT2PTR(cd->usersd[i]->status.char_id), INT2PTR(1));
chat_leavechat(cd->usersd[i], 1);
break;
}
}
return;
}
示例10: Tk_GetAtomName
const char *
Tk_GetAtomName(
Tk_Window tkwin, /* Window token; map atom to name relative to
* this window's display. */
Atom atom) /* Atom whose name is wanted. */
{
TkDisplay *dispPtr;
Tcl_HashEntry *hPtr;
dispPtr = ((TkWindow *) tkwin)->dispPtr;
if (!dispPtr->atomInit) {
AtomInit(dispPtr);
}
hPtr = Tcl_FindHashEntry(&dispPtr->atomTable, INT2PTR(atom));
if (hPtr == NULL) {
const char *name;
Tk_ErrorHandler handler;
int isNew;
char *mustFree = NULL;
handler = Tk_CreateErrorHandler(dispPtr->display, BadAtom, -1, -1,
NULL, NULL);
name = mustFree = XGetAtomName(dispPtr->display, atom);
if (name == NULL) {
name = "?bad atom?";
}
Tk_DeleteErrorHandler(handler);
hPtr = Tcl_CreateHashEntry(&dispPtr->nameTable, name, &isNew);
Tcl_SetHashValue(hPtr, INT2PTR(atom));
if (mustFree) {
XFree(mustFree);
}
name = Tcl_GetHashKey(&dispPtr->nameTable, hPtr);
hPtr = Tcl_CreateHashEntry(&dispPtr->atomTable, INT2PTR(atom), &isNew);
Tcl_SetHashValue(hPtr, (char *)name);
}
return Tcl_GetHashValue(hPtr);
}
示例11: FileGetHandleProc
static int
FileGetHandleProc(
ClientData instanceData, /* The file state. */
int direction, /* TCL_READABLE or TCL_WRITABLE */
ClientData *handlePtr) /* Where to store the handle. */
{
FileState *fsPtr = instanceData;
if (direction & fsPtr->validMask) {
*handlePtr = INT2PTR(fsPtr->fd);
return TCL_OK;
}
return TCL_ERROR;
}
示例12: Tcl_CreatePipe
/*
*----------------------------------------------------------------------
*
* Tcl_CreatePipe --
*
* System dependent interface to create a pipe for the [chan pipe]
* command. Stolen from TclX.
*
* Parameters:
* o interp - Errors returned in result.
* o rchan, wchan - Returned read and write side.
* o flags - Reserved for future use.
* Results:
* TCL_OK or TCL_ERROR.
*
*----------------------------------------------------------------------
*/
int
Tcl_CreatePipe(
Tcl_Interp *interp,
Tcl_Channel *rchan,
Tcl_Channel *wchan,
int flags)
{
int fileNums[2];
if (pipe(fileNums) < 0) {
Tcl_AppendResult(interp, "pipe creation failed: ",
Tcl_PosixError(interp), NULL);
return TCL_ERROR;
}
*rchan = Tcl_MakeFileChannel((ClientData) INT2PTR(fileNums[0]),
TCL_READABLE);
Tcl_RegisterChannel(interp, *rchan);
*wchan = Tcl_MakeFileChannel((ClientData) INT2PTR(fileNums[1]),
TCL_WRITABLE);
Tcl_RegisterChannel(interp, *wchan);
return TCL_OK;
}
示例13: 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");*/
}
}
示例14: 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;
}
示例15: centernode_connect
//Connect to the remote host
cnaccess_t * centernode_connect (centernode_t *cn, const char *host, uint16_t port,
cnaccess_t *a, int type, int isp)
{
int fd = 0;
struct sockaddr_in server;
if ((fd = socket(PF_INET, SOCK_STREAM, 0)) == -1)
{
#ifdef CDNDEBUG
LOG("ER", "create sock-(%d)%s.\n", errno, strerror(errno));
#endif
return 0;
}
//nonblocking connect call
fcntl(fd, F_SETFL, O_NONBLOCK | fcntl(fd, F_GETFL, 0));
memset((uint8_t *)&server, 0, sizeof(server));
server.sin_family = PF_INET;
server.sin_port = htons(port);
server.sin_addr.s_addr = inet_addr(host);
int r = connect(fd, (struct sockaddr *) &server, sizeof(server));
if (r == -1 && errno != EINPROGRESS)
{
#ifdef CDNDEBUG
LOG("ER", "conn to %s.%d-(%d)%s.\n", host, port, errno, strerror(errno));
#endif
return (close(fd), NULL);
}
cnaccess_t *ca = a;
if (ca) { /* reconnect */
ca->fd = fd;
ca->interaction = time(0);
strncpy(ca->host,host,strlen(host));
ca->port = port;
} else ca = cnaccess_create(cn, fd, host, port, type, isp);
if (r == -1 && ++ca->retry > 4)
ca->retry = 1;
ca->status = r ? NS_CONNECTING: NS_NORMAL;
printf("cat %d\n", ca->status);
pthread_mutex_lock(&cn->objlock), /* add it to sesstion table */
gdsl_hash_insert(cn->accesses, ca);
pthread_mutex_unlock(&cn->objlock);
pthread_mutex_lock(&cn->reglock), /* register it to libevent */
gdsl_queue_insert(cn->registration, INT2PTR(ca->fd)),
pthread_mutex_unlock(&cn->reglock);
return ca;
}