• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ caml_alloc_tuple函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中caml_alloc_tuple函数的典型用法代码示例。如果您正苦于以下问题:C++ caml_alloc_tuple函数的具体用法?C++ caml_alloc_tuple怎么用?C++ caml_alloc_tuple使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了caml_alloc_tuple函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: mk_src_info

value mk_src_info(source_info_t *src_info) {
  CAMLparam0();
  CAMLlocal3(ocaml_src_info, file, some_none);

  if (src_info != NULL) {

    if (src_info->filename) {
      //printf("Src info filename: %s\n", src_info->filename);

      file = caml_copy_string(src_info->filename);
      //int len = strlen(src_info->filename);
      //file = caml_alloc_string(len);
      //memcpy(String_val(file),src_info->filename , len);

      some_none = caml_alloc_tuple(1);
      Store_field(some_none, 0, file);
    } else {
      some_none = Val_int(0);
    }

    ocaml_src_info = caml_alloc_tuple(3);
    Store_field(ocaml_src_info, 0, some_none);
    Store_field(ocaml_src_info, 1, Val_int(src_info->line));
    Store_field(ocaml_src_info, 2, Val_int(src_info->col));
  } else {
    ocaml_src_info = caml_alloc_tuple(3);
    Store_field(ocaml_src_info, 0, Val_int(0));
    Store_field(ocaml_src_info, 1, Val_int(0));
    Store_field(ocaml_src_info, 2, Val_int(0));
  }

  CAMLreturn(ocaml_src_info);
}
开发者ID:iskandr,项目名称:parakeet-retired,代码行数:33,代码来源:ast_stubs.c


示例2: Val_physinfo

static value Val_physinfo(libxl_physinfo *c_val)
{
	CAMLparam0();
	CAMLlocal2(v, hwcap);
	int i;

	hwcap = caml_alloc_tuple(8);
	for (i = 0; i < 8; i++)
		Store_field(hwcap, i, caml_copy_int32(c_val->hw_cap[i]));

	v = caml_alloc_tuple(11);
	Store_field(v, 0, Val_int(c_val->threads_per_core));
	Store_field(v, 1, Val_int(c_val->cores_per_socket));
	Store_field(v, 2, Val_int(c_val->max_cpu_id));
	Store_field(v, 3, Val_int(c_val->nr_cpus));
	Store_field(v, 4, Val_int(c_val->cpu_khz));
	Store_field(v, 5, caml_copy_int64(c_val->total_pages));
	Store_field(v, 6, caml_copy_int64(c_val->free_pages));
	Store_field(v, 7, caml_copy_int64(c_val->scrub_pages));
	Store_field(v, 8, Val_int(c_val->nr_nodes));
	Store_field(v, 9, hwcap);
	Store_field(v, 10, caml_copy_int32(c_val->phys_cap));

	CAMLreturn(v);
}
开发者ID:Angel666,项目名称:android_hardware_intel,代码行数:25,代码来源:xl_stubs.c


示例3: caml_gc_get

CAMLprim value caml_gc_get(value v)
{
  CAMLparam0 ();   /* v is ignored */
  CAMLlocal1 (res);

  res = caml_alloc_tuple (7);
#ifndef NATIVE_CODE
  Store_field (res, 5, Val_long (caml_max_stack_size));                 /* l */
#else
  Store_field (res, 5, Val_long (0));
#endif

  CAMLreturn (res);

#if 0
  CAMLparam0 ();   /* v is ignored */
  CAMLlocal1 (res);

  res = caml_alloc_tuple (7);
  Store_field (res, 0, Val_long (Wsize_bsize (Caml_state->minor_heap_size)));  /* s */
  Store_field (res, 1, Val_long (caml_major_heap_increment));           /* i */
  Store_field (res, 2, Val_long (caml_percent_free));                   /* o */
  Store_field (res, 3, Val_long (caml_params->verb_gc));         /* v */
  Store_field (res, 4, Val_long (caml_percent_max));                    /* O */
#ifndef NATIVE_CODE
  Store_field (res, 5, Val_long (caml_max_stack_size));                 /* l */
#else
  Store_field (res, 5, Val_long (0));
#endif
  Store_field (res, 6, Val_long (caml_allocation_policy));              /* a */
  Store_field (res, 7, Val_long (caml_major_window));                   /* w */
  CAMLreturn (res);
#endif
}
开发者ID:dhil,项目名称:ocaml-multicore,代码行数:34,代码来源:gc_ctrl.c


