예제 #1
0
bool SDL::getAllVideoModes(StringVect &modeList)
{
    std::set<std::string> modes;

    for (int display = 0; display < 100; display ++)
    {
        const int numModes = SDL_GetNumDisplayModes(display);
        if (numModes > 0)
        {
            logger->log("Modes for display %d", display);
            for (int f = 0; f < numModes; f ++)
            {
                SDL_DisplayMode mode;
                SDL_GetDisplayMode(display, f, &mode);
                const int w = mode.w;
                const int h = mode.h;
                logger->log("%dx%dx%d", w, h, mode.refresh_rate);
                modes.insert(strprintf("%dx%d", w, h));
            }
        }
    }
    FOR_EACH (std::set<std::string>::const_iterator, it, modes)
        modeList.push_back(*it);
    return true;
}
예제 #2
0
void PlaceableObject::unparent_children (void)
{
    std::list<PlaceableObject*> c = children();
    
    FOR_EACH (i,c)
        unparent_child(*i);
}
예제 #3
0
void TouchManager::clear()
{
    FOR_EACH (TouchItemVectorCIter, it, mObjects)
        unload(*it);
    mObjects.clear();
    mRedraw = true;
}
예제 #4
0
void MapDB::readAtlas(XmlNodePtrConst node)
{
    if (!node)
        return;
    const std::string atlas = XML::getProperty(node, "name", "");
    if (atlas.empty())
        return;
    for_each_xml_child_node(childNode, node)
    {
        if (xmlNameEqual(childNode, "file"))
        {
            const std::string file = XML::getProperty(childNode, "name", "");
            if (file.empty())
                continue;
            mAtlases[atlas].push_back(file);
        }
    }
    if (atlas != "all")
    {
        const AtlasCIter &allAtlas = mAtlases.find("all");
        if (allAtlas != mAtlases.end())
        {
            FOR_EACH (StringVectCIter, it, (*allAtlas).second)
                mAtlases[atlas].push_back(*it);
        }
    }
}
예제 #5
0
  /* This should *not* be flagged as misleading indentation.  */
  if (a) return b; else return c;
}

void fn_9 (int flag)
{
  if (flag) /* { dg-message "3: ...this 'if' clause, but it is not" } */
    foo (0);
    foo (1); /* { dg-warning "statement is indented as if it were guarded by..." } */
}

void fn_10 (int flag)
{
  if (flag) /* { dg-message "3: ...this 'if' clause, but it is not" } */
    if (flag / 2)
      {
        foo (0);
        foo (1);
      }
    foo (2); /* { dg-warning "statement is indented as if it were guarded by..." } */
  foo (3);
}

void fn_11 (void)
{
  if (flagA)
    if (flagB)
      if (flagC) /* { dg-message "7: ...this 'if' clause, but it is not" } */
        foo (0);
        bar (1, 2); /* { dg-warning "statement is indented as if it were guarded by..." } */
}

void fn_12 (void)
{
  if (flagA)
    if (flagB) /* { dg-message "5: ...this 'if' clause, but it is not" } */
      if (flagC)
        foo (0);
      bar (1, 2); /* { dg-warning "statement is indented as if it were guarded by..." } */
}

void fn_13 (void)
{
  if (flagA) /* { dg-message "3: ...this 'if' clause, but it is not" } */
    if (flagB)
      if (flagC)
        foo (0);
    bar (1, 2); /* { dg-warning "statement is indented as if it were guarded by..." } */
}

#define FOR_EACH(VAR, START, STOP) \
  for ((VAR) = (START); (VAR) < (STOP); (VAR++)) /* { dg-message "3: ...this 'for' clause, but it is not" } */

void fn_14 (void)
{
  int i;
  FOR_EACH (i, 0, 10) /* { dg-message "3: in expansion of macro" } */
    foo (i);
    bar (i, i); /* { dg-warning "statement is indented as if it were guarded by..." } */
}
#undef FOR_EACH

