void StandardPresenter::renderField( PresentableField * pField, GfxDevice * pDevice, const Rect& canvas, const Rect& clip ) { void * pBlock = _fieldDataBlock(pField); BlockHeader * pHeader = _header(pBlock); LineInfo * pLineInfo = _lineInfo(pBlock); const Char * pCharArray = _charBuffer(pField)->chars(); Coord lineStart = canvas.pos(); lineStart.y += _textOfsY( pHeader, canvas.h ); TextAttr2 baseAttr; _baseStyle(pField)->exportAttr( _state(pField), &baseAttr ); TextAttr2 attr = baseAttr; Font_p pFont = attr.pFont; Glyphset_p pGlyphSet = pFont->getGlyphset( WG_FONT_NORMAL, attr.size); for( int i = 0 ; i < pHeader->nbLines ; i++ ) { if( lineStart.y < clip.y + clip.h && lineStart.y + pLineInfo->height > clip.y ) { lineStart.x = canvas.x + _lineOfsX( pLineInfo, canvas.w ); const Char * pChars = pCharArray + pLineInfo->offset; Glyph_p pGlyph; Glyph_p pPrevGlyph; Coord pos = lineStart; pos.y += pLineInfo->base; for( int x = 0 ; x < pLineInfo->length ; x++ ) { // TODO: Include handling of special characters // TODO: Support char-style changes. pGlyph = pGlyphSet->getGlyph(pChars->getGlyph(),attr.size); if( pGlyph ) { const GlyphBitmap * pBitmap = pGlyph->getBitmap(); pDevice->clipBlit( clip, pBitmap->pSurface, pBitmap->rect, pos.x + pBitmap->bearingX, pos.y + pBitmap->bearingY ); pos.x += pGlyph->advance(); if( pPrevGlyph ) pos.x += pGlyphSet->getKerning(pPrevGlyph, pGlyph, attr.size); } else if( pChars->getGlyph() == 32 ) pos.x += pGlyphSet->getWhitespaceAdvance( attr.size ); pPrevGlyph = pGlyph; pChars++; } } lineStart.y += pLineInfo->spacing; pLineInfo++; } }
// methods BlockLowPassVector(SuperBlock *parent, const char *name) : Block(parent, name), _state(), _fCut(this, "") // only one parameter, no need to name { for (size_t i = 0; i < M; i++) { _state(i) = 0.0f / 0.0f; } }
void StandardPresenter::addField( PresentableField * pField ) { CharBuffer * pBuffer = _charBuffer(pField); int nLines = _countLines( pBuffer ); _setFieldDataBlock(pField,0); // Make sure pointer is null for the realloc call. void * pBlock = _reallocBlock(pField,nLines); _updateLineInfo( _header(pBlock), _lineInfo(pBlock), pBuffer, _baseStyle(pField), _state(pField) ); _updatePreferredSize( _header(pBlock), _lineInfo(pBlock) ); }
void StandardPresenter::onRefresh( PresentableField * pField ) { CharBuffer * pBuffer = _charBuffer(pField); int nLines = _countLines( pBuffer ); void * pBlock = _fieldDataBlock(pField); if( !pBlock || _header(pBlock)->nbLines != nLines ) pBlock = _reallocBlock(pField,nLines); _updateLineInfo( _header(pBlock), _lineInfo(pBlock), pBuffer, _baseStyle(pField), _state(pField) ); _updatePreferredSize( _header(pBlock), _lineInfo(pBlock) ); }
void Machine::process() { std::unique_lock<std::mutex> lock( _mutexQueueEvents ); auto queue = _eventsQueue; while( _eventsQueue.empty() == false ) _eventsQueue.pop(); lock.unlock(); while( queue.size() > 0 ) { Event& event = *queue.front(); Tag nextState = _currentState->process( event ); auto iState = _state( nextState ); if( _isvalid( iState ) ) { _set_state( *iState ); } queue.pop(); } }
MY_BEGIN_ALLOW_THREADS(self->tstate); ret = SSL_renegotiate(self->ssl); MY_END_ALLOW_THREADS(self->tstate); if (PyErr_Occurred()) { flush_error_queue(); return NULL; } return PyLong_FromLong((long)ret); } static char ssl_Connection_do_handshake_doc[] = "\n\ Perform an SSL handshake (usually called after renegotiate() or one of\n\ set_*_state()). This can raise the same exceptions as send and recv.\n\ \n\ @return: None.\n\ "; static PyObject * ssl_Connection_do_handshake(ssl_ConnectionObj *self, PyObject *args) { int ret, err; if (!PyArg_ParseTuple(args, ":do_handshake")) return NULL; MY_BEGIN_ALLOW_THREADS(self->tstate); ret = SSL_do_handshake(self->ssl); MY_END_ALLOW_THREADS(self->tstate);
State& Machine::state( const Tag & name ) { auto i = _state( name ); assert( _isvalid( i ) ); return **i; }
State& Machine::add_state( const Tag & nameState, const CallBack & onActivate ) { assert( _isvalid( _state( nameState ) ) == false ); return add_state<State>( nameState, onActivate ); }
bool Machine::is_exist_state( const Tag & name )const { return _isvalid( _state( name ) ); }
bool luaengine::eval(const core::string & code) { return _state(code.c_str()); }
static pair_t create_state (uint_fast64_t stage_number, count_t count) { LOOM_ASSERT_LT(stage_number, max_stage_count); LOOM_ASSERT_LE(count, 0xFFFFUL); return _state(stage_number, count); }
static void static_test () { static_assert(get_count(_state(0, 1234)) == 1234, "fail"); static_assert(get_count(_state(1, 1234)) == 1234, "fail"); static_assert(get_count(_state(2, 1234)) == 1234, "fail"); static_assert(get_count(_state(3, 1234)) == 1234, "fail"); static_assert(get_count(_state(4, 1234)) == 1234, "fail"); static_assert(get_stage(_state(0, 1234)) == get_stage(_state(0, 5679)), "fail"); static_assert(get_stage(_state(1, 1234)) == get_stage(_state(1, 5679)), "fail"); static_assert(get_stage(_state(2, 1234)) == get_stage(_state(2, 5679)), "fail"); static_assert(get_stage(_state(3, 1234)) == get_stage(_state(3, 5679)), "fail"); static_assert(_state(0, 1234) != _state(1, 1234), "fail"); static_assert(_state(0, 1234) != _state(2, 1234), "fail"); static_assert(_state(0, 1234) != _state(3, 1234), "fail"); static_assert(_state(0, 1234) != _state(4, 1234), "fail"); static_assert(_state(1, 1234) != _state(2, 1234), "fail"); static_assert(_state(1, 1234) != _state(3, 1234), "fail"); static_assert(_state(1, 1234) != _state(4, 1234), "fail"); static_assert(_state(2, 1234) != _state(3, 1234), "fail"); static_assert(_state(2, 1234) != _state(4, 1234), "fail"); static_assert(_state(3, 1234) != _state(4, 1234), "fail"); }