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

C++ rb_rescue函数代码示例

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

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



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

示例1: executeOnConnectionImmediate

/**
 * This function provides the execute_immediate method for the Connection class.
 *
 * @param  self  A reference to the connection object to perform the execution
 *               through.
 * @param  sql   A reference to the SQL statement to be executed.
 *
 * @return  Always returns nil.
 *
 */
static VALUE executeOnConnectionImmediate(VALUE self, VALUE sql) {
  VALUE transaction = rb_transaction_new(self),
        set         = Qnil,
        results     = Qnil,
        array       = rb_ary_new(),
        dialect     = INT2FIX(3),
        statement   = rb_statement_new(self, transaction, sql, dialect);

  rb_ary_push(array, self);
  rb_ary_push(array, transaction);
  rb_ary_push(array, sql);
  rb_ary_push(array, statement);

  set = rb_rescue(executeBlock, array, executeRescue, array);
  if(set != Qnil) {
    if(TYPE(set) == T_DATA &&
       RDATA(set)->dfree == (RUBY_DATA_FUNC)resultSetFree) {
      rb_assign_transaction(set, transaction);
      if(rb_block_given_p()) {
        results = rb_rescue(executeImmediateBlock, set,
                            executeImmediateRescue, set);
      } else {
        results = set;
      }
    } else {
      rb_funcall(transaction, rb_intern("commit"), 0);
      results = set;
    }
  } else {
    rb_funcall(transaction, rb_intern("commit"), 0);
  }

  return(results);
}
开发者ID:pilcrow,项目名称:rubyfb,代码行数:44,代码来源:Connection.c


示例2: grpc_rb_call_credentials_callback_with_gil

static void grpc_rb_call_credentials_callback_with_gil(void* param) {
  callback_params* const params = (callback_params*)param;
  VALUE auth_uri = rb_str_new_cstr(params->context.service_url);
  /* Pass the arguments to the proc in a hash, which currently only has they key
     'auth_uri' */
  VALUE callback_args = rb_ary_new();
  VALUE args = rb_hash_new();
  VALUE result;
  grpc_metadata_array md_ary;
  grpc_status_code status;
  VALUE details;
  char* error_details;
  grpc_metadata_array_init(&md_ary);
  rb_hash_aset(args, ID2SYM(rb_intern("jwt_aud_uri")), auth_uri);
  rb_ary_push(callback_args, params->get_metadata);
  rb_ary_push(callback_args, args);
  result = rb_rescue(grpc_rb_call_credentials_callback, callback_args,
                     grpc_rb_call_credentials_callback_rescue, Qnil);
  // Both callbacks return a hash, so result should be a hash
  grpc_rb_md_ary_convert(rb_hash_aref(result, rb_str_new2("metadata")),
                         &md_ary);
  status = NUM2INT(rb_hash_aref(result, rb_str_new2("status")));
  details = rb_hash_aref(result, rb_str_new2("details"));
  error_details = StringValueCStr(details);
  params->callback(params->user_data, md_ary.metadata, md_ary.count, status,
                   error_details);
  grpc_rb_metadata_array_destroy_including_entries(&md_ary);
  gpr_free(params);
}
开发者ID:CCNITSilchar,项目名称:grpc,代码行数:29,代码来源:rb_call_credentials.c


示例3: rm_str_to_pct

/*
 *  Extern:     rm_str_to_pct
 *  Purpose:    Given a string in the form NN% return the corresponding double.
 *
*/
double
rm_str_to_pct(VALUE str)
{
    long pct;
    char *pct_str, *end;

    str = rb_rescue(rb_str_to_str, str, rescue_not_str, str);
    pct_str = StringValuePtr(str);
    errno = 0;
    pct = strtol(pct_str, &end, 10);

    if (errno == ERANGE)
    {
        rb_raise(rb_eRangeError, "`%s' out of range", pct_str);
    }
    if (*end != '%')
    {
        rb_raise(rb_eArgError, "expected percentage, got `%s'", pct_str);
    }
    if (pct < 0L)
    {
        rb_raise(rb_eArgError, "percentages may not be negative (got `%s')", pct_str);
    }

    return pct / 100.0;
}
开发者ID:r-project,项目名称:BS,代码行数:31,代码来源:rmutil.c


