Beispiel #1
0
static void *fwd_tab( VTAB *vtab, VTABAREA *curr, unsigned wrap )
{
    VTABAREA            *chase;

    if( curr == NULL ) {
        chase = vtab->first;
    } else {
        chase = _next( curr );
    }
    for( ; ; ) {
        if( chase == NULL ) {
            if( wrap ) {
                chase = vtab->first;
            } else {
                chase = NULL;
                break;
            }
        }
        if( _tab( chase ) ) break;
        if( chase == curr ) {
            chase = NULL;
            break;
        }
        chase = _next( chase );
    }
    return( chase );
}
Beispiel #2
0
Boolean XmlParser::next(XmlEntry& entry, Boolean includeComment)
{
    if (_hideEmptyTags)
    {
        // Get the next tag.

        if (!_next(entry, includeComment))
            return false;

        // If an EMPTY_TAG is encountered, then convert it to a START_TAG and 
        // push a matching END_TAG on the put-back stack. This hides every
        // EMPTY_TAG from the caller.

        if (entry.type == XmlEntry::EMPTY_TAG)
        {
            entry.type = XmlEntry::START_TAG;

            XmlEntry tmp;
            tmp.type = XmlEntry::END_TAG;
            tmp.text = entry.text;
            tmp.nsType = entry.nsType;
            tmp.localName = entry.localName;

            _putBackStack.push(tmp);
        }

        return true;
    }
    else
        return _next(entry, includeComment);
}
Beispiel #3
0
static void *bwd_tab( VTAB *vtab, VTABAREA *curr, unsigned wrap )
{
    VTABAREA           *chase, *hold;

    hold = NULL;
    chase = vtab->first;
    while( chase != curr ) {
        if( _tab( chase ) ) {
            hold = chase;
        }
        chase = _next( chase );
    }
    if( hold == NULL ) {
        if( wrap ) {
            while( chase != NULL ) {
                if( _tab( chase ) ) {
                    hold = chase;
                }
                chase = _next( chase );
            }
        } else {
            hold = NULL;
        }
    }
    return( hold );
}
Beispiel #4
0
void History::toJson(JsonArray& json)
{
  for (int i = _next(_last); i != _last; i = _next(i))
    json.add(_records[i]);

  json.add<unsigned short>(_records[_last]);
}
Beispiel #5
0
/* shim
*/
  u2_noun                                                         //  produce
  j2_mcx(Pt5, shim, fun)(u2_wire wir_r,
                         u2_noun zep,                             //  retain
                         u2_noun tub)                             //  retain
  {
    u2_noun p_tub, q_tub;

    u2_bi_cell(wir_r, tub, &p_tub, &q_tub);

    if ( u2_no == u2_dust(q_tub) ) {
      return _fail(wir_r, tub);
    }
    else {
      u2_noun p_zep, q_zep;
      u2_noun iq_tub = u2_h(q_tub);

      u2_bi_cell(wir_r, zep, &p_zep, &q_zep);
      if ( u2_fly_is_cat(p_zep) && 
           u2_fly_is_cat(q_zep) &&
           u2_fly_is_cat(iq_tub) )
      {
        if ( (iq_tub >= p_zep) && (iq_tub <= q_zep) ) {
          return _next(wir_r, tub);
        }
        else return _fail(wir_r, tub);
      }
      else {
        return u2_bl_bail(wir_r, c3__fail);
      }
    }
  }
Beispiel #6
0
Token Lexer::_next() {
    if (_pos == _end) {
        return {Token::EOF_, "<EOF>", {_line, _col}};
    }

    std::smatch sm;


    if (*_pos == '\n') {
        return _consumeSep();
    } else if (isspace(*_pos)) {
        return _consumeSpaces();
    } else if (std::regex_search(_pos, _end, sm, _comment_pattern,
        std::regex_constants::match_continuous)) {
        _pos += sm.length();
        _line += 1;
        _col = 0;
        return _next();
        
    } else {
        size_t i = 0;

        for (auto& r : _token_patterns) {
            if (std::regex_search(_pos, _end, sm, r, std::regex_constants::match_continuous)) {
                Token ret{_token_types[i], sm.str(sm.size() > 1 ? 1 : 0), {_line, _col}};
                _col += sm.length();
                _pos += sm.length();
                return ret;
            }
            i += 1;
        }

        return _consumeUnknown();
    }
}
Beispiel #7
0
/* shim
*/
  u3_noun
  _cqe_shim_fun(u3_noun zep,
                u3_noun tub)
  {
    u3_noun p_tub, q_tub;

    u3x_cell(tub, &p_tub, &q_tub);

    if ( c3n == u3du(q_tub) ) {
      return _fail(tub);
    }
    else {
      u3_noun p_zep, q_zep;
      u3_noun iq_tub = u3h(q_tub);

      u3x_cell(zep, &p_zep, &q_zep);
      if ( _(u3a_is_cat(p_zep)) &&
           _(u3a_is_cat(q_zep)) &&
           _(u3a_is_cat(iq_tub)) )
      {
        if ( (iq_tub >= p_zep) && (iq_tub <= q_zep) ) {
          return _next(tub);
        }
        else return _fail(tub);
      }
      else {
        return u3m_bail(c3__fail);
      }
    }
  }