示例4: ocaml_gstreamer_message_parse_tag

CAMLprim value ocaml_gstreamer_message_parse_tag(value _msg)
{
  CAMLparam1(_msg);
  CAMLlocal4(v,s,t,ans);
  GstMessage *msg = Message_val(_msg);
  GstTagList *tags = NULL;
  const GValue *val;
  const gchar *tag;
  int taglen;
  int i, j, n;

  caml_release_runtime_system();
  gst_message_parse_tag(msg, &tags);
  taglen = gst_tag_list_n_tags(tags);
  caml_acquire_runtime_system();

  ans = caml_alloc_tuple(taglen);
  for(i = 0; i < taglen; i++)
    {
      t = caml_alloc_tuple(2);

      // Tag name
      tag = gst_tag_list_nth_tag_name(tags, i);
      Store_field(t, 0, caml_copy_string(tag));

      // Tag fields
      n = gst_tag_list_get_tag_size(tags, tag);
      v = caml_alloc_tuple(n);
      for (j = 0; j < n; j++)
        {
          val = gst_tag_list_get_value_index(tags, tag, j);
          if (G_VALUE_HOLDS_STRING(val)) {
              s = caml_copy_string(g_value_get_string(val));
            }
          else if (GST_VALUE_HOLDS_DATE_TIME(val)) {
              GstDateTime *dt = g_value_get_boxed(val);
              gchar *dt_str = gst_date_time_to_iso8601_string(dt);
              s = caml_copy_string(dt_str);
              g_free(dt_str);
            }
          else {
              //TODO: better typed handling of non-string values?
              char *vc = g_strdup_value_contents(val);
              s = caml_copy_string(vc);
              free(vc);
            }
          Store_field(v, j, s);
        }
      Store_field(t, 1, v);

      Store_field(ans, i, t);
    }

  gst_tag_list_unref(tags);

  CAMLreturn(ans);
}
开发者ID:gndl,项目名称:ocaml-gstreamer,代码行数:57,代码来源:gstreamer_stubs.c


示例5: caml_gc_quick_stat

CAMLprim value caml_gc_quick_stat(value v)
{
    CAMLparam0 ();
    CAMLlocal1 (res);

    /* get a copy of these before allocating anything... */
    double minwords = caml_stat_minor_words
                      + (double) Wsize_bsize (caml_young_end - caml_young_ptr);
    double prowords = caml_stat_promoted_words;
    double majwords = caml_stat_major_words + (double) caml_allocated_words;
    intnat mincoll = caml_stat_minor_collections;
    intnat majcoll = caml_stat_major_collections;
    intnat heap_words = caml_stat_heap_size / sizeof (value);
    intnat top_heap_words = caml_stat_top_heap_size / sizeof (value);
    intnat cpct = caml_stat_compactions;
    intnat heap_chunks = caml_stat_heap_chunks;

    res = caml_alloc_tuple (15);
    Store_field (res, 0, caml_copy_double (minwords));
    Store_field (res, 1, caml_copy_double (prowords));
    Store_field (res, 2, caml_copy_double (majwords));
    Store_field (res, 3, Val_long (mincoll));
    Store_field (res, 4, Val_long (majcoll));
    Store_field (res, 5, Val_long (heap_words));
    Store_field (res, 6, Val_long (heap_chunks));
    Store_field (res, 7, Val_long (0));
    Store_field (res, 8, Val_long (0));
    Store_field (res, 9, Val_long (0));
    Store_field (res, 10, Val_long (0));
    Store_field (res, 11, Val_long (0));
    Store_field (res, 12, Val_long (0));
    Store_field (res, 13, Val_long (cpct));
    Store_field (res, 14, Val_long (top_heap_words));
    CAMLreturn (res);
}
开发者ID:rizo,项目名称:snowflake-os,代码行数:35,代码来源:gc_ctrl.c


