Exemplo n.º 1
0
  void camera_extract(void *obj, char *func){
    return;
    //tCamera *camera = (tCamera *)obj;
    try {
      cout << func << endl;
      vector<string> elems = split(func, '_');
      /*
      cout << "size : " << elems.size() << endl;
      vector<string>::iterator it;
      cout << "elems contains:";
      for ( it=elems.begin() ; it < elems.end(); it++ )
	cout << " " << *it;
      cout << endl;
      */
      if(elems[0] == "start") cout << "START !" << endl;
      else if(elems[0] == "stop") cout << "STOP !" << endl;
      else cout << "F**K !" << endl;
      long toto = ygets_l(0);
      ypush_long(toto);
    } catch ( string msg ) {
      y_error(msg.c_str());
    }
    catch ( char const * msg ) {
      y_error(msg);
    }
  }
Exemplo n.º 2
0
  void Y_camera_obj(int argc) {
    tCamera *camera = (tCamera *) ypush_obj(&camera_yObj, sizeof(tCamera));
    //    memset(handle,0,sizeof(tCamera));

    try {
      // initialise the Prosilica API
      if (!PvInitialize()) {
	// wait for a camera to be plugged
	waitForCamera();

	// get a camera from the list
	cameraGet(camera);

	// setup the camera
	cameraSetup(camera);
      } else {
	throw "failed to initialise the API\n";
      }
    } catch ( string msg ) {
      y_error(msg.c_str());
    }
    catch ( char const * msg ) {
      y_error(msg);
    }

  }
Exemplo n.º 3
0
void
Y_gy_setlocale(int argc)
{
  if (argc > 2) y_error("gy_setlocale, [[CATEGORY, ], LOCALE]");
  char * scat="LC_ALL";
  char * sloc =NULL;
  int cat=0;
  if (argc == 2) scat = ygets_q(1);
  if (yarg_string(0)) sloc = ygets_q(0);
  if (!strcmp(scat, "LC_ALL")) cat = LC_ALL;
  else if (!strcmp(scat, "LC_COLLATE")) cat = LC_COLLATE;
  else if (!strcmp(scat, "LC_CTYPE")) cat = LC_CTYPE;
  else if (!strcmp(scat, "LC_MONETARY")) cat = LC_MONETARY;
  else if (!strcmp(scat, "LC_NUMERIC")) cat = LC_NUMERIC;
  else if (!strcmp(scat, "LC_TIME")) cat = LC_TIME;
  else y_error("unsupported locale category");

  if (sloc && cat==LC_NUMERIC && strcmp(sloc, "C"))
    y_error("Yorick does not support LC_NUMERIC != \"C\"");

  *ypush_q(0) = p_strcpy(setlocale(cat, sloc));

  setlocale(LC_NUMERIC, "C");

}
Exemplo n.º 4
0
void yav_opencodec(yav_ctxt *obj, unsigned int width, unsigned int height) {
  obj->video_st->codec->width=width;
  obj->video_st->codec->height=height;
  av_dump_format(obj->oc, 0, obj->oc->filename, 1);

  if (obj->video_st) {
    AVCodecContext *c;
    c = obj->video_st->codec;

    if (avcodec_open2(c, obj->codec, NULL) < 0)
      y_error("could not open codec\n");

    obj->picture = av_frame_alloc();
    if (!obj->picture)
      y_error("Could not allocate picture");

    int size = avpicture_get_size(c->pix_fmt, c->width, c->height);
    uint8_t *picture_buf = av_malloc(size);
    if (!picture_buf) {
      av_frame_free(&obj->picture);
      y_error("unable to allocate memory");
    }
    avpicture_fill((AVPicture *)obj->picture, picture_buf,
                   c->pix_fmt, c->width, c->height);
    if (obj->oc->oformat->video_codec == AV_CODEC_ID_H264 ||
	obj->oc->oformat->video_codec == AV_CODEC_ID_THEORA) obj->picture->pts=-1;


    /* if the output format is not RGB24, then a temporary RGB24
       picture is needed too. It is then converted to the required
       output format */
    if (c->pix_fmt != AV_PIX_FMT_RGB24) {
      obj->tmp_picture = av_frame_alloc();
      if (!obj->tmp_picture) {
	y_error("Could not allocate picture");
      }
      size = avpicture_get_size(AV_PIX_FMT_RGB24, c->width, c->height);
      uint8_t *tmp_picture_buf = av_malloc(size);
      if (!tmp_picture_buf) {
	av_frame_free(&obj->tmp_picture);
	av_frame_free(&obj->picture);
	y_error("unable to allocate memory");
      }
      avpicture_fill((AVPicture *)obj->tmp_picture, tmp_picture_buf,
		     AV_PIX_FMT_RGB24, c->width, c->height);
    }
  }

  /* open the output file, if needed */
  if (!(obj->oc->oformat->flags & AVFMT_NOFILE))
    if (avio_open(&obj->oc->pb, obj->oc->filename, AVIO_FLAG_WRITE) < 0)
      y_errorq("Could not open '%s'", obj->oc->filename);

  obj->open = 1;

  /* write the stream header, if any */
  avformat_write_header(obj->oc, NULL);

}
Exemplo n.º 5
0
Arquivo: yusb.c Projeto: emmt/yusb
static void failure(const char* reason, int code)
{
  static char msg[256];
  if (reason == NULL || reason[0] == 0) {
    y_error(get_error_description(code));
  } else {
    sprintf(msg, "%s [%s]",  reason, get_error_name(code));
    y_error(msg);
  }
}
Exemplo n.º 6
0
  void camera_free(void *obj) {
    tCamera *camera = (tCamera *) obj;
    try {
      // unsetup the camera
      cameraUnsetup(camera);

      // uninitialise the API
      PvUnInitialize();

    } catch ( string msg ) {
      y_error(msg.c_str());
    }
    catch ( char const * msg ) {
      y_error(msg);
    }
  }
