void av_update(struct IC *p,bvtype *isused) { int i,j; if((p->z.flags&(VKONST|VAR))==VAR){ i=p->z.v->index; if(p->z.flags&DREFOBJ) i+=vcount-rcount; if(i<0||i>=vcount){ printf("i=%d\n",i);pric2(stdout,p); ierror(0); } if(p->z.flags&DREFOBJ){ if(!(p->z.v->flags&DNOTTYPESAFE)) BCLR(isused,i); }else{ if(ISSCALAR(p->z.v->vtyp->flags)||(p->code==ASSIGN&&zmeqto(p->q2.val.vmax,szof(p->z.v->vtyp)))) BCLR(isused,i); } /* bei Zuweisung an p wird *p aktiv */ if(i<rcount) BSET(isused,i+vcount-rcount); } for(j=0;j<p->use_cnt;j++){ i=p->use_list[j].v->index; if(p->use_list[j].flags&DREFOBJ) i+=vcount-rcount; if(i<0||i>=vcount) continue; BSET(isused,i); } }
ALIST_API ControlPartCode ALSetFocus(ControlPartCode focusPart, ALHandle hAL) { ControlPartCode result; Boolean oldFocus; CGrafPtr savePort; WindowPtr winRef; if (hAL == nil || *hAL == nil) return kControlFocusNoPart; // Keep track of the old state of things. oldFocus = (BTST((*hAL)->flags, alFFocused) != 0); switch (focusPart) { case kControlFocusNoPart: // Turn off all focusing. BCLR((*hAL)->flags, alFFocused); result = kControlFocusNoPart; break; case kControlFocusNextPart: // Switch the state from off/on to on/off. case kControlFocusPrevPart: if (BTST((*hAL)->flags, alFFocused)) { // Turn off the focus. BCLR((*hAL)->flags, alFFocused); result = kControlFocusNoPart; } else { // Turn on the focus. BSET((*hAL)->flags, alFFocused); result = kControlListBoxPart; } break; case kControlListBoxPart: // Turn on focusing. BSET((*hAL)->flags, alFFocused); result = kControlListBoxPart; break; default: // simply return the state of focus result = (BTST((*hAL)->flags, alFFocused)) ? kControlListBoxPart : kControlFocusNoPart; break; } // If the focus changed, redraw if the alFDrawFocus feature is turned on. if ( BTST((*hAL)->features, alFDrawFocus) && oldFocus != (BTST((*hAL)->flags, alFFocused) != 0)) { GDHandle saveDevice; GetGWorld(&savePort, &saveDevice); ALGetInfo(alWindow, &winRef, hAL); SetPortWindowPort(winRef); _ALDrawListBorder(hAL); SetGWorld(savePort, saveDevice); } return result; } // ALSetFocus
ALIST_API short ALFeatureFlag(unsigned long feature, short action, ALHandle hAL) { ALPtr pAL; short status; if (hAL == nil || *hAL == nil) return alBitClear; pAL = *hAL; // get current status of the specified feature status = BTST(pAL->features, feature) ? alBitSet : alBitClear; // if action is alBitToggle, invert flag if (action == alBitToggle) action = 1 - status; // reset flag according to action if (action == alBitClear) { BCLR(pAL->features, feature); if ( feature == alFInhibitRedraw ) // If we're enabling drawing, recalculate what's visible. _ALCalcVisibleCells( hAL ); } else if ( action == alBitSet ) BSET(pAL->features, feature); // return old status return status; } // ALFeatureFlag
ALIST_API OSErr ALCollapseRow(long rowNum, Boolean collapseChildren, ALHandle hAL) { ALCell tempCell; unsigned long superRowOffset, offset; // Sanity check. if ( hAL == nil || *hAL == nil || rowNum < (**hAL).dataBounds.top || rowNum >= (**hAL).dataBounds.bottom ) return paramErr; // Make sure the list is heirarchical. if ( !BTST( (*hAL)->features, alFHeirarchical ) ) return false; // The left-most cell contains the heirarchical data. tempCell.h = (**hAL).dataBounds.left; tempCell.v = rowNum; superRowOffset = _ALCalcOffsetFromCell(&tempCell, &(*hAL)->dataBounds); // Mark the row as collapsed. BCLR((*(*hAL)->hSelected)[superRowOffset], alSexpanded); // See if it's a heirarchical row. if ( BTST((*(*hAL)->hSelected)[superRowOffset], alSsuperrow) ) { for ( tempCell.v++; tempCell.v < (*hAL)->dataBounds.bottom; tempCell.v++ ) { // Go through looking for children. offset = _ALCalcOffsetFromCell( &tempCell, &(*hAL)->dataBounds ); if ( (*(*hAL)->hLevels)[ offset ] > (*(*hAL)->hLevels)[ superRowOffset ] ) { if ( collapseChildren ) // Mark all children as collapsed. BCLR( (*(*hAL)->hSelected)[ offset ], alSexpanded ); // Also, clear all selection bits. BCLR( (*(*hAL)->hSelected)[ offset ], alSselected ); } else break; } // Recalculate the visible cells. _ALCalcVisibleCells( hAL ); // Redraw the entire list. if ( !BTST((*hAL)->features, alFInhibitRedraw) ) ALUpdate( nil, hAL ); } return noErr; }
void ptsstop(TTY tp, int fl) { if (!fl) { fl = TIOCPKT_STOP; BSET(tp->state, PF_STOPPED); } else BCLR(tp->state, PF_STOPPED); BSET(tp->send, fl); ptc_select(tp); }
int ttflush(TTY tp, int mode) { if (mode & 1) { qflush(&tp->inq); } if (mode & 2) { BCLR(tp->state, ST_STOPPED); ptsstop(tp,mode); qflush(&tp->outq); if (ISSET(tp->state,ST_DRAIN)) { BCLR(tp->state, ST_DRAIN); Run(&tp->outq); } } return RPDONE; }
void ttstart(TTY tp) { ULONG state = tp->state; if (ISSET(state, ST_STOPPED)) return; if (state & PF_STOPPED) { BCLR(tp->state, PF_STOPPED); tp->send = TIOCPKT_START; ptc_select(tp); } }
static int insert_biterror(unsigned char *buf) { unsigned int bit = 0; unsigned int byte = 0; while (byte < mtd->writesize) { for (bit = 0; bit <= 7; bit++) { if (CBIT(buf[byte], bit)) { BCLR(buf[byte], bit); pr_info("Inserted biterror @ %u/%u\n", byte, bit); return 0; } } byte++; } pr_err("biterror: Failed to find a '1' bit\n"); return -EIO; }
void INT_Excep_TPU2_TGI2A() { SoftwarePwm* p; for (p = &softwarePwmTable[0]; p < &softwarePwmTable[MaxSoftwarePwmChannels]; p++) { if (p->valid) { if (p->count == p->term) { BCLR(p->out, p->bit); } else if (p->count == 0) { BSET(p->out, p->bit); } if (p->length > 0 && --p->length == 0) { p->valid = false; } if (++p->count >= p->period) { p->count = 0; } } } }
void ScriptEngine::parseRegister(char * c, char ** args) { // %REGISTER[bit] = value char * nreg = ++c; while(*c != '[') ++c; *c = '\0'; uint8 bit = atoi((++c)); uint8 * reg = Register::GetRegisterByName(nreg); if (reg == NULL) { WriteLine(PSTR("Unknown register.\r\n")); return; } WriteRAM(nreg,0); Register::WriteRegister(reg); WriteLine(PSTR(" --> "),0); if (atoi(args[1])) BSET(*reg, bit); else BCLR(*reg,bit); Register::WriteRegister(reg); WriteLine(PSTR("\r\n")); }
/** * @brief 关SPI接收中断 * * @param spino SPI通道号 */ void spi_disable_rcv_int(uint8_t spino) { SPI_MemMapPtr base_addr = spi_get_base_address(spino); BCLR(SPI_RSER_RFDF_RE_SHIFT, SPI_RSER_REG(base_addr));/* 关闭SPI接收中断 */ exc_disable(spino + INT_SPI0); /* 开接收引脚的IRQ中断 */ }
/* node_dynamic_setup: prepare for execution (state: NODE_DYNAMIC_READY) * pynodes already linked to a script (node->id != NULL). */ static void node_dynamic_setup(bNode *node) { #ifdef WITH_PYTHON NodeScriptDict *nsd = NULL; bNodeTree *nodetree = NULL; bNodeType *ntype = NULL; PyGILState_STATE gilstate; /* Possible cases: * NEW * ADDEXIST * LOADED * REPARSE * ERROR * READY */ /* NEW, but not linked to a script: link default (empty) typeinfo */ if (!node->id) { node->typeinfo = node_dynamic_find_typeinfo(&node_all_shaders, NULL); return; } /* READY, no need to be here */ if (BTST(node->custom1, NODE_DYNAMIC_READY)) return; gilstate = PyGILState_Ensure(); /* ERROR, reset to (empty) defaults */ if (BCLR(node->custom1, NODE_DYNAMIC_ERROR) == 0) { node_dynamic_reset(node, 0); PyGILState_Release(gilstate); return; } /* User asked to update this pynode, prepare it for reparsing */ if (BTST(node->custom1, NODE_DYNAMIC_REPARSE)) { int needs_parsing = 1; node->custom1 = BSET(node->custom1, NODE_DYNAMIC_NEW); if (BTST(node->custom1, NODE_DYNAMIC_ERROR)) { node->custom1 = BCLR(node->custom1, NODE_DYNAMIC_REPARSE); ntype = node_dynamic_find_typeinfo(&node_all_shaders, node->id); if (ntype) { node->typeinfo = ntype; node->custom1 = BSET(node->custom1, NODE_DYNAMIC_ADDEXIST); node->custom1 = BCLR(node->custom1, NODE_DYNAMIC_ERROR); needs_parsing = 0; } else { nodeMakeDynamicType(node); } } else { node_dynamic_rem_all_links(node->typeinfo); node_dynamic_free_typeinfo_sockets(node->typeinfo); node_dynamic_update_socket_links(node, NULL); node_dynamic_free_storage_cb(node); } if (needs_parsing) { nsd = MEM_callocN(sizeof(NodeScriptDict), "node script dictionary"); nsd->dict = init_dynamicdict(); node->storage = nsd; /* prepared, now reparse: */ node_dynamic_parse(node); PyGILState_Release(gilstate); return; } } else if (BTST(node->custom1, NODE_DYNAMIC_LOADED)) { /* when loading from a .blend we don't have G.main yet, so we * quickly abuse node->storage in ntreeInitTypes (node.c) to have * our nodetree ptr (needed if a pynode script that worked before * saving the .blend for some reason fails upon loading): */ nodetree = (bNodeTree *)node->storage; node->storage = NULL; } if (node->storage) fprintf(stderr, "\nDEBUG: PYNODES ERROR: non NULL node->storage in node_dynamic_setup()\n"); nsd = MEM_callocN(sizeof(NodeScriptDict), "node script dictionary"); node->storage = nsd; /* NEW, LOADED or REPARSE */ if (BNTST(node->custom1, NODE_DYNAMIC_ADDEXIST)) { /* check if there's already a bNodeType linked to this script */ /* (XXX hardcoded for shader nodes for now) */ ntype = node_dynamic_find_typeinfo(&node_all_shaders, node->id); if (ntype) { /* if so, reuse it */ node->typeinfo = ntype; /* so this is actually an ADDEXIST type */ node->custom1 = BSET(node->custom1, NODE_DYNAMIC_ADDEXIST); } else { /* create bNodeType for this pynode */ nodeMakeDynamicType(node); nsd->dict = init_dynamicdict(); if ((node_dynamic_parse(node) == -1) && nodetree) { node_dynamic_reset_loaded(node); } PyGILState_Release(gilstate); return; } } /* ADDEXIST: new pynode linked to an already registered dynamic type, * we just reuse existing py dict and pynode */ nsd->dict = node->typeinfo->pydict; nsd->node = node->typeinfo->pynode; Py_INCREF((PyObject *)(nsd->dict)); Py_INCREF((PyObject *)(nsd->node)); if (BTST(node->custom1, NODE_DYNAMIC_NEW)) { nodeAddSockets(node, node->typeinfo); node->custom1 = BCLR(node->custom1, NODE_DYNAMIC_NEW); } node->custom1 = BCLR(node->custom1, NODE_DYNAMIC_ADDEXIST); node->custom1 = BSET(node->custom1, NODE_DYNAMIC_READY); PyGILState_Release(gilstate); #endif /* WITH_PYTHON */ return; }
ALIST_API void ALActivate(Boolean isActive, ALHandle hAL) { short status; short hilite; ALPtr pAL; // Sanity check! if (hAL == nil || *hAL == nil) return; // Get current status of the active flag status = BTST((*hAL)->flags, alFActive) ? alBitSet : alBitClear; if ((isActive && status == alBitSet) || (!isActive && status == alBitClear)) return; // Do nothing, we're already the way the user wants us to be. else { // Hide the selection hiliting. _ALHiliteSelected(hAL); pAL = *hAL; if ( isActive ) { BSET(pAL->flags, alFComingActive); BSET(pAL->flags, alFActive); hilite = kControlNoPart; } else { BCLR(pAL->flags, alFActive); hilite = kControlInactivePart; // Dispose of the offscreen port if we're inactive. if (pAL->offscreenPort != nil) { DisposeGWorld(pAL->offscreenPort); (*hAL)->offscreenPort = nil; } } // Show the selection hiliting. _ALHiliteSelected(hAL); #if ALIST_USEAPPEARANCEMGR if (BTST((*hAL)->flags, alFHasAppearanceMgr) != 0) { if ((*hAL)->vScroll != nil) { if (hilite == kControlInactivePart) DeactivateControl((*hAL)->vScroll); else ActivateControl((*hAL)->vScroll); } if ((*hAL)->hScroll != nil) { if (hilite == kControlInactivePart) DeactivateControl((*hAL)->hScroll); else ActivateControl((*hAL)->hScroll); } } else #endif { if ((*hAL)->vScroll != nil) HiliteControl((*hAL)->vScroll, hilite); if ((*hAL)->hScroll != nil) HiliteControl((*hAL)->hScroll, hilite); } ALUpdate( nil, hAL ); } } // ALActivate
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ WEFastSetStyle // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // Sets the style without making an undo entry and can effect any text range, not just the selection OSErr WEFastSetStyle( WEStyleMode mode, const TextStyle *ts, SInt32 inStart, SInt32 inEnd, WEHandle hWE) { WEPtr pWE; WEActionHandle hAction; ScriptCode fontScript; Boolean saveWELock; OSErr err; // lock the WE record saveWELock = _WESetHandleLock((Handle) hWE, true); pWE = *hWE; // return an error code if this instance is read-only err = weReadOnlyErr; if (BTST(pWE->features, weFReadOnly)) { goto cleanup; } // stop any ongoing inline input session WEStopInlineSession(hWE); if (BTST(pWE->features, weFMonoStyled)) { // MONOSTYLED TEXT // apply the change to the whole text, not just to the selection range if ((err = _WESetStyleRange(0, pWE->textLength, mode, (WETextStyle *) ts, hWE)) != noErr) { goto cleanup; } // invalidate the null style record BCLR(pWE->flags, weFUseNullStyle); // redraw the text if ((err = _WERedraw(0, pWE->textLength, hWE)) != noErr) { goto cleanup; } } else if (inStart == inEnd) { // MULTISTYLED TEXT; NULL SELECTION // first make sure the nullStyle field contains valid information _WESynchNullStyle(hWE); // apply style changes to the nullStyle record _WECopyStyle((WETextStyle *) ts, &pWE->nullStyle.runStyle, pWE->nullStyle.runStyle.tsFace, mode); // special case: if this instance is empty, propagate the // change to the style table (this avoids some subtle problems) if (pWE->textLength == 0) { if ((err = _WESetStyleRange(0, 0, weDoAll + weDoReplaceFace, &pWE->nullStyle.runStyle, hWE)) != noErr) { goto cleanup; } } #if !WASTE_NO_SYNCH // if the font was altered, synchronize the keyboard script if (BTST(pWE->flags, weFNonRoman) && (mode & weDoFont)) { fontScript = FontToScript(pWE->nullStyle.runStyle.tsFont); if (fontScript != GetScriptManagerVariable(smKeyScript)) { KeyScript(fontScript); } } #endif } else { // MULTISTYLED TEXT; NON-EMPTY SELECTION // increment modification count pWE->modCount++; // check for "smart" font modes if (BTST(pWE->flags, weFNonRoman) && ((mode & weDoSmartFont) == weDoSmartFont)) { if ((err = _WESmartSetFont(mode, ts, hWE)) != noErr) { goto cleanup; } mode &= ~weDoFont; } // set the style of the selection range if ((err = _WESetStyleRange(inStart,inEnd, mode, (WETextStyle *) ts, hWE)) != noErr) { goto cleanup; } // and redraw the text if ((err = _WERedraw(inStart,inEnd, hWE)) != noErr) { goto cleanup; } } // clear the result code err = noErr; cleanup: // unlock the WE record _WESetHandleLock((Handle) hWE, saveWELock); // return result code return err; }
/* * Process an input character, with input processing * return -1, if queue full. */ int ttinput(int c, TTY tp) { USHORT lflag = tp->t_lflag; char far *cc = tp->t_cc; CQ rq = &tp->inq; int nocan = ISCLR(lflag,ICANON); int ret = 0; /* only 8 or 7 bits */ c &= (tp->t_iflag & ISTRIP ? 0x7f : 0xff); /* filter out CR LF sequences, store as LF only */ if (c==0x0d) { if (ISSET(tp->t_iflag, IGNCR)) // Ignore CR on input { BSET(tp->state,ST_CRSEEN); return 0; } else if (ISSET(tp->t_iflag, ICRNL)) // Translate CR -> NR on input c = 0x0a; } else if (c != 0x0a && ISSET(tp->state,ST_CRSEEN)) { /* out of band CR, ok */ BCLR(tp->state,ST_CRSEEN); if (putc(0x0d,rq) < 0) return -1; if (nocan) ret = ttecho(0x0d, tp); } else if ( c == 0x0a && ISSET(tp->t_iflag, INLCR)) { BCLR(tp->state, ST_CRSEEN); c = 0x0d; } else if (ISCLR(lflag,EXTPROC)) { BCLR(tp->state,ST_CRSEEN); /* internal processing */ if (ISSET(lflag,ISIG)) { if (CCEQ(cc[VINTR],c) /*|| CCEQ(cc[VQUIT],c)*/) { if (ISCLR(lflag,NOFLSH)) ttflush(tp,3); ttecho(c,tp); pgsignal(tp->pgrp, SIGINT); goto endproc; } } } else /* else was an LF or no CRSEEN */ BCLR(tp->state,ST_CRSEEN); if (ret >= 0) { /* regular char or CR/LF: put in queue */ if (putc(c,rq) >= 0) { if (nocan) ret = ttecho(c,tp); } } endproc: /* reaches here if something has been processed */ ttstart(tp); return ret; }