Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3301 for code/trunk/src/core


Ignore:
Timestamp:
Jul 18, 2009, 4:03:59 PM (15 years ago)
Author:
rgrieder
Message:

Found even more casts. They sure aren't all of them, but I hope to have caught every pointer C-style cast because they can be very dangerous.
Note: I didn't do the pointer casts in the network library because that would have taken way too long.

Location:
code/trunk/src/core
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/core/ConfigFileManager.cc

    r3280 r3301  
    572572        else
    573573        {
    574             COUT(1) << "ConfigFileManager: Can't find a config file for type with ID " << (int)type << std::endl;
     574            COUT(1) << "ConfigFileManager: Can't find a config file for type with ID " << static_cast<int>(type) << std::endl;
    575575            COUT(1) << "Using " << DEFAULT_CONFIG_FILE << " file." << std::endl;
    576576            this->setFilename(type, DEFAULT_CONFIG_FILE);
  • code/trunk/src/core/ConfigValueContainer.h

    r3196 r3301  
    6969            inline virtual ~ConfigValueCallback() {}
    7070            inline virtual void call(void* object)
    71                 { if (!Identifier::isCreatingHierarchy()) { (((T*)object)->*this->function_)(); } }
     71            {
     72                if (!Identifier::isCreatingHierarchy())
     73                    (static_cast<T*>(object)->*this->function_)();
     74            }
    7275
    7376        private:
  • code/trunk/src/core/Executor.cc

    r3280 r3301  
    9999
    100100            // assign all given arguments to the multitypes
    101             for (unsigned int i = 0; i < std::min(tokens.size(), (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
     101            for (unsigned int i = 0; i < std::min(tokens.size(), MAX_FUNCTOR_ARGUMENTS); i++)
    102102                param[i] = tokens[i];
    103103
    104104            // fill the remaining multitypes with default values
    105             for (unsigned int i = tokens.size(); i < std::min(paramCount, (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
     105            for (unsigned int i = tokens.size(); i < std::min(paramCount, MAX_FUNCTOR_ARGUMENTS); i++)
    106106                param[i] = this->defaultValue_[i];
    107107
    108108            // evaluate the param types through the functor
    109             for (unsigned int i = 0; i < std::min(paramCount, (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
     109            for (unsigned int i = 0; i < std::min(paramCount, MAX_FUNCTOR_ARGUMENTS); i++)
    110110                this->functor_->evaluateParam(i, param[i]);
    111111
  • code/trunk/src/core/Executor.h

    r3280 r3301  
    104104            COUT(5) << tokens[i]; \
    105105        } \
    106         COUT(5) << ") and " << std::max((int)paramCount - (int)tokens.size(), 0) << " default values ("; \
     106        COUT(5) << ") and " << std::max(static_cast<int>(paramCount) - static_cast<int>(tokens.size()), 0) << " default values ("; \
    107107        for (unsigned int i = tokens.size(); i < paramCount; i++) \
    108108        { \
  • code/trunk/src/core/IRC.cc

    r3280 r3301  
    5252    void IRC::initialize()
    5353    {
    54         unsigned int threadID = (unsigned int)IRC_TCL_THREADID;
     54        unsigned int threadID = IRC_TCL_THREADID;
    5555        TclThreadManager::createID(threadID);
    5656        this->bundle_ = TclThreadManager::getInstance().getInterpreterBundle(threadID);
  • code/trunk/src/core/LuaBind.cc

    r3280 r3301  
    124124  const char * LuaBind::lua_Chunkreader(lua_State *L, void *data, size_t *size)
    125125  {
    126     LoadS* ls = ((LoadS*)data);
     126    LoadS* ls = static_cast<LoadS*>(data);
    127127    if (ls->size == 0) return NULL;
    128128    *size = ls->size;
  • code/trunk/src/core/Shell.cc

    r3300 r3301  
    228228    std::string Shell::getFromHistory() const
    229229    {
    230         unsigned int index = mod(((int)this->historyOffset_) - ((int)this->historyPosition_), this->maxHistoryLength_);
     230        unsigned int index = mod(static_cast<int>(this->historyOffset_) - static_cast<int>(this->historyPosition_), this->maxHistoryLength_);
    231231        if (index < this->commandHistory_.size() && this->historyPosition_ != 0)
    232232            return this->commandHistory_[index];
     
    249249            {
    250250                if (this->bAddOutputLevel_)
    251                     output.insert(0, 1, (char)OutputHandler::getOutStream().getOutputLevel());
     251                    output.insert(0, 1, static_cast<char>(OutputHandler::getOutStream().getOutputLevel()));
    252252
    253253                this->lines_.insert(this->lines_.begin(), output);
  • code/trunk/src/core/Super.h

    r3196 r3301  
    9191            static void check() \
    9292            { \
    93                 SuperFunctionCondition<functionnumber, T, 0, templatehack2>::apply((T*)0); \
     93                SuperFunctionCondition<functionnumber, T, 0, templatehack2>::apply(static_cast<T*>(0)); \
    9494                SuperFunctionCondition<functionnumber + 1, T, 0, templatehack2>::check(); \
    9595            } \
     
    149149                // This call to the apply-function is the whole check. By calling the function with
    150150                // a T* pointer, the right function get's called.
    151                 SuperFunctionCondition<functionnumber, T, 0, templatehack2>::apply((T*)0);
     151                SuperFunctionCondition<functionnumber, T, 0, templatehack2>::apply(static_cast<T*>(0));
    152152
    153153                // Go go the check for of next super-function (functionnumber + 1)
  • code/trunk/src/core/TclThreadManager.cc

    r3300 r3301  
    278278    std::string TclThreadManager::tcl_query(int querierID, Tcl::object const &args)
    279279    {
    280         return TclThreadManager::getInstance().evalQuery((unsigned int)querierID, stripEnclosingBraces(args.get()));
     280        return TclThreadManager::getInstance().evalQuery(static_cast<unsigned int>(querierID), stripEnclosingBraces(args.get()));
    281281    }
    282282
    283283    std::string TclThreadManager::tcl_crossquery(int querierID, int threadID, Tcl::object const &args)
    284284    {
    285         return TclThreadManager::getInstance().evalQuery((unsigned int)querierID, (unsigned int)threadID, stripEnclosingBraces(args.get()));
     285        return TclThreadManager::getInstance().evalQuery(static_cast<unsigned int>(querierID), static_cast<unsigned int>(threadID), stripEnclosingBraces(args.get()));
    286286    }
    287287
    288288    bool TclThreadManager::tcl_running(int threadID)
    289289    {
    290         TclInterpreterBundle* bundle = TclThreadManager::getInstance().getInterpreterBundle((unsigned int)threadID);
     290        TclInterpreterBundle* bundle = TclThreadManager::getInstance().getInterpreterBundle(static_cast<unsigned int>(threadID));
    291291        if (bundle)
    292292        {
     
    556556                    try
    557557                    {
    558                         if (querierID == 0 || std::find(querier->queriers_.begin(), querier->queriers_.end(), (unsigned int)0) != querier->queriers_.end())
     558                        if (querierID == 0 || std::find(querier->queriers_.begin(), querier->queriers_.end(), 0U) != querier->queriers_.end())
    559559                            successfullyLocked = interpreter_lock.try_lock();
    560560                        else
     
    631631            boost::try_mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_.interpreterMutex_);
    632632#endif
    633             unsigned long maxtime = (unsigned long)(time.getDeltaTime() * 1000000 * TCLTHREADMANAGER_MAX_CPU_USAGE);
     633            unsigned long maxtime = static_cast<unsigned long>(time.getDeltaTime() * 1000000 * TCLTHREADMANAGER_MAX_CPU_USAGE);
    634634            Ogre::Timer timer;
    635635            while (!this->queueIsEmpty())
  • code/trunk/src/core/XMLPort.h

    r3196 r3301  
    9393*/
    9494#define XMLPortParamVariable(classname, paramname, variable, xmlelement, mode) \
    95     XMLPortVariableHelperClass xmlcontainer##variable##dummy((void*)&variable); \
     95    XMLPortVariableHelperClass xmlcontainer##variable##dummy(static_cast<void*>(&variable)); \
    9696    static ExecutorMember<orxonox::XMLPortVariableHelperClass>* xmlcontainer##variable##loadexecutor = static_cast<ExecutorMember<orxonox::XMLPortVariableHelperClass>*>(orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getLoader(variable)), std::string( #classname ) + "::" + #variable + "loader")); \
    9797    static ExecutorMember<orxonox::XMLPortVariableHelperClass>* xmlcontainer##variable##saveexecutor = static_cast<ExecutorMember<orxonox::XMLPortVariableHelperClass>*>(orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getSaver (variable)), std::string( #classname ) + "::" + #variable + "saver" )); \
     
    561561                                                    COUT(4) << object->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl;
    562562
    563                                                     BaseObject* newObject = identifier->fabricate((BaseObject*)object);
     563                                                    BaseObject* newObject = identifier->fabricate(static_cast<BaseObject*>(object));
    564564                                                    assert(newObject);
    565565                                                    newObject->setLoaderIndentation(object->getLoaderIndentation() + "  ");
     
    571571                                                    {
    572572                                                        newObject->XMLPort(*child, XMLPort::LoadObject);
    573                                                         COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
     573                                                        COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ")" << std::endl;
    574574                                                    }
    575575                                                    else
    576576                                                    {
    577                                                         COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
     577                                                        COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ")" << std::endl;
    578578                                                    }
    579579
     
    671671            template <class T>
    672672            void load(const T& value)
    673                 { *((T*)this->variable_) = value; }
     673                { *static_cast<T*>(this->variable_) = value; }
    674674
    675675            template <class T>
    676676            const T& save()
    677                 { return *((T*)this->variable_); }
     677                { return *static_cast<T*>(this->variable_); }
    678678
    679679            template <class T>
  • code/trunk/src/core/input/InputBuffer.cc

    r3196 r3301  
    218218        }
    219219
    220         this->insert((char)evt.text);
     220        this->insert(static_cast<char>(evt.text));
    221221    }
    222222
  • code/trunk/src/core/input/InputManager.cc

    r3280 r3301  
    175175
    176176            // Fill parameter list
    177             windowHndStr << (unsigned int)windowHnd_;
     177            windowHndStr << static_cast<unsigned int>(windowHnd);
    178178            paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
    179179#if defined(ORXONOX_PLATFORM_WINDOWS)
  • code/trunk/src/core/input/KeyBinder.cc

    r3280 r3301  
    444444                    if (mousePosition_[i] < 0)
    445445                    {
    446                         mouseAxes_[2*i + 0].absVal_ =  -mousePosition_[i]/(float)mouseClippingSize_ * mouseSensitivity_;
    447                         mouseAxes_[2*i + 1].absVal_ =  0.0f;
     446                        mouseAxes_[2*i + 0].absVal_ = -mouseSensitivity_ * mousePosition_[i] / mouseClippingSize_;
     447                        mouseAxes_[2*i + 1].absVal_ = 0.0f;
    448448                    }
    449449                    else
    450450                    {
    451                         mouseAxes_[2*i + 0].absVal_ =  0.0f;
    452                         mouseAxes_[2*i + 1].absVal_ =   mousePosition_[i]/(float)mouseClippingSize_ * mouseSensitivity_;
     451                        mouseAxes_[2*i + 0].absVal_ = 0.0f;
     452                        mouseAxes_[2*i + 1].absVal_ =  mouseSensitivity_ * mousePosition_[i] / mouseClippingSize_;
    453453                    }
    454454                }
     
    460460        {
    461461            if (rel[i] < 0)
    462                 mouseAxes_[0 + 2*i].relVal_ = -((float)rel[i])/(float)mouseClippingSize_ * mouseSensitivity_;
     462                mouseAxes_[0 + 2*i].relVal_ = -mouseSensitivity_ * rel[i] / mouseClippingSize_;
    463463            else
    464                 mouseAxes_[1 + 2*i].relVal_ =  ((float)rel[i])/(float)mouseClippingSize_ * mouseSensitivity_;
     464                mouseAxes_[1 + 2*i].relVal_ =  mouseSensitivity_ * rel[i] / mouseClippingSize_;
    465465        }
    466466    }
     
    474474        if (rel < 0)
    475475            for (int i = 0; i < -rel/mouseWheelStepSize_; i++)
    476                 mouseButtons_[8].execute(KeybindMode::OnPress, ((float)abs)/mouseWheelStepSize_);
     476                mouseButtons_[8].execute(KeybindMode::OnPress, static_cast<float>(abs)/mouseWheelStepSize_);
    477477        else
    478478            for (int i = 0; i < rel/mouseWheelStepSize_; i++)
    479                 mouseButtons_[9].execute(KeybindMode::OnPress, ((float)abs)/mouseWheelStepSize_);
     479                mouseButtons_[9].execute(KeybindMode::OnPress, static_cast<float>(abs)/mouseWheelStepSize_);
    480480    }
    481481
Note: See TracChangeset for help on using the changeset viewer.