Ejemplo n.º 1
0
static VALUE
get_value(ValueStruct *val)
{
    if (val == NULL)
        return Qnil;
    if (IS_VALUE_NIL(val))
        return Qnil;
    switch (ValueType(val)) {
    case GL_TYPE_BOOL:
        return ValueBool(val) ? Qtrue : Qfalse;
    case GL_TYPE_INT:
        return INT2NUM(ValueInteger(val));
    case GL_TYPE_FLOAT:
        return rb_float_new(ValueFloat(val));
    case GL_TYPE_NUMBER:
        return bigdecimal_new(val);
    case GL_TYPE_CHAR:
    case GL_TYPE_VARCHAR:
    case GL_TYPE_DBCODE:
    case GL_TYPE_TEXT:
        return rb_str_new2(ValueToString(val, codeset));
    case GL_TYPE_BYTE:
    case GL_TYPE_BINARY:
        if (ValueByte(val) == NULL) {
            return Qnil;
        }
        else {
            return rb_str_new(ValueByte(val), ValueByteLength(val));
        }
    case GL_TYPE_OBJECT:
        return INT2NUM(ValueObjectId(val));
    case GL_TYPE_ARRAY:
        return aryval_new(val, 0);
    case GL_TYPE_RECORD:
        return recval_new(val, 0);
	case GL_TYPE_TIMESTAMP:
		return timestamp_new(val);
	case GL_TYPE_DATE:
		return date_new(val);
    default:
        rb_raise(rb_eArgError, "unsupported ValueStruct type");
        break;
    }
    return Qnil;                /* not reached */
}
Ejemplo n.º 2
0
// Returns a date in the format dd/mm/yyyy
// The returned date must be freed
date_t* get_date(int x,int y,int size,const point* top,const point* bottom,int* clear_key_pressed)
{
	date_t* date = NULL;
	char buf[MAXBUF];	
	int ret_val;
	memset (buf,'\0',sizeof(buf));
	window(x,y,x+size,y);
	gotoxy(1,1);	
	CHECK(SUCCESS==set_cursor(1));		
	ret_val = getkbd_entry (h_clock, "", (signed char *)buf, 0/*no timeout*/, NUMERIC,
                            (char *) szKeyMapVx680, sizeof (szKeyMapVx680), 8, 8);
	window(top->x,top->y,bottom->x,bottom->y);	
	CHECK(SUCCESS==set_cursor(0));		
	if (ret_val>0) {
		CHECK(8==ret_val);
		date = date_new(buf);		
	} else if (-3==ret_val) {
		CHECK(NULL!=clear_key_pressed);
		*clear_key_pressed = TRUE;
	}
	return date;
}