示例6: tun_opendev

CAMLprim value
tun_opendev(value devname, value kind, value pi, value persist, value user, value group)
{
  CAMLparam5(devname, kind, pi, persist, user);
  CAMLxparam1(group);
  CAMLlocal2(res, dev_caml);

  char dev[IFNAMSIZ];
  int fd;

#if defined (__APPLE__) && defined (__MACH__)
  if (caml_string_length(devname) < 4)
    caml_failwith("On MacOSX, you need to specify the name of the device, e.g. tap0");
#endif

  memset(dev, 0, sizeof dev);
  memcpy(dev, String_val(devname), caml_string_length(devname));

  // All errors are already checked by tun_alloc, returned fd is valid
  // otherwise it would have crashed before
  fd = tun_alloc(dev, Int_val(kind), Bool_val(pi), Bool_val(persist), Int_val(user), Int_val(group));

  res = caml_alloc_tuple(2);
  dev_caml = caml_copy_string(dev);

  Store_field(res, 0, Val_int(fd));
  Store_field(res, 1, dev_caml);

  CAMLreturn(res);
}
开发者ID:pgj,项目名称:ocaml-tuntap,代码行数:30,代码来源:tuntap_stubs.c


示例7: stub_get_blktap3_stats

CAMLprim value stub_get_blktap3_stats(value filename)
{

	CAMLparam1(filename);
	CAMLlocal1(stats);

	FILE *c_fd;
	struct stats c_stats;

	c_fd = fopen(String_val(filename), "rb");

	if (!c_fd) uerror("fopen", Nothing);
	if (fread(&c_stats, sizeof(struct stats), 1, c_fd) < 1) uerror("fread", Nothing);

	stats = caml_alloc_tuple(10);

	Store_field(stats, 0, caml_copy_int64((int64_t) c_stats.read_reqs_submitted));
	Store_field(stats, 1, caml_copy_int64((int64_t) c_stats.read_reqs_completed));
	Store_field(stats, 2, caml_copy_int64((int64_t) c_stats.read_sectors));
	Store_field(stats, 3, caml_copy_int64((int64_t) c_stats.read_total_ticks));
	Store_field(stats, 4, caml_copy_int64((int64_t) c_stats.write_reqs_submitted));
	Store_field(stats, 5, caml_copy_int64((int64_t) c_stats.write_reqs_completed));
	Store_field(stats, 6, caml_copy_int64((int64_t) c_stats.write_sectors));
	Store_field(stats, 7, caml_copy_int64((int64_t) c_stats.write_total_ticks));
	Store_field(stats, 8, caml_copy_int64((int64_t) c_stats.io_errors));
	if ((c_stats.flags) & BT3_LOW_MEMORY_MODE)
		Store_field(stats, 9, Val_true);
	else
		Store_field(stats, 9, Val_false);

	fclose(c_fd);

	CAMLreturn(stats);

}
开发者ID:euanh,项目名称:rrdd-plugins,代码行数:35,代码来源:blktap3_stats_stubs.c


示例8: stub_gnttab_map_fresh

