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


C++ AccessVariable类代码示例

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


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

示例1: access_read_regular_ivar

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

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

示例2: test_access_variable_is_slot

  void test_access_variable_is_slot() {
    AccessVariable* av = AccessVariable::allocate(state);

    Arguments args(state->symbol("blah"), G(object));

    av->name(state, state->symbol("@module_name"));

    Object* ret = av->access_execute(state, av, G(object), args);
    TS_ASSERT(try_as<Symbol>(ret));

    TS_ASSERT_EQUALS(std::string("Object"), as<Symbol>(ret)->cpp_str(state));
  }
开发者ID:Justme0,项目名称:rubinius,代码行数:12,代码来源:test_access_variable.hpp

示例3: test_access_variable

  void test_access_variable() {
    AccessVariable* av = AccessVariable::allocate(state);

    Arguments args(state->symbol("blah"), G(object));

    av->name(state, state->symbol("@blah"));

    G(object)->set_ivar(state, av->name(), state->symbol("Sweet"));

    Object* ret = av->execute(state, av, G(object), args);
    TS_ASSERT(try_as<Symbol>(ret));

    TS_ASSERT_EQUALS(std::string("Sweet"), as<Symbol>(ret)->cpp_str(state));
  }
开发者ID:Justme0,项目名称:rubinius,代码行数:14,代码来源:test_access_variable.hpp

示例4: test_write_variable_is_slot

  void test_write_variable_is_slot() {
    AccessVariable* av = AccessVariable::allocate(state);

    Symbol* val = state->symbol("Blah");
    Object* ary[1] = {val};
    Arguments args(state->symbol("blah"), G(object), 1, ary);

    av->name(state, state->symbol("@module_name"));
    av->write(state, cTrue);

    Object* ret = av->access_execute(state, av, G(object), args);
    TS_ASSERT_EQUALS(ret, val);

    TS_ASSERT_EQUALS(val, G(object)->module_name());
  }
开发者ID:Justme0,项目名称:rubinius,代码行数:15,代码来源:test_access_variable.hpp

示例5: test_write_variable

  void test_write_variable() {
    AccessVariable* av = AccessVariable::allocate(state);

    Symbol* val = state->symbol("Blah");
    Object* ary[1] = {val};
    Arguments args(state->symbol("blah"), G(object), 1, ary);

    av->name(state, state->symbol("@blah"));
    av->write(state, cTrue);

    Object* ret = av->execute(state, av, G(object), args);
    TS_ASSERT_EQUALS(ret, val);

    Symbol* out = as<Symbol>(G(object)->get_ivar(state, av->name()));
    TS_ASSERT_EQUALS(val, out);
  }
开发者ID:Justme0,项目名称:rubinius,代码行数:16,代码来源:test_access_variable.hpp

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

示例7: access_execute

  /* Run when an AccessVariable is executed. Uses the details in msg.method
   * to access instance variables of msg.recv */
  ExecuteStatus AccessVariable::access_execute(STATE, Task* task, Message& msg) {
    AccessVariable* access = as<AccessVariable>(msg.method);

    /* The writer case. */
    if(access->write()->true_p()) {
      if(msg.args() != 1) {
        Exception::argument_error(state, 1, msg.args());
      }

      /* Fall through, handle it as a normal ivar. */
      msg.recv->set_ivar(state, access->name(), msg.get_argument(0));
      task->primitive_return(msg.get_argument(0), msg);
      return cExecuteContinue;
    }

    /* The read case. */
    if(msg.args() != 0) {
      Exception::argument_error(state, 0, msg.args());
    } else {
      task->primitive_return(msg.recv->get_ivar(state, access->name()), msg);
    }

    return cExecuteContinue;
  }
开发者ID:gustin,项目名称:rubinius,代码行数:26,代码来源:access_variable.cpp

示例8: allocate

 AccessVariable* AccessVariable::allocate(STATE) {
   AccessVariable* av = state->new_object<AccessVariable>(G(access_variable));
   av->set_executor(AccessVariable::access_execute);
   return av;
 }
开发者ID:gustin,项目名称:rubinius,代码行数:5,代码来源:access_variable.cpp


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