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


C++ NUM2UINT函数代码示例

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


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

示例1: rb_grn_expression_define_variable

/*
 * _expression_ で使用可能な変数を作成する。
 *
 * @overload define_variable(options={})
 *   @param [::Hash] options The name and value
 *     pairs. Omitted names are initialized as the default value.
 *   @option options :name [String] (nil)
 *     変数の名前。省略した場合は名前を付けない。
 *   @option options :domain [Groonga::Table] (nil)
 *     テーブルを指定すると、そのテーブル用のレコードとして初期化する。
 *   @option options :reference [Bool] (nil)
 *     Initializes this variable as reference hold variable if
 *     @:[email protected] is true. Reference hold variable is GRN_PTR type
 *     in groonga. You can't use @:[email protected] with @:[email protected]
 * @return [Groonga::Variable]
 *
 */
static VALUE
rb_grn_expression_define_variable (int argc, VALUE *argv, VALUE self)
{
    grn_ctx *context = NULL;
    grn_obj *expression, *variable;
    char *name = NULL;
    unsigned name_size = 0;
    VALUE options, rb_name, rb_domain, rb_variable, rb_reference;

    rb_scan_args(argc, argv, "01", &options);

    rb_grn_expression_deconstruct(SELF(self), &expression, &context,
                                  NULL, NULL,
                                  NULL, NULL, NULL);

    rb_grn_scan_options(options,
                        "name", &rb_name,
                        "domain", &rb_domain,
                        "reference", &rb_reference,
                        NULL);

    if (!NIL_P(rb_name)) {
        name = StringValuePtr(rb_name);
        name_size = RSTRING_LEN(rb_name);
    }

    variable = grn_expr_add_var(context, expression, name, name_size);
    rb_variable = GRNVARIABLE2RVAL(context, variable);

    if (RVAL2CBOOL(rb_obj_is_kind_of(rb_domain, rb_cGrnTable))) {
        grn_id domain_id;
        domain_id = NUM2UINT(rb_funcall(rb_domain, rb_intern("id"), 0));
        GRN_RECORD_INIT(variable, 0, domain_id);
    } else if (!NIL_P(rb_reference) && RVAL2CBOOL(rb_reference)) {
        GRN_PTR_INIT(variable, 0, GRN_DB_OBJECT);
    }

    return rb_variable;
}
开发者ID:kenhys,项目名称:rroonga,代码行数:56,代码来源:rb-grn-expression.c

示例2: rb_grn_double_array_trie_update_by_id

static VALUE
rb_grn_double_array_trie_update_by_id (VALUE self, VALUE rb_id, VALUE rb_new_key)
{
    grn_ctx *context;
    grn_obj *table;
    grn_id id, domain_id;
    grn_obj *new_key, *domain;
    grn_rc rc;

    rb_grn_double_array_trie_deconstruct(SELF(self), &table, &context,
                                         NULL, &new_key, &domain_id, &domain,
                                         NULL, NULL, NULL,
                                         NULL);

    id = NUM2UINT(rb_id);
    RVAL2GRNKEY(rb_new_key, context, new_key, domain_id, domain, self);
    rc = grn_table_update_by_id(context, table, id,
                                GRN_BULK_HEAD(new_key), GRN_BULK_VSIZE(new_key));
    rb_grn_rc_check(rc, self);

    return Qnil;
}
开发者ID:cosmo0920,项目名称:rroonga,代码行数:22,代码来源:rb-grn-double-array-trie.c

示例3: grpc_rb_call_add_metadata

static VALUE grpc_rb_call_add_metadata(int argc, VALUE *argv, VALUE self) {
  VALUE metadata;
  VALUE flags = Qnil;
  ID id_size = rb_intern("size");

  /* "11" == 1 mandatory args, 1 (flags) is optional */
  rb_scan_args(argc, argv, "11", &metadata, &flags);
  if (NIL_P(flags)) {
    flags = UINT2NUM(0); /* Default to no flags */
  }
  if (TYPE(metadata) != T_HASH) {
    rb_raise(rb_eTypeError, "add metadata failed: metadata should be a hash");
    return Qnil;
  }
  if (NUM2UINT(rb_funcall(metadata, id_size, 0)) == 0) {
    return Qnil;
  }
  rb_ivar_set(self, id_flags, flags);
  rb_ivar_set(self, id_input_md, metadata);
  rb_hash_foreach(metadata, grpc_rb_call_add_metadata_hash_cb, self);
  return Qnil;
}
开发者ID:Abioy,项目名称:kythe,代码行数:22,代码来源:rb_call.c

示例4: objectid_generate