CAMLprim value stub_gnttab_map_fresh(
    value xgh,
    value reference,
    value domid,
    value writable
)
{
    CAMLparam4(xgh, reference, domid, writable);
    CAMLlocal2(pair, contents);

    void *map =
        xc_gnttab_map_grant_ref(_G(xgh), Int_val(domid), Int_val(reference),
                                Bool_val(writable)?PROT_READ | PROT_WRITE:PROT_READ);

    if(map==NULL) {
        caml_failwith("Failed to map grant ref");
    }

    contents = caml_ba_alloc_dims(XC_GNTTAB_BIGARRAY, 1,
                                  map, 1 << XC_PAGE_SHIFT);
    pair = caml_alloc_tuple(2);
    Store_field(pair, 0, contents); /* grant_handle */
    Store_field(pair, 1, contents); /* Io_page.t */
    CAMLreturn(pair);
}
开发者ID:johnelse,项目名称:ocaml-gnt,代码行数:25,代码来源:gnttab_stubs.c


示例9: check_mems_taint

bool check_mems_taint( memorylog_entry* memlog, unsigned int cnt )
{
    CAMLparam0();
    CAMLlocal4( addrs, ret, v, tupl );
    static value *proc_check_mems_taint = NULL;

    if ( !proc_check_mems_taint ) {
        proc_check_mems_taint = caml_named_value( "check_mems_taint" );
    }

    addrs = Val_emptylist;
    for ( unsigned int i = 0; i < cnt; i ++  ) {
        tupl = caml_alloc_tuple( 2 );
        Store_field( tupl, 0, caml_copy_nativeint( memlog[i].addr ) );
        Store_field( tupl, 1, Val_int( memlog[i].size * 8 ) );
        v = caml_alloc_small( 2, 0 );
        Field( v, 0 ) = tupl;
        Field( v, 1 ) = addrs;
        addrs = v;
    }

    ret = caml_callback( *proc_check_mems_taint, addrs );

    CAMLreturnT( bool, Bool_val( ret ) );
}
开发者ID:ArashAll,项目名称:symfuzz,代码行数:25,代码来源:analysis_api.cpp


示例10: stub_inotify_convert

value stub_inotify_convert(value buf)
{
	CAMLparam1(buf);
	CAMLlocal3(event, l, tmpl);
	struct inotify_event ev;
	int i;

	l = Val_emptylist;
	tmpl = Val_emptylist;

	memcpy(&ev, String_val(buf), sizeof(struct inotify_event));

	for (i = 0; inotify_return_table[i]; i++) {
		if (!(ev.mask & inotify_return_table[i]))
			continue;
		tmpl = caml_alloc_small(2, Tag_cons);
		Field(tmpl, 0) = Val_int(i);
		Field(tmpl, 1) = l;
		l = tmpl;
	}

	event = caml_alloc_tuple(4);
	Store_field(event, 0, Val_int(ev.wd));
	Store_field(event, 1, l);
	Store_field(event, 2, caml_copy_int32(ev.cookie));
	Store_field(event, 3, Val_int(ev.len));

	CAMLreturn(event);
}
开发者ID:GunioRobot,项目名称:lfs,代码行数:29,代码来源:inotify_stubs.c


示例11: simulation_get_pose3d_stub

value simulation_get_pose3d_stub(value sim_val, value name_val)
{
  CAMLparam2(sim_val, name_val);
  CAMLlocal1(result);

	playerc_simulation_t *sim = Simulation_val(sim_val);
  char *name = String_val(name_val);

  double x, y, z;
  double roll, pitch, yaw;
  double time;

  DPRINTF("getting sim %p pose3d: name - %s\n", sim, name);

  if(playerc_simulation_get_pose3d(sim, name, &x, &y, &z, &roll, &pitch, &yaw, &time))
    exception_playerc_error();

  DPRINTF("set sim %p pose3d: name - %s x = %f y = %f z = %f roll = %f pitch = %f yaw = %f time = %f\n",
      sim, name, x, y, z, roll, pitch, yaw, time);

  result = caml_alloc_tuple(7);
  Store_field(result, 0, copy_double(x));
  Store_field(result, 1, copy_double(y));
  Store_field(result, 2, copy_double(z));
  Store_field(result, 3, copy_double(roll));
  Store_field(result, 4, copy_double(pitch));
  Store_field(result, 5, copy_double(yaw));
  Store_field(result, 6, copy_double(time));

  CAMLreturn(result);
}
开发者ID:jordanthayer,项目名称:ocaml-search,代码行数:31,代码来源:simulation_stubs.c


