Пример #1
0
void scene_clean_ani_players(void *userdata) {
    scene *sc = (scene*)userdata;
    iterator it;
    animationplayer *tmp = 0;

    list_iter_begin(&sc->child_players, &it);
    while((tmp = iter_next(&it)) != NULL) {
        if(tmp->finished) {
            animationplayer_free(tmp);
            list_delete(&sc->child_players, &it); 
        }
    }
    
    list_iter_begin(&sc->root_players, &it);
    while((tmp = iter_next(&it)) != NULL) {
        if(tmp->finished) {
            // if their probability is 1, go around again
            if (sc->loop && sc->bk->anims[tmp->id]->probability == 1) {
                animationplayer_reset(tmp);
            } else {
                animationplayer_free(tmp);
                list_delete(&sc->root_players, &it);
            }
        }
    }
}
Пример #2
0
Файл: gen.c Проект: irori/8cc
static void emit_data_int(List *inits, int size, int off, int depth) {
    SAVE;
    Iter *iter = list_iter(inits);
    while (!iter_end(iter) && 0 < size) {
        Node *node = iter_next(iter);
        Node *v = node->initval;
        emit_padding(node, off);
        if (node->totype->bitsize > 0) {
            assert(node->totype->bitoff == 0);
            long data = eval_intexpr(v);
            Ctype *totype = node->totype;
            while (!iter_end(iter)) {
                node = iter_next(iter);
                if (node->totype->bitsize <= 0) {
                    break;
                }
                v = node->initval;
                totype = node->totype;
                data |= ((((long)1 << totype->bitsize) - 1) & eval_intexpr(v)) << totype->bitoff;
            }
            emit_data_primtype(totype, &(Node){ AST_LITERAL, totype, .ival = data });
            off += totype->size;
            size -= totype->size;
            if (iter_end(iter))
                break;
        } else {
Пример #3
0
Object c_GenMapWaitHandle::ti_create(const Variant& dependencies) {
  if (UNLIKELY(!dependencies.isObject() ||
      dependencies.getObjectData()->getCollectionType() !=
        Collection::MapType)) {
    Object e(SystemLib::AllocInvalidArgumentExceptionObject(
      "Expected dependencies to be an instance of Map"));
    throw e;
  }
  assert(dependencies.getObjectData()->instanceof(c_Map::classof()));
  auto deps = p_Map::attach(c_Map::Clone(dependencies.getObjectData()));
  for (ssize_t iter_pos = deps->iter_begin();
       deps->iter_valid(iter_pos);
       iter_pos = deps->iter_next(iter_pos)) {

    auto* current = tvAssertCell(deps->iter_value(iter_pos));
    if (UNLIKELY(!c_WaitHandle::fromCell(current))) {
      Object e(SystemLib::AllocInvalidArgumentExceptionObject(
        "Expected dependencies to be a map of WaitHandle instances"));
      throw e;
    }
  }

  Object exception;
  for (ssize_t iter_pos = deps->iter_begin();
       deps->iter_valid(iter_pos);
       iter_pos = deps->iter_next(iter_pos)) {

    auto* current = tvAssertCell(deps->iter_value(iter_pos));
    assert(current->m_type == KindOfObject);
    assert(current->m_data.pobj->instanceof(c_WaitHandle::classof()));
    auto child = static_cast<c_WaitHandle*>(current->m_data.pobj);

    if (child->isSucceeded()) {
      auto k = deps->iter_key(iter_pos);
      deps->set(k.asCell(), &child->getResult());
    } else if (child->isFailed()) {
      putException(exception, child->getException());
    } else {
      assert(child->instanceof(c_WaitableWaitHandle::classof()));
      auto child_wh = static_cast<c_WaitableWaitHandle*>(child);

      p_GenMapWaitHandle my_wh = NEWOBJ(c_GenMapWaitHandle)();
      my_wh->initialize(exception, deps.get(), iter_pos, child_wh);

      AsioSession* session = AsioSession::Get();
      if (UNLIKELY(session->hasOnGenMapCreateCallback())) {
        session->onGenMapCreate(my_wh.get(), dependencies);
      }

      return my_wh;
    }
  }

  if (exception.isNull()) {
    return Object::attach(c_StaticWaitHandle::CreateSucceeded(
      make_tv<KindOfObject>(deps.detach())));
  } else {
    return Object::attach(c_StaticWaitHandle::CreateFailed(exception.detach()));
  }
}
Пример #4
0
void animation_free(animation *ani) {
    iterator it;

    // Free animation string
    str_free(&ani->animation_string);

    // Free collision coordinates
    vector_free(&ani->collision_coords);

    // Free extra strings
    vector_iter_begin(&ani->extra_strings, &it);
    str *tmp_str = NULL;
    while((tmp_str = iter_next(&it)) != NULL) {
        str_free(tmp_str);
    }
    vector_free(&ani->extra_strings);

    // Free animations
    vector_iter_begin(&ani->sprites, &it);
    sprite *tmp_sprite = NULL;
    while((tmp_sprite = iter_next(&it)) != NULL) {
        sprite_free(tmp_sprite);
    }
    vector_free(&ani->sprites);
}
Пример #5
0
void scene_tick(scene *scene) {
    // Remove finished players
    scene_clean_ani_players(scene);

    // Tick all players
    iterator it;
    animationplayer *tmp = 0;
    list_iter_begin(&scene->child_players, &it);
    while((tmp = iter_next(&it)) != NULL) {
        animationplayer_run(tmp);
    }
    list_iter_begin(&scene->root_players, &it);
    while((tmp = iter_next(&it)) != NULL) {
        animationplayer_run(tmp);
    }

    // Run custom tick function, if defined
    if(scene->tick != NULL) {
        scene->tick(scene);
    }
        
    // If no animations to play, jump to next scene (if any)
    // TODO: Hackish, make this nicer.
    if(list_size(&scene->root_players) <= 0 && scene->this_id != SCENE_MELEE && scene->this_id != SCENE_VS && scene->this_id != SCENE_MECHLAB) {
        if (scene->this_id == SCENE_CREDITS) {
            scene->next_id = SCENE_NONE;
        } else {
            scene->next_id = SCENE_MENU;
        }
        DEBUG("NEXT ID!");
    }
}
Пример #6
0
void _set_track_val_list(track_ctx_t *trackctx,
                         list_t *bindings,
                         byte_t *val_list,
                         size_t *list_sz)
{
  list_iterator_t iter_binding, iter_track;
  uint_t          idx;
  track_ctx_t     *trackctx_ptr = NULL;
  binding_t       *binding = NULL;

  memset(val_list, 0, 256);
  for (iter_init(&iter_binding, bindings), idx = 0;
       iter_node(&iter_binding);
       iter_next(&iter_binding))
    {
      binding = iter_node_ptr(&iter_binding);
      for (iter_init(&iter_track, &(binding->tracks));
           iter_node(&iter_track);
           iter_next(&iter_track))
        {
          trackctx_ptr = iter_node_ptr(&iter_track);
          if (trackctx == trackctx_ptr)
            {
              val_list[idx] = binding->val;
              idx++;
              break;
            }
        }
    }
  *list_sz = idx;
}
Пример #7
0
static cairo_bool_t
_cairo_contour_simplify_chain (cairo_contour_t *contour, const double tolerance,
			       const cairo_contour_iter_t *first,
			       const cairo_contour_iter_t *last)
{
    cairo_contour_iter_t iter, furthest;
    uint64_t max_error;
    int x0, y0;
    int nx, ny;
    int count;

    iter = *first;
    iter_next (&iter);
    if (iter_equal (&iter, last))
	return FALSE;

    x0 = first->point->x;
    y0 = first->point->y;
    nx = last->point->y - y0;
    ny = x0 - last->point->x;

    count = 0;
    max_error = 0;
    do {
	cairo_point_t *p = iter.point;
	if (! DELETED(p)) {
	    uint64_t d = (uint64_t)nx * (x0 - p->x) + (uint64_t)ny * (y0 - p->y);
	    if (d * d > max_error) {
		max_error = d * d;
		furthest = iter;
	    }
	    count++;
	}
	iter_next (&iter);
    } while (! iter_equal (&iter, last));
    if (count == 0)
	return FALSE;

    if (max_error > tolerance * ((uint64_t)nx * nx + (uint64_t)ny * ny)) {
	cairo_bool_t simplified;

	simplified = FALSE;
	simplified |= _cairo_contour_simplify_chain (contour, tolerance,
						     first, &furthest);
	simplified |= _cairo_contour_simplify_chain (contour, tolerance,
						     &furthest, last);
	return simplified;
    } else {
	iter = *first;
	iter_next (&iter);
	do {
	    MARK_DELETED (iter.point);
	    iter_next (&iter);
	} while (! iter_equal (&iter, last));

	return TRUE;
    }
}
static dbus_bool_t
find_next_typecode (DBusMessageDataIter *iter,
                    DBusString          *data,
                    DBusValidity        *expected_validity)
{
  int body_seq;
  int byte_seq;
  int base_depth;

  base_depth = iter->depth;

 restart:
  _dbus_assert (iter->depth == (base_depth + 0));
  _dbus_string_set_length (data, 0);

  body_seq = iter_get_sequence (iter);
  
  if (!generate_many_bodies (iter, data, expected_validity))
    return FALSE;
  /* Undo the "next" in generate_many_bodies */
  iter_set_sequence (iter, body_seq);
  
  iter_recurse (iter);
  while (TRUE)
    {
      _dbus_assert (iter->depth == (base_depth + 1));
      
      byte_seq = iter_get_sequence (iter);

      _dbus_assert (byte_seq <= _dbus_string_get_length (data));
      
      if (byte_seq == _dbus_string_get_length (data))
        {
          /* reset byte count */
          iter_set_sequence (iter, 0);
          iter_unrecurse (iter);
          _dbus_assert (iter->depth == (base_depth + 0));
          iter_next (iter); /* go to the next body */
          goto restart;
        }

      _dbus_assert (byte_seq < _dbus_string_get_length (data));

      if (dbus_type_is_valid (_dbus_string_get_byte (data, byte_seq)))
        break;
      else
        iter_next (iter);
    }

  _dbus_assert (byte_seq == iter_get_sequence (iter));
  _dbus_assert (byte_seq < _dbus_string_get_length (data));

  iter_unrecurse (iter);

  _dbus_assert (iter->depth == (base_depth + 0));
  
  return TRUE;
}
static dbus_bool_t
generate_typecode_changed (DBusMessageDataIter *iter,
                           DBusString          *data,
                           DBusValidity        *expected_validity)
{
  int byte_seq;
  int typecode_seq;
  int base_depth;

  base_depth = iter->depth;

 restart:
  _dbus_assert (iter->depth == (base_depth + 0));
  _dbus_string_set_length (data, 0);
  
  if (!find_next_typecode (iter, data, expected_validity))
    return FALSE;

  iter_recurse (iter);
  byte_seq = iter_get_sequence (iter);

  _dbus_assert (byte_seq < _dbus_string_get_length (data));
  
  iter_recurse (iter);
  typecode_seq = iter_get_sequence (iter);
  iter_next (iter);

  _dbus_assert (typecode_seq <= _DBUS_N_ELEMENTS (typecodes));
  
  if (typecode_seq == _DBUS_N_ELEMENTS (typecodes))
    {
      _dbus_assert (iter->depth == (base_depth + 2));
      iter_set_sequence (iter, 0); /* reset typecode sequence */
      iter_unrecurse (iter);
      _dbus_assert (iter->depth == (base_depth + 1));
      iter_next (iter); /* go to the next byte_seq */
      iter_unrecurse (iter);
      _dbus_assert (iter->depth == (base_depth + 0));
      goto restart;
    }

  _dbus_assert (iter->depth == (base_depth + 2));
  iter_unrecurse (iter);
  _dbus_assert (iter->depth == (base_depth + 1));
  iter_unrecurse (iter);
  _dbus_assert (iter->depth == (base_depth + 0));

#if 0
  printf ("Changing byte %d in message %d to %c\n",
          byte_seq, iter_get_sequence (iter), typecodes[typecode_seq]);
#endif
  
  _dbus_string_set_byte (data, byte_seq, typecodes[typecode_seq]);
  *expected_validity = DBUS_VALIDITY_UNKNOWN;
  return TRUE;
}
Пример #10
0
gchar *
gegl_instrument_utf8 (void)
{
  GString *s = g_string_new ("");
  gchar   *ret;
  Timing  *iter = root;

  sort_children (root);

  while (iter)
    {
      gchar *buf;

      if (!strcmp (iter->name, root->name))
        {
          buf = g_strdup_printf ("Total time: %.3fs\n", seconds (iter->usecs));
          s   = g_string_append (s, buf);
          g_free (buf);
        }

      s = tab_to (s, timing_depth (iter) * INDENT_SPACES);
      s = g_string_append (s, iter->name);

      s   = tab_to (s, SECONDS_COL);
      buf = g_strdup_printf ("%5.1f%%", iter->parent ? 100.0 * iter->usecs / iter->parent->usecs : 100.0);
      s   = g_string_append (s, buf);
      g_free (buf);
      s = tab_to (s, BAR_COL);
      s = bar (s, BAR_WIDTH, normalized (iter->usecs));
      s = g_string_append (s, "\n");

      if (timing_depth (iter_next (iter)) < timing_depth (iter))
        {
          if (timing_other (iter->parent) > 0)
            {
              s   = tab_to (s, timing_depth (iter) * INDENT_SPACES);
              s   = g_string_append (s, "other");
              s   = tab_to (s, SECONDS_COL);
              buf = g_strdup_printf ("%5.1f%%", 100 * normalized (timing_other (iter->parent)));
              s   = g_string_append (s, buf);
              g_free (buf);
              s = tab_to (s, BAR_COL);
              s = bar (s, BAR_WIDTH, normalized (timing_other (iter->parent)));
              s = g_string_append (s, "\n");
            }
          s = g_string_append (s, "\n");
        }

      iter = iter_next (iter);
    }

  ret = g_strdup (s->str);
  g_string_free (s, TRUE);
  return ret;
}
Пример #11
0
distance_label_t *graph_find_path(graph_t *g,char *time, void *from, void *to)
{
    assert(graph_has_node(g, from) && graph_has_node(g, to));
    list_t *visited = list_new();
    list_t *distanceLabels = list_new();
    iter_t *it;
    for (it = iter(g->nodes); !iter_done(it); iter_next(it))
        {
            distance_label_t *dl = calloc(1, sizeof(distance_label_t));
            dl->dist = -1;
            dl->label = iter_get(it);
            dl->path = NULL;
	    dl->path_edges = NULL;
	    dl->arrival_time = time;
            list_add(distanceLabels, dl);
        }
    iter_free(it);
    get_distance_label(distanceLabels, from, g->comp)->path = list_new();
    get_distance_label(distanceLabels, from, g->comp)->path_edges = list_new();
    dijkstra(g, from, to, visited, distanceLabels);
    distance_label_t *best = get_distance_label(distanceLabels, to, g->comp);
    assert(best);
    free_distancelabels(g->comp,distanceLabels,best);
    list_free(visited);

    graph_print_trip(g,time,from,best);
    
    return best;
}
Пример #12
0
void *get_min_distance_node(list_t *distanceLabels, comparator_t comp,
                            list_t *visited)
{
    assert(distanceLabels);

    int minDist = -1;
    void *minLabel = NULL;
    iter_t *it;
    for (it = iter(distanceLabels); !iter_done(it); iter_next(it))
        {
            distance_label_t *itdl = iter_get(it);
            if (itdl->dist == -1) // inte varit där
                {
                    continue;
                }
            if (list_has(visited, comp, itdl->label)) // finns redan i visited, abort
                {
                    continue;
                }
            if (minDist == -1 || itdl->dist < minDist)// om inte ändrats en enda gång eller nya distansen 'r mindre än förra minsta distans.
                {
                    minDist = itdl->dist;
                    minLabel = itdl->label;
                }
        }
    iter_free(it);
    return minLabel;
}
Пример #13
0
ALWAYS_INLINE
typename std::enable_if<
  std::is_base_of<BaseMap, TMap>::value, Object>::type
BaseMap::php_takeWhile(const Variant& fn) {
  CallCtx ctx;
  vm_decode_function(fn, nullptr, false, ctx);
  if (!ctx.func) {
    SystemLib::throwInvalidArgumentExceptionObject(
               "Parameter must be a valid callback");
  }
  auto map = req::make<TMap>();
  if (!m_size) return Object{std::move(map)};
  int32_t version UNUSED;
  if (std::is_same<c_Map, TMap>::value) {
    version = m_version;
  }
  for (ssize_t pos = iter_begin(); iter_valid(pos); pos = iter_next(pos)) {
    auto* e = iter_elm(pos);
    bool b = invokeAndCastToBool(ctx, 1, &e->data);
    if (std::is_same<c_Map, TMap>::value) {
      if (UNLIKELY(version != m_version)) {
        throw_collection_modified();
      }
    }
    if (!b) break;
    e = iter_elm(pos);
    if (e->hasIntKey()) {
      map->set(e->ikey, &e->data);
    } else {
      assert(e->hasStrKey());
      map->set(e->skey, &e->data);
    }
  }
  return Object{std::move(map)};
}
Пример #14
0
bool_t iter_move_to_addr(list_iterator_t *iterator, void *addr)
{
  for (iter_head(iterator); iter_node(iterator); iter_next(iterator))
    if (iter_node_ptr(iterator) == addr)
      return TRUE;
  return FALSE;
}
Пример #15
0
int ai_block_projectile(controller *ctrl, ctrl_event **ev) {
    ai *a = ctrl->data;
    object *o = ctrl->har;

    iterator it;
    object **o_tmp;
    vector_iter_begin(&a->active_projectiles, &it);
    while((o_tmp = iter_next(&it)) != NULL) {
        object *o_prj = *o_tmp;
        if(projectile_get_owner(o_prj) == o)  {
            continue;
        }
        if(o_prj->cur_sprite && maybe(a->difficulty)) {
            vec2i pos_prj = vec2i_add(object_get_pos(o_prj), o_prj->cur_sprite->pos);
            vec2i size_prj = object_get_size(o_prj);
            if (object_get_direction(o_prj) == OBJECT_FACE_LEFT) {
                pos_prj.x = object_get_pos(o_prj).x + ((o_prj->cur_sprite->pos.x * -1) - size_prj.x);
            }
            if(fabsf(pos_prj.x - o->pos.x) < 120) {
                a->cur_act = (o->direction == OBJECT_FACE_RIGHT ? ACT_DOWN|ACT_LEFT : ACT_DOWN|ACT_RIGHT);
                controller_cmd(ctrl, a->cur_act, ev);
                return 1;
            }
        }

    }

    return 0;
}
Пример #16
0
/** kmeans_reduce()
 *	Updates the sum calculation for the various points
 */
void kmeans_reduce(void *key_in, iterator_t *itr)
{
    assert (key_in);
    assert (itr);
    
    int i;
    int *sum;
    int *mean;
    void *val;
    int vals_len = iter_size (itr);
    
    sum = (int *)calloc(dim, sizeof(int));
    mean = (int *)malloc(dim * sizeof(int));
    
    i = 0;
    while (iter_next (itr, &val))
    {
        add_to_sum (sum, val);
        ++i;
    }
    assert (i == vals_len);
    
    for (i = 0; i < dim; i++)
    {
        mean[i] = sum[i] / vals_len;
    }
    
    free(sum);
    emit(key_in, (void *)mean);
}
Пример #17
0
int main(int argc, const char** argv)
{
	//fprintf(stderr,"%s\n","Who even knows the even what?");
	
	FILE* f;
	const char* fname = 0;
	char* buf;
	
	if (argc > 1)
		fname = argv[1];
	f = fopen(fname,"r");
	
	int buflen = 120;
	iter* fiter = new_iter(f,0,buflen,'\n');
	
	buf = fiter->buf;
	
	int h = -1;
	char* s = 0;
	char c[1024];
	char n = 0;
	int i = 0;
	do {
		//fprintf(stderr,"n: %i, %i, %08x\n",n,fiter->bufcount,fiter->flags);
		s = iter_next(fiter);
		printf("%s\n",s);
		i++;
	} while (s && i < 15);
	
	free_iter(fiter);
	fclose(f);
	
	return 0;
}
Пример #18
0
void write_midifile_track_engine_ctx(int fd, engine_ctx_t *ctx)
{
  list_iterator_t iter;
  output_t        *output;
  buf_node_t      head = {NULL, 0, NULL};
  buf_node_t      *node;
  uint_t          idx = 0;

  for (iter_init(&iter, &(ctx->output_list)),
         node = &head,
         idx = 0;
       iter_node(&iter);
       iter_next(&iter),
         idx++)
    {
      output = iter_node_ptr(&iter);
      node = _append_sysex_port(node, output, idx);
    }

  node = _append_metaev_set_tempo(node, ctx->tempo);
  /* node = _append_metaev_eot(node); */
  _append_metaev_eot(node);

  node = get_midifile_trackhdr(get_buf_list_size(head.next));
  node->next = head.next;

  write_buf_list(fd, node);
  free_buf_list(node);
}
Пример #19
0
static int
global_saxdb_read(struct dict *db)
{
    struct record_data *hir;
    time_t posted;
    long flags;
    unsigned long duration;
    char *str, *from, *message;
    dict_iterator_t it;

    for(it=dict_first(db); it; it=iter_next(it))
    {
        hir = iter_data(it);
	if(hir->type != RECDB_OBJECT)
	{
	    log_module(G_LOG, LOG_WARNING, "Unexpected rectype %d for %s.", hir->type, iter_key(it));
            continue;
	}

        str = database_get_data(hir->d.object, KEY_FLAGS, RECDB_QSTRING);
        flags = str ? strtoul(str, NULL, 0) : 0;

        str = database_get_data(hir->d.object, KEY_POSTED, RECDB_QSTRING);
        posted = str ? strtoul(str, NULL, 0) : 0;

        str = database_get_data(hir->d.object, KEY_DURATION, RECDB_QSTRING);
        duration = str ? strtoul(str, NULL, 0) : 0;

        from = database_get_data(hir->d.object, KEY_FROM, RECDB_QSTRING);
        message = database_get_data(hir->d.object, KEY_MESSAGE, RECDB_QSTRING);

	message_add(flags, posted, duration, from, message);
    }
    return 0;
}
Пример #20
0
void cpp_eval(char *buf) {
    FILE *fp = fmemopen(buf, strlen(buf), "r");
    set_input_file("(eval)", NULL, fp);
    List *toplevels = read_toplevels();
    for (Iter *i = list_iter(toplevels); !iter_end(i);)
        emit_toplevel(iter_next(i));
}
Пример #21
0
char* iter_next(iter* it)
{
	if (it->flags & _iter_LAST_LINE)
		return 0;
	
	char* buf = it->buf;
	int buflen = it->buflen;
	
	//fprintf(stderr,"xind: %i\n",it->xind);
	// Double zeros.  We need to force a double-zero on the final buffer read.
	if (!buf[it->xind] || it->xind >= it->buflen) {
		if (it->flags & _iter_FINAL_READ) {
			// Reached the end of everything, I guess...
			it->flags |= _iter_LAST_LINE;
			return 0;
		}
		else {
			// Buffer reset trailing line to beginning, so gotta do again.
			//fprintf(stderr,"Vrap daggle.\n");
			_iter_next_buffer(it);
			return iter_next(it);
		}
	}
	
	char* c = &buf[it->xind];
	
	int i;
	for (i=it->xind; buf[i] && i < buflen; ++i) {
		////fprintf(stderr,"%i,%c\n",i,buf[i]);
		if (buf[i] == '\n') {
			buf[i] = 0;
			break;
		}
	}
	++i;
	if (i >= buflen && buf[i-1] != '\n') {
		//fprintf(stderr,"This one, here... but with i,xind,buflen: %i, %i, %i\n",i,it->xind,buflen);
		_iter_next_buffer(it);
		return iter_next(it);
	}
	
	it->xind = i;
	//fprintf(stderr,"setting xind to: %i\n",i);
	// At this point, the returned string is ready to go.  Just need to set xind.
	
	return c;
}
Пример #22
0
void menu_tick(menu *menu) {
    iterator it;
    component **tmp;
    vector_iter_begin(&menu->objs, &it);
    while((tmp = iter_next(&it)) != NULL) {
        (*tmp)->tick(*tmp);
    }
}
Пример #23
0
static Timing *timing_find (Timing      *root,
                            const gchar *name)
{
  Timing *iter = root;

  if (!iter)
    return NULL;

  while (iter)
    {
      if (!strcmp (iter->name, name))
        return iter;
      if (timing_depth (iter_next (iter)) <= timing_depth (root))
        return NULL;
      iter = iter_next (iter);
    }
  return NULL;
}
Пример #24
0
Файл: gen.c Проект: irori/8cc
static char *get_caller_list(void) {
    String *s = make_string();
    for (Iter *i = list_iter(functions); !iter_end(i);) {
        string_appendf(s, "%s", iter_next(i));
        if (!iter_end(i))
            string_appendf(s, " -> ");
    }
    return get_cstring(s);
}
Пример #25
0
void menu_render(menu *menu) {
    iterator it;
    component **tmp;
    video_render_sprite(&menu->sur, menu->x, menu->y, BLEND_ALPHA, 0);
    vector_iter_begin(&menu->objs, &it);
    while((tmp = iter_next(&it)) != NULL) {
        (*tmp)->render(*tmp);
    }
}
Пример #26
0
int main2()
    //@ requires emp;
    //@ ensures emp;
{
    struct llist *l = create_llist();
    llist_add(l, 5);
    llist_add(l, 10);
    llist_add(l, 15);
    struct iter *i1 = llist_create_iter(l);
    struct iter *i2 = llist_create_iter(l);
    int i1e1 = iter_next(i1); assert(i1e1 == 5);
    int i2e1 = iter_next(i2); assert(i2e1 == 5);
    int i1e2 = iter_next(i1); assert(i1e2 == 10);
    int i2e2 = iter_next(i2); assert(i2e2 == 10);
    iter_dispose(i1);
    iter_dispose(i2);
    llist_dispose(l);
    return 0;
}
Пример #27
0
void graph_foreach_edge(graph_t *g, void_fun3_t f)
{
    iter_t *it;
    for (it = iter(g->edges); !iter_done(it); iter_next(it))
        {
            edge_t  *e = iter_get(it);
            f(e->from, e->to, e->label);
        }
    iter_free(it);
}
Пример #28
0
Файл: gen.c Проект: irori/8cc
static void set_reg_nums(List *args) {
    numgp = numfp = 0;
    for (Iter *i = list_iter(args); !iter_end(i);) {
        Node *arg = iter_next(i);
        if (is_flotype(arg->ctype))
            numfp++;
        else
            numgp++;
    }
}
Пример #29
0
void tcache_clear() {
    iterator it;
    hashmap_iter_begin(&cache->entries, &it);
    hashmap_pair *pair;
    while((pair = iter_next(&it)) != NULL) {
        tcache_entry_value *entry = pair->val;
        SDL_DestroyTexture(entry->tex);
    }
    hashmap_clear(&cache->entries);
}
Пример #30
0
int menu_get_ypos(menu *menu) {
    int ypos = 8;
    iterator it;
    vector_iter_begin(&menu->objs, &it);
    component **tmp;
    while((tmp = iter_next(&it)) != NULL) {
        ypos += (*tmp)->h;
    }
    return ypos;
}