static VALUE objectid_generate(int argc, VALUE* args, VALUE self)
{
    VALUE oid;
    unsigned char oid_bytes[12];
    unsigned long t, inc;
    unsigned short pid;
    int i;

    if(argc == 0 || (argc == 1 && *args == Qnil)) {
        t = htonl((int)time(NULL));
    } else {
        t = htonl(NUM2UINT(rb_funcall(*args, rb_intern("to_i"), 0)));
    }
    MEMCPY(&oid_bytes, &t, unsigned char, 4);

    MEMCPY(&oid_bytes[4], hostname_digest, unsigned char, 3);

    pid = htons(getpid());
    MEMCPY(&oid_bytes[7], &pid, unsigned char, 2);

    /* No need to synchronize modification of this counter between threads;
     * MRI global interpreter lock guarantees serializability.
     *
     * Compiler should optimize out impossible branch.
     */
    if (sizeof(unsigned int) == 4) {
        object_id_inc++;
    } else {
        object_id_inc = (object_id_inc + 1) % 0xFFFFFF;
    }
    inc = htonl(object_id_inc);
    MEMCPY(&oid_bytes[9], ((unsigned char*)&inc + 1), unsigned char, 3);

    oid = rb_ary_new2(12);
    for(i = 0; i < 12; i++) {
        rb_ary_store(oid, i, INT2FIX((unsigned int)oid_bytes[i]));
    }
    return oid;
}
开发者ID:DanPatey,项目名称:TeleSign-QA,代码行数:39,代码来源:cbson.c

示例5: rb_epeg_image_initialize

/*
 * call-seq:
 *  intialize()
 *
 * See Epeg::Image.open
 */
static VALUE rb_epeg_image_initialize(VALUE self)
{
  Epeg_Image *image;
  Data_Get_Struct(self, Epeg_Image, image);

  VALUE q = rb_cv_get(CLASS_OF(self), "@@quality");
  epeg_quality_set(image, NUM2UINT(q));
  rb_iv_set(self, "@quality", q);

  epeg_comment_set(image, (char *)NULL);

  int w, h;
  epeg_size_get(image, &w, &h);

  rb_iv_set(self, "@width",     INT2NUM(w));
  rb_iv_set(self, "@height",    INT2NUM(h));

  rb_iv_set(self, "epeg_file_closed", Qfalse);
  rb_iv_set(self, "epeg_trimmed",     Qfalse);

  return self;
}
开发者ID:nelsond,项目名称:ruby-epeg,代码行数:28,代码来源:epeg_image.c

示例6: trans_complete

static VALUE
trans_complete(int argc, VALUE * argv, VALUE obj)
{
    VALUE tidVal = rb_ivar_get(obj, rb_intern("tid"));

    if (TYPE(tidVal) != T_FIXNUM && TYPE(tidVal) != T_BIGNUM) {
        rb_raise(rb_eException, "internal error, incorrect 'tid' ivar");
    } else if (argc > 1) {
        rb_raise(rb_eArgError, "wrong number of arguments");
    }
    
    unsigned int tid = NUM2UINT(tidVal);

    bp::Object * data = NULL;
    if (argc == 1) data = rubyToBPObject(argv[0]);
    const BPElement * e = (data == NULL) ? NULL : data->elemPtr();
    g_bpCoreFunctions->postResults(tid, e);
    
    if (data != NULL) delete data;

    return Qnil;
}
开发者ID:browserplus,项目名称:bp-ruby,代码行数:22,代码来源:BuiltIns.cpp

示例7: library_initialize

static VALUE
library_initialize(VALUE self, VALUE libname, VALUE libflags)
{
    Library* library;
    int flags;

    Check_Type(libflags, T_FIXNUM);

    Data_Get_Struct(self, Library, library);
    flags = libflags != Qnil ? NUM2UINT(libflags) : 0;
    
    library->handle = dl_open(libname != Qnil ? StringValueCStr(libname) : NULL, flags);
    if (library->handle == NULL) {
        char errmsg[1024];
        dl_error(errmsg, sizeof(errmsg));
        rb_raise(rb_eLoadError, "Could not open library '%s': %s",
                libname != Qnil ? StringValueCStr(libname) : "[current process]",
                errmsg);
    }
    rb_iv_set(self, "@name", libname != Qnil ? libname : rb_str_new2("[current process]"));
    return self;
}
开发者ID:Flameeyes,项目名称:ffi,代码行数:22,代码来源:DynamicLibrary.c

示例8: sdl_listModes

static VALUE sdl_listModes(VALUE mod,VALUE flags)
{
  SDL_Rect **modes;
  int i;
  VALUE modesArray;
  
  modes=SDL_ListModes(NULL,NUM2UINT(flags));

  if( modes == NULL )
    return Qnil;/* no modes available */
  if( modes == (SDL_Rect **)-1)
    return Qtrue;/* all resolutions available */

  /* available modes into modesArray */
  modesArray=rb_ary_new();
  
  for(i=0;modes[i]!=NULL;++i){
    rb_ary_push( modesArray,
		 rb_ary_new3( 2, INT2NUM(modes[i]->w), INT2NUM(modes[i]->h)) );
  }
  return modesArray;
}
开发者ID:alokmenghrajani,项目名称:alokmenghrajani.github.com,代码行数:22,代码来源:rubysdl_video.c

