void AssignErrorValue( UDFContext *context) { if (context->theFunction->unknownReturnValueType & BOOLEAN_TYPE) { mCVSetBoolean(context->returnValue,false); } else if (context->theFunction->unknownReturnValueType & STRING_TYPE) { mCVSetString(context->returnValue,""); } else if (context->theFunction->unknownReturnValueType & SYMBOL_TYPE) { mCVSetSymbol(context->returnValue,"nil"); } else if (context->theFunction->unknownReturnValueType & INTEGER_TYPE) { mCVSetInteger(context->returnValue,0); } else if (context->theFunction->unknownReturnValueType & FLOAT_TYPE) { mCVSetFloat(context->returnValue,0.0); } else if (context->theFunction->unknownReturnValueType & MULTIFIELD_TYPE) { EnvSetMultifieldErrorValue(context->environment,context->returnValue); } else if (context->theFunction->unknownReturnValueType & INSTANCE_NAME_TYPE) { mCVSetInstanceName(context->returnValue,"nil"); } else if (context->theFunction->unknownReturnValueType & FACT_ADDRESS_TYPE) { mCVSetFactAddress(context->returnValue,&FactData(context->environment)->DummyFact); } else if (context->theFunction->unknownReturnValueType & INSTANCE_ADDRESS_TYPE) { mCVSetInstanceAddress(context->returnValue,&InstanceData(context->environment)->DummyInstance); } else if (context->theFunction->unknownReturnValueType & EXTERNAL_ADDRESS_TYPE) { CVSetExternalAddress(context->returnValue,NULL,0); } else { mCVSetVoid(context->returnValue); } }
/**************************************************** NAME : InstancesPurge DESCRIPTION : Removes all instances INPUTS : None RETURNS : TRUE if all instances deleted, FALSE otherwise SIDE EFFECTS : The instance hash table is cleared NOTES : None ****************************************************/ globle intBool InstancesPurge( void *theEnv) { DestroyAllInstances(theEnv); CleanupInstances(theEnv); return((InstanceData(theEnv)->InstanceList != NULL) ? FALSE : TRUE); }
/**************************************************** NAME : InstancesPurge DESCRIPTION : Removes all instances INPUTS : None RETURNS : true if all instances deleted, false otherwise SIDE EFFECTS : The instance hash table is cleared NOTES : None ****************************************************/ bool InstancesPurge( void *theEnv) { DestroyAllInstances(theEnv); CleanupInstances(theEnv); return((InstanceData(theEnv)->InstanceList != NULL) ? false : true); }
void DataKeeper::DoSaveUsers() { ModesExts currdata; const user_hash& users = ServerInstance->Users->GetUsers(); for (user_hash::const_iterator i = users.begin(); i != users.end(); ++i) { User* const user = i->second; // Serialize user modes for (size_t j = 0; j < handledmodes[MODETYPE_USER].size(); j++) { ModeHandler* mh = handledmodes[MODETYPE_USER][j].mh; if (user->IsModeSet(mh)) currdata.modelist.push_back(InstanceData(j, mh->GetUserParameter(user))); } // Serialize all extensions attached to the User SaveExtensions(user, currdata.extlist); // Add to list if the user has any modes or extensions set that we are interested in, otherwise we don't // have to do anything with this user when restoring if (!currdata.empty()) { userdatalist.push_back(UserData(user->uuid)); userdatalist.back().swap(currdata); } } }
void DataKeeper::SaveMemberData(Channel* chan, std::vector<OwnedModesExts>& memberdatalist) { ModesExts currdata; const Channel::MemberMap& users = chan->GetUsers(); for (Channel::MemberMap::const_iterator i = users.begin(); i != users.end(); ++i) { Membership* const memb = i->second; for (size_t j = 0; j < handledmodes[MODETYPE_CHANNEL].size(); j++) { ModeHandler* mh = handledmodes[MODETYPE_CHANNEL][j].mh; if ((mh->IsPrefixMode()) && (memb->hasMode(mh->GetModeChar()))) currdata.modelist.push_back(InstanceData(j, memb->user->uuid)); // Need to pass the user's uuid to the mode parser to set the mode later } SaveExtensions(memb, currdata.extlist); // Same logic as in DoSaveUsers() if (!currdata.empty()) { memberdatalist.push_back(OwnedModesExts(memb->user->uuid)); memberdatalist.back().swap(currdata); } } }
void DataKeeper::SaveListModes(Channel* chan, ListModeBase* lm, size_t index, ModesExts& currdata) { const ListModeBase::ModeList* list = lm->GetList(chan); if (!list) return; for (ListModeBase::ModeList::const_iterator i = list->begin(); i != list->end(); ++i) { const ListModeBase::ListItem& listitem = *i; currdata.modelist.push_back(InstanceData(index, listitem.mask)); } }
/**************************************************** NAME : InstancesPurge DESCRIPTION : Removes all instances INPUTS : None RETURNS : TRUE if all instances deleted, FALSE otherwise SIDE EFFECTS : The instance hash table is cleared NOTES : None ****************************************************/ globle intBool InstancesPurge( void *theEnv) { int svdepth; DestroyAllInstances(theEnv); svdepth = EvaluationData(theEnv)->CurrentEvaluationDepth; if (EvaluationData(theEnv)->CurrentEvaluationDepth == 0) EvaluationData(theEnv)->CurrentEvaluationDepth = -1; CleanupInstances(theEnv); EvaluationData(theEnv)->CurrentEvaluationDepth = svdepth; return((InstanceData(theEnv)->InstanceList != NULL) ? FALSE : TRUE); }
globle void InstanceTableUsage( void *theEnv) { unsigned long i; int instanceCounts[COUNT_SIZE]; INSTANCE_TYPE *ins; unsigned long int instanceCount, totalInstanceCount = 0; EnvArgCountCheck(theEnv,"instance-table-usage",EXACTLY,0); for (i = 0; i < COUNT_SIZE; i++) { instanceCounts[i] = 0; } /*======================================*/ /* Count entries in the instance table. */ /*======================================*/ for (i = 0; i < INSTANCE_TABLE_HASH_SIZE; i++) { instanceCount = 0; for (ins = InstanceData(theEnv)->InstanceTable[i]; ins != NULL; ins = ins->nxtHash) { instanceCount++; totalInstanceCount++; } if (instanceCount < (COUNT_SIZE - 1)) { instanceCounts[instanceCount]++; } else { instanceCounts[COUNT_SIZE - 1]++; } } /*========================*/ /* Print the information. */ /*========================*/ EnvPrintRouter(theEnv,WDISPLAY,"Total Instances: "); PrintLongInteger(theEnv,WDISPLAY,(long) totalInstanceCount); EnvPrintRouter(theEnv,WDISPLAY,"\n"); for (i = 0; i < COUNT_SIZE; i++) { PrintLongInteger(theEnv,WDISPLAY,(long) i); EnvPrintRouter(theEnv,WDISPLAY," "); PrintLongInteger(theEnv,WDISPLAY,(long) instanceCounts[i]); EnvPrintRouter(theEnv,WDISPLAY,"\n"); } }
void DataKeeper::SaveExtensions(Extensible* extensible, std::vector<InstanceData>& extdata) { const Extensible::ExtensibleStore& setexts = extensible->GetExtList(); // Position of the extension saved in the handledexts list size_t index = 0; for (std::vector<ProviderInfo>::const_iterator i = handledexts.begin(); i != handledexts.end(); ++i, index++) { ExtensionItem* const item = i->extitem; Extensible::ExtensibleStore::const_iterator it = setexts.find(item); if (it == setexts.end()) continue; std::string value = item->serialize(FORMAT_INTERNAL, extensible, it->second); // If the serialized value is empty the extension won't be saved and restored if (!value.empty()) extdata.push_back(InstanceData(index, value)); } }
void BufferedPrimitiveRenderer::RenderTempNoAANoDepth() { ID3D11DeviceContext* deviceContext = lowLevelGraphics->GetDeviceContext(); vector<InstanceData> instanceData[NumDebugPrimitiveTypes]; for(U32 i = 0; i < _countof(temporaryPrimitives); ++i) { for(auto j = 0; j < temporaryPrimitives[i].size(); ++j) { const BufferedPrimitive& bufferedPrimitive = temporaryPrimitives[i][j]; if (!bufferedPrimitive.antiAliased && !bufferedPrimitive.depthEnabled) { instanceData[i].push_back(InstanceData(bufferedPrimitive.transform, bufferedPrimitive.color)); } } } for(U32 i = 0; i < _countof(instanceData); ++i) { if (!instanceData[i].empty()) { primitivesData[i]->Bind(deviceContext, VertexChannelType::Geometry); instanceBuffer->SetData(deviceContext, instanceData[i]); instanceBuffer->Bind(deviceContext, 0, Mesh::InstanceChannelSlot); deviceContext->DrawIndexedInstanced(primitivesData[i]->GetIndexCount(), instanceData[i].size(), 0, 0, 0); } } }
void DataKeeper::DoSaveChans() { ModesExts currdata; std::vector<OwnedModesExts> currmemberdata; const chan_hash& chans = ServerInstance->GetChans(); for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i) { Channel* const chan = i->second; // Serialize channel modes for (size_t j = 0; j < handledmodes[MODETYPE_CHANNEL].size(); j++) { ModeHandler* mh = handledmodes[MODETYPE_CHANNEL][j].mh; ListModeBase* lm = mh->IsListModeBase(); if (lm) SaveListModes(chan, lm, j, currdata); else if (chan->IsModeSet(mh)) currdata.modelist.push_back(InstanceData(j, chan->GetModeParameter(mh))); } // Serialize all extensions attached to the Channel SaveExtensions(chan, currdata.extlist); // Serialize all extensions attached to and all modes set on all members of the channel SaveMemberData(chan, currmemberdata); // Same logic as in DoSaveUsers() plus we consider the modes and extensions of all members if ((!currdata.empty()) || (!currmemberdata.empty())) { chandatalist.push_back(ChanData(chan)); chandatalist.back().swap(currdata); chandatalist.back().memberdatalist.swap(currmemberdata); } } }
/********************************************************* NAME : UpdateExpression DESCRIPTION : Given a bloaded expression buffer, this routine refreshes the pointers in the expression array INPUTS : 1) a bloaded expression buffer 2) the index of the expression to refresh RETURNS : Nothing useful SIDE EFFECTS : Expression updated NOTES : None *********************************************************/ static void UpdateExpression( Environment *theEnv, void *buf, unsigned long obji) { BSAVE_EXPRESSION *bexp; unsigned long theIndex; bexp = (BSAVE_EXPRESSION *) buf; ExpressionData(theEnv)->ExpressionArray[obji].type = bexp->type; switch(bexp->type) { case FCALL: ExpressionData(theEnv)->ExpressionArray[obji].value = BloadData(theEnv)->FunctionArray[bexp->value]; break; case GCALL: #if DEFGENERIC_CONSTRUCT ExpressionData(theEnv)->ExpressionArray[obji].value = GenericPointer(bexp->value); #else ExpressionData(theEnv)->ExpressionArray[obji].value = NULL; #endif break; case PCALL: #if DEFFUNCTION_CONSTRUCT ExpressionData(theEnv)->ExpressionArray[obji].value = DeffunctionPointer(bexp->value); #else ExpressionData(theEnv)->ExpressionArray[obji].value = NULL; #endif break; case DEFTEMPLATE_PTR: #if DEFTEMPLATE_CONSTRUCT ExpressionData(theEnv)->ExpressionArray[obji].value = DeftemplatePointer(bexp->value); #else ExpressionData(theEnv)->ExpressionArray[obji].value = NULL; #endif break; case DEFCLASS_PTR: #if OBJECT_SYSTEM ExpressionData(theEnv)->ExpressionArray[obji].value = DefclassPointer(bexp->value); #else ExpressionData(theEnv)->ExpressionArray[obji].value = NULL; #endif break; case DEFGLOBAL_PTR: #if DEFGLOBAL_CONSTRUCT ExpressionData(theEnv)->ExpressionArray[obji].value = DefglobalPointer(bexp->value); #else ExpressionData(theEnv)->ExpressionArray[obji].value = NULL; #endif break; case INTEGER_TYPE: ExpressionData(theEnv)->ExpressionArray[obji].value = SymbolData(theEnv)->IntegerArray[bexp->value]; IncrementIntegerCount(ExpressionData(theEnv)->ExpressionArray[obji].integerValue); break; case FLOAT_TYPE: ExpressionData(theEnv)->ExpressionArray[obji].value = SymbolData(theEnv)->FloatArray[bexp->value]; IncrementFloatCount(ExpressionData(theEnv)->ExpressionArray[obji].floatValue); break; case INSTANCE_NAME_TYPE: #if ! OBJECT_SYSTEM ExpressionData(theEnv)->ExpressionArray[obji].type = SYMBOL_TYPE; #endif case GBL_VARIABLE: case SYMBOL_TYPE: case STRING_TYPE: ExpressionData(theEnv)->ExpressionArray[obji].value = SymbolData(theEnv)->SymbolArray[bexp->value]; IncrementLexemeCount(ExpressionData(theEnv)->ExpressionArray[obji].lexemeValue); break; #if DEFTEMPLATE_CONSTRUCT case FACT_ADDRESS_TYPE: ExpressionData(theEnv)->ExpressionArray[obji].value = &FactData(theEnv)->DummyFact; RetainFact((Fact *) ExpressionData(theEnv)->ExpressionArray[obji].value); break; #endif #if OBJECT_SYSTEM case INSTANCE_ADDRESS_TYPE: ExpressionData(theEnv)->ExpressionArray[obji].value = &InstanceData(theEnv)->DummyInstance; RetainInstance((Instance *) ExpressionData(theEnv)->ExpressionArray[obji].value); break; #endif case EXTERNAL_ADDRESS_TYPE: ExpressionData(theEnv)->ExpressionArray[obji].value = NULL; break; case VOID_TYPE: break; default: if (EvaluationData(theEnv)->PrimitivesArray[bexp->type] == NULL) break; if (EvaluationData(theEnv)->PrimitivesArray[bexp->type]->bitMap) { ExpressionData(theEnv)->ExpressionArray[obji].value = SymbolData(theEnv)->BitMapArray[bexp->value]; IncrementBitMapCount((CLIPSBitMap *) ExpressionData(theEnv)->ExpressionArray[obji].value); } break; } theIndex = bexp->nextArg; if (theIndex == ULONG_MAX) { ExpressionData(theEnv)->ExpressionArray[obji].nextArg = NULL; } else { ExpressionData(theEnv)->ExpressionArray[obji].nextArg = (struct expr *) &ExpressionData(theEnv)->ExpressionArray[theIndex]; } theIndex = bexp->argList; if (theIndex == ULONG_MAX) { ExpressionData(theEnv)->ExpressionArray[obji].argList = NULL; } else { ExpressionData(theEnv)->ExpressionArray[obji].argList = (struct expr *) &ExpressionData(theEnv)->ExpressionArray[theIndex]; } }
bool RakeResults<SampleSeq>::copy_into(FwdIter iter, FwdIter end, typename SampleSeq::PrivateMemberAccess& received_data_p) { typedef typename SampleSeq::value_type Sample; typedef OPENDDS_MAP(SubscriptionInstance*, InstanceData) InstanceMap; InstanceMap inst_map; typedef OPENDDS_SET(SubscriptionInstance*) InstanceSet; InstanceSet released_instances; for (CORBA::ULong idx = 0; iter != end && idx < max_samples_; ++idx, ++iter) { // 1. Populate the Received Data sequence ReceivedDataElement* rde = iter->rde_; if (received_data_.maximum() != 0) { if (rde->registered_data_ == 0) { received_data_p.assign_sample(idx, Sample()); } else { received_data_p.assign_sample(idx, *static_cast<Sample*>(rde->registered_data_)); } } else { received_data_p.assign_ptr(idx, rde); } // 2. Per-sample SampleInfo (not the three *_rank variables) and state SubscriptionInstance& inst = *iter->si_; inst.instance_state_.sample_info(info_seq_[idx], rde); rde->sample_state_ = DDS::READ_SAMPLE_STATE; // 3. Record some info about per-instance SampleInfo (*_rank) so that // we can fill in the ranks after the loop has completed std::pair<typename InstanceMap::iterator, bool> result = inst_map.insert(std::make_pair(&inst, InstanceData())); InstanceData& id = result.first->second; if (result.second) { // first time we've seen this Instance ReceivedDataElement& mrs = *inst.rcvd_samples_.tail_; id.MRS_disposed_gc_ = static_cast<CORBA::Long>(mrs.disposed_generation_count_); id.MRS_nowriters_gc_ = static_cast<CORBA::Long>(mrs.no_writers_generation_count_); } if (iter->index_in_instance_ >= id.MRSIC_index_) { id.MRSIC_index_ = iter->index_in_instance_; id.MRSIC_disposed_gc_ = static_cast<CORBA::Long>(rde->disposed_generation_count_); id.MRSIC_nowriters_gc_ = static_cast<CORBA::Long>(rde->no_writers_generation_count_); } if (!id.most_recent_generation_) { id.most_recent_generation_ = inst.instance_state_.most_recent_generation(rde); } id.sampleinfo_positions_.push_back(idx); // 4. Take if (oper_ == DDS_OPERATION_TAKE) { // If removing the sample releases it if (inst.rcvd_samples_.remove(rde)) { // Prevent access of the SampleInfo, below released_instances.insert(&inst); } this->reader_->dec_ref_data_element(rde); } } // Fill in the *_ranks in the SampleInfo, and set instance state (mrg) for (typename InstanceMap::iterator i_iter(inst_map.begin()), i_end(inst_map.end()); i_iter != i_end; ++i_iter) { InstanceData& id = i_iter->second; { // Danger, limit visibility of inst SubscriptionInstance& inst = *i_iter->first; // If this instance has not been released if (released_instances.find(&inst) == released_instances.end()) { if (id.most_recent_generation_) { inst.instance_state_.accessed(); } } } CORBA::Long sample_rank = static_cast<CORBA::Long>(id.sampleinfo_positions_.size()); for (IndexList::iterator s_iter(id.sampleinfo_positions_.begin()), s_end(id.sampleinfo_positions_.end()); s_iter != s_end; ++s_iter) { DDS::SampleInfo& si = info_seq_[*s_iter]; si.sample_rank = --sample_rank; si.generation_rank = id.MRSIC_disposed_gc_ + id.MRSIC_nowriters_gc_ - si.generation_rank; si.absolute_generation_rank = id.MRS_disposed_gc_ + id.MRS_nowriters_gc_ - si.absolute_generation_rank; } } return true; }
globle void DeriveDefaultFromConstraints( void *theEnv, CONSTRAINT_RECORD *constraints, DATA_OBJECT *theDefault, int multifield, int garbageMultifield) { unsigned short theType; unsigned long minFields; void *theValue; /*=============================================================*/ /* If no constraints are specified, then use the symbol nil as */ /* a default for single field slots and a multifield of length */ /* 0 as a default for multifield slots. */ /*=============================================================*/ if (constraints == NULL) { if (multifield) { SetpType(theDefault,MULTIFIELD); SetpDOBegin(theDefault,1); SetpDOEnd(theDefault,0); if (garbageMultifield) SetpValue(theDefault,(void *) EnvCreateMultifield(theEnv,0L)); else SetpValue(theDefault,(void *) CreateMultifield2(theEnv,0L)); } else { theDefault->type = SYMBOL; theDefault->value = EnvAddSymbol(theEnv,(char*)"nil"); } return; } /*=========================================*/ /* Determine the default's type and value. */ /*=========================================*/ if (constraints->anyAllowed || constraints->symbolsAllowed) { theType = SYMBOL; theValue = FindDefaultValue(theEnv,SYMBOL,constraints,EnvAddSymbol(theEnv,(char*)"nil")); } else if (constraints->stringsAllowed) { theType = STRING; theValue = FindDefaultValue(theEnv,STRING,constraints,EnvAddSymbol(theEnv,(char*)"")); } else if (constraints->integersAllowed) { theType = INTEGER; theValue = FindDefaultValue(theEnv,INTEGER,constraints,EnvAddLong(theEnv,0LL)); } else if (constraints->floatsAllowed) { theType = FLOAT; theValue = FindDefaultValue(theEnv,FLOAT,constraints,EnvAddDouble(theEnv,0.0)); } #if OBJECT_SYSTEM else if (constraints->instanceNamesAllowed) { theType = INSTANCE_NAME; theValue = FindDefaultValue(theEnv,INSTANCE_NAME,constraints,EnvAddSymbol(theEnv,(char*)"nil")); } else if (constraints->instanceAddressesAllowed) { theType = INSTANCE_ADDRESS; theValue = (void *) &InstanceData(theEnv)->DummyInstance; } #endif #if DEFTEMPLATE_CONSTRUCT else if (constraints->factAddressesAllowed) { theType = FACT_ADDRESS; theValue = (void *) &FactData(theEnv)->DummyFact; } #endif else if (constraints->externalAddressesAllowed) { theType = EXTERNAL_ADDRESS; theValue = EnvAddExternalAddress(theEnv,NULL,0); } else { theType = SYMBOL; theValue = EnvAddSymbol(theEnv,(char*)"nil"); } /*=========================================================*/ /* If the default is for a multifield slot, then create a */ /* multifield default value that satisfies the cardinality */ /* constraints for the slot. The default value for a */ /* multifield slot is a multifield of length 0. */ /*=========================================================*/ if (multifield) { if (constraints->minFields == NULL) minFields = 0; else if (constraints->minFields->value == SymbolData(theEnv)->NegativeInfinity) minFields = 0; else minFields = (unsigned long) ValueToLong(constraints->minFields->value); SetpType(theDefault,MULTIFIELD); SetpDOBegin(theDefault,1); SetpDOEnd(theDefault,(long) minFields); if (garbageMultifield) SetpValue(theDefault,(void *) EnvCreateMultifield(theEnv,minFields)); else SetpValue(theDefault,(void *) CreateMultifield2(theEnv,minFields)); for (; minFields > 0; minFields--) { SetMFType(GetpValue(theDefault),minFields,theType); SetMFValue(GetpValue(theDefault),minFields,theValue); } } else { theDefault->type = theType; theDefault->value = theValue; } }
globle const char *DataObjectToString( void *theEnv, DATA_OBJECT *theDO) { void *thePtr; const char *theString; char *newString; const char *prefix, *postfix; size_t length; struct externalAddressHashNode *theAddress; char buffer[30]; switch (GetpType(theDO)) { case MULTIFIELD: prefix = "("; theString = ValueToString(ImplodeMultifield(theEnv,theDO)); postfix = ")"; break; case STRING: prefix = "\""; theString = DOPToString(theDO); postfix = "\""; break; case INSTANCE_NAME: prefix = "["; theString = DOPToString(theDO); postfix = "]"; break; case SYMBOL: return(DOPToString(theDO)); case FLOAT: return(FloatToString(theEnv,DOPToDouble(theDO))); case INTEGER: return(LongIntegerToString(theEnv,DOPToLong(theDO))); case RVOID: return(""); #if OBJECT_SYSTEM case INSTANCE_ADDRESS: thePtr = DOPToPointer(theDO); if (thePtr == (void *) &InstanceData(theEnv)->DummyInstance) { return("<Dummy Instance>"); } if (((struct instance *) thePtr)->garbage) { prefix = "<Stale Instance-"; theString = ValueToString(((struct instance *) thePtr)->name); postfix = ">"; } else { prefix = "<Instance-"; theString = ValueToString(GetFullInstanceName(theEnv,(INSTANCE_TYPE *) thePtr)); postfix = ">"; } break; #endif case EXTERNAL_ADDRESS: theAddress = (struct externalAddressHashNode *) DOPToPointer(theDO); /* TBD Need specific routine for creating name string. */ gensprintf(buffer,"<Pointer-%d-%p>",(int) theAddress->type,DOPToExternalAddress(theDO)); thePtr = EnvAddSymbol(theEnv,buffer); return(ValueToString(thePtr)); #if DEFTEMPLATE_CONSTRUCT case FACT_ADDRESS: if (DOPToPointer(theDO) == (void *) &FactData(theEnv)->DummyFact) { return("<Dummy Fact>"); } thePtr = DOPToPointer(theDO); gensprintf(buffer,"<Fact-%lld>",((struct fact *) thePtr)->factIndex); thePtr = EnvAddSymbol(theEnv,buffer); return(ValueToString(thePtr)); #endif default: return("UNK"); } length = strlen(prefix) + strlen(theString) + strlen(postfix) + 1; newString = (char *) genalloc(theEnv,length); newString[0] = '\0'; genstrcat(newString,prefix); genstrcat(newString,theString); genstrcat(newString,postfix); thePtr = EnvAddSymbol(theEnv,newString); genfree(theEnv,newString,length); return(ValueToString(thePtr)); }
bool Toolbar::initialise() { int barPosition; // get height of the window barPosition = (-WindowManager::getInstance()->getWindowResolution().height * 0.8f) / 2; //==================== // initialise Sprites //==================== // Background m_background = new Sprite; if (!m_background) { return false; } m_result = m_background->initialise(Rect3D(728, 88), "ui_toolbar.dds"); if (!m_result) { return false; } m_background->getTransform()->setY(barPosition); m_background->setShader("texture"); // Toolbar Icons m_toolbarIcons = new InstancedSprite; if (!m_toolbarIcons) { return false; } m_result = m_toolbarIcons->initialise(Rect3D(64, 64), "ui_icons.dds"); if (!m_result) { return false; } m_toolbarIcons->setShader("instancedtexture"); m_toolbarIcons->setBlendMode(BlendMode::AlphaMasked); // Highlighter m_highlighter = new Sprite; if (!m_highlighter) { return false; } m_result = m_highlighter->initialise(Rect3D(92, 92), "ui_toolbar_select.dds"); if (!m_result) { return false; } m_highlighter->setShader("texture"); m_highlighter->setBlendMode(BlendMode::AlphaMasked); //================== // initialise Tools //================== // Add Icon Data m_toolData.push_back(InstanceData(D3DXVECTOR3(-320, barPosition, 1), D3DXVECTOR2(31, 17), D3DXVECTOR2(32, 21))); // Pickaxe m_toolData.push_back(InstanceData(D3DXVECTOR3(-240, barPosition, 1), D3DXVECTOR2(18, 11), D3DXVECTOR2(32, 21))); // Dirt m_toolData.push_back(InstanceData(D3DXVECTOR3(-160, barPosition, 1), D3DXVECTOR2(3, 12), D3DXVECTOR2(32, 21))); // Sand m_toolData.push_back(InstanceData(D3DXVECTOR3(-80, barPosition, 1), D3DXVECTOR2(10, 8), D3DXVECTOR2(32, 21))); // Cobblestone m_toolData.push_back(InstanceData(D3DXVECTOR3( 0, barPosition, 1), D3DXVECTOR2(7, 12), D3DXVECTOR2(32, 21))); // Stone m_toolData.push_back(InstanceData(D3DXVECTOR3( 80, barPosition, 1), D3DXVECTOR2(6, 9), D3DXVECTOR2(32, 21))); // Wood m_toolData.push_back(InstanceData(D3DXVECTOR3(160, barPosition, 1), D3DXVECTOR2(30, 1), D3DXVECTOR2(32, 21))); // Water Bucket // create Instanced Sprite for (unsigned int i = 0; i < m_toolData.size(); i++) { m_toolbarIcons->addInstance(m_toolData[i]); } m_toolbarIcons->rebuildInstanceBuffer(); //================= // initialise Vars //================= m_selectedIndex = 0; refresh(); return true; }
const char *DataObjectToString( Environment *theEnv, UDFValue *theDO) { CLIPSLexeme *thePtr; const char *theString; char *newString; const char *prefix, *postfix; size_t length; CLIPSExternalAddress *theAddress; StringBuilder *theSB; char buffer[30]; switch (theDO->header->type) { case MULTIFIELD_TYPE: prefix = "("; theString = ImplodeMultifield(theEnv,theDO)->contents; postfix = ")"; break; case STRING_TYPE: prefix = "\""; theString = theDO->lexemeValue->contents; postfix = "\""; break; case INSTANCE_NAME_TYPE: prefix = "["; theString = theDO->lexemeValue->contents; postfix = "]"; break; case SYMBOL_TYPE: return theDO->lexemeValue->contents; case FLOAT_TYPE: return(FloatToString(theEnv,theDO->floatValue->contents)); case INTEGER_TYPE: return(LongIntegerToString(theEnv,theDO->integerValue->contents)); case VOID_TYPE: return(""); #if OBJECT_SYSTEM case INSTANCE_ADDRESS_TYPE: if (theDO->instanceValue == &InstanceData(theEnv)->DummyInstance) { return("<Dummy Instance>"); } if (theDO->instanceValue->garbage) { prefix = "<Stale Instance-"; theString = theDO->instanceValue->name->contents; postfix = ">"; } else { prefix = "<Instance-"; theString = GetFullInstanceName(theEnv,theDO->instanceValue)->contents; postfix = ">"; } break; #endif case EXTERNAL_ADDRESS_TYPE: theAddress = theDO->externalAddressValue; theSB = CreateStringBuilder(theEnv,30); OpenStringBuilderDestination(theEnv,"DOTS",theSB); if ((EvaluationData(theEnv)->ExternalAddressTypes[theAddress->type] != NULL) && (EvaluationData(theEnv)->ExternalAddressTypes[theAddress->type]->longPrintFunction != NULL)) { (*EvaluationData(theEnv)->ExternalAddressTypes[theAddress->type]->longPrintFunction)(theEnv,"DOTS",theAddress); } else { WriteString(theEnv,"DOTS","<Pointer-"); gensprintf(buffer,"%d-",theAddress->type); WriteString(theEnv,"DOTS",buffer); gensprintf(buffer,"%p",theAddress->contents); WriteString(theEnv,"DOTS",buffer); WriteString(theEnv,"DOTS",">"); } thePtr = CreateString(theEnv,theSB->contents); SBDispose(theSB); CloseStringBuilderDestination(theEnv,"DOTS"); return thePtr->contents; #if DEFTEMPLATE_CONSTRUCT case FACT_ADDRESS_TYPE: if (theDO->factValue == &FactData(theEnv)->DummyFact) { return("<Dummy Fact>"); } gensprintf(buffer,"<Fact-%lld>",theDO->factValue->factIndex); thePtr = CreateString(theEnv,buffer); return thePtr->contents; #endif default: return("UNK"); } length = strlen(prefix) + strlen(theString) + strlen(postfix) + 1; newString = (char *) genalloc(theEnv,length); newString[0] = '\0'; genstrcat(newString,prefix); genstrcat(newString,theString); genstrcat(newString,postfix); thePtr = CreateString(theEnv,newString); genfree(theEnv,newString,length); return thePtr->contents; }