示例12: stub_launch_activate_socket

CAMLprim value stub_launch_activate_socket(value name) {
  CAMLparam1(name);
  CAMLlocal1(result);
  const char *c_name = caml_strdup(String_val(name));
  int *listening_fds = NULL;
  size_t n_listening_fds = 0;
  int err;

  caml_release_runtime_system();
  err = launch_activate_socket(c_name, &listening_fds, &n_listening_fds);
  caml_acquire_runtime_system();

  caml_stat_free((void*)c_name);

  switch (err) {
    case 0:
      result = caml_alloc_tuple(n_listening_fds);
      for (int i = 0; i < n_listening_fds; i++) {
        Store_field(result, i, Val_int(*(listening_fds + i)));
      }
      break;
    default:
      unix_error(err, "launch_activate_socket", name);
      break;
  }
  CAMLreturn(result);
}
开发者ID:cakeplus,项目名称:ocaml-launchd,代码行数:27,代码来源:launchd_stubs.c


示例13: caml_natdynlink_open

CAMLprim value caml_natdynlink_open(value filename, value global)
{
  CAMLparam2 (filename, global);
  CAMLlocal3 (res, handle, header);
  void *sym;
  void *dlhandle;
  char *p;

  /* TODO: dlclose in case of error... */

  p = caml_strdup(String_val(filename));
  caml_enter_blocking_section();
  dlhandle = caml_dlopen(String_val(filename), 1, Int_val(global));
  caml_leave_blocking_section();
  caml_stat_free(p);

  if (NULL == dlhandle)
    caml_failwith(caml_dlerror());

  sym = caml_dlsym(dlhandle, "caml_plugin_header");
  if (NULL == sym)
    caml_failwith("not an OCaml plugin");

  handle = Val_handle(dlhandle);
  header = caml_input_value_from_malloc(sym, 0);

  res = caml_alloc_tuple(2);
  Init_field(res, 0, handle);
  Init_field(res, 1, header);
  CAMLreturn(res);
}
开发者ID:bluddy,项目名称:ocaml-multicore,代码行数:31,代码来源:natdynlink.c


示例14: get_capabilities

CAMLprim value get_capabilities() {
	CAMLparam0();
	CAMLlocal1(out_val);
	out_val = caml_alloc_tuple(5);
#if defined(WIN32) || defined (__CYGWIN__)
	int info[4];
	int max_eax;
	__cpuid(info, 0);
	max_eax = info[0];
	if(max_eax >= 1) {
		__cpuid(info, 1);
	} else {
		info[0] = 0;
		info[1] = 0;
		info[2] = 0;
		info[3] = 0;
	}
	Store_field(out_val, 0, Val_bool(info[3] & (1 << 25)));
	Store_field(out_val, 1, Val_bool(info[3] & (1 << 26)));
	Store_field(out_val, 2, Val_bool(info[2] & (1 <<  0)));
	Store_field(out_val, 3, Val_bool(info[2] & (1 <<  9)));
	Store_field(out_val, 4, Val_bool(info[2] & (1 << 19)));
#else
	// Don't use SSE stuff - other OSes may be on any random architecture
	Store_field(out_val, 0, Val_bool(0));
	Store_field(out_val, 1, Val_bool(0));
	Store_field(out_val, 2, Val_bool(0));
	Store_field(out_val, 3, Val_bool(0));
	Store_field(out_val, 4, Val_bool(0));
#endif
	CAMLreturn(out_val);
}
开发者ID:hmage,项目名称:mp3packer,代码行数:32,代码来源:c_part.c


示例15: get_section_data_internal

