本文整理汇总了C++中Bool_val函数的典型用法代码示例。如果您正苦于以下问题:C++ Bool_val函数的具体用法?C++ Bool_val怎么用?C++ Bool_val使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Bool_val函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: domain_build_info_val
static int domain_build_info_val (caml_gc *gc, libxl_domain_build_info *c_val, value v)
{
CAMLparam1(v);
CAMLlocal1(infopriv);
c_val->max_vcpus = Int_val(Field(v, 0));
c_val->cur_vcpus = Int_val(Field(v, 1));
c_val->max_memkb = Int64_val(Field(v, 2));
c_val->target_memkb = Int64_val(Field(v, 3));
c_val->video_memkb = Int64_val(Field(v, 4));
c_val->shadow_memkb = Int64_val(Field(v, 5));
c_val->kernel.path = dup_String_val(gc, Field(v, 6));
c_val->is_hvm = Tag_val(Field(v, 7)) == 0;
infopriv = Field(Field(v, 7), 0);
if (c_val->hvm) {
c_val->u.hvm.pae = Bool_val(Field(infopriv, 0));
c_val->u.hvm.apic = Bool_val(Field(infopriv, 1));
c_val->u.hvm.acpi = Bool_val(Field(infopriv, 2));
c_val->u.hvm.nx = Bool_val(Field(infopriv, 3));
c_val->u.hvm.viridian = Bool_val(Field(infopriv, 4));
c_val->u.hvm.timeoffset = dup_String_val(gc, Field(infopriv, 5));
c_val->u.hvm.timer_mode = Int_val(Field(infopriv, 6));
c_val->u.hvm.hpet = Int_val(Field(infopriv, 7));
c_val->u.hvm.vpt_align = Int_val(Field(infopriv, 8));
} else {
c_val->u.pv.slack_memkb = Int64_val(Field(infopriv, 0));
c_val->u.pv.cmdline = dup_String_val(gc, Field(infopriv, 1));
c_val->u.pv.ramdisk.path = dup_String_val(gc, Field(infopriv, 2));
c_val->u.pv.features = dup_String_val(gc, Field(infopriv, 3));
}
CAMLreturn(0);
}
示例2: ocaml_guestfs_create
/* Guestfs.create */
value
ocaml_guestfs_create (value environmentv, value close_on_exitv, value unitv)
{
CAMLparam3 (environmentv, close_on_exitv, unitv);
CAMLlocal1 (gv);
unsigned flags = 0;
guestfs_h *g;
if (environmentv != Val_int (0) &&
!Bool_val (Field (environmentv, 0)))
flags |= GUESTFS_CREATE_NO_ENVIRONMENT;
if (close_on_exitv != Val_int (0) &&
!Bool_val (Field (close_on_exitv, 0)))
flags |= GUESTFS_CREATE_NO_CLOSE_ON_EXIT;
g = guestfs_create_flags (flags);
if (g == NULL)
caml_failwith ("failed to create guestfs handle");
guestfs_set_error_handler (g, NULL, NULL);
gv = Val_guestfs (g);
CAMLreturn (gv);
}
示例3: device_pci_val
static int device_pci_val(caml_gc *gc, libxl_device_pci *c_val, value v)
{
union {
unsigned int value;
struct {
unsigned int reserved1:2;
unsigned int reg:6;
unsigned int func:3;
unsigned int dev:5;
unsigned int bus:8;
unsigned int reserved2:7;
unsigned int enable:1;
}fields;
}u;
CAMLparam1(v);
/* FIXME: propagate API change to ocaml */
u.value = Int_val(Field(v, 0));
c_val->reg = u.fields.reg;
c_val->func = u.fields.func;
c_val->dev = u.fields.dev;
c_val->bus = u.fields.bus;
c_val->enable = u.fields.enable;
c_val->domain = Int_val(Field(v, 1));
c_val->vdevfn = Int_val(Field(v, 2));
c_val->msitranslate = Bool_val(Field(v, 3));
c_val->power_mgmt = Bool_val(Field(v, 4));
CAMLreturn(0);
}
示例4: start_interp
value start_interp(value may_free, value prog, value offset, value vlen) /* ML */
{
bytecode_t bprog = (bytecode_t)&Byte(prog, Long_val(offset)); // In ML heap
int len = Long_val(vlen);
value res;
#if defined(MOSML_BIG_ENDIAN) && !defined(ALIGNMENT)
fixup_endianness(&Byte(prog, 0), (asize_t) len);
#endif
#if defined(DIRECT_JUMP) && defined(THREADED)
{
realcode_t generated_code;
res = interprete(/* mode=byte exec */ 1, bprog, len, &generated_code);
if (Bool_val(may_free)) {
// printf("start_interp freeing: generated_code=%d, len=%d\n",
// (int)*generated_code, len);
free(generated_code); // Allocated by the call to interprete()
}
}
#else
{
// Copy bytecode to memory outside the ML heap
bytecode_t actualprog = (bytecode_t)malloc(len);
bcopy(bprog, actualprog, len);
res = interprete(/* mode=byte exec */ 1, actualprog, len, NULL);
if (Bool_val(may_free))
free(actualprog); // Allocated above
}
#endif
return res;
}
示例5: 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);
}
示例6: Elm_Actionslider_Pos_vals
PREFIX Elm_Actionslider_Pos Elm_Actionslider_Pos_vals(
value v_left, value v_center, value v_right)
{
Elm_Actionslider_Pos pos = 0;
if(Bool_val(v_left)) pos = pos | ELM_ACTIONSLIDER_LEFT;
if(Bool_val(v_center)) pos = pos | ELM_ACTIONSLIDER_CENTER;
if(Bool_val(v_right)) pos = pos | ELM_ACTIONSLIDER_RIGHT;
return pos;
}
示例7: getFileInfos
CAMLprim value getFileInfos (value path, value need_size) {
#ifdef __APPLE__
CAMLparam1(path);
CAMLlocal3(res, fInfo, length);
int retcode;
struct attrlist attrList;
unsigned long options = FSOPT_REPORT_FULLSIZE;
struct {
u_int32_t length;
char finderInfo [32];
off_t rsrcLength;
} __attribute__ ((packed)) attrBuf;
attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
attrList.reserved = 0;
attrList.commonattr = ATTR_CMN_FNDRINFO;
attrList.volattr = 0; /* volume attribute group */
attrList.dirattr = 0; /* directory attribute group */
if (Bool_val (need_size))
attrList.fileattr = ATTR_FILE_RSRCLENGTH; /* file attribute group */
else
attrList.fileattr = 0;
attrList.forkattr = 0; /* fork attribute group */
retcode = getattrlist(String_val (path), &attrList, &attrBuf,
sizeof attrBuf, options);
if (retcode == -1) uerror("getattrlist", path);
if (Bool_val (need_size)) {
if (attrBuf.length != sizeof attrBuf)
unix_error (EINVAL, "getattrlist", path);
} else {
if (attrBuf.length != sizeof (u_int32_t) + 32)
unix_error (EINVAL, "getattrlist", path);
}
fInfo = alloc_string (32);
memcpy (String_val (fInfo), attrBuf.finderInfo, 32);
if (Bool_val (need_size))
length = copy_int64 (attrBuf.rsrcLength);
else
length = copy_int64 (0);
res = alloc_small (2, 0);
Field (res, 0) = fInfo;
Field (res, 1) = length;
CAMLreturn (res);
#else
unix_error (ENOSYS, "getattrlist", path);
#endif
}
示例8: lsolver_translate_exception
static int lsolver_translate_exception(value vexn)
{
CAMLparam1(vexn);
CAMLlocal1(vtag);
int r;
vtag = Field(vexn, 0);
if (vtag == SUNDIALS_EXN_TAG(RecoverableFailure)) {
r = 100;
} else if (vtag == LSOLVER_EXN_TAG(ATimesFailure)) {
r = Bool_val(Field(vexn, 1)) ? SUNLS_ATIMES_FAIL_REC
: SUNLS_ATIMES_FAIL_UNREC;
} else if (vtag == LSOLVER_EXN_TAG(PSetFailure)) {
r = Bool_val(Field(vexn, 1)) ? SUNLS_PSET_FAIL_REC
: SUNLS_PSET_FAIL_UNREC;
} else if (vtag == LSOLVER_EXN_TAG(PSolveFailure)) {
r = Bool_val(Field(vexn, 1)) ? SUNLS_PSOLVE_FAIL_UNREC
: SUNLS_PSOLVE_FAIL_REC;
} else if (vtag == LSOLVER_EXN_TAG(GSFailure)) {
r = SUNLS_GS_FAIL;
} else if (vtag == LSOLVER_EXN_TAG(QRSolFailure)) {
r = SUNLS_QRSOL_FAIL;
} else if (vtag == LSOLVER_EXN_TAG(ResReduced)) {
r = SUNLS_RES_REDUCED;
} else if (vtag == LSOLVER_EXN_TAG(ConvFailure)) {
r = SUNLS_CONV_FAIL;
} else if (vtag == LSOLVER_EXN_TAG(QRfactFailure)) {
r = SUNLS_QRFACT_FAIL;
} else if (vtag == LSOLVER_EXN_TAG(LUfactFailure)) {
r = SUNLS_LUFACT_FAIL;
} else if (vtag == LSOLVER_EXN_TAG(PackageFailure)) {
r = Bool_val(Field(vexn, 1)) ? SUNLS_PACKAGE_FAIL_REC
: SUNLS_PACKAGE_FAIL_UNREC;
} else if (vtag == LSOLVER_EXN_TAG(InvalidArgument)) {
r = SUNLS_ILL_INPUT;
} else {
r = -100;
}
CAMLreturnT(int, r);
}
示例9: ml_IGUIContextMenu_addItem_native
extern "C" CAMLprim value ml_IGUIContextMenu_addItem_native(
value v_cm, value v_text, value v_cmd_id, value v_enabled,
value v_has_submenu, value v_checked, value v_auto_checking) {
int text_size = caml_string_length(v_text);
IGUIContextMenu* cm = (IGUIContextMenu*) v_cm;
wchar_t text[text_size + 1];
u32 idx;
mbstowcs(text, String_val(v_text), text_size);
idx = cm->addItem(text, Bool_val(v_enabled), Bool_val(v_has_submenu),
Bool_val(v_checked), Bool_val(v_auto_checking));
return Val_int(idx);
}
示例10: ocaml_ssl_set_mode
CAMLprim value ocaml_ssl_set_mode(value socket, value mode)
{
CAMLparam2(socket,mode);
long m;
ssl_socket_t *ssl = ssl_socket_of_block(socket);
m = 0;
if (Bool_val(Field(mode, 0))) m |= SSL_MODE_ENABLE_PARTIAL_WRITE;
if (Bool_val(Field(mode, 1))) m |= SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER;
if (Bool_val(Field(mode, 2))) m |= SSL_MODE_AUTO_RETRY;
SSL_set_mode(ssl->handler, m);
CAMLreturn(Val_unit);
}
示例11: ml_IGUIEnvironment_addStaticText_native
extern "C" CAMLprim value ml_IGUIEnvironment_addStaticText_native(
value v_env, value v_text, value v_rect, value v_border, value v_word_warp,
value v_parent, value v_id, value v_fill_bg)
{
IGUIElement* parent;
if(v_parent == Val_int(0)) parent = NULL;
else parent = (IGUIElement*) Field(v_parent, 0);
int text_size = strlen(String_val(v_text));
wchar_t text[text_size + 1];
mbstowcs(text, String_val(v_text), text_size + 1);
return (value) ((IGUIEnvironment*) v_env)->addStaticText(text,
Rect_s32_val(v_rect), Bool_val(v_border), Bool_val(v_word_warp), parent,
Int_val(v_id), Bool_val(v_fill_bg));
}
示例12: device_disk_val
static int device_disk_val(caml_gc *gc, libxl_device_disk *c_val, value v)
{
CAMLparam1(v);
c_val->backend_domid = Int_val(Field(v, 0));
c_val->pdev_path = dup_String_val(gc, Field(v, 1));
c_val->vdev = dup_String_val(gc, Field(v, 2));
c_val->backend = (Int_val(Field(v, 3)));
c_val->format = (Int_val(Field(v, 4)));
c_val->unpluggable = Bool_val(Field(v, 5));
c_val->readwrite = Bool_val(Field(v, 6));
c_val->is_cdrom = Bool_val(Field(v, 7));
CAMLreturn(0);
}
示例13: pattern_font_sort
CAMLprim value pattern_font_sort(value plist, value trim)
{
CAMLparam0();
CAMLlocal2(res, nres);
FcPattern *pat;
FcFontSet *match;
FcResult result;
int i;
pat = FcPattern_val(plist);
FcConfigSubstitute(NULL, pat, FcMatchPattern);
FcDefaultSubstitute(pat);
match = FcFontSort(NULL, pat, Bool_val(trim) ? FcTrue : FcFalse, NULL, &result);
/* Reconstruire la belle liste */
res = Val_int(0); /* empty list */
for(i = match->nfont; i >= 0; i--) {
nres = caml_alloc(2, 0);
Store_field(nres, 0, caml_copy_pattern(match->fonts[i]));
Store_field(nres, 1, res);
res = nres;
}
FcFontSetDestroy(match);
FcPatternDestroy(pat);
CAMLreturn(res);
}
示例14: ml_skin_init
CAMLprim value ml_skin_init (value use_vbo_v, value geom_v)
{
CAMLparam2 (use_vbo_v, geom_v);
CAMLlocal5 (vertexa_v, normala_v, uva_v, skin_v, colors_v);
State *s = &glob_state;
use_vbo = Bool_val (use_vbo_v);
#ifdef _WIN32
if (use_vbo) {
GETPA (BindBuffer);
GETPA (GenBuffers);
GETPA (BufferData);
GETPA (BufferSubData);
GETPA (MapBuffer);
GETPA (UnmapBuffer);
}
#endif
vertexa_v = Field (geom_v, 0);
normala_v = Field (geom_v, 1);
uva_v = Field (geom_v, 2);
skin_v = Field (geom_v, 3);
colors_v = Field (geom_v, 4);
skin_init (s, vertexa_v, normala_v, uva_v, skin_v, colors_v);
CAMLreturn (Val_unit);
}
示例15: caml_sqlite3_enable_load_extension
CAMLprim value caml_sqlite3_enable_load_extension(value v_db, value v_onoff)
{
int ret;
db_wrap *dbw = Sqlite3_val(v_db);
ret = sqlite3_enable_load_extension(dbw->db, Bool_val(v_onoff));
return Val_bool(ret);
}