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


C++ RBOOL函数代码示例

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


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

示例1: NDIV

  Time* Time::specific(STATE, Object* self, Integer* sec, Integer* nsec,
                       Object* gmt, Object* offset)
  {
    Time* tm = state->new_object_dirty<Time>(as<Class>(self));

    tm->seconds_ = sec->to_long_long();
    tm->nanoseconds_ = nsec->to_native();

    // Do a little overflow cleanup.
    if(tm->nanoseconds_ >= 1000000000) {
      tm->seconds_ += tm->nanoseconds_ / 1000000000;
      tm->nanoseconds_ %= 1000000000;
    }

    if(tm->nanoseconds_ < 0) {
      tm->seconds_ += NDIV(tm->nanoseconds_, 1000000000);
      tm->nanoseconds_ = NMOD(tm->nanoseconds_, 1000000000);
    }

    tm->decomposed(state, nil<Array>());
    tm->is_gmt(state, RBOOL(CBOOL(gmt)));
    tm->offset(state, offset);
    tm->zone(state, nil<String>());

    return tm;
  }
开发者ID:Locke23rus,项目名称:rubinius,代码行数:26,代码来源:time.cpp

示例2: get_tm

  Array* Time::calculate_decompose(STATE) {
    if(!decomposed_->nil_p()) return decomposed_;

    struct tm64 tm = get_tm();

    /* update Time::TM_FIELDS when changing order of fields */
    Array* ary = Array::create(state, 11);
    ary->set(state, 0, Integer::from(state, tm.tm_sec));
    ary->set(state, 1, Integer::from(state, tm.tm_min));
    ary->set(state, 2, Integer::from(state, tm.tm_hour));
    ary->set(state, 3, Integer::from(state, tm.tm_mday));
    ary->set(state, 4, Integer::from(state, tm.tm_mon + 1));
    ary->set(state, 5, Integer::from(state, tm.tm_year));
    ary->set(state, 6, Integer::from(state, tm.tm_wday));
    ary->set(state, 7, Integer::from(state, tm.tm_yday + 1));
    ary->set(state, 8, RBOOL(tm.tm_isdst));

    if (zone_->nil_p()) {
      if(offset_->nil_p() && tm.tm_zone) {
        zone(state, locale_string(state, tm.tm_zone));
      } else {
        zone(state, nil<String>());
      }
    }
    ary->set(state, 9, zone());

    // Cache it.
    decomposed(state, ary);
    return ary;
  }
开发者ID:Locke23rus,项目名称:rubinius,代码行数:30,代码来源:time.cpp

示例3: rb_range_new

VALUE
rb_range_new(VALUE beg, VALUE end, int exclude_end)
{
    VALUE range = rb_obj_alloc(rb_cRange);

    range_init(range, beg, end, RBOOL(exclude_end));
    return range;
}
开发者ID:DashYang,项目名称:sim,代码行数:8,代码来源:range.c

示例4: passed_blockarg

    inline bool passed_blockarg(STATE, CallFrame* call_frame, intptr_t count) {
      if(!call_frame->arguments) {
        Exception::internal_error(state, "no arguments object");
        return false;
      }

      stack_push(RBOOL(count == (int)call_frame->arguments->total()));
      return true;
    }
开发者ID:chuckremes,项目名称:rubinius,代码行数:9,代码来源:passed_blockarg.hpp

示例5: range_initialize

static VALUE
range_initialize(int argc, VALUE *argv, VALUE range)
{
    VALUE beg, end, flags;

    rb_scan_args(argc, argv, "21", &beg, &end, &flags);
    range_modify(range);
    range_init(range, beg, end, RBOOL(RTEST(flags)));
    return Qnil;
}
开发者ID:DashYang,项目名称:sim,代码行数:10,代码来源:range.c

示例6: equal

    // Rubinius.primitive+ :string_equal
    Object* equal(STATE, String* other) {
      if(encoding() != other->encoding() &&
         Encoding::compatible_p(state, this, other)->nil_p()) return cFalse;
      if(this->num_bytes() != other->num_bytes()) return cFalse;
      int comp = memcmp(
          this->byte_address(),
          other->byte_address(),
          this->num_bytes()->to_native());

      return RBOOL(comp == 0);
    }
开发者ID:JesseChavez,项目名称:rubinius,代码行数:12,代码来源:string.hpp

示例7: breakpoints

  Object* CompiledCode::is_breakpoint(STATE, Fixnum* ip) {
    int i = ip->to_native();
    if(machine_code() == NULL) return cFalse;
    if(!machine_code()->validate_ip(state, i)) return Primitives::failure();
    if(breakpoints()->nil_p()) return cFalse;

    bool found = false;
    breakpoints()->fetch(state, ip, &found);

    return RBOOL(found);
  }
开发者ID:clockmaker002,项目名称:rubinius,代码行数:11,代码来源:compiled_code.cpp

示例8: bool_test

