int SocketEngine::DispatchEvents() { timeval tval; tval.tv_sec = 1; tval.tv_usec = 0; fd_set rfdset = ReadSet, wfdset = WriteSet, errfdset = ErrSet; int sresult = select(MaxFD + 1, &rfdset, &wfdset, &errfdset, &tval); ServerInstance->UpdateTime(); for (int i = 0, j = sresult; i <= MaxFD && j > 0; i++) { int has_read = FD_ISSET(i, &rfdset), has_write = FD_ISSET(i, &wfdset), has_error = FD_ISSET(i, &errfdset); if (!(has_read || has_write || has_error)) continue; --j; EventHandler* ev = GetRef(i); if (!ev) continue; if (has_error) { stats.ErrorEvents++; socklen_t codesize = sizeof(int); int errcode = 0; if (getsockopt(i, SOL_SOCKET, SO_ERROR, (char*)&errcode, &codesize) < 0) errcode = errno; ev->HandleEvent(EVENT_ERROR, errcode); continue; } if (has_read) { stats.ReadEvents++; ev->SetEventMask(ev->GetEventMask() & ~FD_READ_WILL_BLOCK); ev->HandleEvent(EVENT_READ); if (ev != GetRef(i)) continue; } if (has_write) { stats.WriteEvents++; int newmask = (ev->GetEventMask() & ~(FD_WRITE_WILL_BLOCK | FD_WANT_SINGLE_WRITE)); SocketEngine::OnSetEvent(ev, ev->GetEventMask(), newmask); ev->SetEventMask(newmask); ev->HandleEvent(EVENT_WRITE); } } return sresult; }
int KQueueEngine::DispatchEvents() { ts.tv_nsec = 0; ts.tv_sec = 1; int i = kevent(EngineHandle, NULL, 0, &ke_list[0], ke_list.size(), &ts); ServerInstance->UpdateTime(); if (i < 0) return i; TotalEvents += i; for (int j = 0; j < i; j++) { struct kevent& kev = ke_list[j]; EventHandler* eh = GetRef(kev.ident); if (!eh) continue; if (kev.flags & EV_EOF) { ErrorEvents++; eh->HandleEvent(EVENT_ERROR, kev.fflags); continue; } if (kev.filter == EVFILT_WRITE) { WriteEvents++; /* When mask is FD_WANT_FAST_WRITE or FD_WANT_SINGLE_WRITE, * we set a one-shot write, so we need to clear that bit * to detect when it set again. */ const int bits_to_clr = FD_WANT_SINGLE_WRITE | FD_WANT_FAST_WRITE | FD_WRITE_WILL_BLOCK; SetEventMask(eh, eh->GetEventMask() & ~bits_to_clr); eh->HandleEvent(EVENT_WRITE); if (eh != GetRef(kev.ident)) // whoops, deleted out from under us continue; } if (kev.filter == EVFILT_READ) { ReadEvents++; SetEventMask(eh, eh->GetEventMask() & ~FD_READ_WILL_BLOCK); eh->HandleEvent(EVENT_READ); } } return i; }
GLint HoeFormatX(HOEFORMAT format) { switch (format) { case HOE_A8R8G8B8: case HOE_B8G8R8X8: case HOE_R8G8B8A8: return GetRef()->ext.ARB_texture_compression ? GL_COMPRESSED_RGBA:GL_RGBA8; case HOE_R8G8B8: return GetRef()->ext.ARB_texture_compression ? GL_COMPRESSED_RGB:GL_RGB8; default: Con_Print("warning: %s format not convert to Glformat",HoeFormatString(format)); return 0; } }
void CWCamera::DrawOnScreen() { char GlobalPosition[30]={0}; const Point3D& Pos=GetRef().GetAbsCoord(Point3D(0,0,0)); sprintf(GlobalPosition,"%5.2f %5.2f %5.2f",Pos.x(),Pos.y(),Pos.z()); Hgl::WriteText(GlobalPosition, Point2D(.30f,.75f)); //write global position }
ValueMap S_info::Get(const void *s) const { ValueMap m; for(int i = 0; i < column.GetCount(); i++) m.Add(column.GetKey(i), GetRef(s, i)); return m; }
/** * @function GetNeighbors * @brief Returns the IDs of the neighboring states of the input */ std::vector<int> Dijkstra3D::GetNeighbors( int id ) { std::vector<int> neighbors; int idx = mV[id].x; int idy = mV[id].y; int idz = mV[id].z; int nx; int ny; int nz; for( int i = 0; i < 26; i++ ) { nx = idx + mNX[i]; ny = idy + mNY[i]; nz = idz + mNZ[i]; if( nx < 0 || nx > mDimX -1 || ny < 0 || ny > mDimY -1 || nz < 0 || nz > mDimZ -1 ) { continue; } int n_id = GetRef(nx,ny,nz); if( mV[ n_id ].color == 0 || mGrid->getCell(nx,ny,nz) == 1 || mV[ n_id ].color == 3 ) { continue; } else { neighbors.push_back( n_id ); } } return neighbors; }
fwRefContainer<ComponentData> ComponentLoader::LoadComponent(const char* componentName) { auto component = m_knownComponents[componentName]; if (!component.GetRef()) { FatalError("Unknown component %s.", componentName); } if (component->IsLoaded()) { return component; } // match and resolve dependencies auto dependencies = component->GetDepends(); for (auto& dependency : dependencies) { // find the first component to provide this bool match = false; for (auto& it : m_knownComponents) { auto matchProvides = it.second->GetProvides(); for (auto& provide : matchProvides) { if (dependency.IsMatchedBy(provide)) { trace("Resolving dependency for %s by %s (%s).\n", dependency.GetString().c_str(), it.second->GetName().c_str(), provide.GetString().c_str()); auto dependencyData = LoadComponent(it.second->GetName().c_str()); component->AddDependency(dependencyData); match = true; break; } } // break if matched if (match) { break; } } if (!match && dependency.GetCategory() != "vendor") { trace("Unable to resolve dependency for %s.\n", dependency.GetString().c_str()); return nullptr; } } // load the component component->Load(); return component; }
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- AlembicCurves::AlembicCurves(SceneNodePtr eNode, AlembicWriteJob *in_Job, Abc::OObject oParent) : AlembicObject(eNode, in_Job, oParent) { MObject nRef = GetRef(); MFnNurbsCurve node(nRef); MStatus status; MObject abcCurveId = node.attribute("abcCurveId", &status); if (status == MStatus::kSuccess) { const int cId = MPlug(nRef, abcCurveId).asInt(); if (cId != 0) { this->accumRef = AlembicCurveAccumulator::GetAccumulator(cId, nRef, eNode, in_Job, oParent); return; } } const bool animTS = (GetJob()->GetAnimatedTs() > 0); mObject = AbcG::OCurves(GetMyParent(), eNode->name, animTS); mSchema = mObject.getSchema(); // create all properties Abc::OCompoundProperty comp = mSchema.getArbGeomParams(); mRadiusProperty = Abc::OFloatArrayProperty(comp, ".radius", mSchema.getMetaData(), animTS); mColorProperty = Abc::OC4fArrayProperty(comp, ".color", mSchema.getMetaData(), animTS); mFaceIndexProperty = Abc::OInt32ArrayProperty(comp, ".face_index", mSchema.getMetaData(), animTS); mVertexIndexProperty = Abc::OInt32ArrayProperty( comp, ".vertex_index", mSchema.getMetaData(), animTS); mKnotVectorProperty = Abc::OFloatArrayProperty(comp, ".knot_vector", mSchema.getMetaData(), animTS); }
bool TFxSprite::Init(str particleSystem, TFxSpriteAnimTask * task, bool reset ) { TFxSpriteRef s = GetRef(); if (reset) { mDrawnOnce = false; s->GetLPS()->NewScript(); } if (particleSystem.has_data()) { s->GetLPS()->RegisterDataSource("dLocus",&s->mEmitterLocus); s->GetLPS()->RegisterDataSource("dUp",&s->mEmitterUp); if( !s->GetLPS()->Load(particleSystem) ) { return false; } s->mName = particleSystem ; if (!task) { task = ((TFxSpriteAnimTask*)GetAnimTask()); } task->mSpriteList.insert( s ); } return true; }
tBool PopRef(int *aRef,tForthHeaderType match1, tForthHeaderType match2) { tBool matched=GetRef(aRef,match1,match2); if(matched) gRefSP++; // then pop as well. return matched; }
status_t BFileInterface::HandleMessage(int32 message, const void *data, size_t size) { CALLED(); status_t rv; switch(message) { case FILEINTERFACE_SET_REF: { const fileinterface_set_ref_request *request = (const fileinterface_set_ref_request*) data; fileinterface_set_ref_reply reply; entry_ref ref(request->device, request->directory, request->name); reply.duration = request->duration; rv = SetRef(ref, request->create, &reply.duration); request->SendReply(rv, &reply, sizeof(reply)); return B_OK; } case FILEINTERFACE_GET_REF: { const fileinterface_get_ref_request *request = (const fileinterface_get_ref_request*) data; fileinterface_get_ref_reply reply; entry_ref resultRef; rv = GetRef(&resultRef, reply.mimetype); if (rv == B_OK) { reply.device = resultRef.device; reply.directory = resultRef.directory; strcpy(reply.name, resultRef.name); } request->SendReply(rv, &reply, sizeof(reply)); return B_OK; } case FILEINTERFACE_SNIFF_REF: { const fileinterface_sniff_ref_request *request = (const fileinterface_sniff_ref_request*) data; fileinterface_sniff_ref_reply reply; entry_ref ref(request->device, request->directory, request->name); rv = SniffRef(ref, reply.mimetype, &reply.capability); request->SendReply(rv, &reply, sizeof(reply)); return B_OK; } default: return B_ERROR; } return B_ERROR; }
__declspec(dllexport) void ExecuteRootScript(const std::string& scriptBit) { auto rootWindow = Instance<NUIWindowManager>::Get()->GetRootWindow(); if (rootWindow.GetRef() && rootWindow->GetBrowser() && rootWindow->GetBrowser()->GetMainFrame()) { rootWindow->GetBrowser()->GetMainFrame()->ExecuteJavaScript(scriptBit, "internal", 1); } }
void TGgSchBs::SaveXml(const TStr& FNm){ TFOut FOut(FNm); FILE* fOut=FOut.GetFileId(); fprintf(fOut, "<GgSchBs>\n"); for (int RefN=0; RefN<GetRefs(); RefN++){ PGgSchRef Ref=GetRef(RefN); Ref->SaveXml(fOut, 1+RefN); } fprintf(fOut, "</GgSchBs>"); }
void SCH_REFERENCE::Annotate() { if( m_NumRef < 0 ) m_Ref += '?'; else { // To avoid a risk of duplicate, for power components // the ref number is 0nnn instead of nnn. // Just because sometimes only power components are annotated if( GetLibPart() && GetLibPart()->IsPower() ) m_Ref = TO_UTF8( GetRef() << "0" << m_NumRef ); else m_Ref = TO_UTF8( GetRef() << m_NumRef ); } m_RootCmp->SetRef( &m_SheetPath, FROM_UTF8( m_Ref.c_str() ) ); m_RootCmp->SetUnit( m_Unit ); m_RootCmp->SetUnitSelection( &m_SheetPath, m_Unit ); }
void S_info::Set(const void *s, int i, const Value& v) const { Ref f = GetRef(s, i); if(f.Is<bool>() && IsString(v)) { String h = v; f = !(h == "0" || IsNull(h)); } else f = v; }
void MUIDRefCache::Insert(const MUID& uid, void* pRef) { #ifdef _DEBUG if (GetRef(uid)) { _ASSERT(0); OutputDebugString("MUIDRefCache DUPLICATED Data. \n"); } #endif insert(value_type(uid, pRef)); }
void SCH_REFERENCE::Annotate() { if( m_NumRef < 0 ) m_Ref += wxChar( '?' ); else m_Ref = TO_UTF8( GetRef() << m_NumRef ); m_RootCmp->SetRef( &m_SheetPath, FROM_UTF8( m_Ref.c_str() ) ); m_RootCmp->SetUnit( m_Unit ); m_RootCmp->SetUnitSelection( &m_SheetPath, m_Unit ); }
fwRefContainer<Component> ComponentData::CreateInstance(const std::string& userData) { auto instance = CreateManualInstance(); if (instance.GetRef() && !instance->Initialize(userData)) { instance = nullptr; } return instance; }
__declspec(dllexport) CefBrowser* GetBrowser() { auto rootWindow = Instance<NUIWindowManager>::Get()->GetRootWindow(); if (!rootWindow.GetRef()) { return nullptr; } return rootWindow->GetBrowser(); }
JNIEXPORT jintArray JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getBanner(JNIEnv* env, jobject obj) { const std::vector<u32>& buffer = GetRef(env, obj)->GetBannerImage().buffer; const jsize size = static_cast<jsize>(buffer.size()); const jintArray out_array = env->NewIntArray(size); if (!out_array) return nullptr; env->SetIntArrayRegion(out_array, 0, size, reinterpret_cast<const jint*>(buffer.data())); return out_array; }
bool FolderPanel :: GetPath( BPath * path ) { entry_ref ref ; if( !GetRef( &ref ) ) return false ; BEntry ent( &ref ) ; path->SetTo( &ent ) ; return ( path->InitCheck() == B_OK ) ; }
//-------------------------------------------------------------------------------------------------- static void DelCmdHandler ( le_atServer_CmdRef_t commandRef, le_atServer_Type_t type, uint32_t parametersNumber, void* contextPtr ) { AtSession_t *atSessionPtr = (AtSession_t *)contextPtr; le_atServer_FinalRsp_t finalRsp = LE_ATSERVER_OK; le_atServer_CmdRef_t cmdRef; char param[LE_ATDEFS_PARAMETER_MAX_BYTES]; int i = 0; switch (type) { case LE_ATSERVER_TYPE_PARA: for (i = 0; i < parametersNumber && parametersNumber <= PARAM_MAX; i++) { memset(param,0,LE_ATDEFS_PARAMETER_MAX_BYTES); // get the command to delete LE_ASSERT_OK(le_atServer_GetParameter(commandRef, i, param, LE_ATDEFS_PARAMETER_MAX_BYTES)); // get its refrence cmdRef = GetRef(atSessionPtr->atCmds, atSessionPtr->cmdsCount, param); LE_DEBUG("Deleting %p => %s", cmdRef, param); // delete the command LE_ASSERT_OK(le_atServer_Delete(cmdRef)); } // send an OK final response finalRsp = LE_ATSERVER_OK; break; // this command doesn't support test and read send an ERROR final // reponse case LE_ATSERVER_TYPE_TEST: case LE_ATSERVER_TYPE_READ: finalRsp = LE_ATSERVER_ERROR; break; // an action command type to verify that AT+DEL command does exist // send an OK final response case LE_ATSERVER_TYPE_ACT: finalRsp = LE_ATSERVER_OK; break; default: LE_ASSERT(0); break; } // send final response LE_ASSERT_OK(le_atServer_SendFinalResultCode(commandRef, finalRsp, "", 0)); }
void SCH_REFERENCE::Annotate() { if( m_NumRef < 0 ) m_Ref += '?'; else { m_Ref = TO_UTF8( GetRef() << GetRefNumber() ); } m_RootCmp->SetRef( &m_SheetPath, FROM_UTF8( m_Ref.c_str() ) ); m_RootCmp->SetUnit( m_Unit ); m_RootCmp->SetUnitSelection( &m_SheetPath, m_Unit ); }
QTSS_Error HTTPSessionInterface::RegDevSession(const char* serial, UInt32 serailLen) { if((::strlen(serial) == 0) || (serailLen == 0)) return QTSS_ValueNotFound; fSessionType = qtssDeviceSession; QTSS_SetValue(this, qtssEasySesSerial, 0, serial, serailLen); fDevSerialPtr.Set( fSerial, serailLen); fDevRef.Set( fDevSerialPtr, this); OS_Error theErr = QTSServerInterface::GetServer()->GetRecordSessionMap()->Register(GetRef()); //printf("[line:%d]HTTPSessionInterface::RegDevSession theErr = %d\n",__LINE__, theErr); if(theErr == OS_NoErr) fAuthenticated = true; return theErr; }
/* Recursively print a parse tree as code */ void PrintParseTree(VyParseTree* tree){ int treeType = tree->type; /* If it is a list, then print a parenthesized list */ if(treeType == TREE_LIST){ PrintListGeneric(tree, '(', ')'); } /* Print a reference separated by a colon */ else if(treeType == TREE_REF){ PrintParseTree(GetObj(tree)); /* Delete the previous space before adding the colon */ printf("\b:"); PrintParseTree(GetRef(tree)); } /* If it is a number or identifier, just print the string */ else if(treeType == TREE_IDENT) { printf("%s ", GetStrData(tree)); } else if(treeType == TREE_NUM){ PrintNumber(GetNumberData(tree)); /* Print a space so that the backspace doesn't delete part of the number */ printf(" "); } /* Print strings enclosed in quotes */ else if(treeType == TREE_STR){ printf("\""); printf("%s", GetStrData(tree)); printf("\""); printf("\""); } /* If it is an error, print the error */ else if(treeType == TREE_ERROR){ printf("\n---------------------------------\n"); printf("Error: %s", tree->data->error.message); printf("\n---------------------------------\n"); } else{ printf("\n\n\nWarning: Incorrect parse tree node type: %d! \n\n\n", treeType); } }
bool Config::CheckTexture(dword &width,dword &height,HOEFORMAT &format) { #ifdef _HOE_OPENGL_ if (format == HOE_X8R8G8B8) format = HOE_R8G8B8; // resize to 2*n dword w1=1,h1=1; while (w1 < width) w1 <<= 1; while (h1 < height) h1 <<= 1; width = w1; height = h1; #endif #ifdef _HOE_D3D_ switch (format) { case HOE_A8R8G8B8: case HOE_R8G8B8A8: format = HOE_B8G8R8A8; break; case HOE_X8R8G8B8: case HOE_R8G8B8: format = HOE_B8G8R8X8; break; case HOE_L8A8: if (GetRef()->IsTextureFormatOk(HOE_L8A8)) format = HOE_L8A8; else format = HOE_B8G8R8X8; break; // povolene formaty case HOE_DXT1: case HOE_DXT2: case HOE_DXT3: case HOE_DXT4: case HOE_DXT5: case HOE_U8V8: break; default: assert(!"warning: check format"); }; #endif return false; }
void SocketEngine::DispatchTrialWrites() { std::vector<int> working_list; working_list.reserve(trials.size()); working_list.assign(trials.begin(), trials.end()); trials.clear(); for(unsigned int i=0; i < working_list.size(); i++) { int fd = working_list[i]; EventHandler* eh = GetRef(fd); if (!eh) continue; int mask = eh->event_mask; eh->event_mask &= ~(FD_ADD_TRIAL_READ | FD_ADD_TRIAL_WRITE); if ((mask & (FD_ADD_TRIAL_READ | FD_READ_WILL_BLOCK)) == FD_ADD_TRIAL_READ) eh->HandleEvent(EVENT_READ, 0); if ((mask & (FD_ADD_TRIAL_WRITE | FD_WRITE_WILL_BLOCK)) == FD_ADD_TRIAL_WRITE) eh->HandleEvent(EVENT_WRITE, 0); } }
CDbConn CDbLib::Connect(char *dsn) { char *uid, *pwd, *etc; ParseDSN(dsn, dsn, uid, pwd, etc); qObjTSRef ts = GetRef(); if (myHENV) { TRACE("sql: spawning connection\n"); SQLHDBC hdbc; SQLRETURN nResult; if ((nResult = SQLAllocHandle(SQL_HANDLE_DBC, myHENV, &hdbc) != SQL_SUCCESS)) { return CDbConn(this, (SQLHDBC)NULL); } if (etc && *etc) { CStr connIn; connIn = CStr("DSN=")<<dsn<<";UID="<<uid<<";PWD="<<pwd<<';'<<etc; CStr connOut(1024); short totLen; nResult = SQLDriverConnect(hdbc, NULL, (LPSQLC) connIn.SafeP(), connIn.Length(), (LPSQLC) connOut.SafeP(), connOut.Length(), &totLen, SQL_DRIVER_NOPROMPT); } else { nResult = SQLConnect(hdbc, (LPSQLC) dsn, SQL_NTS, (LPSQLC) uid, SQL_NTS, (LPSQLC) pwd, SQL_NTS); } // if failed to connect, free the allocated hdbc before return if (!SQL_SUCCEEDED(nResult)) { CDbConn conn(this, hdbc); conn.SetError(nResult); return conn; } return CDbConn(this, hdbc); } else { return CDbConn(this, (SQLHDBC)NULL); } }
/* Check and print errors */ int CheckAndPrintErrors(VyParseTree* tree){ int treeType = tree->type; int error = 0; if(treeType == TREE_LIST){ /* Check each element recursively */ int i; for(i = 0; i < ListTreeSize(tree); i++){ VyParseTree* next = GetListData(tree,i); /* Check the sub nodes for errors */ int listError = CheckAndPrintErrors(next); if(listError) error = 1; } } /* Check each piece of the ref */ else if(treeType == TREE_REF){ int objError = CheckAndPrintErrors(GetObj(tree)); int refError = CheckAndPrintErrors(GetRef(tree)); if(objError || refError) error = 1; } /* If it is an error, print the error */ else if(treeType == TREE_ERROR){ printf("\n\n"); printf("------- Parsing Error -------\n"); printf("Position: "); PrintPosition(tree->pos); printf("\n"); printf(tree->data->error.message); printf("\n-----------------------------"); error = 1; } return error; }
bool IOCPEngine::HasFd(int fd) { return (GetRef(fd) != 0); }