本文整理汇总了C++中caml_named_value函数的典型用法代码示例。如果您正苦于以下问题:C++ caml_named_value函数的具体用法?C++ caml_named_value怎么用?C++ caml_named_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了caml_named_value函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ocaml_f0r_dlopen
CAMLprim value ocaml_f0r_dlopen(value fname)
{
CAMLparam1(fname);
CAMLlocal1(ans);
plugin_t *p = malloc(sizeof(plugin_t));
p->handle = dlopen(String_val(fname), RTLD_LAZY);
if (!p->handle) { free(p); caml_raise_constant(*caml_named_value("f0r_exn_not_a_plugin")); }
p->init = dlsym(p->handle, "f0r_init");
if (!p->init) { dlclose(p->handle); free(p); caml_raise_constant(*caml_named_value("f0r_exn_not_a_plugin")); }
p->deinit = dlsym(p->handle, "f0r_deinit");
if (!p->deinit) { dlclose(p->handle); free(p); caml_raise_constant(*caml_named_value("f0r_exn_not_a_plugin")); }
p->get_plugin_info = dlsym(p->handle, "f0r_get_plugin_info");
if (!p->get_plugin_info) { dlclose(p->handle); free(p); caml_raise_constant(*caml_named_value("f0r_exn_not_a_plugin")); }
p->get_param_info = dlsym(p->handle, "f0r_get_param_info");
if (!p->get_param_info) { dlclose(p->handle); free(p); caml_raise_constant(*caml_named_value("f0r_exn_not_a_plugin")); }
p->construct = dlsym(p->handle, "f0r_construct");
if (!p->construct) { dlclose(p->handle); free(p); caml_raise_constant(*caml_named_value("f0r_exn_not_a_plugin")); }
p->destruct = dlsym(p->handle, "f0r_destruct");
if (!p->destruct) { dlclose(p->handle); free(p); caml_raise_constant(*caml_named_value("f0r_exn_not_a_plugin")); }
p->get_param_value = dlsym(p->handle, "f0r_get_param_value");
if (!p->get_param_value) { dlclose(p->handle); free(p); caml_raise_constant(*caml_named_value("f0r_exn_not_a_plugin")); }
p->set_param_value = dlsym(p->handle, "f0r_set_param_value");
if (!p->set_param_value) { dlclose(p->handle); free(p); caml_raise_constant(*caml_named_value("f0r_exn_not_a_plugin")); }
p->update = dlsym(p->handle, "f0r_update");
p->update2 = dlsym(p->handle, "f0r_update2");
if (!p->update && !p->update2) { dlclose(p->handle); free(p); caml_raise_constant(*caml_named_value("f0r_exn_not_a_plugin")); }
p->init();
ans = caml_alloc_custom(&plugin_ops, sizeof(plugin_t*), 0, 1);
Plugin_val(ans) = p;
CAMLreturn(ans);
}
开发者ID:savonet,项目名称:ocaml-frei0r,代码行数:34,代码来源:frei0r_stubs.c
示例2: zompInitCamlCallbacks
void zompInitCamlCallbacks() {
isBoundCB = caml_named_value("isBound");
lookupCB = caml_named_value("lookup");
parseCB = caml_named_value("parse");
getCounterValueInt = caml_named_value("zompCommonGetCounterValueInt");
getCounterValueFloat = caml_named_value("zompCommonGetCounterValueFloat");
}
开发者ID:sheijk,项目名称:Zomp,代码行数:7,代码来源:zompvm_caml.cpp
示例3: on_state_change
static uint64 on_state_change (utp_callback_arguments *a)
{
CAMLparam0 ();
value *cb;
static value *on_connect_fun = NULL;
static value *on_writable_fun = NULL;
static value *on_eof_fun = NULL;
static value *on_close_fun = NULL;
if (on_connect_fun == NULL) on_connect_fun = caml_named_value ("utp_on_connect");
if (on_writable_fun == NULL) on_writable_fun = caml_named_value ("utp_on_writable");
if (on_eof_fun == NULL) on_eof_fun = caml_named_value ("utp_on_eof");
if (on_close_fun == NULL) on_close_fun = caml_named_value ("utp_on_close");
switch (a->state) {
case UTP_STATE_CONNECT:
cb = on_connect_fun;
break;
case UTP_STATE_WRITABLE:
cb = on_writable_fun;
break;
case UTP_STATE_EOF:
cb = on_eof_fun;
break;
case UTP_STATE_DESTROYING:
UTP_DEBUG ("destroying socket");
cb = on_close_fun;
break;
default:
UTP_DEBUG ("unknown state change: %d", a->state);
cb = NULL;
break;
}
if (cb) caml_callback (*cb, Val_utp_socket (a->socket));
CAMLreturn (0);
}
开发者ID:nojb,项目名称:ocaml-utp,代码行数:35,代码来源:utpstubs.c
示例4: ocaml_ssl_embed_socket
CAMLprim value ocaml_ssl_embed_socket(value socket_, value context)
{
CAMLparam1(context);
CAMLlocal1(block);
#ifdef Socket_val
SOCKET socket = Socket_val(socket_);
#else
int socket = Int_val(socket_);
#endif
SSL_CTX *ctx = Ctx_val(context);
SSL *ssl;
block = caml_alloc_custom(&socket_ops, sizeof(SSL*), 0, 1);
if (socket < 0)
caml_raise_constant(*caml_named_value("ssl_exn_invalid_socket"));
caml_enter_blocking_section();
ssl = SSL_new(ctx);
if (!ssl)
{
caml_leave_blocking_section();
caml_raise_constant(*caml_named_value("ssl_exn_handler_error"));
}
SSL_set_fd(ssl, socket);
caml_leave_blocking_section();
SSL_val(block) = ssl;
CAMLreturn(block);
}
开发者ID:marcolinoas,项目名称:libres3,代码行数:29,代码来源:ssl_stubs.c
示例5: ocaml_gstreamer_appsrc_push_buffer_data
CAMLprim value ocaml_gstreamer_appsrc_push_buffer_data(value _as, value _buf)
{
CAMLparam2(_as, _buf);
int buflen = Caml_ba_array_val(_buf)->dim[0];
appsrc *as = Appsrc_val(_as);
GstBuffer *gstbuf;
GstMapInfo map;
GstFlowReturn ret;
gboolean bret;
caml_release_runtime_system();
gstbuf = gst_buffer_new_and_alloc(buflen);
bret = gst_buffer_map(gstbuf, &map, GST_MAP_WRITE);
caml_acquire_runtime_system();
if(!bret) caml_raise_constant(*caml_named_value("gstreamer_exn_failure"));
memcpy(map.data, (unsigned char*)Caml_ba_data_val(_buf), buflen);
caml_release_runtime_system();
gst_buffer_unmap(gstbuf, &map);
ret = gst_app_src_push_buffer(as->appsrc, gstbuf);
caml_acquire_runtime_system();
if (ret != GST_FLOW_OK) caml_raise_constant(*caml_named_value("gstreamer_exn_failure"));
CAMLreturn(Val_unit);
}
开发者ID:gndl,项目名称:ocaml-gstreamer,代码行数:26,代码来源:gstreamer_stubs.c
示例6: ocaml_ssl_ctx_init_ec_from_named_curve
CAMLprim value ocaml_ssl_ctx_init_ec_from_named_curve(value context, value curve_name)
{
CAMLparam2(context, curve_name);
EC_KEY *ecdh = NULL;
int nid = 0;
SSL_CTX *ctx = Ctx_val(context);
char *ec_curve_name = String_val(curve_name);
if(*ec_curve_name == 0)
caml_raise_constant(*caml_named_value("ssl_exn_ec_curve_error"));
nid = OBJ_sn2nid(ec_curve_name);
if(nid == 0){
caml_raise_constant(*caml_named_value("ssl_exn_ec_curve_error"));
}
caml_enter_blocking_section();
ecdh = EC_KEY_new_by_curve_name(nid);
if(ecdh != NULL){
if(SSL_CTX_set_tmp_ecdh(ctx,ecdh) != 1){
caml_leave_blocking_section();
caml_raise_constant(*caml_named_value("ssl_exn_ec_curve_error"));
}
SSL_CTX_set_options(ctx, SSL_OP_SINGLE_ECDH_USE);
caml_leave_blocking_section();
EC_KEY_free(ecdh);
}
else{
caml_leave_blocking_section();
caml_raise_constant(*caml_named_value("ssl_exn_ec_curve_error"));
}
CAMLreturn(Val_unit);
}
开发者ID:marcolinoas,项目名称:libres3,代码行数:33,代码来源:ssl_stubs.c
示例7: ocaml_ssl_ctx_init_dh_from_file
CAMLprim value ocaml_ssl_ctx_init_dh_from_file(value context, value dh_file_path)
{
CAMLparam2(context, dh_file_path);
DH *dh = NULL;
SSL_CTX *ctx = Ctx_val(context);
char *dh_cfile_path = String_val(dh_file_path);
if(*dh_cfile_path == 0)
caml_raise_constant(*caml_named_value("ssl_exn_diffie_hellman_error"));
dh = load_dh_param(dh_cfile_path);
caml_enter_blocking_section();
if (dh != NULL){
if(SSL_CTX_set_tmp_dh(ctx,dh) != 1){
caml_leave_blocking_section();
caml_raise_constant(*caml_named_value("ssl_exn_diffie_hellman_error"));
}
SSL_CTX_set_options(ctx, SSL_OP_SINGLE_DH_USE);
caml_leave_blocking_section();
DH_free(dh);
}
else{
caml_leave_blocking_section();
caml_raise_constant(*caml_named_value("ssl_exn_diffie_hellman_error"));
}
CAMLreturn(Val_unit);
}
开发者ID:marcolinoas,项目名称:libres3,代码行数:27,代码来源:ssl_stubs.c
示例8: ocaml_ssl_ctx_use_certificate
CAMLprim value ocaml_ssl_ctx_use_certificate(value context, value cert, value privkey)
{
CAMLparam3(context, cert, privkey);
SSL_CTX *ctx = Ctx_val(context);
char *cert_name = String_val(cert);
char *privkey_name = String_val(privkey);
caml_enter_blocking_section();
if (SSL_CTX_use_certificate_chain_file(ctx, cert_name) <= 0)
{
caml_leave_blocking_section();
caml_raise_constant(*caml_named_value("ssl_exn_certificate_error"));
}
if (SSL_CTX_use_PrivateKey_file(ctx, privkey_name, SSL_FILETYPE_PEM) <= 0)
{
caml_leave_blocking_section();
caml_raise_constant(*caml_named_value("ssl_exn_private_key_error"));
}
if (!SSL_CTX_check_private_key(ctx))
{
caml_leave_blocking_section();
caml_raise_constant(*caml_named_value("ssl_exn_unmatching_keys"));
}
caml_leave_blocking_section();
CAMLreturn(Val_unit);
}
开发者ID:marcolinoas,项目名称:libres3,代码行数:27,代码来源:ssl_stubs.c
示例9: caml_sqlite3_init
CAMLprim value caml_sqlite3_init(value __unused v_unit)
{
caml_sqlite3_InternalError = caml_named_value("Sqlite3.InternalError");
caml_sqlite3_Error = caml_named_value("Sqlite3.Error");
caml_sqlite3_RangeError = caml_named_value("Sqlite3.RangeError");
return Val_unit;
}
开发者ID:Moondee,项目名称:caut-lib,代码行数:7,代码来源:sqlite3_stubs.c
示例10: PQocaml_init
CAMLprim value PQocaml_init(value __unused v_unit)
{
v_empty_string = caml_alloc_string(0);
caml_register_generational_global_root(&v_empty_string);
v_exc_Oid = caml_named_value("Postgresql.Oid");
v_null_param = caml_named_value("Postgresql.null");
return Val_unit;
}
开发者ID:Nevor,项目名称:postgresql-ocaml,代码行数:8,代码来源:postgresql_stubs.c
示例11: camltk_init
CAMLprim value camltk_init(value v)
{
/* Initialize the OCaml pointers */
if (tkerror_exn == NULL)
tkerror_exn = caml_named_value("tkerror");
if (handler_code == NULL)
handler_code = caml_named_value("camlcb");
return Val_unit;
}
开发者ID:Chris00,项目名称:ocaml,代码行数:9,代码来源:cltkCaml.c
示例12: caml_db_init
value caml_db_init(value v){
CAMLparam1(v);
if (caml_db_exn == NULL)
caml_db_exn = caml_named_value("dberror");
if (caml_key_exists_exn == NULL)
caml_key_exists_exn = caml_named_value("keyexists");
if (caml_db_run_recovery_exn == NULL)
caml_db_run_recovery_exn = caml_named_value("dbrunrecovery");
CAMLreturn (Val_unit);
}
开发者ID:jleinenbach,项目名称:GnuKS,代码行数:10,代码来源:bdb_stubs.c
示例13: ast_init
void ast_init(void) {
if (ast_inited) return;
ast_inited = 1;
ocaml_mk_ast_info = caml_named_value("mk_ast_info");
ocaml_print_ast_node = caml_named_value("print_ast_node");
ocaml_get_prim = caml_named_value("get_prim");
ocaml_mk_formal_args = caml_named_value("mk_formal_args");
ocaml_mk_actual_args = caml_named_value("mk_actual_args");
}
开发者ID:iskandr,项目名称:parakeet-retired,代码行数:11,代码来源:ast_stubs.c
示例14: ocaml_gstreamer_appsink_pull_buffer
CAMLprim value ocaml_gstreamer_appsink_pull_buffer(value _as, value string_mode)
{
CAMLparam1(_as);
CAMLlocal1(ans);
appsink *as = Appsink_val(_as);
GstSample *gstsample;
GstBuffer *gstbuf;
GstMapInfo map;
intnat len;
gboolean ret;
caml_release_runtime_system();
gstsample = gst_app_sink_pull_sample(as->appsink);
caml_acquire_runtime_system();
if (!gstsample)
{
if (gst_app_sink_is_eos(as->appsink))
caml_raise_constant(*caml_named_value("gstreamer_exn_eos"));
else
caml_raise_constant(*caml_named_value("gstreamer_exn_failure"));
}
caml_release_runtime_system();
gstbuf = gst_sample_get_buffer(gstsample);
caml_acquire_runtime_system();
if (!gstbuf) caml_raise_constant(*caml_named_value("gstreamer_exn_failure"));
caml_release_runtime_system();
ret = gst_buffer_map(gstbuf, &map, GST_MAP_READ);
caml_acquire_runtime_system();
if (!ret) caml_raise_constant(*caml_named_value("gstreamer_exn_failure"));
len = map.size;
if (string_mode == Val_false) {
ans = caml_ba_alloc(CAML_BA_C_LAYOUT | CAML_BA_UINT8, 1, NULL, &len);
memcpy(Caml_ba_data_val(ans), map.data, len);
} else {
ans = caml_alloc_string(len);
memcpy(String_val(ans), map.data, len);
}
caml_release_runtime_system();
gst_buffer_unmap(gstbuf, &map);
gst_sample_unref(gstsample);
caml_acquire_runtime_system();
CAMLreturn(ans);
}
开发者ID:gndl,项目名称:ocaml-gstreamer,代码行数:51,代码来源:gstreamer_stubs.c
示例15: caml_bjack_read
CAMLprim value caml_bjack_read(value device, value len)
{
CAMLparam2(device,len);
CAMLlocal1(ans);
int n = Int_val(len) ;
char* buf = malloc(n) ;
jack_driver_t* drv = Bjack_drv_val(device);
long ret;
if (drv->num_input_channels > 0)
{
caml_enter_blocking_section();
ret = JACK_Read(drv,(unsigned char *)buf,n);
caml_leave_blocking_section();
}
else
{
caml_raise_constant(*caml_named_value("bio2jack_exn_too_many_input_channels"));
}
if (ret < 0) caml_failwith("jack_read");
ans = caml_alloc_string(ret);
memcpy(String_val(ans),buf,ret);
free(buf);
CAMLreturn(ans);
}
开发者ID:savonet,项目名称:ocaml-bjack,代码行数:28,代码来源:jack_stubs.c
示例16: caml_bjack_write
CAMLprim value caml_bjack_write(value device, value data)
{
CAMLparam2(device,data);
int n = caml_string_length(data) ;
jack_driver_t* drv = Bjack_drv_val(device);
long ret;
char* buf = malloc(n) ;
memcpy(buf,String_val(data),n);
if (drv->num_output_channels > 0)
{
caml_enter_blocking_section();
ret = JACK_Write(drv,(unsigned char *)buf,n);
caml_leave_blocking_section();
}
else
{
caml_raise_constant(*caml_named_value("bio2jack_exn_too_many_output_channels"));
}
if (ret < 0) caml_failwith("jack_write");
free(buf);
CAMLreturn(Val_long(ret));
}
开发者ID:savonet,项目名称:ocaml-bjack,代码行数:26,代码来源:jack_stubs.c
示例17: pcre_ocaml_init
/* Fetchs the named OCaml-values + caches them and
calculates + caches the variant hash values */
CAMLprim value pcre_ocaml_init(value __unused v_unit)
{
pcre_exc_Error = caml_named_value("Pcre.Error");
pcre_exc_Backtrack = caml_named_value("Pcre.Backtrack");
var_Start_only = caml_hash_variant("Start_only");
var_ANCHORED = caml_hash_variant("ANCHORED");
var_Char = caml_hash_variant("Char");
var_Not_studied = caml_hash_variant("Not_studied");
var_Studied = caml_hash_variant("Studied");
var_Optimal = caml_hash_variant("Optimal");
pcre_callout = &pcre_callout_handler;
return Val_unit;
}
开发者ID:mmottl,项目名称:pcre-ocaml,代码行数:18,代码来源:pcre_stubs.c
示例18: caml_mdb_cursor_get
CAMLprim value caml_mdb_cursor_get(value curs,value key,value data,value op){
CAMLparam4(curs,key,data,op);
CAMLlocal3(result,mlkey,mldata);
MDB_val key_,data_;
key_.mv_data=String_val(key);
key_.mv_size=caml_string_length(key);
data_.mv_data=String_val(data);
data_.mv_size=caml_string_length(data);
int ret;
if((ret=mdb_cursor_get( (MDB_cursor*)curs, &key_, &data_, Int_val(op) ))){
if(ret==MDB_NOTFOUND) {
static value *exn=NULL;
if(exn==NULL) exn=caml_named_value("lmdb_not_found");
caml_raise_constant(*exn);
} else
caml_failwith("error in mdb_cursor_get");
}
mlkey=caml_alloc_string(key_.mv_size);
memcpy(String_val(mlkey),key_.mv_data,key_.mv_size);
mldata=caml_alloc_string(data_.mv_size);
memcpy(String_val(mldata),data_.mv_data,data_.mv_size);
result=caml_alloc(2,0);
Store_field(result,0,mlkey);
Store_field(result,1,mldata);
CAMLreturn(result);
}
开发者ID:8l,项目名称:pijul,代码行数:27,代码来源:lmdb_stubs.c
示例19: caml_minor_collection
/* Do a minor collection and a slice of major collection, call finalisation
functions, etc.
Leave the minor heap empty.
*/
CAMLexport void caml_minor_collection (void)
{
value *note_gc;
uint64_t start_time;
note_gc = caml_named_value("MProf.Trace.note_gc");
if (note_gc)
start_time = NOW();
intnat prev_alloc_words = caml_allocated_words;
caml_empty_minor_heap ();
caml_stat_promoted_words += caml_allocated_words - prev_alloc_words;
++ caml_stat_minor_collections;
caml_major_collection_slice (0);
caml_force_major_slice = 0;
caml_final_do_calls ();
if (note_gc){
double duration_ns = (double) (NOW () - start_time);
value result = caml_callback_exn(*note_gc, caml_copy_double(duration_ns / 1000000000));
if (Is_exception_result(result))
printk("warning: note_gc threw an exception!\n");
}
caml_empty_minor_heap ();
}
开发者ID:avsm,项目名称:mirage-platform,代码行数:33,代码来源:minor_gc.c
示例20: wrapper_bdd_allsat
CAMLprim value wrapper_bdd_allsat(value r) {
CAMLparam1(r);
BDD bdd = BDD_val(r);
value* f = caml_named_value("__allsat_handler");
void handler(char* varset, int size) {
CAMLlocal2(tl,v);
int i = 0;
tl = Val_emptylist;
//printf("size : %d\n", size);
for (i = 0 ; i < size; i++) {
//printf("%d : %d\n", i, varset[i]);
// variants in ocaml range from 0 to n-1 !!!
switch (varset[i]) {
case 0 :
v = Val_int(0);
break; // False
case 1 :
v = Val_int(1);
break; // True
case -1 :
v = Val_int(2);
break; // Unknown
default :
caml_failwith("Unknown variable value");
break;
}
if (varset[i] != -1) {
tl = append(tuple(Val_int(i),v),tl);
}
}
caml_callback(*f,tl);
CAMLreturn0;
}
开发者ID:aziem,项目名称:ocaml-buddy,代码行数:33,代码来源:libbuddy_stubs.c
注:本文中的caml_named_value函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论