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


C++ CBOOL函数代码示例

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


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

示例1: access_execute

  /* Run when an AccessVariable is executed. Uses the details in exec
   * to access instance variables of args.recv() */
  Object* AccessVariable::access_execute(STATE, CallFrame* call_frame, Executable* exec, Module* mod,
                                         Arguments& args) {
    AccessVariable* access = as<AccessVariable>(exec);
    Object* const self = args.recv();

    /* The writer case. */
    if(access->write()->true_p()) {
      if(CBOOL(self->frozen_p(state)) && CBOOL(self->frozen_mod_disallowed(state))) {
        Exception::frozen_error(state, call_frame, self);
        return 0;
      }

      if(args.total() != 1) {
        Exception::argument_error(state, 1, args.total());
        return NULL;
      }

      if(kind_of<Class>(mod) && self->reference_p()) {
        // Promote this to use a direct accessor
        if(TypeInfo* ti = state->memory()->find_type_info(self)) {
          TypeInfo::Slots::iterator it = ti->slots.find(access->name()->index());
          if(it != ti->slots.end()) {
            // Found one!
            access->set_executor(ti->slot_accessors[it->second]);
            ti->set_field(state, self, it->second, args.get_argument(0));
            return args.get_argument(0);
          }
        }

        /* Fall through, handle it as a normal ivar. */
        access->set_executor(access_write_regular_ivar);
      }

      self->set_ivar(state, access->name(), args.get_argument(0));
      return args.get_argument(0);
    }

    /* The read case. */
    if(args.total() != 0) {
      Exception::argument_error(state, 0, args.total());
      return NULL;
    }

    if(kind_of<Class>(mod) && self->reference_p()) {
      // Promote this to use a direct accessor
      if(TypeInfo* ti = state->memory()->find_type_info(self)) {
        TypeInfo::Slots::iterator it = ti->slots.find(access->name()->index());
        if(it != ti->slots.end()) {
          // Found one!
          access->set_executor(ti->slot_accessors[it->second]);
          return ti->get_field(state, self, it->second);
        }
      }
      // Ok, its a table ivar, setup fast access for next time.
      access->set_executor(access_read_regular_ivar);
    }

    return self->get_ivar(state, access->name());
  }
开发者ID:Locke23rus,项目名称:rubinius,代码行数:61,代码来源:access_variable.cpp

