Example #1
0
BitVector::BitVector(void) :
  _block(_zero_block),
  _count(0),
  _has_count(true)
{
  add_reference(_zero_block);
}
Example #2
0
BitVector::BitVector(const BitVector &other) :
  _block(other._block),
  _count(other._count),
  _has_count(other._has_count)
{
  add_reference(_block);
}
Example #3
0
CTemplateArray<value_type, size_type>& CTemplateArray<value_type, size_type>::operator= (const CTemplateArray<value_type, size_type>& x)
{
  sub_reference(m_key);
  m_key = x.m_key;
  add_reference(m_key);
  return *this;
}
Example #4
0
        void net_io::do_read(size_t sz)
        {
            add_reference();

            void* ptr = _parser->read_buffer_ptr((int)sz);
            int remaining = _parser->read_buffer_capacity();

            _socket.async_read_some(boost::asio::buffer(ptr, remaining),
                [this](boost::system::error_code ec, std::size_t length)
            {
                if (!!ec)
                {
                    on_failure();
                }
                else
                {
                    int read_next;
                    message_ptr msg = _parser->get_message_on_receive((int)length, read_next);

                    while (msg != nullptr)
                    {
                        this->on_message_read(msg);
                        msg = _parser->get_message_on_receive(0, read_next);
                    }
                     
                    do_read(read_next);
                }

                release_reference();
            });
        }
Example #5
0
        void net_io::do_write()
        {
            auto msg = _sq.peek();
            if (nullptr == msg.get())
                return;

            std::vector<blob> buffers;
            _parser->prepare_buffers_for_send(msg, buffers);

            std::vector<boost::asio::const_buffer> buffers2;
            for (auto& b : buffers)
            {
                buffers2.push_back(boost::asio::const_buffer(b.data(), b.length()));
            }

            add_reference();
            boost::asio::async_write(_socket, buffers2,
                [this, msg](boost::system::error_code ec, std::size_t length)
            {
                if (!!ec)
                {
                    on_failure();
                }
                else
                {
                    auto smsg = _sq.dequeue_peeked();
                    dassert(smsg == msg, "sent msg must be the first msg in send queue");
                    //dinfo("network message sent, rpc_id = %016llx", msg->header().rpc_id);

                    do_write();
                }

                release_reference();
            });
        }
Example #6
0
CTemplateArray<value_type, size_type>::CTemplateArray(value_type* data, const size_type size)
  : m_key(s_key_counter++)
{
  add_reference(m_key);
  mem().resize(size);
  memcpy(this->data(), data, sizeof(value_type) * size);
}
Example #7
0
void BitVector::set_to_ones(void)
  {
    _has_count = true;
    _count = 0;
    remove_reference(_block);
    _block = _ones_block;
    add_reference(_block);
  }
Example #8
0
void BitVector::set_to_zero(void)
  {
    remove_reference(_block);
    _block = _zero_block;
    add_reference(_block);
   _has_count = true;
   _count = 0;
  }
Example #9
0
void BitVector::operator=(const BitVector &other)
  {
    if (_block != other._block)
      {
        remove_reference(_block);
        _block = other._block;
        add_reference(_block);
	_has_count = other._has_count;
	_count = other._count;
      }
  }
Example #10
0
//Sprite Class Constructor (String Filename)
msl::sprite::sprite(const std::string& filename,const unsigned int number_of_frames):_texture(0),_number_of_frames(number_of_frames)
{
	//Track References to Textures
	add_reference();

	//Assign Members
	unsigned int width=0;
	unsigned int height=0;
	*this=msl::sprite(load_texture(filename,width,height),number_of_frames);
	_width=width;
	_height=height;
}
Example #11
0
static void process_gc_worklist(MVMThreadContext *tc, MVMHeapSnapshotState *ss, char *desc) {
    MVMCollectable **c_ptr;
    MVMuint16 ref_kind = desc
        ? MVM_SNAPSHOT_REF_KIND_STRING
        : MVM_SNAPSHOT_REF_KIND_UNKNOWN;
    MVMuint16 ref_index = desc
        ? get_string_index(tc, ss, desc, STR_MODE_CONST)
        : 0;
    while (( c_ptr = MVM_gc_worklist_get(tc, ss->gcwl) )) {
        MVMCollectable *c = *c_ptr;
        if (c)
            add_reference(tc, ss, ref_kind, ref_index,
                get_collectable_idx(tc, ss, c));
    }
}
notifier_domain_t *register_notifier_domain(domain_maintainer_t *dm, const str_t *name)
{
	notifier_domain_t *d = NULL;
	
	if (!dm) return NULL;
	
	cds_mutex_lock(&dm->mutex);
	d = find_domain_nolock(dm, name);
	if (!d) d = add_domain_nolock(dm, name);
	if (d) {
		add_reference(&d->ref); /* add reference for client */
	}
	cds_mutex_unlock(&dm->mutex);
	return d;
}
Example #13
0
//Sprite Class Constructor (Default, Raw OpenGL Texture)
msl::sprite::sprite(const unsigned int texture,const unsigned int number_of_frames)
	:_texture(texture),_number_of_frames(number_of_frames)
{
	//Track References to Textures
	add_reference();

	//Get Texture Size
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D,_texture);
	glDisable(GL_TEXTURE_2D);

	//Check Number of Frames
	if(_number_of_frames==0)
		_number_of_frames=1;
}
Example #14
0
void cmark_reference_create(cmark_reference_map *map, cmark_chunk *label,
                            cmark_chunk *url, cmark_chunk *title) {
  cmark_reference *ref;
  unsigned char *reflabel = normalize_reference(map->mem, label);

  /* empty reference name, or composed from only whitespace */
  if (reflabel == NULL)
    return;

  ref = (cmark_reference *)map->mem->calloc(1, sizeof(*ref));
  ref->label = reflabel;
  ref->hash = refhash(ref->label);
  ref->url = cmark_clean_url(map->mem, url);
  ref->title = cmark_clean_title(map->mem, title);
  ref->next = NULL;

  add_reference(map, ref);
}
Example #15
0
File: x-c.c Project: alan707/senuti
static void
phase8a_get (token_ty *tp)
{
  phase6_get (tp);
  if (tp->type == token_type_name && is_inttypes_macro (tp->string))
    {
      /* Turn PRIdXXX into "<PRIdXXX>".  */
      size_t len = strlen (tp->string);
      char *new_string = (char *) xmalloc (len + 3);
      new_string[0] = '<';
      memcpy (new_string + 1, tp->string, len);
      new_string[len + 1] = '>';
      new_string[len + 2] = '\0';
      free (tp->string);
      tp->string = new_string;
      tp->comment = add_reference (savable_comment);
      tp->type = token_type_string_literal;
    }
}
Example #16
0
extern void reference_create(reference_map *map, chunk *label, chunk *url, chunk *title)
{
	reference *ref;
	unsigned char *reflabel = normalize_reference(label);

	/* empty reference name, or composed from only whitespace */
	if (reflabel == NULL)
		return;

	ref = calloc(1, sizeof(*ref));
	if(ref != NULL) {
		ref->label = reflabel;
		ref->hash = refhash(ref->label);
		ref->url = clean_url(url);
		ref->title = clean_title(title);
		ref->next = NULL;

		add_reference(map, ref);
	}
}
Example #17
0
//Copy Assignment Operator
msl::sprite& msl::sprite::operator=(const msl::sprite& copy)
{
	//Protect Against Self Assignment
	if(this!=&copy)
	{
		//Track References to Textures
		remove_reference();

		//Assign Members
		_texture=copy._texture;
		_number_of_frames=copy._number_of_frames;
		_width=copy._width;
		_height=copy._height;

		//Track References to Textures
		add_reference();
	}

	//Return
	return *this;
}
Example #18
0
        void client_net_io::connect()
        {
            session_state closed_state = SS_CLOSED;

            if (_state.compare_exchange_strong(closed_state, SS_CONNECTING))
            {
                boost::asio::ip::tcp::endpoint ep(
                    boost::asio::ip::address_v4(ntohl(_remote_addr.ip)), _remote_addr.port);

                add_reference();
                _socket.async_connect(ep, [this](boost::system::error_code ec)
                {
                    if (!ec)
                    {
                        _reconnect_count = 0;
                        _state = SS_CONNECTED;

                        dinfo("client session %s:%d connected",
                            _remote_addr.name.c_str(),
                            static_cast<int>(_remote_addr.port)
                            );

                        set_options();

                        do_write();
                        do_read();                        
                    }
                    else
                    {
                        derror("network client session connect failed, error = %s",
                            ec.message().c_str()
                            );
                        on_failure();
                    }
                    release_reference();
                });
            }
        }
