Permalink
Browse files

API cleanup: move new_(class|module) out of VM

  • Loading branch information...
1 parent 1956797 commit 380797fc490da190e007c3104c266827a29e0781 @evanphx evanphx committed Nov 3, 2011
Showing with 257 additions and 156 deletions.
  1. +4 −1 vm/builtin/access_variable.cpp
  2. +4 −1 vm/builtin/alias.cpp
  3. +3 −1 vm/builtin/array.cpp
  4. +3 −1 vm/builtin/autoload.cpp
  5. +3 −1 vm/builtin/bignum.cpp
  6. +3 −1 vm/builtin/block_environment.cpp
  7. +4 −1 vm/builtin/bytearray.cpp
  8. +4 −1 vm/builtin/channel.cpp
  9. +4 −1 vm/builtin/chararray.cpp
  10. +3 −1 vm/builtin/compactlookuptable.cpp
  11. +4 −1 vm/builtin/compiledmethod.cpp
  12. +3 −1 vm/builtin/data.cpp
  13. +3 −1 vm/builtin/dir.cpp
  14. +4 −2 vm/builtin/encoding.cpp
  15. +3 −1 vm/builtin/exception.cpp
  16. +3 −1 vm/builtin/executable.cpp
  17. +3 −1 vm/builtin/ffi_pointer.cpp
  18. +3 −1 vm/builtin/fiber.cpp
  19. +3 −1 vm/builtin/fixnum.cpp
  20. +3 −1 vm/builtin/float.cpp
  21. +4 −1 vm/builtin/global_cache_entry.cpp
  22. +5 −2 vm/builtin/io.cpp
  23. +4 −1 vm/builtin/iseq.cpp
  24. +5 −2 vm/builtin/list.cpp
  25. +4 −1 vm/builtin/location.cpp
  26. +4 −3 vm/builtin/nativefunction.cpp
  27. +4 −1 vm/builtin/nativemethod.cpp
  28. +3 −1 vm/builtin/proc.cpp
  29. +4 −1 vm/builtin/randomizer.cpp
  30. +4 −2 vm/builtin/regexp.cpp
  31. +4 −1 vm/builtin/staticscope.cpp
  32. +3 −1 vm/builtin/string.cpp
  33. +3 −1 vm/builtin/symbol.cpp
  34. +3 −1 vm/builtin/thread.cpp
  35. +3 −1 vm/builtin/time.cpp
  36. +4 −1 vm/builtin/variable_scope.cpp
  37. +3 −1 vm/builtin/weakref.cpp
  38. +3 −1 vm/ffi.cpp
  39. +8 −15 vm/objectmemory.cpp
  40. +2 −0 vm/objectmemory.hpp
  41. +78 −27 vm/ontology.cpp
  42. +26 −0 vm/ontology.hpp
  43. +3 −1 vm/test/test_array.hpp
  44. +3 −1 vm/test/test_lookuptable.hpp
  45. +3 −1 vm/test/test_regexp.hpp
  46. +0 −49 vm/vm.cpp
  47. +0 −18 vm/vm.hpp
