예제 #1
0
bool flash_device_get(const wgChar *name, struct flash_device *t)
{
	HSQUIRRELVM v = qr_open(NULL); 
	if(SQ_FAILED(sqstd_dofile(v, _SC("flashdevice.nut"), SQFalse, SQTrue))){
		qr_close(v);
		return false;
	}
	SQInteger top = sq_gettop(v);
	call(v, name);
	if(sq_gettype(v, -1) != OT_TABLE){
		goto field_error;
	}
	t->name = name;
	if(long_get(v, _SC("capacity"), &t->capacity) == false){
		goto field_error;
	}
	if(long_get(v, _SC("pagesize"), &t->pagesize) == false){
		goto field_error;
	}
	if(long_get(v, _SC("erase_wait"), &t->erase_wait) == false){
		goto field_error;
	}
	if(bool_get(v, _SC("erase_require"), &t->erase_require) == false){
		goto field_error;
	}
	if(bool_get(v, _SC("retry"), &t->retry) == false){
		goto field_error;
	}
	if(long_get(v, _SC("command_mask"), &t->command_mask) == false){
		goto field_error;
	}
	long dd;
	if(long_get(v, _SC("id_manufacurer"), &dd) == false){
		goto field_error;
	}
	t->id_manufacurer = dd;
	if(long_get(v, _SC("id_device"), &dd) == false){
		goto field_error;
	}
	t->id_device = dd;
	sq_settop(v, top);
	qr_close(v);
	return true;

field_error:
//	puts("script field error");
	qr_close(v);
	return false;
}
예제 #2
0
파일: any.c 프로젝트: JanDeVisser/obelix
data_t * _any_cmp(data_t *self, char *name, arguments_t *args) {
  data_t *other = arguments_get_arg(args, 0);
  int_t  *ret;
  int     cmp = data_cmp(self, other);

  if (!strcmp(name, "==")) {
    ret = bool_get(cmp == 0);
  } else if (!strcmp(name, "!=")) {
    ret = bool_get(cmp != 0);
  } else if (!strcmp(name, ">")) {
    ret = bool_get(cmp > 0);
  } else if (!strcmp(name, ">=")) {
    ret = bool_get(cmp >= 0);
  } else if (!strcmp(name, "<")) {
    ret = bool_get(cmp < 0);
  } else if (!strcmp(name, "<=")) {
    ret = bool_get(cmp <= 0);
  } else {
    assert(0);
    ret = (int_t *) data_false();
  }
  return (data_t *) ret;
}