示例9: ImageList_animate

VALUE
ImageList_animate(int argc, VALUE *argv, VALUE self)
{
    Image *images;
    Info *info;
    VALUE info_obj;

    if (argc > 1)
    {
        rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc);
    }

    // Create a new Info object to use with this call
    info_obj = rm_info_new();

    // Convert the images array to an images sequence.
    images = images_from_imagelist(self);

    if (argc == 1)
    {
        Image *img;
        unsigned int delay;

        delay = NUM2UINT(argv[0]);
        for (img = images; img; img = GetNextImageInList(img))
        {
            img->delay = delay;
        }
    }

    Data_Get_Struct(info_obj, Info, info);
    (void) AnimateImages(info, images);
    rm_check_image_exception(images, RetainOnError);
    rm_split(images);

    RB_GC_GUARD(info_obj);

    return self;
}
开发者ID:ABaumgaertner,项目名称:rmagick,代码行数:39,代码来源:rmilist.c

示例10: cr_mesh_pattern_set_corner_color_generic

static VALUE
cr_mesh_pattern_set_corner_color_generic (int argc, VALUE *argv, VALUE self)
{
  cairo_pattern_t *pattern;
  VALUE rb_nth_corner, rb_red, rb_green, rb_blue, rb_alpha;
  unsigned int nth_corner;
  double red, green, blue, alpha;

  rb_scan_args (argc, argv, "41",
                &rb_nth_corner, &rb_red, &rb_green, &rb_blue, &rb_alpha);

  nth_corner = NUM2UINT (rb_nth_corner);
  if (nth_corner > 3)
    {
      VALUE inspected;

      inspected = rb_funcall (rb_ary_new4 (argc, argv), id_inspect, 0);
      rb_raise (rb_eArgError, "nth_corner must be 0, 1, 2 or 3: <%u>: <%s>",
                nth_corner, RVAL2CSTR (inspected));
    }

  pattern = _SELF (self);
  red = NUM2DBL (rb_red);
  green = NUM2DBL (rb_green);
  blue = NUM2DBL (rb_blue);
  if (NIL_P (rb_alpha))
    {
      cairo_mesh_pattern_set_corner_color_rgb (pattern, nth_corner,
                                               red, green, blue);
    }
  else
    {
      alpha = NUM2DBL (rb_alpha);
      cairo_mesh_pattern_set_corner_color_rgba (pattern, nth_corner,
                                                red, green, blue, alpha);
    }
  cr_pattern_check_status (pattern);
  return self;
}
开发者ID:jdlehman,项目名称:rcairo,代码行数:39,代码来源:rb_cairo_pattern.c

示例11: trans_prompt

static VALUE
trans_prompt(int argc, VALUE * argv, VALUE obj)
{
    VALUE tidVal = rb_ivar_get(obj, rb_intern("tid"));

    if (TYPE(tidVal) != T_FIXNUM && TYPE(tidVal) != T_BIGNUM) {
        rb_raise(rb_eException, "internal error, incorrect 'tid' ivar");
    } else if (argc != 2) {
        rb_raise(rb_eArgError, "wrong number of arguments");
    } else if (!rb_block_given_p()) {
        rb_raise(rb_eArgError, "block required for prompt method");
    } else if (TYPE(argv[0]) != T_STRING) {
        rb_raise(rb_eException,
                 "transaction.prompt requires a string path argument");
    }
    
    unsigned int tid = NUM2UINT(tidVal);
    std::string path(RSTRING_PTR(argv[0]));
    bp::Object * data = rubyToBPObject(argv[1]);
    const BPElement * e = (data == NULL) ? NULL : data->elemPtr();

    s_lock.lock();
    unsigned int x = g_bpCoreFunctions->prompt(tid, (BPPath) path.c_str(), e,
                                               dummyCB, NULL);

    // grab the passed in block and increment a reference to it
    VALUE val = rb_block_proc();
    s_outstandingPrompts[x] = val;
    rb_gc_register_address(&s_outstandingPrompts[x]);
    s_lock.unlock();

    // now call the block!
    
    if (data != NULL) delete data;

    // return the prompt id!
    return Qnil;
}
开发者ID:browserplus,项目名称:bp-ruby,代码行数:38,代码来源:BuiltIns.cpp

示例12: client_set_default_unix_socket_mode