示例4: flags_compare

static gint
flags_compare(VALUE self, VALUE rhs)
{
    flags_holder* p = flags_get_holder(self);
    compare_data data;

    data.gtype = G_TYPE_FROM_CLASS(p->gclass);
    data.rb_value = rhs;
    data.value = 0;
    data.compatible = TRUE;

    rb_rescue(flags_compare_get_flags_body, (VALUE)&data,
              flags_compare_get_flags_rescue, (VALUE)&data);
    if (!data.compatible) {
        return FLAGS_COMP_INCOMPARABLE;
    }

    if (p->value == data.value)
        return FLAGS_COMP_EQUAL;
    else if ((p->value & data.value) == data.value)
        return FLAGS_COMP_GREATER;
    else if ((p->value & data.value) == p->value)
        return FLAGS_COMP_LESS;
    else
        return FLAGS_COMP_ELSE;
}
开发者ID:adamhooper,项目名称:ruby-gnome2,代码行数:26,代码来源:rbgobj_flags.c


示例5: io_write_callback

int io_write_callback(void * ctx, char * buffer, int len) {
    VALUE args[2];

    args[0] = (VALUE)ctx;
    args[1] = rb_str_new(buffer, (long)len);

    rb_rescue(write_check, (VALUE)args, write_failed, 0);
    return len;
}
开发者ID:sshic,项目名称:nokogiri,代码行数:9,代码来源:xml_io.c


示例6: define_function_rb

static bool define_function_rb(language_interpreter_t*li, const char*script)
{
    ruby_dfunc_t dfunc;
    dfunc.li = li;
    dfunc.script = script;
    dfunc.fail = false;
    VALUE ret = rb_rescue(define_function_internal, (VALUE)&dfunc, define_function_exception, (VALUE)&dfunc);
    return !dfunc.fail;
}
开发者ID:JackieXie168,项目名称:mrscake,代码行数:9,代码来源:language_rb.c


示例7: rb_block_arg_dispatcher

static void
rb_block_arg_dispatcher(rb_vm_block_t *block, VALUE param)
{
    assert(block != NULL);
    VALUE args[2];
    args[0] = (VALUE)block;
    args[1] = param;
    rb_rescue(rb_block_arg_eval, (VALUE) args, rb_block_rescue, (VALUE)"gcd.c: Exception in rb_block_arg_dispatcher");
}
开发者ID:JosephKu,项目名称:MacRuby,代码行数:9,代码来源:gcd.c


示例8: startConnectionTransaction

/**
 * This function provides the start_transaction method for the Database class.
 *
 * @param  self  A reference to the Database object to start the transaction
 *               on.
 *
 * @return  A reference to a Transaction object or nil if a problem occurs.
 *
 */
static VALUE startConnectionTransaction(VALUE self) {
  VALUE result = rb_transaction_new(self);

  if(rb_block_given_p()) {
    result = rb_rescue(startTransactionBlock, result,
                       startTransactionRescue, result);
  }

  return(result);
}
开发者ID:georgiev,项目名称:rubyfb,代码行数:19,代码来源:Connection.c


示例9: rg_set

static VALUE
rg_set(VALUE self, VALUE targets)
{
    struct clipboard_set_args args = { self, targets, rb_block_proc() };

    G_CHILD_ADD(self, args.func);

    return rb_rescue(clipboard_set_body, (VALUE)&args,
                     clipboard_set_rescue, (VALUE)&args);
}
开发者ID:msakai,项目名称:ruby-gnome2,代码行数:10,代码来源:rbgtkclipboard.c


示例10: cmp_equal

static VALUE
cmp_equal(VALUE x, VALUE y)
{
    VALUE a[2];

    if (x == y) return Qtrue;

    a[0] = x; a[1] = y;
    return rb_rescue(cmp_eq, (VALUE)a, cmp_failed, 0);
}
开发者ID:brightbox,项目名称:deb-ruby1.9.1,代码行数:10,代码来源:compar.c