static void bool_test(LTRandomGenerator *r) {
    int bcounts[2];
    bcounts[0] = 0;
    bcounts[1] = 0;
    for (int i = 0; i < SAMPLE_SIZE; i++) {
        bcounts[RBOOL(r) ? 1 : 0]++;
    }
    printf("Bool:\n");
    printf("  false: %d\n", bcounts[0]);
    printf("  true : %d\n", bcounts[1]);
}
开发者ID:JakobssonAndre,项目名称:lotech,代码行数:11,代码来源:randtest.cpp

示例9: switch

// RenderTexture#active=(flag)
// RenderTexture#set_active(flag)
// RenderTexture#setActive(flag)
VALUE rbRenderTexture::SetActive( int argc, VALUE* args, VALUE aSelf )
{
    bool flag = false;
    switch( argc )
    {
    case 1:
        flag = RTEST( args[ 0 ] );
    case 0:
        break;
    default:
        INVALID_ARGUMENT_LIST( argc, "0 or 1" );
    }

    bool result = rbMacros::ToSFML< sf::RenderTexture >( aSelf, rbRenderTexture::Class )->setActive( flag );
    return RBOOL( result );
}
开发者ID:paulas,项目名称:rbSFML,代码行数:19,代码来源:RenderTexture.cpp

示例10: if

Object* CallUnit::kind_of_executor(STATE, CallFrame* call_frame,
                                   CallUnit* unit,
                                   Executable* exec, Module* mod,
                                   Arguments& args)
{
    Object* obj;
    if(unit->which_ == -1) {
        obj = args.recv();
    } else if(unit->which_ < (int)args.total()) {
        obj = args.get_argument(unit->which_);
    } else {
        return cFalse;
    }

    if(Module* mod = try_as<Module>(unit->value())) {
        return RBOOL(obj->kind_of_p(state, mod));
    } else {
        return cFalse;
    }
}
开发者ID:andre-richter,项目名称:rubinius,代码行数:20,代码来源:call_unit.cpp

示例11: rand_bw_image

static void rand_bw_image(LTRandomGenerator *r, int w, int h, const char *name) {
    LTImageBuffer buf(name);
    buf.width = w;
    buf.height = h;
    buf.bb_left = 0;
    buf.bb_top = h - 1;
    buf.bb_right = w - 1;
    buf.bb_bottom = 0;
    buf.bb_pixels = new LTpixel[w * h];
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            if (RBOOL(r)) {
                buf.bb_pixels[j * w + i] = 0xFFFFFFFF;
            } else {
                buf.bb_pixels[j * w + i] = 0x000000FF;
            }
        }
    }
    ltWriteImage(name, &buf);
    printf("Generated %s\n", name);
}
开发者ID:JakobssonAndre,项目名称:lotech,代码行数:21,代码来源:randtest.cpp

示例12: RBOOL

 Object* VariableScope::script(STATE) {
   return RBOOL(script_p());
 }
开发者ID:JesseChavez,项目名称:rubinius,代码行数:3,代码来源:variable_scope.cpp

示例13: push_has_block

 inline void push_has_block(CallFrame* call_frame) {
   stack_push(RBOOL(CBOOL(call_frame->scope->block())));
 }
开发者ID:JesseChavez,项目名称:rubinius,代码行数:3,代码来源:push_has_block.hpp

示例14: RBOOL

 Object* IO::fnmatch(STATE, String* pattern, String* path, Fixnum* flags) {
   return RBOOL(mri_fnmatch(pattern->c_str(state), path->c_str(state), flags->to_native()));
 }
开发者ID:JesseChavez,项目名称:rubinius,代码行数:3,代码来源:io.cpp

示例15: call


//.........这里部分代码省略.........
              args.use_array(ary);
            }

            N = args.total();
          }
        }
      }

      const native_int P = mcode->post_args;
      const native_int H = M - P;

      // Too many args (no rest argument!)
      if(!RP && N > T) {
        if(lambda) return false;

        N = T;
      }

      // Too few args!
      if(lambda && N < M) return false;

      Object* kw = 0;
      Object* kw_remainder = 0;
      bool KP = false;
      bool KA = false;

      if(mcode->keywords && N > M) {
        Object* obj = args.get_argument(args.total() - 1);

        OnStack<1> os(state, obj);
        Object* arguments[2];

        arguments[0] = obj;
        arguments[1] = RBOOL(O > 0 || RP);
        Arguments args(G(sym_keyword_object), G(runtime), 2, arguments);
        Dispatch dis(G(sym_keyword_object));

        Object* kw_result = dis.send(state, call_frame, args);

        if(kw_result) {
          if(Array* ary = try_as<Array>(kw_result)) {
            Object* o = 0;

            if(!(o = ary->get(state, 0))->nil_p()) {
              kw_remainder = o;
              KA = true;
            }

            kw = ary->get(state, 1);
            KP = true;
          }
        } else {
          return false;
        }
      }

      // A single kwrest argument
      if(mcode->keywords && !RP && !KP && N >= T) {
        if(lambda) return false;

        N = T - 1;
      }

      const native_int K = (KP && !KA && N > M) ? 1 : 0;
      const native_int N_M_K = N - M - K;
      const native_int E = N_M_K > 0 ? N_M_K : 0;
开发者ID:Locke23rus,项目名称:rubinius,代码行数:67,代码来源:block_environment.cpp


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