static VALUE
client_set_default_unix_socket_mode (VALUE self, VALUE rb_mode)
{
    guint mode;

    if (NIL_P(rb_mode)) {
        mode = 0;
    } else if (RVAL2CBOOL(rb_obj_is_kind_of(rb_mode, rb_cString))) {
        gchar *error_message = NULL;
        if (!milter_utils_parse_file_mode(RVAL2CSTR(rb_mode),
                                          &mode, &error_message)) {
            VALUE rb_error_message;
            rb_error_message = CSTR2RVAL(error_message);
            g_free(error_message);
            rb_raise(rb_eArgError, "%s", RSTRING_PTR(rb_error_message));
        }
    } else {
        mode = NUM2UINT(rb_mode);
    }

    milter_client_set_default_unix_socket_mode(SELF(self), mode);
    return self;
}
开发者ID:hayamiz,项目名称:milter-manager,代码行数:23,代码来源:rb-milter-client.c

示例13: rb_mouse_arbitrary_click_up

/*
 * Generate the up click part of an arbitrary click event
 *
 * This might be useful in concert with {Mouse.arbitrary_click_down} if
 * you want to inject some behaviour between the down and up click events.
 *
 * You can optionally specify a point to click; the mouse cursor will
 * instantly jump to the given point; otherwise the click event happens
 * at the current cursor position.
 *
 * @overload arbitrary_click_up()
 *   @return [CGPoint]
 * @overload arbitrary_click_up(point)
 *   @param point [CGPoint]
 *   @return [CGPoint]
 */
static
VALUE
rb_mouse_arbitrary_click_up(const int argc,
                            VALUE* const argv,
                            UNUSED const VALUE self)
{
    if (argc == 0)
        rb_raise(rb_eArgError,
                 "arbitrary_click_up requires at least one arg");

    const uint_t button = NUM2UINT(argv[0]);

    switch (argc) {
    case 1:
        mouse_arbitrary_click_up(button);
        break;
    case 2:
    default:
        mouse_arbitrary_click_up2(button, rb_mouse_unwrap_point(argv[1]));
    }

    return CURRENT_POSITION;
}
开发者ID:AXElements,项目名称:mouse,代码行数:39,代码来源:mouse.c

示例14: console_key_pressed_p

static VALUE
console_key_pressed_p(VALUE io, VALUE k)
{
    int vk = -1;

    if (FIXNUM_P(k)) {
	vk = NUM2UINT(k);
    }
    else {
	const struct vktable *t;
	if (SYMBOL_P(k)) {
	    k = rb_sym2str(k);
	}
	else {
	    StringValueCStr(k);
	}
	t = console_win32_vk(RSTRING_PTR(k), RSTRING_LEN(k));
	if (!t || (vk = (short)t->vk) == -1) {
	    rb_raise(rb_eArgError, "unknown virtual key code: %"PRIsVALUE, k);
	}
    }
    return GetKeyState(vk) & 0x80 ? Qtrue : Qfalse;
}
开发者ID:DashYang,项目名称:sim,代码行数:23,代码来源:console.c

示例15: grpc_rb_call_start_write

/*
  call-seq:
     call.start_write(byte_buffer, tag, flags=nil)

   Queue a byte buffer for writing.
   flags is a bit-field combination of the write flags defined above.
   A write with byte_buffer null is allowed, and will not send any bytes on the
   wire. If this is performed without GRPC_WRITE_BUFFER_HINT flag it provides
   a mechanism to flush any previously buffered writes to outgoing flow control.
   REQUIRES: No other writes are pending on the call. It is only safe to
             start the next write after the corresponding write_accepted event
             is received.
             GRPC_INVOKE_ACCEPTED must have been received by the application
             prior to calling this on the client. On the server,
             grpc_call_accept must have been called successfully.
   Produces a GRPC_WRITE_ACCEPTED event. */
static VALUE grpc_rb_call_start_write(int argc, VALUE *argv, VALUE self) {
  VALUE byte_buffer = Qnil;
  VALUE tag = Qnil;
  VALUE flags = Qnil;
  grpc_call *call = NULL;
  grpc_byte_buffer *bfr = NULL;
  grpc_call_error err;

  /* "21" == 2 mandatory args, 1 (flags) is optional */
  rb_scan_args(argc, argv, "21", &byte_buffer, &tag, &flags);
  if (NIL_P(flags)) {
    flags = UINT2NUM(0); /* Default to no flags */
  }
  bfr = grpc_rb_get_wrapped_byte_buffer(byte_buffer);
  Data_Get_Struct(self, grpc_call, call);
  err = grpc_call_start_write_old(call, bfr, ROBJECT(tag), NUM2UINT(flags));
  if (err != GRPC_CALL_OK) {
    rb_raise(rb_eCallError, "start write failed: %s (code=%d)",
             grpc_call_error_detail_of(err), err);
  }

  return Qnil;
}
开发者ID:Abioy,项目名称:kythe,代码行数:39,代码来源:rb_call.c


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