示例11: cb_encode_value

    VALUE
cb_encode_value(VALUE val, uint32_t flags)
{
    VALUE blob, args[2];

    args[0] = val;
    args[1] = (VALUE)flags;
    blob = rb_rescue(do_encode, (VALUE)args, coding_failed, 0);
    return blob; /* bytestring or exception object */
}
开发者ID:dr-strangecode,项目名称:couchbase-ruby-client,代码行数:10,代码来源:utils.c


示例12: _equal

/*
 * call-seq:
 *   == image -> bool
 *
 * compares two image.
 *
 *
 */
DLL_LOCAL VALUE _equal(VALUE self, VALUE other)
{
	equal_obj obj;
	obj.self = _self;
	obj.other = other;

	return rb_rescue(
		RUBY_METHOD_FUNC(_equal_block),(VALUE)&obj,
		RUBY_METHOD_FUNC(_equal_rescue),Qnil
	);
}
开发者ID:Hanmac,项目名称:rwx,代码行数:19,代码来源:wxImage.cpp


示例13: rbg_rval2gslist

GSList *
rbg_rval2gslist(VALUE rb_array)
{
    struct rval2gslist_args args;
    args.list = NULL;
    args.rb_array = rb_array;

    rb_rescue(rval2gslist_body, (VALUE)&args,
              rval2gslist_rescue, (VALUE)&args);

    return args.list;
}
开发者ID:adamhooper,项目名称:ruby-gnome2,代码行数:12,代码来源:rbgutil_list.c


示例14: event_callback_wrapper

static void event_callback_wrapper (const unsigned long signature, int event, const char *data_str, const unsigned long data_num)
{
    struct em_event e;
    e.signature = signature;
    e.event = event;
    e.data_str = data_str;
    e.data_num = data_num;

    if (!rb_ivar_defined(EmModule, Intern_at_error_handler))
        event_callback(&e);
    else
        rb_rescue((VALUE (*)(ANYARGS))event_callback, (VALUE)&e, (VALUE (*)(ANYARGS))event_error_handler, Qnil);
}
开发者ID:MitulMistry,项目名称:sinatra-sessions-v-000,代码行数:13,代码来源:rubymain.cpp


示例15: event_callback_wrapper

static void event_callback_wrapper (const unsigned long a1, int a2, const char *a3, const unsigned long a4)
{
	struct em_event e;
	e.a1 = a1;
	e.a2 = a2;
	e.a3 = a3;
	e.a4 = a4;

	if (!rb_ivar_defined(EmModule, Intern_at_error_handler))
		event_callback(&e);
	else
		rb_rescue((VALUE (*)(ANYARGS))event_callback, (VALUE)&e, (VALUE (*)(ANYARGS))event_error_handler, Qnil);
}
开发者ID:bernd,项目名称:eventmachine,代码行数:13,代码来源:rubymain.cpp


示例16: rb_lapack_determinant

VALUE rb_lapack_determinant(VALUE self)
{
  Matrix *m;
  VALUE copy;
  //char error_msg[64];
  int i;
  float result_c[2];
  double result_z[2];
  float r_tmp[2];
  double d_tmp[2];
  
  Data_Get_Struct(self, Matrix, m);
  if(m->nrows != m->ncols)
  { //sprintf(error_msg, "Matrix not square");
    rb_raise(rb_eRuntimeError, "Matrix not square");
  }
  
  if(m->matrix_type != LU)
  {
    copy = rb_rescue( rb_getrf_mod_helper, self, rb_lapack_getrf_rescue, Qnil);
    if(copy == Qnil)
      return INT2FIX(0); //any error, we return a determinant of 0
    Data_Get_Struct(copy, Matrix, m);
  }
  
  switch(m->data_type)
  {
  case Single_t: 
    result_c[0] = (float) 1.0;
    for(i=0; i < m->nrows; i++) 
    { rb_blas_get_member(r_tmp, m, i, i);
      result_c[0] *= r_tmp[0];
    }  
    return rb_float_new(result_c[0]);
  case Double_t:
    result_z[0] = 1.0;
    for(i=0; i < m->nrows; i++) 
    { rb_blas_get_member(d_tmp, m, i, i);
      result_z[0] *= d_tmp[0];
    }  
    return rb_float_new(result_z[0]);

  case Complex_t:
  case Double_Complex_t:
    //sprintf(error_msg, "Complex yet to be implemented");
    rb_raise(rb_eRuntimeError, "Complex yet to be implemented");
    break;

  }
    
}
开发者ID:rbur004,项目名称:ratlas,代码行数:51,代码来源:rb_lapack_determinant.c