示例2: get_tm

  String* Time::strftime(STATE, String* format) {
    struct tm64 tm = get_tm();

    struct timespec64 ts;
    ts.tv_sec = seconds_;
    ts.tv_nsec = nanoseconds_;

    int off = 0;
    if(Fixnum* offset = try_as<Fixnum>(utc_offset(state))) {
      off = offset->to_int();
    }

    if(format->byte_size() == 0) return String::create(state, NULL, 0);

    char stack_str[STRFTIME_STACK_BUF];

    size_t chars = ::strftime_extended(stack_str, STRFTIME_STACK_BUF,
                       format->c_str(state), &tm, &ts, CBOOL(is_gmt_) ? 1 : 0,
                       off);

    size_t buf_size = format->byte_size();

    String* result = 0;

    if(chars == 0) {
      buf_size *= 2;
      char* malloc_str = (char*)malloc(buf_size);

      if(!malloc_str) {
        Exception::memory_error(state);
        return NULL;
      }

      chars = ::strftime_extended(malloc_str, buf_size,
                  format->c_str(state), &tm, &ts, CBOOL(is_gmt_) ? 1 : 0,
                  off);
      if(chars) {
        result = String::create(state, malloc_str, chars);
        result->encoding(state, format->encoding());
      }

      free(malloc_str);
    } else {
      result = String::create(state, stack_str, chars);
      result->encoding(state, format->encoding());
    }

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

示例3: propagate_last_match

 Object* Regexp::propagate_last_match(STATE, CallFrame* call_frame) {
   Object* obj = call_frame->last_match(state);
   if(CBOOL(obj)) {
     Regexp::set_last_match(state, obj, call_frame);
   }
   return obj;
 }
开发者ID:DanielVartanov,项目名称:rubinius,代码行数:7,代码来源:regexp.cpp

示例4: to_ary

  Array* Array::to_ary(STATE, Object* value, CallFrame* call_frame) {
    if(Tuple* tup = try_as<Tuple>(value)) {
      return Array::from_tuple(state, tup);
    }

    if(CBOOL(value->respond_to(state, G(sym_to_ary), cTrue))) {
      Object* res = value->send(state, call_frame, G(sym_to_ary));
      if(!res) return 0;

      if(Array* ary = try_as<Array>(res)) {
        return ary;
      }

      if(LANGUAGE_18_ENABLED || !res->nil_p()) {
        Exception::type_error(state, "to_ary should return an Array", call_frame);
        return 0;
      }

      // NOTE: On >= 1.9, if res is nil just fall through and return [value]
    }

    Array* ary = Array::create(state, 1);
    ary->set(state, 0, value);
    return ary;
  }
开发者ID:Emily,项目名称:rubinius,代码行数:25,代码来源:array.cpp

示例5: 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

示例6: BGl_readzd2config_schzd2zzinit_libzd2dirzd2

/* read-config_sch */
	obj_t BGl_readzd2config_schzd2zzinit_libzd2dirzd2(obj_t BgL_fz00_8)
	{
		AN_OBJECT;
		{	/* Init/lib_dir.scm 63 */
			{	/* Init/lib_dir.scm 64 */
				obj_t BgL_portz00_124;

				{	/* Init/lib_dir.scm 64 */

					BgL_portz00_124 =
						BGl_openzd2inputzd2filez00zz__r4_ports_6_10_1z00(BgL_fz00_8, BTRUE);
				}
				{	/* Init/lib_dir.scm 65 */
					obj_t BgL_val1508z00_125;

					BgL_val1508z00_125 =
						BGl_zc3exitza31528ze3z83zzinit_libzd2dirzd2(BgL_fz00_8,
						BgL_portz00_124);
					bgl_close_input_port(BgL_portz00_124);
					if (CBOOL(BGl_valzd2fromzd2exitzf3zf3zz__bexitz00
							(BgL_val1508z00_125)))
						{	/* Init/lib_dir.scm 71 */
							return
								BGl_unwindzd2untilz12zc0zz__bexitz00(CAR(BgL_val1508z00_125),
								CDR(BgL_val1508z00_125));
						}
					else
						{	/* Init/lib_dir.scm 71 */
							return BgL_val1508z00_125;
						}
				}
			}
		}
	}
开发者ID:8l,项目名称:bigloo-llvm,代码行数:35,代码来源:lib_dir.c

示例7: BGl_unixzd2filenamezd2zzcc_execz00

/* unix-filename */
	BGL_EXPORTED_DEF obj_t BGl_unixzd2filenamezd2zzcc_execz00(obj_t BgL_argsz00_1)
	{
		AN_OBJECT;
		{	/* Cc/exec.scm 33 */
			{	/* Cc/exec.scm 34 */
				obj_t BgL_sz00_91;

				BgL_sz00_91 =
					BGl_stringzd2appendzd2zz__r4_strings_6_7z00(BgL_argsz00_1);
				{	/* Cc/exec.scm 35 */
					bool_t BgL_testz00_139;

					{	/* Cc/exec.scm 35 */

						BgL_testz00_139 =
							CBOOL(BGl_stringzd2indexzd2zz__r4_strings_6_7z00(BgL_sz00_91,
								BCHAR(((unsigned char) ' ')), BINT(((long) 0))));
					}
					if (BgL_testz00_139)
						{	/* Cc/exec.scm 35 */
							return
								string_append_3(BGl_string1528z00zzcc_execz00, BgL_sz00_91,
								BGl_string1528z00zzcc_execz00);
						}
					else
						{	/* Cc/exec.scm 35 */
							return BgL_sz00_91;
						}
				}
			}
		}
	}
开发者ID:8l,项目名称:bigloo-llvm,代码行数:33,代码来源:exec.c

示例8: dlbe_PassThrough

/*-----------------------------------------------------------------------------------
 * Name: dlbe_PassThrough
 *
 * Description:
 * This function verifies the validity of a Unique Record Id and then retrieves the
 * information from it (RecordType)
 *
 * Parameters:
 * UniqueIdPtr (input) - A Unique Record Id Ptr
 *
 * RETURN:
 * The recordtype that the unique record id coresponds to if the Unique ID is valid,
 * otherwise returns DAL_OOB.
 *
 * ERROR CODES
 * CSSMERR_DL_INVALID_RECORD_UID
 *-----------------------------------------------------------------------------------*/
CSSM_RETURN dlbe_PassThrough (
	CSSM_DL_DB_HANDLE DLDBHandle,
	uint32 PassThroughId,
	const void * InputParams,
	void ** OutputParams)
{
	FFDL_WRITE_BACK_CACHE_STATUS CacheStatus;

	if (PassThroughId == FFDL_PASSTHROUGH_SET_WRITE_BACK_CACHE)
	{
		if (port_IsBadReadPtr(InputParams, sizeof(FFDL_WRITE_BACK_CACHE_STATUS)))
			return CSSMERR_DL_INVALID_POINTER;

		if (DLDBHandle.DBHandle != 0)
			return CSSMERR_DL_INVALID_DB_HANDLE;

		CacheStatus = *((const FFDL_WRITE_BACK_CACHE_STATUS *)InputParams);

		if (CacheStatus != FFDL_ENABLE_CACHE && CacheStatus != FFDL_DISABLE_CACHE)
			return FFDL_CACHE_STATUS_INVALID;

		ffport_nrSetCache(CBOOL(CacheStatus == FFDL_ENABLE_CACHE));
	}
	else
		return CSSMERR_DL_INVALID_PASSTHROUGH_ID;

	return CSSM_OK;
}
开发者ID:ozgend,项目名称:hive,代码行数:45,代码来源:ff_func.cpp

示例9: cvar_set

  Object* Module::cvar_set(STATE, Symbol* name, Object* value) {
    if(!name->is_cvar_p(state)->true_p()) return Primitives::failure();

    if(CBOOL(frozen_p(state))) {
      Exception::type_error(state, "unable to change frozen object");
    }

    Module* mod = this;
    Module* mod_to_query;

    while(!mod->nil_p()) {
      mod_to_query = get_module_to_query(mod);

      if(mod_to_query->table_ivar_defined(state, name)->true_p()) {
        mod_to_query->set_table_ivar(state, name, value);
        return value;
      }

      mod = mod->superclass();
    }

    mod = this;
    mod_to_query = get_module_to_query(mod);

    mod_to_query->set_ivar(state, name, value);
    return value;
  }
开发者ID:Erreon,项目名称:rubinius,代码行数:27,代码来源:module.cpp

示例10: NDIV

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

    if(sizeof(time_t) == sizeof(long long)) {
      tm->seconds_ = sec->to_long_long();
      tm->nanoseconds_ = nsec->to_long_long();
    } else {
      tm->seconds_ = sec->to_native();
      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);
    }

    if(LANGUAGE_18_ENABLED(state)) {
      tm->nanoseconds_ -= (tm->nanoseconds_ % 1000);
    }

    tm->is_gmt(state, CBOOL(gmt) ? cTrue : cFalse);

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