static struct httpc* _httpc_new()
{
	gint err;
	gchar sid[33];
	GString *buff = qev_buffer_get();
	struct httpc *hc = g_slice_alloc0(sizeof(*hc));

	_uuid(sid);

	hc->polling = test_socket();
	hc->waiting = test_socket();
	hc->aq = g_async_queue_new();
	hc->sid = g_strdup(sid);
	hc->th_run = TRUE;
	g_mutex_init(&hc->lock);

	hc->th = g_thread_new("httpc", _httpc_thread, hc);

	g_string_printf(buff, INIT_HEADERS, hc->sid);
	err = send(hc->polling, buff->str, buff->len, 0);
	ck_assert_int_eq(err, buff->len);

	qev_buffer_put(buff);

	_next(hc, "/qio/callback/1:0={\"code\":200,\"data\":\"localhost\"}");

	return hc;
}
Beispiel #9
0
bool
RingBuffer::get(void *val, size_t val_size)
{
	if (_tail != _head) {
		unsigned candidate;
		unsigned next;

		if ((val_size == 0) || (val_size > _item_size)) {
			val_size = _item_size;
		}

		do {
			/* decide which element we think we're going to read */
			candidate = _tail;

			/* and what the corresponding next index will be */
			next = _next(candidate);

			/* go ahead and read from this index */
			if (val != NULL) {
				memcpy(val, &_buf[candidate * _item_size], val_size);
			}

			/* if the tail pointer didn't change, we got our item */
		} while (!__PX4_SBCAP(&_tail, candidate, next));

		return true;

	} else {
		return false;
	}
}
vector<string> ObjectFunctor::operator()()
{
	vector<string> result;
	NetworkID id = get();

	if (id)
	{
		FactoryObject reference = GameFactory::GetObject(id);
		Reference* object = vaultcast<Object>(reference);

		if (object)
		{
			unsigned int flags = this->flags();

			if (flags & FLAG_REFERENCE)
				result.push_back(Utils::toString(object->GetReference()));
			else if (flags & FLAG_BASE)
				result.push_back(Utils::toString(object->GetBase()));
		}
	}
	else
	{
		vector<FactoryObject>::iterator it;
		vector<FactoryObject> references = GameFactory::GetObjectTypes(ID_OBJECT);
		unsigned int refID;

		for (it = references.begin(); it != references.end(); GameFactory::LeaveReference(*it), ++it)
			if ((refID = (**it)->GetReference()) && !filter(**it))
				result.push_back(Utils::toString(refID));
	}

	_next(result);

	return result;
}
Beispiel #11
0
ROMol *SDMolSupplier::next() {
  PRECONDITION(dp_inStream, "no stream");
  if (df_end && d_last >= d_len) {
    throw FileParseException("EOF hit.");
  }

  // set the stream to the current position
  dp_inStream->seekg(d_molpos[d_last]);

  std::string tempStr;
  ROMol *res = NULL;
  // finally if we reached the end of the file set end to be true
  if (dp_inStream->eof()) {
    // FIX: we should probably be throwing an exception here
    df_end = true;
    d_len = d_molpos.size();
    return res;
  }

  res = _next();

  ++d_last;
  std::streampos posHold = dp_inStream->tellg();
  this->checkForEnd();
  if (!this->df_end && d_last >= static_cast<int>(d_molpos.size())) {
    d_molpos.push_back(posHold);
  }

  return res;
}
Beispiel #12
0
Token Lexer::_consumeSpaces() {
    while (isspace(*_pos) && *_pos != '\n') {
        _col += 1;
        _pos += 1;
    }
    return _next();
}
Beispiel #13
0
void Font::_loadFont(FT_Face &face) {
  FT_Set_Char_Size(face, _height << 6, _height << 6, 96, 96);
  glGenTextures(kMaxChars, _textures);
  
  for (wchar_t ch = 0; ch < kMaxChars; ch++) {
    if (FT_Load_Glyph(face, FT_Get_Char_Index(face, ch), FT_LOAD_DEFAULT)) {
      log.error(kModFont, "%s: %c", kString15006, ch);
      return;
    }
    
    FT_Glyph glyph;
    if (FT_Get_Glyph(face->glyph, &glyph)) {
      log.error(kModFont, "%s: %c", kString15007, ch);
      return;
    }
    
    FT_Glyph_To_Bitmap(&glyph, ft_render_mode_normal, 0, 1);
    FT_BitmapGlyph bitmapGlyph = (FT_BitmapGlyph)glyph;
    FT_Bitmap bitmap = bitmapGlyph->bitmap;
    
    int width = _next(bitmap.width);
    int height = _next(bitmap.rows);
    GLubyte* expandedData;
    expandedData = new GLubyte[2 * width * height];
    
    for (int j = 0; j < height; j++) {
      for (int i = 0; i < width; i++) {
        expandedData[2 * (i + j * width)] =
        expandedData[2 * (i + j * width) + 1] =
        (i >= bitmap.width || j >= bitmap.rows) ?
        0 : bitmap.buffer[i + bitmap.width * j];
      }
    }
    
    float x = static_cast<float>(bitmap.width) / static_cast<float>(width);
    float y = static_cast<float>(bitmap.rows) / static_cast<float>(height);
    _glyph[ch] = _makeGlyph(x, y, bitmap, bitmapGlyph, face);
    
    glBindTexture(GL_TEXTURE_2D, _textures[ch]);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexImage2D(GL_TEXTURE_2D, 0, 2, width, height, 0,
                 GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, expandedData);
    delete[] expandedData;
  }
  _isLoaded = true;
}
Beispiel #14
0
std::vector<Token> Lexer::run() {
    _pos = _input.cbegin();
    _end = _input.cend();
    _col = 0;
    _line = 0;

    Token token{_next()};

    while (true) {
        _tokens.push_back(token);
        if (token.getType() == Token::EOF_) {
            break;
        }
        token = _next();
    }

    return _tokens;
}
Beispiel #15
0
bool ElementIterator::hasNext()
{
  if (_pending.empty())
  {
    _next();
  }

  return _pending.empty() == false;
}
npy_double npy_spacing(npy_double x)
{
    /* XXX: npy isnan/isinf may be optimized by bit twiddling */
    if (npy_isinf(x)) {
        return NPY_NAN;
    }

    return _next(x, 1) - x;
}
Beispiel #17
0
/**
 * If the object has only constant values, it pre-evalutes the object.
 * so that the expression doesn't need to be evaluated repeatedly.
 */