Example #19
0
static void
phase5_get (token_ty *tp)
{
  static char *buffer;
  static int bufmax;
  int bufpos;
  int c;

  if (phase5_pushback_length)
    {
      *tp = phase5_pushback[--phase5_pushback_length];
      return;
    }
  for (;;)
    {
      tp->line_number = line_number;
      c = phase2_getc ();

      switch (c)
        {
        case EOF:
          tp->type = token_type_eof;
          return;

        case '\n':
          if (last_non_comment_line > last_comment_line)
            savable_comment_reset ();
          /* FALLTHROUGH */
        case '\r':
        case '\t':
        case ' ':
          /* Ignore whitespace and comments.  */
          continue;
        }

      last_non_comment_line = tp->line_number;

      switch (c)
        {
        case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
        case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
        case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
        case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
        case 'Y': case 'Z':
        case '_':
        case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
        case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
        case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
        case 's': case 't': case 'u': case 'v': case 'w': case 'x':
        case 'y': case 'z':
        case '0': case '1': case '2': case '3': case '4':
        case '5': case '6': case '7': case '8': case '9':
          /* Symbol, or part of a number.  */
          bufpos = 0;
          for (;;)
            {
              if (bufpos >= bufmax)
                {
                  bufmax = 2 * bufmax + 10;
                  buffer = xrealloc (buffer, bufmax);
                }
              buffer[bufpos++] = c;
              c = phase2_getc ();
              switch (c)
                {
                case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
                case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
                case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
                case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
                case 'Y': case 'Z':
                case '_':
                case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
                case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
                case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
                case 's': case 't': case 'u': case 'v': case 'w': case 'x':
                case 'y': case 'z':
                case '0': case '1': case '2': case '3': case '4':
                case '5': case '6': case '7': case '8': case '9':
                  continue;
                default:
                  if (bufpos == 1 && buffer[0] == '_' && c == '(')
                    {
                      tp->type = token_type_i18n;
                      return;
                    }
                  phase2_ungetc (c);
                  break;
                }
              break;
            }
          if (bufpos >= bufmax)
            {
              bufmax = 2 * bufmax + 10;
              buffer = xrealloc (buffer, bufmax);
            }
          buffer[bufpos] = '\0';
          tp->string = xstrdup (buffer);
          tp->type = token_type_symbol;
          return;

        case '"':
          bufpos = 0;
          for (;;)
            {
              c = phase7_getc ();
              if (c == EOF || c == P7_QUOTES)
                break;
              if (bufpos >= bufmax)
                {
                  bufmax = 2 * bufmax + 10;
                  buffer = xrealloc (buffer, bufmax);
                }
              buffer[bufpos++] = c;
            }
          if (bufpos >= bufmax)
            {
              bufmax = 2 * bufmax + 10;
              buffer = xrealloc (buffer, bufmax);
            }
          buffer[bufpos] = '\0';
          tp->string = xstrdup (buffer);
          tp->type = token_type_string_literal;
          tp->comment = add_reference (savable_comment);
          return;

        case '(':
          tp->type = token_type_lparen;
          return;

        case ')':
          tp->type = token_type_rparen;
          return;

        case ',':
          tp->type = token_type_comma;
          return;

        default:
          /* We could carefully recognize each of the 2 and 3 character
             operators, but it is not necessary, as we only need to recognize
             gettext invocations.  Don't bother.  */
          tp->type = token_type_other;
          return;
        }
    }
}
Example #20
0
//Copy Constructor
msl::sprite::sprite(const msl::sprite& copy):_texture(copy._texture),_number_of_frames(copy._number_of_frames),_width(copy._width),_height(copy._height)
{
	//Track References to Textures
	add_reference();
}
Example #21
0
/* Adds a reference with a VM string description. */
static void add_reference_vm_str(MVMThreadContext *tc, MVMHeapSnapshotState *ss,
                               MVMString *str,  MVMuint64 to) {
   MVMuint64 str_idx = get_vm_string_index(tc, ss, str);
   add_reference(tc, ss, MVM_SNAPSHOT_REF_KIND_STRING, str_idx, to);
}
Example #22
0
/* Adds a reference with an integer description. */
static void add_reference_idx(MVMThreadContext *tc, MVMHeapSnapshotState *ss,
                               MVMuint64 idx,  MVMuint64 to) {
    add_reference(tc, ss, MVM_SNAPSHOT_REF_KIND_INDEX, idx, to);
}
Example #23
0
File: x-c.c Project: alan707/senuti
static void
phase5_get (token_ty *tp)
{
  static char *buffer;
  static int bufmax;
  int bufpos;
  int c;

  if (phase5_pushback_length)
    {
      *tp = phase5_pushback[--phase5_pushback_length];
      return;
    }
  tp->string = NULL;
  tp->number = 0;
  tp->line_number = line_number;
  c = phase4_getc ();
  switch (c)
    {
    case EOF:
      tp->type = token_type_eof;
      return;

    case '\n':
      tp->type = token_type_eoln;
      return;

    case ' ':
    case '\f':
    case '\t':
      for (;;)
	{
	  c = phase4_getc ();
	  switch (c)
	    {
	    case ' ':
	    case '\f':
	    case '\t':
	      continue;

	    default:
	      phase4_ungetc (c);
	      break;
	    }
	  break;
	}
      tp->type = token_type_white_space;
      return;

    case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
    case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N':
    case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
    case 'V': case 'W': case 'X': case 'Y': case 'Z':
    case '_':
    case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
    case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
    case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u':
    case 'v': case 'w': case 'x': case 'y': case 'z':
      bufpos = 0;
      for (;;)
	{
	  if (bufpos >= bufmax)
	    {
	      bufmax = 2 * bufmax + 10;
	      buffer = xrealloc (buffer, bufmax);
	    }
	  buffer[bufpos++] = c;
	  c = phase4_getc ();
	  switch (c)
	    {
	    case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
	    case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
	    case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
	    case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
	    case 'Y': case 'Z':
	    case '_':
	    case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
	    case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
	    case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
	    case 's': case 't': case 'u': case 'v': case 'w': case 'x':
	    case 'y': case 'z':
	    case '0': case '1': case '2': case '3': case '4':
	    case '5': case '6': case '7': case '8': case '9':
	      continue;

	    default:
	      phase4_ungetc (c);
	      break;
	    }
	  break;
	}
      if (bufpos >= bufmax)
	{
	  bufmax = 2 * bufmax + 10;
	  buffer = xrealloc (buffer, bufmax);
	}
      buffer[bufpos] = 0;
      tp->string = xstrdup (buffer);
      tp->type = token_type_name;
      return;

    case '.':
      c = phase4_getc ();
      phase4_ungetc (c);
      switch (c)
	{
	default:
	  tp->type = token_type_symbol;
	  return;

	case '0': case '1': case '2': case '3': case '4':
	case '5': case '6': case '7': case '8': case '9':
	  c = '.';
	  break;
	}
      /* FALLTHROUGH */

    case '0': case '1': case '2': case '3': case '4':
    case '5': case '6': case '7': case '8': case '9':
      /* The preprocessing number token is more "generous" than the C
	 number tokens.  This is mostly due to token pasting (another
	 thing we can ignore here).  */
      bufpos = 0;
      for (;;)
	{
	  if (bufpos >= bufmax)
	    {
	      bufmax = 2 * bufmax + 10;
	      buffer = xrealloc (buffer, bufmax);
	    }
	  buffer[bufpos++] = c;
	  c = phase4_getc ();
	  switch (c)
	    {
	    case 'e':
	    case 'E':
	      if (bufpos >= bufmax)
		{
		  bufmax = 2 * bufmax + 10;
		  buffer = xrealloc (buffer, bufmax);
		}
	      buffer[bufpos++] = c;
	      c = phase4_getc ();
	      if (c != '+' || c != '-')
		{
		  phase4_ungetc (c);
		  break;
		}
	      continue;

	    case 'A': case 'B': case 'C': case 'D':           case 'F':
	    case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
	    case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
	    case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
	    case 'Y': case 'Z':
	    case 'a': case 'b': case 'c': case 'd':           case 'f':
	    case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
	    case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
	    case 's': case 't': case 'u': case 'v': case 'w': case 'x':
	    case 'y': case 'z':
	    case '0': case '1': case '2': case '3': case '4':
	    case '5': case '6': case '7': case '8': case '9':
	    case '.':
	      continue;

	    default:
	      phase4_ungetc (c);
	      break;
	    }
	  break;
	}
      if (bufpos >= bufmax)
	{
	  bufmax = 2 * bufmax + 10;
	  buffer = xrealloc (buffer, bufmax);
	}
      buffer[bufpos] = 0;
      tp->type = token_type_number;
      tp->number = atol (buffer);
      return;

    case '\'':
      /* We could worry about the 'L' before wide character constants,
	 but ignoring it has no effect unless one of the keywords is
	 "L".  Just pretend it won't happen.  Also, we don't need to
	 remember the character constant.  */
      for (;;)
	{
	  c = phase7_getc ();
	  if (c == P7_NEWLINE)
	    {
	      error_with_progname = false;
	      error (0, 0, _("%s:%d: warning: unterminated character constant"),
		     logical_file_name, line_number - 1);
	      error_with_progname = true;
	      phase7_ungetc ('\n');
	      break;
	    }
	  if (c == EOF || c == P7_QUOTE)
	    break;
	}
      tp->type = token_type_character_constant;
      return;

    case '"':
      /* We could worry about the 'L' before wide string constants,
	 but since gettext's argument is not a wide character string,
	 let the compiler complain about the argument not matching the
	 prototype.  Just pretend it won't happen.  */
      bufpos = 0;
      for (;;)
	{
	  c = phase7_getc ();
	  if (c == P7_NEWLINE)
	    {
	      error_with_progname = false;
	      error (0, 0, _("%s:%d: warning: unterminated string literal"),
		     logical_file_name, line_number - 1);
	      error_with_progname = true;
	      phase7_ungetc ('\n');
	      break;
	    }
	  if (c == EOF || c == P7_QUOTES)
	    break;
	  if (c == P7_QUOTE)
	    c = '\'';
	  if (bufpos >= bufmax)
	    {
	      bufmax = 2 * bufmax + 10;
	      buffer = xrealloc (buffer, bufmax);
	    }
	  buffer[bufpos++] = c;
	}
      if (bufpos >= bufmax)
	{
	  bufmax = 2 * bufmax + 10;
	  buffer = xrealloc (buffer, bufmax);
	}
      buffer[bufpos] = 0;
      tp->type = token_type_string_literal;
      tp->string = xstrdup (buffer);
      tp->comment = add_reference (savable_comment);
      return;

    case '(':
      tp->type = token_type_lparen;
      return;

    case ')':
      tp->type = token_type_rparen;
      return;

    case ',':
      tp->type = token_type_comma;
      return;

    case '#':
      tp->type = token_type_hash;
      return;

    case ':':
      tp->type = token_type_colon;
      return;

    case '@':
      if (objc_extensions)
	{
	  tp->type = token_type_objc_special;
	  tp->comment = add_reference (savable_comment);
	  return;
	}
      /* FALLTHROUGH */

    default:
      /* We could carefully recognize each of the 2 and 3 character
	operators, but it is not necessary, as we only need to recognize
	gettext invocations.  Don't bother.  */
      tp->type = token_type_symbol;
      return;
    }
}
Example #24
0
static void
phase4_get (token_ty *tp)
{
  static char *buffer;
  static int bufmax;
  int bufpos;
  int c;

  if (phase4_pushback_length)
    {
      *tp = phase4_pushback[--phase4_pushback_length];
      return;
    }
  tp->string = NULL;

  for (;;)
    {
      tp->line_number = line_number;
      c = phase3_getc ();
      switch (c)
	{
	case EOF:
	  tp->type = token_type_eof;
	  return;

	case '\n':
	  if (last_non_comment_line > last_comment_line)
	    savable_comment_reset ();
	  /* FALLTHROUGH */
	case ' ':
	case '\t':
	case '\r':
	  /* Ignore whitespace.  */
	  continue;
	}

      last_non_comment_line = tp->line_number;

      switch (c)
	{
	case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
	case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N':
	case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
	case 'V': case 'W': case 'X': case 'Y': case 'Z':
	case '_':
	case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
	case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
	case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u':
	case 'v': case 'w': case 'x': case 'y': case 'z':
	case 127: case 128: case 129: case 130: case 131: case 132: case 133:
	case 134: case 135: case 136: case 137: case 138: case 139: case 140:
	case 141: case 142: case 143: case 144: case 145: case 146: case 147:
	case 148: case 149: case 150: case 151: case 152: case 153: case 154:
	case 155: case 156: case 157: case 158: case 159: case 160: case 161:
	case 162: case 163: case 164: case 165: case 166: case 167: case 168:
	case 169: case 170: case 171: case 172: case 173: case 174: case 175:
	case 176: case 177: case 178: case 179: case 180: case 181: case 182:
	case 183: case 184: case 185: case 186: case 187: case 188: case 189:
	case 190: case 191: case 192: case 193: case 194: case 195: case 196:
	case 197: case 198: case 199: case 200: case 201: case 202: case 203:
	case 204: case 205: case 206: case 207: case 208: case 209: case 210:
	case 211: case 212: case 213: case 214: case 215: case 216: case 217:
	case 218: case 219: case 220: case 221: case 222: case 223: case 224:
	case 225: case 226: case 227: case 228: case 229: case 230: case 231:
	case 232: case 233: case 234: case 235: case 236: case 237: case 238:
	case 239: case 240: case 241: case 242: case 243: case 244: case 245:
	case 246: case 247: case 248: case 249: case 250: case 251: case 252:
	case 253: case 254: case 255:
	  bufpos = 0;
	  for (;;)
	    {
	      if (bufpos >= bufmax)
		{
		  bufmax = 2 * bufmax + 10;
		  buffer = xrealloc (buffer, bufmax);
		}
	      buffer[bufpos++] = c;
	      c = phase1_getc ();
	      switch (c)
		{
		case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
		case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
		case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
		case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
		case 'Y': case 'Z':
		case '_':
		case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
		case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
		case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
		case 's': case 't': case 'u': case 'v': case 'w': case 'x':
		case 'y': case 'z':
		case '0': case '1': case '2': case '3': case '4':
		case '5': case '6': case '7': case '8': case '9':
		case 127: case 128: case 129: case 130: case 131: case 132:
		case 133: case 134: case 135: case 136: case 137: case 138:
		case 139: case 140: case 141: case 142: case 143: case 144:
		case 145: case 146: case 147: case 148: case 149: case 150:
		case 151: case 152: case 153: case 154: case 155: case 156:
		case 157: case 158: case 159: case 160: case 161: case 162:
		case 163: case 164: case 165: case 166: case 167: case 168:
		case 169: case 170: case 171: case 172: case 173: case 174:
		case 175: case 176: case 177: case 178: case 179: case 180:
		case 181: case 182: case 183: case 184: case 185: case 186:
		case 187: case 188: case 189: case 190: case 191: case 192:
		case 193: case 194: case 195: case 196: case 197: case 198:
		case 199: case 200: case 201: case 202: case 203: case 204:
		case 205: case 206: case 207: case 208: case 209: case 210:
		case 211: case 212: case 213: case 214: case 215: case 216:
		case 217: case 218: case 219: case 220: case 221: case 222:
		case 223: case 224: case 225: case 226: case 227: case 228:
		case 229: case 230: case 231: case 232: case 233: case 234:
		case 235: case 236: case 237: case 238: case 239: case 240:
		case 241: case 242: case 243: case 244: case 245: case 246:
		case 247: case 248: case 249: case 250: case 251: case 252:
		case 253: case 254: case 255: 
		  continue;

		default:
		  phase1_ungetc (c);
		  break;
		}
	      break;
	    }
	  if (bufpos >= bufmax)
	    {
	      bufmax = 2 * bufmax + 10;
	      buffer = xrealloc (buffer, bufmax);
	    }
	  buffer[bufpos] = 0;
	  tp->string = xstrdup (buffer);
	  tp->type = token_type_symbol;
	  return;

	case '\'':
	  /* Single-quoted string literal.  */
	  bufpos = 0;
	  for (;;)
	    {
	      c = phase1_getc ();
	      if (c == EOF || c == '\'')
		break;
	      if (c == '\\')
		{
		  c = phase1_getc ();
		  if (c != '\\' && c != '\'')
		    {
		      phase1_ungetc (c);
		      c = '\\';
		    }
		}
	      if (bufpos >= bufmax)
		{
		  bufmax = 2 * bufmax + 10;
		  buffer = xrealloc (buffer, bufmax);
		}
	      buffer[bufpos++] = c;
	    }
	  if (bufpos >= bufmax)
	    {
	      bufmax = 2 * bufmax + 10;
	      buffer = xrealloc (buffer, bufmax);
	    }
	  buffer[bufpos] = 0;
	  tp->type = token_type_string_literal;
	  tp->string = xstrdup (buffer);
	  tp->comment = add_reference (savable_comment);
	  return;

	case '"':
	  /* Double-quoted string literal.  */
	  tp->type = token_type_string_literal;
	  bufpos = 0;
	  for (;;)
	    {
	      c = phase1_getc ();
	      if (c == EOF || c == '"')
		break;
	      if (c == '$')
		{
		  c = phase1_getc ();
		  if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')
		      || c == '_' || c == '{' || c >= 0x7f)
		    {
		      /* String with variables.  */
		      tp->type = token_type_other;
		      continue;
		    }
		  phase1_ungetc (c);
		  c = '$';
		}
	      if (c == '{')
		{
		  c = phase1_getc ();
		  if (c == '$')
		    {
		      /* String with expressions.  */
		      tp->type = token_type_other;
		      continue;
		    }
		  phase1_ungetc (c);
		  c = '{';
		}
	      if (c == '\\')
		{
		  int n, j;

		  c = phase1_getc ();
		  switch (c)
		    {
		    case '"':
		    case '\\':
		    case '$':
		      break;

		    case '0': case '1': case '2': case '3':
		    case '4': case '5': case '6': case '7':
		      n = 0;
		      for (j = 0; j < 3; ++j)
			{
			  n = n * 8 + c - '0';
			  c = phase1_getc ();
			  switch (c)
			    {
			    default:
			      break;

			    case '0': case '1': case '2': case '3':
			    case '4': case '5': case '6': case '7':
			      continue;
			    }
			  break;
			}
		      phase1_ungetc (c);
		      c = n;
		      break;

		    case 'x':
		      n = 0;
		      for (j = 0; j < 2; ++j)
			{
			  c = phase1_getc ();
			  switch (c)
			    {
			    case '0': case '1': case '2': case '3': case '4':
			    case '5': case '6': case '7': case '8': case '9':
			      n = n * 16 + c - '0';
			      break;
			    case 'A': case 'B': case 'C': case 'D': case 'E':
			    case 'F':
			      n = n * 16 + 10 + c - 'A';
			      break;
			    case 'a': case 'b': case 'c': case 'd': case 'e':
			    case 'f':
			      n = n * 16 + 10 + c - 'a';
			      break;
			    default:
			      phase1_ungetc (c);
			      c = 0;
			      break;
			    }
			  if (c == 0)
			    break;
			}
		      if (j == 0)
			{
			  phase1_ungetc ('x');
			  c = '\\';
			}
		      else
			c = n;
		      break;

		    case 'n':
		      c = '\n';
		      break;
		    case 't':
		      c = '\t';
		      break;
		    case 'r':
		      c = '\r';
		      break;

		    default:
		      phase1_ungetc (c);
		      c = '\\';
		      break;
		    }
		}
	      if (bufpos >= bufmax)
		{
		  bufmax = 2 * bufmax + 10;
		  buffer = xrealloc (buffer, bufmax);
		}
	      buffer[bufpos++] = c;
	    }
	  if (bufpos >= bufmax)
	    {
	      bufmax = 2 * bufmax + 10;
	      buffer = xrealloc (buffer, bufmax);
	    }
	  buffer[bufpos] = 0;
	  if (tp->type == token_type_string_literal)
	    {
	      tp->string = xstrdup (buffer);
	      tp->comment = add_reference (savable_comment);
	    }
	  return;

	case '?':
	case '%':
	  {
	    int c2 = phase1_getc ();
	    if (c2 == '>')
	      {
		/* ?> and %> terminate PHP mode and switch back to HTML
		   mode.  */
		skip_html ();
		tp->type = token_type_other;
	      }
	    else
	      {
		phase1_ungetc (c2);
		tp->type = (c == '%' ? token_type_operator1 : token_type_other);
	      }
	    return;
	  }

	case '(':
	  tp->type = token_type_lparen;
	  return;

	case ')':
	  tp->type = token_type_rparen;
	  return;

	case ',':
	  tp->type = token_type_comma;
	  return;

	case '[':
	  tp->type = token_type_lbracket;
	  return;

	case ']':
	  tp->type = token_type_rbracket;
	  return;

	case '.':
	  tp->type = token_type_dot;
	  return;

	case '*':
	case '/':
	  tp->type = token_type_operator1;
	  return;

	case '+':
	case '-':
	  {
	    int c2 = phase1_getc ();
	    if (c2 == c)
	      /* ++ or -- */
	      tp->type = token_type_operator1;
	    else
	      /* + or - */
	      {
		phase1_ungetc (c2);
		tp->type = token_type_operator2;
	      }
	    return;
	  }

	case '!':
	case '~':
	case '@':
	  tp->type = token_type_operator2;
	  return;

	case '<':
	  {
	    int c2 = phase1_getc ();
	    if (c2 == '<')
	      {
		int c3 = phase1_getc ();
		if (c3 == '<')
		  {
		    /* Start of here document.
		       Parse whitespace, then label, then newline.  */
		    do
		      c = phase3_getc ();
		    while (c == ' ' || c == '\t' || c == '\n' || c == '\r');

		    bufpos = 0;
		    do
		      {
			if (bufpos >= bufmax)
			  {
			    bufmax = 2 * bufmax + 10;
			    buffer = xrealloc (buffer, bufmax);
			  }
			buffer[bufpos++] = c;
			c = phase3_getc ();
		      }
		    while (c != EOF && c != '\n' && c != '\r');
		    /* buffer[0..bufpos-1] now contains the label.  */

		    /* Now skip the here document.  */
		    for (;;)
		      {
			c = phase1_getc ();
			if (c == EOF)
			  break;
			if (c == '\n' || c == '\r')
			  {
			    int bufidx = 0;

			    while (bufidx < bufpos)
			      {
				c = phase1_getc ();
				if (c == EOF)
				  break;
				if (c != buffer[bufidx])
				  {
				    phase1_ungetc (c);
				    break;
				  }
				bufidx++;
			      }
			    if (bufidx == bufpos)
			      {
				c = phase1_getc ();
				if (c != ';')
				  phase1_ungetc (c);
				c = phase1_getc ();
				if (c == '\n' || c == '\r')
				  break;
			      }
			  }
		      }

		    /* FIXME: Ideally we should turn the here document into a
		       string literal if it didn't contain $ substitution.  And
		       we should also respect backslash escape sequences like
		       in double-quoted strings.  */
		    tp->type = token_type_other;
		    return;
		  }
		phase1_ungetc (c3);
	      }

	    /* < / script > terminates PHP mode and switches back to HTML
	       mode.  */
	    while (c2 == ' ' || c2 == '\t' || c2 == '\n' || c2 == '\r')
	      c2 = phase1_getc ();
	    if (c2 == '/')
	      {
		do
		  c2 = phase1_getc ();
		while (c2 == ' ' || c2 == '\t' || c2 == '\n' || c2 == '\r');
		if (c2 == 's' || c2 == 'S')
		  {
		    c2 = phase1_getc ();
		    if (c2 == 'c' || c2 == 'C')
		      {
			c2 = phase1_getc ();
			if (c2 == 'r' || c2 == 'R')
			  {
			    c2 = phase1_getc ();
			    if (c2 == 'i' || c2 == 'I')
			      {
				c2 = phase1_getc ();
				if (c2 == 'p' || c2 == 'P')
				  {
				    c2 = phase1_getc ();
				    if (c2 == 't' || c2 == 'T')
				      {
					do
					  c2 = phase1_getc ();
					while (c2 == ' ' || c2 == '\t'
					       || c2 == '\n' || c2 == '\r');
					if (c2 == '>')
					  {
					    skip_html ();
					  }
					else
					  phase1_ungetc (c2);
				      }
				    else
				      phase1_ungetc (c2);
				  }
				else
				  phase1_ungetc (c2);
			      }
			    else
			      phase1_ungetc (c2);
			  }
			else
			  phase1_ungetc (c2);
		      }
		    else
		      phase1_ungetc (c2);
		  }
		else
		  phase1_ungetc (c2);
	      }
	    else
	      phase1_ungetc (c2);

	    tp->type = token_type_other;
	    return;
	  }

	case '`':
	  /* Execution operator.  */
	default:
	  /* We could carefully recognize each of the 2 and 3 character
	     operators, but it is not necessary, as we only need to recognize
	     gettext invocations.  Don't bother.  */
	  tp->type = token_type_other;
	  return;
	}
    }
}
Example #25
0
/* Adds a reference with a constant C string description. */
static void add_reference_const_cstr(MVMThreadContext *tc, MVMHeapSnapshotState *ss,
                                     const char *cstr,  MVMuint64 to) {
    MVMuint64 str_idx = get_string_index(tc, ss, (char *)cstr, STR_MODE_CONST);
    add_reference(tc, ss, MVM_SNAPSHOT_REF_KIND_STRING, str_idx, to);
}
 void add_reference(OopOrNarrowOopStar from) {
   return add_reference(from, 0);
 }
