void ClientSession::EncodeChanges( PyDict* into ) { PyDict::const_iterator cur, end; cur = mSession->begin(); end = mSession->end(); for(; cur != end; cur++) { PyString* str = cur->first->AsString(); PyTuple* value = cur->second->AsTuple(); PyRep* last = value->GetItem( 0 ); PyRep* current = value->GetItem( 1 ); if( last->hash() != current->hash() ) { // Duplicate tuple PyTuple* t = new PyTuple( 2 ); t->SetItem( 0, last ); PyIncRef( last ); t->SetItem( 1, current ); PyIncRef( current ); into->SetItem( str, t ); PyIncRef( str ); // Update our tuple value->SetItem( 0, current ); PyIncRef( current ); } } mDirty = false; }
PyRep* ClientSession::_GetCurrent( const char* name ) const { PyTuple* v = _GetValueTuple( name ); if( v == NULL ) return NULL; return v->GetItem( 1 ); }
void ClientSession::_Set( const char* name, PyRep* value ) { PyTuple* v = _GetValueTuple( name ); if( v == NULL ) { v = new PyTuple( 2 ); v->SetItem( 0, new PyNone ); v->SetItem( 1, new PyNone ); mSession->SetItemString( name, v ); } PyRep* current = v->GetItem( 1 ); if( value->hash() != current->hash() ) { v->SetItem( 1, value ); mDirty = true; } else { PyDecRef( value ); } }