示例11: goto_if_false

 inline bool goto_if_false(CallFrame* call_frame) {
   Object* t1 = stack_pop();
   if(!CBOOL(t1)) {
     return true;
   } else {
     return false;
   }
 }
开发者ID:chuckremes,项目名称:rubinius,代码行数:8,代码来源:goto_if_false.hpp

示例12: access_write_regular_ivar

  Object* AccessVariable::access_write_regular_ivar(STATE, CallFrame* call_frame, Executable* exec, Module* mod,
                                         Arguments& args) {
    AccessVariable* access = as<AccessVariable>(exec);
    if(unlikely(args.total() != 1)) {
      Exception::argument_error(state, 1, args.total());
      return NULL;
    }

    Object* recv = args.recv();

    if(CBOOL(recv->frozen_p(state)) && CBOOL(recv->frozen_mod_disallowed(state))) {
      Exception::frozen_error(state, call_frame, recv);
      return 0;
    }

    return recv->set_ivar(state, access->name(), args.get_argument(0));
  }
开发者ID:Locke23rus,项目名称:rubinius,代码行数:17,代码来源:access_variable.cpp

示例13: set_critical

 Object* Thread::set_critical(STATE, Object* obj) {
   if(CBOOL(obj)) {
     state->shared().set_critical(state);
     return cTrue;
   } else {
     state->shared().clear_critical(state);
     return cFalse;
   }
 }
开发者ID:magnusmorton,项目名称:rubinius,代码行数:9,代码来源:thread.cpp

示例14: locate_method_on

    /** @todo Remove redundancy between this and sends. --rue */
    Tuple* locate_method_on(STATE, CallFrame* call_frame, Object* recv, Symbol* name, Object* priv) {
      LookupData lookup(recv, recv->lookup_begin(state), CBOOL(priv) ? G(sym_private) : G(sym_protected));
      Dispatch dis(name);

      if(!GlobalCache::resolve(state, dis.name, dis, lookup)) {
        return nil<Tuple>();
      }

      return Tuple::from(state, 2, dis.method, dis.module);
    }
开发者ID:fakeleft,项目名称:rubinius,代码行数:11,代码来源:helpers.cpp

示例15: set_ivar

    inline bool set_ivar(STATE, CallFrame* call_frame, intptr_t literal) {
      if(CBOOL(call_frame->self()->frozen_p(state))) {
        Exception::frozen_error(state, call_frame->self());
        return false;
      }

      Symbol* sym = reinterpret_cast<Symbol*>(literal);
      call_frame->self()->set_ivar(state, sym, stack_top());
      return true;
    }
开发者ID:JesseChavez,项目名称:rubinius,代码行数:10,代码来源:set_ivar.hpp


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