当前位置: 首页>>代码示例>>C++>>正文


C++ rb_rescue函数代码示例

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


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


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