value get_section_data_internal( bhp _p )
{
    CAMLparam0();
    CAMLlocal4( data, v, str, tupl );

    bh* p = (bh*) _p;
    struct bfd* abfd = p->bfdp;
    asection *sect;
    bfd_size_type datasize = 0;

    data = Val_emptylist;

    if ( p->is_from_file ) {

        for ( sect = abfd->sections; sect != NULL; sect = sect->next ) {
            datasize = bfd_get_section_size( sect );
            str = caml_alloc_string( datasize );
            bfd_get_section_contents( abfd, sect,
                                      (bfd_byte*)String_val(str),
                                      0, datasize );
            tupl = caml_alloc_tuple( 3 );
            Store_field( tupl, 0, str );
            Store_field( tupl, 1, caml_copy_int64( sect->vma ) );
            Store_field( tupl, 2, caml_copy_int64( sect->vma + datasize ) );
            v = caml_alloc_small( 2, 0 );
            Field( v, 0 ) = tupl;
            Field( v, 1 ) = data;
            data = v;
        }

    }

    CAMLreturn( data );
}
开发者ID:chubbymaggie,项目名称:libbil,代码行数:34,代码来源:bfdwrap_helper.c


示例16: simulation_get_pose2d_stub

value simulation_get_pose2d_stub(value sim_val, value name_val)
{
  CAMLparam2(sim_val, name_val);
  CAMLlocal1(result);

	playerc_simulation_t *sim = Simulation_val(sim_val);
  char *name = String_val(name_val);

  double x, y, a;

  DPRINTF("getting sim %p pose2d: name - %s\n", sim, name);

  if(playerc_simulation_get_pose2d(sim, name, &x, &y, &a))
    exception_playerc_error();

  DPRINTF("got sim %p pose2d: name - %s x = %f y = %f a = %f\n",
      sim, name, x, y, a);

  result = caml_alloc_tuple(3);
  Store_field(result, 0, copy_double(x));
  Store_field(result, 1, copy_double(y));
  Store_field(result, 2, copy_double(a));

  CAMLreturn(result);
}
开发者ID:jordanthayer,项目名称:ocaml-search,代码行数:25,代码来源:simulation_stubs.c


示例17: caml_gc_quick_stat

CAMLprim value caml_gc_quick_stat(value v)
{
  CAMLparam0 ();
  CAMLlocal1 (res);

  /* get a copy of these before allocating anything... */
  struct gc_stats s;
  caml_sample_gc_stats(&s);
  intnat majcoll = Caml_state->stat_major_collections;

  res = caml_alloc_tuple (16);
  Store_field (res, 0, caml_copy_double ((double)s.minor_words));
  Store_field (res, 1, caml_copy_double ((double)s.promoted_words));
  Store_field (res, 2, caml_copy_double ((double)s.major_words));
  Store_field (res, 3, Val_long (s.minor_collections));
  Store_field (res, 4, Val_long (majcoll));
  Store_field (res, 5, Val_long (
    s.major_heap.pool_words + s.major_heap.large_words));
  Store_field (res, 6, Val_long (0));
  Store_field (res, 7, Val_long (
    s.major_heap.pool_live_words + s.major_heap.large_words));
  Store_field (res, 8, Val_long (
    s.major_heap.pool_live_blocks + s.major_heap.large_blocks));
  Store_field (res, 9, Val_long (
    s.major_heap.pool_words - s.major_heap.pool_live_words - s.major_heap.pool_frag_words));
  Store_field (res, 10, Val_long (0));
  Store_field (res, 11, Val_long (0));
  Store_field (res, 12, Val_long (s.major_heap.pool_frag_words));
  Store_field (res, 13, Val_long (0));
  Store_field (res, 14, Val_long (
    s.major_heap.pool_max_words + s.major_heap.large_max_words));
  Store_field (res, 15, Val_long (0));
  CAMLreturn (res);
}
开发者ID:dhil,项目名称:ocaml-multicore,代码行数:34,代码来源:gc_ctrl.c