#define FOR_EACH(VAR, START, STOP) for ((VAR) = (START); (VAR) < (STOP); (VAR++)) /* { dg-message "36: ...this 'for' clause, but it is not" } */
void fn_15 (void)
{
  int i;
  FOR_EACH (i, 0, 10) /* { dg-message "3: in expansion of macro" } */
    foo (i);
    bar (i, i); /* { dg-warning "statement is indented as if it were guarded by..." } */
}
예제 #6
0
void ParticleList::clearLocally()
{
    FOR_EACH (ParticleListCIter, it, mElements)
        (*it)->kill();

    mElements.clear();
}
예제 #7
0
void ColorDB::load()
{
    if (mLoaded)
        unload();

    std::map<ItemColor, ItemColorData> colors;
    ColorListsIterator it = mColorLists.find("hair");
    if (it != mColorLists.end())
        colors = it->second;
    loadHair(paths.getStringValue("hairColorFile"), colors);
    loadHair(paths.getStringValue("hairColorPatchFile"), colors);
    StringVect list;
    BeingCommon::getIncludeFiles(paths.getStringValue(
                                     "hairColorPatchDir"), list, ".xml");
    FOR_EACH (StringVectCIter, it2, list)
    loadHair(*it2, colors);

    mColorLists["hair"] = colors;

    loadColorLists(paths.getStringValue("itemColorsFile"));
    loadColorLists(paths.getStringValue("itemColorsPatchFile"));
    loadXmlDir("itemColorsPatchDir", loadColorLists);

    it = mColorLists.find("hair");
    if (it != mColorLists.end())
        mHairColorsSize = static_cast<int>((*it).second.size());
    else
        mHairColorsSize = 0;
    mLoaded = true;
}
예제 #8
0
PlayerRelationsManager::~PlayerRelationsManager()
{
    delete_all(mIgnoreStrategies);

    FOR_EACH (PlayerRelationsCIter, it, mRelations)
        delete it->second;
    mRelations.clear();
}
예제 #9
0
void EditDialog::action(const gcn::ActionEvent &event)
{
    // Proxy button events to our listeners
    FOR_EACH (ActionListenerIterator, i, mActionListeners)
        (*i)->action(event);

    if (event.getId() == mEventOk)
        scheduleDelete();
}
예제 #10
0
void Logger::flush()
{
    if (!mThreadLocked)
    {
        SDL_mutexP(mMutex);
        FOR_EACH (std::vector<std::string>::const_iterator, it, mDelayedLog)
            mLogFile << *it;
        mDelayedLog.clear();
        SDL_mutexV(mMutex);
    }
}
예제 #11
0
static void loadDB(const std::string &name, BadgesInfos &arr)
{
    loadXmlFile(paths.getStringValue("badgesFile"),
        name, arr, SkipError_false);
    loadXmlFile(paths.getStringValue("badgesPatchFile"),
        name, arr, SkipError_true);

    StringVect listVect;
    Files::getFilesInDir(paths.getStringValue(
        "badgesPatchDir"), listVect, ".xml");
    FOR_EACH (StringVectCIter, itVect, listVect)
        loadXmlFile(*itVect, name, arr, SkipError_true);
}
예제 #12
0
void PlayerRelationsManager::init()
{
    load();

    if (!mPersistIgnores)
    {
        clear();  // Yes, we still keep them around in the config file
                  // until the next update.
    }

    FOR_EACH (PlayerRelationListenersCIter, it, mListeners)
        (*it)->updateAll();
}
예제 #13
0
void PlayerRelationsManager::signalUpdate(const std::string &name)
{
    FOR_EACH (PlayerRelationListenersCIter, it, mListeners)
        (*it)->updatedPlayer(name);

    if (actorManager)
    {
        Being *const being = actorManager->findBeingByName(
            name, ActorType::Player);

        if (being && being->getType() == ActorType::Player)
            being->updateColors();
    }
}
__fastcall TCustomResinMainSelectWizardFrame::~TCustomResinMainSelectWizardFrame()
{
	Q_SAFE_DELETE_ARRAY(ResinChooser);
	Q_SAFE_DELETE_ARRAY(ResinChooserCaptions);
	Q_SAFE_DELETE_ARRAY(ResinForce);
	Q_SAFE_DELETE_ARRAY(ResinBothCarts);
	Q_SAFE_DELETE_ARRAY(ResinLeftRightCarts);
	FOR_EACH(i)
	   Q_SAFE_DELETE_ARRAY(ResinReplCycle[i]);
	Q_SAFE_DELETE_ARRAY(ResinReplCycle);

	if(lblHSWwarning)
		delete lblHSWwarning;
}
예제 #15
0
파일: error.c 프로젝트: barak/sigscheme
SCM_EXPORT void
scm_show_backtrace(ScmObj trace_stack)
{
#if SCM_USE_BACKTRACE
    ScmObj frame, env, obj;
#if SCM_DEBUG_BACKTRACE_VAL
    ScmObj elm;
#endif
    DECLARE_INTERNAL_FUNCTION("scm_show_backtrace");

    if (NULLP(trace_stack))
        return;

    scm_port_puts(scm_err, SCM_BACKTRACE_HEADER);
    scm_port_newline(scm_err);

    /* show each frame's obj */
    FOR_EACH (frame, trace_stack) {
#if SCM_DEBUG_BACKTRACE_SEP
        scm_port_puts(scm_err, SCM_BACKTRACE_SEP);
        scm_port_newline(scm_err);
#endif

        env = TRACE_FRAME_ENV(frame);
        obj = TRACE_FRAME_OBJ(frame);

        SCM_WRITE_SS(scm_err, obj);
        scm_port_newline(scm_err);

#if SCM_DEBUG_BACKTRACE_VAL
        switch (SCM_TYPE(obj)) {
        case ScmSymbol:
            show_arg(obj, env);
            break;

        case ScmCons:
            FOR_EACH (elm, obj)
                show_arg(elm, env);
            /* dot list */
            if (IDENTIFIERP(obj))
                show_arg(obj, env);
            break;

        default:
            break;
        }
#endif /* SCM_DEBUG_BACKTRACE_VAL */
    }
예제 #16
0
/* enter a dynamic extent of another continuation (dest) */
static void
enter_dynamic_extent(ScmObj dest)
{
    ScmObj frame, unwound, retpath;
    DECLARE_INTERNAL_FUNCTION("enter_dynamic_extent");

    retpath = SCM_NULL;
    unwound = dest;
    while (!NULLP(unwound) && !EQ(unwound, l_current_dynamic_extent)) {
        frame = POP(unwound);
        retpath = CONS(frame, retpath);
    }

    FOR_EACH (frame, retpath)
        scm_call(DYNEXT_FRAME_BEFORE(frame), SCM_NULL);
}
예제 #17
0
void SpellManager::fillSpells()
{
    CommandsDB::load();

    CommandsMap &commands = CommandsDB::getAll();
    FOR_EACH (CommandsMapIter, it, commands)
        addSpell((*it).second);

    for (unsigned f = 0; f < SPELL_SHORTCUT_ITEMS * SPELL_SHORTCUT_TABS; f++)
    {
        const std::map<unsigned int, TextCommand*>::const_iterator
            it = mSpells.find(f);
        if (it == mSpells.end())
            addSpell(new TextCommand(f));
    }
    CommandsDB::unload();
}
예제 #18
0
WhoIsOnline::~WhoIsOnline()
{
    config.removeListeners(this);

    if (mThread && SDL_GetThreadID(mThread))
        SDL_WaitThread(mThread, nullptr);

    free(mMemoryBuffer);
    mMemoryBuffer = nullptr;

    // Remove possibly leftover temporary download
    delete []mCurlError;

    FOR_EACH (std::set<OnlinePlayer*>::iterator, itd, mOnlinePlayers)
        delete *itd;
    mOnlinePlayers.clear();
    mOnlineNicks.clear();
}
예제 #19
0
int main(void) {
    volatile int x, y, z; const int n = 20;

    List * pTriples = SEQ(
                          T(x, y, z),
                          (
                           (x, R(1, n)),
                           (y, R(x, n)),
                           (z, R(y, n))
                          ),
                          (x*x + y*y == z*z)
                         );

    volatile Triple t;
    FOR_EACH(t, Triple, pTriples,  printf("%d, %d, %d\n", t._1, t._2, t._3)  );

    return 0;
}
예제 #20
0
    bool parse_arguments( int &argc, char **argv, bool remove_args = true )
    {
        file_name_ = std::string( argv[0] );

        std::list< std::string > q;
        for ( int i = 1; i < argc; ++i )
        {
            q.push_back( std::string( argv[i] ) );
        }

        FOR_EACH ( it, q )
        {

            if ( *it == "-h" || *it == "--help" || *it == "-help" )
            {
                std::cout << "Usage: " << file_name_ << " [OPTIONS] ...\n\n";
                FOR_EACH ( it, handlers_ )
                {
                    std::cout.width(29);
                    std::cout << std::left
                              << ("  --" + (*it)->get_name() + "=" + (*it)->get_type());

                    std::string desc = (*it)->get_description();
                    std::vector< std::string > lines;
                    detail::explode( lines, desc, '\n' );

                    FOR_EACH ( lit, lines )
                        std::cout << (*lit) << "\n" << std::string( 29, ' ' );
                    std::cout << "default=" << (*it)->get_default() << "\n";
                    std::cout << "\n";
                }

                std::cout << "Notes:\n"
                          << "  - For non-BOOLEAN types:\n"
                          << "      -key VALUE (is equivalent to --key=VALUE)\n"
                          << "      -key=VALUE (is equivalent to --key=VALUE)\n"
                          << "  - For BOOLEAN types:\n"
                          << "      -key   (is equivalent to --key=true)\n"
                          << "      -nokey (is equivalent to --key=false)\n\n\n";

                exit( 0 );
                return false;
            }
예제 #21
0
void ActionStack::addAction(Action* action, bool allow_merge) {
	if (!action) return; // no action
	action->perform(false); // TODO: delete action if perform throws
	tellListeners(*action, false);
	// clear redo list
	if (!redo_actions.empty()) allow_merge = false; // don't merge after undo
	FOR_EACH(a, redo_actions) delete a;
	redo_actions.clear();
	// try to merge?
	if (allow_merge && !undo_actions.empty() &&
	    last_was_add                         && // never merge with something that was redone once already
	    undo_actions.back() != save_point    && // never merge with the save point
	    undo_actions.back()->merge(*action) // merged with top undo action
	    ) {
		delete action;
	} else {
		undo_actions.push_back(action);
	}
	last_was_add = true;
}
예제 #22
0
void att_ctrl_init(void)
{
   ASSERT_ONCE();

   /* load parameters: */
   opcd_param_t params[] =
   {
      {"p", &angle_p.value},
      {"i", &angle_i.value},
      {"i_max", &angle_i_max.value},
      {"d", &angle_d.value},
      {"pitch_bias", &biases[0]},
      {"roll_bias", &biases[1]},
      {"angles_max", &angles_max},
      OPCD_PARAMS_END
   };
   opcd_params_apply("controllers.attitude.", params);
   
   /* initialize controllers: */
   FOR_EACH(i, controllers)
      pid_init(&controllers[i], &angle_p, &angle_i, &angle_d, &angle_i_max);
}
예제 #23
0
void
fn_37 (void)
{
  int i;

#define EMPTY
#define FOR_EACH(VAR, START, STOP) for (VAR = START; VAR < STOP; VAR++)

  while (flagA); /* { dg-message "3: ...this 'while' clause" } */
    foo (0); /* { dg-warning "statement is indented as if" } */

  if (flagA)
    ;
  else if (flagA); /* { dg-message "8: ...this 'if' clause" } */
    foo (0); /* { dg-warning "statement is indented as if" } */
  while (flagA) /* { dg-message "3: ...this 'while' clause" } */
    /* blah */;
    foo (0); /* { dg-warning "statement is indented as if" } */

  if (flagA)
    ;
  else if (flagA) /* { dg-message "8: ...this 'if' clause" } */
    foo (1);
    foo (2); /* { dg-warning "statement is indented as if" } */

  if (flagA)
    foo (1);
  else if (flagA) /* { dg-message "8: ...this 'if' clause" } */
    foo (2);
    foo (3); /* { dg-warning "statement is indented as if" } */

  if (flagB) /* { dg-message "3: ...this 'if' clause" } */
    /* blah */;
    { /* { dg-warning "statement is indented as if" } */
      foo (0);
    }

  if (flagB) /* { dg-message "3: ...this 'if' clause" } */
    /* blah */;
   { /* { dg-warning "statement is indented as if" } */
     foo (0);
   }


  if (flagB)
    ;
  else; foo (0); /* { dg-warning "statement is indented as if" } */

  if (flagC); foo (2); /* { dg-warning "statement is indented as if" } */

  if (flagA)
    ; /* blah */ { /* { dg-warning "statement is indented as if" } */
      foo (1);
    }

  if (flagB) ; /* { dg-message "3: ...this 'if' clause" } */
    return; /* { dg-warning "statement is indented as if" } */

  if (flagB) EMPTY; /* { dg-message "3: ...this 'if' clause" } */
    foo (1); /* { dg-warning "statement is indented as if" } */

  for (i = 0; i < 10; i++); /* { dg-message "3: ...this 'for' clause" } */
    foo (2); /* { dg-warning "statement is indented as if" } */

  FOR_EACH (i, 0, 10);
    foo (2); /* { dg-warning "statement is indented as if" } */

  FOR_EACH (i, 0, 10);
    { /* { dg-warning "statement is indented as if" } */
      foo (3);
    }

  FOR_EACH (i, 0, 10);
  { /* { dg-warning "statement is indented as if" } */
    foo (3);
  }

  while (i++); { /* { dg-warning "statement is indented as if" } */
    foo (3);
  }

  if (i++); { /* { dg-warning "statement is indented as if" } */
    foo (3);
  }

  if (flagA) {
    foo (1);
  } else /* { dg-message "5: ...this 'else' clause" } */
    if (flagB)
       foo (2);
    foo (3); /* { dg-warning "statement is indented as if" } */

  if (flagA)
    foo (1);
  else if (flagB); /* { dg-message "8: ...this 'if' clause" } */
    foo (2); /* { dg-warning "statement is indented as if" } */

  for (i = 0; /* { dg-message "3: ...this 'for' clause" } */
       i < 10;
       i++);
    foo (i); /* { dg-warning "statement is indented as if" } */

#undef EMPTY
#undef FOR_EACH
}
예제 #24
0
void att_ctrl_reset(void)
{
   FOR_EACH(i, controllers)
      pid_reset(&controllers[i]);
}
예제 #25
0
파일: palette.cpp 프로젝트: koo5/manaplus
void Palette::advanceGradients()
{
    FOR_EACH (Palettes::const_iterator, it, mInstances)
        (*it)->advanceGradient();
}
예제 #26
0
void Inventory::distributeSlotsChangedEvent()
{
    FOR_EACH (InventoryListenerList::const_iterator, i, mInventoryListeners)
        (*i)->slotsChanged(this);
}
예제 #27
0
DecimalFormat::DecimalFormat( bool is_default, const store::Item_t& qname,
                              ctor_properties_type const &properties,
                              QueryLoc const &loc ) :
  is_default_( is_default ),
  qname_( qname )
{
  for ( ctor_properties_type::size_type i = 0; i < properties.size() - 1;
        ++i ) {
    for ( ctor_properties_type::size_type j = i + 1; j < properties.size();
          ++j ) {
      if ( i == j )
        continue;
      if ( properties[i].first == properties[j].first ) {
        //
        // XQuery 3.0 4.10: It is a static error for a decimal format
        // declaration to define the same property more than once.
        //
        throw XQUERY_EXCEPTION(
          err::XQST0114,
          ERROR_PARAMS( properties[i].first ),
          ERROR_LOC( loc )
        );
      }
      if ( properties[i].second == properties[j].second ) {
        //
        // Ibid: It is a static error if, for any named or unnamed decimal
        // format, the properties representing characters used in a picture
        // string do not have distinct values.
        //
        throw XQUERY_EXCEPTION(
          err::XQST0098,
          ERROR_PARAMS(
            properties[i].second, properties[i].first, properties[j].first
          ),
          ERROR_LOC( loc )
        );
      }
    } // for ( ... j ... )
  } // for ( ... i ... )

  FOR_EACH( ctor_properties_type, property, properties )
    properties_[ property->first ] = property->second;

  struct property_attribute {
    char const *name;
    bool is_string;
    char const *default_value;
  };

  static property_attribute const attributes[] = {
    { "decimal-separator" , false, "."            },
    { "digit"             , false, "#"            },
    { "grouping-separator", false, ","            },
    { "infinity"          , true , "Infinity"     },
    { "minus-sign"        , false, "-"            },
    { "NaN"               , true , "Nan"          },
    { "pattern-separator" , false, ";"            },
    { "percent"           , false, "%"            },
    { "per-mille"         , false, "\xE2\x80\xB0" },
    { "zero-digit"        , false, "0"            },
    { 0, false, 0 }
  };

  for ( property_attribute const *attr = attributes; attr->name; ++attr ) {
    value_type &value = properties_[ attr->name ];
    if ( value.empty() )
      value = attr->default_value;
    else if ( !attr->is_string && utf8::length( value ) > 1 ) {
      //
      // Ibid: It is a static error for a decimal format declaration to specify
      // a value that is not valid for a given property.
      //
      throw XQUERY_EXCEPTION(
        err::XQST0097,
        ERROR_PARAMS( value, attr->name, ZED( XQST0097_MustBeChar ) ),
        ERROR_LOC( loc )
      );
    }
  }

  //
  // XQuery 3.0 2.1.1: zero-digit specifies the character used for the zero-
  // digit-symbol; the default value is the digit zero (0). This character must
  // be a digit (category Nd in the Unicode property database), and it must
  // have the numeric value zero.
  //
  value_type const &zero_digit = properties_[ "zero-digit" ];
  unicode::code_point const zero_digit_cp = utf8::decode( zero_digit.c_str() );
  unicode::code_point zero_cp;
  if ( !unicode::is_Nd( zero_digit_cp, &zero_cp ) || zero_digit_cp != zero_cp )
    throw XQUERY_EXCEPTION(
      err::XQST0097,
      ERROR_PARAMS( zero_digit, "zero-digit", ZED( XQST0097_MustBeZeroDigit ) ),
      ERROR_LOC( loc )
    );
}
예제 #28
0
void NpcPostDialog::closeAll()
{
    FOR_EACH (DialogList::const_iterator, it, instances)
        (*it)->close();
}
예제 #29
0
ActionStack::~ActionStack() {
	// we own the actions, delete them
	FOR_EACH(a, undo_actions) delete a;
	FOR_EACH(a, redo_actions) delete a;
}
예제 #30
0
void ActionStack::tellListeners(const Action& action, bool undone) {
	FOR_EACH(l, listeners) l->onAction(action, undone);
}