static muse_cell json_share_object_expr( muse_env *env, muse_cell objexpr )
{
	muse_cell listitems = _tail(_head(_tail(objexpr)));

	while ( listitems ) {
		if ( !json_is_constant( env, _next(&listitems) ) )
			return objexpr;
	}

	return muse_eval( env, objexpr, MUSE_FALSE );
}
Beispiel #18
0
void indri::file::DirectoryIterator::_next() {
  directoryiterator_next( _platform );
  _copyCurrent();

  std::string current = directoryiterator_current( _platform );

  if( !directoryiterator_done( _platform ) &&
      (current == "." || current == "..") ) {
    _next();
  }
}
Beispiel #19
0
	//_____________________________________________________________________________
	LayerHook * ModalHook::_nextLayerHook() const
	{
		ModalHook * p = _next();
	
		// We have multiple inheritance, so lets make the cast in a safe way, preserving NULL-pointer as NULL.
	
		if( p )
			return p;
		else
			return 0;
	}
END_TEST

START_TEST(test_http_tons_of_newlines)
{
	struct httpc *hc = _httpc_new();

	_send(hc, "\n\n\n\n\n\n\n\n\n\n/qio/ping:1=null\n\n\n\n\n\n\n\n");
	_next(hc, "/qio/callback/1:0={\"code\":200,\"data\":null}");

	_httpc_free(hc);
}
Beispiel #21
0
  ROMol *ForwardSDMolSupplier::next() {
    PRECONDITION(dp_inStream,"no stream");
    ROMol *res = NULL;

    if (dp_inStream->eof()) {
      //FIX: we should probably be throwing an exception here
      df_end = true;
      return res;
    }

    res=_next();
    return res;
  }
