Permalink
Browse files

Removed use of Qtrue|false|nil|undef from native code.

Also cleaned up definition of C-API macros. Absolutely no macros should have
different definitions between the native code and the C-API code.

Move definitions of MRI OOP bit patterns to the configure script.

Added RBOOL() to convert a C++ bool to Ruby true or false.
  • Loading branch information...
1 parent 94ecb45 commit 832cbb39e8a0724e7589511c5a7e7997415e0580 @brixen brixen committed Jan 14, 2012
Showing with 1,613 additions and 1,774 deletions.
  1. +1 −1 Rakefile
  2. +119 −1 configure
  3. +2 −0 vm/.gitignore
  4. +2 −2 vm/agent.cpp
  5. +7 −7 vm/arguments.hpp
  6. +7 −7 vm/builtin/array.cpp
  7. +1 −1 vm/builtin/atomic.cpp
  8. +1 −1 vm/builtin/autoload.cpp
  9. +28 −28 vm/builtin/bignum.cpp
  10. +3 −3 vm/builtin/block_environment.cpp
  11. +2 −2 vm/builtin/bytearray.cpp
  12. +1 −1 vm/builtin/bytearray.hpp
  13. +3 −3 vm/builtin/call_unit.cpp
  14. +9 −9 vm/builtin/channel.cpp
  15. +5 −5 vm/builtin/class.cpp
  16. +8 −8 vm/builtin/compactlookuptable.cpp
  17. +6 −6 vm/builtin/compiledmethod.cpp
  18. +7 −7 vm/builtin/dir.cpp
  19. +5 −5 vm/builtin/encoding.cpp
  20. +2 −2 vm/builtin/encoding.hpp
  21. +1 −1 vm/builtin/exception.cpp
  22. +4 −4 vm/builtin/executable.cpp
  23. +13 −13 vm/builtin/ffi_pointer.cpp
  24. +10 −10 vm/builtin/fiber.cpp
  25. +5 −5 vm/builtin/find_object.cpp
  26. +8 −8 vm/builtin/fixnum.cpp
  27. +3 −3 vm/builtin/fixnum.hpp
  28. +20 −20 vm/builtin/float.cpp
  29. +2 −2 vm/builtin/heap_dump.cpp
  30. +6 −6 vm/builtin/integer.cpp
  31. +35 −35 vm/builtin/io.cpp
  32. +1 −1 vm/builtin/io.hpp
  33. +3 −3 vm/builtin/list.cpp
  34. +2 −2 vm/builtin/location.cpp
  35. +11 −11 vm/builtin/lookuptable.cpp
  36. +2 −2 vm/builtin/methodtable.cpp
  37. +5 −5 vm/builtin/module.cpp
  38. +21 −21 vm/builtin/nativefunction.cpp
  39. +10 −10 vm/builtin/nativemethod.cpp
  40. +11 −11 vm/builtin/nativemethod.hpp
  41. +32 −32 vm/builtin/object.cpp
  42. +7 −7 vm/builtin/object.hpp
  43. +5 −5 vm/builtin/packed_object.cpp
  44. +1 −1 vm/builtin/proc.cpp
  45. +2 −2 vm/builtin/randomizer.cpp
  46. +12 −12 vm/builtin/regexp.cpp
  47. +23 −23 vm/builtin/string.cpp
  48. +3 −3 vm/builtin/string.hpp
  49. +3 −3 vm/builtin/symbol.cpp
  50. +1 −1 vm/builtin/symbol.hpp
  51. +68 −68 vm/builtin/system.cpp
  52. +12 −12 vm/builtin/thread.cpp
  53. +5 −5 vm/builtin/time.cpp
  54. +3 −3 vm/builtin/tuple.cpp
  55. +1 −1 vm/builtin/tuple.hpp
  56. +150 −150 vm/builtin/unpack18.cpp
  57. +150 −150 vm/builtin/unpack19.cpp
  58. +3 −3 vm/builtin/variable_scope.cpp
  59. +2 −2 vm/call_frame.cpp
  60. +4 −4 vm/call_frame.hpp
  61. +5 −90 vm/capi/18/include/ruby.h
  62. +5 −90 vm/capi/19/include/ruby/ruby.h
  63. +1 −1 vm/capi/array.cpp
  64. +11 −11 vm/capi/capi.cpp
  65. +1 −1 vm/capi/gc.cpp
  66. +1 −1 vm/capi/globals.cpp
  67. +2 −2 vm/capi/numeric.cpp
  68. +4 −4 vm/capi/object.cpp
  69. +2 −2 vm/capi/string.cpp
  70. +6 −3 vm/capi/symbol.cpp
  71. +1 −57 vm/capi/tag.hpp
  72. +9 −9 vm/codegen/field_extract.rb
  73. +2 −2 vm/dispatch.hpp
  74. +1 −1 vm/drivers/cli.cpp
  75. +1 −1 vm/gc/baker.cpp
  76. +2 −2 vm/gc/gc.cpp
  77. +1 −1 vm/gc/immix.cpp
  78. +7 −7 vm/gc/root.cpp
  79. +3 −3 vm/gc/root.hpp
  80. +1 −1 vm/gc/write_barrier.hpp
  81. +3 −3 vm/helpers.cpp
  82. +1 −1 vm/inline_cache.cpp
  83. +23 −47 vm/instructions.def
  84. +1 −1 vm/instruments/rbxti.cpp
  85. +3 −3 vm/instruments/tooling.cpp
  86. +5 −5 vm/llvm/inline.cpp
  87. +14 −14 vm/llvm/inline_primitive.cpp
  88. +2 −2 vm/llvm/jit_block.cpp
  89. +1 −1 vm/llvm/jit_builder.cpp
  90. +2 −2 vm/llvm/jit_inline_block.cpp
  91. +2 −2 vm/llvm/jit_inline_method.cpp
  92. +2 −2 vm/llvm/jit_method.cpp
  93. +4 −4 vm/llvm/jit_operations.hpp
  94. +39 −39 vm/llvm/jit_util.cpp
  95. +25 −25 vm/llvm/jit_visit.hpp
  96. +2 −2 vm/llvm/state.cpp
  97. +5 −5 vm/marshal.cpp
  98. +6 −6 vm/object_utils.hpp
  99. +17 −17 vm/objectmemory.cpp
  100. +11 −11 vm/ontology.cpp
  101. +3 −3 vm/oop.cpp
  102. +30 −38 vm/oop.hpp
  103. +1 −1 vm/primitives.cpp
  104. +2 −2 vm/signal.cpp
  105. +2 −2 vm/stack_variables.hpp
  106. +2 −2 vm/state.cpp
  107. +0 −18 vm/test/capi/capi_reset.h
  108. +0 −2 vm/test/capi/test_constants.hpp
  109. +28 −34 vm/test/capi/test_handles.hpp
  110. +2 −2 vm/test/test_access_variable.hpp
  111. +25 −25 vm/test/test_array.hpp
  112. +53 −53 vm/test/test_bignum.hpp
  113. +2 −2 vm/test/test_bytearray.hpp
  114. +5 −5 vm/test/test_channel.hpp
  115. +1 −1 vm/test/test_class.hpp
  116. +8 −8 vm/test/test_compactlookuptable.hpp
  117. +1 −1 vm/test/test_compiled_file.hpp
  118. +4 −4 vm/test/test_dir.hpp
  119. +1 −1 vm/test/test_exception.hpp
  120. +39 −39 vm/test/test_fixnum.hpp
  121. +35 −35 vm/test/test_float.hpp
  122. +3 −3 vm/test/test_integer.hpp
  123. +5 −5 vm/test/test_io.hpp
  124. +49 −49 vm/test/test_lookuptable.hpp
  125. +2 −2 vm/test/test_module.hpp
  126. +10 −10 vm/test/test_nativefunction.hpp
  127. +8 −8 vm/test/test_nativemethod.hpp
  128. +62 −62 vm/test/test_object.hpp
  129. +7 −7 vm/test/test_objectmemory.hpp
  130. +1 −1 vm/test/test_ontology.hpp
  131. +9 −9 vm/test/test_pointer.hpp
  132. +5 −5 vm/test/test_regexp.hpp
  133. +46 −46 vm/test/test_string.hpp
  134. +5 −5 vm/test/test_symboltable.hpp
  135. +1 −1 vm/test/test_time.hpp
  136. +9 −9 vm/test/test_tuple.hpp
  137. +6 −6 vm/test/test_unmarshal.hpp
  138. +14 −14 vm/thread_state.cpp
  139. +11 −11 vm/vm.cpp
  140. +1 −1 vm/vm.hpp
  141. +2 −2 vm/vmmethod.cpp