@@ -12,11 +12,14 @@
#include "dispatch.hpp"
#include "arguments.hpp"
+#include "ontology.hpp"
+
namespace rubinius {
void AccessVariable::init(STATE) {
// HACK test superclass of AccessVariable
- GO(access_variable).set(state->vm()->new_class("AccessVariable", G(executable), G(rubinius)));
+ GO(access_variable).set(ontology::new_class(state,
+ "AccessVariable", G(executable), G(rubinius)));
G(access_variable)->set_object_type(state, AccessVariableType);
G(access_variable)->name(state, state->symbol("Rubinius::AccessVariable"));
}
View
@@ -2,9 +2,12 @@
#include "builtin/class.hpp"
#include "builtin/exception.hpp"
+#include "ontology.hpp"
+
namespace rubinius {
void Alias::init(STATE) {
- GO(alias).set(state->vm()->new_class("Alias", G(executable), G(rubinius)));
+ GO(alias).set(ontology::new_class(state, "Alias",
+ G(executable), G(rubinius)));
G(alias)->set_object_type(state, AliasType);
}
View
@@ -12,6 +12,8 @@
#include "arguments.hpp"
#include "dispatch.hpp"
+#include "ontology.hpp"
+
#include <iostream>
#include <math.h>
@@ -23,7 +25,7 @@
namespace rubinius {
void Array::init(STATE) {
- GO(array).set(state->vm()->new_class("Array", G(object)));
+ GO(array).set(ontology::new_class(state, "Array", G(object)));
G(array)->set_object_type(state, ArrayType);
}
View
@@ -3,13 +3,15 @@
#include "builtin/class.hpp"
#include "builtin/autoload.hpp"
+#include "ontology.hpp"
+
namespace rubinius {
Autoload* Autoload::create(STATE) {
return state->new_object<Autoload>(G(autoload));
}
void Autoload::init(STATE) {
- GO(autoload).set(state->vm()->new_class("Autoload"));
+ GO(autoload).set(ontology::new_class(state, "Autoload"));
G(autoload)->set_object_type(state, AutoloadType);
}
View
@@ -18,6 +18,8 @@
#include "builtin/bytearray.hpp"
#include "configuration.hpp"
+#include "ontology.hpp"
+
#include "missing/math.h"
#define BASIC_CLASS(blah) G(blah)
@@ -193,7 +195,7 @@ namespace rubinius {
}
void Bignum::init(STATE) {
- GO(bignum).set(state->vm()->new_class("Bignum", G(integer)));
+ GO(bignum).set(ontology::new_class(state, "Bignum", G(integer)));
G(bignum)->set_object_type(state, BignumType);
}
@@ -27,6 +27,8 @@
#include "configuration.hpp"
#include "on_stack.hpp"
+#include "ontology.hpp"
+
#ifdef RBX_WINDOWS
#include <malloc.h>
#endif
@@ -40,7 +42,7 @@
namespace rubinius {
void BlockEnvironment::init(STATE) {
- GO(blokenv).set(state->vm()->new_class("BlockEnvironment", G(object),
+ GO(blokenv).set(ontology::new_class(state, "BlockEnvironment", G(object),
G(rubinius)));
G(blokenv)->set_object_type(state, BlockEnvironmentType);
G(blokenv)->name(state, state->symbol("Rubinius::BlockEnvironment"));
View
@@ -14,10 +14,13 @@
#include "object_utils.hpp"
+#include "ontology.hpp"
+
namespace rubinius {
void ByteArray::init(STATE) {
- GO(bytearray).set(state->vm()->new_class_under("ByteArray", G(rubinius)));
+ GO(bytearray).set(ontology::new_class_under(state,
+ "ByteArray", G(rubinius)));
G(bytearray)->set_object_type(state, ByteArrayType);
G(bytearray)->name(state, state->symbol("Rubinius::ByteArray"));
}
View
@@ -19,12 +19,15 @@
#include "on_stack.hpp"
+#include "ontology.hpp"
+
#include <sys/time.h>
namespace rubinius {
void Channel::init(STATE) {
- GO(channel).set(state->vm()->new_class("Channel", G(object), G(rubinius)));
+ GO(channel).set(ontology::new_class(state, "Channel",
+ G(object), G(rubinius)));
G(channel)->set_object_type(state, Channel::type);
G(channel)->name(state, state->symbol("Rubinius::Channel"));
}
View
@@ -14,10 +14,13 @@
#include "object_utils.hpp"
+#include "ontology.hpp"
+
namespace rubinius {
void CharArray::init(STATE) {
- GO(chararray).set(state->vm()->new_class_under("CharArray", G(rubinius)));
+ GO(chararray).set(ontology::new_class_under(state,
+ "CharArray", G(rubinius)));
G(chararray)->set_object_type(state, CharArrayType);
G(chararray)->name(state, state->symbol("Rubinius::CharArray"));
}
@@ -8,11 +8,13 @@
#include "builtin/lookuptable.hpp"
#include "builtin/symbol.hpp"
+#include "ontology.hpp"
+
#include <iostream>
namespace rubinius {
void CompactLookupTable::init(STATE) {
- GO(compactlookuptable).set(state->vm()->new_class("CompactLookupTable",
+ GO(compactlookuptable).set(ontology::new_class(state, "CompactLookupTable",
G(tuple), G(rubinius)));
G(compactlookuptable)->set_object_type(state, CompactLookupTableType);
G(compactlookuptable)->name(state, state->symbol("Rubinius::CompactLookupTable"));
@@ -29,6 +29,8 @@
#include "on_stack.hpp"
+#include "ontology.hpp"
+
#ifdef ENABLE_LLVM
#include "llvm/state.hpp"
#include "llvm/jit_compiler.hpp"
@@ -38,7 +40,8 @@
namespace rubinius {
void CompiledMethod::init(STATE) {
- GO(cmethod).set(state->vm()->new_class("CompiledMethod", G(executable), G(rubinius)));
+ GO(cmethod).set(ontology::new_class(state,
+ "CompiledMethod", G(executable), G(rubinius)));
G(cmethod)->set_object_type(state, CompiledMethodType);
G(cmethod)->name(state, state->symbol("Rubinius::CompiledMethod"));
}
View
@@ -7,10 +7,12 @@
#include "capi/capi.hpp"
+#include "ontology.hpp"
+
namespace rubinius {
void Data::init(STATE) {
- GO(data).set(state->vm()->new_class("Data", G(object)));
+ GO(data).set(ontology::new_class(state, "Data", G(object)));
G(data)->set_object_type(state, DataType);
}
View
@@ -10,12 +10,14 @@
#include "object_utils.hpp"
+#include "ontology.hpp"
+
#include <sys/types.h>
#include <dirent.h>
namespace rubinius {
void Dir::init(STATE) {
- GO(dir).set(state->vm()->new_class("Dir", G(object)));
+ GO(dir).set(ontology::new_class(state, "Dir", G(object)));
G(dir)->set_object_type(state, DirType);
}
View
@@ -8,6 +8,8 @@
#include "object_utils.hpp"
+#include "ontology.hpp"
+
#include <ctype.h>
extern OnigEncodingType OnigEncodingASCII;
@@ -17,10 +19,10 @@ namespace rubinius {
void Encoding::init(STATE) {
onig_init(); // in regexp.cpp too, but idempotent.
- Class* enc = state->vm()->new_class_under("Encoding", G(rubinius));
+ Class* enc = ontology::new_class_under(state, "Encoding", G(rubinius));
enc->name(state, state->symbol("Rubinius::Encoding"));
- GO(encoding).set(state->vm()->new_class_under("Encoding", enc));
+ GO(encoding).set(ontology::new_class_under(state, "Encoding", enc));
G(encoding)->set_object_type(state, EncodingType);
G(encoding)->name(state, state->symbol("Encoding"));
View
@@ -20,11 +20,13 @@
#include "configuration.hpp"
+#include "ontology.hpp"
+
#include <iostream>
namespace rubinius {
void Exception::init(STATE) {
- GO(exception).set(state->vm()->new_class("Exception", G(object)));
+ GO(exception).set(ontology::new_class(state, "Exception", G(object)));
G(exception)->set_object_type(state, ExceptionType);
}
@@ -12,10 +12,12 @@
#include "call_frame.hpp"
#include "objectmemory.hpp"
+#include "ontology.hpp"
+
namespace rubinius {
void Executable::init(STATE) {
- GO(executable).set(state->vm()->new_class("Executable", G(object), G(rubinius)));
+ GO(executable).set(ontology::new_class(state, "Executable", G(object), G(rubinius)));
G(executable)->set_object_type(state, ExecutableType);
G(executable)->name(state, state->symbol("Rubinius::Executable"));
}
@@ -30,13 +30,15 @@
#include "arguments.hpp"
#include "dispatch.hpp"
+#include "ontology.hpp"
+
#include "windows_compat.h"
namespace rubinius {
void Pointer::init(STATE) {
Module* ffi = as<Module>(G(object)->get_const(state, "FFI"));
- GO(ffi_pointer).set(state->vm()->new_class_under("Pointer", ffi));
+ GO(ffi_pointer).set(ontology::new_class_under(state, "Pointer", ffi));
G(ffi_pointer)->set_object_type(state, PointerType);
G(ffi_pointer)->set_const(state, "CURRENT_PROCESS",
View
@@ -16,6 +16,8 @@
#include "call_frame.hpp"
#include "arguments.hpp"
+#include "ontology.hpp"
+
#include "on_stack.hpp"
#ifdef FIBER_NATIVE
@@ -122,7 +124,7 @@ struct fiber_context_t {
namespace rubinius {
void Fiber::init(STATE) {
- GO(fiber).set(state->vm()->new_class("Fiber", G(object), G(rubinius)));
+ GO(fiber).set(ontology::new_class(state, "Fiber", G(object), G(rubinius)));
G(fiber)->set_object_type(state, FiberType);
#ifdef FIBER_ENABLED
View
@@ -10,12 +10,14 @@
#include "vm/object_utils.hpp"
#include "vm/configuration.hpp"
+#include "ontology.hpp"
+
#include <iostream>
namespace rubinius {
void Fixnum::init(STATE) {
- GO(fixnum_class).set(state->vm()->new_class("Fixnum", G(integer)));
+ GO(fixnum_class).set(ontology::new_class(state, "Fixnum", G(integer)));
G(fixnum_class)->set_object_type(state, FixnumType);
G(fixnum_class)->set_const(state, "MIN", Fixnum::from(FIXNUM_MIN));
View
@@ -10,6 +10,8 @@
#include "primitives.hpp"
#include "configuration.hpp"
+#include "ontology.hpp"
+
#include <gdtoa.h>
#include <string.h>
@@ -22,7 +24,7 @@
namespace rubinius {
void Float::init(STATE) {
- GO(floatpoint).set(state->vm()->new_class("Float", G(numeric)));
+ GO(floatpoint).set(ontology::new_class(state, "Float", G(numeric)));
G(floatpoint)->set_object_type(state, FloatType);
G(floatpoint)->set_const(state, "RADIX", Fixnum::from(FLT_RADIX));
@@ -2,10 +2,13 @@
#include "builtin/class.hpp"
#include "builtin/staticscope.hpp"
+#include "ontology.hpp"
+
namespace rubinius {
void GlobalCacheEntry::init(STATE) {
GO(global_cache_entry).set(
- state->vm()->new_class("GlobalCacheEntry", G(object), G(rubinius)));
+ ontology::new_class(state, "GlobalCacheEntry",
+ G(object), G(rubinius)));
}
GlobalCacheEntry* GlobalCacheEntry::create(STATE, Object *value,
View
@@ -38,14 +38,17 @@
#include "capi/handle.hpp"
+#include "ontology.hpp"
+
#include "windows_compat.h"
namespace rubinius {
void IO::init(STATE) {
- GO(io).set(state->vm()->new_class("IO", G(object)));
+ GO(io).set(ontology::new_class(state, "IO", G(object)));
G(io)->set_object_type(state, IOType);
- GO(iobuffer).set(state->vm()->new_class("InternalBuffer", G(object), G(io)));
+ GO(iobuffer).set(ontology::new_class(state, "InternalBuffer",
+ G(object), G(io)));
G(iobuffer)->set_object_type(state, IOBufferType);
}
View
@@ -2,11 +2,14 @@
#include "builtin/iseq.hpp"
#include "builtin/tuple.hpp"
+#include "ontology.hpp"
+
#include "vm.hpp"
namespace rubinius {
void InstructionSequence::init(STATE) {
- GO(iseq).set(state->vm()->new_class("InstructionSequence", G(object), G(rubinius)));
+ GO(iseq).set(ontology::new_class(state,
+ "InstructionSequence", G(object), G(rubinius)));
G(iseq)->set_object_type(state, InstructionSequenceType);
}
Oops, something went wrong.

0 comments on commit 380797f

Please sign in to comment.