示例17: rm_percentage

/*
 *  Extern:     rm_percentage(obj)
 *  Purpose:    Return a double between 0.0 and 1.0, inclusive.
 *              If the argument is a number convert to a Float object,
 *              otherwise it's supposed to be a string in the form "NN%".
 *              Convert to a number and then to a Float.
*/
double
rm_percentage(VALUE arg)
{
    double pct;
    long pct_long;
    char *pct_str, *end;
    int not_num;

    // Try to convert the argument to a number. If failure, sets not_num to non-zero.
    (void) rb_protect(arg_is_number, arg, &not_num);

    if (not_num)
    {
        arg = rb_rescue(rb_str_to_str, arg, rescue_not_str, arg);
        pct_str = StringValuePtr(arg);
        errno = 0;
        pct_long = strtol(pct_str, &end, 10);
        if (errno == ERANGE)
        {
            rb_raise(rb_eRangeError, "`%s' out of range", pct_str);
        }
        if (*end != '\0' && *end != '%')
        {
            rb_raise(rb_eArgError, "expected percentage, got `%s'", pct_str);
        }

        if (*end == '%' && pct_long != 0)
        {
            pct = ((double)pct_long) / 100.0;
        }
        else
        {
            pct = (double) pct_long;
        }
        if (pct < 0.0)
        {
            rb_raise(rb_eArgError, "percentages may not be negative (got `%s')", pct_str);
        }
    }
    else
    {
        pct = NUM2DBL(arg);
        if (pct < 0.0)
        {
            rb_raise(rb_eArgError, "percentages may not be negative (got `%g')", pct);
        }
    }

    return pct;
}
开发者ID:r-project,项目名称:BS,代码行数:57,代码来源:rmutil.c


示例18: rbgdk_rval2gdkpixbufglist

GList *
rbgdk_rval2gdkpixbufglist(VALUE value)
{
    struct rval2gdkpixbufglist_args args;

    args.ary = rb_ary_to_ary(value);
    args.n = RARRAY_LEN(args.ary);
    args.result = NULL;

    rb_rescue(rbgdk_rval2gdkpixbufglist_body, (VALUE)&args,
              rbgdk_rval2gdkpixbufglist_rescue, (VALUE)&args);

    return args.result;
}
开发者ID:geoffyoungs,项目名称:ruby-gnome2,代码行数:14,代码来源:rbgdk.c


示例19: rg_set_extra_attrs

static VALUE
rg_set_extra_attrs(VALUE self, VALUE attrs)
{
    struct ana_set_extra_attrs_args args;
    args.analysis = _SELF(self);
    args.ary = rb_ary_to_ary(attrs);
    args.n = RARRAY_LEN(args.ary);
    args.result = NULL;

    rb_rescue(ana_set_extra_attrs_body, (VALUE)&args,
              ana_set_extra_attrs_rescue, (VALUE)&args);

    return self;
}
开发者ID:Vasfed,项目名称:ruby-gnome2,代码行数:14,代码来源:rbpangoanalysis.c


示例20: rg_set_runs

static VALUE
rg_set_runs(VALUE self, VALUE attrs)
{
    struct layout_line_set_runs_args args;
    args.line = _SELF(self);
    args.ary = rb_ary_to_ary(attrs);
    args.n = RARRAY_LEN(args.ary);
    args.result = NULL;

    rb_rescue(layout_line_set_runs_body, (VALUE)&args,
              layout_line_set_runs_rescue, (VALUE)&args);

    return self;
}
开发者ID:Vasfed,项目名称:pango,代码行数:14,代码来源:rbpangolayoutline.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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