View
2 Rakefile
@@ -33,7 +33,7 @@ end
require config_rb
BUILD_CONFIG = Rubinius::BUILD_CONFIG
-unless BUILD_CONFIG[:config_version] == 153
+unless BUILD_CONFIG[:config_version] == 154
STDERR.puts "Your configuration is outdated, please run ./configure first"
exit 1
end
View
120 configure
@@ -118,7 +118,7 @@ class Configure
@libversion = "2.0"
@version = "#{@libversion}.0dev"
@release_date = "yyyy-mm-dd"
- @config_version = 153
+ @config_version = 154
# TODO: add conditionals for platforms
if RbConfig::CONFIG["build_os"] =~ /darwin/
@@ -1241,6 +1241,124 @@ end
FileUtils.cp config_h, "vm/capi/19/include/ruby/config.h"
+ # Write definitions for the MRI Object-Oriented Pointer (OOP) definitions.
+ mri_oop_h = "vm/capi/18/include/mri_oop.h"
+ File.open mri_oop_h, "wb" do |f|
+ f.puts <<-EOO
+#ifndef RBX_CAPI_MRI_OOP_H
+#define RBX_CAPI_MRI_OOP_H
+
+/* This file is generated by the build system. Your edits
+ * will be lost. See the configure script.
+ */
+
+/*
+ * In MRI, VALUE represents an object.
+ *
+ * In Rubinius, this is a Handle.
+ */
+#define VALUE intptr_t
+
+/*
+ * In MRI, ID represents an interned string, i.e. a Symbol.
+ *
+ * In Rubinius, this is a raw Symbol.
+ */
+#define ID intptr_t
+
+/*
+ * The C-API uses handles to refer to all Ruby objects rather than raw
+ * pointers to objects. There are four categories of objects:
+ *
+ * 1. References (e.g. instances of Array, String, Hash, etc.)
+ * 2. Fixnums
+ * 3. Symbols
+ * 4. "Booleans" (i.e. Qfalse, Qtrue, Qnil, Qundef)
+ *
+ * The handles are tagged to distinguish the categories of objects.
+ *
+ * The tagging scheme allows passing Symbols and Fixnums straight through
+ * without changing their values. This ensures that if a C extension
+ * assigns a global ID with the value of a Symbol, any subsequent handle
+ * requested for that symbol (e.g. from rb_intern()) will have the same
+ * value. Passing Fixnums through means that all the Fixnum conversions
+ * do not have to be reimplemented for the C-API.
+ *
+ * The tags break down as follows (@see vm/oop.hpp for more details):
+ *
+ * 00 0 0000 Qfalse
+ * xx x xxx1 Fixnum
+ * xx x x110 Symbol
+ *
+ * 01 0 0010 Qtrue
+ * 10 0 0010 Qnil
+ * 11 0 0010 Qundef
+ *
+ * In other words, any bit pattern ending in 1 is a Fixnum, ending in 110
+ * is a Symbol, ending in 0010 is a C-API "boolean" and Qfalse is 0.
+ *
+ * NOTE: The Qfalse value is defined to be 0 because it is 0 in MRI and
+ * extensions written for MRI have (absolutely wrongly, infuriatingly,
+ * but-what-can-you-do-now) relied on that assumption in boolean contexts.
+ * Rather than fighting a myriad subtle bugs, we just go along with it.
+ */
+
+/* The false object. */
+#define Qfalse ((VALUE)0x00)
+
+/* The true object. */
+#define Qtrue ((VALUE)0x22)
+
+/* The nil object. */
+#define Qnil ((VALUE)0x42)
+
+/* The undef object. NEVER EXPOSE THIS TO USER CODE. EVER. */
+#define Qundef ((VALUE)0x62)
+
+#define FALSE_P(v) ((VALUE)(v) == Qfalse)
+#define TRUE_P(v) ((VALUE)(v) == Qtrue)
+#define NIL_P(v) ((VALUE)(v) == Qnil)
+#define UNDEF_P(v) ((VALUE)(v) == Qundef)
+
+
+#undef TAG_REF
+#undef TAG_REF_MASK
+
+#define TAG_REF 0x0
+#define TAG_REF_MASK 0x3
+
+#undef TAG_FIXNUM
+#undef TAG_FIXNUM_SHIFT
+#undef TAG_FIXNUM_MASK
+
+#define TAG_FIXNUM 0x1
+#define TAG_FIXNUM_SHIFT 0x1
+#define TAG_FIXNUM_MASK 0x1
+
+#undef TAG_SYMBOL
+#undef TAG_SYMBOL_MASK
+
+#define TAG_SYMBOL 0x6
+#define TAG_SYMBOL_MASK 0x7
+
+#define REFERENCE_P(v) ((v) && (((VALUE)(v) & TAG_REF_MASK) == TAG_REF))
+#define IMMEDIATE_P(x) (!REFERENCE_P(x))
+
+#define FIXNUM_P(v) (((VALUE)(v) & TAG_FIXNUM_MASK) == TAG_FIXNUM)
+#define SYMBOL_P(v) (((VALUE)(v) & TAG_SYMBOL_MASK) == TAG_SYMBOL)
+
+#define CAPI_TAG_FIXNUM(v) ((VALUE)(((VALUE)(v) << TAG_FIXNUM_SHIFT) | TAG_FIXNUM))
+
+#define FIXNUM_WIDTH ((8 * sizeof(native_int)) - TAG_FIXNUM_SHIFT - 1)
+#define FIXNUM_MAX (((native_int)1 << FIXNUM_WIDTH) - 1)
+#define FIXNUM_MIN (-(FIXNUM_MAX))
+
+#endif
+ EOO
+ end
+
+ FileUtils.cp mri_oop_h, "vm/capi/19/include/ruby/mri_oop.h"
+
# Write a require file depending on which Readline library we use.
File.open "lib/readline.rb", "wb" do |f|
if @rb_readline
View
2 vm/.gitignore
@@ -4,6 +4,8 @@ gen/*
test/test_instructions.hpp
capi/18/include/config.h
+capi/18/include/mri_oop.h
capi/18/include/rbx_config.h
capi/19/include/ruby/config.h
+capi/19/include/ruby/mri_oop.h
capi/19/include/rbx_config.h
View
4 vm/agent.cpp
@@ -87,10 +87,10 @@ namespace rubinius {
// This class is always created with the GIL locked, so it's ok
// to access ruby stuff here.
IO* from = IO::create(state, a2r_ruby());
- from->sync(state, Qtrue);
+ from->sync(state, cTrue);
IO* to = IO::create(state, r2a_ruby());
- to->sync(state, Qtrue);
+ to->sync(state, cTrue);
shared_.globals.rubinius.get()->set_const(state, "FROM_AGENT", from);
shared_.globals.rubinius.get()->set_const(state, "TO_AGENT", to);
View
14 vm/arguments.hpp
@@ -32,34 +32,34 @@ namespace rubinius {
Arguments(Symbol* name, Object* recv, uint32_t total, Object** buffer)
: name_(name)
, recv_(recv)
- , block_(Qnil)
+ , block_(cNil)
, total_(total)
, arguments_(buffer)
, argument_container_(0)
{}
Arguments(Symbol* name, uint32_t total, Object** buffer)
: name_(name)
- , recv_(Qnil)
- , block_(Qnil)
+ , recv_(cNil)
+ , block_(cNil)
, total_(total)
, arguments_(buffer)
, argument_container_(0)
{}
Arguments(Symbol* name)
: name_(name)
- , recv_(Qnil)
- , block_(Qnil)
+ , recv_(cNil)
+ , block_(cNil)
, total_(0)
, arguments_(0)
, argument_container_(0)
{}
Arguments(Symbol* name, Array* ary)
: name_(name)
- , recv_(Qnil)
- , block_(Qnil)
+ , recv_(cNil)
+ , block_(cNil)
{
use_array(ary);
}
View
14 vm/builtin/array.cpp
@@ -101,7 +101,7 @@ namespace rubinius {
Array* Array::to_ary(STATE, Object* value, CallFrame* call_frame) {
if(Tuple* tup = try_as<Tuple>(value)) {
return Array::from_tuple(state, tup);
- } else if(CBOOL(value->respond_to(state, state->symbol("to_ary"), Qtrue))) {
+ } else if(CBOOL(value->respond_to(state, state->symbol("to_ary"), cTrue))) {
Arguments args(state->symbol("to_ary"), value, 0, 0);
Dispatch dis(args.name());
@@ -145,7 +145,7 @@ namespace rubinius {
}
// Off either end, return nil
- if(index >= total || index < start) return Qnil;
+ if(index >= total || index < start) return cNil;
return tuple_->at(state, index);
}
@@ -194,7 +194,7 @@ namespace rubinius {
Object* Array::get(STATE, size_t idx) {
if(idx >= (size_t)total_->to_native()) {
- return Qnil;
+ return cNil;
}
idx += start_->to_native();
@@ -256,9 +256,9 @@ namespace rubinius {
Object* Array::shift(STATE) {
size_t cnt = total_->to_native();
- if(cnt == 0) return Qnil;
+ if(cnt == 0) return cNil;
Object* obj = get(state, 0);
- set(state, 0, Qnil);
+ set(state, 0, cNil);
start(state, Fixnum::from(start_->to_native() + 1));
total(state, Fixnum::from(cnt - 1));
return obj;
@@ -282,9 +282,9 @@ namespace rubinius {
Object* Array::pop(STATE) {
size_t cnt = total_->to_native();
- if(cnt == 0) return Qnil;
+ if(cnt == 0) return cNil;
Object *obj = get(state, cnt - 1);
- set(state, cnt-1, Qnil);
+ set(state, cnt-1, cNil);
total(state, Fixnum::from(cnt - 1));
return obj;
}
View
2 vm/builtin/atomic.cpp
@@ -18,6 +18,6 @@ namespace rubinius {
Object* AtomicReference::compare_and_set(STATE, Object* old, Object* new_) {
Object** pp = &value_;
- return atomic::compare_and_swap((void**)pp, old, new_) ? Qtrue : Qfalse;
+ return atomic::compare_and_swap((void**)pp, old, new_) ? cTrue : cFalse;
}
}
View
2 vm/builtin/autoload.cpp
@@ -18,7 +18,7 @@ namespace rubinius {
Object* Autoload::resolve(STATE, CallFrame* call_frame, bool honor_require) {
if(honor_require) {
Array* args = Array::create(state, 1);
- args->set(state, 0, Qtrue);
+ args->set(state, 0, cTrue);
return send(state, call_frame, G(sym_call), args);
} else {
View
56 vm/builtin/bignum.cpp
@@ -777,16 +777,16 @@ namespace rubinius {
}
if(r == MP_EQ) {
- return Qtrue;
+ return cTrue;
}
- return Qfalse;
+ return cFalse;
}
Object* Bignum::equal(STATE, Bignum* b) {
if(mp_cmp(mp_val(), b->mp_val()) == MP_EQ) {
- return Qtrue;
+ return cTrue;
}
- return Qfalse;
+ return cFalse;
}
Object* Bignum::equal(STATE, Float* b) {
@@ -858,22 +858,22 @@ namespace rubinius {
mp_clear(&n);
if(r == MP_LT) {
- return Qtrue;
+ return cTrue;
}
- return Qfalse;
+ return cFalse;
} else {
if(mp_cmp_d(a, bi) == MP_GT) {
- return Qtrue;
+ return cTrue;
}
- return Qfalse;
+ return cFalse;
}
}
Object* Bignum::gt(STATE, Bignum* b) {
if(mp_cmp(mp_val(), b->mp_val()) == MP_GT) {
- return Qtrue;
+ return cTrue;
}
- return Qfalse;
+ return cFalse;
}
Object* Bignum::gt(STATE, Float* b) {
@@ -891,15 +891,15 @@ namespace rubinius {
int r = mp_cmp_d(&n, -bi);
mp_clear(&n);
if(r == MP_EQ || r == MP_LT) {
- return Qtrue;
+ return cTrue;
}
- return Qfalse;
+ return cFalse;
} else {
int r = mp_cmp_d(a, bi);
if(r == MP_EQ || r == MP_GT) {
- return Qtrue;
+ return cTrue;
}
- return Qfalse;
+ return cFalse;
}
}
@@ -910,9 +910,9 @@ namespace rubinius {
Object* Bignum::ge(STATE, Bignum* b) {
int r = mp_cmp(mp_val(), b->mp_val());
if(r == MP_GT || r == MP_EQ) {
- return Qtrue;
+ return cTrue;
}
- return Qfalse;
+ return cFalse;
}
Object* Bignum::lt(STATE, Fixnum* b) {
@@ -929,22 +929,22 @@ namespace rubinius {
mp_clear(&n);
if(r == MP_GT) {
- return Qtrue;
+ return cTrue;
}
- return Qfalse;
+ return cFalse;
} else {
if(mp_cmp_d(a, bi) == MP_LT) {
- return Qtrue;
+ return cTrue;
}
- return Qfalse;
+ return cFalse;
}
}
Object* Bignum::lt(STATE, Bignum* b) {
if(mp_cmp(mp_val(), b->mp_val()) == MP_LT) {
- return Qtrue;
+ return cTrue;
}
- return Qfalse;
+ return cFalse;
}
Object* Bignum::lt(STATE, Float* b) {
@@ -962,24 +962,24 @@ namespace rubinius {
int r = mp_cmp_d(&n, -bi);
mp_clear(&n);
if(r == MP_EQ || r == MP_GT) {
- return Qtrue;
+ return cTrue;
}
- return Qfalse;
+ return cFalse;
} else {
int r = mp_cmp_d(a, bi);
if(r == MP_EQ || r == MP_LT) {
- return Qtrue;
+ return cTrue;
}
- return Qfalse;
+ return cFalse;
}
}
Object* Bignum::le(STATE, Bignum* b) {
int r = mp_cmp(mp_val(), b->mp_val());
if(r == MP_LT || r == MP_EQ) {
- return Qtrue;
+ return cTrue;
}
- return Qfalse;
+ return cFalse;
}
Object* Bignum::le(STATE, Float* b) {
View
6 vm/builtin/block_environment.cpp
@@ -127,7 +127,7 @@ namespace rubinius {
Array* ary = 0;
if(!(ary = try_as<Array>(obj))) {
- if(CBOOL(obj->respond_to(state, state->symbol("to_ary"), Qfalse))) {
+ if(CBOOL(obj->respond_to(state, state->symbol("to_ary"), cFalse))) {
obj = obj->send(state, call_frame, state->symbol("to_ary"));
if(!(ary = try_as<Array>(obj))) {
Exception::type_error(state, "to_ary must return an Array", call_frame);
@@ -444,7 +444,7 @@ namespace rubinius {
// inlinable so that this works even with the JIT on.
if(!target) {
- return Qnil;
+ return cNil;
}
target->cm->backend_method()->set_no_inline();
@@ -453,7 +453,7 @@ namespace rubinius {
return target->scope->block();
}
- return Qnil;
+ return cNil;
}
void BlockEnvironment::Info::show(STATE, Object* self, int level) {
View
4 vm/builtin/bytearray.cpp
@@ -224,7 +224,7 @@ namespace rubinius {
native_int max = max_o->to_native();
if(len == 0) return start;
- if(max == 0) return Qnil;
+ if(max == 0) return cNil;
if(max > size()) max = size();
max -= (len - 1);
@@ -243,7 +243,7 @@ namespace rubinius {
}
}
- return Qnil;
+ return cNil;
}
// Ripped from 1.8.7 and cleaned up
View
2 vm/builtin/bytearray.hpp
@@ -62,7 +62,7 @@ namespace rubinius {
/* ::locate searches for +pattern+ in the ByteArray. Returns the
* number of characters from the front of the ByteArray to the end
- * of the pattern if a match is found. Returns Qnil if a match is
+ * of the pattern if a match is found. Returns cNil if a match is
* not found. Starts searching at index +start+.
*/
View
6 vm/builtin/call_unit.cpp
@@ -97,13 +97,13 @@ namespace rubinius {
} else if(unit->which_ < (int)args.total()) {
obj = args.get_argument(unit->which_);
} else {
- return Qfalse;
+ return cFalse;
}
if(Module* mod = try_as<Module>(unit->value())) {
- return obj->kind_of_p(state, mod) ? Qtrue : Qfalse;
+ return obj->kind_of_p(state, mod) ? cTrue : cFalse;
} else {
- return Qfalse;
+ return cFalse;
}
}
}
View
18 vm/builtin/channel.cpp
@@ -77,7 +77,7 @@ namespace rubinius {
} else {
if(self->semaphore_count_ > 0) {
for(int i = 0; i < self->semaphore_count_; i++) {
- self->value_->append(state, Qnil);
+ self->value_->append(state, cNil);
}
self->semaphore_count_ = 0;
}
@@ -89,7 +89,7 @@ namespace rubinius {
self->condition_.signal();
}
- return Qnil;
+ return cNil;
}
Object* Channel::try_receive(STATE, GCToken gct) {
@@ -100,15 +100,15 @@ namespace rubinius {
if(self->semaphore_count_ > 0) {
self->semaphore_count_--;
- return Qnil;
+ return cNil;
}
- if(self->value_->empty_p()) return Qnil;
+ if(self->value_->empty_p()) return cNil;
return self->value_->shift(state);
}
Object* Channel::receive(STATE, GCToken gct, CallFrame* call_frame) {
- return receive_timeout(state, gct, Qnil, call_frame);
+ return receive_timeout(state, gct, cNil, call_frame);
}
#define NANOSECONDS 1000000000
@@ -129,7 +129,7 @@ namespace rubinius {
if(self->semaphore_count_ > 0) {
self->semaphore_count_--;
- return Qnil;
+ return cNil;
}
if(!self->value_->empty_p()) return self->value_->shift(state);
@@ -196,7 +196,7 @@ namespace rubinius {
}
state->vm()->clear_waiter();
- state->vm()->thread->sleep(state, Qfalse);
+ state->vm()->thread->sleep(state, cFalse);
self->unpin();
self->waiters_--;
@@ -205,11 +205,11 @@ namespace rubinius {
if(self->semaphore_count_ > 0) {
self->semaphore_count_--;
- return Qnil;
+ return cNil;
}
// We were awoken, but there is no value to use. Return false.
- if(self->value()->empty_p()) return Qfalse;
+ if(self->value()->empty_p()) return cFalse;
return self->value()->shift(state);
}
View
10 vm/builtin/class.cpp
@@ -91,7 +91,7 @@ namespace rubinius {
for(size_t i = 0; i < size - sizeof(ObjectHeader);
i += sizeof(Object*)) {
Object** pos = reinterpret_cast<Object**>(body + i);
- *pos = Qundef;
+ *pos = cUndef;
}
return obj;
@@ -127,7 +127,7 @@ namespace rubinius {
for(size_t i = 0; i < size - sizeof(ObjectHeader);
i += sizeof(Object*)) {
Object** pos = reinterpret_cast<Object**>(body + i);
- *pos = Qundef;
+ *pos = cUndef;
}
return obj;
@@ -145,7 +145,7 @@ namespace rubinius {
return new_obj;
} else if(!type_info_->allow_user_allocate || kind_of<SingletonClass>(this)) {
Exception::type_error(state, "direct allocation disabled");
- return Qnil;
+ return cNil;
} else if(type_info_->type == Object::type) {
// transition all normal object classes to PackedObject
Class* self = this;
@@ -186,7 +186,7 @@ namespace rubinius {
Object* Class::set_superclass(STATE, Object* obj) {
if(obj->nil_p()) {
superclass(state, nil<Class>());
- return Qnil;
+ return cNil;
}
Class* sup;
@@ -209,7 +209,7 @@ namespace rubinius {
SingletonClass::attach(state, this, sup->singleton_class(state));
- return Qnil;
+ return cNil;
}
void Class::set_object_type(STATE, size_t type) {
View
16 vm/builtin/compactlookuptable.cpp
@@ -41,22 +41,22 @@ namespace rubinius {
}
}
- return Qnil;
+ return cNil;
}
Object* CompactLookupTable::remove(STATE, Object* key, bool* removed) {
for(unsigned int i = 0; i < COMPACTLOOKUPTABLE_SIZE; i += 2) {
if(at(state, i) == key) {
Object* val = at(state, i + 1);
- put(state, i, Qnil);
- put(state, i + 1, Qnil);
+ put(state, i, cNil);
+ put(state, i + 1, cNil);
if(removed) *removed = true;
return val;
}
}
- return Qnil;
+ return cNil;
}
Object* CompactLookupTable::store(STATE, Object* key, Object* val) {
@@ -65,19 +65,19 @@ namespace rubinius {
if(tmp == key || tmp->nil_p()) {
put(state, i, key);
put(state, i + 1, val);
- return Qtrue;
+ return cTrue;
}
}
- return Qfalse;
+ return cFalse;
}
Object* CompactLookupTable::has_key(STATE, Object* key) {
for(unsigned int i = 0; i < COMPACTLOOKUPTABLE_SIZE; i += 2) {
- if(at(state, i) == key) return Qtrue;
+ if(at(state, i) == key) return cTrue;
}
- return Qfalse;
+ return cFalse;
}
Array* CompactLookupTable::keys(STATE) {
View
12 vm/builtin/compiledmethod.cpp
@@ -159,7 +159,7 @@ namespace rubinius {
// TODO fix me to raise an exception
assert(0);
- return Qnil;
+ return cNil;
}
void CompiledMethod::specialize(STATE, TypeInfo* ti) {
@@ -346,20 +346,20 @@ namespace rubinius {
}
}
- return removed ? Qtrue : Qfalse;
+ return removed ? cTrue : cFalse;
}
Object* CompiledMethod::is_breakpoint(STATE, Fixnum* ip) {
int i = ip->to_native();
- if(backend_method_ == NULL) return Qfalse;
+ if(backend_method_ == NULL) return cFalse;
if(!backend_method_->validate_ip(state, i)) return Primitives::failure();
- if(breakpoints_->nil_p()) return Qfalse;
+ if(breakpoints_->nil_p()) return cFalse;
bool found = false;
breakpoints_->fetch(state, ip, &found);
- if(found) return Qtrue;
- return Qfalse;
+ if(found) return cTrue;
+ return cFalse;
}
CompiledMethod* CompiledMethod::of_sender(STATE, CallFrame* calling_environment) {
View
14 vm/builtin/dir.cpp
@@ -65,7 +65,7 @@ namespace rubinius {
this->path(state, path);
- return Qtrue;
+ return cTrue;
}
Object* Dir::close(STATE) {
@@ -76,19 +76,19 @@ namespace rubinius {
os_ = 0;
}
- return Qnil;
+ return cNil;
}
Object* Dir::closed_p(STATE) {
- return os_ ? Qfalse : Qtrue;
+ return os_ ? cFalse : cTrue;
}
Object* Dir::read(STATE) {
guard(state);
struct dirent *ent = readdir(os_);
- if(!ent) return Qnil;
+ if(!ent) return cNil;
return String::create(state, ent->d_name);
}
@@ -99,13 +99,13 @@ namespace rubinius {
switch(kind->to_native()) {
case 0:
seekdir(os_, pos->to_native());
- return Qtrue;
+ return cTrue;
case 1:
rewinddir(os_);
- return Qtrue;
+ return cTrue;
case 2:
return Integer::from(state, telldir(os_));
}
- return Qnil;
+ return cNil;
}
}
View
10 vm/builtin/encoding.cpp
@@ -94,13 +94,13 @@ namespace rubinius {
static Tuple* encoding_reference(STATE, int index, const char* alias_name = 0) {
Tuple* pair = Tuple::create(state, 2);
if(!alias_name) {
- pair->put(state, 0, Qnil);
+ pair->put(state, 0, cNil);
} else {
pair->put(state, 0, String::create(state, alias_name));
}
if(index < 0) {
- pair->put(state, 1, Qnil);
+ pair->put(state, 1, cNil);
} else {
pair->put(state, 1, Fixnum::from(index));
}
@@ -153,7 +153,7 @@ namespace rubinius {
}
Encoding* Encoding::define_dummy(STATE, const char* name) {
- return define(state, name, ONIG_ENCODING_ASCII, Qtrue);
+ return define(state, name, ONIG_ENCODING_ASCII, cTrue);
}
Encoding* Encoding::replicate(STATE, const char* name, const char* original) {
@@ -308,8 +308,8 @@ namespace rubinius {
}
Object* Encoding::ascii_compatible_p(STATE) {
- bool v = encoding_->min_enc_len == 1 && dummy_ == Qfalse;
- return v ? Qtrue : Qfalse;
+ bool v = encoding_->min_enc_len == 1 && dummy_ == cFalse;
+ return v ? cTrue : cFalse;
}
void Encoding::Info::show(STATE, Object* self, int level) {
View
4 vm/builtin/encoding.hpp
@@ -51,10 +51,10 @@ namespace rubinius {
static Encoding* create_bootstrap(STATE, const char* name,
Index index, OnigEncodingType* enc);
static void create_internal(STATE, const char* name, int index);
- static Encoding* create(STATE, OnigEncodingType* enc, Object* dummy = Qfalse);
+ static Encoding* create(STATE, OnigEncodingType* enc, Object* dummy = cFalse);
static Encoding* define(STATE, const char* name, OnigEncodingType* enc,
- Object* dummy = Qfalse);
+ Object* dummy = cFalse);
static Encoding* define_dummy(STATE, const char* name);
static Encoding* replicate(STATE, const char* name, const char* original);
static Encoding* alias(STATE, const char* name, const char* original);
View
2 vm/builtin/exception.cpp
@@ -249,7 +249,7 @@ namespace rubinius {
/* exception_errno_error primitive */
Object* Exception::errno_error(STATE, Object* reason, Fixnum* ern) {
Class* exc_class = get_errno_error(state, ern);
- if(exc_class->nil_p()) return Qnil;
+ if(exc_class->nil_p()) return cNil;
return make_errno_exception(state, exc_class, reason);
}
View
8 vm/builtin/executable.cpp
@@ -70,14 +70,14 @@ namespace rubinius {
}
void Executable::add_inliner(ObjectMemory* om, CompiledMethod* cm) {
- if(!inliners_ || inliners_ == (Inliners*)Qnil) inliners_ = new Inliners;
+ if(!inliners_ || inliners_ == (Inliners*)cNil) inliners_ = new Inliners;
inliners_->inliners().push_back(cm);
om->write_barrier(this, cm);
}
void Executable::clear_inliners(STATE) {
- if(!inliners_ || inliners_ == (Inliners*)Qnil) return;
+ if(!inliners_ || inliners_ == (Inliners*)cNil) return;
for(std::list<CompiledMethod*>::const_iterator i = inliners_->inliners().begin();
i != inliners_->inliners().end();
++i) {
@@ -94,7 +94,7 @@ namespace rubinius {
void Executable::Info::mark_inliners(Object* obj, ObjectMark& mark) {
Executable* exc = (Executable*)obj;
- if(!exc->inliners_ || exc->inliners_ == (Inliners*)Qnil) return;
+ if(!exc->inliners_ || exc->inliners_ == (Inliners*)cNil) return;
if(exc->inliners_) {
Inliners* inl = exc->inliners_;
@@ -123,7 +123,7 @@ namespace rubinius {
void Executable::Info::visit_inliners(Object* obj, ObjectVisitor& visit) {
Executable* exc = (Executable*)obj;
- if(!exc->inliners_ || exc->inliners_ == (Inliners*)Qnil) return;
+ if(!exc->inliners_ || exc->inliners_ == (Inliners*)cNil) return;
if(exc->inliners_) {
for(std::list<CompiledMethod*>::iterator i = exc->inliners_->inliners().begin();
View
26 vm/builtin/ffi_pointer.cpp
@@ -292,7 +292,7 @@ namespace rubinius {
ret = Fixnum::from((unsigned int)(READ(unsigned char)));
break;
case RBX_FFI_TYPE_BOOL:
- ret = (READ(unsigned char)) ? Qtrue : Qfalse;
+ ret = (READ(unsigned char)) ? cTrue : cFalse;
break;
case RBX_FFI_TYPE_SHORT:
ret = Fixnum::from((int)(READ(short)));
@@ -330,7 +330,7 @@ namespace rubinius {
case RBX_FFI_TYPE_PTR: {
void *lptr = READ(void*);
if(!lptr) {
- ret = Qnil;
+ ret = cNil;
} else {
ret = Pointer::create(state, lptr);
}
@@ -339,7 +339,7 @@ namespace rubinius {
case RBX_FFI_TYPE_STRING: {
char* result = READ(char*);
if(result == NULL) {
- ret = Qnil;
+ ret = cNil;
} else {
ret = String::create(state, result);
}
@@ -353,7 +353,7 @@ namespace rubinius {
result = READ(char*);
if(result == NULL) {
- s = p = Qnil;
+ s = p = cNil;
} else {
s = String::create(state, result);
p = Pointer::create(state, result);
@@ -367,7 +367,7 @@ namespace rubinius {
}
default:
case RBX_FFI_TYPE_VOID:
- ret = Qnil;
+ ret = cNil;
break;
}
@@ -407,31 +407,31 @@ namespace rubinius {
WRITE(unsigned short, as<Fixnum>(val)->to_native());
break;
case RBX_FFI_TYPE_INT:
- if(FIXNUM_P(val)) {
+ if(val->fixnum_p()) {
WRITE(int, as<Fixnum>(val)->to_int());
} else {
type_assert(state, val, BignumType, "converting to int");
WRITE(int, as<Bignum>(val)->to_int());
}
break;
case RBX_FFI_TYPE_UINT:
- if(FIXNUM_P(val)) {
+ if(val->fixnum_p()) {
WRITE(unsigned int, as<Fixnum>(val)->to_uint());
} else {
type_assert(state, val, BignumType, "converting to unsigned int");
WRITE(unsigned int, as<Bignum>(val)->to_uint());
}
break;
case RBX_FFI_TYPE_LONG:
- if(FIXNUM_P(val)) {
+ if(val->fixnum_p()) {
WRITE(long, as<Fixnum>(val)->to_long());
} else {
type_assert(state, val, BignumType, "converting to long");
WRITE(long, as<Bignum>(val)->to_long());
}
break;
case RBX_FFI_TYPE_ULONG:
- if(FIXNUM_P(val)) {
+ if(val->fixnum_p()) {
WRITE(unsigned long, as<Fixnum>(val)->to_ulong());
} else {
type_assert(state, val, BignumType, "converting to unsigned long");
@@ -451,15 +451,15 @@ namespace rubinius {
break;
}
case RBX_FFI_TYPE_LONG_LONG:
- if(FIXNUM_P(val)) {
+ if(val->fixnum_p()) {
WRITE(long long, as<Fixnum>(val)->to_long_long());
} else {
type_assert(state, val, BignumType, "converting to long long");
WRITE(long long, as<Bignum>(val)->to_long_long());
}
break;
case RBX_FFI_TYPE_ULONG_LONG:
- if(FIXNUM_P(val)) {
+ if(val->fixnum_p()) {
WRITE(unsigned long long, as<Fixnum>(val)->to_ulong_long());
} else {
type_assert(state, val, BignumType, "converting to unsigned long long");
@@ -470,7 +470,7 @@ namespace rubinius {
WRITE(Object*, val);
break;
case RBX_FFI_TYPE_PTR:
- if(NIL_P(val)) {
+ if(val->nil_p()) {
WRITE(void*, NULL);
} else {
Pointer *mp = as<Pointer>(val);
@@ -480,7 +480,7 @@ namespace rubinius {
break;
case RBX_FFI_TYPE_STRING: {
const char* result;
- if(NIL_P(val)) {
+ if(val->nil_p()) {
result = NULL;
} else {
String* str = as<String>(val);
View
20 vm/builtin/fiber.cpp
@@ -27,9 +27,9 @@ namespace rubinius {
G(fiber)->set_object_type(state, FiberType);
#ifdef FIBER_ENABLED
- G(fiber)->set_const(state, "ENABLED", Qtrue);
+ G(fiber)->set_const(state, "ENABLED", cTrue);
#else
- G(fiber)->set_const(state, "ENABLED", Qfalse);
+ G(fiber)->set_const(state, "ENABLED", cFalse);
#endif
}
@@ -71,12 +71,12 @@ namespace rubinius {
OnStack<1> os(&state, fib);
Array* result = nil<Array>();
- Object* obj = fib->starter()->send(&state, NULL, state.globals().sym_call.get(), fib->value(), Qnil, false);
+ Object* obj = fib->starter()->send(&state, NULL, state.globals().sym_call.get(), fib->value(), cNil, false);
// GC has run! Don't use stack vars!
fib = Fiber::current(&state);
fib->status_ = Fiber::eDead;
- fib->set_ivar(&state, state.symbol("@dead"), Qtrue);
+ fib->set_ivar(&state, state.symbol("@dead"), cTrue);
Fiber* dest = fib->prev();
assert(!dest->nil_p());
@@ -177,10 +177,10 @@ namespace rubinius {
Array* ret = cur->value();
- if(ret->nil_p()) return Qnil;
+ if(ret->nil_p()) return cNil;
switch(ret->size()) {
- case 0: return Qnil;
+ case 0: return cNil;
case 1: return ret->get(state, 0);
default: return ret;
}
@@ -233,10 +233,10 @@ namespace rubinius {
Array* ret = cur->value();
- if(ret->nil_p()) return Qnil;
+ if(ret->nil_p()) return cNil;
switch(ret->size()) {
- case 0: return Qnil;
+ case 0: return cNil;
case 1: return ret->get(state, 0);
default: return ret;
}
@@ -276,10 +276,10 @@ namespace rubinius {
Array* ret = cur->value();
- if(ret->nil_p()) return Qnil;
+ if(ret->nil_p()) return cNil;
switch(ret->size()) {
- case 0: return Qnil;
+ case 0: return cNil;
case 1: return ret->get(state, 0);
default: return ret;
}
View
10 vm/builtin/find_object.cpp
@@ -105,7 +105,7 @@ namespace rubinius {
Object* obj = reinterpret_cast<Object*>(id >> 1);
// Be sure to not leak a bad reference leak out here.
- if(obj->reference_p()) return Qnil;
+ if(obj->reference_p()) return cNil;
return obj;
}
@@ -139,7 +139,7 @@ namespace rubinius {
{}
virtual bool perform(STATE, Object* obj) {
- return obj->respond_to(state, name_, Qtrue)->true_p();
+ return obj->respond_to(state, name_, cTrue)->true_p();
}
};
@@ -274,7 +274,7 @@ namespace rubinius {
QueryCondition* condition = create_condition(state, arg);
if(!condition) return Fixnum::from(0);
- Object* ret = Qnil;
+ Object* ret = cNil;
// Special case for looking for an object_id of an immediate
if(ObjectIdCondition* oic = dynamic_cast<ObjectIdCondition*>(condition)) {
@@ -284,7 +284,7 @@ namespace rubinius {
} else {
args->set(state, 0, obj);
ret = callable->send(state, calling_environment, G(sym_call),
- args, Qnil, false);
+ args, cNil, false);
}
delete condition;
@@ -316,7 +316,7 @@ namespace rubinius {
} else {
args->set(state, 0, obj);
ret = callable->send(state, calling_environment, G(sym_call),
- args, Qnil, false);
+ args, cNil, false);
if(!ret) break;
}
}
View
16 vm/builtin/fixnum.cpp
@@ -243,15 +243,15 @@ namespace rubinius {
}
Object* Fixnum::equal(STATE, Fixnum* other) {
- return to_native() == other->to_native() ? Qtrue : Qfalse;
+ return to_native() == other->to_native() ? cTrue : cFalse;
}
Object* Fixnum::equal(STATE, Bignum* other) {
return other->equal(state, this);
}
Object* Fixnum::equal(STATE, Float* other) {
- return (double)to_native() == other->val ? Qtrue : Qfalse;
+ return (double)to_native() == other->val ? cTrue : cFalse;
}
Object* Fixnum::compare(STATE, Fixnum* other) {
@@ -294,39 +294,39 @@ namespace rubinius {
}
Object* Fixnum::gt(STATE, Float* other) {
- return (double) to_native() > other->val ? Qtrue : Qfalse;
+ return (double) to_native() > other->val ? cTrue : cFalse;
}
Object* Fixnum::ge(STATE, Fixnum* other) {
- return to_native() >= other->to_native() ? Qtrue : Qfalse;
+ return to_native() >= other->to_native() ? cTrue : cFalse;
}
Object* Fixnum::ge(STATE, Bignum* other) {
return other->le(state, this);
}
Object* Fixnum::ge(STATE, Float* other) {
- return (double) to_native() >= other->val ? Qtrue : Qfalse;
+ return (double) to_native() >= other->val ? cTrue : cFalse;
}
Object* Fixnum::lt(STATE, Bignum* other) {
return other->gt(state, this);
}
Object* Fixnum::lt(STATE, Float* other) {
- return (double) to_native() < other->val ? Qtrue : Qfalse;
+ return (double) to_native() < other->val ? cTrue : cFalse;
}
Object* Fixnum::le(STATE, Fixnum* other) {
- return to_native() <= other->to_native() ? Qtrue : Qfalse;
+ return to_native() <= other->to_native() ? cTrue : cFalse;
}
Object* Fixnum::le(STATE, Bignum* other) {
return other->ge(state, this);
}
Object* Fixnum::le(STATE, Float* other) {
- return (double) to_native() <= other->val ? Qtrue : Qfalse;
+ return (double) to_native() <= other->val ? cTrue : cFalse;
}
Integer* Fixnum::left_shift(STATE, Fixnum* bits) {
View
6 vm/builtin/fixnum.hpp
@@ -36,7 +36,7 @@ namespace rubinius {
// Rubinius.primitive :fixnum_s_eqq
static Object* is_fixnum(STATE, Object* obj) {
- return obj->fixnum_p() ? Qtrue : Qfalse;
+ return obj->fixnum_p() ? cTrue : cFalse;
}
// Rubinius.primitive! :fixnum_add
@@ -136,7 +136,7 @@ namespace rubinius {
// Rubinius.primitive! :fixnum_gt
Object* gt(STATE, Fixnum* other) {
- return to_native() > other->to_native() ? Qtrue : Qfalse;
+ return to_native() > other->to_native() ? cTrue : cFalse;
}
// Rubinius.primitive! :fixnum_gt
@@ -156,7 +156,7 @@ namespace rubinius {
// Rubinius.primitive! :fixnum_lt
Object* lt(STATE, Fixnum* other) {
- return to_native() < other->to_native() ? Qtrue : Qfalse;
+ return to_native() < other->to_native() ? cTrue : cFalse;
}
// Rubinius.primitive! :fixnum_lt
View
40 vm/builtin/float.cpp
@@ -152,28 +152,28 @@ namespace rubinius {
Object* Float::equal(STATE, Float* other) {
if(this->val == other->val) {
- return Qtrue;
+ return cTrue;
}
- return Qfalse;
+ return cFalse;
}
Object* Float::equal(STATE, Integer* other) {
Float* o = Float::coerce(state, other);
if(this->val == o->val) {
- return Qtrue;
+ return cTrue;
}
- return Qfalse;
+ return cFalse;
}
Object* Float::eql(STATE, Float* other) {
if(this->val == other->val) {
- return Qtrue;
+ return cTrue;
}
- return Qfalse;
+ return cFalse;
}
Object* Float::eql(STATE, Integer* other) {
- return Qfalse;
+ return cFalse;
}
Object* Float::compare(STATE, Float* other) {
@@ -184,7 +184,7 @@ namespace rubinius {
} else if(this->val < other->val){
return Fixnum::from(-1);
} else {
- return Qnil;
+ return cNil;
}
}
@@ -204,52 +204,52 @@ namespace rubinius {
} else if(this->val < o->val){
return Fixnum::from(-1);
} else {
- return Qnil;
+ return cNil;
}
}
Object* Float::gt(STATE, Float* other) {
- return this->val > other->val ? Qtrue : Qfalse;
+ return this->val > other->val ? cTrue : cFalse;
}
Object* Float::gt(STATE, Integer* other) {
- return this->val > Float::coerce(state, other)->val ? Qtrue : Qfalse;
+ return this->val > Float::coerce(state, other)->val ? cTrue : cFalse;
}
Object* Float::ge(STATE, Float* other) {
- return this->val >= other->val ? Qtrue : Qfalse;
+ return this->val >= other->val ? cTrue : cFalse;
}
Object* Float::ge(STATE, Integer* other) {
- return this->val >= Float::coerce(state, other)->val ? Qtrue : Qfalse;
+ return this->val >= Float::coerce(state, other)->val ? cTrue : cFalse;
}
Object* Float::lt(STATE, Float* other) {
- return this->val < other->val ? Qtrue : Qfalse;
+ return this->val < other->val ? cTrue : cFalse;
}
Object* Float::lt(STATE, Integer* other) {
- return this->val < Float::coerce(state, other)->val ? Qtrue : Qfalse;
+ return this->val < Float::coerce(state, other)->val ? cTrue : cFalse;
}
Object* Float::le(STATE, Float* other) {
- return this->val <= other->val ? Qtrue : Qfalse;
+ return this->val <= other->val ? cTrue : cFalse;
}
Object* Float::le(STATE, Integer* other) {
- return this->val <= Float::coerce(state, other)->val ? Qtrue : Qfalse;
+ return this->val <= Float::coerce(state, other)->val ? cTrue : cFalse;
}
Object* Float::fisinf(STATE) {
if(isinf(this->val) != 0) {
return this->val < 0 ? Fixnum::from(-1) : Fixnum::from(1);
} else {
- return Qnil;
+ return cNil;
}
}
Object* Float::fisnan(STATE) {
- return isnan(this->val) == 1 ? Qtrue : Qfalse;
+ return isnan(this->val) == 1 ? cTrue : cFalse;
}
Integer* Float::fround(STATE) {
@@ -311,7 +311,7 @@ namespace rubinius {
char str[sizeof(double)];
int sz;
- if (want_double == Qtrue) {
+ if (want_double == cTrue) {
double* p = (double *)str;
*p = this->val;
sz = 8;
View
4 vm/builtin/heap_dump.cpp
@@ -387,7 +387,7 @@ namespace rubinius {
walker.seed(gc_data);
int fd = open(path->c_str(state), O_CREAT | O_TRUNC | O_WRONLY, 0666);
- if(fd < 0) return Qnil;
+ if(fd < 0) return cNil;
HeapDump dump(fd);
@@ -405,6 +405,6 @@ namespace rubinius {
std::cout << "Heap dumped to " << path->c_str(state) << "\n";
close(fd);
- return Qnil;
+ return cNil;
}
}
View
12 vm/builtin/integer.cpp
@@ -123,7 +123,7 @@ namespace rubinius {
// Skip any combination of leading whitespace and underscores.
// Leading whitespace is OK in strict mode, but underscores are not.
while(isspace(*str) || *str == '_') {
- if(*str == '_' && strict == Qtrue) {
+ if(*str == '_' && strict == cTrue) {
return nil<Integer>();
} else {
str++;
@@ -223,7 +223,7 @@ namespace rubinius {
// If there is more stuff after the spaces, get out of dodge.
if(chr) {
- if(strict == Qtrue) {
+ if(strict == cTrue) {
return nil<Integer>();
} else {
goto return_value;
@@ -238,7 +238,7 @@ namespace rubinius {
if(chr == '_') {
if(underscore) {
// Double underscore is forbidden in strict mode.
- if(strict == Qtrue) {
+ if(strict == cTrue) {
return nil<Integer>();
} else {
// Stop parse number after two underscores in a row
@@ -260,7 +260,7 @@ namespace rubinius {
chr -= ('a' - 10);
} else {
//Invalid character, stopping right here.
- if(strict == Qtrue) {
+ if(strict == cTrue) {
return nil<Integer>();
} else {
break;
@@ -270,7 +270,7 @@ namespace rubinius {
// Bail if the current chr is greater or equal to the base,
// mean it's invalid.
if(chr >= base) {
- if(strict == Qtrue) {
+ if(strict == cTrue) {
return nil<Integer>();
} else {
break;
@@ -293,7 +293,7 @@ namespace rubinius {
}
// If we last saw an underscore and we're strict, bail.
- if(underscore && strict == Qtrue) {
+ if(underscore && strict == cTrue) {
return nil<Integer>();
}
View
70 vm/builtin/io.cpp
@@ -73,7 +73,7 @@ namespace rubinius {
}
io->ibuffer(state, IOBuffer::create(state));
- io->eof(state, Qfalse);
+ io->eof(state, cFalse);
io->lineno(state, Fixnum::from(0));
// Don't bother to add finalization for stdio
@@ -89,7 +89,7 @@ namespace rubinius {
io->descriptor(state, nil<Fixnum>());
io->mode(state, nil<Fixnum>());
io->ibuffer(state, IOBuffer::create(state));
- io->eof(state, Qfalse);
+ io->eof(state, cFalse);
io->lineno(state, Fixnum::from(0));
// Ensure the instance's class is set (i.e. for subclasses of IO)
@@ -228,7 +228,7 @@ namespace rubinius {
/* And the main event, pun intended */
retry:
state->vm()->interrupt_with_signal();
- state->vm()->thread->sleep(state, Qtrue);
+ state->vm()->thread->sleep(state, cTrue);
{
GCIndependent guard(state, calling_environment);
@@ -238,7 +238,7 @@ namespace rubinius {
maybe_limit);
}
- state->vm()->thread->sleep(state, Qfalse);
+ state->vm()->thread->sleep(state, cFalse);
state->vm()->clear_waiter();
if(events == -1) {
@@ -260,7 +260,7 @@ namespace rubinius {
}
/* Timeout expired */
- if(events == 0) return Qnil;
+ if(events == 0) return cNil;
/* Build the results. */
Array* output = Array::create(state, 3);
@@ -290,7 +290,7 @@ namespace rubinius {
ibuf->reset(state);
}
- return Qtrue;
+ return cTrue;
}
Object* IO::reopen_path(STATE, String* path, Fixnum* mode) {
@@ -317,7 +317,7 @@ namespace rubinius {
ibuf->reset(state);
}
- return Qtrue;
+ return cTrue;
}
Object* IO::ensure_open(STATE) {
@@ -331,7 +331,7 @@ namespace rubinius {
Exception::io_error(state, "shutdown stream");
}
- return Qnil;
+ return cNil;
}
Object* IO::connect_pipe(STATE, IO* lhs, IO* rhs) {
@@ -345,7 +345,7 @@ namespace rubinius {
lhs->mode(state, Fixnum::from(O_RDONLY));
rhs->mode(state, Fixnum::from(O_WRONLY));
- return Qtrue;
+ return cTrue;
}
Integer* IO::seek(STATE, Integer* amount, Fixnum* whence) {
@@ -376,7 +376,7 @@ namespace rubinius {
// Already closed, ignore.
if(desc == -1) {
- return Qnil;
+ return cNil;
}
// Invalid descriptor no matter what.
@@ -392,7 +392,7 @@ namespace rubinius {
if(!hdl->rio_close()) {
Exception::errno_error(state);
}
- return Qnil;
+ return cNil;
}
}
@@ -410,7 +410,7 @@ namespace rubinius {
Exception::system_call_error(state, message.str());
}
- return Qnil;
+ return cNil;
}
/**
@@ -551,14 +551,14 @@ namespace rubinius {
retry:
state->vm()->interrupt_with_signal();
- state->vm()->thread->sleep(state, Qtrue);
+ state->vm()->thread->sleep(state, cTrue);
{
GCIndependent guard(state, calling_environment);
bytes_read = ::read(fd, buffer->byte_address(), count);
}
- state->vm()->thread->sleep(state, Qfalse);
+ state->vm()->thread->sleep(state, cFalse);
state->vm()->clear_waiter();
if(bytes_read == -1) {
@@ -577,7 +577,7 @@ namespace rubinius {
buffer->unpin();
if(bytes_read == 0) {
- return Qnil;
+ return cNil;
}
buffer->num_bytes(state, Fixnum::from(bytes_read));
@@ -620,7 +620,7 @@ namespace rubinius {
Exception::errno_error(state, "read(2) failed");
}
- if(bytes_read == 0) return Qnil;
+ if(bytes_read == 0) return cNil;
buffer->num_bytes(state, Fixnum::from(bytes_read));
return buffer;
@@ -701,7 +701,7 @@ namespace rubinius {
if(cnt == -1) {
Exception::errno_error(state);
} else if(cnt == 0) {
- return Qnil;
+ return cNil;
}
str->num_bytes(state, Fixnum::from(cnt));
@@ -795,7 +795,7 @@ namespace rubinius {
retry:
state->vm()->interrupt_with_signal();
- state->vm()->thread->sleep(state, Qtrue);
+ state->vm()->thread->sleep(state, cTrue);
{
GCIndependent guard(state, calling_environment);
@@ -805,7 +805,7 @@ namespace rubinius {
(struct sockaddr*)buf, &alen);
}
- state->vm()->thread->sleep(state, Qfalse);
+ state->vm()->thread->sleep(state, cFalse);
state->vm()->clear_waiter();
buffer->unpin();
@@ -834,7 +834,7 @@ namespace rubinius {
if(alen && alen != sizeof(buf)) {
ary->set(state, 1, ipaddr(state, (struct sockaddr*)buf, alen));
} else {
- ary->set(state, 1, Qnil);
+ ary->set(state, 1, cNil);
}
break;
#ifndef RBX_WINDOWS
@@ -855,14 +855,14 @@ namespace rubinius {
native_int fd = to_fd();
if(op == state->symbol("tty?")) {
- return isatty(fd) ? Qtrue : Qfalse;
+ return isatty(fd) ? cTrue : cFalse;
#ifndef RBX_WINDOWS
} else if(op == state->symbol("ttyname")) {
return String::create(state, ttyname(fd));
#endif
}
- return Qnil;
+ return cNil;
}
// Stole/ported from 1.8.7. The system fnmatch doesn't support
@@ -1049,10 +1049,10 @@ namespace rubinius {
Object* IO::fnmatch(STATE, String* pattern, String* path, Fixnum* flags) {
if(mri_fnmatch(pattern->c_str(state), path->c_str(state), flags->to_native())) {
- return Qtrue;
+ return cTrue;
}
- return Qfalse;
+ return cFalse;
}
@@ -1067,15 +1067,15 @@ namespace rubinius {
retry:
state->vm()->interrupt_with_signal();
- state->vm()->thread->sleep(state, Qtrue);
+ state->vm()->thread->sleep(state, cTrue);
{
GCIndependent guard(state, calling_environment);
new_fd = ::accept(fd, (struct sockaddr*)&socka, &sock_len);
set = true;
}
- state->vm()->thread->sleep(state, Qfalse);
+ state->vm()->thread->sleep(state, cFalse);
state->vm()->clear_waiter();
if(new_fd == -1) {
@@ -1088,7 +1088,7 @@ namespace rubinius {
return NULL;
}
- if(!set) return Qnil;
+ if(!set) return cNil;
return Fixnum::from(new_fd);
}
@@ -1134,7 +1134,7 @@ namespace rubinius {
return Primitives::failure();
}
- return Qnil;
+ return cNil;
#endif
}
@@ -1179,14 +1179,14 @@ namespace rubinius {
retry:
state->vm()->interrupt_with_signal();
- state->vm()->thread->sleep(state, Qtrue);
+ state->vm()->thread->sleep(state, cTrue);
{
GCIndependent guard(state);
code = recvmsg(read_fd, &msg, 0);
}
- state->vm()->thread->sleep(state, Qfalse);
+ state->vm()->thread->sleep(state, cFalse);
state->vm()->clear_waiter();
if(code == -1) {
@@ -1233,7 +1233,7 @@ namespace rubinius {
buf->total(state, Fixnum::from(bytes));
buf->used(state, Fixnum::from(0));
buf->reset(state);
- buf->write_synced(state, Qtrue);
+ buf->write_synced(state, cTrue);
return buf;
}
@@ -1243,7 +1243,7 @@ namespace rubinius {
}
Object* IOBuffer::unshift(STATE, String* str, Fixnum* start_pos) {
- write_synced(state, Qfalse);
+ write_synced(state, cFalse);
native_int start_pos_native = start_pos->to_native();
native_int str_size = str->byte_size();
native_int data_size = as<ByteArray>(str->data())->size();
@@ -1278,14 +1278,14 @@ namespace rubinius {
retry:
state->vm()->interrupt_with_signal();
- state->vm()->thread->sleep(state, Qtrue);
+ state->vm()->thread->sleep(state, cTrue);
{