Example #27
0
long WorldSocket::AddReference (void)
{
    return static_cast<long> (add_reference());
}
Example #28
0
static void
phase3_get (token_ty *tp)
{
  int c;
  int c2;
  int c_start;

  if (phase3_pushback_length)
    {
      *tp = phase3_pushback[--phase3_pushback_length];
      return;
    }

  tp->string = NULL;

  for (;;)
    {
      tp->line_number = line_number;
      c = phase2_getc ();

      switch (c)
        {
        case EOF:
          tp->type = token_type_eof;
          return;

        case '\n':
          if (last_non_comment_line > last_comment_line)
            savable_comment_reset ();
          /* Intentionally not breaking.  */
        case ' ':
        case '\t':
        case '\f':
          continue;

        case '+':
        case '-':
        case '*':
        case '/':
        case '^':
        case '%':
        case '#':
          tp->type = token_type_operator1;
          return;
        case '<':
        case '>':
        case '=':
          c2 = phase1_getc ();
          if (c2 != '=')
            phase1_ungetc (c2);
          tp->type = token_type_operator2;
          return;
        case '~':
          c2 = phase1_getc ();
          if (c2 == '=')
            {
              tp->type = token_type_operator2;
              return;
            }
          else
            phase1_ungetc (c2);
          continue;
        case '(':
          tp->type = token_type_lparen;
          return;
        case ')':
          tp->type = token_type_rparen;
          return;
        case ',':
          tp->type = token_type_comma;
          return;

        case ';':
          tp->type = token_type_other;
          return;

          /* There are three operators beginning with a dot.  '.',
             '..' and '...'.  The most useful for us is the string
             concatenation operator ('..').  */
        case '.':
          c = phase1_getc ();
          if (c == '.')
            {
              c = phase1_getc ();
              if (c == '.')
                {
                  tp->type = token_type_other;
                  return;
                }
              else
                {
                  phase1_ungetc (c);
                  tp->type = token_type_doubledot;
                  return;
                }
            }
          else if (c >= '0' && c <= '9')
            {
              /* It's a number.  We aren't interested in the actual
                 numeric value, so ignore the dot and let next
                 iteration eat the number.  */
              phase1_ungetc (c);
              continue;
            }
          else
            {
              phase1_ungetc (c);
              tp->type = token_type_dot;
              return;
            }

        case '"':
        case '\'':
          c_start = c;
          string_start ();

          for (;;)
            {
              /* We need unprocessed characters from phase 1.  */
              c = phase1_getc ();

              /* We got '\', this is probably an escape sequence.  */
              if (c == '\\')
                {
                  c = phase1_getc ();
                  switch (c)
                    {
                    case 'a':
                      string_add ('\a');
                      break;
                    case 'b':
                      string_add ('\b');
                      break;
                    case 'f':
                      string_add ('\f');
                      break;
                    case 'n':
                      string_add ('\n');
                      break;
                    case 'r':
                      string_add ('\r');
                      break;
                    case 't':
                      string_add ('\t');
                      break;
                    case 'v':
                      string_add ('\v');
                      break;
                    case 'x':
                      {
                        int num = 0;
                        int i = 0;

                        for (i = 0; i < 2; i++)
                          {
                            c = phase1_getc ();
                            if (c >= '0' && c <= '9')
                              num += c - '0';
                            else if (c >= 'a' && c <= 'f')
                              num += c - 'a' + 10;
                            else if (c >= 'A' && c <= 'F')
                              num += c - 'A' + 10;
                            else
                              {
                                phase1_ungetc (c);
                                break;
                              }

                            if (i == 0)
                              num *= 16;
                          }

                        if (i == 2)
                          string_add (num);
                      }

                      break;
                    case 'z':
                      /* Ignore the following whitespace.  */
                      do
                        {
                          c = phase1_getc ();
                        }
                      while (c == ' ' || c == '\n' || c == '\t' || c == '\r'
                             || c == '\f' || c == '\v');

                      phase1_ungetc (c);

                      break;
                    default:
                      /* Check if it's a '\ddd' sequence.  */
                      if (c >= '0' && c <= '9')
                        {
                          int num = 0;
                          int i = 0;

                          while (c >= '0' && c <= '9' && i < 3)
                            {
                              num *= 10;
                              num += (c - '0');
                              c = phase1_getc ();
                              i++;
                            }

                          /* The last read character is either a
                             non-number or another number after our
                             '\ddd' sequence.  We need to ungetc it.  */
                          phase1_ungetc (c);

                          /* The sequence number is too big, this
                             causes a lexical error.  Ignore it.  */
                          if (num < 256)
                            string_add (num);
                        }
                      else
                        string_add (c);
                    }
                }
              else if (c == c_start || c == EOF || c == '\n')
                {
                  /* End of string.  */
                  string_end ();
                  tp->string = xstrdup (string_buf);
                  tp->comment = add_reference (savable_comment);
                  tp->type = token_type_string;
                  return;
                }
              else
                string_add (c);
            }
          break;

        case '[':
          c = phase1_getc ();

          /* Count the number of equal signs.  */
          int esigns = 0;
          while (c == '=')
            {
              esigns++;
              c = phase1_getc ();
            }

          if (c != '[')
            {
              /* We did not find what we were looking for, ungetc it.  */
              phase1_ungetc (c);
              if (esigns == 0)
                {
                  /* Our current character isn't '[' and we got 0 equal
                     signs, so the first '[' must have been a left
                     bracket.  */
                  tp->type = token_type_lbracket;
                  return;
                }
              else
                /* Lexical error, ignore it.  */
                continue;
            }

          string_start ();

          for (;;)
            {
              c = phase1_getc ();

              if (c == ']')
                {
                  c = phase1_getc ();

                  /* Count the number of equal signs.  */
                  int esigns2 = 0;
                  while (c == '=')
                    {
                      esigns2++;
                      c = phase1_getc ();
                    }

                  if (c == ']' && esigns == esigns2)
                    {
                      /* We got ']==...==]', where the number of equal
                         signs matches the number of equal signs in
                         the opening bracket.  */
                      string_end ();
                      tp->string = xstrdup (string_buf);
                      tp->comment = add_reference (savable_comment);
                      tp->type = token_type_string;
                      return;
                    }
                  else
                    {
                      /* Otherwise we got either ']==' garbage or
                         ']==...==]' with a different number of equal
                         signs.

                         Add ']' and equal signs to the string, and
                         ungetc the current character, because the
                         second ']' might be a part of another closing
                         long bracket, e.g. '==]===]'.  */
                      phase1_ungetc (c);

                      string_add (']');
                      while (esigns2--)
                        string_add ('=');
                    }
                }
              else
                {
                  if (c == EOF)
                    {
                      string_end ();
                      tp->string = xstrdup (string_buf);
                      tp->comment = add_reference (savable_comment);
                      tp->type = token_type_string;
                      return;
                    }
                  else
                    string_add (c);
                }
            }
          break;

        case ']':
          tp->type = token_type_rbracket;
          return;

        default:
          if (c >= '0' && c <= '9')
            {
              while (c >= '0' && c <= '9')
                c = phase1_getc ();

              if (c == '.')
                {
                  c = phase1_getc ();
                  while (c >= '0' && c <= '9')
                    c = phase1_getc ();
                }

              if (c == 'e' || c == 'E')
                {
                  if (c == '+' || c == '-')
                    c = phase1_getc ();
                  while (c >= '0' && c <= '9')
                    c = phase1_getc ();
                }

              phase1_ungetc (c);

              tp->type = token_type_number;
              return;
            }
          else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
                   || c == '_')
            {
              string_start ();
              while ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
                     || c == '_' || (c >= '0' && c <= '9'))
                {
                  string_add (c);
                  c = phase1_getc ();
                }
              string_end ();
              phase1_ungetc (c);

              if (strcmp (string_buf, "not") == 0)
                tp->type = token_type_operator1;
              else if (strcmp (string_buf, "and") == 0)
                tp->type = token_type_operator2;
              else if (strcmp (string_buf, "or") == 0)
                tp->type = token_type_operator2;
              else
                {
                  tp->string = xstrdup (string_buf);
                  tp->type = token_type_symbol;
                }
              return;
            }
          else
            tp->type = token_type_other;
        }
    }
}
Example #29
0
int collect_dlr(void) {

  struct reference *r;
  struct stack *s;
  struct label *l;
  int section, x, i, n, q;
  unsigned char *t, *dtmp;
  double dou;

  
  section = 0;
  obj_tmp = obj_first;
  while (obj_tmp != NULL) {
    /* OBJECT FILE */
    if (obj_tmp->format == WLA_VERSION_OBJ) {
      t = obj_tmp->exported_defines;
      i = READ_T;

      /* load defines */
      for (; i > 0; i--) {
	l = calloc(1, sizeof(struct label));
	if (l == NULL) {
	  fprintf(stderr, "COLLECT_DLR: Out of memory.\n");
	  return FAILED;
	}

	/* copy the name */
	for (x = 0; !(*t == 0 || *t == 1); t++, x++)
	  l->name[x] = *t;
	l->name[x] = 0;
	if (*t == 0)
	  l->status = LABEL_STATUS_DEFINE;
        else if (*t == 1)
	  l->status = LABEL_STATUS_STACK;
	else {
	  fprintf(stderr, "COLLECT_DLR: Unknown definition type \"%d\".\n", *t);
	  return FAILED;
	}
	t++;

	READ_DOU;
	l->address = dou;
	l->base = 0;
	l->file_id = obj_tmp->id;
	l->section_status = OFF;
        l->section_struct = NULL;

	add_label(l);
      }

      /* load labels */
      i = READ_T;

      for (; i > 0; i--) {
	l = calloc(1, sizeof(struct label));
	if (l == NULL) {
	  fprintf(stderr, "COLLECT_DLR: Out of memory.\n");
	  return FAILED;
	}
	for (x = 0; !(*t == 0 || *t == 1 || *t == 2); t++, x++)
	  l->name[x] = *t;
	l->name[x] = 0;
	
	if (*t == 0)
	  l->status = LABEL_STATUS_LABEL;
        else if (*t == 1)
	  l->status = LABEL_STATUS_SYMBOL;
        else if (*t == 2)
	  l->status = LABEL_STATUS_BREAKPOINT;
	else {
	  fprintf(stderr, "COLLECT_DLR: Unknown label type \"%d\".\n", *t);
	  return FAILED;
	}

	t++;
	l->slot = *(t++);
	l->file_id_source = *(t++);

	l->section = READ_T;
	if (l->section == 0)
	  l->section_status = OFF;
	else {
	  l->section_status = ON;
	  l->section += section;
	}
	l->address = READ_T;
	l->linenumber = READ_T;
	l->base = (((int)l->address) >> 16) & 0xFF;
	l->address = ((int)l->address) & 0xFFFF;
	l->bank = READ_T;
	l->file_id = obj_tmp->id;
        l->section_struct = NULL;

	add_label(l);
      }

      i = READ_T;

      /* load references */
      for (; i > 0; i--) {
	r = malloc(sizeof(struct reference));
	if (r == NULL) {
	  fprintf(stderr, "COLLECT_DLR: Out of memory.\n");
	  return FAILED;
	}
	for (x = 0; *t != 0; t++, x++)
	  r->name[x] = *t;
	r->name[x] = 0;
	t++;
	r->type = *(t++);
	r->file_id_source = *(t++);
	r->slot = *(t++);
	r->section = READ_T;
	if (r->section == 0)
	  r->section_status = OFF;
	else {
	  r->section_status = ON;
	  r->section += section;
	}
	r->linenumber = READ_T;
	r->address = READ_T;
	r->bank = READ_T;

	add_reference(r);
      }

      i = READ_T;

      /* load pending calculations */
      for (; i > 0; i--) {
	s = malloc(sizeof(struct stack));
	if (s == NULL) {
	  fprintf(stderr, "COLLECT_DLR: Out of memory.\n");
	  return FAILED;
	}

	s->id = READ_T;
	s->type = *(t++);
	s->section = READ_T;
	if (s->section == 0)
	  s->section_status = OFF;
	else {
	  s->section_status = ON;
	  s->section += section;
	}
	s->file_id_source = *(t++);
	x = *(t++);
	s->position = *(t++);
	s->slot = *(t++);
	s->address = READ_T;
	s->linenumber = READ_T;
	s->bank = READ_T;
	s->stacksize = x;
	
	s->stack = malloc(sizeof(struct stackitem) * x);
	if (s->stack == NULL) {
	  fprintf(stderr, "COLLECT_DLR: Out of memory.\n");
	  free(s);
	  return FAILED;
	}
	
	add_stack(s);

	for (n = 0; n != x; n++) {
	  s->stack[n].type = *(t++);
	  s->stack[n].sign = *(t++);
	  if (s->stack[n].type == STACK_ITEM_TYPE_STRING) {
	    for (q = 0; *t != 0; t++, q++)
	      s->stack[n].string[q] = *t;
	    s->stack[n].string[q] = 0;
	    t++;
	  }
	  else {
	    READ_DOU;
	    s->stack[n].value = dou;
	  }
	}
      }

      /* save pointer to data block area */
      obj_tmp->data_blocks = t;
    }
    /* LIBRARY FILE */
    else if (obj_tmp->format == WLA_VERSION_LIB) {
Example #30
0
/**
 * gom_command_builder_build_create:
 * @builder: (in): A #GomCommandBuilder.
 * @version: the version of the database.
 *
 * Builds a list of #GomCommand to update the table for the
 * resource_type associated with @builder up to @version.
 *
 * Returns: (element-type GomCommand) (transfer full): A #GList of #GomCommand.
 */
GList *
gom_command_builder_build_create (GomCommandBuilder *builder,
                                  guint              version)
{
   GomCommandBuilderPrivate *priv;
   GomResourceClass *klass;
   GomCommand *command;
   GList *ret = NULL;
   GString *str;
   GParamSpec *primary_pspec, **pspecs;
   guint n_pspecs;
   guint i;

   g_return_val_if_fail(GOM_IS_COMMAND_BUILDER(builder), NULL);
   g_return_val_if_fail(version >= 1, NULL);

   priv = builder->priv;

   klass = g_type_class_ref(priv->resource_type);

   primary_pspec = g_object_class_find_property(G_OBJECT_CLASS(klass),
                                                klass->primary_key);
   g_assert(primary_pspec);

   pspecs = g_object_class_list_properties(G_OBJECT_CLASS(klass), &n_pspecs);

   /* Create the table if it doesn't already exist*/
   if (version == 1) {
      str = g_string_new("CREATE TABLE IF NOT EXISTS ");
      add_table_name(str, klass);
      g_string_append(str, "(");
      add_pkey_column(str, klass);

      for (i = 0; i < n_pspecs; i++) {
         if (pspecs[i] != primary_pspec &&
             is_mapped(pspecs[i]) &&
             is_new_in_version(pspecs[i], version)) {
            g_string_append(str, ",");
            g_string_append_printf(str, "'%s' %s",
                                   pspecs[i]->name,
                                   sql_type_for_column (pspecs[i]));
            add_reference(str, pspecs[i]);
            add_unique(str, pspecs[i]);
            add_notnull(str, pspecs[i]);
         }
      }
      g_string_append(str, ")");
      command = g_object_new(GOM_TYPE_COMMAND,
                             "adapter", priv->adapter,
                             "sql", str->str,
                             NULL);
      ret = g_list_prepend(NULL, command);
      g_string_free(str, TRUE);

      goto out;
   }

   /* And now each of the columns for versions > 1 */
   for (i = 0; i < n_pspecs; i++) {
     if (pspecs[i] != primary_pspec &&
         is_mapped(pspecs[i]) &&
         is_new_in_version(pspecs[i], version)) {
       str = g_string_new("ALTER TABLE ");
       add_table_name(str, klass);
       g_string_append(str, " ADD COLUMN ");
       g_string_append_printf(str, "'%s' %s",
                              pspecs[i]->name,
                              sql_type_for_column (pspecs[i]));
       add_unique(str, pspecs[i]);
       add_notnull(str, pspecs[i]);
       add_reference(str, pspecs[i]);

       command = g_object_new(GOM_TYPE_COMMAND,
                              "adapter", priv->adapter,
                              "sql", str->str,
                              NULL);
       ret = g_list_prepend(ret, command);
       g_string_free(str, TRUE);
     }
   }

out:
   g_free(pspecs);

   g_type_class_unref(klass);

   return g_list_reverse(ret);;
}