Example #1
0
expression_t *
expr_primitive_for_type (type_t const * self)
{
  assert (self != NULL);

  if (self->base.kind == tk_own)
    self = self->t_own.host;
  assert (self->base.kind != tk_own);

  switch (self->base.kind)
    {
    case tk_int:
      return new_expr_int (new_cursor ("", 0), 0);
    case tk_real:
      return new_expr_real (new_cursor ("", 0), new_estring_from ("0.0"));
    case tk_string:
      return new_expr_string (new_cursor ("", 0), new_estring_from (""));
    case tk_bool:
      return new_expr_bool (new_cursor ("", 0), 1);

    case tk_unknown:
    case tk_implicit:
    case tk_any:
    case tk_void:
    case tk_label:
    case tk_switch:
    case tk_array:
    case tk_own:
    case tk_proc:
      assert (!"Should never get there!");
    };

  assert (!"Should never get there!");
  return NULL;
}
Example #2
0
void map_cursor_init(void)
{
        cursor = new_cursor(frame_h, frame_w, 0, 0, LINES-1, COLS, 0, 0, HJKL);
        nav_win = newwin(nav_h, nav_w, LINES-nav_h, CENT_X-(nav_w/2));
        nav_pan = new_panel(nav_win);
        wbkgrnd(nav_win, &PURPLE[2]);
}
Example #3
0
void PredictiveCursor::open(const Trie &trie,
                            const String &str,
                            UInt32 offset,
                            UInt32 limit,
                            UInt32 flags) {
  GRN_DAT_THROW_IF(PARAM_ERROR, (str.ptr() == NULL) && (str.length() != 0));

  flags = fix_flags(flags);
  PredictiveCursor new_cursor(trie, offset, limit, flags);
  new_cursor.init(str);
  new_cursor.swap(this);
}
Example #4
0
void IdCursor::open(const Trie &trie,
                    UInt32 min_id,
                    UInt32 max_id,
                    UInt32 offset,
                    UInt32 limit,
                    UInt32 flags) {
  flags = fix_flags(flags);

  IdCursor new_cursor(trie, offset, limit, flags);
  new_cursor.init(min_id, max_id);
  new_cursor.swap(this);
}
Example #5
0
void KeyCursor::open(const Trie &trie,
                     const String &min_str,
                     const String &max_str,
                     UInt32 offset,
                     UInt32 limit,
                     UInt32 flags) {
  GRN_DAT_THROW_IF(PARAM_ERROR,
                   (min_str.ptr() == NULL) && (min_str.length() != 0));
  GRN_DAT_THROW_IF(PARAM_ERROR,
                   (max_str.ptr() == NULL) && (max_str.length() != 0));

  flags = fix_flags(flags);
  KeyCursor new_cursor(trie, offset, limit, flags);
  new_cursor.init(min_str, max_str);
  new_cursor.swap(this);
}
Example #6
0
static void split_cursors(raw_data_t *rd, cursor_group_t *curg, int *ncur)
{
    int cnt;
    int i;
    cursor_t *cur;
    cursor_t *list = NULL;
    cursor_header_t *ch = (cursor_header_t *)rd->data;
    int swap = 0;

    if(ch->type == 2)
        swap = 0;
    else if(BYTESWAP_WORD(ch->type) == 2)
        swap = 1;
    else
        yyerror("Cursor resource data has invalid type id %d", ch->type);
    cnt = swap ? BYTESWAP_WORD(ch->count) : ch->count;
    for(i = 0; i < cnt; i++)
    {
        cursor_dir_entry_t cde;
        BITMAPINFOHEADER info;
        memcpy(&cde, rd->data + sizeof(cursor_header_t)
               + i*sizeof(cursor_dir_entry_t), sizeof(cde));

        cur = new_cursor();
        cur->id = alloc_cursor_id(curg->lvc.language);
        cur->lvc = curg->lvc;
        if(swap)
        {
            cde.offset = BYTESWAP_DWORD(cde.offset);
            cde.ressize= BYTESWAP_DWORD(cde.ressize);
        }
        if(cde.offset > rd->size
                || cde.offset + cde.ressize > rd->size)
            yyerror("Cursor resource data corrupt");
        cur->width = cde.width;
        cur->height = cde.height;
        cur->nclr = cde.nclr;
        memcpy(&info, rd->data + cde.offset, sizeof(info));
        convert_bitmap((char *)&info, 0);
        memcpy(rd->data + cde.offset, &info, sizeof(info));
        /* The bitmap is in destination byteorder. We want native for our structures */
        switch(byteorder)
        {
#ifdef WORDS_BIGENDIAN
        case WRC_BO_LITTLE:
#else
        case WRC_BO_BIG:
#endif
            cur->planes = BYTESWAP_WORD(info.biPlanes);
            cur->bits = BYTESWAP_WORD(info.biBitCount);
            break;
        default:
            cur->planes = info.biPlanes;
            cur->bits = info.biBitCount;
        }
        if(!win32 && (cur->planes != 1 || cur->bits != 1))
            yywarning("Win16 cursor contains colors");
        cur->xhot = swap ? BYTESWAP_WORD(cde.xhot) : cde.xhot;
        cur->yhot = swap ? BYTESWAP_WORD(cde.yhot) : cde.yhot;
        cur->data = new_raw_data();
        copy_raw_data(cur->data, rd, cde.offset, cde.ressize);
        if(!list)
        {
            list = cur;
        }
        else
        {
            cur->next = list;
            list->prev = cur;
            list = cur;
        }
    }
    curg->cursorlist = list;
    *ncur = cnt;
}