Exemplo n.º 7
0
Arquivo: yusb.c Projeto: emmt/yusb
static void load_device_list(void)
{
  INITIALIZE;
  free_dev_list(); /* in case of interrupts */
  dev_count = libusb_get_device_list(ctx, &dev_list);
  if (dev_count < 0) {
    y_error("failed to get USB devices list");
  }
}
Exemplo n.º 8
0
long
yarg_key(int iarg)
{
  if (iarg>=0 && !sp[-iarg].ops) {
    if (!iarg) y_error("(BUG) stack corrupted in yarg_key");
    return sp[-iarg].index;
  }
  return -1;
}
Exemplo n.º 9
0
Arquivo: yusb.c Projeto: emmt/yusb
static void initialize(void)
{
  if (ctx == NULL) {
    int code = libusb_init(&ctx);
    if (code != 0) {
      if (ctx != NULL) {
        y_error("*** ASSERTION FAILED *** non NULL context on libusb_init failure");
      }
      failure(NULL, code);
    }
    if (ctx == NULL) {
      y_error("*** ASSERTION FAILED *** NULL context on libusb_init success");
    }
    ycall_on_quit(finalize);
    libusb_set_debug(ctx, LIBUSB_LOG_LEVEL_NONE);
    libusb_setlocale("en");
  }
}
Exemplo n.º 10
0
ypointer_t
ygets_p(int iarg)
{
  Operations *ops;
  Member *type;
  void **p;
  if (iarg < 0) return 0;
  p = ygeta_array(iarg, &ops, &type);
  if (ops!=&pointerOps || type->dims)
    y_error("expecting scalar pointer argument");
  return p[0];
}
Exemplo n.º 11
0
ystring_t
ygets_q(int iarg)
{
  Operations *ops;
  Member *type;
  char **q;
  if (iarg < 0) return 0;
  q = ygeta_array(iarg, &ops, &type);
  if (ops!=&stringOps || type->dims)
    y_error("expecting scalar string argument");
  return q[0];
}
Exemplo n.º 12
0
Arquivo: yusb.c Projeto: emmt/yusb
void Y_usb_debug(int argc)
{
  int level;

  if (argc != 1) {
    y_error("expecting exactly one argument");
  }
  level = ygets_i(0);
  INITIALIZE;
  libusb_set_debug(ctx, level);
  ypush_nil();
}
Exemplo n.º 13
0
ypointer_t *
ygeta_p(int iarg, long *ntot, long *dims)
{
  Operations *ops;
  Member *type;
  void *p;
  if (iarg < 0) return 0;
  p = ygeta_array(iarg, &ops, &type);
  yget_dims(ntot, dims, type);
  if (ops != &pointerOps)
    y_error("expecting pointer argument");
  return p;
}
Exemplo n.º 14
0
Arquivo: yusb.c Projeto: emmt/yusb
void Y_usb_control_transfer(int argc)
{
  ydev_instance_t* obj;
  int ret;
  int type, request, value, index, length;
  long size;
  unsigned char* data;
  unsigned int timeout;

  /* Get arguments. */
  if (argc != 8) {
    y_error("expecting exactly 8 arguments");
  }
  obj = get_device(7);
  type = ygets_i(6) & 0xff; /* uint8_t */
  request = ygets_i(5) & 0xff; /* uint8_t */
  value = ygets_i(4) & 0xffff; /* uint16_t */
  index = ygets_i(3) & 0xffff; /* uint16_t */
  data = (unsigned char*)get_data(2, &size);
  length = ygets_i(1) & 0xffff; /* uint16_t */
  timeout = (unsigned int)(ygets_l(0) & 0xffffffffL);
  if (length < 0) {
    y_error("invalid length");
  }
  if (length > size) {
    y_error("length must be at most the size of the data");
  }

  /* Apply operation. */
  ret = libusb_control_transfer(obj->handle, type, request, value,
                                index, data, length, timeout);
  if (ret < 0 && yarg_subroutine()) {
    failure(NULL, ret);
  }
  ypush_int(ret);
}
Exemplo n.º 15
0
void
Y_timestamp(int argc)
{
  time_t n_time = time((void *)0);
  char *time = ctime(&n_time);
  long index = yget_ref(0);
  if (argc != 1) y_error("timestamp takes exactly one argument");
  if (index >= 0) {
    ypush_long((long)n_time);
    yput_global(index, 0);
  }
  if (!yarg_subroutine()) {
    char **q = ypush_q(0);
    q[0] = p_strcpy(strtok(time, "\n"));
  }
}
Exemplo n.º 16
0
int
yarg_kw(int iarg, long *kglobs, int *kiargs)
{
  long n, *globs, vndex;
  while (iarg>=0 && !sp[-iarg].ops) {
    if (!iarg)
      y_error("(BUG) stack corrupted in yarg_kw");
    vndex = sp[-iarg].index;
    n = kglobs[0];
    for (globs=kglobs+1 ; --n >= 0 ; globs++)
      if (globs[0] == vndex) break;
    if (n < 0)
      y_errorq("unrecognized keyword: %s", globalTable.names[vndex]);
    kiargs[kglobs[0]-1-n] = --iarg;
    --iarg;
  }
  return iarg;
}
Exemplo n.º 17
0
Arquivo: yusb.c Projeto: emmt/yusb
void Y_usb_claim_interface(int argc)
{
  ydev_instance_t* obj;
  int interface_number;
  int ret;

  if (argc != 2) {
    y_error("expecting exactly 2 arguments");
  }
  obj = get_device(1);
  interface_number = ygets_i(0);

  ret = libusb_claim_interface(obj->handle, interface_number);
  if (ret < 0 && yarg_subroutine()) {
    failure(NULL, ret);
  }
  ypush_int(ret);
}
Exemplo n.º 18
0
Arquivo: yusb.c Projeto: emmt/yusb
static void* get_data(int iarg, long* the_size)
{
  void* data;
  long size, ntot;
  int type;

  data = NULL;
  size = 0;
  if (! yarg_nil(iarg)) {
    data = ygeta_any(iarg, &ntot, NULL, &type);
    switch(type) {
    case Y_CHAR:
      size = sizeof(char)*ntot;
      break;
    case Y_SHORT:
      size = sizeof(short)*ntot;
      break;
    case Y_INT:
      size = sizeof(int)*ntot;
      break;
    case Y_LONG:
      size = sizeof(long)*ntot;
      break;
    case Y_FLOAT:
      size = sizeof(float)*ntot;
      break;
    case Y_DOUBLE:
      size = sizeof(double)*ntot;
      break;
    case Y_COMPLEX:
      size = 2*sizeof(double)*ntot;
      break;
    default:
      y_error("bad data type");
    }
  }
  if (the_size != NULL) {
    *the_size = size;
  }
  return data;
}
Exemplo n.º 19
0
Arquivo: yusb.c Projeto: emmt/yusb
void Y_usb_open_device(int argc)
{
  ydev_instance_t *obj = NULL;
  libusb_device* dev;
  int bus, port;
  int i, ret;

  if (argc != 2) {
    y_error("expecting exactly 2 arguments");
  }
  bus = ygets_i(1);
  port = ygets_i(0);

  load_device_list();
  for (i = 0; i < dev_count; ++i) {
    dev = dev_list[i];
    if (libusb_get_bus_number(dev) == bus &&
        libusb_get_port_number(dev) == port) {
      obj = (ydev_instance_t *)ypush_obj(&ydev_class, sizeof(ydev_instance_t));
      obj->device = libusb_ref_device(dev);
      ret = libusb_open(obj->device, &obj->handle);
      if (ret < 0) {
        obj->handle = NULL;
        failure("failed to open device", ret);
      }
      obj->bus = bus;
      obj->port = port;
      obj->address = libusb_get_device_address(dev);
      ret = libusb_get_device_descriptor(dev, &obj->descriptor);
      if (ret != 0) {
        free_dev_list();
        failure("unable to get device descriptor", ret);
      }
      break;
    }
  }
  free_dev_list();
  if (obj == NULL) {
    ypush_nil();
  }
}
Exemplo n.º 20
0
Arquivo: yusb.c Projeto: emmt/yusb
void Y_usb_get_string(int argc)
{
  char str[STRING_DESCRIPTOR_SIZE];
  ydev_instance_t* obj;
  int index;
  int ret;

  if (argc != 2) {
    y_error("expecting exactly 2 arguments");
  }
  obj = get_device(1);
  index = ygets_i(0);

  ret = get_string_descriptor(obj->handle, index, str, sizeof(str));
  if (ret < 0) {
    ypush_int(ret);
  } else {
    str[sizeof(str)/sizeof(str[0]) - 1] = 0;
    push_string(str);
  }
}
Exemplo n.º 21
0
Arquivo: yusb.c Projeto: emmt/yusb
static void ydev_extract(void *addr, char *member)
{
  ydev_instance_t *obj = (ydev_instance_t *)addr;
  int c = (member != NULL ? member[0] : '\0');
  if (c == 'b' && strcmp(member, "bus") == 0) {
    ypush_int(obj->bus);
  } else if (c == 'p' && strcmp(member, "port") == 0) {
    ypush_int(obj->port);
  } else if (c == 'a' && strcmp(member, "address") == 0) {
    ypush_int(obj->address);
  } else if (c == 'v' && strcmp(member, "vendor") == 0) {
    ypush_int(obj->descriptor.idVendor);
  } else if (c == 'p' && strcmp(member, "product") == 0) {
    ypush_int(obj->descriptor.idProduct);
  } else if (c == 'm' && strcmp(member, "manufacturer") == 0) {
    ypush_int(obj->descriptor.iManufacturer);
  } else if (c == 's' && strcmp(member, "serial") == 0) {
    ypush_int(obj->descriptor.iSerialNumber);
  } else {
    y_error("bad member name");
  }
}
Exemplo n.º 22
0
Arquivo: yusb.c Projeto: emmt/yusb
void Y__usb_probe_devices(int argc)
{
  struct libusb_device_descriptor desc;
  libusb_device* dev;
  long dims[3];
  int* data;
  int i, ret;

  if (argc != 1 || ! yarg_nil(0)) {
    y_error("expecting exactly one nil argument");
  }
  load_device_list();
  if (dev_count > 0) {
    dims[0] = 2;
    dims[1] = 7;
    dims[2] = dev_count;
    data = ypush_i(dims);
    for (i = 0; i < dev_count; ++i) {
      dev = dev_list[i];
      ret = libusb_get_device_descriptor(dev, &desc);
      if (ret != 0) {
        free_dev_list();
        failure("unable to get device descriptor", ret);
      }
      data[0] = libusb_get_bus_number(dev);
      data[1] = libusb_get_port_number(dev);
      data[2] = libusb_get_device_address(dev);
      data[3] = desc.idVendor;
      data[4] = desc.idProduct;
      data[5] = desc.iManufacturer;
      data[6] = desc.iSerialNumber;
      data += 7;
    }
  } else {
    ypush_nil();
  }
  free_dev_list();
}
Exemplo n.º 23
0
long
ygets_l(int iarg)
{
  Operations *ops;
  Member *type;
  void *p;
  if (iarg < 0) return 0;
  p = ygeta_array(iarg, &ops, &type);
  if (!type->dims && ops->promoteID<T_FLOAT) {
    if (ops != &longOps) {
      int is_db = (sp[-iarg].ops == &dataBlockSym);
      long x;
      y_to_l[ops->promoteID](p, &x, type->number);
      sp[-iarg].ops = &longScalar;
      if (is_db) Unref(sp[-iarg].value.db);
      sp[-iarg].value.l = x;
      return x;
    }
    return *(long *)p;
  }
  y_error("expecting scalar integer argument");
  return 0;
}
Exemplo n.º 24
0
double
ygets_d(int iarg)
{
  Operations *ops;
  Member *type;
  void *p;
  if (iarg < 0) return 0;
  p = ygeta_array(iarg, &ops, &type);
  if (!type->dims && ops->promoteID<T_COMPLEX) {
    if (ops != &doubleOps) {
      int is_db = (sp[-iarg].ops == &dataBlockSym);
      double x;
      y_to_d[ops->promoteID](p, &x, type->number);
      sp[-iarg].ops = &doubleScalar;
      if (is_db) Unref(sp[-iarg].value.db);
      sp[-iarg].value.d = x;
      return x;
    }
    return *(double *)p;
  }
  y_error("expecting scalar real argument");
  return 0;
}
Exemplo n.º 25
0
void
gy_value_set_iarg(GValue* pval, GITypeInfo * info, int iarg)
{
  GY_DEBUG("in gy_value_set_iarg\n");
  GITypeTag type = g_type_info_get_tag(info);
  GIBaseInfo * itrf;
  switch (type) {
  case GI_TYPE_TAG_BOOLEAN:
    g_value_set_boolean(pval, ygets_c(iarg));
    break;
  case GI_TYPE_TAG_INT8:
    g_value_set_schar(pval, ygets_c(iarg));
    break;
  case GI_TYPE_TAG_UINT8:
    g_value_set_uchar(pval, ygets_c(iarg));
    break;
  case GI_TYPE_TAG_INT16:
  case GI_TYPE_TAG_INT32:
    g_value_set_int(pval, ygets_i(iarg));
    break;
  case GI_TYPE_TAG_UINT16:
  case GI_TYPE_TAG_UINT32:
    g_value_set_uint(pval, ygets_i(iarg));
    break;
  case GI_TYPE_TAG_INT64:
    g_value_set_int64(pval, ygets_l(iarg));
    break;
  case GI_TYPE_TAG_UINT64:
    g_value_set_uint64(pval, ygets_l(iarg));
    break;
  case GI_TYPE_TAG_FLOAT:
    g_value_set_float(pval, ygets_f(iarg));
    break;
  case GI_TYPE_TAG_DOUBLE:
    g_value_set_double(pval, ygets_d(iarg));
    break;
  case GI_TYPE_TAG_GTYPE:
    g_value_set_gtype(pval, ygets_l(iarg));
    break;
  case GI_TYPE_TAG_UTF8:
  case GI_TYPE_TAG_FILENAME:
    g_value_set_static_string (pval, ygets_q(iarg));
    GY_DEBUG("GValue is string: \"%s\"\n", ygets_q(iarg));
    break;
    /* interface types */
  case GI_TYPE_TAG_INTERFACE:
    itrf = g_type_info_get_interface(info);
    switch(g_base_info_get_type (itrf)) {
    case GI_INFO_TYPE_ENUM:
      g_value_set_enum (pval, ygets_l(iarg));
      break;
    case GI_INFO_TYPE_OBJECT:
      g_value_set_object(pval, yget_gy_Object(iarg)->object);
      break;
    default:
      y_errorn("Unimplemented GValue interface type %ld",
	       g_base_info_get_type (itrf));
    }
    g_base_info_unref(itrf);
    break;
  case GI_TYPE_TAG_VOID:
  default:
    y_error("Unimplement property GValue type");
  }
  GY_DEBUG("out gy_iarg2gvalue\n");
}
Exemplo n.º 26
0
void
gy_value_init(GValue * val, GITypeInfo * info)
{
  GY_DEBUG("in gy_value_init\n");
  GITypeTag type = g_type_info_get_tag(info);
  GIBaseInfo * itrf;
  GY_DEBUG("Initializing GValue to %s\n", g_type_tag_to_string(type));
  switch (type) {
    /* basic types */
  case GI_TYPE_TAG_BOOLEAN:
    g_value_init(val, G_TYPE_BOOLEAN);
    break;
  case GI_TYPE_TAG_INT8:
    g_value_init(val, G_TYPE_CHAR);
    break;
  case GI_TYPE_TAG_UINT8:
    g_value_init(val, G_TYPE_UCHAR);
    break;
  case GI_TYPE_TAG_INT16:
  case GI_TYPE_TAG_INT32:
    g_value_init(val, G_TYPE_INT);
    break;
  case GI_TYPE_TAG_UINT16:
  case GI_TYPE_TAG_UINT32:
    g_value_init(val, G_TYPE_INT);
    break;
  case GI_TYPE_TAG_INT64:
    g_value_init(val, G_TYPE_INT64);
    break;
  case GI_TYPE_TAG_UINT64:
    g_value_init(val, G_TYPE_UINT64);
    break;
  case GI_TYPE_TAG_FLOAT:
    g_value_init(val, G_TYPE_FLOAT);
    break;
  case GI_TYPE_TAG_DOUBLE:
    g_value_init(val, G_TYPE_DOUBLE);
    break;
  case GI_TYPE_TAG_GTYPE:
    g_value_init(val, G_TYPE_GTYPE);
    break;
  case GI_TYPE_TAG_UTF8:
  case GI_TYPE_TAG_FILENAME:
    g_value_init(val, G_TYPE_STRING);
    GY_DEBUG("GValue is string\n");
    break;
    /* interface types */
  case GI_TYPE_TAG_INTERFACE:
    itrf = g_type_info_get_interface(info);
    switch(g_base_info_get_type (itrf)) {
    case GI_INFO_TYPE_OBJECT:
      g_value_init(val, G_TYPE_OBJECT);
      break;
    case GI_INFO_TYPE_ENUM:
      g_value_init(val,  g_registered_type_info_get_g_type(itrf));
      GY_DEBUG("GValue is enum\n");
      break;
    default:
      y_errorn("Unimplemented GValue interface type %ld",
	       g_base_info_get_type (itrf));
    }
    g_base_info_unref(itrf);
    break;
  case GI_TYPE_TAG_VOID:
  default:
    y_error("Unimplement property GValue type");
  }
  GY_DEBUG("out gy_value_init\n");
}
Exemplo n.º 27
0
void
gy_value_push(GValue * pval, GITypeInfo * info, gy_Object* o)
{
  GITypeTag tag = g_type_info_get_tag(info);
  GY_DEBUG("Pushing %s from GValue\n", g_type_tag_to_string(tag));
  switch (tag) {
    /* basic types */
  case GI_TYPE_TAG_VOID:{
    GITypeInfo * cellinfo = g_type_info_get_param_type(info, 0);
    if (cellinfo) {
      GITypeTag ctag = g_type_info_get_tag(cellinfo);
      GY_DEBUG("void contains %s\n", g_type_tag_to_string(ctag));
      g_base_info_unref(cellinfo);
    }
    ypush_nil();
    break;}
  case GI_TYPE_TAG_BOOLEAN:
    *ypush_c(NULL) = g_value_get_boolean(pval);
    break;
  case GI_TYPE_TAG_INT8:
    *ypush_gint8(NULL) = g_value_get_schar(pval);
    break;
  case GI_TYPE_TAG_UINT8:
    *ypush_guint8(NULL)= g_value_get_uchar(pval);
    break;
  case GI_TYPE_TAG_INT16:
  case GI_TYPE_TAG_INT32:
    *ypush_gint32(NULL) = g_value_get_int(pval);
    break;
  case GI_TYPE_TAG_UINT16:
  case GI_TYPE_TAG_UINT32:
    *ypush_guint32(NULL) = g_value_get_uint(pval);
    break;
  case GI_TYPE_TAG_INT64:
    ypush_long(g_value_get_int64(pval));
    break;
  case GI_TYPE_TAG_UINT64:
    ypush_long(g_value_get_uint64(pval));
    break;
  case GI_TYPE_TAG_FLOAT:
    *ypush_f(NULL)=g_value_get_float(pval);
    break;
  case GI_TYPE_TAG_DOUBLE:
    ypush_double(g_value_get_double(pval));
    break;
  case GI_TYPE_TAG_GTYPE:
    ypush_long(g_value_get_gtype(pval));
    break;
  case GI_TYPE_TAG_UTF8:
  case GI_TYPE_TAG_FILENAME:
    *ypush_q(NULL) = p_strcpy(g_value_get_string(pval));
    break;
    /* array types */
  case GI_TYPE_TAG_ARRAY:
    y_error("array");
    break;
    /* interface types */
  case GI_TYPE_TAG_INTERFACE:
    {
      GIBaseInfo * itrf = g_type_info_get_interface (info);
      switch(g_base_info_get_type (itrf)) {
      case GI_INFO_TYPE_ENUM:
	ypush_long(g_value_get_enum(pval));
	g_base_info_unref(itrf);
	break;
      case GI_INFO_TYPE_OBJECT:
	{
	  GObject * prop=g_value_get_object(pval);
	  g_object_ref_sink(prop);
	  if (!prop) {
	    g_base_info_unref(itrf);
	    y_error("get property failed");
	  }
	  GY_DEBUG("pushing result... ");
	  ypush_check(1);
	  gy_Object * out = ypush_gy_Object();

	  out->info=itrf;
	  out->object=prop;
	  out->repo=o->repo;
	}
	break;
      default:
      	g_base_info_unref(itrf);
      	y_error ("fix me: only properties of type object supported yet");
      }
      break;
    }
  default:
    y_error("Unimplemented");
  }


}
Exemplo n.º 28
0
Arquivo: yusb.c Projeto: emmt/yusb
 static void do_transfer(int argc,
                         int (*transfer)(struct libusb_device_handle* handle,
                                         unsigned char endpoint,
                                         unsigned char* data,
                                         int length,
                                         int* transferred,
                                         unsigned int timeout))
{
  ydev_instance_t* obj;
  int ret, iarg;
  int endpoint, length, transferred, offset;
  long size;
  unsigned char* data;
  unsigned int timeout;
  long transferred_index;

  /* Get arguments. */
  if (argc != 6 && argc != 7) {
    y_error("expecting 6 or 7 arguments");
  }
  iarg = argc;
  obj = get_device(--iarg);
  endpoint = ygets_i(--iarg) & 0xff; /* uint8_t */
  data = (unsigned char*)get_data(--iarg, &size);
  length = ygets_i(--iarg);
  if (length < 0) {
    y_error("invalid length");
  }
  if (length > size) {
    y_error("length must be at most the size of the data");
  }
  transferred_index = yget_ref(--iarg);
  if (transferred_index < 0L) {
    y_error("expecting a simple variable reference");
  }
  timeout = (unsigned int)(ygets_l(--iarg) & 0xffffffffL);
  if (iarg > 0) {
    offset = ygets_i(--iarg);
    if (offset < 0 || offset > length) {
      y_error("invalid offset");
    }
  } else {
    offset = 0;
  }

  /* Apply operation. */
  if (length > offset) {
    ret = transfer(obj->handle, endpoint, data + offset,
                   length - offset, &transferred, timeout);
    if (!(ret == 0 || (ret == LIBUSB_ERROR_TIMEOUT && transferred > 0))) {
      /* No data has been transferred. */
      transferred = 0;
      if (yarg_subroutine()) {
        /* Some error has occured. */
        failure(NULL, ret);
      }
    }
  } else {
    /* Nothing to do. */
    transferred = 0;
    ret = 0;
  }
  if (transferred_index >= 0L) {
    /* Store total number of transferred bytes so far. */
    ypush_int(offset + transferred);
    yput_global(transferred_index, 0);
  }
  ypush_int(ret);
}
Exemplo n.º 29
0
  // av_opt_set missing at least until this version
  int av_opt_set (void *obj, const char * name, const char * val,
		  int search_flags)
  { y_error("av_opt_set unimplemented in this libav/ffmpeg"); return -1; }
Exemplo n.º 30
0
Arquivo: yusb.c Projeto: emmt/yusb
void Y_usb_error_description(int argc)
{
  if (argc != 1) y_error("expected exactly one argument");
  push_string(get_error_description(ygets_i(0)));
}