Beispiel #22
0
 // Increase iterator
 void increment() {
     if (cur != end) {
         _next(cur);
         if (cur != end) {
             for (auto it = begin; it != cur; ++it) {
                 // In order to avoid duplicates, we call increment() again if `cur->base` has already been iterated
                 if ((not it->isConstant()) and it->base == cur->base) {
                     increment();
                     break;
                 }
             }
         }
     }
 }
END_TEST

START_TEST(test_http_incoming_wait)
{
	struct httpc *hc = _httpc_new();
	struct client *surrogate = test_get_surrogate();
	struct protocol_frames pframes = protocol_http_frame("/test", "", 0, "null");

	_send(hc, "/qio/ping:0=null");
	QEV_WAIT_FOR(surrogate->http.client != NULL);
	surrogate->http.flags.incoming = TRUE;

	protocol_http_send(surrogate, &pframes);

	_send(hc, "/qio/ping:1=null");
	_next(hc, "/test:0=null");
	_next(hc, "/qio/callback/1:0={\"code\":200,\"data\":null}");

	qev_buffer_put(pframes.def);
	qev_buffer_put(pframes.raw);

	_httpc_free(hc);
}
Beispiel #24
0
bool
RingBuffer::put(const void *val, size_t val_size)
{
	unsigned next = _next(_head);
	if (next != _tail) {
		if ((val_size == 0) || (val_size > _item_size))
			val_size = _item_size;
		memcpy(&_buf[_head * _item_size], val, val_size);
		_head = next;
		return true;
	} else {
		return false;
	}
}
Beispiel #25
0
indri::file::DirectoryIterator::DirectoryIterator( const std::string& path, bool relative ) :
  _relative(relative)
{
  _path = indri::file::Path::trim( path );
  _platform = directoryiterator_init( _path );

  std::string current = directoryiterator_current( _platform );

  if( !directoryiterator_done( _platform ) &&
      (current == "." || current == "..") ) {
    _next();
  }

  _copyCurrent();
}
Beispiel #26
0
static void json_write_object( muse_port_t p, muse_cell obj )
{
	muse_env *env = p->env;
	muse_cell plist = object_plist( env, obj );
	port_putc( '{', p );
	while ( plist ) {
		muse_cell ht = _next(&plist);
		json_write_string(p, _symname(_head(ht)));
		port_putc(':',p);
		json_write(p,_tail(ht));
		if ( plist )
			port_putc( ',', p );
	}
	port_putc( '}', p );
}
END_TEST

START_TEST(test_http_replace_poller)
{
	guint i;
	struct httpc *hc = _httpc_new();

	for (i = 0; i < 10; i++) {
		_send(hc, "/qio/ping:0=null");
	}

	_send(hc, "/qio/ping:1=null");
	_next(hc, "/qio/callback/1:0={\"code\":200,\"data\":null}");

	_httpc_free(hc);
}
Beispiel #28
0
static void json_write_hash( muse_port_t p, muse_cell obj )
{
	muse_env *env = p->env;
	int sp = _spos();
	muse_cell alist = fn_hashtable_to_alist( env, NULL, _cons(obj,MUSE_NIL) );
	_unwind(sp);
	port_putc( '{', p );
	while ( alist ) {
		muse_cell ht = _next(&alist);
		json_write_string(p, _symname(_head(ht)));
		port_putc(':',p);
		json_write(p,_tail(ht));
		if ( alist )
			port_putc( ',', p );
	}
	port_putc( '}', p );
}
Beispiel #29
0
bool QueryTextScene::HandleKeyPressed(Event::KeyEvent key)
{
	if (_input_text.handleKeyPress(key))
	{
		UpdateInputTextOrigin();
		return true;
	}
	else
	{
		if (key.code == Keyboard::Return)
		{
			_next(_input_text.getString());
			return true;
		}
		else return false;
	}
}
Beispiel #30
0
const boost::shared_ptr<Element>& ElementIterator::next()
{
  if (_pending.empty())
  {
    _next();
  }

  if (_pending.empty())
  {
    _current.reset();
  }
  else
  {
    _current = _pending.front();
    _pending.pop_front();
  }
  return _current;
}