// Get SWindow pointer from handle SWindow* SWindowMgr::GetWindow(SWND swnd) { if(!swnd) return NULL; SWindow *pRet=NULL; ::EnterCriticalSection(&getSingleton().m_lockWndMap); getSingleton().GetKeyObject(swnd,pRet); ::LeaveCriticalSection(&getSingleton().m_lockWndMap); return pRet; }
void ChunkManager::unregisterPlanet(Planet *p) { //Remove planet from planetList, and delete ChunkManager if no more planets exist getSingleton().planetList.remove(p); if (getSingleton().planetList.empty()) { delete singletonPtr; singletonPtr = NULL; } }
// Destroy DuiWindow BOOL SWindowMgr::DestroyWindow(SWND swnd) { ::EnterCriticalSection(&getSingleton().m_lockWndMap); BOOL bRet=getSingleton().RemoveKeyObject(swnd); STimer2::KillTimer(swnd); ::LeaveCriticalSection(&getSingleton().m_lockWndMap); return bRet; }
// Specify a handle to a SWindow SWND SWindowMgr::NewWindow(SWindow *pSwnd) { SASSERT(pSwnd); ::EnterCriticalSection(&getSingleton().m_lockWndMap); SWND swndNext = ++ getSingleton().m_hNextWnd; getSingleton().AddKeyObject(swndNext,pSwnd); ::LeaveCriticalSection(&getSingleton().m_lockWndMap); return swndNext; }
PyObject* Level::setSkyBox(PyObject *self, PyObject* args){ char* newMat; float dist; PyArg_ParseTuple(args, "sf", &newMat, &dist); if (strlen(newMat) > 0){ getSingleton()->getSceneManager()->setSkyBox(true, newMat, dist); }else{ getSingleton()->getSceneManager()->setSkyBox(false, newMat, dist); } Py_RETURN_NONE; }
static SFC::DT getDominantType( SFC::DT dt1, SFC::DT dt2 ) { SFC::DT baseDT1 = getSingleton().getBaseDT( dt1 ); SFC::DT baseDT2 = getSingleton().getBaseDT( dt2 ); assert( baseDT1.type() == SFC::BasicType::meta && baseDT2.type() == SFC::BasicType::meta ); SFC::BasicType basicType1 = SFC::BasicType::Cast( baseDT1 ); SFC::BasicType basicType2 = SFC::BasicType::Cast( baseDT2 ); std::string dominantTypeName = TypePrecedence::getDominantType( basicType1.name(), basicType2.name() ); return static_cast< std::string >( basicType1.name() ) == dominantTypeName ? basicType1 : basicType2; }
PyObject* Level::setSecondLifeHud(PyObject *self, PyObject* args){ GameObject* target; PyArg_ParseTuple(args, "l", &target); if (target != NULL){ getSingleton()->mHud->setSecondLifeTarget(target); }else{ getSingleton()->mHud->clearSecondLifeTarget(); } Py_RETURN_NONE; //return rv; }
Widget * WidgetManager::Reflect(pugi::xml_node element) { WidgetManager* ins = getSingleton(); WidgetPointerMap::iterator wpmi = ins->widgetHeap.find(element); if (wpmi != ins->widgetHeap.end()) { return wpmi->second; } else { WidgetConstuctionMap::iterator i = ins->constructMap.find(element.name()); _ASSERTE(i != getSingleton()->constructMap.end()); Widget *w = i->second(element); ins->widgetHeap.insert(std::make_pair(element, w)); return w; } }
void THSoundEffects::_onChannelFinish(int iChannel) { THSoundEffects *pThis = getSingleton(); if(pThis == NULL) return; pThis->releaseChannel(iChannel); }
void THSoundEffects::_onChannelFinish(int iChannel) { THSoundEffects *pThis = getSingleton(); if(pThis == NULL) return; pThis->m_iChannelStatus |= (1 << iChannel); }
void ChunkManager::registerPlanet(Planet *p) { //Create ChunkManager if none exists, and add planet to planetList if (singletonPtr == NULL) singletonPtr = new ChunkManager(); getSingleton().planetList.push_back(p); }
PyObject* Level::addXmlBranch(PyObject *self, PyObject* args){ char* objName; PyArg_ParseTuple(args, "s", &objName); string s = objName; s = "<level>"+s+"</level>"; getSingleton()->getCurrentSegment()->pushObjects(&XML(s)); Py_RETURN_NONE; //return PyFloat_FromDouble(getSingleton()->mCurrentSegment->getTimeDelta()); }
int MemPool::SelfTest() { Log::printf("Testing MemPool...\n"); void* allocated[2][MEMPOOL_TABLE_SIZE]; for (int size=1;size<MEMPOOL_TABLE_SIZE;size++) { allocated[0][size]=getSingleton()->malloc(size); allocated[1][size]=getSingleton()->malloc(size); } for (int size=1;size<MEMPOOL_TABLE_SIZE;size++) { getSingleton()->free(size,allocated[1][size]); getSingleton()->free(size,allocated[0][size]); } for (int size=1;size<MEMPOOL_TABLE_SIZE;size++) { void* temp1=getSingleton()->malloc(size); void* temp2=getSingleton()->malloc(size); XgeReleaseAssert(temp1==allocated[0][size]); XgeReleaseAssert(temp2==allocated[1][size]); } return 0; }
void CBarcode1::enumerate(MethodResultJni& res) { RAWTRACE("enumerate"); JNIEnv *env = jniInit(); if (!env) { RAWLOG_ERROR("JNI initialization failed"); return; } jhobject jhSingleton = getSingleton(env); env->CallVoidMethod(jhSingleton.get(), s_midEnumerate, static_cast<jobject>(res)); }
rho::String CBarcode1::getDefaultID() { RAWTRACE("getDefaultID"); JNIEnv *env = jniInit(); if (!env) { RAWLOG_ERROR("JNI initialization failed"); return rho::String(); } jhobject jhSingleton = getSingleton(env); jhstring res = static_cast<jstring>(env->CallObjectMethod(jhSingleton.get(), s_midGetDefaultID)); return rho_cast<rho::String>(env, res); }
void CLightsensorBase::setDefaultID(const rho::String& id) { LOG(TRACE) + "setDefaultID: " + id; JNIEnv *env = jniInit(); if (!env) { LOG(FATAL) + "JNI initialization failed"; return; } jhobject instance = getSingleton(env); jhstring jhId = rho_cast<jstring>(env, id); env->CallVoidMethod(instance.get(), s_midSetDefaultID, jhId.get()); }
rho::String CLightsensorBase::getDefaultID() { LOG(TRACE) + "getDefaultID"; JNIEnv *env = jniInit(); if (!env) { LOG(FATAL) + "JNI initialization failed"; return rho::String(); } jhobject jhSingleton = getSingleton(env); jhstring res = static_cast<jstring>(env->CallObjectMethod(jhSingleton.get(), s_midGetDefaultID)); return rho_cast<rho::String>(env, res); }
PyObject* Level::getObjectPtr(PyObject *self, PyObject* args){ GameObject* ptr; char* objName; PyArg_ParseTuple(args, "s", &objName); ptr = getSingleton()->getCurrentSegment()->getObjectByName(objName); if (ptr == NULL){ throw("Python : Object not found : "+(string)(objName)); } PyObject* rv = PyLong_FromLong((long)ptr); return rv; }
void CBarcode1::setDefaultID(const rho::String& id) { RAWTRACE1("setDefaultID(id = \"%s\")", id.c_str()); JNIEnv *env = jniInit(); if (!env) { RAWLOG_ERROR("JNI initialization failed"); return; } jhobject instance = getSingleton(env); jhstring jhId = rho_cast<jstring>(env, id); env->CallVoidMethod(instance.get(), s_midSetDefaultID, jhId.get()); }
Registry *Registry::getSingletonPtr() { return &getSingleton(); }
Mad::Manager::Resource* Mad::Manager::Resource::initialise() { return getSingleton(); }
ParseConsumer* LuaManager::getParseConsumer() { return getSingleton().consumer; }
VOID SNotifyCenter::OnTimer( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime ) { getSingleton().ExecutePendingEvents(); }
PyObject* Level::getTimeDelta(PyObject *self, PyObject* args){ return PyFloat_FromDouble(getSingleton()->mCurrentSegment->getTimeDelta()); }
// Get style object from pool by class name BOOL DuiStylePool::GetStyle(LPCSTR lpszName, DuiStyle& style) { if(!getSingleton().HasKey(lpszName)) return FALSE; style=getSingleton().GetKeyObject(lpszName); return TRUE; }
llvm::Expected<std::vector<CodeTemplate>> UopsSnippetGenerator::generateCodeTemplates(const Instruction &Instr) const { CodeTemplate CT; const llvm::BitVector *ScratchSpaceAliasedRegs = nullptr; if (Instr.hasMemoryOperands()) { const auto &ET = State.getExegesisTarget(); CT.ScratchSpacePointerInReg = ET.getScratchMemoryRegister(State.getTargetMachine().getTargetTriple()); if (CT.ScratchSpacePointerInReg == 0) return llvm::make_error<BenchmarkFailure>( "Infeasible : target does not support memory instructions"); ScratchSpaceAliasedRegs = &State.getRATC().getRegister(CT.ScratchSpacePointerInReg).aliasedBits(); // If the instruction implicitly writes to ScratchSpacePointerInReg , abort. // FIXME: We could make a copy of the scratch register. for (const auto &Op : Instr.Operands) { if (Op.isDef() && Op.isImplicitReg() && ScratchSpaceAliasedRegs->test(Op.getImplicitReg())) return llvm::make_error<BenchmarkFailure>( "Infeasible : memory instruction uses scratch memory register"); } } const AliasingConfigurations SelfAliasing(Instr, Instr); InstructionTemplate IT(Instr); if (SelfAliasing.empty()) { CT.Info = "instruction is parallel, repeating a random one."; CT.Instructions.push_back(std::move(IT)); instantiateMemoryOperands(CT.ScratchSpacePointerInReg, CT.Instructions); return getSingleton(std::move(CT)); } if (SelfAliasing.hasImplicitAliasing()) { CT.Info = "instruction is serial, repeating a random one."; CT.Instructions.push_back(std::move(IT)); instantiateMemoryOperands(CT.ScratchSpacePointerInReg, CT.Instructions); return getSingleton(std::move(CT)); } const auto TiedVariables = getVariablesWithTiedOperands(Instr); if (!TiedVariables.empty()) { CT.Info = "instruction has tied variables, using static renaming."; CT.Instructions = generateSnippetUsingStaticRenaming( State, IT, TiedVariables, ScratchSpaceAliasedRegs); instantiateMemoryOperands(CT.ScratchSpacePointerInReg, CT.Instructions); return getSingleton(std::move(CT)); } const auto &ReservedRegisters = State.getRATC().reservedRegisters(); // No tied variables, we pick random values for defs. llvm::BitVector Defs(State.getRegInfo().getNumRegs()); for (const auto &Op : Instr.Operands) { if (Op.isReg() && Op.isExplicit() && Op.isDef() && !Op.isMemory()) { auto PossibleRegisters = Op.getRegisterAliasing().sourceBits(); remove(PossibleRegisters, ReservedRegisters); // Do not use the scratch memory address register. if (ScratchSpaceAliasedRegs) remove(PossibleRegisters, *ScratchSpaceAliasedRegs); assert(PossibleRegisters.any() && "No register left to choose from"); const auto RandomReg = randomBit(PossibleRegisters); Defs.set(RandomReg); IT.getValueFor(Op) = llvm::MCOperand::createReg(RandomReg); } } // And pick random use values that are not reserved and don't alias with defs. const auto DefAliases = getAliasedBits(State.getRegInfo(), Defs); for (const auto &Op : Instr.Operands) { if (Op.isReg() && Op.isExplicit() && Op.isUse() && !Op.isMemory()) { auto PossibleRegisters = Op.getRegisterAliasing().sourceBits(); remove(PossibleRegisters, ReservedRegisters); // Do not use the scratch memory address register. if (ScratchSpaceAliasedRegs) remove(PossibleRegisters, *ScratchSpaceAliasedRegs); remove(PossibleRegisters, DefAliases); assert(PossibleRegisters.any() && "No register left to choose from"); const auto RandomReg = randomBit(PossibleRegisters); IT.getValueFor(Op) = llvm::MCOperand::createReg(RandomReg); } } CT.Info = "instruction has no tied variables picking Uses different from defs"; CT.Instructions.push_back(std::move(IT)); instantiateMemoryOperands(CT.ScratchSpacePointerInReg, CT.Instructions); return getSingleton(std::move(CT)); }