示例18: caml_udpv4_recvfrom

CAMLprim value
caml_udpv4_recvfrom(value v_fd, value v_str, value v_off, value v_len, value v_src)
{
  CAMLparam5(v_fd, v_str, v_off, v_len, v_src);
  CAMLlocal3(v_ret, v_err, v_inf);
  unsigned char *buf = String_val(v_str) + Int_val(v_off);
  size_t len = Int_val(v_len);
  int fd = Int_val(v_fd);
  struct sockaddr_in sa;
  socklen_t sa_len = sizeof(sa);
  int r = recvfrom(fd, (void *)buf, len, MSG_DONTWAIT, (struct sockaddr *)&sa, &sa_len);
  if (r < 0) {
    if (errno == EAGAIN || errno==EWOULDBLOCK)
      Val_WouldBlock(v_ret);
    else {
      v_err = caml_copy_string(strerror(errno));
      Val_Err(v_ret, v_err);
    }
  } else {
    v_inf = caml_alloc_tuple(3);
    Store_field(v_inf, 0, caml_copy_int32(ntohl(sa.sin_addr.s_addr)));
    Store_field(v_inf, 1, Val_int(ntohs(sa.sin_port)));
    Store_field(v_inf, 2, Val_int(r));
    Val_OK(v_ret, v_inf);
  }
  CAMLreturn(v_ret);
}
开发者ID:blackswanburst,项目名称:mirage,代码行数:27,代码来源:socket_stubs.c


示例19: convert_json_t

static value
convert_json_t (json_t *val, int level)
{
  CAMLparam0 ();
  CAMLlocal5 (rv, v, tv, sv, consv);

  if (level > 20)
    caml_invalid_argument ("too many levels of object/array nesting");

  if (json_is_object (val)) {
    const char *key;
    json_t *jvalue;

    rv = caml_alloc (1, JSON_DICT_TAG);
    v = Val_int (0);
    /* This will create the OCaml list backwards, but JSON
     * dictionaries are supposed to be unordered so that shouldn't
     * matter, right?  Well except that for some consumers this does
     * matter (eg. simplestreams which incorrectly uses a dict when it
     * really should use an array).
     */
    json_object_foreach (val, key, jvalue) {
      tv = caml_alloc_tuple (2);
      sv = caml_copy_string (key);
      Store_field (tv, 0, sv);
      sv = convert_json_t (jvalue, level + 1);
      Store_field (tv, 1, sv);
      consv = caml_alloc (2, 0);
      Store_field (consv, 1, v);
      Store_field (consv, 0, tv);
      v = consv;
    }
    Store_field (rv, 0, v);
  }
开发者ID:libguestfs,项目名称:libguestfs,代码行数:34,代码来源:JSON_parser-c.c


示例20: caml_inotify_convert

value caml_inotify_convert(value buf) {
  CAMLparam1(buf);
  CAMLlocal3(event, list, next);

  list = next = Val_emptylist;

  struct inotify_event ievent;
  memcpy(&ievent, String_val(buf), sizeof(struct inotify_event));

  int flag;
  for (flag = 0; inotify_return_table[flag]; flag++) {
    if (!(ievent.mask & inotify_return_table[flag]))
      continue;

    next = caml_alloc_small(2, Tag_cons);
    Field(next, 0) = Val_int(flag);
    Field(next, 1) = list;
    list = next;
  }

  event = caml_alloc_tuple(4);
  Store_field(event, 0, Val_int(ievent.wd));
  Store_field(event, 1, list);
  Store_field(event, 2, caml_copy_int32(ievent.cookie));
  Store_field(event, 3, Val_int(ievent.len));

  CAMLreturn(event);
}
开发者ID:SiebelsTim,项目名称:hhvm,代码行数:28,代码来源:inotify_stubs.c



注:本文中的caml_alloc_tuple函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ caml_copy_double函数代码示例发布时间:2022-05-30
下一篇:
C++ caml_alloc_string函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap