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

C++ caml_alloc_small函数代码示例

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

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



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

示例1: llvm_target_option

static value llvm_target_option(LLVMTargetRef Target) {
  if(Target != NULL) {
    value Result = caml_alloc_small(1, 0);
    Store_field(Result, 0, (value) Target);
    return Result;
  }

  return Val_int(0);
}
开发者ID:0x00evil,项目名称:llvm,代码行数:9,代码来源:target_ocaml.c


示例2: ocamlr_eval_sxp

CAMLprim value ocamlr_eval_sxp (value sexp_list) {

  /* sexp_list is an OCaml value containing a SEXP of sexptype LANGSXP.
     This is a LISP-style pairlist of SEXP values. r_eval_sxp executes
     the whole pairlist, and sends back the resulting SEXP wrapped up in
     an OCaml value. There's also an error handling mechanism. */

  /* r_eval_sxp handles values of type LANGSXP and PROMSXP. So we have two
     functions on the OCaml side associated to this stub, the first on
     with type lang sexp -> raw sexp, the other one with type
     prom sexp -> raw sexp. This also means that there is a dynamic type
     checking being done in the scope of the R_tryEval function, and it
     would be nice to shortcut it with statically typed equivalents. */

  CAMLparam0();

  SEXP e;        // Placeholder for the result of beta-reduction.
  int error = 0; // Error catcher boolean.

  SEXP our_call = Sexp_val(sexp_list);
  caml_enter_blocking_section();
  e = R_tryEval(our_call, R_GlobalEnv, &error);
  caml_leave_blocking_section();

  /* Implements error handling from R to Objective Caml. */
  if (error) {

    value ml_error_call = Val_unit;
    value ml_error_message = Val_unit;

    Begin_roots2(ml_error_call, ml_error_message);

    ml_error_call = Val_sexp(ocamlr_error_call);
    ocamlr_error_call = NULL;      //should check for a memory leak here...
                                   //depends on GC status of prior error_call.

    ml_error_message = caml_copy_string(ocamlr_error_message);
    ocamlr_error_message = NULL;   //should check for a memory leak here...
                                   //it seems to me that a string is leaked here.

    value error_result = caml_alloc_small(2, 0);
    Store_field(error_result, 0, ml_error_call);
    Store_field(error_result, 1, ml_error_message);

    /* The exception callback mechanism is described on the webpage
       http://www.pps.jussieu.fr/Livres/ora/DA-OCAML/book-ora118.html
       We should check to see if we could avoid the string-name lookup
       to avoid unnecessary delays in exception handling. */

    caml_raise_with_arg(*caml_named_value("OCaml-R generic error"), error_result);

    End_roots();
  }

  CAMLreturn(Val_sexp(e));
}
开发者ID:cakeplus,项目名称:OCaml-R,代码行数:56,代码来源:reduction.c


示例3: native_pub_createeee_QWidget_QWidget_Qt_WindowFlags

// constructor QWidget(QWidget* parent  = 0,Qt::WindowFlags f  = 0)
//argnames = (arg0 arg1)
    value native_pub_createeee_QWidget_QWidget_Qt_WindowFlags(value arg0,value arg1) {
        CAMLparam2(arg0,arg1);
        CAMLlocal1(_ans);
        QWidget* _arg0 = (arg0==Val_none) ? NULL : ((QWidget* )(Some_val(arg0)));
        Qt::WindowFlags _arg1 = enum_of_caml_Qt_WindowFlags(arg1);
        QWidget* ans = new QWidget(_arg0, _arg1);
        _ans = caml_alloc_small(1, Abstract_tag);
        (*((QWidget **) &Field(_ans, 0))) = ans;
        CAMLreturn(_ans);
    }
开发者ID:martindemello,项目名称:lablqt,代码行数:12,代码来源:QWidget.cpp


示例4: coq_makeaccu

value coq_makeaccu (value i) {
  CAMLparam1(i);
  CAMLlocal1(res);
  code_t q = coq_stat_alloc(2 * sizeof(opcode_t));
  res = caml_alloc_small(1, Abstract_tag);
  Code_val(res) = q;
  *q++ = VALINSTR(MAKEACCU);
  *q = (opcode_t)Int_val(i);
  CAMLreturn(res);
}
开发者ID:TheoWinterhalter,项目名称:coq,代码行数:10,代码来源:coq_fix_code.c


示例5: ml_physh_set_alloc

value ml_physh_set_alloc(value empty, value null)
{
    CAMLparam2(empty, null);
    CAMLlocal2(v,vmin);

    vmin = caml_alloc_small(2, 0);
    Field(vmin, 0) = null;
    Field(vmin, 1) = null;

    v = caml_alloc_small(6, 0);
    Field(v, 0) = Val_int(caml_stat_minor_collections);
    Field(v, 1) = Val_int(0);
    Field(v, 2) = vmin;
    Field(v, 3) = Val_int(caml_stat_compactions);
    Field(v, 4) = Val_int(0);
    Field(v, 5) = empty;

    CAMLreturn(v);
}
开发者ID:let-def,项目名称:grenier,代码行数:19,代码来源:ml_physh_set.c


示例6: lseek_cb

static value
lseek_cb(uv_req_t * req)
{
  const struct req * r = req->data;
  value ret;
  const int64_t offset = voids_to_int64_t(&r->c);
  if ( offset == -1 ){
    ret = caml_alloc_small(1,Error_tag);
    Field(ret,0) = Val_uwt_error(r->offset);
  }
  else {
    value p = caml_copy_int64(offset);
    Begin_roots1(p);
    ret = caml_alloc_small(1,Ok_tag);
    Field(ret,0) = p;
    End_roots();
  }
  return ret;
}
开发者ID:djs55,项目名称:uwt,代码行数:19,代码来源:uwt_stubs_worker.c


示例7: caml_raise_constant

CAMLexport void caml_raise_constant(value tag)
{
  CAMLparam1 (tag);
  CAMLlocal1 (bucket);

  bucket = caml_alloc_small (1, 0);
  Field(bucket, 0) = tag;
  caml_raise(bucket);
  CAMLnoreturn;
}
开发者ID:crackleware,项目名称:ocamlcc,代码行数:10,代码来源:fail.c


示例8: raise_with_two_args

static inline void raise_with_two_args(value v_tag, value v_arg1, value v_arg2)
{
  CAMLparam3(v_tag, v_arg1, v_arg2);
  value v_exc = caml_alloc_small(3, 0);
  Field(v_exc, 0) = v_tag;
  Field(v_exc, 1) = v_arg1;
  Field(v_exc, 2) = v_arg2;
  caml_raise(v_exc);
  CAMLnoreturn;
}
开发者ID:Moondee,项目名称:caut-lib,代码行数:10,代码来源:sqlite3_stubs.c


示例9: lightsource_process

CAMLprim value lightsource_process(value record_lightsource,
                                   value list_polygon_objects,
                                   value polygon_view) {
  CAMLparam3(record_lightsource, list_polygon_objects, polygon_view);
  CAMLlocal5(polygon_prev_head, list_polygon_head, vector_prev_head,
             list_vector_head, tmp_polygon);
  CAMLlocal1(tmp_vector);
  LightSource l = LightSource(Vector_val(Field(record_lightsource, 0)),
                              Double_val(Field(record_lightsource, 1)),
                              Double_val(Field(record_lightsource, 2)));
  std::vector<Polygon> tmp_polygon_list = std::vector<Polygon>();
  polygon_list_to_std_vector(list_polygon_objects, &tmp_polygon_list);
  std::vector<Vector> tmp_vector_list = std::vector<Vector>();
  vector_list_to_std_vector(Field(polygon_view, 0), &tmp_vector_list);
  Polygon polygon = Polygon(tmp_vector_list);
  // auto start = std::chrono::steady_clock::now();
  std::vector<Polygon> list_polygon = l.process(tmp_polygon_list);
  // auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(
  //     std::chrono::steady_clock::now() - start);
  // printf("--> %lld\n", duration.count());
  polygon_prev_head = Val_unit;
  for (Polygon p : list_polygon) {
    vector_prev_head = Val_unit;
    for (Vector v : p.get_vertices()) {
      tmp_vector = caml_alloc_small(2, Double_array_tag);
      Double_field(tmp_vector, 0) = v.x;
      Double_field(tmp_vector, 1) = v.y;
      list_vector_head = caml_alloc_small(2, 0);
      Field(list_vector_head, 0) = tmp_vector;
      Field(list_vector_head, 1) = vector_prev_head;
      vector_prev_head = list_vector_head;
    }
    tmp_polygon = caml_alloc_small(1, 0);
    Field(tmp_polygon, 0) = list_vector_head;

    list_polygon_head = caml_alloc_small(2, 0);
    Field(list_polygon_head, 0) = tmp_polygon;
    Field(list_polygon_head, 1) = polygon_prev_head;
    polygon_prev_head = list_polygon_head;
  }
  CAMLreturn(list_polygon_head);
}
开发者ID:SodaCookie,项目名称:amnesia-engine,代码行数:42,代码来源:lightsource.cpp


示例10: my_alloc_sockaddr

value my_alloc_sockaddr(struct sockaddr_storage *ss)
{
  value res, a;
  struct sockaddr_un *sun;
  struct sockaddr_in *sin;
  struct sockaddr_in6 *sin6;

  switch(ss->ss_family) {
  case AF_UNIX:
    sun = (struct sockaddr_un *) ss;
    a = caml_copy_string(sun->sun_path);
    Begin_root (a);
    res = caml_alloc_small(1, 0);
    Field(res,0) = a;
    End_roots();
    break;
  case AF_INET:
    sin = (struct sockaddr_in *) ss;
    a = caml_alloc_string(4);
    memcpy(String_val(a), &sin->sin_addr, 4);
    Begin_root (a);
    res = caml_alloc_small(2, 1);
    Field(res, 0) = a;
    Field(res, 1) = Val_int(ntohs(sin->sin_port));
    End_roots();
    break;
  case AF_INET6:
    sin6 = (struct sockaddr_in6 *) ss;
    a = caml_alloc_string(16);
    memcpy(String_val(a), &sin6->sin6_addr, 16);
    Begin_root (a);
    res = caml_alloc_small(2, 1);
    Field(res, 0) = a;
    Field(res, 1) = Val_int(ntohs(sin6->sin6_port));
    End_roots();
    break;
  default:
    unix_error(EAFNOSUPPORT, "", Nothing);
  }

  return res;
}
开发者ID:haesbaert,项目名称:extunix,代码行数:42,代码来源:sendmsg.c


示例11: Val_cairo_font_extents

value
Val_cairo_font_extents (cairo_font_extents_t * s)
{
  value v = caml_alloc_small (5 * Double_wosize, Double_array_tag);
  Store_double_field (v, 0, s->ascent);
  Store_double_field (v, 1, s->descent);
  Store_double_field (v, 2, s->height);
  Store_double_field (v, 3, s->max_x_advance);
  Store_double_field (v, 4, s->max_y_advance);
  return v;
}
开发者ID:DMClambo,项目名称:pfff,代码行数:11,代码来源:ml_cairo.c


示例12: caml_raise_with_arg

void caml_raise_with_arg(value tag, value arg)
{
  CAMLparam2 (tag, arg);
  CAMLlocal1 (bucket);

  bucket = caml_alloc_small (2, 0);
  caml_initialize_field(bucket, 0, tag);
  caml_initialize_field(bucket, 1, arg);
  caml_raise(bucket);
  CAMLnoreturn;
}
开发者ID:dhil,项目名称:ocaml-multicore,代码行数:11,代码来源:fail.c


示例13: Val_rc

static inline value Val_rc(int rc)
{
  value v_res;
  if (rc >= 0) {
    if (rc <= 26) return Val_int(rc);
    if (rc == 100 || rc == 101) return Val_int(rc - 73);
  }
  v_res = caml_alloc_small(1, 0);
  Field(v_res, 0) = Val_int(rc);
  return v_res;
}
开发者ID:Moondee,项目名称:caut-lib,代码行数:11,代码来源:sqlite3_stubs.c


示例14: value_of_mouse_button

static value value_of_mouse_button(Uint8 b)
{
  value r;
  if (SDL_BUTTON_LEFT <= b && b <= SDL_BUTTON_WHEELDOWN)
    r = Val_int(b - 1);
  else {
    r = caml_alloc_small(1, 0);
    Field(r, 0) = Val_int(b);
  }
  return r;
}
开发者ID:Ninju,项目名称:OCamlSDL,代码行数:11,代码来源:sdlevent_stub.c


示例15: lightsource_create_lightsource

CAMLprim value lightsource_create_lightsource(value vector_position,
                                              value double_radius,
                                              value double_strength) {
  CAMLparam3(vector_position, double_radius, double_strength);
  CAMLlocal1(record_lightsource);
  record_lightsource = caml_alloc_small(3, 0);
  Field(record_lightsource, 0) = vector_position;
  Field(record_lightsource, 1) = double_radius;
  Field(record_lightsource, 2) = double_strength;
  CAMLreturn(record_lightsource);
}
开发者ID:SodaCookie,项目名称:amnesia-engine,代码行数:11,代码来源:lightsource.cpp


示例16: caml_sys_get_config

CAMLprim value caml_sys_get_config(value unit)
{
  CAMLparam0 ();   /* unit is unused */
  CAMLlocal2 (result, ostype);

  ostype = caml_copy_string(OCAML_OS_TYPE);
  result = caml_alloc_small (2, 0);
  Field(result, 0) = ostype;
  Field(result, 1) = Val_long (8 * sizeof(value));
  CAMLreturn (result);
}
开发者ID:blackswanburst,项目名称:mirage,代码行数:11,代码来源:sys.c


示例17: caml_sys_get_argv

CAMLprim value caml_sys_get_argv(value unit)
{
  CAMLparam0 ();   /* unit is unused */
  CAMLlocal3 (exe_name, argv, res);
  exe_name = caml_copy_string(caml_exe_name);
  argv = caml_copy_string_array((char const **) caml_main_argv);
  res = caml_alloc_small(2, 0);
  Field(res, 0) = exe_name;
  Field(res, 1) = argv;
  CAMLreturn(res);
}
开发者ID:jessicah,项目名称:snowflake-jocaml,代码行数:11,代码来源:sys.c


示例18: raise_internal_error

static inline void raise_internal_error(char *msg)
{
  CAMLparam0();
  CAMLlocal1(v_msg);
  value v_arg;
  v_msg = caml_copy_string(msg);
  v_arg = caml_alloc_small(1, 1);
  Field(v_arg, 0) = v_msg;
  raise_pcre_error(v_arg);
  CAMLnoreturn;
}
开发者ID:mmottl,项目名称:pcre-ocaml,代码行数:11,代码来源:pcre_stubs.c


示例19: pcre_get_match_limit_stub

/* Gets the match limit of a regular expression if it exists */
CAMLprim value pcre_get_match_limit_stub(value v_rex){
  pcre_extra *extra = (pcre_extra *) Field(v_rex, 2);
  if (extra == NULL) return None;
  if (extra->flags & PCRE_EXTRA_MATCH_LIMIT) {
    value lim = Val_int(extra->match_limit);
    value res = caml_alloc_small(1, 0);
    Field(res, 0) = lim;
    return res;
  }
  return None;
}
开发者ID:DMClambo,项目名称:pfff,代码行数:12,代码来源:pcre_stubs.c


示例20: expr_allocate

value expr_allocate()
{
#define wosize ( 2 + (sizeof(expr) + sizeof(value) - 1) / sizeof(value) )
  value ret;
  if( wosize < Max_young_wosize )
    ret = caml_alloc_small( wosize, Custom_tag );
  else
    ret = caml_alloc_shr( wosize, Custom_tag );
  Field( ret, 0 ) = (value)&expr_ops;
  return ret;
}
开发者ID:cjgillot,项目名称:mycas,代码行数:11,代码来源:expr_wrap.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ caml_alloc_string函数代码示例发布时间:2022-05-30
下一篇:
C++ caml_alloc_custom函数代码示例发布时间: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